Initialize sources on gpus when ATRIP_SOURCES_IN_GPU

This commit is contained in:
Ania Brown 2023-01-23 14:21:51 +01:00 committed by Alejandro Gallo
parent 9a5a2487be
commit 4af47a0bb7
2 changed files with 18 additions and 2 deletions

View File

@ -418,6 +418,22 @@ template <typename F=double>
LOG(0,"Atrip") << "INIT SliceUnion: " << name << "\n"; LOG(0,"Atrip") << "INIT SliceUnion: " << name << "\n";
#if defined(ATRIP_SOURCES_IN_GPU)
for (auto& ptr: sources) {
const CUresult sourceError =
cuMemAlloc(&ptr, sizeof(F) * sliceSize);
if (ptr == 0UL) {
throw "UNSUFICCIENT MEMORY ON THE GRAPHIC CARD FOR SOURCES";
}
if (sourceError != CUDA_SUCCESS) {
std::stringstream s;
s << "Error allocating memory for sources "
<< "code " << sourceError << "\n";
throw s.str();
}
}
#endif
for (auto& ptr: sliceBuffers) { for (auto& ptr: sliceBuffers) {
#if defined(HAVE_CUDA) #if defined(HAVE_CUDA)
const CUresult error = const CUresult error =

View File

@ -688,7 +688,7 @@ Atrip::Output Atrip::run(Atrip::Input<F> const& in) {
#if defined(HAVE_CUDA) #if defined(HAVE_CUDA)
double *tupleEnergy; double *tupleEnergy;
cuMemAlloc((DataPtr<double>*)&tupleEnergy, sizeof(double)); cuMemAlloc((DataPtr<double>*)&tupleEnergy, sizeof(double));
#elif #else
double _tupleEnergy(0.); double _tupleEnergy(0.);
double *tupleEnergy = &_tupleEnergy; double *tupleEnergy = &_tupleEnergy;
#endif /* defined(HAVE_CUDA) */ #endif /* defined(HAVE_CUDA) */
@ -727,7 +727,7 @@ Atrip::Output Atrip::run(Atrip::Input<F> const& in) {
cuMemcpyDtoH((void*)&host_tuple_energy, cuMemcpyDtoH((void*)&host_tuple_energy,
(DataPtr<double>)tupleEnergy, (DataPtr<double>)tupleEnergy,
sizeof(double)); sizeof(double));
#elif #else
double host_tuple_energy = *tupleEnergy; double host_tuple_energy = *tupleEnergy;
#endif /* defined(HAVE_CUDA) */ #endif /* defined(HAVE_CUDA) */