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
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ spack*
*.gdml

*.log
cmake-build-debug
clueLib/cmake-build-debug
data/output
build
build.*.log
NMake
Expand Down Expand Up @@ -56,3 +59,6 @@ CTestTestfile.cmake
CPackSourceConfig.cmake
CPackConfig.cmake
cmake_install.cmake

# third party libraries
alpaka/
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "alpaka"]
path = alpaka
url = https://github.com/psychocoderHPC/alpaka2.git
branch = dev
path = alpaka
url = git@github.com:alpaka-group/alpaka3.git
branch = dev
79 changes: 41 additions & 38 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ project(
# Location of the ALPAKA
set(ALPAKA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/alpaka CACHE PATH "Path to ALPAKA (by default: submodule)")

# Location of TBB
#set(TBB_DIR "/cvmfs/cms.cern.ch/slc7_amd64_gcc820/external/tbb/2020_U2-ghbfee/cmake/TBB/")

# Activate VERBOSE output
set(CMAKE_VERBOSE_MAKEFILE OFF)

Expand All @@ -20,10 +17,12 @@ include(CheckLanguage)
check_language(CUDA)
if(CMAKE_CUDA_COMPILER)
enable_language(CUDA)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CUDA_ARCHITECTURES "60;70;75")
set(CMAKE_CXX_STANDARD 20)
if(NOT CMAKE_CUDA_ARCHITECTURES)
set(CMAKE_CUDA_ARCHITECTURES "60;70;75;80")
endif()
else()
message(STATUS "No CUDA compiler found. Still, you can run the C++ version!")
message(STATUS "No CUDA compiler found. Still, you can run the C++ version and alpaka!")
endif()

if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
Expand All @@ -33,56 +32,60 @@ endif()
include(GNUInstallDirs)

# Set up C++ Standard
set(CMAKE_CXX_STANDARD 17 CACHE STRING "")
set(CMAKE_CXX_STANDARD 20 CACHE STRING "")

if(NOT CMAKE_CXX_STANDARD MATCHES "17|20")
message(FATAL_ERROR "Unsupported C++ standard: ${CMAKE_CXX_STANDARD}")
endif()

# Find Boost
set(Boost_DEBUG 1)
find_package(Boost REQUIRED)

# Include Boost headers
include_directories(${Boost_INCLUDE_DIRS})

if(Boost_FOUND)
message(STATUS "Boost package found!")
endif()

#find_package(TBB REQUIRED)
#if(TBB_FOUND)
# message(STATUS "TBB package found!")
#endif()
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/alpaka")

add_subdirectory(clueLib)
add_subdirectory(src)

# SOME TESTS
enable_testing()

# Shared implementation (run test [cpu/gpu])
function(run_test_common target label repeats suffix extra_args)
file(GLOB inputs "${CMAKE_CURRENT_SOURCE_DIR}/data/input/*.csv")
foreach(input_file IN LISTS inputs)
get_filename_component(input_dir "${input_file}" DIRECTORY)
get_filename_component(input_name "${input_file}" NAME_WE)
get_filename_component(input_ext "${input_file}" EXT)

set(test_name "${input_name}_${label}_${suffix}")
set(output_file "${input_dir}/${test_name}${input_ext}")

add_test(
NAME "${test_name}"
COMMAND $<TARGET_FILE:${target}>
-i "${input_file}"
-O "${output_file}"
-d 7.0 -r10.0 -o 2 -e "${repeats}" -v
${extra_args}
)
endforeach()
endfunction()

function(run_test_cpu target label repeats)
FILE(GLOB inputs "${CMAKE_CURRENT_SOURCE_DIR}/data/input/*.csv")
foreach(input_file IN LISTS inputs)
add_test(NAME ${input_file}_${label}_CPU COMMAND ${target} -i ${input_file} -d 7.0 -r10.0 -o 2 -e ${repeats} -v)
endforeach()
run_test_common("${target}" "${label}" "${repeats}" "CPU" "")
endfunction()

function(run_test_gpu target label repeats)
FILE(GLOB inputs "${CMAKE_CURRENT_SOURCE_DIR}/data/input/*.csv")
foreach(input_file IN LISTS inputs)
add_test(NAME ${input_file}_${label}_GPU COMMAND ${target} -i ${input_file} -d 7.0 -r10.0 -o 2 -e ${repeats} -v -u)
endforeach()
function(run_test_gpu target label repeats executor)
# Pass the executor-specific args through to the shared function
run_test_common("${target}" "${label}" "${repeats}" "${executor}" "-u;${executor}")
endfunction()

if(CMAKE_CUDA_COMPILER)
run_test_cpu(./src/clue/main main 4)
run_test_cpu(./src/clue_cuda_alpaka/mainAlpakaCUDA Alpaka 4)
run_test_gpu(./src/clue/main CUDA 100)
run_test_gpu(./src/clue_cuda_alpaka/mainAlpakaCUDA AlpakaCUDA 100)
#else()
#run_test_cpu(./src/clue_tbb_alpaka/mainAlpakaTBB TBB 4)
if(alpaka_EXEC_GpuCuda)
run_test_gpu(mainAlpaka Alpaka 100 GpuCuda)
endif()

if(alpaka_EXEC_CpuOmpBlocks)
run_test_gpu(mainAlpaka Alpaka 100 CpuOmpBlocks)
endif()


#--- add version files ---------------------------------------------------------
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/CLUEVersion.h
${CMAKE_CURRENT_BINARY_DIR}/CLUEVersion.h )
Expand Down
2 changes: 1 addition & 1 deletion alpaka
22 changes: 10 additions & 12 deletions clueLib/include/CLUEAlgo.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
#ifndef CLUEAlgo_h
#define CLUEAlgo_h

// C/C++ headers
#include "Points.h"
#include "Tiles.h"

#pragma once
// clang-format off
#include <chrono>
#include <fstream>
#include <functional>
#include <set>
#include <string>
#include <vector>

// C/C++ headers
#include "Points.h"
#include "Tiles.h"

// clang-format on

// The type T is used to pass the number of bins in each dimension and the
// allowed ranges spanned. Ancillary quantities, like the inverse of the bin
// width should also be provided. Code will not compile if any such information
Expand Down Expand Up @@ -139,7 +140,6 @@ class CLUEAlgo
points_.weight.resize(n);
std::copy(std::begin(weight), std::end(weight), std::begin(points_.weight));


points_.p_x = points_.x.data();
points_.p_y = points_.y.data();
points_.p_layer = points_.layer.data();
Expand Down Expand Up @@ -394,7 +394,8 @@ void CLUEAlgo<T, NLAYERS>::makeClusters()

// std::cout << "STANDALONE: before prepare" << std::endl;
prepareDataStructures(allLayerTiles);
// std::cout << "STANDALONE: after prepare datastructures makeClusters" << std::endl;
// std::cout << "STANDALONE: after prepare datastructures makeClusters" <<
// std::endl;
auto finish = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> elapsed = finish - start;
std::cout << "--- prepareDataStructures: " << elapsed.count() * 1000 << " ms\n";
Expand All @@ -411,7 +412,6 @@ void CLUEAlgo<T, NLAYERS>::makeClusters()
elapsed = finish - start;
std::cout << "--- calculateDistanceToHigher: " << elapsed.count() * 1000 << " ms\n";


findAndAssignClusters();
// std::cout << "STANDALONE: end makeClusters" << std::endl;
}
Expand Down Expand Up @@ -600,5 +600,3 @@ inline float CLUEAlgo<T, NLAYERS>::distance(int i, int j) const
float const dy = points_.p_y[i] - points_.p_y[j];
return std::sqrt(dx * dx + dy * dy);
}

#endif
Loading