Skip to content

Commit 8f39006

Browse files
authored
Merge pull request #1781 from danielpeter/devel
Devel
2 parents a8182ff + b4d710a commit 8f39006

File tree

8 files changed

+688
-318
lines changed

8 files changed

+688
-318
lines changed

src/gpu/check_fields_cuda.cu

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ void FC_FUNC_(get_norm_acoustic_from_device,
222222

223223
Mesh* mp = (Mesh*)(*Mesh_pointer); //get mesh pointer out of fortran integer container
224224
realw max = 0.0;
225-
realw *d_max;
225+
realw *d_max = NULL;
226226

227227
//initializes
228228
*norm = 0.0f;
@@ -275,6 +275,7 @@ void FC_FUNC_(get_norm_acoustic_from_device,
275275

276276
// on host (allocates & initializes to zero)
277277
h_max = (realw*) calloc(num_blocks_x*num_blocks_y,sizeof(realw));
278+
if (!h_max) { exit_on_error("Error: allocating temporary host h_max array"); }
278279

279280
// allocates memory on device
280281
gpuMalloc_realw((void**)&d_max,num_blocks_x*num_blocks_y);
@@ -382,7 +383,7 @@ void FC_FUNC_(get_norm_elastic_from_device,
382383

383384
Mesh* mp = (Mesh*)(*Mesh_pointer); //get mesh pointer out of fortran integer container
384385
realw max,res;
385-
realw *d_max;
386+
realw *d_max = NULL;
386387

387388
//initializes
388389
*norm = 0.0f;
@@ -402,6 +403,7 @@ void FC_FUNC_(get_norm_elastic_from_device,
402403

403404
// on host (allocates & initializes to zero)
404405
h_max = (realw*) calloc(num_blocks_x*num_blocks_y,sizeof(realw));
406+
if (!h_max) { exit_on_error("Error: allocating temporary host h_max array"); }
405407

406408
// allocates memory on device
407409
gpuMalloc_realw((void**)&d_max,num_blocks_x*num_blocks_y);
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,30 @@
1+
/*
2+
!=====================================================================
3+
!
4+
! S p e c f e m 3 D
5+
! -----------------
6+
!
7+
! Main historical authors: Dimitri Komatitsch and Jeroen Tromp
8+
! CNRS, France
9+
! and Princeton University, USA
10+
! (there are currently many more authors!)
11+
! (c) October 2017
12+
!
13+
! This program is free software; you can redistribute it and/or modify
14+
! it under the terms of the GNU General Public License as published by
15+
! the Free Software Foundation; either version 3 of the License, or
16+
! (at your option) any later version.
17+
!
18+
! This program is distributed in the hope that it will be useful,
19+
! but WITHOUT ANY WARRANTY; without even the implied warranty of
20+
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21+
! GNU General Public License for more details.
22+
!
23+
! You should have received a copy of the GNU General Public License along
24+
! with this program; if not, write to the Free Software Foundation, Inc.,
25+
! 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26+
!
27+
!=====================================================================
28+
*/
29+
130
#include "wavefield_discontinuity_kernel.cu"

src/gpu/kernels/wavefield_discontinuity_kernel.cu

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,35 @@
1+
/*
2+
!=====================================================================
3+
!
4+
! S p e c f e m 3 D
5+
! -----------------
6+
!
7+
! Main historical authors: Dimitri Komatitsch and Jeroen Tromp
8+
! CNRS, France
9+
! and Princeton University, USA
10+
! (there are currently many more authors!)
11+
! (c) October 2017
12+
!
13+
! This program is free software; you can redistribute it and/or modify
14+
! it under the terms of the GNU General Public License as published by
15+
! the Free Software Foundation; either version 3 of the License, or
16+
! (at your option) any later version.
17+
!
18+
! This program is distributed in the hope that it will be useful,
19+
! but WITHOUT ANY WARRANTY; without even the implied warranty of
20+
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21+
! GNU General Public License for more details.
22+
!
23+
! You should have received a copy of the GNU General Public License along
24+
! with this program; if not, write to the Free Software Foundation, Inc.,
25+
! 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26+
!
27+
!=====================================================================
28+
*/
29+
30+
131
__global__ void add_acceleration_discontinuity_kernel(
2-
realw_const_p accel_wd,
32+
realw_const_p accel_wd,
333
realw_const_p mass_in_wd,
434
const int* boundary_to_iglob_wd,
535
const int size, realw* accel

src/gpu/wavefield_discontinuity_cuda.cu

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,37 @@
1+
/*
2+
!=====================================================================
3+
!
4+
! S p e c f e m 3 D
5+
! -----------------
6+
!
7+
! Main historical authors: Dimitri Komatitsch and Jeroen Tromp
8+
! CNRS, France
9+
! and Princeton University, USA
10+
! (there are currently many more authors!)
11+
! (c) October 2017
12+
!
13+
! This program is free software; you can redistribute it and/or modify
14+
! it under the terms of the GNU General Public License as published by
15+
! the Free Software Foundation; either version 3 of the License, or
16+
! (at your option) any later version.
17+
!
18+
! This program is distributed in the hope that it will be useful,
19+
! but WITHOUT ANY WARRANTY; without even the implied warranty of
20+
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21+
! GNU General Public License for more details.
22+
!
23+
! You should have received a copy of the GNU General Public License along
24+
! with this program; if not, write to the Free Software Foundation, Inc.,
25+
! 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26+
!
27+
!=====================================================================
28+
*/
29+
130
#include "mesh_constants_gpu.h"
231

332
extern EXTERN_LANG
433
void FC_FUNC_(wavefield_discontinuity_add_traction_cuda,
5-
WAVEFIELD_DISCONTINUITY_ADD_TRACTION_CUDA)(int* size_points,
34+
WAVEFIELD_DISCONTINUITY_ADD_TRACTION_CUDA)(int* size_points,
635
int* size_faces,
736
long* Mesh_pointer){
837
TRACE("wavefield_discontinuity_add_traction_cuda");
@@ -17,7 +46,7 @@ void FC_FUNC_(wavefield_discontinuity_add_traction_cuda,
1746

1847
dim3 grid(num_blocks_x,num_blocks_y);
1948
dim3 threads(blocksize,1,1);
20-
49+
2150
#ifdef USE_CUDA
2251
if (run_cuda) {
2352
add_acceleration_discontinuity_kernel
@@ -29,17 +58,17 @@ void FC_FUNC_(wavefield_discontinuity_add_traction_cuda,
2958
#endif
3059
#ifdef USE_HIP
3160
if (run_hip) {
32-
hipLaunchKernelGGL(add_acceleration_discontinuity_kernel,
61+
hipLaunchKernelGGL(add_acceleration_discontinuity_kernel,
3362
dim3(grid), dim3(threads), 0, mp->compute_stream, mp->d_accel_wd,
3463
mp->d_mass_in_wd,
35-
mp->d_boundary_to_iglob_wd,
64+
mp->d_boundary_to_iglob_wd,
3665
size, mp->d_accel);
3766
}
3867
#endif
39-
68+
4069
size = (*size_faces);
4170
blocksize = NGLL2;
42-
71+
4372
get_blocks_xy(size,&num_blocks_x,&num_blocks_y);
4473

4574
dim3 grid2(num_blocks_x,num_blocks_y);

src/specfem3D/couple_with_injection.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3328,7 +3328,7 @@ subroutine couple_with_injection_prepare_specfem_files()
33283328
! check integer size limit: size of reclen must fit onto an 4-byte integer
33293329
if (reclen > int(2147483646.0 / 2)) then
33303330
print *,'reclen needed exceeds integer 4-byte limit: ',reclen
3331-
print *,' ',reclen,' custom_real/ndim/npoints_local = ',CUSTOM_REAL, NDIM, npoints_local
3331+
print *,' ',reclen,' CUSTOM_REAL/ndim/npoints_local = ',CUSTOM_REAL, NDIM, npoints_local
33323332
print *,'bit size Fortran: ',bit_size(reclen)
33333333
call exit_MPI(myrank,"Error reclen integer limit")
33343334
endif

src/specfem3D/locate_source.F90

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ subroutine locate_source()
699699

700700
! user info for many source points
701701
if (.not. SHOW_DETAILS_LOCATE_SOURCE .and. NSOURCES >= 10) then
702-
write(IMAIN,*) 'for all following ',NSOURCES-1,'sources we will suppress the details to avoid getting to long here...'
702+
write(IMAIN,*) 'for all following sources we will suppress the detail infos to avoid getting to long here...'
703703
write(IMAIN,*)
704704
write(IMAIN,*) 'In case you wish to see detailed source informations for all source points, consider turning on the'
705705
write(IMAIN,*) 'parameter SHOW_DETAILS_LOCATE_SOURCE in setup/constants.h'
@@ -759,6 +759,12 @@ subroutine locate_source()
759759
write(IMAIN,*) ' total moment magnitude Mw = ', Mw
760760
endif
761761
write(IMAIN,*)
762+
! statistics
763+
write(IMAIN,*) ' source ranges:'
764+
write(IMAIN,*) ' depth : min/max = ',sngl(minval(depth(:))/1000.d0),'/',sngl(maxval(depth(:))/1000.d0),' km'
765+
write(IMAIN,*) ' half duration: min/max = ',sngl(minval(hdur(:))),'/',sngl(maxval(hdur(:)))
766+
write(IMAIN,*) ' time shift : min/max = ',sngl(minval(tshift_src(:))),'/',sngl(maxval(tshift_src(:)))
767+
write(IMAIN,*)
762768
write(IMAIN,*) '********************'
763769
call flush_IMAIN()
764770
endif

src/specfem3D/wavefield_discontinuity_solver.f90

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,12 @@ end subroutine transfer_wavefield_discontinuity_to_GPU
166166
subroutine prepare_wavefield_discontinuity_GPU()
167167
use specfem_par, only: Mesh_pointer
168168
implicit none
169-
call prepare_wavefield_discontinuity_device(Mesh_pointer, ispec_to_elem_wd,&
170-
nglob_wd, nspec_wd, ibool_wd,&
171-
boundary_to_iglob_wd,&
172-
mass_in_wd,&
173-
nfaces_wd, face_ijk_wd,&
174-
face_ispec_wd, face_normal_wd,&
169+
call prepare_wavefield_discontinuity_device(Mesh_pointer, ispec_to_elem_wd, &
170+
nglob_wd, nspec_wd, ibool_wd, &
171+
boundary_to_iglob_wd, &
172+
mass_in_wd, &
173+
nfaces_wd, face_ijk_wd, &
174+
face_ispec_wd, face_normal_wd, &
175175
face_jacobian2dw_wd)
176176
end subroutine prepare_wavefield_discontinuity_GPU
177177

0 commit comments

Comments
 (0)