Skip to content

Commit 5f03747

Browse files
authored
CMake: DPC++, OMP Def., Binary Names (#1125)
With regards to the `WarpX_COMPUTE` options the following changes are introduced: - default: `OMP` (as in GNUmake) - rename: `NONE` -> `NOACC` (no accelerated computing backend) - adds: `DPCPP` (for SYCL/Intel DPC++ beta7 or newer) Furthermore, we encode relevant, user-facing options in our binary name. The namings are intentionally a different and skip few options that are verbose and unlikely to appear even in development at the same time. Furthermore, this builds a `warpx` symlink in `bin/` to the latest build executable (when swtiching options), so that repeated compile-and-test workflows do not need to take care of the executable name anymore.
1 parent c8d587e commit 5f03747

File tree

6 files changed

+94
-20
lines changed

6 files changed

+94
-20
lines changed

.github/workflows/macos.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ jobs:
2323
- name: build WarpX
2424
run: |
2525
mkdir build_dp && cd build_dp
26-
cmake .. -DCMAKE_VERBOSE_MAKEFILE=ON -DWarpX_COMPUTE=OMP -DWarpX_OPENPMD=ON -DWarpX_openpmd_internal=OFF
26+
cmake .. -DCMAKE_VERBOSE_MAKEFILE=ON -DWarpX_OPENPMD=ON -DWarpX_openpmd_internal=OFF
2727
make -j 2
2828
2929
cd ..
3030
3131
mkdir build_sp && cd build_sp
32-
cmake .. -DCMAKE_VERBOSE_MAKEFILE=ON -DWarpX_COMPUTE=OMP -DWarpX_OPENPMD=ON -DWarpX_openpmd_internal=OFF -DENABLE_DP=OFF -DENABLE_DP_PARTICLES=OFF
32+
cmake .. -DCMAKE_VERBOSE_MAKEFILE=ON -DWarpX_OPENPMD=ON -DWarpX_openpmd_internal=OFF -DWarpX_PRECISION=single
3333
make -j 2

.github/workflows/ubuntu.yml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,20 @@ jobs:
3232
export CC=$(which icc)
3333
3434
mkdir build_dp && cd build_dp
35-
cmake .. -DCMAKE_VERBOSE_MAKEFILE=ON -DWarpX_MPI=OFF -DWarpX_COMPUTE=OMP -DWarpX_OPENPMD=ON -DWarpX_openpmd_internal=OFF
35+
cmake .. -DCMAKE_VERBOSE_MAKEFILE=ON -DWarpX_MPI=OFF -DWarpX_OPENPMD=ON -DWarpX_openpmd_internal=OFF
3636
make -j 2
3737
3838
cd ..
3939
4040
mkdir build_sp && cd build_sp
41-
cmake .. -DCMAKE_VERBOSE_MAKEFILE=ON -DWarpX_MPI=OFF -DWarpX_COMPUTE=OMP -DWarpX_OPENPMD=ON -DWarpX_openpmd_internal=OFF -DENABLE_DP=OFF -DENABLE_DP_PARTICLES=OFF
41+
cmake .. -DCMAKE_VERBOSE_MAKEFILE=ON -DWarpX_MPI=OFF -DWarpX_OPENPMD=ON -DWarpX_openpmd_internal=OFF -DWarpX_PRECISION=single
4242
make -j 2
4343
4444
build_dpcc:
4545
name: oneAPI DPC++ SP [Linux]
4646
runs-on: ubuntu-latest
4747
steps:
4848
- uses: actions/checkout@v2
49-
with:
50-
path: 'warpx_directory/WarpX'
5149
- name: install dependencies
5250
shell: bash
5351
run: |
@@ -74,12 +72,12 @@ jobs:
7472
- name: build WarpX
7573
shell: bash
7674
run: |
77-
set -ex
78-
cd warpx_directory
79-
git clone --depth 1 https://github.com/ECP-WarpX/picsar.git
80-
git clone --depth 1 --branch development https://github.com/AMReX-Codes/amrex.git
81-
cd WarpX
8275
set +e
8376
source /opt/intel/inteloneapi/setvars.sh
8477
set -e
85-
make -j 2 USE_DPCPP=TRUE USE_MPI=FALSE USE_OPENPMD=TRUE USE_OMP=FALSE PRECISION=FLOAT USE_SINGLE_PRECISION_PARTICLES=TRUE
78+
export CXX=$(which dpcpp)
79+
export CC=$(which clang)
80+
81+
mkdir build_sp && cd build_sp
82+
cmake .. -DCMAKE_VERBOSE_MAKEFILE=ON -DWarpX_MPI=OFF -DWarpX_COMPUTE=DPCPP -DWarpX_OPENPMD=ON -DWarpX_openpmd_internal=OFF -DWarpX_PRECISION=single
83+
make -j 2

CMakeLists.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ if(NOT WarpX_PRECISION IN_LIST WarpX_PRECISION_VALUES)
5454
message(FATAL_ERROR "WarpX_PRECISION (${WarpX_PRECISION}) must be one of ${WarpX_PRECISION_VALUES}")
5555
endif()
5656

57-
set(WarpX_COMPUTE_VALUES NONE CUDA OMP) # HIP DPCPP
58-
set(WarpX_COMPUTE NONE CACHE STRING "Parallel, on-node computing backend (NONE/CUDA/OMP)")
57+
set(WarpX_COMPUTE_VALUES NOACC OMP CUDA DPCPP) # HIP
58+
set(WarpX_COMPUTE OMP CACHE STRING "On-node, accelerated computing backend (NOACC/OMP/CUDA/DPCPP)")
5959
set_property(CACHE WarpX_COMPUTE PROPERTY STRINGS ${WarpX_COMPUTE_VALUES})
6060
if(NOT WarpX_COMPUTE IN_LIST WarpX_COMPUTE_VALUES)
6161
message(FATAL_ERROR "WarpX_PRECISION (${WarpX_COMPUTE}) must be one of ${WarpX_COMPUTE_VALUES}")
@@ -67,7 +67,7 @@ option(WarpX_amrex_internal "Download & build AMReX" ON)
6767
set_default_build_type("RelWithDebInfo")
6868

6969
# this defined the variable BUILD_TESTING which is ON by default
70-
include(CTest)
70+
#include(CTest)
7171

7272

7373
# Dependencies ################################################################
@@ -191,6 +191,9 @@ if(ENABLE_CUDA)
191191
)
192192
endif()
193193

194+
# fancy binary name for build variants
195+
set_warpx_binary_name()
196+
194197

195198
# Defines #####################################################################
196199
#

Docs/source/building/cmake.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,11 @@ CMake Option Default & Values Descrip
130130
For example, one can also build against a local AMReX git repo.
131131
Assuming AMReX' source is located in ``$HOME/src/amrex`` and changes are committed into a branch such as ``my-amrex-branch`` then pass to ``cmake`` the arguments: ``-DWarpX_amrex_repo=file://$HOME/src/amrex -DWarpX_amrex_branch=my-amrex-branch``.
132132

133-
For developers, WarpX can be configured in further detail with options from AMReX, which are `documented in the AMReX manual <https://amrex-codes.github.io/amrex/docs_html/BuildingAMReX.html#customization-options>`_.
133+
For developers, WarpX can be configured in further detail with options from AMReX, which are `documented in the AMReX manual <https://amrex-codes.github.io/amrex/docs_html/BuildingAMReX.html#customization-options>`_.
134+
135+
Run
136+
===
137+
138+
An executable WarpX binary with the current compile-time options encoded in its file name will be created in ``bin/``.
139+
140+
Additionally, a `symbolic link <https://en.wikipedia.org/wiki/Symbolic_link>`_ named ``warpx`` can be found in that directory, which points to the last built WarpX executable.

cmake/WarpXFunctions.cmake

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ macro(set_cxx_warnings)
101101
endif ()
102102
endmacro()
103103

104+
104105
# Take an <imported_target> and expose it as INTERFACE target with
105106
# WarpX::thirdparty::<propagated_name> naming and SYSTEM includes.
106107
#
@@ -113,6 +114,62 @@ function(make_third_party_includes_system imported_target propagated_name)
113114
endfunction()
114115

115116

117+
# Set a feature-based binary name for the WarpX executable and create a generic
118+
# warpx symlink to it. Only sets options relevant for users (see summary).
119+
#
120+
function(set_warpx_binary_name)
121+
set_target_properties(WarpX PROPERTIES OUTPUT_NAME "warpx")
122+
if(WarpX_DIMS STREQUAL 3)
123+
set_property(TARGET WarpX APPEND_STRING PROPERTY OUTPUT_NAME ".3d")
124+
elseif(WarpX_DIMS STREQUAL 2)
125+
set_property(TARGET WarpX APPEND_STRING PROPERTY OUTPUT_NAME ".2d")
126+
elseif(WarpX_DIMS STREQUAL RZ)
127+
set_property(TARGET WarpX APPEND_STRING PROPERTY OUTPUT_NAME ".RZ")
128+
endif()
129+
130+
if(WarpX_MPI)
131+
set_property(TARGET WarpX APPEND_STRING PROPERTY OUTPUT_NAME ".MPI")
132+
else()
133+
set_property(TARGET WarpX APPEND_STRING PROPERTY OUTPUT_NAME ".NOMPI")
134+
endif()
135+
136+
set_property(TARGET WarpX APPEND_STRING PROPERTY OUTPUT_NAME ".${WarpX_COMPUTE}")
137+
138+
if(WarpX_PRECISION STREQUAL "double")
139+
set_property(TARGET WarpX APPEND_STRING PROPERTY OUTPUT_NAME ".DP")
140+
else()
141+
set_property(TARGET WarpX APPEND_STRING PROPERTY OUTPUT_NAME ".SP")
142+
endif()
143+
144+
if(WarpX_ASCENT)
145+
set_property(TARGET WarpX APPEND_STRING PROPERTY OUTPUT_NAME ".ASCENT")
146+
endif()
147+
148+
if(WarpX_OPENPMD)
149+
set_property(TARGET WarpX APPEND_STRING PROPERTY OUTPUT_NAME ".OMP")
150+
endif()
151+
152+
if(WarpX_PSATD)
153+
set_property(TARGET WarpX APPEND_STRING PROPERTY OUTPUT_NAME ".PSATD")
154+
endif()
155+
156+
if(WarpX_QED)
157+
set_property(TARGET WarpX APPEND_STRING PROPERTY OUTPUT_NAME ".QED")
158+
endif()
159+
160+
if(CMAKE_BUILD_TYPE MATCHES "Debug")
161+
set_property(TARGET WarpX APPEND_STRING PROPERTY OUTPUT_NAME ".DEBUG")
162+
endif()
163+
164+
# alias to the latest build, because using the full name is often confusing
165+
add_custom_command(TARGET WarpX POST_BUILD
166+
COMMAND ${CMAKE_COMMAND} -E create_symlink
167+
$<TARGET_FILE:WarpX>
168+
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/warpx
169+
)
170+
endfunction()
171+
172+
116173
# Set an MPI_TEST_EXE variable for test runs which runs num_ranks
117174
# ranks. On some systems, you might need to use the a specific
118175
# mpiexec wrapper, e.g. on Summit (ORNL) pass the hint
@@ -164,7 +221,7 @@ function(warpx_print_summary)
164221
#else()
165222
# message(" Library: static")
166223
#endif()
167-
message(" Testing: ${BUILD_TESTING}")
224+
#message(" Testing: ${BUILD_TESTING}")
168225
#message(" Invasive Tests: ${WarpX_USE_INVASIVE_TESTS}")
169226
#message(" Internal VERIFY: ${WarpX_USE_VERIFY}")
170227
message(" Build options:")

cmake/dependencies/AMReX.cmake

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,26 @@ macro(find_amrex)
2222
if(WarpX_COMPUTE STREQUAL CUDA)
2323
set(ENABLE_ACC OFF CACHE INTERNAL "")
2424
set(ENABLE_CUDA ON CACHE INTERNAL "")
25-
#set(ENABLE_DPCPP OFF CACHE INTERNAL "")
25+
set(ENABLE_DPCPP OFF CACHE BOOL "")
26+
#set(ENABLE_HIP OFF CACHE BOOL "")
2627
set(ENABLE_OMP OFF CACHE INTERNAL "")
2728
elseif(WarpX_COMPUTE STREQUAL OMP)
2829
set(ENABLE_ACC OFF CACHE INTERNAL "")
2930
set(ENABLE_CUDA OFF CACHE INTERNAL "")
30-
#set(ENABLE_DPCPP OFF CACHE INTERNAL "")
31+
set(ENABLE_DPCPP OFF CACHE BOOL "")
32+
#set(ENABLE_HIP OFF CACHE BOOL "")
3133
set(ENABLE_OMP ON CACHE INTERNAL "")
34+
elseif(WarpX_COMPUTE STREQUAL DPCPP)
35+
set(ENABLE_ACC OFF CACHE INTERNAL "")
36+
set(ENABLE_CUDA OFF CACHE INTERNAL "")
37+
set(ENABLE_DPCPP ON CACHE BOOL "")
38+
#set(ENABLE_HIP OFF CACHE BOOL "")
39+
set(ENABLE_OMP OFF CACHE INTERNAL "")
3240
else()
3341
set(ENABLE_ACC OFF CACHE INTERNAL "")
3442
set(ENABLE_CUDA OFF CACHE INTERNAL "")
35-
#set(ENABLE_DPCPP OFF CACHE INTERNAL "")
43+
set(ENABLE_DPCPP OFF CACHE BOOL "")
44+
#set(ENABLE_HIP OFF CACHE BOOL "")
3645
set(ENABLE_OMP OFF CACHE INTERNAL "")
3746
endif()
3847

0 commit comments

Comments
 (0)