File indexing completed on 2025-01-18 09:13:07
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include "TestDeviceCuts.hpp"
0011
0012
0013 #include <cuda_runtime.h>
0014
0015
0016 #include <stdexcept>
0017
0018
0019 #define CUDA_CHECK(EXP) \
0020 do { \
0021 cudaError_t errorCode = EXP; \
0022 if (errorCode != cudaSuccess) { \
0023 throw std::runtime_error( \
0024 "Failed to set up the custom seed filter functions"); \
0025 } \
0026 } while (false)
0027
0028
0029 __device__ float testSeedWeight(const Acts::Cuda::Details::SpacePoint& bottom,
0030 const Acts::Cuda::Details::SpacePoint&,
0031 const Acts::Cuda::Details::SpacePoint& top) {
0032 float weight = 0;
0033 if (bottom.radius > 150) {
0034 weight = 400;
0035 }
0036 if (top.radius < 150) {
0037 weight = 200;
0038 }
0039 return weight;
0040 }
0041
0042
0043 __device__ bool testSingleSeedCut(float weight,
0044 const Acts::Cuda::Details::SpacePoint& bottom,
0045 const Acts::Cuda::Details::SpacePoint&,
0046 const Acts::Cuda::Details::SpacePoint&) {
0047 return !(bottom.radius > 150. && weight < 380.);
0048 }
0049
0050
0051 static __device__ Acts::Cuda::TripletFilterConfig::seedWeightFunc_t
0052 seedWeightDeviceFunc = testSeedWeight;
0053 static __device__ Acts::Cuda::TripletFilterConfig::singleSeedCutFunc_t
0054 singleSeedCutDeviceFunc = testSingleSeedCut;
0055
0056 Acts::Cuda::TripletFilterConfig testDeviceCuts() {
0057
0058 Acts::Cuda::TripletFilterConfig result;
0059
0060
0061
0062 CUDA_CHECK(cudaMemcpyFromSymbol(
0063 &(result.seedWeight), ::seedWeightDeviceFunc,
0064 sizeof(Acts::Cuda::TripletFilterConfig::seedWeightFunc_t)));
0065 CUDA_CHECK(cudaMemcpyFromSymbol(
0066 &(result.singleSeedCut), ::singleSeedCutDeviceFunc,
0067 sizeof(Acts::Cuda::TripletFilterConfig::singleSeedCutFunc_t)));
0068
0069
0070 return result;
0071 }