Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@ on:

jobs:
CI:
defaults:
run:
shell: bash
strategy:
matrix:
distro: ['ubuntu:latest']
backend: ["SERIAL", "OPENMP"]
arborx: ["ArborX", "NoArborX"]
runs-on: ubuntu-20.04
container:
image: ghcr.io/ecp-copa/ci-containers/${{ matrix.distro }}
Expand All @@ -30,10 +34,26 @@ jobs:
run: |
cmake -B build \
-DCMAKE_INSTALL_PREFIX=$HOME/kokkos \
-DKokkos_CXX_STANDARD=14 \
-DKokkos_CXX_STANDARD=17 \
-DKokkos_ENABLE_${{ matrix.backend }}=ON
cmake --build build --parallel 2
cmake --install build
- name: Checkout arborx
if: ${{ matrix.arborx == 'ArborX' }}
uses: actions/[email protected]
with:
repository: arborx/ArborX
ref: v1.2
path: arborx
- name: Build arborx
if: ${{ matrix.arborx == 'ArborX' }}
working-directory: arborx
run: |
cmake -B build \
-DCMAKE_PREFIX_PATH=${HOME}/kokkos \
-DCMAKE_INSTALL_PREFIX=$HOME/arborx
cmake --build build --parallel 2
cmake --install build
- name: Checkout Cabana
uses: actions/[email protected]
with:
Expand All @@ -43,10 +63,12 @@ jobs:
- name: Build Cabana
working-directory: Cabana
run: |
[[ ${{ matrix.arborx }} == 'ArborX' ]] && cmake_opts+=( -DCabana_REQUIRE_ARBORX=ON )
cmake -B build \
-DCMAKE_INSTALL_PREFIX=$HOME/Cabana \
-DCMAKE_PREFIX_PATH="$HOME/kokkos" \
-DCabana_REQUIRE_${{ matrix.backend }}=ON
-DCMAKE_PREFIX_PATH="$HOME/kokkos;$HOME/arborx" \
-DCabana_REQUIRE_${{ matrix.backend }}=ON \
${cmake_opts[@]}
cmake --build build --parallel 2
cmake --install build
- name: Checkout code
Expand Down
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,12 @@ include(GNUInstallDirs)

find_package(Cabana)

option(HACCabana_REQUIRE_ARBORX "Build HACCabana with Cabana-ArborX neighbor list support" ${Cabana_ENABLE_ARBORX})
if(${HACCabana_REQUIRE_ARBORX} AND NOT ${Cabana_ENABLE_ARBORX})
message(FATAL_ERROR "Cabana must be compiled with ArborX support to use HACCabana_REQUIRE_ARBORX")
endif()
set(HACCabana_ENABLE_ARBORX ${HACCabana_REQUIRE_ARBORX})
if(HACCabana_ENABLE_ARBORX)
message(STATUS "ArborX neighbor list enabled.")
endif()
add_subdirectory(src)
9 changes: 9 additions & 0 deletions cmake/HACCabanaConfig.cmakein
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
include(CMakeFindDependencyMacro)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}" )
list(APPEND CMAKE_PREFIX_PATH @CMAKE_PREFIX_PATH@)
find_dependency(Kokkos REQUIRED)
find_dependency(Cabana REQUIRED)
set(HACCabana_ENABLE_ARBORX @HACCabana_ENABLE_ARBORX@)
if(HACCabana_ENABLE_ARBORX)
find_dependency(ArborX REQUIRED)
endif()
9 changes: 5 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
configure_file(HACCabana_Config.h.cmakein HACCabana_Config.h)

file(GLOB HACCABANA_HEADERS *.h)
file(GLOB HACCABANA_SOURCES *.cxx)

install(FILES ${HACCABANA_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

add_library(HACCabana ${HACCABANA_SOURCES})

target_include_directories(HACCabana PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
Expand All @@ -17,9 +17,10 @@ install(TARGETS HACCabana
target_link_libraries(HACCabana Cabana::cabanacore)

install(TARGETS HACCabana DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/HACCabana_Config.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

# Require minimum of C++14
set_target_properties(HACCabana PROPERTIES INTERFACE_COMPILE_FEATURES cxx_std_14)
# Require minimum of C++17
set_target_properties(HACCabana PROPERTIES INTERFACE_COMPILE_FEATURES cxx_std_17)

add_executable(driver_short-range driver_gpu.cxx)
target_link_libraries(driver_short-range PUBLIC HACCabana)
Expand Down
6 changes: 6 additions & 0 deletions src/HACCabana_Config.h.cmakein
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef HACCABANA_CONFIG_HPP
#define HACCABANA_CONFIG_HPP

#cmakedefine HACCabana_ENABLE_ARBORX

#endif
85 changes: 85 additions & 0 deletions src/Neighbor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#ifndef NEIGHBORS_H
#define NEIGHBORS_H

#include "HACCabana_Config.h"

namespace HACCabana
{
struct LinkedCellTag
{
};
struct ArborXTag
{
};

template <typename AoSoADevice, typename NeighborType>
struct Neighbors;

template <typename AoSoADevice>
struct Neighbors<AoSoADevice, LinkedCellTag>
{
using device_type = typename AoSoADevice::device_type;
using neighbor_type = Cabana::LinkedCellList<device_type>;
using tag_type = LinkedCellTag;
// Store to avoid reallocation during rebuild.
neighbor_type cell_list;

Neighbors(AoSoADevice aosoa_device,
const float, const float cm_size, const float min_pos,
const float max_pos)
{
auto position = Cabana::slice<HACCabana::Particles::Fields::Position>(
aosoa_device, "position");

// create the cell list on the GPU
// NOTE: fuzz particles (outside of overload) are not included
float dx = cm_size;
float x_min = min_pos;
float x_max = max_pos;

float grid_delta[3] = {dx, dx, dx};
float grid_min[3] = {x_min, x_min, x_min};
float grid_max[3] = {x_max, x_max, x_max};

cell_list = neighbor_type(position, grid_delta, grid_min, grid_max);
}

template <typename ParticlesType>
void update(ParticlesType aosoa_device)
{
cell_list.build(aosoa_device);
Cabana::permute(cell_list, aosoa_device);
}
};

#ifdef HACCabana_ENABLE_ARBORX
template <typename AoSoADevice>
struct Neighbors<AoSoADevice, ArborXTag>
{
using device_type = typename AoSoADevice::device_type;
using neighbor_type =
Cabana::Experimental::CrsGraph<typename device_type::memory_space,
Cabana::FullNeighborTag>;
using tag_type = ArborXTag;
neighbor_type neighbor_list;

Neighbors(AoSoADevice aosoa_device, const float rmax2, const float,
const float, const float)
{
auto position = Cabana::slice<HACCabana::Particles::Fields::Position>(
aosoa_device, "position");
// Interface in Cabana to ArborX neighbor search.
neighbor_list = Cabana::Experimental::makeNeighborList<device_type>(
Cabana::FullNeighborTag{}, position, 0, position.size(), rmax2);
}
};
#endif

template <typename NeighborType, typename AoSoADevice>
auto createNeighbors(AoSoADevice &aosoa_device, const float rmax2, const float cm_size, const float min_pos,
const float max_pos)
{
return Neighbors<AoSoADevice, NeighborType>(aosoa_device, rmax2, cm_size, min_pos, max_pos);
}
}
#endif
Loading