Skip to content

Commit 2b72e40

Browse files
committed
As prev, in memory.hpp
1 parent 1d02f69 commit 2b72e40

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

sycl/include/syclcompat/memory.hpp

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -326,11 +326,11 @@ template <memory_region Memory, class T = byte_t> class memory_traits {
326326
};
327327

328328
static inline void *malloc(size_t size, sycl::queue q) {
329-
#ifdef COMPAT_USM_LEVEL_NONE
329+
#ifdef SYCLCOMPAT_USM_LEVEL_NONE
330330
return mem_mgr::instance().mem_alloc(size * sizeof(byte_t));
331331
#else
332332
return sycl::malloc_device(size, q.get_device(), q.get_context());
333-
#endif // COMPAT_USM_LEVEL_NONE
333+
#endif // SYCLCOMPAT_USM_LEVEL_NONE
334334
}
335335

336336
/// Calculate pitch (padded length of major dimension \p x) by rounding up to
@@ -366,7 +366,7 @@ static inline void *malloc(size_t &pitch, size_t x, size_t y, size_t z,
366366
template <class T>
367367
static inline sycl::event fill(sycl::queue q, void *dev_ptr, const T &pattern,
368368
size_t count) {
369-
#ifdef COMPAT_USM_LEVEL_NONE
369+
#ifdef SYCLCOMPAT_USM_LEVEL_NONE
370370
auto &mm = mem_mgr::instance();
371371
assert(mm.is_device_ptr(dev_ptr));
372372
auto alloc = mm.translate_ptr(dev_ptr);
@@ -395,7 +395,7 @@ static inline sycl::event fill(sycl::queue q, void *dev_ptr, const T &pattern,
395395
/// \returns An event representing the memset operation.
396396
static inline sycl::event memset(sycl::queue q, void *dev_ptr, int value,
397397
size_t size) {
398-
#ifdef COMPAT_USM_LEVEL_NONE
398+
#ifdef SYCLCOMPAT_USM_LEVEL_NONE
399399
auto &mm = mem_mgr::instance();
400400
assert(mm.is_device_ptr(dev_ptr));
401401
auto alloc = mm.translate_ptr(dev_ptr);
@@ -413,7 +413,7 @@ static inline sycl::event memset(sycl::queue q, void *dev_ptr, int value,
413413
});
414414
#else
415415
return q.memset(dev_ptr, value, size);
416-
#endif // COMPAT_USM_LEVEL_NONE
416+
#endif // SYCLCOMPAT_USM_LEVEL_NONE
417417
}
418418

419419
/// \brief Sets \p value to the 3D memory region pointed by \p data in \p q.
@@ -467,7 +467,7 @@ enum class pointer_access_attribute {
467467

468468
static pointer_access_attribute get_pointer_attribute(sycl::queue q,
469469
const void *ptr) {
470-
#ifdef COMPAT_USM_LEVEL_NONE
470+
#ifdef SYCLCOMPAT_USM_LEVEL_NONE
471471
return mem_mgr::instance().is_device_ptr(ptr)
472472
? pointer_access_attribute::device_only
473473
: pointer_access_attribute::host_only;
@@ -481,7 +481,7 @@ static pointer_access_attribute get_pointer_attribute(sycl::queue q,
481481
case sycl::usm::alloc::host:
482482
return pointer_access_attribute::host_device;
483483
}
484-
#endif // COMPAT_USM_LEVEL_NONE
484+
#endif // SYCLCOMPAT_USM_LEVEL_NONE
485485
}
486486

487487
static memcpy_direction
@@ -502,7 +502,7 @@ static sycl::event memcpy(sycl::queue q, void *to_ptr, const void *from_ptr,
502502
const std::vector<sycl::event> &dep_events = {}) {
503503
if (!size)
504504
return sycl::event{};
505-
#ifdef COMPAT_USM_LEVEL_NONE
505+
#ifdef SYCLCOMPAT_USM_LEVEL_NONE
506506
auto &mm = mem_mgr::instance();
507507
auto real_direction = deduce_memcpy_direction(q, to_ptr, from_ptr);
508508

@@ -562,7 +562,7 @@ static sycl::event memcpy(sycl::queue q, void *to_ptr, const void *from_ptr,
562562
}
563563
#else
564564
return q.memcpy(to_ptr, from_ptr, size, dep_events);
565-
#endif // COMPAT_USM_LEVEL_NONE
565+
#endif // SYCLCOMPAT_USM_LEVEL_NONE
566566
}
567567

568568
// Get actual copy range and make sure it will not exceed range.
@@ -680,7 +680,7 @@ memcpy(sycl::queue q, void *to_ptr, const void *from_ptr,
680680
break;
681681
}
682682
case device_to_device:
683-
#ifdef COMPAT_USM_LEVEL_NONE
683+
#ifdef SYCLCOMPAT_USM_LEVEL_NONE
684684
{
685685
auto &mm = mem_mgr::instance();
686686
auto to_alloc = mm.translate_ptr(to_surface);
@@ -714,7 +714,7 @@ memcpy(sycl::queue q, void *to_ptr, const void *from_ptr,
714714
from_surface[get_offset(id, from_slice, from_range.get(0))];
715715
});
716716
}));
717-
#endif // COMPAT_USM_LEVEL_NONE
717+
#endif // SYCLCOMPAT_USM_LEVEL_NONE
718718
break;
719719
default:
720720
throw std::runtime_error("[SYCLcompat] memcpy: invalid direction value");
@@ -753,7 +753,7 @@ static sycl::event combine_events(std::vector<sycl::event> &events,
753753

754754
} // namespace detail
755755

756-
#ifdef COMPAT_USM_LEVEL_NONE
756+
#ifdef SYCLCOMPAT_USM_LEVEL_NONE
757757
/// Check if the pointer \p ptr represents device pointer or not.
758758
///
759759
/// \param ptr The pointer to be checked.
@@ -987,11 +987,11 @@ namespace detail {
987987

988988
inline void free(void *ptr, const sycl::queue &q) {
989989
if (ptr) {
990-
#ifdef COMPAT_USM_LEVEL_NONE
990+
#ifdef SYCLCOMPAT_USM_LEVEL_NONE
991991
detail::mem_mgr::instance().mem_free(ptr);
992992
#else
993993
sycl::free(ptr, q.get_context());
994-
#endif // COMPAT_USM_LEVEL_NONE
994+
#endif // SYCLCOMPAT_USM_LEVEL_NONE
995995
}
996996
}
997997
} // namespace detail
@@ -1016,7 +1016,7 @@ namespace {
10161016
/// \param ptr Point to free.
10171017
/// \returns no return value.
10181018
static inline void free(void *ptr, sycl::queue q = get_default_queue()) {
1019-
#ifndef COMPAT_USM_LEVEL_NONE
1019+
#ifndef SYCLCOMPAT_USM_LEVEL_NONE
10201020
get_device(get_device_id(q.get_device())).queues_wait_and_throw();
10211021
#endif
10221022
detail::free(ptr, q);
@@ -1570,7 +1570,7 @@ template <class T, memory_region Memory, size_t Dimension> class device_memory {
15701570
"device memory region should be global, constant or shared");
15711571
// Make sure that singleton class dev_mgr will destruct later than this.
15721572
detail::dev_mgr::instance();
1573-
#ifdef COMPAT_USM_LEVEL_NONE
1573+
#ifdef SYCLCOMPAT_USM_LEVEL_NONE
15741574
detail::mem_mgr::instance();
15751575
#endif
15761576
}
@@ -1632,16 +1632,16 @@ template <class T, memory_region Memory, size_t Dimension> class device_memory {
16321632
template <size_t Dim = Dimension>
16331633
typename std::enable_if<Dim == 1, T>::type &operator[](size_t index) {
16341634
init();
1635-
#ifdef COMPAT_USM_LEVEL_NONE
1635+
#ifdef SYCLCOMPAT_USM_LEVEL_NONE
16361636
return syclcompat::get_buffer<typename std::enable_if<Dim == 1, T>::type>(
16371637
_device_ptr)
16381638
.template get_access<sycl::access_mode::read_write>()[index];
16391639
#else
16401640
return _device_ptr[index];
1641-
#endif // COMPAT_USM_LEVEL_NONE
1641+
#endif // SYCLCOMPAT_USM_LEVEL_NONE
16421642
}
16431643

1644-
#ifdef COMPAT_USM_LEVEL_NONE
1644+
#ifdef SYCLCOMPAT_USM_LEVEL_NONE
16451645
/// Get sycl::accessor for the device memory object when usm is not used.
16461646
accessor_t get_access(sycl::handler &cgh) {
16471647
return get_buffer(_device_ptr)
@@ -1657,7 +1657,7 @@ template <class T, memory_region Memory, size_t Dimension> class device_memory {
16571657
get_access(sycl::handler &cgh) {
16581658
return syclcompat_accessor_t((T *)_device_ptr, _range);
16591659
}
1660-
#endif // COMPAT_USM_LEVEL_NONE
1660+
#endif // SYCLCOMPAT_USM_LEVEL_NONE
16611661

16621662
private:
16631663
device_memory(value_t *memory_ptr, size_t size,
@@ -1666,7 +1666,7 @@ template <class T, memory_region Memory, size_t Dimension> class device_memory {
16661666
_device_ptr(memory_ptr), _q(q) {}
16671667

16681668
void allocate_device(sycl::queue q) {
1669-
#ifndef COMPAT_USM_LEVEL_NONE
1669+
#ifndef SYCLCOMPAT_USM_LEVEL_NONE
16701670
if (Memory == memory_region::usm_shared) {
16711671
_device_ptr = (value_t *)sycl::malloc_shared(_size, q.get_device(),
16721672
q.get_context());
@@ -1705,14 +1705,14 @@ class device_memory<T, Memory, 0> : public device_memory<T, Memory, 1> {
17051705

17061706
/// Default constructor
17071707
device_memory(sycl::queue q = get_default_queue()) : base(1, q) {}
1708-
#ifdef COMPAT_USM_LEVEL_NONE
1708+
#ifdef SYCLCOMPAT_USM_LEVEL_NONE
17091709
/// Get sycl::accessor for the device memory object when usm is not used.
17101710
accessor_t get_access(sycl::handler &cgh) {
17111711
auto buf = get_buffer(base::get_ptr())
17121712
.template reinterpret<T, 1>(sycl::range<1>(1));
17131713
return accessor_t(buf, cgh);
17141714
}
1715-
#endif // COMPAT_USM_LEVEL_NONE
1715+
#endif // SYCLCOMPAT_USM_LEVEL_NONE
17161716
};
17171717

17181718
template <class T, size_t Dimension>
@@ -1725,7 +1725,7 @@ using shared_memory = device_memory<T, memory_region::usm_shared, Dimension>;
17251725
class pointer_attributes {
17261726
public:
17271727
void init(const void *ptr, sycl::queue q = get_default_queue()) {
1728-
#ifdef COMPAT_USM_LEVEL_NONE
1728+
#ifdef SYCLCOMPAT_USM_LEVEL_NONE
17291729
throw std::runtime_error(
17301730
"[SYCLcompat] pointer_attributes: only works for USM pointer.");
17311731
#else
@@ -1737,7 +1737,7 @@ class pointer_attributes {
17371737
: nullptr;
17381738
sycl::device device_obj = sycl::get_pointer_device(ptr, q.get_context());
17391739
device_id = detail::dev_mgr::instance().get_device_id(device_obj);
1740-
#endif // COMPAT_USM_LEVEL_NONE
1740+
#endif // SYCLCOMPAT_USM_LEVEL_NONE
17411741
}
17421742

17431743
sycl::usm::alloc get_memory_type() { return memory_type; }

0 commit comments

Comments
 (0)