Skip to content

Commit

Permalink
Replace TAcc with the explicit accelerator type
Browse files Browse the repository at this point in the history
  • Loading branch information
fwyzard committed Dec 11, 2024
1 parent e648b61 commit 53a0974
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::ecal::multifit {
///
class Kernel_prep_1d_and_initialize {
public:
template <typename TAcc, typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
ALPAKA_FN_ACC void operator()(TAcc const& acc,
ALPAKA_FN_ACC void operator()(Acc1D const& acc,
EcalDigiDeviceCollection::ConstView digisDevEB,
EcalDigiDeviceCollection::ConstView digisDevEE,
EcalUncalibratedRecHitDeviceCollection::View uncalibRecHitsEB,
Expand Down Expand Up @@ -328,8 +327,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::ecal::multifit {
///
class Kernel_prep_2d {
public:
template <typename TAcc, typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
ALPAKA_FN_ACC void operator()(TAcc const& acc,
ALPAKA_FN_ACC void operator()(Acc2D const& acc,
EcalDigiDeviceCollection::ConstView digisDevEB,
EcalDigiDeviceCollection::ConstView digisDevEE,
EcalMultifitConditionsDevice::ConstView conditionsDev,
Expand Down Expand Up @@ -466,11 +464,12 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::ecal::multifit {
} // namespace ALPAKA_ACCELERATOR_NAMESPACE::ecal::multifit

namespace alpaka::trait {
using namespace ALPAKA_ACCELERATOR_NAMESPACE;
using namespace ALPAKA_ACCELERATOR_NAMESPACE::ecal::multifit;

//! The trait for getting the size of the block shared dynamic memory for Kernel_prep_1d_and_initialize.
template <typename TAcc>
struct BlockSharedMemDynSizeBytes<Kernel_prep_1d_and_initialize, TAcc> {
template <>
struct BlockSharedMemDynSizeBytes<Kernel_prep_1d_and_initialize, Acc1D> {
//! \return The size of the shared memory allocated for a block.
template <typename TVec, typename... TArgs>
ALPAKA_FN_HOST_ACC static auto getBlockSharedMemDynSizeBytes(Kernel_prep_1d_and_initialize const&,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::ecal::multifit {
///
class Kernel_minimize {
public:
template <typename TAcc, typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
ALPAKA_FN_ACC void operator()(TAcc const& acc,
ALPAKA_FN_ACC void operator()(Acc1D const& acc,
InputProduct::ConstView const& digisDevEB,
InputProduct::ConstView const& digisDevEE,
OutputProduct::View uncalibRecHitsEB,
Expand Down Expand Up @@ -293,23 +292,25 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::ecal::multifit {
} // namespace ALPAKA_ACCELERATOR_NAMESPACE::ecal::multifit

namespace alpaka::trait {
using namespace ALPAKA_ACCELERATOR_NAMESPACE;
using namespace ALPAKA_ACCELERATOR_NAMESPACE::ecal::multifit;

//! The trait for getting the size of the block shared dynamic memory for Kernel_minimize.
template <typename TAcc>
struct BlockSharedMemDynSizeBytes<Kernel_minimize, TAcc> {
template <>
struct BlockSharedMemDynSizeBytes<Kernel_minimize, Acc1D> {
//! \return The size of the shared memory allocated for a block.
template <typename TVec, typename... TArgs>
ALPAKA_FN_HOST_ACC static auto getBlockSharedMemDynSizeBytes(Kernel_minimize const&,
TVec const& threadsPerBlock,
TVec const& elemsPerThread,
TArgs const&...) -> std::size_t {
using ScalarType = ecal::multifit::SampleVector::Scalar;
using ScalarType = ::ecal::multifit::SampleVector::Scalar;

// return the amount of dynamic shared memory needed
std::size_t bytes = 2 * threadsPerBlock[0u] * elemsPerThread[0u] *
calo::multifit::MapSymM<ScalarType, ecal::multifit::SampleVector::RowsAtCompileTime>::total *
sizeof(ScalarType);
std::size_t bytes =
2 * threadsPerBlock[0u] * elemsPerThread[0u] *
calo::multifit::MapSymM<ScalarType, ::ecal::multifit::SampleVector::RowsAtCompileTime>::total *
sizeof(ScalarType);
return bytes;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::ecal::multifit {
using ScalarType = ::ecal::multifit::SampleVector::Scalar;

public:
template <typename TAcc, typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
ALPAKA_FN_ACC void operator()(TAcc const& acc,
ALPAKA_FN_ACC void operator()(Acc1D const& acc,
ScalarType* const sample_values,
ScalarType* const sample_value_errors,
bool* const useless_sample_values,
Expand Down Expand Up @@ -120,8 +119,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::ecal::multifit {
using ScalarType = ::ecal::multifit::SampleVector::Scalar;

public:
template <typename TAcc, typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
ALPAKA_FN_ACC void operator()(TAcc const& acc,
ALPAKA_FN_ACC void operator()(Acc1D const& acc,
EcalDigiDeviceCollection::ConstView digisDevEB,
EcalDigiDeviceCollection::ConstView digisDevEE,
ScalarType* const sample_values,
Expand Down Expand Up @@ -523,8 +521,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::ecal::multifit {
using ScalarType = ::ecal::multifit::SampleVector::Scalar;

public:
template <typename TAcc, typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
ALPAKA_FN_ACC void operator()(TAcc const& acc,
ALPAKA_FN_ACC void operator()(Acc1D const& acc,
EcalDigiDeviceCollection::ConstView digisDevEB,
EcalDigiDeviceCollection::ConstView digisDevEE,
ScalarType* const sample_values,
Expand Down Expand Up @@ -730,8 +727,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::ecal::multifit {
using ScalarType = ::ecal::multifit::SampleVector::Scalar;

public:
template <typename TAcc, typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
ALPAKA_FN_ACC void operator()(TAcc const& acc,
ALPAKA_FN_ACC void operator()(Acc1D const& acc,
EcalDigiDeviceCollection::ConstView digisDevEB,
EcalDigiDeviceCollection::ConstView digisDevEE,
EcalMultifitConditionsDevice::ConstView conditionsDev,
Expand Down Expand Up @@ -777,8 +773,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::ecal::multifit {
using ScalarType = ::ecal::multifit::SampleVector::Scalar;

public:
template <typename TAcc, typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
ALPAKA_FN_ACC void operator()(TAcc const& acc,
ALPAKA_FN_ACC void operator()(Acc1D const& acc,
EcalDigiDeviceCollection::ConstView digisDevEB,
EcalDigiDeviceCollection::ConstView digisDevEE,
EcalMultifitConditionsDevice::ConstView conditionsDev,
Expand Down Expand Up @@ -960,8 +955,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::ecal::multifit {
using ScalarType = ::ecal::multifit::SampleVector::Scalar;

public:
template <typename TAcc, typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
ALPAKA_FN_ACC void operator()(TAcc const& acc,
ALPAKA_FN_ACC void operator()(Acc1D const& acc,
EcalDigiDeviceCollection::ConstView digisDevEB,
EcalDigiDeviceCollection::ConstView digisDevEE,
EcalUncalibratedRecHitDeviceCollection::View uncalibRecHitsEB,
Expand Down Expand Up @@ -1095,18 +1089,19 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::ecal::multifit {
} // namespace ALPAKA_ACCELERATOR_NAMESPACE::ecal::multifit

namespace alpaka::trait {
using namespace ALPAKA_ACCELERATOR_NAMESPACE;
using namespace ALPAKA_ACCELERATOR_NAMESPACE::ecal::multifit;

//! The trait for getting the size of the block shared dynamic memory for Kernel_time_compute_nullhypot.
template <typename TAcc>
struct BlockSharedMemDynSizeBytes<Kernel_time_compute_nullhypot, TAcc> {
template <>
struct BlockSharedMemDynSizeBytes<Kernel_time_compute_nullhypot, Acc1D> {
//! \return The size of the shared memory allocated for a block.
template <typename TVec, typename... TArgs>
ALPAKA_FN_HOST_ACC static auto getBlockSharedMemDynSizeBytes(Kernel_time_compute_nullhypot const&,
TVec const& threadsPerBlock,
TVec const& elemsPerThread,
TArgs const&...) -> std::size_t {
using ScalarType = ecal::multifit::SampleVector::Scalar;
using ScalarType = ::ecal::multifit::SampleVector::Scalar;

// return the amount of dynamic shared memory needed
std::size_t bytes = threadsPerBlock[0u] * elemsPerThread[0u] * 4 * sizeof(ScalarType);
Expand All @@ -1115,44 +1110,44 @@ namespace alpaka::trait {
};

//! The trait for getting the size of the block shared dynamic memory for Kernel_time_compute_makeratio.
template <typename TAcc>
struct BlockSharedMemDynSizeBytes<Kernel_time_compute_makeratio, TAcc> {
template <>
struct BlockSharedMemDynSizeBytes<Kernel_time_compute_makeratio, Acc1D> {
template <typename TVec, typename... TArgs>
ALPAKA_FN_HOST_ACC static auto getBlockSharedMemDynSizeBytes(Kernel_time_compute_makeratio const&,
TVec const& threadsPerBlock,
TVec const& elemsPerThread,
TArgs const&...) -> std::size_t {
using ScalarType = ecal::multifit::SampleVector::Scalar;
using ScalarType = ::ecal::multifit::SampleVector::Scalar;

std::size_t bytes = (8 * sizeof(ScalarType) + 3 * sizeof(bool)) * threadsPerBlock[0u] * elemsPerThread[0u];
return bytes;
}
};

//! The trait for getting the size of the block shared dynamic memory for Kernel_time_compute_findamplchi2_and_finish.
template <typename TAcc>
struct BlockSharedMemDynSizeBytes<Kernel_time_compute_findamplchi2_and_finish, TAcc> {
template <>
struct BlockSharedMemDynSizeBytes<Kernel_time_compute_findamplchi2_and_finish, Acc1D> {
template <typename TVec, typename... TArgs>
ALPAKA_FN_HOST_ACC static auto getBlockSharedMemDynSizeBytes(Kernel_time_compute_findamplchi2_and_finish const&,
TVec const& threadsPerBlock,
TVec const& elemsPerThread,
TArgs const&...) -> std::size_t {
using ScalarType = ecal::multifit::SampleVector::Scalar;
using ScalarType = ::ecal::multifit::SampleVector::Scalar;

std::size_t bytes = 2 * threadsPerBlock[0u] * elemsPerThread[0u] * sizeof(ScalarType);
return bytes;
}
};

//! The trait for getting the size of the block shared dynamic memory for Kernel_time_computation_init.
template <typename TAcc>
struct BlockSharedMemDynSizeBytes<Kernel_time_computation_init, TAcc> {
template <>
struct BlockSharedMemDynSizeBytes<Kernel_time_computation_init, Acc1D> {
template <typename TVec, typename... TArgs>
ALPAKA_FN_HOST_ACC static auto getBlockSharedMemDynSizeBytes(Kernel_time_computation_init const&,
TVec const& threadsPerBlock,
TVec const& elemsPerThread,
TArgs const&...) -> std::size_t {
using ScalarType = ecal::multifit::SampleVector::Scalar;
using ScalarType = ::ecal::multifit::SampleVector::Scalar;

std::size_t bytes = 2 * threadsPerBlock[0u] * elemsPerThread[0u] * sizeof(ScalarType);
return bytes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
// Set energy and number of hits in each clusters
class HGCalLayerClustersSoAAlgoKernelEnergy {
public:
template <typename TAcc, typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
ALPAKA_FN_ACC void operator()(TAcc const& acc,
ALPAKA_FN_ACC void operator()(Acc1D const& acc,
const unsigned int numer_of_clusters,
const HGCalSoARecHitsDeviceCollection::ConstView input_rechits_soa,
const HGCalSoARecHitsExtraDeviceCollection::ConstView input_clusters_soa,
Expand All @@ -38,8 +37,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
// Kernel to find the max for every cluster
class HGCalLayerClustersSoAAlgoKernelPositionByHits {
public:
template <typename TAcc, typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
ALPAKA_FN_ACC void operator()(TAcc const& acc,
ALPAKA_FN_ACC void operator()(Acc1D const& acc,
const unsigned int numer_of_clusters,
float thresholdW0,
float positionDeltaRho2,
Expand Down Expand Up @@ -83,8 +81,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
// Real Kernel position
class HGCalLayerClustersSoAAlgoKernelPositionByHits2 {
public:
template <typename TAcc, typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
ALPAKA_FN_ACC void operator()(TAcc const& acc,
ALPAKA_FN_ACC void operator()(Acc1D const& acc,
const unsigned int numer_of_clusters,
float thresholdW0,
float positionDeltaRho2,
Expand Down Expand Up @@ -121,8 +118,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
// Besides the final position, add also the DetId of the seed of each cluster
class HGCalLayerClustersSoAAlgoKernelPositionByHits3 {
public:
template <typename TAcc, typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
ALPAKA_FN_ACC void operator()(TAcc const& acc,
ALPAKA_FN_ACC void operator()(Acc1D const& acc,
const unsigned int numer_of_clusters,
float thresholdW0,
float positionDeltaRho2,
Expand Down
18 changes: 8 additions & 10 deletions RecoLocalCalo/HcalRecProducers/plugins/alpaka/Mahi.dev.cc
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {

class Kernel_prep1d_sameNumberOfSamples {
public:
template <typename TAcc, typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
ALPAKA_FN_ACC void operator()(TAcc const& acc,
ALPAKA_FN_ACC void operator()(Acc2D const& acc,
OProductType::View outputGPU,
IProductTypef01::ConstView f01HEDigis,
IProductTypef5::ConstView f5HBDigis,
Expand Down Expand Up @@ -748,8 +747,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {

class Kernel_prep_pulseMatrices_sameNumberOfSamples {
public:
template <typename TAcc, typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
ALPAKA_FN_ACC void operator()(TAcc const& acc,
ALPAKA_FN_ACC void operator()(Acc3D const& acc,
float* pulseMatrices,
float* pulseMatricesM,
float* pulseMatricesP,
Expand Down Expand Up @@ -968,8 +966,7 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
template <int NSAMPLES, int NPULSES>
class Kernel_minimize {
public:
template <typename TAcc, typename = std::enable_if_t<alpaka::isAccelerator<TAcc>>>
ALPAKA_FN_ACC void operator()(TAcc const& acc,
ALPAKA_FN_ACC void operator()(Acc1D const& acc,
OProductType::View outputGPU,
float const* amplitudes,
float* pulseMatrices,
Expand Down Expand Up @@ -1408,11 +1405,12 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE {
} // namespace ALPAKA_ACCELERATOR_NAMESPACE

namespace alpaka::trait {
using namespace ALPAKA_ACCELERATOR_NAMESPACE;
using namespace ALPAKA_ACCELERATOR_NAMESPACE::hcal::reconstruction::mahi;

//! The trait for getting the size of the block shared dynamic memory for Kernel_prep_1d_and_initialize.
template <typename TAcc>
struct BlockSharedMemDynSizeBytes<Kernel_prep1d_sameNumberOfSamples, TAcc> {
template <>
struct BlockSharedMemDynSizeBytes<Kernel_prep1d_sameNumberOfSamples, Acc2D> {
//! \return The size of the shared memory allocated for a block.
template <typename TVec, typename... TArgs>
ALPAKA_FN_HOST_ACC static auto getBlockSharedMemDynSizeBytes(Kernel_prep1d_sameNumberOfSamples const&,
Expand All @@ -1431,8 +1429,8 @@ namespace alpaka::trait {
};

//! The trait for getting the size of the block shared dynamic memory for kernel_minimize.
template <int NSAMPLES, int NPULSES, typename TAcc>
struct BlockSharedMemDynSizeBytes<Kernel_minimize<NSAMPLES, NPULSES>, TAcc> {
template <int NSAMPLES, int NPULSES>
struct BlockSharedMemDynSizeBytes<Kernel_minimize<NSAMPLES, NPULSES>, Acc1D> {
//! \return The size of the shared memory allocated for a block.
template <typename TVec, typename... TArgs>
ALPAKA_FN_HOST_ACC static auto getBlockSharedMemDynSizeBytes(Kernel_minimize<NSAMPLES, NPULSES> const&,
Expand Down

0 comments on commit 53a0974

Please sign in to comment.