Skip to content

Commit

Permalink
cuda_ds
Browse files Browse the repository at this point in the history
  • Loading branch information
czgdp1807 committed Feb 11, 2020
1 parent d0fe906 commit 118a0e8
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/test_cuda_data_structures.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "test_cuda_data_structures.hpp"
40 changes: 40 additions & 0 deletions tests/test_cuda_data_structures.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#ifndef TESTS_TEST_CUDA_DATA_STRUCTURES_HPP
#define TESTS_TEST_CUDA_DATA_STRUCTURES_HPP
#define BOOST_TEST_MODULE "Unit tests for cuda support for data structures."
#include<boost/test/unit_test.hpp>
#include<adaboost/cuda/cuda_data_structures.hpp>

BOOST_AUTO_TEST_CASE()
{
cudaEvent_t has_happened;
cudaEventCreate(&has_happened);
adaboost::cuda::core::VectorGPU<float> vec1(1000);
adaboost::cuda::core::VectorGPU<float> vec2(1000);
unsigned block_size = 32;
vec1.fill(1.0, block_size);
vec2.fill(1.0, block_size);
cudaEventRecord(has_happened);
cudaEventSynchronize(has_happened);
float result_gpu;
product_gpu(vec1, vec2, result_gpu, block_size);
cudaEventRecord(has_happened);
cudaEventSynchronize(has_happened);
BOOST_CHECK_MESSAGE(result_gpu == 1000.0,
"Result from product on GPU should be 1000.0");
vec1.copy_to_host();
vec2.copy_to_host();
cudaEventRecord(has_happened);
cudaEventSynchronize(has_happened);
for(unsigned i = 0; i < 1000; i++)
{
std::string msg1 = "All entries of VectorGPU should be 1";
BOOST_CHECK_MESSAGE(1 == vec1.at(i), msg1);
BOOST_CHECK_MESSAGE(1 == vec2.at(i), msg1);
}
float result;
product_gpu(vec1, vec2, result);
BOOST_CHECK_MESSAGE(result, 1000.0,
"Result from product on CPU should be 1000.0");
}

#endif

0 comments on commit 118a0e8

Please sign in to comment.