ATLAS Offline Software
LinearTransformAsyncExampleAlg.cxx
Go to the documentation of this file.
1 //
2 // Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 //
4 
5 // Local include(s).
7 
8 namespace AthCUDAExamples {
9 
11  ATH_MSG_INFO("Starting execute");
12 
13  // Create a dummy array variable in pinned memory that will be multiplied by
14  // some amount.
15  static const std::size_t ARRAY_SIZE = 10000;
16  static const float ARRAY_ELEMENT = 3.141592f;
17  std::vector<float> dummyArray(ARRAY_SIZE, ARRAY_ELEMENT);
18 
19  // Run calculation. See LinearTransformAsyncExampleAlg.cu.
20  static const float MULTIPLIER = 1.23f;
21  ATH_MSG_INFO("Starting linearTransform");
22  ATH_CHECK(linearTransform(dummyArray, MULTIPLIER));
23 
24  // Check if the operation succeeded.
25  static const float EXPECTED_RESULT = ARRAY_ELEMENT * MULTIPLIER;
26  for (std::size_t i = 0; i < ARRAY_SIZE; ++i) {
27  if (std::abs(dummyArray[i] - EXPECTED_RESULT) > 0.001) {
28  ATH_MSG_ERROR("The CUDA transformation failed to run");
29  return StatusCode::FAILURE;
30  }
31  }
32 
33  // Return gracefully.
34  return StatusCode::SUCCESS;
35 }
36 
37 } // namespace AthCUDAExamples
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
AthCUDAExamples
Definition: cudaMultiply.h:11
AthCUDAExamples::LinearTransformAsyncExampleAlg::linearTransform
StatusCode linearTransform(std::vector< float > &arr, float multiplier) const
GPU kernel launcher.
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:85
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
AthCUDAExamples::LinearTransformAsyncExampleAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Function executing the algorithm.
Definition: LinearTransformAsyncExampleAlg.cxx:10
LinearTransformAsyncExampleAlg.h