Skip to content

Commit 351cb82

Browse files
committed
test: Remove obsolete mutex tests
1 parent 3aea5cc commit 351cb82

1 file changed

Lines changed: 0 additions & 163 deletions

File tree

test/stdgpu/mutex.inc

Lines changed: 0 additions & 163 deletions
Original file line numberDiff line numberDiff line change
@@ -337,169 +337,6 @@ TEST_F(stdgpu_mutex, multiple_try_lock_both_locked)
337337
stdgpu::mutex_array<>::destroyDeviceObject(locks_check);
338338
}
339339

340-
class lock_multiple_functor_new_reference
341-
{
342-
public:
343-
lock_multiple_functor_new_reference(const stdgpu::mutex_array<>& locks,
344-
const stdgpu::index_t n_0,
345-
const stdgpu::index_t n_1,
346-
int* result)
347-
: _locks(locks)
348-
, _n_0(n_0)
349-
, _n_1(n_1)
350-
, _result(result)
351-
{
352-
}
353-
354-
STDGPU_DEVICE_ONLY void
355-
operator()(STDGPU_MAYBE_UNUSED const stdgpu::index_t i)
356-
{
357-
stdgpu::mutex_array<>::reference ref_0 = static_cast<stdgpu::mutex_array<>::reference>(_locks[_n_0]);
358-
stdgpu::mutex_array<>::reference ref_1 = static_cast<stdgpu::mutex_array<>::reference>(_locks[_n_1]);
359-
*_result = stdgpu::try_lock(ref_0, ref_1);
360-
}
361-
362-
private:
363-
stdgpu::mutex_array<> _locks;
364-
stdgpu::index_t _n_0;
365-
stdgpu::index_t _n_1;
366-
int* _result;
367-
};
368-
369-
int
370-
lock_multiple_new_reference(const stdgpu::mutex_array<>& locks, const stdgpu::index_t n_0, const stdgpu::index_t n_1)
371-
{
372-
int* result = createDeviceArray<int>(1);
373-
374-
stdgpu::for_each_index(thrust::device, 1, lock_multiple_functor_new_reference(locks, n_0, n_1, result));
375-
376-
int host_result;
377-
copyDevice2HostArray<int>(result, 1, &host_result, MemoryCopy::NO_CHECK);
378-
379-
destroyDeviceArray<int>(result);
380-
381-
return host_result;
382-
}
383-
384-
class lock_single_functor_new_reference
385-
{
386-
public:
387-
lock_single_functor_new_reference(const stdgpu::mutex_array<>& locks, const stdgpu::index_t n, std::uint8_t* result)
388-
: _locks(locks)
389-
, _n(n)
390-
, _result(result)
391-
{
392-
}
393-
394-
STDGPU_DEVICE_ONLY void
395-
operator()(STDGPU_MAYBE_UNUSED const stdgpu::index_t i)
396-
{
397-
stdgpu::mutex_array<>::reference ref = static_cast<stdgpu::mutex_array<>::reference>(_locks[_n]);
398-
*_result = static_cast<std::uint8_t>(ref.try_lock());
399-
}
400-
401-
private:
402-
stdgpu::mutex_array<> _locks;
403-
stdgpu::index_t _n;
404-
std::uint8_t* _result;
405-
};
406-
407-
bool
408-
lock_single_new_reference(const stdgpu::mutex_array<>& locks, const stdgpu::index_t n)
409-
{
410-
std::uint8_t* result = createDeviceArray<std::uint8_t>(1);
411-
412-
stdgpu::for_each_index(thrust::device, 1, lock_single_functor_new_reference(locks, n, result));
413-
414-
std::uint8_t host_result;
415-
copyDevice2HostArray<std::uint8_t>(result, 1, &host_result, MemoryCopy::NO_CHECK);
416-
417-
destroyDeviceArray<std::uint8_t>(result);
418-
419-
return static_cast<bool>(host_result);
420-
}
421-
422-
TEST_F(stdgpu_mutex, multiple_try_lock_both_unlocked_new_reference)
423-
{
424-
const stdgpu::index_t n_0 = 21;
425-
const stdgpu::index_t n_1 = 42;
426-
427-
stdgpu::mutex_array<> locks_check = stdgpu::mutex_array<>::createDeviceObject(locks_size);
428-
429-
ASSERT_TRUE(equal(locks, locks_check));
430-
431-
EXPECT_EQ(lock_multiple_new_reference(locks, n_0, n_1), -1);
432-
433-
// Both mutexes should be locked now
434-
ASSERT_TRUE(lock_single_new_reference(locks_check, n_0));
435-
ASSERT_TRUE(lock_single_new_reference(locks_check, n_1));
436-
EXPECT_TRUE(equal(locks, locks_check));
437-
438-
stdgpu::mutex_array<>::destroyDeviceObject(locks_check);
439-
}
440-
441-
TEST_F(stdgpu_mutex, multiple_try_lock_first_unlocked_second_locked_new_reference)
442-
{
443-
const stdgpu::index_t n_0 = 21;
444-
const stdgpu::index_t n_1 = 42;
445-
446-
ASSERT_TRUE(lock_single_new_reference(locks, n_1));
447-
448-
stdgpu::mutex_array<> locks_check = stdgpu::mutex_array<>::createDeviceObject(locks_size);
449-
ASSERT_TRUE(lock_single_new_reference(locks_check, n_1));
450-
451-
ASSERT_TRUE(equal(locks, locks_check));
452-
453-
EXPECT_EQ(lock_multiple_new_reference(locks, n_0, n_1), 1);
454-
455-
// Nothing has changed
456-
EXPECT_TRUE(equal(locks, locks_check));
457-
458-
stdgpu::mutex_array<>::destroyDeviceObject(locks_check);
459-
}
460-
461-
TEST_F(stdgpu_mutex, multiple_try_lock_first_locked_second_unlocked_new_reference)
462-
{
463-
const stdgpu::index_t n_0 = 21;
464-
const stdgpu::index_t n_1 = 42;
465-
466-
ASSERT_TRUE(lock_single_new_reference(locks, n_0));
467-
468-
stdgpu::mutex_array<> locks_check = stdgpu::mutex_array<>::createDeviceObject(locks_size);
469-
ASSERT_TRUE(lock_single_new_reference(locks_check, n_0));
470-
471-
ASSERT_TRUE(equal(locks, locks_check));
472-
473-
EXPECT_EQ(lock_multiple_new_reference(locks, n_0, n_1), 0);
474-
475-
// Nothing has changed
476-
EXPECT_TRUE(equal(locks, locks_check));
477-
478-
stdgpu::mutex_array<>::destroyDeviceObject(locks_check);
479-
}
480-
481-
TEST_F(stdgpu_mutex, multiple_try_lock_both_locked_new_reference)
482-
{
483-
const stdgpu::index_t n_0 = 21;
484-
const stdgpu::index_t n_1 = 42;
485-
486-
ASSERT_TRUE(lock_single_new_reference(locks, n_0));
487-
ASSERT_TRUE(lock_single_new_reference(locks, n_1));
488-
489-
stdgpu::mutex_array<> locks_check = stdgpu::mutex_array<>::createDeviceObject(locks_size);
490-
ASSERT_TRUE(lock_single_new_reference(locks_check, n_0));
491-
ASSERT_TRUE(lock_single_new_reference(locks_check, n_1));
492-
493-
ASSERT_TRUE(equal(locks, locks_check));
494-
495-
EXPECT_EQ(lock_multiple_new_reference(locks, n_0, n_1), 0);
496-
497-
// Nothing has changed
498-
EXPECT_TRUE(equal(locks, locks_check));
499-
500-
stdgpu::mutex_array<>::destroyDeviceObject(locks_check);
501-
}
502-
503340
TEST_F(stdgpu_mutex, get_allocator)
504341
{
505342
const stdgpu::index_t N = 10000;

0 commit comments

Comments
 (0)