Skip to content

Commit 9e87c25

Browse files
authored
Merge pull request #20 from oneapi-src/sam/code_update/2309
[SeisAcoMod2D] code update + cmake changes
2 parents 99a61d2 + f474f08 commit 9e87c25

File tree

4 files changed

+74
-51
lines changed

4 files changed

+74
-51
lines changed

SeisAcoMod2D/CUDA/CMakeLists.txt

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,25 @@ endif()
2525

2626
option(USE_SM "Build for specific SM" OFF)
2727

28-
# CMAKE_CXX_FLAGS
29-
if("${CMAKE_CXX_FLAGS}" STREQUAL "")
28+
set(DEF_WL_CXX_FLAGS " ")
29+
set(DEF_GENERAL_CXX_FLAGS " -O3 -std=c++11 -fopenmp ")
30+
set(DEF_COMBINED_CXX_FLAGS "${DEF_GENERAL_CXX_FLAGS} ${DEF_WL_CXX_FLAGS}")
31+
32+
# -DCMAKE_CXX_FLAGS=" -blah -blah " overrides the default flags (BOTH general and WL specific)
33+
# -DOVERRIDE_GENERAL_CXX_FLAGS=" -blah -blah " overrides the general flags only (and not the workload specific flags)
34+
# passing in both CMAKE_CXX_FLAGS and OVERRIDE_GENERAL_CXX_FLAGS is not allowed, in order to prevent ambiguity
35+
36+
if(NOT "${CMAKE_CXX_FLAGS}" STREQUAL "" AND NOT "${OVERRIDE_GENERAL_CXX_FLAGS}" STREQUAL "")
37+
message(FATAL_ERROR "Both CMAKE_CXX_FLAGS and OVERRIDE_GENERAL_CXX_FLAGS cannot be passed in together")
38+
elseif("${CMAKE_CXX_FLAGS}" STREQUAL "" AND "${OVERRIDE_GENERAL_CXX_FLAGS}" STREQUAL "")
3039
message(STATUS "Using DEFAULT compilation flags")
31-
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} " -O3 -std=c++11 -fopenmp ")
32-
else()
33-
message(STATUS "OVERRIDING DEFAULT compilation flags")
40+
set(CMAKE_CXX_FLAGS "${DEF_COMBINED_CXX_FLAGS}")
41+
elseif(NOT "${OVERRIDE_GENERAL_CXX_FLAGS}" STREQUAL "")
42+
message(STATUS "OVERRIDING GENERAL compilation flags")
43+
set(CMAKE_CXX_FLAGS "${OVERRIDE_GENERAL_CXX_FLAGS}")
44+
string(APPEND CMAKE_CXX_FLAGS ${DEF_WL_CXX_FLAGS})
45+
elseif(NOT "${CMAKE_CXX_FLAGS}" STREQUAL "")
46+
message(STATUS "OVERRIDING GENERAL and WORKLOAD SPECIFIC compilation flags")
3447
endif()
3548

3649
# CUDA_NVCC_FLAGS
@@ -45,20 +58,6 @@ endif()
4558
find_package(CUDA REQUIRED)
4659

4760
find_package(MPI REQUIRED)
48-
# message(STATUS "MPI_FOUND: ${MPI_FOUND}")
49-
# message(STATUS "MPI_VERSION: ${MPI_VERSION}")
50-
# message(STATUS "MPIEXEC: ${MPIEXEC}")
51-
# message(STATUS "MPIEXEC_EXECUTABLE: ${MPIEXEC_EXECUTABLE}")
52-
# message(STATUS "MPI_CXX_COMPILER: ${MPI_CXX_COMPILER}")
53-
# message(STATUS "MPIEXEC_NUMPROC_FLAG: ${MPIEXEC_NUMPROC_FLAG}")
54-
# message(STATUS "MPIEXEC_MAX_NUMPROCS: ${MPIEXEC_MAX_NUMPROCS}")
55-
# message(STATUS "MPIEXEC_PREFLAGS: ${MPIEXEC_PREFLAGS}")
56-
# message(STATUS "MPIEXEC_POSTFLAGS: ${MPIEXEC_POSTFLAGS}")
57-
# message(STATUS "MPI_CXX_COMPILE_FLAGS: ${MPI_CXX_COMPILE_FLAGS}")
58-
# message(STATUS "MPI_CXX_COMPILE_OPTIONS: ${MPI_CXX_COMPILE_OPTIONS}")
59-
# message(STATUS "MPI_CXX_INCLUDE_PATH: ${MPI_CXX_INCLUDE_PATH}")
60-
# message(STATUS "MPI_CXX_LINK_FLAGS: ${MPI_CXX_LINK_FLAGS}")
61-
# message(STATUS "MPI_CXX_LIBRARIES: ${MPI_CXX_LIBRARIES}")
6261

6362
set(SOURCES
6463
${CMAKE_SOURCE_DIR}/../common/main.cpp

SeisAcoMod2D/HIP/CMakeLists.txt

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,25 @@ set(CMAKE_MODULE_PATH "${ROCM_PATH}/hip/cmake" ${CMAKE_MODULE_PATH})
3434
set(HIP_INCLUDE_DIRS "${ROCM_PATH}/include" ${HIP_INCLUDE_DIRS})
3535
set(HIP_LIBRARIES "${ROCM_PATH}/lib" ${HIP_LIBRARIES})
3636

37-
# CMAKE_CXX_FLAGS
38-
if("${CMAKE_CXX_FLAGS}" STREQUAL "")
37+
set(DEF_WL_CXX_FLAGS " -D__HIP_PLATFORM_AMD__ ")
38+
set(DEF_GENERAL_CXX_FLAGS " -cxx=hipcc -O3 -std=c++17 -fopenmp ")
39+
set(DEF_COMBINED_CXX_FLAGS "${DEF_GENERAL_CXX_FLAGS} ${DEF_WL_CXX_FLAGS}")
40+
41+
# -DCMAKE_CXX_FLAGS=" -blah -blah " overrides the default flags (BOTH general and WL specific)
42+
# -DOVERRIDE_GENERAL_CXX_FLAGS=" -blah -blah " overrides the general flags only (and not the workload specific flags)
43+
# passing in both CMAKE_CXX_FLAGS and OVERRIDE_GENERAL_CXX_FLAGS is not allowed, in order to prevent ambiguity
44+
45+
if(NOT "${CMAKE_CXX_FLAGS}" STREQUAL "" AND NOT "${OVERRIDE_GENERAL_CXX_FLAGS}" STREQUAL "")
46+
message(FATAL_ERROR "Both CMAKE_CXX_FLAGS and OVERRIDE_GENERAL_CXX_FLAGS cannot be passed in together")
47+
elseif("${CMAKE_CXX_FLAGS}" STREQUAL "" AND "${OVERRIDE_GENERAL_CXX_FLAGS}" STREQUAL "")
3948
message(STATUS "Using DEFAULT compilation flags")
40-
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} " -cxx=hipcc -O3 -std=c++17 -fopenmp -D__HIP_PLATFORM_AMD__ ")
41-
else()
42-
message(STATUS "OVERRIDING DEFAULT compilation flags")
49+
set(CMAKE_CXX_FLAGS "${DEF_COMBINED_CXX_FLAGS}")
50+
elseif(NOT "${OVERRIDE_GENERAL_CXX_FLAGS}" STREQUAL "")
51+
message(STATUS "OVERRIDING GENERAL compilation flags")
52+
set(CMAKE_CXX_FLAGS "${OVERRIDE_GENERAL_CXX_FLAGS}")
53+
string(APPEND CMAKE_CXX_FLAGS ${DEF_WL_CXX_FLAGS})
54+
elseif(NOT "${CMAKE_CXX_FLAGS}" STREQUAL "")
55+
message(STATUS "OVERRIDING GENERAL and WORKLOAD SPECIFIC compilation flags")
4356
endif()
4457

4558
set(SOURCES

SeisAcoMod2D/README.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,6 @@
22

33
Parallel 2D Acoustic Finite Difference Seismic Modelling using the Staggered Grid. The original CUDA source code is from [here](https://github.com/richaras/SeisAcoMod2D). For SYCL version, the CUDA code was migrated using Intel DPCT, and then the resulting code was modified to remove the dpct headers.
44

5-
## Cloning
6-
7-
To clone, do
8-
9-
```
10-
git clone https://github.com/oneapi-src/Velocity-Bench.git
11-
```
125
# Build Instructions
136

147
## Downlod and extract data:

SeisAcoMod2D/SYCL/CMakeLists.txt

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,36 +28,50 @@ option(USE_NVIDIA_BACKEND "Build for NVIDIA backend" OFF)
2828
option(USE_AMDHIP_BACKEND "Build for AMD HIP backend" OFF)
2929
option(USE_SM "Build for specific SM" OFF)
3030

31-
set(INTEL_GPU_CXX_FLAGS " -cxx=icpx -O2 -std=c++17 -fsycl -fopenmp ")
32-
set(NVIDIA_GPU_CXX_FLAGS " -cxx=clang++ -O3 -std=c++17 -fsycl ")
33-
set(AMD_GPU_CXX_FLAGS " -cxx=clang++ -O3 -std=c++17 -fsycl ")
31+
set(DEF_INTEL_WL_CXX_FLAGS " ")
32+
set(DEF_NVIDIA_WL_CXX_FLAGS " ")
33+
set(DEF_AMD_WL_CXX_FLAGS " ")
3434

35-
set(USE_DEFAULT_FLAGS ON)
36-
if("${CMAKE_CXX_FLAGS}" STREQUAL "")
35+
set(DEF_INTEL_GENERAL_CXX_FLAGS " -cxx=icpx -O2 -std=c++17 -fsycl -fopenmp ")
36+
set(DEF_NVIDIA_GENERAL_CXX_FLAGS " -cxx=clang++ -O3 -std=c++17 -fsycl ")
37+
set(DEF_AMD_GENERAL_CXX_FLAGS " -cxx=clang++ -O3 -std=c++17 -fsycl ")
38+
39+
# -DCMAKE_CXX_FLAGS=" -blah -blah " overrides the default flags (BOTH general and WL specific)
40+
# -DOVERRIDE_GENERAL_CXX_FLAGS=" -blah -blah " overrides the general flags only (and not the workload specific flags)
41+
# passing in both CMAKE_CXX_FLAGS and OVERRIDE_GENERAL_CXX_FLAGS is not allowed, in order to prevent ambiguity
42+
43+
if(NOT "${CMAKE_CXX_FLAGS}" STREQUAL "" AND NOT "${OVERRIDE_GENERAL_CXX_FLAGS}" STREQUAL "")
44+
message(FATAL_ERROR "Both CMAKE_CXX_FLAGS and OVERRIDE_GENERAL_CXX_FLAGS cannot be passed in together")
45+
elseif("${CMAKE_CXX_FLAGS}" STREQUAL "" AND "${OVERRIDE_GENERAL_CXX_FLAGS}" STREQUAL "")
3746
message(STATUS "Using DEFAULT compilation flags")
38-
else()
39-
message(STATUS "Overriding DEFAULT compilation flags")
40-
set(USE_DEFAULT_FLAGS OFF)
47+
set(INTEL_GPU_CXX_FLAGS "${DEF_INTEL_GENERAL_CXX_FLAGS} ${DEF_INTEL_WL_CXX_FLAGS}")
48+
set(NVIDIA_GPU_CXX_FLAGS "${DEF_NVIDIA_GENERAL_CXX_FLAGS} ${DEF_NVIDIA_WL_CXX_FLAGS}")
49+
set(AMD_GPU_CXX_FLAGS "${DEF_AMD_GENERAL_CXX_FLAGS} ${DEF_AMD_WL_CXX_FLAGS}")
50+
elseif(NOT "${OVERRIDE_GENERAL_CXX_FLAGS}" STREQUAL "")
51+
message(STATUS "OVERRIDING GENERAL compilation flags")
52+
set(INTEL_GPU_CXX_FLAGS "${OVERRIDE_GENERAL_CXX_FLAGS} ${DEF_INTEL_WL_CXX_FLAGS}")
53+
set(NVIDIA_GPU_CXX_FLAGS "${OVERRIDE_GENERAL_CXX_FLAGS} ${DEF_NVIDIA_WL_CXX_FLAGS}")
54+
set(AMD_GPU_CXX_FLAGS "${OVERRIDE_GENERAL_CXX_FLAGS} ${DEF_AMD_WL_CXX_FLAGS}")
55+
elseif(NOT "${CMAKE_CXX_FLAGS}" STREQUAL "")
56+
message(STATUS "OVERRIDING GENERAL and WORKLOAD SPECIFIC compilation flags")
57+
set(INTEL_GPU_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
58+
set(NVIDIA_GPU_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
59+
set(AMD_GPU_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
4160
endif()
4261

43-
# AOT compilation
4462
if(GPU_AOT)
4563
message(STATUS "Enabling INTEL backend")
46-
if(USE_DEFAULT_FLAGS)
47-
set(CMAKE_CXX_FLAGS "${INTEL_GPU_CXX_FLAGS}") # Default flags for Intel backend
48-
endif()
49-
if( (${GPU_AOT} STREQUAL "pvc") OR (${GPU_AOT} STREQUAL "PVC") )
64+
set(CMAKE_CXX_FLAGS "${INTEL_GPU_CXX_FLAGS}")
65+
if((${GPU_AOT} STREQUAL "pvc") OR (${GPU_AOT} STREQUAL "PVC"))
5066
message(STATUS "Enabling Intel GPU AOT compilation for ${GPU_AOT}")
5167
string(APPEND CMAKE_CXX_FLAGS " -fsycl-targets=spir64_gen -Xs \"-device 0x0bd5 -revision_id 0x2f\" ")
5268
else()
5369
message(STATUS "Using custom AOT compilation flag ${GPU_AOT}")
54-
string(APPEND CMAKE_CXX_FLAGS " ${GPU_AOT} ")
70+
string(APPEND CMAKE_CXX_FLAGS " ${GPU_AOT} ") # User should be aware of advanced AOT compilation flags
5571
endif()
5672
elseif(USE_NVIDIA_BACKEND)
5773
message(STATUS "Enabling NVIDIA backend")
58-
if(USE_DEFAULT_FLAGS)
59-
set(CMAKE_CXX_FLAGS "${NVIDIA_GPU_CXX_FLAGS}") # Default flags for NVIDIA backend
60-
endif()
74+
set(CMAKE_CXX_FLAGS "${NVIDIA_GPU_CXX_FLAGS}")
6175
if(USE_SM)
6276
message("-- Building for SM_${USE_SM} compatibility")
6377
string(APPEND CMAKE_CXX_FLAGS " -fsycl-targets=nvptx64-nvidia-cuda -Xsycl-target-backend --cuda-gpu-arch=sm_${USE_SM} ")
@@ -67,12 +81,16 @@ elseif(USE_NVIDIA_BACKEND)
6781
endif()
6882
elseif(USE_AMDHIP_BACKEND)
6983
message(STATUS "Enabling AMD HIP backend for ${USE_AMDHIP_BACKEND} AMD architecture")
70-
if(USE_DEFAULT_FLAGS)
71-
set(CMAKE_CXX_FLAGS "${AMD_GPU_CXX_FLAGS}") # Default flags for AMD backend
72-
endif()
84+
set(CMAKE_CXX_FLAGS "${AMD_GPU_CXX_FLAGS}")
7385
string(APPEND CMAKE_CXX_FLAGS " -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend --offload-arch=${USE_AMDHIP_BACKEND} ")
86+
else()
87+
# JIT case
88+
message(STATUS "Enabling INTEL backend")
89+
set(CMAKE_CXX_FLAGS "${INTEL_GPU_CXX_FLAGS}")
7490
endif()
7591

92+
message(STATUS "CXX Compilation flags set to: ${CMAKE_CXX_FLAGS}")
93+
7694
set(SOURCES
7795
${CMAKE_SOURCE_DIR}/../common/main.cpp
7896
${CMAKE_SOURCE_DIR}/../common/json_parser.cpp

0 commit comments

Comments
 (0)