Skip to content

Commit 2acab4b

Browse files
committed
limit max threads
1 parent b3b948c commit 2acab4b

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

source/module_hamilt_lcao/module_gint/gint_force_gpu.cu

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,10 @@ void gint_fvl_gpu(const hamilt::HContainer<double>* dm,
9292
dm->get_nnr() * sizeof(double),
9393
cudaMemcpyHostToDevice));
9494

95-
#pragma omp parallel num_threads(num_streams)
95+
#ifdef _OPENMP
96+
const int max_thread_num = std::min(omp_get_max_threads(), num_streams);
97+
#endif
98+
#pragma omp parallel num_threads(max_thread_num)
9699
{
97100
#ifdef _OPENMP
98101
const int tid = omp_get_thread_num();

source/module_hamilt_lcao/module_gint/gint_rho_gpu.cu

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ void gint_rho_gpu(const hamilt::HContainer<double>* dm,
7272
cudaMemcpyHostToDevice));
7373

7474
// calculate the rho for every nbzp bigcells
75-
#pragma omp parallel num_threads(num_streams)
75+
#ifdef _OPENMP
76+
const int max_thread_num = std::min(omp_get_max_threads(), num_streams);
77+
#endif
78+
#pragma omp parallel num_threads(max_thread_num)
7679
{
7780
#ifdef _OPENMP
7881
const int tid = omp_get_thread_num();

source/module_hamilt_lcao/module_gint/gint_vl_gpu.cu

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@ void gint_vl_gpu(hamilt::HContainer<double>* hRGint,
7474
Cuda_Mem_Wrapper<double*> gemm_B(max_atompair_per_z, num_streams, true);
7575
Cuda_Mem_Wrapper<double*> gemm_C(max_atompair_per_z, num_streams, true);
7676

77-
#pragma omp parallel num_threads(num_streams)
77+
#ifdef _OPENMP
78+
const int max_thread_num = std::min(omp_get_max_threads(), num_streams);
79+
#endif
80+
#pragma omp parallel num_threads(max_thread_num)
7881
{
7982
#ifdef _OPENMP
8083
const int tid = omp_get_thread_num();

0 commit comments

Comments
 (0)