Skip to content

Commit 6e6bcf6

Browse files
committed
Add buffer memory leak test case
See issue #746
1 parent 520f9b3 commit 6e6bcf6

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

test/test_reduce.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,4 +276,23 @@ BOOST_AUTO_TEST_CASE(reduce_uchar_to_float)
276276
BOOST_CHECK_EQUAL(sum, 500);
277277
}
278278

279+
// Test case for https://github.com/boostorg/compute/issues/746
280+
BOOST_AUTO_TEST_CASE(buffer_reference_count_test)
281+
{
282+
using compute::uint_;
283+
284+
compute::vector<uint_> vector(8, context);
285+
const compute::buffer& b = vector.get_buffer();
286+
uint_ rc1 = b.get_info<CL_MEM_REFERENCE_COUNT>();
287+
{
288+
compute::fill(vector.begin(), vector.end(), uint_(2), queue);
289+
290+
uint_ product;
291+
compute::reduce(vector.begin(), vector.end(), &product, compute::multiplies<uint_>(), queue);
292+
BOOST_CHECK_EQUAL(product, uint_(256));
293+
}
294+
uint_ rc2 = b.get_info<CL_MEM_REFERENCE_COUNT>();
295+
BOOST_CHECK_EQUAL(rc1, rc2);
296+
}
297+
279298
BOOST_AUTO_TEST_SUITE_END()

0 commit comments

Comments
 (0)