Skip to content

Commit d7b5c0d

Browse files
againullv-klochkov
authored andcommitted
[SYCL] Fix memory leaks
Signed-off-by: Gainullin <[email protected]>
1 parent 635f845 commit d7b5c0d

File tree

5 files changed

+9
-7
lines changed

5 files changed

+9
-7
lines changed

sycl/include/CL/sycl/detail/cg.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,8 @@ class CG {
346346

347347
CGTYPE getType() { return MType; }
348348

349+
virtual ~CG() = default;
350+
349351
private:
350352
CGTYPE MType;
351353
// The following storages needed to ensure that arguments won't die while

sycl/include/CL/sycl/group.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ template <typename T, int Dimensions = 1> class private_memory {
7777
#else
7878
// On serial host there is one private_memory<T> instance per work group, so
7979
// it must have space to hold separate value per WI in the group.
80-
std::unique_ptr<T> Val;
80+
std::unique_ptr<T[]> Val;
8181
#endif // #ifdef __SYCL_DEVICE_ONLY__
8282
};
8383

sycl/test/hier_par/hier_par_basic.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ int main() {
114114
constexpr int N_ITER = 2;
115115

116116
constexpr size_t range_length = N_WG * WG_SIZE_PHYSICAL;
117-
std::unique_ptr<int> data(new int[range_length]);
117+
std::unique_ptr<int[]> data(new int[range_length]);
118118
int *ptr = data.get();
119119
bool passed = true;
120120

@@ -232,7 +232,7 @@ int main() {
232232
const int WG_LINEAR_SIZE = WG_X_SIZE * WG_Y_SIZE;
233233
const int range_length = N_WG * WG_LINEAR_SIZE;
234234

235-
std::unique_ptr<int> data(new int[range_length]);
235+
std::unique_ptr<int[]> data(new int[range_length]);
236236
int *ptr = data.get();
237237

238238
std::memset(ptr, 0, range_length * sizeof(ptr[0]));

sycl/test/hier_par/hier_par_wgscope.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ static bool testWgScope(queue &Q) {
4040
const int VAL2 = 1000;
4141
const int GROUP_ID_SPLIT = 2;
4242

43-
std::unique_ptr<int> Data(new int[RangeLength]);
43+
std::unique_ptr<int[]> Data(new int[RangeLength]);
4444
int *Ptr = Data.get();
4545
std::memset(Ptr, 0, RangeLength * sizeof(Ptr[0]));
4646

@@ -204,7 +204,7 @@ bool testPrivateMemory(queue &Q) {
204204
constexpr int C1 = 5;
205205
constexpr int C2 = 1;
206206

207-
std::unique_ptr<int> Data(new int[RangeLength]);
207+
std::unique_ptr<int[]> Data(new int[RangeLength]);
208208
int *Ptr = Data.get();
209209

210210
std::memset(Ptr, 0, RangeLength * sizeof(Ptr[0]));

sycl/test/regression/group.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ bool group__get_group_range() {
3434
const range<DIMS> GlobalRange = LocalRange * GroupRange;
3535
using DataType = size_t;
3636
const int DataLen = GlobalRange.size() * DIMS;
37-
std::unique_ptr<DataType> Data(new DataType[DataLen]);
37+
std::unique_ptr<DataType[]> Data(new DataType[DataLen]);
3838
std::memset(Data.get(), 0, DataLen * sizeof(DataType));
3939

4040
try {
@@ -100,7 +100,7 @@ bool group__get_linear_id() {
100100
const range<DIMS> GlobalRange = LocalRange * GroupRange;
101101
using DataType = size_t;
102102
const int DataLen = GlobalRange.size() * DIMS;
103-
std::unique_ptr<DataType> Data(new DataType[DataLen]);
103+
std::unique_ptr<DataType[]> Data(new DataType[DataLen]);
104104
std::memset(Data.get(), 0, DataLen * sizeof(DataType));
105105

106106
try {

0 commit comments

Comments
 (0)