8
8
#pragma once
9
9
10
10
#include < CL/sycl/context.hpp>
11
+ #include < CL/sycl/detail/common.hpp>
11
12
#include < CL/sycl/detail/export.hpp>
12
13
#include < CL/sycl/device.hpp>
13
14
#include < CL/sycl/exception.hpp>
@@ -24,8 +25,10 @@ namespace sycl {
24
25
__SYCL_EXPORT void *aligned_alloc (size_t alignment, size_t size,
25
26
const device &dev, const context &ctxt,
26
27
usm::alloc kind,
27
- const property_list &propList);
28
- __SYCL_EXPORT void free (void *ptr, const context &ctxt);
28
+ const property_list &propList,
29
+ const detail::code_location CL);
30
+ __SYCL_EXPORT void free (void *ptr, const context &ctxt,
31
+ const detail::code_location CL);
29
32
30
33
template <typename T, usm::alloc AllocKind, size_t Alignment = alignof (T)>
31
34
class usm_allocator {
@@ -74,11 +77,12 @@ class usm_allocator {
74
77
// / Allocates memory.
75
78
// /
76
79
// / \param NumberOfElements is a count of elements to allocate memory for.
77
- T *allocate (size_t NumberOfElements) {
80
+ T *allocate (size_t NumberOfElements, const detail::code_location CL =
81
+ detail::code_location::current ()) {
78
82
79
83
auto Result = reinterpret_cast <T *>(
80
84
aligned_alloc (getAlignment (), NumberOfElements * sizeof (value_type),
81
- MDevice, MContext, AllocKind, MPropList));
85
+ MDevice, MContext, AllocKind, MPropList, CL ));
82
86
if (!Result) {
83
87
throw memory_allocation_error ();
84
88
}
@@ -89,9 +93,11 @@ class usm_allocator {
89
93
// /
90
94
// / \param Ptr is a pointer to memory being deallocated.
91
95
// / \param Size is a number of elements previously passed to allocate.
92
- void deallocate (T *Ptr, size_t ) {
96
+ void deallocate (
97
+ T *Ptr, size_t ,
98
+ const detail::code_location CL = detail::code_location::current()) {
93
99
if (Ptr) {
94
- free (Ptr, MContext);
100
+ free (Ptr, MContext, CL );
95
101
}
96
102
}
97
103
0 commit comments