Functionality to choose accelerator device (GPU)
When PARALLAX is compiled stand-alone, get_device_count always returns
1 (i.e. the CPU), and set_device_id is a sanity check confirming that
it's called with id 0.
When PARALLAX is linked to the PAccX library, these
subroutines are simple wrappers around
paccx_solver_get_device_count and
paccx_solver_set_device.
In turn, PAccX may be linked to different backends.
As of 2025-03-14 a CXX (i.e. CPU) backend is always present, and an
optional GPU backend is also available (CUDA or HIP, chosen at CMake
configure time).
Note: these subroutines control the global device settings of the
calling process/thread.
If your code links against PARALLAX and another accelerator-capable
library, please test thoroughly and ensure the code behaves as desired.
| enumerator | :: | BACKEND_CPU | = | 0 | |
| enumerator | :: | BACKEND_GPU | = | 1 | |
| enumerator | :: | BACKEND_ROCALUTION_CPU | = | 2 | |
| enumerator | :: | BACKEND_ROCALUTION_GPU | = | 3 |
Enumerator defining the backends
These values MUST agree with the corresponding enum in
paccx.hxx from PAccX
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=c_int32_t), | intent(in) | :: | backend | |||
| integer(kind=c_int32_t), | intent(out) | :: | count |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=c_int32_t), | intent(in) | :: | backend | |||
| integer(kind=c_int32_t), | intent(in) | :: | device_id |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=c_int32_t), | intent(in) | :: | backend |
Get the number of available devices for the backend specified.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | backend |
Backend to use. Should be one of * BACKEND_CPU * BACKEND_GPU |
||
| integer, | intent(out) | :: | count |
Number of available devices |
Given a specific backend, set the device to use
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | backend |
Backend to use. Should be one of * BACKEND_CPU * BACKEND_GPU |
||
| integer, | intent(in) | :: | device_id |
Desired device id to use.
If there are |
Assign devices to MPI ranks in order. Only works if number of ranks is greater or equal to number of devices Device assigned to rank rr is (rr modulo total_number_of_devices).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | object_type |
Object type. For now this means "solver_type". |
Get the number of available devices for the backend specified.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | backend |
Backend to use. Should be one of * BACKEND_CPU * BACKEND_GPU |