版本: Open MPI 3.0.1编译好可执行的C语言程序后,使用 mpirun -np 3 Test 命令,发现没有正常运行,而是报错:There are not enough slots available in the system to satisfy the 3 slotsthat were requested by the application: /home/. Slots that were requested by the application' it means you have been allocated one resource on the given openmpi 'there are not enough slots available in the, please be aware that there are no schools or application preparation organizations that are affiliated with or agents of cslb, although some may have company.
Why does openmpi think only 2 slots are available when in fact 4 processors are available? As per the ark.intel.com page for this CPU 1: # of Cores 2 # of Threads 4 So openmpi seems to be (correctly, IMHO) counting cores here, rather than threads. There are not enough slots available in the system to satisfy the 2 slots that were requested by the application. Bugs and config available.
HiContributions and bug reports are welcome from anyone! Some of the bestfeatures in h5py, including thread support, dimension scales, and thescale-offset filter, came from user code contributions.
Since we use GitHub, the workflow will be familiar to many people.If you have questions about the process or about the details of implementingyour feature, always feel free to ask on the Google Groups list, eitherby emailing:
or via the web interface at:
Anyone can post to this list. Your first message will be approved by amoderator, so don’t worry if there’s a brief delay.
This guide is divided into three sections. The first describes how to filea bug report.
The second describes the mechanics ofhow to submit a contribution to the h5py project; for example, how tocreate a pull request, which branch to base your work on, etc.We assume you’re are familiar with Git, the version control system used by h5py.If not, here’s a great place to start.
Finally, we describe the various subsystems inside h5py, and givetechnical guidance as to how to implement your changes.
Bug reports are always welcome! The issue tracker is at:
Always feel free to ask on the mailing list (h5py at Google Groups).Discussions there are seen by lots of people and are archived by Google.Even if the issue you’re having turns out not to be a bug in the end, otherpeople can benefit from a record of the conversation.
By the way, nobody will get mad if you file a bug and it turns out to besomething else. That’s just how software development goes.
When filing a bug, there are two things you should include. The first isthe output of h5py.version.info
:
The second is a detailed explanation of what went wrong. Unless the bugis really trivial, include code if you can, either via GitHub’sinline markup:
or by uploading a code sample to Github Gist.
This section describes how to contribute changes to the h5py code base.Before you start, be sure to read the h5py license and contributoragreement in “license.txt”. You can find this in the source distribution,or view it online at the main h5py repository at GitHub.
The basic workflow is to clone h5py with git, make your changes in a topicbranch, and then create a pull request at GitHub asking to merge the changesinto the main h5py project.
Here are some tips to getting your pull requests accepted:
The best way to do this is by signing in to GitHub and cloning theh5py project directly. You’ll end up with a new repository under youraccount; for example, if your username is yourname
, the repositorywould be at http://github.com/yourname/h5py.
Then, clone your new copy of h5py to your local machine:
Check out a new branch for the bugfix or feature you’re writing:
The exact name of the branch can be anything you want. For bug fixes, oneapproach is to put the issue number in the branch name.
We develop all changes against the master branch.If we’re making a bugfix release, a bot will backport merged pull requests.
You can implement the feature as a number of small changes, or as one bigcommit; there’s no project policy. Double-check to make sure you’veincluded all your files; run gitstatus
and check the output.
The easiest way to run the tests is withtox:
Changes which could affect people building and using h5py after the next releaseshould have a news entry. You don’t need to do this if your changes don’t affectusage, e.g. adding tests or correcting comments.
In the news/
folder, make a copy of TEMPLATE.rst
named after your branch.Edit the new file, adding a sentence or two about what you’ve added or fixed.Commit this to git too.
News entries are merged into the what’s new documentsfor each release. They should allow someone to quickly understand what a newfeature is, or whether a bug they care about has been fixed. E.g.:
The Building h5py section is for changes which affect how people build h5pyfrom source. It’s not about how we make prebuilt wheels; changes to that whichmake a visible difference can go in New features or Bug fixes.
If it’s your first time to contribute to this project, you should add yourself intoauthor list and follow the format below:
Push your topic branch back up to your GitHub clone:
Then, create a pull request based on your topic branch.
Your pull request might be accepted right away. More commonly, the maintainerswill post comments asking you to fix minor things, like add a few tests, cleanup the style to be PEP-8 compliant, etc.
The pull request page also shows the results of building and testing themodified code on Travis and Appveyor CI and Azure Pipelines.Check back after about 30 minutes to see if the build succeeded,and if not, try to modify your changes to make it work.
When making changes after creating your pull request, just add commits toyour topic branch and push them to your GitHub repository. Don’t try torebase or open a new pull request! We don’t mind having a few extracommits in the history, and it’s helpful to keep all the history togetherin one place.
This section is a little more involved, and provides tips on how to modifyh5py. The h5py package is built in layers. Starting from the bottom, theyare:
api_gen.py
)h5py.File
.Rather than talk about the layers in an abstract way, the parts below areguides to adding specific functionality to various parts of h5py.Most sections span at least two or three of these layers.
This is one of the most common contributed changes. The example below showshow one would add the function H5Dget_storage_size
,which determines the space on disk used by an HDF5 dataset. This functionis already partially wrapped in h5py, so you can see how it works.
It’s recommended thatyou follow along, if not by actually adding the feature then by at leastopening the various files as we work through the example.
First, get ahold ofthe function signature; the easiest place for this is at the onlineHDF5 Reference Manual.Then, add the function’s C signature to the file api_functions.txt
:
This particular signature uses types (hsize_t
, hid_t
) which are alreadydefined elsewhere. But ifthe function you’re adding needs a struct or enum definition, you canadd it using Cython code to the file api_types_hdf5.pxd
.
The next step is to add a Cython function or method which calls the functionyou added. The h5py modules follow the naming conventionof the C API; functions starting with H5D
are wrapped in h5d.pyx
.
Opening h5d.pyx
, we notice that since this function takes a datasetidentifier as the first argument, it belongs as a method on the DatasetIDobject. We write a wrapper method:
The first line of the docstring gives the method signature.This is necessary because Cython will use a “generic” signature likemethod(*args,**kwds)
when the file is compiled. The h5py documentationsystem will extract the first line and use it as the signature.
Next, we decide whether we want to add access to this function to thehigh-level interface. That means users of the top-level h5py.Dataset
object will be able to see how much space on disk their files use. Thehigh-level interface is implemented in the subpackage h5py._hl
, andthe Dataset object is in module dataset.py
. Opening it up, we adda property on the Dataset
object:
You’ll see that the low-level DatasetID
object is available on thehigh-level Dataset
object as obj.id
. This is true of all thehigh-level objects, like File
and Group
as well.
Finally (and don’t skip this step), we write unit tests for this feature.Since the feature is ultimately exposed at the high-level interface, it’s OKto write tests for the Dataset.storagesize
property only. Unit tests forthe high-level interface are located in the “tests” subfolder, right neardataset.py
.
It looks like the right file is test_dataset.py
. Unit tests areimplemented as methods on custom unittest.UnitTest
subclasses;each new feature should be tested by its own new class. In thetest_dataset
module, we see there’s already a subclass calledBaseDataset
, which implements some simple set-up and cleanup methods andprovides a h5py.File
object as obj.f
. We’ll base our test class onthat:
This set of tests would be adequate to get a pull request approved. We don’ttest every combination under the sun (different ranks, datasets with morethan 2**32 elements, datasets with the string “kumquat” in the name…), butthe basic, commonly encountered set of conditions.
To build and test our changes, we have to do a few things. First of all,run the file api_gen.py
to re-generate the Cython wrappers fromapi_functions.txt
:
Then build the project, which recompiles h5d.pyx
:
Finally, run the test suite, which includes the two methods we just wrote:
If the tests pass, the feature is ready for a pull request.
At the moment, h5py must be backwards-compatible all the way back toHDF5 1.8.4. Starting with h5py 2.2.0, it’s possible to conditionallyinclude functions which only appear in newer versions of HDF5. It’s alsopossible to mark functions which require Parallel HDF5. For example, thefunction H5Fset_mpi_atomicity
was introduced in HDF5 1.8.9 and requiresParallel HDF5. Specifiers before the signature in api_functions.txt
communicate this:
You can specify either, both or none of “MPI” or a version number in “X.Y.Z”format.
In the Cython code, these show up as “preprocessor” defines MPI
andHDF5_VERSION
. So the low-level implementation (as a method onh5py.h5f.FileID
) looks like this:
High-level code can check the version of the HDF5 library, or check to see ifthe method is present on FileID
objects.
Typically to run code under MPI, mpirun
must be used to start the MPIprocesses. Similarly, tests using MPI features (such as collective IO), mustalso be run under mpirun
. h5py uses pytest markers (specificallypytest.mark.mpi
and other markers frompytest-mpi) to specify which testsrequire usage of mpirun
, and will handle skipping the tests as needed. Asimple example of how to do this is:
To run these tests, you’ll need to:
tox
installed (e.g. via pipinstalltox
)Then running:
should run the tests. You may need to pass HDF5_DIR
depending on thelocation of the HDF5 with MPI support. You can choose which python version tobuild against by changing py37 (e.g. py36 runs python 3.6, this is a toxfeature), and test with the minimum version requirements by using mindeps
rather than deps
.
If you get an error similar to:
then you need to reduce the number of MPI processes you are asking MPI to use.If you have already reduced the number of processes requested (or are runningthe default number which is 2), you will need to look up the documentation foryour MPI implementation for handling this error. On OpenMPI (which is usuallythe default MPI implementation on most systems), running:
will instruct OpenMPI to allow more MPI processes than available cores on yoursystem.
If you need to pass additional environment variables to your MPI implementation,add these variables to the passenv
setting in the tox.ini
, and send us a PRwith that change noting the MPI implementation.