Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion source/module_hamilt_lcao/module_gint/gint_force_gpu.cu
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#ifdef _OPENMP
#include <omp.h>
#endif

#include "gint_force_gpu.h"
#include "kernels/cuda/cuda_tools.cuh"
Expand Down Expand Up @@ -87,16 +89,21 @@ void gint_fvl_gpu(const hamilt::HContainer<double>* dm,
dm->get_wrapper(),
dm->get_nnr() * sizeof(double),
cudaMemcpyHostToDevice));

#ifdef _OPENMP
#pragma omp parallel for num_threads(num_streams) collapse(2)
#endif
for (int i = 0; i < gridt.nbx; i++)
{
for (int j = 0; j < gridt.nby; j++)
{
// 20240620 Note that it must be set again here because
// cuda's device is not safe in a multi-threaded environment.
checkCuda(cudaSetDevice(gridt.dev_id));
#ifdef _OPENMP
const int sid = omp_get_thread_num();
#else
const int sid = 0;
#endif

int max_m = 0;
int max_n = 0;
Expand Down
8 changes: 8 additions & 0 deletions source/module_hamilt_lcao/module_gint/gint_rho_gpu.cu
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
#include "gint_tools.h"
#include "kernels/cuda/gint_rho.cuh"

#ifdef _OPENMP
#include <omp.h>
#endif

namespace GintKernel
{
Expand Down Expand Up @@ -68,7 +70,9 @@ void gint_rho_gpu(const hamilt::HContainer<double>* dm,
cudaMemcpyHostToDevice));

// calculate the rho for every nbzp bigcells
#ifdef _OPENMP
#pragma omp parallel for num_threads(num_streams) collapse(2)
#endif
for (int i = 0; i < gridt.nbx; i++)
{
for (int j = 0; j < gridt.nby; j++)
Expand All @@ -78,7 +82,11 @@ void gint_rho_gpu(const hamilt::HContainer<double>* dm,

checkCuda(cudaSetDevice(gridt.dev_id));
// get stream id
#ifdef _OPENMP
const int sid = omp_get_thread_num();
#else
const int sid = 0;
#endif

int max_m = 0;
int max_n = 0;
Expand Down
8 changes: 8 additions & 0 deletions source/module_hamilt_lcao/module_gint/gint_vl_gpu.cu
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#ifdef _OPENMP
#include <omp.h>
#endif

#include "kernels/cuda/cuda_tools.cuh"
#include "module_base/ylm.h"
Expand Down Expand Up @@ -71,15 +73,21 @@ void gint_vl_gpu(hamilt::HContainer<double>* hRGint,
Cuda_Mem_Wrapper<double*> gemm_B(max_atompair_per_z, num_streams, true);
Cuda_Mem_Wrapper<double*> gemm_C(max_atompair_per_z, num_streams, true);

#ifdef _OPENMP
#pragma omp parallel for num_threads(num_streams) collapse(2)
#endif
for (int i = 0; i < gridt.nbx; i++)
{
for (int j = 0; j < gridt.nby; j++)
{
// 20240620 Note that it must be set again here because
// cuda's device is not safe in a multi-threaded environment.
checkCuda(cudaSetDevice(gridt.dev_id));
#ifdef _OPENMP
const int sid = omp_get_thread_num();
#else
const int sid = 0;
#endif

int max_m = 0;
int max_n = 0;
Expand Down