[cig-commits] [commit] devel: Fix hard-coded paths in CUDA routines. (dae8154)
cig_noreply at geodynamics.org
cig_noreply at geodynamics.org
Sat Apr 26 06:28:52 PDT 2014
Repository : ssh://geoshell/specfem3d
On branch : devel
Link : https://github.com/geodynamics/specfem3d/compare/a668bacb1ee6d977dbb736f361fd6a1c87643cf0...aa19d657e7ebf41f81216672453c6411d6ab3fdf
>---------------------------------------------------------------
commit dae81541d8ae3a11c2f1140462f4b3355c2428ec
Author: Elliott Sales de Andrade <esalesde at physics.utoronto.ca>
Date: Sat Apr 26 04:26:16 2014 -0400
Fix hard-coded paths in CUDA routines.
I'm not happy with this extra macro, but at least there's only one of
them instead of hard-coded paths all over the place. Ideally, the path
would be passed along from Fortran, but I'm not sure of the code flow to
be able to do that just yet.
>---------------------------------------------------------------
dae81541d8ae3a11c2f1140462f4b3355c2428ec
src/cuda/check_fields_cuda.cu | 10 +++++-----
src/cuda/initialize_cuda.cu | 4 ++--
src/cuda/mesh_constants_cuda.h | 5 +++++
src/cuda/save_and_compare_cpu_vs_gpu.c | 7 ++++---
4 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/src/cuda/check_fields_cuda.cu b/src/cuda/check_fields_cuda.cu
index e45f760..39c06e1 100644
--- a/src/cuda/check_fields_cuda.cu
+++ b/src/cuda/check_fields_cuda.cu
@@ -111,7 +111,7 @@ void exit_on_cuda_error(char* kernel_name) {
#else
myrank = 0;
#endif
- sprintf(filename,"../OUTPUT_FILES/error_message_%06d.txt",myrank);
+ sprintf(filename,OUTPUT_FILES_PATH"/error_message_%06d.txt",myrank);
fp = fopen(filename,"a+");
if (fp != NULL){
fprintf(fp,"Error after %s: %s\n", kernel_name, cudaGetErrorString(err));
@@ -142,7 +142,7 @@ void exit_on_error(char* info) {
#else
myrank = 0;
#endif
- sprintf(filename,"../OUTPUT_FILES/error_message_%06d.txt",myrank);
+ sprintf(filename,OUTPUT_FILES_PATH"/error_message_%06d.txt",myrank);
fp = fopen(filename,"a+");
if (fp != NULL){
fprintf(fp,"ERROR: %s\n",info);
@@ -175,7 +175,7 @@ void print_CUDA_error_if_any(cudaError_t err, int num) {
#else
myrank = 0;
#endif
- sprintf(filename,"../OUTPUT_FILES/error_message_%06d.txt",myrank);
+ sprintf(filename,OUTPUT_FILES_PATH"/error_message_%06d.txt",myrank);
fp = fopen(filename,"a+");
if (fp != NULL){
fprintf(fp,"\nCUDA error !!!!! <%s> !!!!! \nat CUDA call error code: # %d\n",cudaGetErrorString(err),num);
@@ -306,12 +306,12 @@ void output_free_memory(int myrank,char* info_str) {
do_output_info = 0;
if( myrank == 0 ){
do_output_info = 1;
- sprintf(filename,"../OUTPUT_FILES/gpu_device_mem_usage.txt");
+ sprintf(filename,OUTPUT_FILES_PATH"/gpu_device_mem_usage.txt");
}
// debugging
if( DEBUG ){
do_output_info = 1;
- sprintf(filename,"../OUTPUT_FILES/gpu_device_mem_usage_proc_%06d.txt",myrank);
+ sprintf(filename,OUTPUT_FILES_PATH"/gpu_device_mem_usage_proc_%06d.txt",myrank);
}
// outputs to file
diff --git a/src/cuda/initialize_cuda.cu b/src/cuda/initialize_cuda.cu
index 18353ea..8036fa8 100644
--- a/src/cuda/initialize_cuda.cu
+++ b/src/cuda/initialize_cuda.cu
@@ -176,12 +176,12 @@ void FC_FUNC_(initialize_cuda_device,
do_output_info = 0;
if( myrank == 0 ){
do_output_info = 1;
- sprintf(filename,"../OUTPUT_FILES/gpu_device_info.txt");
+ sprintf(filename,OUTPUT_FILES_PATH"/gpu_device_info.txt");
}
// debugging
if( DEBUG ){
do_output_info = 1;
- sprintf(filename,"../OUTPUT_FILES/gpu_device_info_proc_%06d.txt",myrank);
+ sprintf(filename,OUTPUT_FILES_PATH"/gpu_device_info_proc_%06d.txt",myrank);
}
// output to file
diff --git a/src/cuda/mesh_constants_cuda.h b/src/cuda/mesh_constants_cuda.h
index e7a1043..02b470f 100644
--- a/src/cuda/mesh_constants_cuda.h
+++ b/src/cuda/mesh_constants_cuda.h
@@ -101,6 +101,11 @@
/* ----------------------------------------------------------------------------------------------- */
+// Output paths, see setup/constants.h
+#define OUTPUT_FILES_PATH "./OUTPUT_FILES/"
+
+/* ----------------------------------------------------------------------------------------------- */
+
// (optional) pre-processing directive used in kernels: if defined check that it is also set in src/shared/constants.h:
// leads up to ~ 5% performance increase
//#define USE_MESH_COLORING_GPU
diff --git a/src/cuda/save_and_compare_cpu_vs_gpu.c b/src/cuda/save_and_compare_cpu_vs_gpu.c
index bfd339f..b488f00 100644
--- a/src/cuda/save_and_compare_cpu_vs_gpu.c
+++ b/src/cuda/save_and_compare_cpu_vs_gpu.c
@@ -37,6 +37,7 @@
#endif
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
+#define LOCAL_PATH_Q "./OUTPUT_FILES/DATABASES_MPI/"
void save_to_max_surface_file_(float* maxval) {
@@ -96,7 +97,7 @@ void get_max_from_surface_file_(int* nodes_per_iterationf,int* NSTEP) {
#else
procid = 0;
#endif
- sprintf(filename,"/scratch/eiger/rietmann/SPECFEM3D_AIGLE/OUTPUT_FILES/DATABASES_MPI/proc%06d_surface_movie",procid);
+ sprintf(filename,LOCAL_PATH_Q"/proc%06d_surface_movie",procid);
FILE* fp; int it;
printf("Opening %s for analysis\n",filename);
@@ -176,8 +177,8 @@ void compare_two_vectors_(int* sizef,float* vector1,float* vector2,int* num_erro
void compare_surface_files_(int* bytes_per_iteration, int* number_of_iterations) {
- char* cpu_file = "/scratch/eiger/rietmann/SPECFEM3D/OUTPUT_FILES/DATABASES_MPI/cpu_proc000001_surface_movie";
- char* gpu_file = "/scratch/eiger/rietmann/SPECFEM3D/OUTPUT_FILES/DATABASES_MPI/cpu_v2_proc000001_surface_movie";
+ char* cpu_file = LOCAL_PATH_Q"/cpu_proc000001_surface_movie";
+ char* gpu_file = LOCAL_PATH_Q"/cpu_v2_proc000001_surface_movie";
FILE* fp_cpu;
fp_cpu = fopen(cpu_file,"rb");
More information about the CIG-COMMITS
mailing list