Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alpaka: Clustering + Throughput #558

Merged
merged 47 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
9495e5e
Swap trait code to use templated args.
CrossR Aug 1, 2023
0d63262
Start work on clustering code.
CrossR Aug 1, 2023
2755dc5
Fix compilation warnings for barrier code.
CrossR Aug 1, 2023
1cf1684
Add example code for new alpaka algorithm.
CrossR Aug 1, 2023
e50c19a
Clamp alpaka WorkDiv size.
CrossR Aug 1, 2023
e774345
Fix block extent to match CUDA definition.
CrossR Aug 1, 2023
4db5a27
Correctly initialise value to zero.
CrossR Aug 2, 2023
3e74a44
Start adding in throughput examples.
CrossR Aug 2, 2023
3e15f26
Add multi-threaded throughput example.
CrossR Aug 2, 2023
9a77362
Add back CUDA device info.
CrossR Aug 2, 2023
30ed2f6
Format code.
CrossR Aug 2, 2023
e879154
Fix some headers.
CrossR Aug 2, 2023
a4fc492
Zero the triplet_buffer memory.
CrossR Aug 11, 2023
949c4f1
Merge branch 'main' into alpaka_clustering
CrossR Aug 30, 2023
64c9f2f
Merge remote-tracking branch 'origin/main' into alpaka_clustering
CrossR Aug 30, 2023
e0defcc
Fix post-merge changes.
CrossR Aug 31, 2023
99d145a
Fix for CLI options changing.
CrossR Aug 31, 2023
fadca68
Revert change to seeding_config.
CrossR Aug 31, 2023
5a97c97
Merge branch 'alpaka_second_example' into alpaka_clustering
CrossR Jan 30, 2024
0904ada
Fix up building of seeding and seq examples.
CrossR Jan 30, 2024
3ea39a4
Re-enable the Alpaka throughput examples.
CrossR Jan 30, 2024
d3f2ab6
Simplify the device output.
CrossR Jan 30, 2024
3c4b64b
Barrier should be blockOr not blockCount.
CrossR Jan 31, 2024
b82fd58
Merge branch 'alpaka_second_example' into alpaka_clustering
CrossR Feb 6, 2024
8b29c59
Merge branch 'alpaka_second_example' into alpaka_clustering
CrossR Feb 12, 2024
0028fbe
Merge branch 'alpaka_second_example' into alpaka_clustering
CrossR Feb 15, 2024
b770ced
Fix post merge.
CrossR Feb 15, 2024
805a5a6
Merge branch 'alpaka_second_example' into alpaka_clustering
CrossR Mar 5, 2024
d75244a
Update for new alpaka code layout.
CrossR Mar 5, 2024
e59dfa2
Merge branch 'main' into alpaka_clustering
CrossR Mar 7, 2024
8c75ec1
Fix post merge.
CrossR Mar 7, 2024
8335654
Merge branch 'main' into alpaka_clustering
CrossR Apr 24, 2024
65024ba
Start to fix things, post merge.
CrossR Apr 25, 2024
924452a
Add missing sort algorithm.
CrossR Apr 25, 2024
f40db4c
Tidy up, post merge.
CrossR Apr 25, 2024
60a526d
Fix up issues.
CrossR Apr 26, 2024
a1b1618
Use correct HIP memory resource in throughput examples.
CrossR May 10, 2024
15f20f5
Fix for CPU running.
CrossR May 10, 2024
b7d9552
Merge remote-tracking branch 'origin/main' into alpaka_clustering
CrossR Jun 3, 2024
0fbaf9a
Fix post merge.
CrossR Jun 3, 2024
8dfb5b9
Temporarily fix pragma unroll issue.
CrossR Jun 4, 2024
4da1b6d
Move to hints file.
CrossR Jun 4, 2024
695e5c9
Merge remote-tracking branch 'origin/main' into alpaka_clustering
CrossR Jun 25, 2024
c7304d9
Fix up PR comments.
CrossR Jun 25, 2024
6006c4c
Merge remote-tracking branch 'origin/main' into alpaka_clustering
CrossR Jul 3, 2024
53dbaff
Start work on PR comments.
CrossR Jul 3, 2024
4471d54
Don't use unroll on GCC for now.
CrossR Jul 4, 2024
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
24 changes: 24 additions & 0 deletions core/include/traccc/definitions/hints.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* 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
*/

#pragma once

#if not defined __has_builtin
#define TRACCC_ASSUME(...)
#elif __has_builtin(__builtin_assume)
#define TRACCC_ASSUME(...) __builtin_assume(__VA_ARGS__)
#else
#define TRACCC_ASSUME(...)
#endif

#if defined(__CUDACC__) || defined(__HIP__) || defined(__OPENMP) || \
defined(__SYCL__) || defined(__clang__)
#define TRACCC_PRAGMA_UNROLL _Pragma("unroll")
#else
#define TRACCC_PRAGMA_UNROLL
#endif
11 changes: 9 additions & 2 deletions device/alpaka/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ include( traccc-alpaka-functions )
include( traccc-compiler-options-cpp )

set(PUBLIC_LIBRARIES traccc::core detray::core detray::utils vecmem::core covfie::core)
set(PRIVATE_LIBRARIES traccc::device_common alpaka::alpaka)
set(PRIVATE_LIBRARIES traccc::device_common alpaka::alpaka traccc::Thrust)

if(alpaka_ACC_GPU_CUDA_ENABLE)
enable_language(CUDA)
Expand All @@ -26,11 +26,18 @@ traccc_add_alpaka_library( traccc_alpaka alpaka TYPE SHARED
# Utility definitions.
"include/traccc/alpaka/utils/make_prefix_sum_buff.hpp"
"src/utils/make_prefix_sum_buff.cpp"
# Seed finding includes
# Seed finding code.
"include/traccc/alpaka/seeding/spacepoint_binning.hpp"
"include/traccc/alpaka/seeding/seed_finding.hpp"
"include/traccc/alpaka/seeding/seeding_algorithm.hpp"
"include/traccc/alpaka/seeding/track_params_estimation.hpp"
# Clusterization
"include/traccc/alpaka/clusterization/clusterization_algorithm.hpp"
"src/clusterization/clusterization_algorithm.cpp"
"include/traccc/alpaka/clusterization/measurement_sorting_algorithm.hpp"
"src/clusterization/measurement_sorting_algorithm.cpp"
"include/traccc/alpaka/clusterization/spacepoint_formation_algorithm.hpp"
"src/clusterization/spacepoint_formation_algorithm.cpp"
# Seeding code
"src/seeding/spacepoint_binning.cpp"
"src/seeding/seed_finding.cpp"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/** 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/measurement.hpp"
#include "traccc/edm/spacepoint.hpp"
#include "traccc/utils/algorithm.hpp"
#include "traccc/utils/memory_resource.hpp"

// VecMem include(s).
#include <vecmem/utils/copy.hpp>

namespace traccc::alpaka {

/// Algorithm performing hit clusterization
///
/// This algorithm implements hit clusterization in a massively-parallel
/// approach. Each thread handles a pre-determined number of detector cells.
///
/// This algorithm returns a buffer which is not necessarily filled yet. A
/// synchronisation statement is required before destroying this buffer.
///
class clusterization_algorithm
: public algorithm<measurement_collection_types::buffer(
const cell_collection_types::const_view&,
const cell_module_collection_types::const_view&)> {

public:
/// Constructor for clusterization algorithm
///
/// @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
/// @param target_cells_per_partition the average number of cells in each
/// partition
///
clusterization_algorithm(const traccc::memory_resource& mr,
vecmem::copy& copy,
const unsigned short target_cells_per_partition);

/// Callable operator for clusterization algorithm
///
/// @param cells a collection of cells
/// @param modules a collection of modules
/// @return a spacepoint collection (buffer) and a collection (buffer) of
/// links from cells to the spacepoints they belong to.
output_type operator()(
const cell_collection_types::const_view& cells,
const cell_module_collection_types::const_view& modules) const override;

private:
/// The average number of cells in each partition
using config_type = unsigned short;
config_type m_target_cells_per_partition;
/// The memory resource(s) to use
traccc::memory_resource m_mr;
/// The copy object to use
std::reference_wrapper<vecmem::copy> m_copy;
};

} // namespace traccc::alpaka
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/** 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
*/

#pragma once

// Project include(s).
#include "traccc/edm/measurement.hpp"
#include "traccc/utils/algorithm.hpp"

// VecMem include(s).
#include <vecmem/utils/copy.hpp>

// System include(s).
#include <functional>

namespace traccc::alpaka {

/// Algorithm sorting the reconstructed measurements in their container
///
/// The track finding algorithm expects measurements belonging to a single
/// detector module to be consecutive in memory. But
/// @c traccc::alpaka::clusterization_algorithm does not (currently) produce the
/// measurements in such an ordered state. This is where this algorithm comes
/// to the rescue.
///
class measurement_sorting_algorithm
: public algorithm<measurement_collection_types::view(
const measurement_collection_types::view&)> {

public:
/// Constructor for the algorithm
///
/// @param copy The copy object to use in the algorithm
///
measurement_sorting_algorithm(vecmem::copy& copy);

/// Callable operator performing the sorting on a container
///
/// @param measurements The measurements to sort
///
output_type operator()(const measurement_collection_types::view&
measurements_view) const override;

private:
/// Copy object to use in the algorithm
std::reference_wrapper<vecmem::copy> m_copy;

}; // class measurement_sorting_algorithm

} // namespace traccc::alpaka
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/** 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
*/

#pragma once

// Project include(s).
#include "traccc/edm/cell.hpp"
#include "traccc/edm/measurement.hpp"
#include "traccc/edm/spacepoint.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 {

/// Algorithm forming space points out of measurements
///
/// This algorithm performs the local-to-global transformation of the 2D
/// measurements made on every detector module, into 3D spacepoint coordinates.
///
class spacepoint_formation_algorithm
: public algorithm<spacepoint_collection_types::buffer(
const measurement_collection_types::const_view&,
const cell_module_collection_types::const_view&)> {

public:
/// Constructor for spacepoint_formation
///
/// @param mr is the memory resource
///
spacepoint_formation_algorithm(const traccc::memory_resource& mr,
vecmem::copy& copy);

/// Callable operator for the space point formation, based on one single
/// module
///
/// @param measurements_view A collection of measurements
/// @param modules_view A collection of modules the measurements link to
/// @return A spacepoint container, with one spacepoint for every
/// measurement
///
output_type operator()(
const measurement_collection_types::const_view& measurements_view,
const cell_module_collection_types::const_view& modules_view)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that you are racing #627 here, but Attila is on a holiday so this can go in first.

const override;

private:
/// The memory resource(s) to use
traccc::memory_resource m_mr;
/// The copy object to use
std::reference_wrapper<vecmem::copy> m_copy;
}; // class spacepoint_formation_algorithm

} // namespace traccc::alpaka
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,13 @@
#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 seed_collection_types::const_view&, const vector3&,
const std::array<traccc::scalar, traccc::e_bound_size>&)> {

public:
Expand All @@ -50,7 +46,6 @@ struct track_params_estimation
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,
Expand Down
Loading
Loading