Skip to content

Commit

Permalink
Merge pull request #851 from tang070205/master
Browse files Browse the repository at this point in the history
cuda api change to generic api
  • Loading branch information
brucefan1983 authored Jan 6, 2025
2 parents e5c788c + 46c6f9c commit 59b92b8
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/minimize/minimizer_fire_box_change.cu
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ void update_box(double* box, const double* d_v, int N)
double processed_v[9];
double* d_processed_v;

cudaMalloc(&d_processed_v, 9 * sizeof(double));
gpuMalloc(&d_processed_v, 9 * sizeof(double));
process_matrix<<<1, 9>>>(d_v, d_processed_v, N);
cudaMemcpy(processed_v, d_processed_v, 9 * sizeof(double), cudaMemcpyDeviceToHost);
gpuMemcpy(processed_v, d_processed_v, 9 * sizeof(double), gpuMemcpyDeviceToHost);
transpose9(processed_v);

for (int i = 0; i < 9; i++) {
Expand All @@ -82,7 +82,7 @@ void update_box(double* box, const double* d_v, int N)
box[i] += result[i];
}

cudaFree(d_processed_v);
gpuFree(d_processed_v);
}

__global__ void get_force_temp_kernel(
Expand Down Expand Up @@ -127,8 +127,8 @@ void get_force_temp(
{

double* d_deform;
cudaMalloc(&d_deform, 9 * sizeof(double));
cudaMemcpy(d_deform, deform, 9 * sizeof(double), cudaMemcpyHostToDevice);
gpuMalloc(&d_deform, 9 * sizeof(double));
gpuMemcpy(d_deform, deform, 9 * sizeof(double), gpuMemcpyHostToDevice);

int threadsPerBlock = 256;
int blocksPerGrid = (N + threadsPerBlock - 1) / threadsPerBlock;
Expand All @@ -139,13 +139,13 @@ void get_force_temp(
virial_cpu_deform[m] = virial_cpu_deform[m] / N;
}

cudaMemcpy(force_temp + N, virial_cpu_deform, 3 * sizeof(double), cudaMemcpyHostToDevice);
cudaMemcpy(
force_temp + 2 * N + 3, virial_cpu_deform + 3, 3 * sizeof(double), cudaMemcpyHostToDevice);
cudaMemcpy(
force_temp + 3 * N + 6, virial_cpu_deform + 6, 3 * sizeof(double), cudaMemcpyHostToDevice);
gpuMemcpy(force_temp + N, virial_cpu_deform, 3 * sizeof(double), gpuMemcpyHostToDevice);
gpuMemcpy(
force_temp + 2 * N + 3, virial_cpu_deform + 3, 3 * sizeof(double), gpuMemcpyHostToDevice);
gpuMemcpy(
force_temp + 3 * N + 6, virial_cpu_deform + 6, 3 * sizeof(double), gpuMemcpyHostToDevice);

cudaFree(d_deform);
gpuFree(d_deform);
}

template <int N>
Expand Down Expand Up @@ -552,4 +552,4 @@ void Minimizer_FIRE_Box_Change::compute(
}

printf("Energy minimization finished.\n");
}
}

0 comments on commit 59b92b8

Please sign in to comment.