-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "test_cuda_data_structures.hpp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |