New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
gpu_manager.F90 in NEMO/branches/2020/dev_r13747_HPC-10_HPDAonline_DiagGPU/tests/DIA_GPU/MY_SRC – NEMO

source: NEMO/branches/2020/dev_r13747_HPC-10_HPDAonline_DiagGPU/tests/DIA_GPU/MY_SRC/gpu_manager.F90 @ 14091

Last change on this file since 14091 was 14091, checked in by mcastril, 4 years ago

Add DIA_GPU test case

File size: 1.8 KB
Line 
1#ifdef key_gpu
2MODULE gpu_manager
3    USE lib_mpp        ! distributed memory computing library
4    USE cudafor
5    USE par_oce
6    !!======================================================================
7    !!                       ***  MODULE  gpu_manager  ***
8    !! GPU CUDA utilities : Defines run parameters for GPGPU routines
9    !!=====================================================================
10    !! History :   1.0  !  2019-10  (M. Faria)   original code
11    !!----------------------------------------------------------------------
12
13    !!----------------------------------------------------------------------
14    IMPLICIT NONE
15    PUBLIC
16    !!----------------------------------------------------------------------
17    !!                   gpu configuration parameters
18    !!----------------------------------------------------------------------
19    INTEGER          :: cudaistat, usecudev
20    INTEGER          :: nodesize
21    INTEGER          :: cudadev
22    INTEGER          :: cusocket
23CONTAINS
24    SUBROUTINE setdevice()
25        nodesize  = 1                                                    !Node number of MPI processes, CTE-Power default 40
26        cusocket  = 1                                                    !Number of NVlink or PCI-E nodes, CTE-Power default 2
27        cudadev   = 1                                                    !Number of GPUs on a node, CTE-Power default 4
28        usecudev  = MOD( mpprank /  ( nodesize / cusocket )  , cudadev ) !Bind MPI RANK to GPU, consider balanced NVlink and constant number of devices per node
29        cudaistat = cudaSetDevice( usecudev  )                           !Set which GPU use. Ex for 4 GPUs. cpus_per_socket / sockets_per_node for "bind-to core"
30        print *, 'CUDA istat ', cudaistat, 'rank', mpprank, 'cuda device', cudadev 
31    END SUBROUTINE setdevice
32
33END MODULE gpu_manager
34#endif
Note: See TracBrowser for help on using the repository browser.