Skip to content

Commit

Permalink
Merge pull request #225 from ExCALIBUR-NEPTUNE/stp/cmake_refactor_to_…
Browse files Browse the repository at this point in the history
…merge

cmake refactor
  • Loading branch information
cmacmackin authored Apr 17, 2024
2 parents 4ef5077 + 4b5e41f commit b411422
Show file tree
Hide file tree
Showing 18 changed files with 144 additions and 91 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
build
build*/
bin
lib
thirdparty/
Expand Down Expand Up @@ -37,3 +37,7 @@ example-runs
**/*_xml/
**/*.chk
**/*.btr

#compile commands
compile_commands.json
.cache
46 changes: 27 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.21)
cmake_minimum_required(VERSION 3.24)

project(
NESO
Expand All @@ -16,23 +16,33 @@ option(ENABLE_NESO_TESTS
include(cmake/Sanitizers.cmake)
include(cmake/CheckFileList.cmake)



# ##############################################################################
# Find dependencies
# ##############################################################################
find_package(SYCL REQUIRED)
if(SYCL_FOUND)
message(STATUS "Using SYCL implementation ${SYCL_IMPLEMENTATION}")
if(hipSYCL_FOUND)
set(HIPSYCL_TARGETS "omp")
set(SYCL_FLAG NESO_HIPSYCL)
elseif(SYCL_IMPLEMENTATION STREQUAL "IntelDPCPP")
set(SYCL_FLAG NESO_DPCPP)
endif()
endif()

# Use a custom FindNektar++ script to provide an interface target
#USE -DNESO_SYCL_VENDOR to chose implementation at gen time
set(NESO_SYCL_VENDOR "Default" CACHE STRING "SYCL vendor to look for - required
if present")
set(NESO_SYCL_VERSION "" CACHE STRING "SYCL version to look for")
include(cmake/SYCL.cmake)
if (NESO_SYCL_VENDOR MATCHES "Default")
find_sycl()
else()
find_sycl(${NESO_SYCL_VENDOR} ${NESO_SYCL_VERSION})
endif()
#
# Use a custom FindNektar++ script to vide an interface target
find_package(Nektar++ REQUIRED)

#Add the NESO-Particles dependencies
find_package(NESO-Particles REQUIRED)
#Alternativly just use as submodule
#option(ENABLE_NESO_PARTICLES_TESTS OFF)
#add_subdirectory(neso-particles)
#include(neso-particles/cmake/restrict-keyword.cmake)

find_package(FFT REQUIRED)
if(FFT_FOUND)
message(STATUS "USING FFT implementation ${FFT_IMPLEMENTATION}")
Expand Down Expand Up @@ -229,7 +239,10 @@ target_compile_options(${NESO_LIBRARY_NAME} PRIVATE ${BUILD_TYPE_COMPILE_FLAGS})
target_link_options(${NESO_LIBRARY_NAME} PUBLIC ${BUILD_TYPE_LINK_FLAGS})
target_link_libraries(
${NESO_LIBRARY_NAME}
PUBLIC Nektar++::nektar++ fft::fft
PUBLIC
Nektar++::nektar++
fft::fft
NESO-Particles::NESO-Particles
PRIVATE ${TEST_LIBRARIES})
add_sycl_to_target(TARGET ${NESO_LIBRARY_NAME} SOURCES ${LIB_SRC_FILES})

Expand All @@ -249,12 +262,7 @@ add_sycl_to_target(TARGET ${PROJECT_NAME} SOURCES ${MAIN_SRC})

# find MPI
find_package(MPI REQUIRED)
# Add the NESO-Particles dependencies
find_package(NESO-PARTICLES REQUIRED)

target_link_libraries(${NESO_LIBRARY_NAME} PUBLIC ${NESO_PARTICLES_LIBRARIES})
target_include_directories(${NESO_LIBRARY_NAME}
PUBLIC ${NESO_PARTICLES_INCLUDE_PATH})

# Solvers
add_subdirectory(solvers)
Expand Down Expand Up @@ -306,8 +314,8 @@ install(
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_cmake/NESOConfigVersion.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_cmake/NESOConfig.cmake
${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindFFT.cmake
${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindSYCL.cmake
${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindNektar++.cmake
${CMAKE_CURRENT_SOURCE_DIR}/cmake/SYCL.cmake
DESTINATION ${INSTALL_CONFIGDIR})

# ##############################################################################
Expand Down
42 changes: 0 additions & 42 deletions cmake/FindSYCL.cmake

This file was deleted.

6 changes: 4 additions & 2 deletions cmake/NESOConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
get_filename_component(NESO_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
include(CMakeFindDependencyMacro)

include("${NESO_CMAKE_DIR}/SYCL.cmake")
find_sycl_if_required()

list(APPEND CMAKE_MODULE_PATH ${NESO_CMAKE_DIR})
find_dependency(SYCL REQUIRED)
find_dependency(Nektar++ REQUIRED)
find_dependency(FFT REQUIRED)
list(REMOVE_AT CMAKE_MODULE_PATH -1)
Expand All @@ -11,4 +13,4 @@ if(NOT TARGET NESO::@PROJECT_NAME@)
include("${NESO_CMAKE_DIR}/@[email protected]")
endif()

set(NESO_LIBRARIES NESO::@LIBRARY_NAME@)
set(NESO_LIBRARIES NESO::@NESO_LIBRARY_NAME@)
71 changes: 71 additions & 0 deletions cmake/SYCL.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#Macro to find a sycl implimentation
#Called without arguments will try to find a compiler appropriate sycl
#With one argument finds that specific implimentation
#With 2 arguments is as above but second argument is treated like version
#Not happy with this yet -
# - should be able to accept lists of implementaions and versions
# - and target architectures CPU,GPU etc
macro(find_sycl)
set(SYCL_FOUND FALSE )
if (${ARGC} EQUAL 0)
#If intel compiler try to find the intel
if (CMAKE_CXX_COMPILER_ID MATCHES "Intel")
#TODO IntelDPCPP is deprecated remove
list(APPEND candidates "IntelSYCL" "IntelDPCPP")
foreach(candidate IN LISTS candidates)
find_package(${candidate} QUIET)
if(${candidate}_FOUND)
set(SYCL_FOUND TRUE )
set(SYCL_IMPLEMENTATION ${candidate} )
break()
endif()
endforeach()
else()
#not intel try one of these
list(APPEND candidates "AdaptiveCPP" "hipSYCL")
list(APPEND versions "" "0.9.4")
foreach(candidate version IN ZIP_LISTS candidates versions)
find_package(${candidate} ${version} QUIET)
if(${candidate}_FOUND)
set(SYCL_FOUND TRUE )
set(SYCL_IMPLEMENTATION ${candidate} )
break()
endif()
endforeach()
endif()
elseif (${ARGC} EQUAL 1)
find_package(${ARGV0} REQUIRED)
if(${ARGV0}_FOUND)
set(SYCL_FOUND TRUE )
set(SYCL_IMPLEMENTATION ${ARGV0} )
endif()
elseif (${ARGC} EQUAL 2)
find_package(${ARGV0} ${ARGV1} REQUIRED)
if(${ARGV0}_FOUND)
set(SYCL_FOUND TRUE )
set(SYCL_IMPLEMENTATION ${ARGV0} )
endif()
endif()
if (NOT COMMAND add_sycl_to_target)
function(add_sycl_to_target)
endfunction()
endif()
if (SYCL_FOUND)
message(STATUS "Found SYCL implimentation ${SYCL_IMPLEMENTATION}")
elseif()
message(WARNING "No SYCL implimentation found - "
"Proceeding on the assumption that the CXX compiler is a SYCL2020 compiler")
endif()
endmacro()

macro(find_sycl_if_required)
if (COMMAND add_sycl_to_target)
#Not perfect method but if in a submodule dont want to use a different
#sycl
message(STATUS "add_sycl_to_target macro exists")
else()
message(STATUS "add_sycl_to_target macro NOT FOUND looking for SYCL implementation...")
find_sycl()
endif()
endmacro()

2 changes: 1 addition & 1 deletion include/nektar_interface/basis_evaluation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ inline void mod_PyrC(const int nummodes, const REAL z, const int k_stride_n,

REAL pn, pnm1, pnm2;
const int alpha = 2 * p + 2 * q - 3;
int maxpq = max(p, q);
int maxpq = std::max(p, q);

/*
* The remaining terms are of the form
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <iostream>
#include <mpi.h>

using namespace std;
using namespace Nektar;
using namespace Nektar::SpatialDomains;
using namespace Nektar::LibUtilities;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

#include "shape_mapping.hpp"

using namespace std;
using namespace Nektar;
using namespace Nektar::SpatialDomains;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <iostream>
#include <mpi.h>

using namespace std;
using namespace Nektar;
using namespace Nektar::SpatialDomains;
using namespace Nektar::LibUtilities;
Expand Down
4 changes: 2 additions & 2 deletions include/nektar_interface/utility_mesh_plotting.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ class VTKGeometryWriter {
*/
inline void write(std::string filename) {
// vertices required
std::map<int, shared_ptr<PointGeom>> vertices;
std::map<int, std::shared_ptr<PointGeom>> vertices;
// edges required
std::map<int, shared_ptr<Geometry1D>> edges;
std::map<int, std::shared_ptr<Geometry1D>> edges;

for (auto &geom : this->geoms) {
const int num_edges = geom->GetNumEdges();
Expand Down
2 changes: 1 addition & 1 deletion include/particle_utility/particle_initialisation_line.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class ParticleInitialisationLine {
NESO::Particles::parallel_advection_initialisation(particle_group);

auto particle_mesh_interface =
dynamic_pointer_cast<ParticleMeshInterface>(domain->mesh);
std::dynamic_pointer_cast<ParticleMeshInterface>(domain->mesh);
// Setup map between cell indices
auto cell_id_translation = std::make_shared<CellIDTranslation>(
sycl_target, particle_group->cell_id_dat, particle_mesh_interface);
Expand Down
2 changes: 1 addition & 1 deletion neso-particles
Submodule neso-particles updated 84 files
+1 −0 .github/workflows/build_docs.yaml
+175 −52 CMakeLists.txt
+5 −0 README.md
+22 −0 cmake/Config.cmake.in
+71 −0 cmake/SYCL.cmake
+19 −0 cmake/check-file-list.cmake
+0 −40 cmake/neso-particles-config.cmake
+40 −0 cmake/restrict-keyword.cmake
+3 −3 docs/doxygen/Doxyfile
+1 −1 docs/generate_versions_json.py
+1 −1 docs/sphinx/requirements.txt
+76 −5 docs/sphinx/source/concept/particle_loop.rst
+50 −0 docs/sphinx/source/concept/particle_products.rst
+8 −8 docs/sphinx/source/guide-user/api_reference.rst
+107 −0 docs/sphinx/source/guide-user/installation.rst
+4 −5 include/boundary_conditions.hpp
+9 −2 include/cartesian_mesh.hpp
+6 −1 include/cell_binning.hpp
+5 −651 include/cell_dat.hpp
+24 −1 include/cell_dat_compression.hpp
+1 −0 include/cell_dat_move.hpp
+23 −0 include/cell_dat_move_impl.hpp
+190 −196 include/compute_target.hpp
+566 −0 include/containers/cell_dat.hpp
+428 −0 include/containers/cell_dat_const.hpp
+98 −0 include/containers/cell_data.hpp
+222 −0 include/containers/descendant_products.hpp
+135 −2 include/containers/global_array.hpp
+177 −2 include/containers/local_array.hpp
+604 −0 include/containers/product_matrix.hpp
+263 −0 include/containers/sym_vector.hpp
+85 −0 include/error_propagate.hpp
+2 −1 include/global_mapping.hpp
+1 −1 include/global_mapping_impl.hpp
+21 −11 include/global_move.hpp
+5 −1 include/global_move_exchange.hpp
+14 −0 include/local_move.hpp
+95 −0 include/loop/access_descriptors.hpp
+194 −712 include/loop/particle_loop.hpp
+98 −0 include/loop/particle_loop_base.hpp
+130 −0 include/loop/particle_loop_index.hpp
+149 −0 include/loop/pli_particle_dat.hpp
+22 −3 include/mesh_interface.hpp
+5 −0 include/neso_particles.hpp
+12 −0 include/packing_unpacking.hpp
+153 −31 include/particle_dat.hpp
+320 −266 include/particle_group.hpp
+615 −0 include/particle_group_impl.hpp
+47 −0 include/particle_set.hpp
+85 −6 include/particle_spec.hpp
+549 −127 include/particle_sub_group.hpp
+165 −26 include/profiling.hpp
+60 −6 include/typedefs.hpp
+3 −2 include/utility.hpp
+101 −30 include/utility_mesh_hierarchy_plotting.hpp
+44 −26 test/CMakeLists.txt
+183 −0 test/example_sources/example_particle_descendant_products.hpp
+6 −2 test/example_sources/example_particle_loop_cell_dat_const.hpp
+30 −0 test/example_sources/example_particle_loop_index.hpp
+35 −0 test/example_sources/example_particle_loop_sym_vector.hpp
+10 −1 test/example_sources/example_particle_sub_group_creation.hpp
+2 −2 test/example_sources/example_particle_sub_group_loop.hpp
+20 −0 test/include/test_base.hpp
+22 −0 test/include/test_neso_particles.hpp
+147 −0 test/include/test_particle_group.hpp
+16 −3 test/test_buffers.cpp
+65 −0 test/test_cell_dat.cpp
+2 −2 test/test_error_propagate.cpp
+15 −8 test/test_examples.cpp
+3 −3 test/test_int_key_value_map.cpp
+5 −5 test/test_particle_dat.cpp
+369 −73 test/test_particle_group.cpp
+22 −37 test/test_particle_group_cell_move.cpp
+57 −63 test/test_particle_group_global_move.cpp
+36 −59 test/test_particle_group_hybrid_move.cpp
+48 −91 test/test_particle_group_local_move.cpp
+41 −69 test/test_particle_group_stencil_move.cpp
+1 −1 test/test_particle_h5part.cpp
+361 −6 test/test_particle_loop.cpp
+20 −0 test/test_particle_set.cpp
+756 −16 test/test_particle_sub_group.cpp
+662 −0 test/test_product_matrix.cpp
+5 −5 test/test_tuple.cpp
+2 −2 test/test_utility.cpp
21 changes: 12 additions & 9 deletions solvers/Electrostatic2D3V/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ add_library(${ELECTROSTATIC_2D3V_LIBRARY_NAME} OBJECT

target_include_directories(
${ELECTROSTATIC_2D3V_LIBRARY_NAME}
PRIVATE ${MPI_INCLUDE_PATH} ${CMAKE_SOURCE_DIR}/include
${NESO_PARTICLES_INCLUDE_PATH})
PRIVATE ${CMAKE_SOURCE_DIR}/include)


target_link_libraries(
${ELECTROSTATIC_2D3V_LIBRARY_NAME}
PRIVATE ${NESO_LIBRARY_NAME} Nektar++::nektar++ ${MPI_LIBRARIES}
${NESO_PARTICLES_LIBRARIES} ${NESO_PARTICLES_LINK_FLAGS})
PRIVATE ${NESO_LIBRARY_NAME}
Nektar++::nektar++
NESO-Particles::NESO-Particles
MPI::MPI_CXX)

# create the solver binary
file(GLOB Electrostatic2D3VSource
Expand All @@ -27,14 +29,15 @@ add_executable(${EXEC_TARGET_NAME} ${Electrostatic2D3VSource})

target_link_libraries(
${EXEC_TARGET_NAME}
PRIVATE ${ELECTROSTATIC_2D3V_LIBRARY_NAME} Nektar++::nektar++
${MPI_LIBRARIES} ${NESO_PARTICLES_LIBRARIES})
PRIVATE ${ELECTROSTATIC_2D3V_LIBRARY_NAME}
Nektar++::nektar++
MPI::MPI_CXX
NESO-Particles::NESO-Particles)

add_link_options(${EXEC_TARGET_NAME} PRIVATE ${NESO_PARTICLES_LINK_FLAGS})

target_include_directories(
${EXEC_TARGET_NAME} PRIVATE ${MPI_INCLUDE_PATH} ${CMAKE_SOURCE_DIR}/include
${NESO_PARTICLES_INCLUDE_PATH})
${EXEC_TARGET_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/include)


add_sycl_to_target(TARGET ${EXEC_TARGET_NAME} SOURCES
${Electrostatic2D3VSource})
Expand Down
9 changes: 5 additions & 4 deletions solvers/H3LAPD/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ set(SOLVER_LIBS
CACHE INTERNAL "")
add_library(${LIBRARY_NAME} OBJECT ${H3LAPD_SRC_FILES})
target_compile_options(${LIBRARY_NAME} PRIVATE ${BUILD_TYPE_COMPILE_FLAGS})
target_link_libraries(${LIBRARY_NAME} PRIVATE Nektar++::nektar++)
target_link_libraries(${LIBRARY_NAME} PRIVATE Nektar++::nektar++
NESO-Particles::NESO-Particles)
# Top-level include dir for nektar-interface headers
set(TOPLEVEL_INCLUDE_DIR "${INC_DIR}")
target_include_directories(
${LIBRARY_NAME} PUBLIC ${CMAKE_CURRENT_LIST_DIR}
${NESO_PARTICLES_INCLUDE_PATH} ${TOPLEVEL_INCLUDE_DIR})
${TOPLEVEL_INCLUDE_DIR})

add_sycl_to_target(TARGET ${LIBRARY_NAME} SOURCES ${H3LAPD_SRC_FILES})

Expand All @@ -31,8 +32,8 @@ target_compile_options(${EXEC_TARGET_NAME} PRIVATE ${BUILD_TYPE_COMPILE_FLAGS})
# Linker options, target libs
target_link_options(${EXEC_TARGET_NAME} PRIVATE ${BUILD_TYPE_LINK_FLAGS})
target_link_libraries(
${EXEC_TARGET_NAME} PRIVATE Nektar++::nektar++ ${NESO_PARTICLES_LIBRARIES}
${NESO_LIBRARY_NAME})
${EXEC_TARGET_NAME} PRIVATE Nektar++::nektar++
NESO-Particles::NESO-Particles ${NESO_LIBRARY_NAME})

add_sycl_to_target(TARGET ${EXEC_TARGET_NAME} SOURCES main.cpp)

Expand Down
12 changes: 8 additions & 4 deletions solvers/SimpleSOL/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Identify source files
set(SIMPLE_SOL_SRC_FILES
EquationSystems/SOLSystem.cpp EquationSystems/SOLWithParticlesSystem.cpp
Forcing/SourceTerms.cpp SimpleSOL.cpp)
EquationSystems/SOLSystem.cpp
EquationSystems/SOLWithParticlesSystem.cpp
Forcing/SourceTerms.cpp
SimpleSOL.cpp
)

# ============================== Object library ===============================
# Put solver specific source in an object library so that tests can use it
Expand All @@ -12,12 +15,13 @@ set(SOLVER_LIBS
add_library(${LIBRARY_NAME} OBJECT ${SIMPLE_SOL_SRC_FILES})
target_compile_options(${LIBRARY_NAME} PRIVATE ${BUILD_TYPE_COMPILE_FLAGS})
target_link_libraries(${LIBRARY_NAME} PRIVATE Nektar++::nektar++
NESO-Particles::NESO-Particles
${NESO_LIBRARY_NAME})
# Top-level include dir for nektar-interface headers
set(TOPLEVEL_INCLUDE_DIR "${INC_DIR}")
target_include_directories(
${LIBRARY_NAME} PUBLIC ${CMAKE_CURRENT_LIST_DIR}
${NESO_PARTICLES_INCLUDE_PATH} ${TOPLEVEL_INCLUDE_DIR})
${TOPLEVEL_INCLUDE_DIR})

add_sycl_to_target(TARGET ${LIBRARY_NAME} SOURCES ${SIMPLE_SOL_SRC_FILES})

Expand All @@ -32,7 +36,7 @@ target_compile_options(${EXEC_TARGET_NAME} PRIVATE ${BUILD_TYPE_COMPILE_FLAGS})
# Linker options, target libs
target_link_options(${EXEC_TARGET_NAME} PRIVATE ${BUILD_TYPE_LINK_FLAGS})
target_link_libraries(
${EXEC_TARGET_NAME} PRIVATE Nektar++::nektar++ ${NESO_PARTICLES_LIBRARIES}
${EXEC_TARGET_NAME} PRIVATE Nektar++::nektar++ NESO-Particles::NESO-Particles
${NESO_LIBRARY_NAME})

add_sycl_to_target(TARGET ${EXEC_TARGET_NAME} SOURCES main.cpp)
Expand Down
Loading

0 comments on commit b411422

Please sign in to comment.