ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
AthenaExamples
AthExCUDA
src
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).
6
#include "
LinearTransformAsyncExampleAlg.h
"
7
8
namespace
AthCUDAExamples
{
9
10
StatusCode
LinearTransformAsyncExampleAlg::execute
(
const
EventContext&)
const
{
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_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
LinearTransformAsyncExampleAlg.h
AthCUDAExamples::LinearTransformAsyncExampleAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Function executing the algorithm.
Definition
LinearTransformAsyncExampleAlg.cxx:10
AthCUDAExamples::LinearTransformAsyncExampleAlg::linearTransform
StatusCode linearTransform(std::vector< float > &arr, float multiplier) const
GPU kernel launcher.
AthCUDAExamples
Definition
cudaMultiply.h:11
Generated on
for ATLAS Offline Software by
1.17.0