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

[SYCL] Fix radix test sort memeory leak #1298

Merged
merged 3 commits into from
Oct 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions SYCL/ESIMD/radix_sort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,8 @@ void radix_sort(queue &q, unsigned *in, unsigned *out, unsigned size) {
//
std::swap(in, out);
}
q.wait();
free(histogram, ctxt);
}

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

unsigned int *histogram = static_cast<unsigned int *>(
malloc_shared(size * sizeof(unsigned int), dev, ctxt));

radix_sort(q, pInputs, tmp_buf, size);

q.wait();

bool pass = memcmp(pInputs, pExpectOutputs, size * sizeof(unsigned int)) == 0;

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

free(pInputs, ctxt);
free(tmp_buf, ctxt);
free(pExpectOutputs);
return 0;
}