EIC Software
Reference for
EIC
simulation and reconstruction software on GitHub
Home page
Related Pages
Modules
Namespaces
Classes
Files
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
QueueWrapper.cpp
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file QueueWrapper.cpp
1
// This file is part of the Acts project.
2
//
3
// Copyright (C) 2020 CERN for the benefit of the Acts project
4
//
5
// This Source Code Form is subject to the terms of the Mozilla Public
6
// License, v. 2.0. If a copy of the MPL was not distributed with this
7
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
9
// System include(s)
10
#include <string>
11
12
// Acts include(s)
13
#include "
Acts/Utilities/Logger.hpp
"
14
15
// SYCL plugin include(s)
16
#include "
Acts/Plugins/Sycl/Utilities/DeviceSelector.hpp
"
17
#include "
Acts/Plugins/Sycl/Utilities/QueueWrapper.hpp
"
18
19
// SYCL include
20
#include <CL/sycl.hpp>
21
22
namespace
Acts::Sycl {
23
24
QueueWrapper::QueueWrapper
(
const
std::string& deviceNameSubtring) {
25
initialize
(deviceNameSubtring);
26
}
27
28
QueueWrapper::QueueWrapper
(
QueueWrapper
&& parent) noexcept
29
: m_queue(parent.m_queue), m_ownsQueue(parent.m_ownsQueue) {
30
parent.m_queue =
nullptr
;
31
parent.m_ownsQueue =
false
;
32
}
33
34
QueueWrapper::QueueWrapper
(
const
QueueWrapper
& other) {
35
m_queue
= other.
m_queue
;
36
m_ownsQueue
=
false
;
37
}
38
39
QueueWrapper::~QueueWrapper
() {
40
if
(
m_ownsQueue
&& (
m_queue
!=
nullptr
)) {
41
delete
m_queue
;
42
}
43
};
44
45
QueueWrapper
&
QueueWrapper::operator=
(
QueueWrapper
&& rhs) noexcept {
46
// Check whether we have to do anything
47
if
(
this
== &rhs) {
48
return
*
this
;
49
}
50
51
// Destroy this queue,
52
if
(
m_ownsQueue
&& (
m_queue
!=
nullptr
)) {
53
delete
m_queue
;
54
}
55
56
// Perform the move
57
m_queue
= rhs.m_queue;
58
m_ownsQueue
= rhs.m_ownsQueue;
59
rhs.m_queue =
nullptr
;
60
rhs.m_ownsQueue =
false
;
61
62
// Return this object.
63
return
*
this
;
64
};
65
66
QueueWrapper
&
QueueWrapper::operator=
(
const
QueueWrapper
& other) {
67
// Check whether we have to do anything
68
if
(
this
== &other) {
69
return
*
this
;
70
}
71
72
m_queue
= other.
m_queue
;
73
m_ownsQueue
=
false
;
74
return
*
this
;
75
};
76
77
cl::sycl::queue*
QueueWrapper::getQueue
()
const
{
78
return
m_queue
;
79
}
80
81
void
QueueWrapper::initialize
(
const
std::string& deviceNameSubstring) {
82
// SYCL kernel exceptions are asynchronous
83
auto
exception_handler = [](cl::sycl::exception_list exceptions) {
84
for
(std::exception_ptr
const
&
e
: exceptions) {
85
try
{
86
std::rethrow_exception(
e
);
87
}
catch
(std::exception&
e
) {
88
ACTS_LOCAL_LOGGER
(
89
Acts::getDefaultLogger
(
"SyclQueue"
,
Acts::Logging::INFO
));
90
ACTS_FATAL
(
"Caught asynchronous (kernel) SYCL exception:\n"
<< e.what())
91
}
92
}
93
};
94
95
ACTS_LOCAL_LOGGER
(
96
Acts::getDefaultLogger
(
"QueueWrapper"
,
Acts::Logging::INFO
));
97
// Create queue with custom device selector
98
m_queue
=
new
cl::sycl::queue(
DeviceSelector
(deviceNameSubstring),
99
exception_handler);
100
101
m_ownsQueue
=
true
;
102
103
// See which device we are running on.
104
ACTS_INFO
(
"Running on: "
105
<<
m_queue
->get_device().get_info<
cl::sycl::info::device::name
>());
106
};
107
108
}
// namespace Acts::Sycl
acts
blob
sPHENIX
Plugins
Sycl
src
Utilities
QueueWrapper.cpp
Built by
Jin Huang
. updated:
Mon Jan 22 2024 12:43:26
using
1.8.2 with
EIC GitHub integration