Skip to content

Commit

Permalink
Merge pull request #153 from atillack/memory_related_fixes
Browse files Browse the repository at this point in the history
Fix for memory double freeing and wrong Cuda device in certain cases
  • Loading branch information
atillack authored Sep 17, 2021
2 parents 0fe820f + d1a0cca commit e567193
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 24 deletions.
4 changes: 4 additions & 0 deletions host/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,9 @@ int main(int argc, char* argv[])
if(mypars.resname) free(mypars.resname);
}
} // end of for loop
#ifdef USE_PIPELINE
#pragma omp single
#endif
if(!filelist.used){
// Clean up memory dynamically allocated to not leak
mypars.receptor_atoms.clear();
Expand All @@ -488,6 +491,7 @@ int main(int argc, char* argv[])
}
} // end of parallel section
if(initial_pars.xml2dlg && !initial_pars.dlg2stdout && (n_files>100)) printf("\n\n"); // finish progress bar


#ifndef _WIN32
// Total time measurement
Expand Down
27 changes: 3 additions & 24 deletions host/src/performdocking.cpp.Cuda
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,12 @@ void setup_gpu_for_docking(
GpuTempData& tData
)
{
cudaError_t status;
if(cData.devnum<-1){
status = cudaSetDevice(cData.devid);
return; // device already setup
}
if(cData.devnum<-1) return; // device already setup
auto const t0 = std::chrono::steady_clock::now();

// Initialize CUDA
int gpuCount=0;
status = cudaGetDeviceCount(&gpuCount);
cudaError_t status = cudaGetDeviceCount(&gpuCount);
RTERROR(status, "cudaGetDeviceCount failed");
if (gpuCount == 0)
{
Expand Down Expand Up @@ -316,7 +312,7 @@ parameters argc and argv:
if(output!=NULL) outbuf = (char*)malloc(256*sizeof(char));

auto const t1 = std::chrono::steady_clock::now();
cudaError_t status;
cudaError_t status = cudaSetDevice(cData.devid); // make sure we're on the correct device

Liganddata myligand_reference;

Expand Down Expand Up @@ -590,21 +586,6 @@ parameters argc and argv:
unsigned int ite_cnt = 0;
#endif

/*
// Added for printing intracontributor_pairs (autodockdevpy)
for (unsigned int intrapair_cnt=0;
intrapair_cnt<dockpars.num_of_intraE_contributors;
intrapair_cnt++) {
if (intrapair_cnt == 0) {
para_printf("%-10s %-10s %-10s\n", "#pair", "#atom1", "#atom2");
}

para_printf ("%-10u %-10u %-10u\n", intrapair_cnt,
KerConst.intraE_contributors_const[3*intrapair_cnt],
KerConst.intraE_contributors_const[3*intrapair_cnt+1]);
}
*/

// Kernel1
uint32_t kernel1_gxsize = blocksPerGridForEachEntity;
uint32_t kernel1_lxsize = threadsPerBlock;
Expand Down Expand Up @@ -694,7 +675,6 @@ parameters argc and argv:
cudaDeviceSynchronize();
#endif
gpu_calc_initpop(kernel1_gxsize, kernel1_lxsize, pMem_conformations_current, pMem_energies_current);
//runKernel1D(command_queue,kernel1,kernel1_gxsize,kernel1_lxsize,&time_start_kernel,&time_end_kernel);
#ifdef DOCK_DEBUG
cudaDeviceSynchronize();
para_printf("%15s" ," ... Finished\n");fflush(stdout);
Expand All @@ -705,7 +685,6 @@ parameters argc and argv:
#ifdef DOCK_DEBUG
para_printf("%-25s", "\tK_EVAL");fflush(stdout);
#endif
//runKernel1D(command_queue,kernel2,kernel2_gxsize,kernel2_lxsize,&time_start_kernel,&time_end_kernel);
gpu_sum_evals(kernel2_gxsize, kernel2_lxsize);
#ifdef DOCK_DEBUG
cudaDeviceSynchronize();
Expand Down

0 comments on commit e567193

Please sign in to comment.