Skip to content

Commit

Permalink
Merge pull request #19 from PabloPalaciosAlonso/v2.x
Browse files Browse the repository at this point in the history
New cuda functions defines
  • Loading branch information
RaulPPelaez authored Jul 11, 2023
2 parents 35f8902 + 1476947 commit d385ab3
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/Integrator/BDHI/BDHI_Cholesky.cu
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ namespace uammd{
//Curand fill with gaussian numbers with mean 0 and var 1
/*This shit is obscure, curand will only work with an even number of elements*/
auto d_noise = thrust::raw_pointer_cast(noise.data());
curandGenerateNormal(curng, d_noise, 3*numberParticles + ((3*numberParticles)%2), real(0.0), real(1.0));
curandgeneratenormal(curng, d_noise, 3*numberParticles + ((3*numberParticles)%2), real(0.0), real(1.0));
isMup2date = false;
}

Expand Down Expand Up @@ -219,7 +219,7 @@ namespace uammd{
3*numberParticles, d_M, 3*numberParticles, d_work, h_work_size, d_info));
curandSetStream(curng, st);
/*Gen new noise in BdW*/
curandGenerateNormal(curng,
curandgeneratenormal(curng,
(real*) BdW,
3*numberParticles + ((3*numberParticles)%2),
real(0.0), real(1.0));
Expand Down
6 changes: 3 additions & 3 deletions src/Integrator/BDHI/BDHI_Lanczos.cu
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ namespace uammd{
thrust::device_vector<real> noise(30000);
auto noise_ptr = thrust::raw_pointer_cast(noise.data());
//Warm cuRNG
curandGenerateNormal(curng, noise_ptr, noise.size(), 0.0, 1.0);
curandGenerateNormal(curng, noise_ptr, noise.size(), 0.0, 1.0);
curandgeneratenormal(curng, noise_ptr, noise.size(), 0.0, 1.0);
curandgeneratenormal(curng, noise_ptr, noise.size(), 0.0, 1.0);
}

namespace Lanczos_ns{
Expand Down Expand Up @@ -172,7 +172,7 @@ namespace uammd{
Lanczos_ns::Dotctor<real3> Mdot(rpy, this->hydrodynamicRadius, radius_ptr, nbody, st);
//Filling V instead of an external array (for v in sqrt(M)·v) is faster
uninitialized_cached_vector<real3> noise(numberParticles);
curandGenerateNormal(curng, (real*)noise.data().get(),
curandgeneratenormal(curng, (real*)noise.data().get(),
3*numberParticles + (3*numberParticles)%2,
real(0.0), real(1.0));
//lanczosAlgorithm->solve(Mdot, (real*) BdW, noise, numberParticles, st);
Expand Down
10 changes: 5 additions & 5 deletions src/Integrator/BDHI/FIB/FIB.cu
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ namespace uammd{
thrust::device_vector<real> noise(30000);
auto noise_ptr = thrust::raw_pointer_cast(noise.data());
//Warm cuRNG
CurandSafeCall(curandGenerateNormal(curng, noise_ptr, noise.size(), 0.0, 1.0));
CurandSafeCall(curandGenerateNormal(curng, noise_ptr, noise.size(), 0.0, 1.0));
CurandSafeCall(curandgeneratenormal(curng, noise_ptr, noise.size(), 0.0, 1.0));
CurandSafeCall(curandgeneratenormal(curng, noise_ptr, noise.size(), 0.0, 1.0));
}
catch(thrust::system_error &e){
sys->log<System::CRITICAL>("[BDHI::FIB] Thrust could not allocate necessary arrays at initialization with error: %s", e.what());
Expand Down Expand Up @@ -871,7 +871,7 @@ namespace uammd{
sys->log<System::DEBUG2>("[BDHI::FIB] Random advection");
if(temperature!=real(0.0)){
sys->log<System::DEBUG2>("[BDHI::FIB] Generate random numbers");
CurandSafeCall(curandGenerateNormal(curng,
CurandSafeCall(curandgeneratenormal(curng,
thrust::raw_pointer_cast(random.data()),
random.size(),
0.0, 1.0));
Expand Down Expand Up @@ -906,7 +906,7 @@ namespace uammd{
sys->log<System::DEBUG2>("[BDHI::FIB] Random advection");
if(temperature!=real(0.0)){
sys->log<System::DEBUG2>("[BDHI::FIB] Generate random numbers");
CurandSafeCall(curandGenerateNormal(curng,
CurandSafeCall(curandgeneratenormal(curng,
thrust::raw_pointer_cast(random.data()),
random.size(),
0.0, 1.0));
Expand All @@ -932,7 +932,7 @@ namespace uammd{
double dV = grid.cellSize.x*grid.cellSize.y*grid.cellSize.z;
real noisePrefactor = sqrt(viscosity*temperature/(dt*dV));
if(temperature!=real(0.0))
CurandSafeCall(curandGenerateNormal(curng,
CurandSafeCall(curandgeneratenormal(curng,
thrust::raw_pointer_cast(random.data()),
random.size(),
0.0, 1.0));
Expand Down
6 changes: 3 additions & 3 deletions src/Integrator/Hydro/ICM.cu
Original file line number Diff line number Diff line change
Expand Up @@ -935,8 +935,8 @@ namespace uammd{
thrust::device_vector<real> noise(30000);
auto noise_ptr = thrust::raw_pointer_cast(noise.data());
//Warm cuRNG
CurandSafeCall(curandGenerateNormal(curng, noise_ptr, noise.size(), 0.0, 1.0));
CurandSafeCall(curandGenerateNormal(curng, noise_ptr, noise.size(), 0.0, 1.0));
CurandSafeCall(curandgeneratenormal(curng, noise_ptr, noise.size(), 0.0, 1.0));
CurandSafeCall(curandgeneratenormal(curng, noise_ptr, noise.size(), 0.0, 1.0));
}
//Sum S·F term using the current particle positions
void ICM::spreadParticleForces(){
Expand Down Expand Up @@ -993,7 +993,7 @@ namespace uammd{
if(temperature!=real(0.0)){
CurandSafeCall(curandSetStream(curng, st));
sys->log<System::DEBUG2>("[Hydro::ICM] Generate random numbers");
CurandSafeCall(curandGenerateNormal(curng, thrust::raw_pointer_cast(random.data()), random.size(), 0.0, 1.0));
CurandSafeCall(curandgeneratenormal(curng, thrust::raw_pointer_cast(random.data()), random.size(), 0.0, 1.0));
}
real3* d_gridVels = (real3*)thrust::raw_pointer_cast(gridVels.data());
real3* d_cellAdvection = (real3*)thrust::raw_pointer_cast(cellAdvection.data());
Expand Down
5 changes: 0 additions & 5 deletions src/Integrator/VerletNVE.cu
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@

#include"VerletNVE.cuh"


#ifndef SINGLE_PRECISION
#define curandGenerateNormal curandGenerateNormalDouble
#endif

namespace uammd{

VerletNVE::VerletNVE(shared_ptr<ParticleGroup> pg, VerletNVE::Parameters par):
Expand Down
21 changes: 20 additions & 1 deletion src/utils/cuda_lib_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#define cusolverDnpotrf cusolverDnSpotrf
#define cusolverDnpotrf_bufferSize cusolverDnSpotrf_bufferSize
#define cublastrmv cublasStrmv
#define curandgeneratenormal curandGenerateNormal
#define cublassymv cublasSsymv
#define cublasgemv cublasSgemv
#define cublasnrm2 cublasSnrm2
Expand All @@ -17,13 +18,22 @@
#define cusolverDnsyevd cusolverDnSsyevd
#define cusolverDnsyevd_bufferSize cusolverDnSsyevd_bufferSize
#define cusolverDngesvd_bufferSize cusolverDnSgesvd_bufferSize
#define cusolverDngetrf_bufferSize cusolverDnSgetrf_bufferSize
#define cusolverDncgetrf_bufferSize cusolverDnCgetrf_bufferSize
#define cusolverDngesvd cusolverDnSgesvd
#define cusolverDngetrf cusolverDnSgetrf
#define cusolverDngetrs cusolverDnSgetrs
#define cusolverDncgetrf cusolverDnCgetrf
#define cusolverDncgetrs cusolverDnCgetrs
#define cublasgemm cublasSgemm
#define cublasrgemv cublasSgemv
#define cublascgemm cublasCgemm
#define cublascgemv cublasCgemv
#else
#define cusolverDnpotrf cusolverDnDpotrf
#define cusolverDnpotrf_bufferSize cusolverDnDpotrf_bufferSize
#define cublastrmv cublasDtrmv
#define curandGenerateNormal curandGenerateNormalDouble
#define curandgeneratenormal curandGenerateNormalDouble
#define cublassymv cublasDsymv
#define cublasgemv cublasDgemv
#define cublasnrm2 cublasDnrm2
Expand All @@ -33,8 +43,17 @@
#define cusolverDnsyevd cusolverDnDsyevd
#define cusolverDnsyevd_bufferSize cusolverDnDsyevd_bufferSize
#define cusolverDngesvd_bufferSize cusolverDnDgesvd_bufferSize
#define cusolverDngetrf_bufferSize cusolverDnDgetrf_bufferSize
#define cusolverDncgetrf_bufferSize cusolverDnZgetrf_bufferSize
#define cusolverDngesvd cusolverDnDgesvd
#define cusolverDngetrf cusolverDnDgetrf
#define cusolverDngetrs cusolverDnDgetrs
#define cusolverDncgetrf cusolverDnZgetrf
#define cusolverDncgetrs cusolverDnZgetrs
#define cublasgemm cublasDgemm
#define cublasrgemv cublasDgemv
#define cublascgemm cublasZgemm
#define cublascgemv cublasZgemv
#endif


Expand Down

0 comments on commit d385ab3

Please sign in to comment.