Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit 3d32795

Browse files
authored
[SYCL] Fix radix test sort memeory leak (#1298)
1 parent 25c9aad commit 3d32795

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

SYCL/ESIMD/radix_sort.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,8 @@ void radix_sort(queue &q, unsigned *in, unsigned *out, unsigned size) {
576576
//
577577
std::swap(in, out);
578578
}
579+
q.wait();
580+
free(histogram, ctxt);
579581
}
580582

581583
//************************************
@@ -621,13 +623,8 @@ int main(int argc, char *argv[]) {
621623
memcpy(pExpectOutputs, pInputs, sizeof(unsigned int) * size);
622624
std::sort(pExpectOutputs, pExpectOutputs + size);
623625

624-
unsigned int *histogram = static_cast<unsigned int *>(
625-
malloc_shared(size * sizeof(unsigned int), dev, ctxt));
626-
627626
radix_sort(q, pInputs, tmp_buf, size);
628627

629-
q.wait();
630-
631628
bool pass = memcmp(pInputs, pExpectOutputs, size * sizeof(unsigned int)) == 0;
632629

633630
for (int i = 0; i < size; i++) {
@@ -641,6 +638,7 @@ int main(int argc, char *argv[]) {
641638
<< std::endl;
642639

643640
free(pInputs, ctxt);
641+
free(tmp_buf, ctxt);
644642
free(pExpectOutputs);
645643
return 0;
646644
}

0 commit comments

Comments
 (0)