-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix the templated version of short_vector, add new tests
- Loading branch information
Showing
4 changed files
with
131 additions
and
147 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
145 changes: 0 additions & 145 deletions
145
tests/Unit/AmpShortVectors/amp_short_vectors_short_vector.cpp
This file was deleted.
Oops, something went wrong.
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,45 @@ | ||
// RUN: %hc %s -o %t.out && %t.out | ||
#include <hc.hpp> | ||
#include <hc_short_vector.hpp> | ||
|
||
#define GRID_SIZE (64) | ||
|
||
using namespace hc; | ||
using namespace hc::short_vector; | ||
|
||
template<typename T> | ||
bool test_norm() { | ||
extent<1> ex(GRID_SIZE); | ||
array_view<int, 1> av(GRID_SIZE); | ||
parallel_for_each(ex, [=](index<1>& idx) [[hc]] { | ||
T val; | ||
av[idx] = (int)val; | ||
}).wait(); | ||
|
||
av.synchronize(); | ||
return av[0] == 0; | ||
} | ||
|
||
template<typename T> | ||
bool test() { | ||
extent<1> ex(GRID_SIZE); | ||
array_view<int, 1> av(GRID_SIZE); | ||
parallel_for_each(ex, [=](index<1>& idx) [[hc]] { | ||
T val; | ||
av[idx] = (int)(val.get_x()); | ||
}).wait(); | ||
|
||
av.synchronize(); | ||
return av[0] == 0; | ||
} | ||
|
||
int main(void) { | ||
bool ret = true; | ||
|
||
ret &= test<short_vector<double,1>::type>(); | ||
ret &= test<short_vector<int,2>::type>(); | ||
ret &= test<short_vector<unsigned int,3>::type>(); | ||
ret &= test<short_vector<float,4>::type>(); | ||
|
||
return !(ret == true); | ||
} |
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,84 @@ | ||
// RUN: %hc %s -o %t.out && %t.out | ||
#include <hc.hpp> | ||
#include <hc_short_vector.hpp> | ||
#include <type_traits> | ||
|
||
using namespace hc; | ||
using namespace hc::short_vector; | ||
|
||
int main(void) { | ||
|
||
static_assert(std::is_same<typename short_vector<unsigned char, 1>::type, uchar_1>::value, | ||
"Mismatched vector types!"); | ||
static_assert(std::is_same<typename short_vector<unsigned char, 2>::type, uchar_2>::value, | ||
"Mismatched vector types!"); | ||
static_assert(std::is_same<typename short_vector<unsigned char, 3>::type, uchar_3>::value, | ||
"Mismatched vector types!"); | ||
static_assert(std::is_same<typename short_vector<unsigned char, 4>::type, uchar_4>::value, | ||
"Mismatched vector types!"); | ||
|
||
static_assert(std::is_same<typename short_vector<char, 1>::type, char_1>::value, | ||
"Mismatched vector types!"); | ||
static_assert(std::is_same<typename short_vector<char, 2>::type, char_2>::value, | ||
"Mismatched vector types!"); | ||
static_assert(std::is_same<typename short_vector<char, 3>::type, char_3>::value, | ||
"Mismatched vector types!"); | ||
static_assert(std::is_same<typename short_vector<char, 4>::type, char_4>::value, | ||
"Mismatched vector types!"); | ||
|
||
static_assert(std::is_same<typename short_vector<unsigned short, 1>::type, ushort_1>::value, | ||
"Mismatched vector types!"); | ||
static_assert(std::is_same<typename short_vector<unsigned short, 2>::type, ushort_2>::value, | ||
"Mismatched vector types!"); | ||
static_assert(std::is_same<typename short_vector<unsigned short, 3>::type, ushort_3>::value, | ||
"Mismatched vector types!"); | ||
static_assert(std::is_same<typename short_vector<unsigned short, 4>::type, ushort_4>::value, | ||
"Mismatched vector types!"); | ||
|
||
static_assert(std::is_same<typename short_vector<short, 1>::type, short_1>::value, | ||
"Mismatched vector types!"); | ||
static_assert(std::is_same<typename short_vector<short, 2>::type, short_2>::value, | ||
"Mismatched vector types!"); | ||
static_assert(std::is_same<typename short_vector<short, 3>::type, short_3>::value, | ||
"Mismatched vector types!"); | ||
static_assert(std::is_same<typename short_vector<short, 4>::type, short_4>::value, | ||
"Mismatched vector types!"); | ||
|
||
static_assert(std::is_same<typename short_vector<unsigned int, 1>::type, uint_1>::value, | ||
"Mismatched vector types!"); | ||
static_assert(std::is_same<typename short_vector<unsigned int, 2>::type, uint_2>::value, | ||
"Mismatched vector types!"); | ||
static_assert(std::is_same<typename short_vector<unsigned int, 3>::type, uint_3>::value, | ||
"Mismatched vector types!"); | ||
static_assert(std::is_same<typename short_vector<unsigned int, 4>::type, uint_4>::value, | ||
"Mismatched vector types!"); | ||
|
||
static_assert(std::is_same<typename short_vector<int, 1>::type, int_1>::value, | ||
"Mismatched vector types!"); | ||
static_assert(std::is_same<typename short_vector<int, 2>::type, int_2>::value, | ||
"Mismatched vector types!"); | ||
static_assert(std::is_same<typename short_vector<int, 3>::type, int_3>::value, | ||
"Mismatched vector types!"); | ||
static_assert(std::is_same<typename short_vector<int, 4>::type, int_4>::value, | ||
"Mismatched vector types!"); | ||
|
||
static_assert(std::is_same<typename short_vector<float, 1>::type, float_1>::value, | ||
"Mismatched vector types!"); | ||
static_assert(std::is_same<typename short_vector<float, 2>::type, float_2>::value, | ||
"Mismatched vector types!"); | ||
static_assert(std::is_same<typename short_vector<float, 3>::type, float_3>::value, | ||
"Mismatched vector types!"); | ||
static_assert(std::is_same<typename short_vector<float, 4>::type, float_4>::value, | ||
"Mismatched vector types!"); | ||
|
||
static_assert(std::is_same<typename short_vector<double, 1>::type, double_1>::value, | ||
"Mismatched vector types!"); | ||
static_assert(std::is_same<typename short_vector<double, 2>::type, double_2>::value, | ||
"Mismatched vector types!"); | ||
static_assert(std::is_same<typename short_vector<double, 3>::type, double_3>::value, | ||
"Mismatched vector types!"); | ||
static_assert(std::is_same<typename short_vector<double, 4>::type, double_4>::value, | ||
"Mismatched vector types!"); | ||
|
||
return 0; | ||
} |