Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-26 08:22:12

0001 /** TRACCC library, part of the ACTS project (R&D line)
0002  *
0003  * (c) 2022-2025 CERN for the benefit of the ACTS project
0004  *
0005  * Mozilla Public License Version 2.0
0006  */
0007 
0008 // Local include(s).
0009 #include "utils.hpp"
0010 
0011 #include "hip_error_handling.hpp"
0012 
0013 namespace traccc::hip::details {
0014 
0015 int get_device() {
0016   int d = -1;
0017   [[maybe_unused]] auto code = hipGetDevice(&d);
0018   return d;
0019 }
0020 
0021 unsigned int get_warp_size(int device) {
0022   int warp_size = 0;
0023   TRACCC_HIP_ERROR_CHECK(
0024       hipDeviceGetAttribute(&warp_size, hipDeviceAttributeWarpSize, device));
0025   return static_cast<unsigned int>(warp_size);
0026 }
0027 
0028 hipStream_t get_stream(const stream& stream) {
0029   return reinterpret_cast<hipStream_t>(stream.hipStream());
0030 }
0031 
0032 select_device::select_device(int device) {
0033   /*
0034    * When the object is constructed, grab the current device number and
0035    * store it as a member variable. Then set the device to whatever was
0036    * specified.
0037    */
0038   TRACCC_HIP_ERROR_CHECK(hipGetDevice(&m_device));
0039   TRACCC_HIP_ERROR_CHECK(hipSetDevice(device));
0040 }
0041 
0042 select_device::~select_device() {
0043   /*
0044    * On destruction, reset the device number to whatever it was before the
0045    * object was constructed.
0046    */
0047   TRACCC_HIP_ERROR_CHECK(hipSetDevice(m_device));
0048 }
0049 
0050 int select_device::device() const {
0051   return m_device;
0052 }
0053 
0054 }  // namespace traccc::hip::details