Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
arbor
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Analyze
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
arbor-sim
arbor
Commits
db887a9e
Unverified
Commit
db887a9e
authored
2 years ago
by
Thorsten Hater
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Expose find_private_gpu to python (#1943)
* Add find_private_gpu and arbor.env.
parent
de83a0fa
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
doc/python/hardware.rst
+14
-0
14 additions, 0 deletions
doc/python/hardware.rst
python/CMakeLists.txt
+1
-0
1 addition, 0 deletions
python/CMakeLists.txt
python/env.cpp
+35
-0
35 additions, 0 deletions
python/env.cpp
python/pyarb.cpp
+2
-0
2 additions, 0 deletions
python/pyarb.cpp
with
52 additions
and
0 deletions
doc/python/hardware.rst
+
14
−
0
View file @
db887a9e
...
...
@@ -68,6 +68,20 @@ Helper functions for checking cmake or environment variables, as well as configu
Check if MPI is finalized.
Env: Helper functions
---------------------
The ``arbor.env`` module collects helper functions for interacting with the environment.
.. function:: find_private_gpu(comm)
Requires GPU and MPI. Will return an integer id of a GPU such that each GPU
is mapped to at most one MPI task (on the same node as the GPU). Raises an
exception if
- not built with GPU or MPI support
- unable to satisfy the constraints above
- handed an invalid or unknown MPI communicator object
Prescribed resources
---------------------
...
...
This diff is collapsed.
Click to expand it.
python/CMakeLists.txt
+
1
−
0
View file @
db887a9e
...
...
@@ -38,6 +38,7 @@ set(pyarb_source
schedule.cpp
simulation.cpp
single_cell_model.cpp
env.cpp
)
# compile the pyarb sources into an object library that will be
...
...
This diff is collapsed.
Click to expand it.
python/env.cpp
0 → 100644
+
35
−
0
View file @
db887a9e
#include
<pybind11/pybind11.h>
#include
<arborenv/gpu_env.hpp>
#include
"mpi.hpp"
#include
"error.hpp"
namespace
pyarb
{
void
register_arborenv
(
pybind11
::
module
&
m
)
{
auto
s
=
m
.
def_submodule
(
"env"
,
"Wrappers for arborenv."
);
s
.
def
(
"find_private_gpu"
,
[]
(
pybind11
::
object
mpi
)
{
#ifndef ARB_GPU_ENABLED
throw
pyarb_error
(
"Private GPU: Arbor is not configured with GPU support."
);
#else
#ifndef ARB_MPI_ENABLED
throw
pyarb_error
(
"Private GPU: Arbor is not configured with MPI."
);
#else
auto
err
=
""
Private
GPU
:
Invalid
MPI
Communicator
.
""
;
if
(
can_convert_to_mpi_comm
(
mpi
))
{
return
arbenv
::
find_private_gpu
(
can_convert_to_mpi_comm
(
mpi
));
}
else
if
(
auto
c
=
py2optional
<
mpi_comm_shim
>
(
mpi
,
err
))
{
return
arbenv
::
find_private_gpu
(
c
->
comm
);
}
else
{
throw
pyarb_error
(
err
);
}
#endif
#endif
},
"Identify a private GPU id per node, only available if built with GPU and MPI.
\n
"
" mpi: The MPI communicator."
);
}
}
This diff is collapsed.
Click to expand it.
python/pyarb.cpp
+
2
−
0
View file @
db887a9e
...
...
@@ -29,6 +29,7 @@ void register_recipe(pybind11::module& m);
void
register_schedules
(
pybind11
::
module
&
m
);
void
register_simulation
(
pybind11
::
module
&
m
,
pyarb_global_ptr
);
void
register_single_cell
(
pybind11
::
module
&
m
);
void
register_arborenv
(
pybind11
::
module
&
m
);
#ifdef ARB_MPI_ENABLED
void
register_mpi
(
pybind11
::
module
&
m
);
...
...
@@ -61,6 +62,7 @@ PYBIND11_MODULE(_arbor, m) {
pyarb
::
register_schedules
(
m
);
pyarb
::
register_simulation
(
m
,
global_ptr
);
pyarb
::
register_single_cell
(
m
);
pyarb
::
register_arborenv
(
m
);
// This is the fallback. All specific translators take precedence by being
// registered *later*.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment