(git:3f0d10b)
Loading...
Searching...
No Matches
nnp_gpu Module Reference

GPU offload driver for the NNP force evaluation. Hosts the ISO_C_BINDING interfaces to the CUDA launchers in src/nnp/gpu/ and the whole-step device pipeline called from nnp_force. All GPU entry points compile to inert stubs unless the build enables the NNP GPU backend (__OFFLOAD without __NO_OFFLOAD_NNP). More...

Functions/Subroutines

logical function, public nnp_gpu_available ()
 Report whether the NNP GPU backend can run: the build must enable it and at least one offload device must be visible. Builds without the backend always report .FALSE., so USE_GPU AUTO resolves to the CPU path there.
subroutine, public nnp_gpu_init_device (gpu_precision, accepted)
 Claim the offload device for this NNP environment and push the requested compute precision to the device side.
logical function, public nnp_gpu_model_capacity_ok (nnp, reason)
 Test whether the model fits the compiled-in device-table capacities: NNP_MAX_SE (group, element) slots per symmetry-function kind, and NNP_SPLINE_CACHE_MAX run-constant parameter tables, of which each radial group holds two (spline values and derivatives) and each angular group four (the packed parameter tables). Called before the device is claimed, so an oversized model is turned away before any upload rather than in the first force evaluation.
subroutine, public nnp_gpu_upload_descriptor_statics (nnp)
 Upload the model-static descriptor tables to the device once at NNP initialization: the per-element symmetry-function scaling parameters (average, minimum, maximum, sigma) and the per-(group, element) symmetry-function to descriptor-row maps. Both are immutable after the input parse, so the device copies are valid for the whole environment lifetime and the per-step descriptor kernels read them without any further host-to-device traffic.
subroutine, public nnp_gpu_upload_network (nnp)
 Upload the committee network to the device once at NNP initialization: the per-element layer topology, the shared activation-function codes, the per-element atomic reference energies and the packed per-committee weights and biases. These are immutable after the weights are read, so the device copies serve every MD step and the per-step network launcher needs no further weight traffic. The weights and biases are packed into zero-padded max_n_nodes-wide slabs so a single stride addresses every (element, layer, committee) block regardless of that block's true size.
subroutine, public nnp_gpu_energy_force (nnp, istart, mecalc, n_input_max, calc_stress)
 Run the whole per-step NNP force evaluation on the device: the cell-list walk, the descriptor build, the committee network and the force scatter, in that order. The walk builds the device neighbour lists, the descriptor build fills the scaled device descriptor, the network fills nnpatomic_energy and leaves its descriptor gradient on the device, and the scatter multiplies that gradient by the descriptor derivatives and reads the total forces back into nnpmyforce. The scatter accumulator is seeded from nnpmyforce, which the caller has zeroed, so on return it holds the complete NNP forces for this window.

Detailed Description

GPU offload driver for the NNP force evaluation. Hosts the ISO_C_BINDING interfaces to the CUDA launchers in src/nnp/gpu/ and the whole-step device pipeline called from nnp_force. All GPU entry points compile to inert stubs unless the build enables the NNP GPU backend (__OFFLOAD without __NO_OFFLOAD_NNP).

Author
Dhruv Sharma (ds217.nosp@m.3@ca.nosp@m.m.ac..nosp@m.uk)

Function/Subroutine Documentation

◆ nnp_gpu_available()

logical function, public nnp_gpu::nnp_gpu_available

Report whether the NNP GPU backend can run: the build must enable it and at least one offload device must be visible. Builds without the backend always report .FALSE., so USE_GPU AUTO resolves to the CPU path there.

Returns
.TRUE. when the GPU code path is usable on this rank

Definition at line 380 of file nnp_gpu.F.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nnp_gpu_init_device()

subroutine, public nnp_gpu::nnp_gpu_init_device ( integer, intent(in) gpu_precision,
logical, intent(out) accepted )

Claim the offload device for this NNP environment and push the requested compute precision to the device side.

The device itself is chosen once per process at startup (see f77_interface), which is also the id DBCSR is given; this routine only activates it, exactly as every other CP2K offload consumer does. Re-selecting here would leave the two out of step for the rest of the run.

Parameters
gpu_precisionresolved GPU_PRECISION keyword value
accepted.FALSE. when another NNP environment already holds the device, in which case nothing was initialized and the caller must fall back to the CPU path

Definition at line 406 of file nnp_gpu.F.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nnp_gpu_model_capacity_ok()

logical function, public nnp_gpu::nnp_gpu_model_capacity_ok ( type(nnp_type), intent(in), pointer nnp,
character(len=*), intent(out) reason )

Test whether the model fits the compiled-in device-table capacities: NNP_MAX_SE (group, element) slots per symmetry-function kind, and NNP_SPLINE_CACHE_MAX run-constant parameter tables, of which each radial group holds two (spline values and derivatives) and each angular group four (the packed parameter tables). Called before the device is claimed, so an oversized model is turned away before any upload rather than in the first force evaluation.

Parameters
nnpthe NNP environment with its radial and angular groups populated
reasonon a .FALSE. result, a phrase naming the exceeded capacity
Returns
.TRUE. when the model fits the device tables

Definition at line 463 of file nnp_gpu.F.

Here is the caller graph for this function:

◆ nnp_gpu_upload_descriptor_statics()

subroutine, public nnp_gpu::nnp_gpu_upload_descriptor_statics ( type(nnp_type), intent(in), pointer nnp)

Upload the model-static descriptor tables to the device once at NNP initialization: the per-element symmetry-function scaling parameters (average, minimum, maximum, sigma) and the per-(group, element) symmetry-function to descriptor-row maps. Both are immutable after the input parse, so the device copies are valid for the whole environment lifetime and the per-step descriptor kernels read them without any further host-to-device traffic.

Parameters
nnpthe NNP environment, with its radial and angular groups populated

Definition at line 773 of file nnp_gpu.F.

Here is the caller graph for this function:

◆ nnp_gpu_upload_network()

subroutine, public nnp_gpu::nnp_gpu_upload_network ( type(nnp_type), intent(in), pointer nnp)

Upload the committee network to the device once at NNP initialization: the per-element layer topology, the shared activation-function codes, the per-element atomic reference energies and the packed per-committee weights and biases. These are immutable after the weights are read, so the device copies serve every MD step and the per-step network launcher needs no further weight traffic. The weights and biases are packed into zero-padded max_n_nodes-wide slabs so a single stride addresses every (element, layer, committee) block regardless of that block's true size.

Parameters
nnpthe NNP environment, with its architecture and committee weights already read

Definition at line 1113 of file nnp_gpu.F.

Here is the caller graph for this function:

◆ nnp_gpu_energy_force()

subroutine, public nnp_gpu::nnp_gpu_energy_force ( type(nnp_type), intent(inout), pointer nnp,
integer, intent(in) istart,
integer, intent(in) mecalc,
integer, intent(in) n_input_max,
logical, intent(in) calc_stress )

Run the whole per-step NNP force evaluation on the device: the cell-list walk, the descriptor build, the committee network and the force scatter, in that order. The walk builds the device neighbour lists, the descriptor build fills the scaled device descriptor, the network fills nnpatomic_energy and leaves its descriptor gradient on the device, and the scatter multiplies that gradient by the descriptor derivatives and reads the total forces back into nnpmyforce. The scatter accumulator is seeded from nnpmyforce, which the caller has zeroed, so on return it holds the complete NNP forces for this window.

Parameters
nnpthe NNP environment; nnpatomic_energy and nnpmyforce are filled
istartfirst rank-local atom (1-based, global index)
mecalcnumber of rank-local atoms
n_input_maxdescriptor-row stride of the device descriptor (max over elements of the network input-layer width)
calc_stress.TRUE. when the caller wants the analytic virial, which the force-scatter kernels then accumulate alongside the forces

Definition at line 1317 of file nnp_gpu.F.

Here is the caller graph for this function: