Skip to content

Commit

Permalink
CMake: DPC++, OMP Def., Binary Names (ECP-WarpX#1125)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ax3l authored Jul 2, 2020
1 parent c8d587e commit 5f03747
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 20 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ jobs:
- name: build WarpX
run: |
mkdir build_dp && cd build_dp
cmake .. -DCMAKE_VERBOSE_MAKEFILE=ON -DWarpX_COMPUTE=OMP -DWarpX_OPENPMD=ON -DWarpX_openpmd_internal=OFF
cmake .. -DCMAKE_VERBOSE_MAKEFILE=ON -DWarpX_OPENPMD=ON -DWarpX_openpmd_internal=OFF
make -j 2
cd ..
mkdir build_sp && cd build_sp
cmake .. -DCMAKE_VERBOSE_MAKEFILE=ON -DWarpX_COMPUTE=OMP -DWarpX_OPENPMD=ON -DWarpX_openpmd_internal=OFF -DENABLE_DP=OFF -DENABLE_DP_PARTICLES=OFF
cmake .. -DCMAKE_VERBOSE_MAKEFILE=ON -DWarpX_OPENPMD=ON -DWarpX_openpmd_internal=OFF -DWarpX_PRECISION=single
make -j 2
18 changes: 8 additions & 10 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,20 @@ jobs:
export CC=$(which icc)
mkdir build_dp && cd build_dp
cmake .. -DCMAKE_VERBOSE_MAKEFILE=ON -DWarpX_MPI=OFF -DWarpX_COMPUTE=OMP -DWarpX_OPENPMD=ON -DWarpX_openpmd_internal=OFF
cmake .. -DCMAKE_VERBOSE_MAKEFILE=ON -DWarpX_MPI=OFF -DWarpX_OPENPMD=ON -DWarpX_openpmd_internal=OFF
make -j 2
cd ..
mkdir build_sp && cd build_sp
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
cmake .. -DCMAKE_VERBOSE_MAKEFILE=ON -DWarpX_MPI=OFF -DWarpX_OPENPMD=ON -DWarpX_openpmd_internal=OFF -DWarpX_PRECISION=single
make -j 2
build_dpcc:
name: oneAPI DPC++ SP [Linux]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
path: 'warpx_directory/WarpX'
- name: install dependencies
shell: bash
run: |
Expand All @@ -74,12 +72,12 @@ jobs:
- name: build WarpX
shell: bash
run: |
set -ex
cd warpx_directory
git clone --depth 1 https://github.com/ECP-WarpX/picsar.git
git clone --depth 1 --branch development https://github.com/AMReX-Codes/amrex.git
cd WarpX
set +e
source /opt/intel/inteloneapi/setvars.sh
set -e
make -j 2 USE_DPCPP=TRUE USE_MPI=FALSE USE_OPENPMD=TRUE USE_OMP=FALSE PRECISION=FLOAT USE_SINGLE_PRECISION_PARTICLES=TRUE
export CXX=$(which dpcpp)
export CC=$(which clang)
mkdir build_sp && cd build_sp
cmake .. -DCMAKE_VERBOSE_MAKEFILE=ON -DWarpX_MPI=OFF -DWarpX_COMPUTE=DPCPP -DWarpX_OPENPMD=ON -DWarpX_openpmd_internal=OFF -DWarpX_PRECISION=single
make -j 2
9 changes: 6 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ if(NOT WarpX_PRECISION IN_LIST WarpX_PRECISION_VALUES)
message(FATAL_ERROR "WarpX_PRECISION (${WarpX_PRECISION}) must be one of ${WarpX_PRECISION_VALUES}")
endif()

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

# this defined the variable BUILD_TESTING which is ON by default
include(CTest)
#include(CTest)


# Dependencies ################################################################
Expand Down Expand Up @@ -191,6 +191,9 @@ if(ENABLE_CUDA)
)
endif()

# fancy binary name for build variants
set_warpx_binary_name()


# Defines #####################################################################
#
Expand Down
9 changes: 8 additions & 1 deletion Docs/source/building/cmake.rst
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,11 @@ CMake Option Default & Values Descrip
For example, one can also build against a local AMReX git repo.
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``.

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>`_.
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>`_.

Run
===

An executable WarpX binary with the current compile-time options encoded in its file name will be created in ``bin/``.

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.
59 changes: 58 additions & 1 deletion cmake/WarpXFunctions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ macro(set_cxx_warnings)
endif ()
endmacro()


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


# Set a feature-based binary name for the WarpX executable and create a generic
# warpx symlink to it. Only sets options relevant for users (see summary).
#
function(set_warpx_binary_name)
set_target_properties(WarpX PROPERTIES OUTPUT_NAME "warpx")
if(WarpX_DIMS STREQUAL 3)
set_property(TARGET WarpX APPEND_STRING PROPERTY OUTPUT_NAME ".3d")
elseif(WarpX_DIMS STREQUAL 2)
set_property(TARGET WarpX APPEND_STRING PROPERTY OUTPUT_NAME ".2d")
elseif(WarpX_DIMS STREQUAL RZ)
set_property(TARGET WarpX APPEND_STRING PROPERTY OUTPUT_NAME ".RZ")
endif()

if(WarpX_MPI)
set_property(TARGET WarpX APPEND_STRING PROPERTY OUTPUT_NAME ".MPI")
else()
set_property(TARGET WarpX APPEND_STRING PROPERTY OUTPUT_NAME ".NOMPI")
endif()

set_property(TARGET WarpX APPEND_STRING PROPERTY OUTPUT_NAME ".${WarpX_COMPUTE}")

if(WarpX_PRECISION STREQUAL "double")
set_property(TARGET WarpX APPEND_STRING PROPERTY OUTPUT_NAME ".DP")
else()
set_property(TARGET WarpX APPEND_STRING PROPERTY OUTPUT_NAME ".SP")
endif()

if(WarpX_ASCENT)
set_property(TARGET WarpX APPEND_STRING PROPERTY OUTPUT_NAME ".ASCENT")
endif()

if(WarpX_OPENPMD)
set_property(TARGET WarpX APPEND_STRING PROPERTY OUTPUT_NAME ".OMP")
endif()

if(WarpX_PSATD)
set_property(TARGET WarpX APPEND_STRING PROPERTY OUTPUT_NAME ".PSATD")
endif()

if(WarpX_QED)
set_property(TARGET WarpX APPEND_STRING PROPERTY OUTPUT_NAME ".QED")
endif()

if(CMAKE_BUILD_TYPE MATCHES "Debug")
set_property(TARGET WarpX APPEND_STRING PROPERTY OUTPUT_NAME ".DEBUG")
endif()

# alias to the latest build, because using the full name is often confusing
add_custom_command(TARGET WarpX POST_BUILD
COMMAND ${CMAKE_COMMAND} -E create_symlink
$<TARGET_FILE:WarpX>
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/warpx
)
endfunction()


# Set an MPI_TEST_EXE variable for test runs which runs num_ranks
# ranks. On some systems, you might need to use the a specific
# mpiexec wrapper, e.g. on Summit (ORNL) pass the hint
Expand Down Expand Up @@ -164,7 +221,7 @@ function(warpx_print_summary)
#else()
# message(" Library: static")
#endif()
message(" Testing: ${BUILD_TESTING}")
#message(" Testing: ${BUILD_TESTING}")
#message(" Invasive Tests: ${WarpX_USE_INVASIVE_TESTS}")
#message(" Internal VERIFY: ${WarpX_USE_VERIFY}")
message(" Build options:")
Expand Down
15 changes: 12 additions & 3 deletions cmake/dependencies/AMReX.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,26 @@ macro(find_amrex)
if(WarpX_COMPUTE STREQUAL CUDA)
set(ENABLE_ACC OFF CACHE INTERNAL "")
set(ENABLE_CUDA ON CACHE INTERNAL "")
#set(ENABLE_DPCPP OFF CACHE INTERNAL "")
set(ENABLE_DPCPP OFF CACHE BOOL "")
#set(ENABLE_HIP OFF CACHE BOOL "")
set(ENABLE_OMP OFF CACHE INTERNAL "")
elseif(WarpX_COMPUTE STREQUAL OMP)
set(ENABLE_ACC OFF CACHE INTERNAL "")
set(ENABLE_CUDA OFF CACHE INTERNAL "")
#set(ENABLE_DPCPP OFF CACHE INTERNAL "")
set(ENABLE_DPCPP OFF CACHE BOOL "")
#set(ENABLE_HIP OFF CACHE BOOL "")
set(ENABLE_OMP ON CACHE INTERNAL "")
elseif(WarpX_COMPUTE STREQUAL DPCPP)
set(ENABLE_ACC OFF CACHE INTERNAL "")
set(ENABLE_CUDA OFF CACHE INTERNAL "")
set(ENABLE_DPCPP ON CACHE BOOL "")
#set(ENABLE_HIP OFF CACHE BOOL "")
set(ENABLE_OMP OFF CACHE INTERNAL "")
else()
set(ENABLE_ACC OFF CACHE INTERNAL "")
set(ENABLE_CUDA OFF CACHE INTERNAL "")
#set(ENABLE_DPCPP OFF CACHE INTERNAL "")
set(ENABLE_DPCPP OFF CACHE BOOL "")
#set(ENABLE_HIP OFF CACHE BOOL "")
set(ENABLE_OMP OFF CACHE INTERNAL "")
endif()

Expand Down

0 comments on commit 5f03747

Please sign in to comment.