Created
April 21, 2015 17:27
-
-
Save navyxliu/3dbcfbc36e698891d65e to your computer and use it in GitHub Desktop.
bug018
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
#include <amptest.h> | |
#include <amptest_main.h> | |
#include <vector> | |
using std::vector; | |
using namespace Concurrency; | |
using namespace Concurrency::Test; | |
/// Common Section | |
template<typename _type> | |
bool test_feature() restrict(amp,cpu); | |
template <typename T> | |
bool test() restrict(amp,cpu) | |
{ | |
return test_feature<T>(); | |
} | |
runall_result test_main() | |
{ | |
accelerator_view av = require_device().get_default_view(); | |
runall_result result; | |
// result &= INVOKE_TEST_FUNC_ON_CPU_AND_GPU_NOAV(/* av, */ test_feature< extent<1> >); | |
// | |
// result &= INVOKE_TEST_FUNC_ON_CPU_AND_GPU_NOAV(/* av, */ []() restrict(amp,cpu)->bool{ | |
// return test<extent<1>>(); | |
// }); | |
// | |
result &= INVOKE_TEST_FUNC_ON_CPU_AND_GPU_NOAV(/* av, */ []() restrict(amp,cpu)->bool{ | |
return test<extent<4>>(); | |
}); | |
// result &= INVOKE_TEST_FUNC_ON_CPU_AND_GPU_NOAV(/* av, */ []() restrict(amp,cpu)->bool{ | |
// return test<extent<10>>(); | |
// }); | |
return result; | |
} | |
template<typename _type> | |
bool test_size() restrict(cpu,amp); | |
template<typename _type> | |
bool test_feature() __GPU | |
{ | |
return test_size<_type>(); | |
} | |
template<typename _type> | |
bool test_positive_size() __GPU | |
{ | |
const int rank = _type::rank; | |
// all positive elements | |
int data1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; | |
{ | |
int correct_size = 1; | |
extent<rank> e1(data1); | |
_type g1(e1); | |
for (int i = 0; i < g1.rank; i++) | |
correct_size *= data1[i]; | |
if (correct_size != g1.size()) | |
return false; | |
} | |
{ | |
int correct_size = 1; | |
extent<rank> e1(data1); | |
_type g1(e1); | |
for (int i = 0; i < g1.rank; i++) | |
correct_size *= data1[i]; | |
if (correct_size != g1.size()) | |
return false; | |
} | |
return true; | |
} | |
template<typename _type> | |
bool test_size_const_attribute() __GPU | |
{ | |
const int rank = _type::rank; | |
int data1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; | |
{ | |
int correct_size = 1; | |
extent<rank> e1(data1); | |
const _type g1(e1); | |
for (int i = 0; i < g1.rank; i++) | |
correct_size *= data1[i]; | |
if (g1.rank != 4) return false; | |
if (correct_size != 24) return false; | |
/* | |
if (correct_size != g1.size()) | |
return false; | |
*/ | |
} | |
/* | |
{ | |
int correct_size = 1; | |
extent<rank> e1(data1); | |
const _type g1(e1); | |
for (int i = 0; i < g1.rank; i++) | |
correct_size *= data1[i]; | |
if (correct_size != g1.size()) | |
return false; | |
} | |
{ | |
int correct_size = 0; // default construtor | |
const _type g1; | |
if (correct_size != g1.size()) | |
return false; | |
} | |
*/ | |
return true; | |
} | |
template<typename _type> // ignore template parameter | |
bool test_size() restrict(amp,cpu) | |
{ | |
return test_size_const_attribute<_type>(); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment