Skip to content

Commit b8b3829

Browse files
authored
use ELPA_WITH_NVIDIA_GPU_VERSION to judge elpa setup gpu (#5163)
* use ELPA_WITH_NVIDIA_GPU_VERSION to judge elpa setup gpu * fix the doc * add some content in doc * replace header file * fix a elpa version 2011 bug * fix include to adopt early version elpa
1 parent 286cdc5 commit b8b3829

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

docs/advanced/acceleration/cuda.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ To compile and use ABACUS in CUDA mode, you currently need to have an NVIDIA GPU
2929

3030
Check the [Advanced Installation Options](https://abacus-rtd.readthedocs.io/en/latest/advanced/install.html#build-with-cuda-support) for the installation of CUDA version support.
3131

32-
When the compilation parameter USE_ELPA is ON (which is the default value) and USE_CUDA is also set to ON, the ELPA library needs to [enable GPU support](https://github.com/marekandreas/elpa/blob/master/documentation/INSTALL.md) at compile time.
32+
Setting both USE_ELPA and USE_CUDA to ON does not automatically enable ELPA to run on GPUs. ELPA support for GPUs needs to be enabled when ELPA is compiled. [enable GPU support](https://github.com/marekandreas/elpa/blob/master/documentation/INSTALL.md).
33+
34+
The ABACUS program will automatically determine whether the current ELPA supports GPU based on the elpa/elpa_configured_options.h header file. Users can also check this header file to determine the GPU support of ELPA in their environment. ELPA introduced a new API elpa_setup_gpu in version 2023.11.001. So if you want to enable ELPA GPU in ABACUS, the ELPA version must be greater than or equal to 2023.11.001.
3335

3436
## Run with the GPU support by editing the INPUT script:
3537

source/module_hsolver/diago_elpa_native.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,17 @@ void DiagoElpaNative<T>::diag_pool(hamilt::MatrixBlock<T>& h_mat,
9595
elpa_setup(handle);
9696
elpa_set(handle, "solver", ELPA_SOLVER_1STAGE, &success);
9797

98-
#ifdef __CUDA
98+
/* ELPA_WITH_NVIDIA_GPU_VERSION is a symbol defined in elpa/elpa_configured_options.h
99+
For example:
100+
cat elpa/elpa_configured_options.h
101+
#define ELPA_WITH_NVIDIA_GPU_VERSION 1
102+
#define ELPA_WITH_AMD_GPU_VERSION 0
103+
#define ELPA_WITH_SYCL_GPU_VERSION 0
104+
*/
105+
#if ELPA_WITH_NVIDIA_GPU_VERSION
99106
if (PARAM.globalv.device_flag == "gpu")
100107
{
101108
elpa_set(handle, "nvidia-gpu", 1, &success);
102-
103109
elpa_set(handle, "real_kernel", ELPA_2STAGE_REAL_NVIDIA_GPU, &success);
104110
elpa_setup_gpu(handle);
105111
}

source/module_hsolver/genelpa/elpa_new.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
#include <elpa/elpa_version.h>
44

5+
6+
57
#if ELPA_API_VERSION >= 20221101
68
#include <elpa/elpa.h>
79
#else
@@ -25,8 +27,16 @@ extern "C"
2527
#include <elpa/elpa_generated.h>
2628
// #include <elpa/elpa_generic.h>
2729
#undef complex
30+
2831
const char *elpa_strerr(int elpa_error);
32+
33+
// This is a header file related to GPU support.
34+
// This header file was not available in the early ELPA.
35+
#if ELPA_API_VERSION >= 20231101
36+
#include <elpa/elpa_configured_options.h>
37+
#endif
2938
}
3039

40+
3141
#include "elpa_generic.hpp" // This is a wrapper for `elpa/elpa_generic.h`.
3242
#endif

0 commit comments

Comments
 (0)