Skip to content

Commit

Permalink
[SYCL][NFC] Move some detail:: functions into library
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexeySachkov committed Sep 23, 2024
1 parent 5beeb96 commit cac4cca
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 34 deletions.
1 change: 1 addition & 0 deletions sycl/include/sycl/detail/helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <sycl/access/access.hpp> // for fence_space
#include <sycl/detail/export.hpp> // for __SYCL_EXPORT
#include <sycl/memory_enums.hpp> // for memory_order
#include <ur_api.h>

#ifdef __SYCL_DEVICE_ONLY__
#include <CL/__spirv/spirv_vars.hpp>
Expand Down
34 changes: 0 additions & 34 deletions sycl/include/sycl/memory_enums.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

#pragma once

#include <ur_api.h> // for ur_memory_order_capability_flags_t

#include <atomic> // for memory_order
#include <vector> // for vector

Expand Down Expand Up @@ -48,38 +46,6 @@ inline constexpr auto memory_order_seq_cst = memory_order::seq_cst;

namespace detail {

inline std::vector<memory_order>
readMemoryOrderBitfield(ur_memory_order_capability_flags_t bits) {
std::vector<memory_order> result;
if (bits & UR_MEMORY_ORDER_CAPABILITY_FLAG_RELAXED)
result.push_back(memory_order::relaxed);
if (bits & UR_MEMORY_ORDER_CAPABILITY_FLAG_ACQUIRE)
result.push_back(memory_order::acquire);
if (bits & UR_MEMORY_ORDER_CAPABILITY_FLAG_RELEASE)
result.push_back(memory_order::release);
if (bits & UR_MEMORY_ORDER_CAPABILITY_FLAG_ACQ_REL)
result.push_back(memory_order::acq_rel);
if (bits & UR_MEMORY_ORDER_CAPABILITY_FLAG_SEQ_CST)
result.push_back(memory_order::seq_cst);
return result;
}

inline std::vector<memory_scope>
readMemoryScopeBitfield(ur_memory_scope_capability_flags_t bits) {
std::vector<memory_scope> result;
if (bits & UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_ITEM)
result.push_back(memory_scope::work_item);
if (bits & UR_MEMORY_SCOPE_CAPABILITY_FLAG_SUB_GROUP)
result.push_back(memory_scope::sub_group);
if (bits & UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_GROUP)
result.push_back(memory_scope::work_group);
if (bits & UR_MEMORY_SCOPE_CAPABILITY_FLAG_DEVICE)
result.push_back(memory_scope::device);
if (bits & UR_MEMORY_SCOPE_CAPABILITY_FLAG_SYSTEM)
result.push_back(memory_scope::system);
return result;
}

#ifndef __SYCL_DEVICE_ONLY__
static constexpr std::memory_order getStdMemoryOrder(sycl::memory_order order) {
switch (order) {
Expand Down
33 changes: 33 additions & 0 deletions sycl/source/detail/device_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <sycl/info/info_desc.hpp>
#include <sycl/memory_enums.hpp>
#include <sycl/platform.hpp>
#include <ur_api.h> // for ur_memory_order_capability_flags_t

#include <chrono>
#include <sstream>
Expand All @@ -34,6 +35,38 @@ namespace sycl {
inline namespace _V1 {
namespace detail {

inline std::vector<memory_order>
readMemoryOrderBitfield(ur_memory_order_capability_flags_t bits) {
std::vector<memory_order> result;
if (bits & UR_MEMORY_ORDER_CAPABILITY_FLAG_RELAXED)
result.push_back(memory_order::relaxed);
if (bits & UR_MEMORY_ORDER_CAPABILITY_FLAG_ACQUIRE)
result.push_back(memory_order::acquire);
if (bits & UR_MEMORY_ORDER_CAPABILITY_FLAG_RELEASE)
result.push_back(memory_order::release);
if (bits & UR_MEMORY_ORDER_CAPABILITY_FLAG_ACQ_REL)
result.push_back(memory_order::acq_rel);
if (bits & UR_MEMORY_ORDER_CAPABILITY_FLAG_SEQ_CST)
result.push_back(memory_order::seq_cst);
return result;
}

inline std::vector<memory_scope>
readMemoryScopeBitfield(ur_memory_scope_capability_flags_t bits) {
std::vector<memory_scope> result;
if (bits & UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_ITEM)
result.push_back(memory_scope::work_item);
if (bits & UR_MEMORY_SCOPE_CAPABILITY_FLAG_SUB_GROUP)
result.push_back(memory_scope::sub_group);
if (bits & UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_GROUP)
result.push_back(memory_scope::work_group);
if (bits & UR_MEMORY_SCOPE_CAPABILITY_FLAG_DEVICE)
result.push_back(memory_scope::device);
if (bits & UR_MEMORY_SCOPE_CAPABILITY_FLAG_SYSTEM)
result.push_back(memory_scope::system);
return result;
}

inline std::vector<info::fp_config>
read_fp_bitfield(ur_device_fp_capability_flags_t bits) {
std::vector<info::fp_config> result;
Expand Down

0 comments on commit cac4cca

Please sign in to comment.