-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #451 from CrossR/alpaka_second_example
Alpaka: Seed Finding
- Loading branch information
Showing
20 changed files
with
1,118 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# TRACCC library, part of the ACTS project (R&D line) | ||
# | ||
# (c) 2024 CERN for the benefit of the ACTS project | ||
# | ||
# Mozilla Public License Version 2.0 | ||
|
||
cmake_minimum_required( VERSION 3.16 ) | ||
|
||
# Guard against multiple includes. | ||
include_guard( GLOBAL ) | ||
|
||
# Function for declaring the libraries of the project. | ||
# This version calls the alpaka_add_library() function to create the library, | ||
# which is setup to use the correct compiler flags depending on the build type. | ||
# | ||
# Usage: traccc_add_alpaka_library( traccc_core core | ||
# [TYPE SHARED/INTERFACE/STATIC] | ||
# include/source1.hpp source2.cpp ) | ||
# | ||
function( traccc_add_alpaka_library fullname basename ) | ||
|
||
# Parse the function's options. | ||
cmake_parse_arguments( ARG "" "TYPE" "" ${ARGN} ) | ||
|
||
# Decide what sources to give to the library. | ||
set( _sources ${ARG_UNPARSED_ARGUMENTS} ) | ||
if( "${ARG_TYPE}" STREQUAL "INTERFACE" ) | ||
set( _sources ) | ||
endif() | ||
|
||
# Create the library. | ||
alpaka_add_library( ${fullname} ${ARG_TYPE} ${_sources} ) | ||
|
||
# Set up how clients should find its headers. | ||
if( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/" ) | ||
set( _depType PUBLIC ) | ||
if( "${ARG_TYPE}" STREQUAL "INTERFACE" ) | ||
set( _depType INTERFACE ) | ||
endif() | ||
target_include_directories( ${fullname} ${_depType} | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> | ||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> ) | ||
unset( _depType ) | ||
endif() | ||
|
||
# Make sure that the library is available as "traccc::${basename}" in every | ||
# situation. | ||
set_target_properties( ${fullname} PROPERTIES EXPORT_NAME ${basename} ) | ||
add_library( traccc::${basename} ALIAS ${fullname} ) | ||
|
||
# Specify the (SO)VERSION of the library. | ||
if( NOT "${ARG_TYPE}" STREQUAL "INTERFACE" ) | ||
set_target_properties( ${fullname} PROPERTIES | ||
VERSION ${PROJECT_VERSION} | ||
SOVERSION ${PROJECT_VERSION_MAJOR} ) | ||
endif() | ||
|
||
# Set up the installation of the library and its headers. | ||
install( TARGETS ${fullname} | ||
EXPORT traccc-exports | ||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" | ||
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" | ||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" ) | ||
if( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/" ) | ||
install( DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/" | ||
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" ) | ||
endif() | ||
|
||
endfunction( traccc_add_alpaka_library ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
device/alpaka/include/traccc/alpaka/seeding/seed_finding.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/** TRACCC library, part of the ACTS project (R&D line) | ||
* | ||
* (c) 2023 CERN for the benefit of the ACTS project | ||
* | ||
* Mozilla Public License Version 2.0 | ||
*/ | ||
|
||
#pragma once | ||
|
||
// Project include(s). | ||
#include "traccc/edm/seed.hpp" | ||
#include "traccc/edm/spacepoint.hpp" | ||
#include "traccc/seeding/detail/seeding_config.hpp" | ||
#include "traccc/seeding/detail/spacepoint_grid.hpp" | ||
#include "traccc/utils/algorithm.hpp" | ||
#include "traccc/utils/memory_resource.hpp" | ||
|
||
// VecMem include(s). | ||
#include <vecmem/utils/copy.hpp> | ||
|
||
// System include(s). | ||
#include <functional> | ||
|
||
namespace traccc::alpaka { | ||
|
||
/// Seed finding for alpaka | ||
class seed_finding : public algorithm<seed_collection_types::buffer( | ||
const spacepoint_collection_types::const_view&, | ||
const sp_grid_const_view&)> { | ||
|
||
public: | ||
/// Constructor for the alpaka seed finding | ||
/// | ||
/// @param config is seed finder configuration parameters | ||
/// @param filter_config is seed filter configuration parameters | ||
/// @param sp_grid spacepoint grid | ||
/// @param mr vecmem memory resource | ||
/// @param copy The copy object to use for copying data between device | ||
/// and host memory blocks | ||
seed_finding(const seedfinder_config& config, | ||
const seedfilter_config& filter_config, | ||
const traccc::memory_resource& mr, vecmem::copy& copy); | ||
|
||
/// Callable operator for the seed finding | ||
/// | ||
/// @param spacepoints_view is a view of all spacepoints in the event | ||
/// @param g2_view is a view of the spacepoint grid | ||
/// @return a vector buffer of seeds | ||
/// | ||
output_type operator()( | ||
const spacepoint_collection_types::const_view& spacepoints_view, | ||
const sp_grid_const_view& g2_view) const override; | ||
|
||
private: | ||
seedfinder_config m_seedfinder_config; | ||
seedfilter_config m_seedfilter_config; | ||
traccc::memory_resource m_mr; | ||
vecmem::copy& m_copy; | ||
}; | ||
|
||
} // namespace traccc::alpaka |
60 changes: 60 additions & 0 deletions
60
device/alpaka/include/traccc/alpaka/seeding/seeding_algorithm.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/** TRACCC library, part of the ACTS project (R&D line) | ||
* | ||
* (c) 2023 CERN for the benefit of the ACTS project | ||
* | ||
* Mozilla Public License Version 2.0 | ||
*/ | ||
|
||
#pragma once | ||
|
||
// Library include(s). | ||
#include "traccc/alpaka/seeding/seed_finding.hpp" | ||
#include "traccc/alpaka/seeding/spacepoint_binning.hpp" | ||
|
||
// Project include(s). | ||
#include "traccc/edm/seed.hpp" | ||
#include "traccc/edm/spacepoint.hpp" | ||
#include "traccc/utils/algorithm.hpp" | ||
|
||
// VecMem include(s). | ||
#include <vecmem/memory/memory_resource.hpp> | ||
|
||
// traccc library include(s). | ||
#include "traccc/utils/memory_resource.hpp" | ||
|
||
namespace traccc::alpaka { | ||
|
||
/// Main algorithm for performing the track seeding on in alpaka | ||
class seeding_algorithm : public algorithm<seed_collection_types::buffer( | ||
const spacepoint_collection_types::const_view&)> { | ||
|
||
public: | ||
/// Constructor for the seed finding algorithm | ||
/// | ||
/// @param mr The memory resource to use | ||
/// @param mr The memory resource(s) to use in the algorithm | ||
/// @param copy The copy object to use for copying data between device | ||
/// and host memory blocks | ||
/// | ||
seeding_algorithm(const seedfinder_config& finder_config, | ||
const spacepoint_grid_config& grid_config, | ||
const seedfilter_config& filter_config, | ||
const traccc::memory_resource& mr, vecmem::copy& copy); | ||
|
||
/// Operator executing the algorithm. | ||
/// | ||
/// @param spacepoints_view is a view of all spacepoints in the event | ||
/// @return the buffer of track seeds reconstructed from the spacepoints | ||
/// | ||
output_type operator()(const spacepoint_collection_types::const_view& | ||
spacepoints_view) const override; | ||
|
||
private: | ||
/// Sub-algorithm performing the spacepoint binning | ||
spacepoint_binning m_spacepoint_binning; | ||
/// Sub-algorithm performing the seed finding | ||
seed_finding m_seed_finding; | ||
|
||
}; // class seeding_algorithm | ||
|
||
} // namespace traccc::alpaka |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
device/alpaka/include/traccc/alpaka/seeding/track_params_estimation.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/** TRACCC library, part of the ACTS project (R&D line) | ||
* | ||
* (c) 2023 CERN for the benefit of the ACTS project | ||
* | ||
* Mozilla Public License Version 2.0 | ||
*/ | ||
|
||
#pragma once | ||
|
||
// Project include(s) | ||
#include "traccc/edm/cell.hpp" | ||
#include "traccc/edm/seed.hpp" | ||
#include "traccc/edm/spacepoint.hpp" | ||
#include "traccc/edm/track_parameters.hpp" | ||
#include "traccc/utils/algorithm.hpp" | ||
#include "traccc/utils/memory_resource.hpp" | ||
|
||
// VecMem include(s). | ||
#include <vecmem/utils/copy.hpp> | ||
|
||
namespace traccc::alpaka { | ||
|
||
/// track parameter estimation for alpaka | ||
struct track_params_estimation | ||
: public algorithm<bound_track_parameters_collection_types::buffer( | ||
const spacepoint_collection_types::const_view&, | ||
const seed_collection_types::const_view&, | ||
const cell_module_collection_types::const_view&, const vector3&, | ||
const std::array<traccc::scalar, traccc::e_bound_size>&)> { | ||
|
||
public: | ||
/// Constructor for track_params_estimation | ||
/// | ||
/// @param mr is the memory resource | ||
/// @param copy The copy object to use for copying data between device | ||
/// and host memory blocks | ||
track_params_estimation(const traccc::memory_resource& mr, | ||
vecmem::copy& copy); | ||
|
||
/// Callable operator for track_params_estimation | ||
/// | ||
/// @param spacepoints All spacepoints of the event | ||
/// @param seeds The reconstructed track seeds of the event | ||
/// @param modules Geometry module vector | ||
/// @param bfield (Temporary) Magnetic field vector | ||
/// @param stddev standard deviation for setting the covariance (Default | ||
/// value from arXiv:2112.09470v1) | ||
/// @return A vector of bound track parameters | ||
/// | ||
output_type operator()( | ||
const spacepoint_collection_types::const_view& spacepoints_view, | ||
const seed_collection_types::const_view& seeds_view, | ||
const cell_module_collection_types::const_view& modules_view, | ||
const vector3& bfield, | ||
const std::array<traccc::scalar, traccc::e_bound_size>& = { | ||
0.02 * detray::unit<traccc::scalar>::mm, | ||
0.03 * detray::unit<traccc::scalar>::mm, | ||
1. * detray::unit<traccc::scalar>::degree, | ||
1. * detray::unit<traccc::scalar>::degree, | ||
0.01 / detray::unit<traccc::scalar>::GeV, | ||
1 * detray::unit<traccc::scalar>::ns}) const override; | ||
|
||
private: | ||
/// Memory resource used by the algorithm | ||
traccc::memory_resource m_mr; | ||
/// Copy object used by the algorithm | ||
vecmem::copy& m_copy; | ||
}; | ||
|
||
} // namespace traccc::alpaka |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.