Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Arrays.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Arrays.hpp
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 #pragma once
10 
11 // SYCL include(s).
12 #include <CL/sycl.hpp>
13 
14 // System include(s).
15 #include <cstddef>
16 #include <memory>
17 
18 namespace Acts::Sycl {
19 
20 namespace detail {
21 
24  public:
26  DeviceArrayDeleter(cl::sycl::queue& queue) : m_queue(&queue) {}
28  void operator()(void* ptr) {
29  if (ptr != nullptr) {
30  cl::sycl::free(ptr, *m_queue);
31  }
32  }
33 
34  private:
36  cl::sycl::queue* m_queue;
37 }; // class DeviceArrayDeleter
38 
39 } // namespace detail
40 
42 template <typename T>
43 using device_array = std::unique_ptr<T, detail::DeviceArrayDeleter>;
44 
46 template <typename T>
47 device_array<T> make_device_array(std::size_t size, cl::sycl::queue& queue) {
48  return device_array<T>(cl::sycl::malloc_device<T>(size, queue),
50 }
51 
52 } // namespace Acts::Sycl