Skip to content

Commit

Permalink
Merge pull request #64 from DerTuchi/new_tests
Browse files Browse the repository at this point in the history
Restructured Tests from last merge and some flag fixes
  • Loading branch information
JPietrzykTUD authored Sep 26, 2023
2 parents 98f5744 + f5fd236 commit 99986c5
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 85 deletions.
60 changes: 33 additions & 27 deletions primitive_data/primitives/calc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ testing:
for(std::size_t i = 0; i < (element_count - Vec::vector_element_count()); i += Vec::vector_element_count()){
std::size_t tester_idx = 0;
for(size_t j = i; j < i + Vec::vector_element_count(); j++) {
reference_result_ptr[tester_idx++] = reference_data_ptr[j];
reference_result_ptr[tester_idx++] = reference_data_ptr[j];
}
auto vec = loadu<Vec>(&test_data_ptr[i]);
auto vec_result = add<Vec>(zero_mask, vec, vec);
Expand All @@ -331,7 +331,7 @@ testing:
typename Vec::mask_type mask = to_mask<Vec>(integral_all_true<Vec>());
std::size_t element_count = 2048;
std::size_t element_count = 1024;
testing::test_memory_helper_t<Vec> test_helper{element_count, Vec::vector_element_count(), false };
bool allOk = true;
auto reference_data_ptr = test_helper.data_ref();
Expand All @@ -342,7 +342,7 @@ testing:
for(std::size_t i = 0; i < (element_count - (2*Vec::vector_element_count())); i += 2*Vec::vector_element_count()){
std::size_t tester_idx = 0;
for(size_t j = i; j < i + Vec::vector_element_count(); j++) {
reference_result_ptr[tester_idx++] = reference_data_ptr[j] + reference_data_ptr[j + Vec::vector_element_count()];
reference_result_ptr[tester_idx++] = reference_data_ptr[j] + reference_data_ptr[j + Vec::vector_element_count()];
}
auto vec_a = loadu<Vec>(&test_data_ptr[i]);
auto vec_b = loadu<Vec>(&test_data_ptr[i + Vec::vector_element_count()]);
Expand All @@ -351,7 +351,6 @@ testing:
test_helper.synchronize();
allOk &= test_helper.validate();
}
if(!allOk) std::cout << (int)to_integral<Vec>(to_mask<Vec>(integral_all_true<Vec>())) << std::endl;
return allOk;
definitions:
#INTEL - AVX512
Expand Down Expand Up @@ -454,39 +453,46 @@ testing:
}
return allOk;
- test_name: "multiply_neg_and_neg"
requires: ["to_array", "set1"]
requires: ["set1", "storeu"]
includes: []
implementation: |
using T = typename Vec::base_type;
using reg_t = typename Vec::register_type;
if(std::is_signed<T>::value){
reg_t vec = set1<Vec>(-1);
auto const vec_result = to_array<Vec>(mul<Vec>(vec,vec));
bool allOk = true;
for(std::size_t i = 0; i < Vec::vector_element_count(); i++){
allOk = (vec_result[i] == 1);
}
return allOk;
}else{
if(std::is_unsigned<T>::value){
return true;
}else{
testing::test_memory_helper_t<Vec> test_helper{ Vec::vector_element_count(), false };
auto reference_result_ptr = test_helper.result_ref();
auto test_result_ptr = test_helper.result_target();
storeu<Vec>(reference_result_ptr, set1<Vec>(1));
auto vec = set1<Vec>(-1);
storeu<Vec>(test_result_ptr, mul<Vec>(vec,vec));
test_helper.synchronize();
return test_helper.validate();
}
- test_name: "multiply_neg_and_pos"
requires: ["to_array", "set1"]
requires: ["set1", "storeu"]
includes: []
implementation: |
using T = typename Vec::base_type;
using reg_t = typename Vec::register_type;
if(std::is_signed<T>::value){
reg_t vec_a = set1<Vec>(-1);
reg_t vec_b = set1<Vec>(1);
auto const vec_result = to_array<Vec>(mul<Vec>(vec_a,vec_b));
bool allOk = true;
for(std::size_t i = 0; i < Vec::vector_element_count(); i++){
allOk = (vec_result[i] == -1);
}
return allOk;
}else{
if(std::is_unsigned<T>::value){
return true;
}else{
testing::test_memory_helper_t<Vec> test_helper{ Vec::vector_element_count(), false };
auto reference_result_ptr = test_helper.result_ref();
auto test_result_ptr = test_helper.result_target();
auto neg = set1<Vec>(-1);
auto pos = set1<Vec>(1);
storeu<Vec>(reference_result_ptr, neg);
storeu<Vec>(test_result_ptr, mul<Vec>(pos, neg));
test_helper.synchronize();
return test_helper.validate();
}
definitions:
#INTEL - AVX512
Expand Down
13 changes: 6 additions & 7 deletions primitive_data/primitives/compare.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -484,21 +484,20 @@ testing:
includes: ["<cstddef>"]
implementation: |
using T = typename Vec::base_type;
std::size_t element_count = 1024;
testing::test_memory_helper_t<Vec> test_helper{element_count, 1, false, testing::alternate_init_no_zero<T>};
testing::test_memory_helper_t<Vec> test_helper{ 1, false };
auto reference_result_ptr = test_helper.result_ref();
auto test_result_ptr = test_helper.result_target();
auto vec = set1<Vec>(0);
*reference_result_ptr = Vec::vector_element_count();
auto result_mask = between_inclusive<Vec>(vec, vec, vec);
auto result_imask = to_integral<Vec>(result_mask);
size_t matches = 0;
for ( size_t i = 0; i < Vec::vector_element_count(); ++i ) {
if(((result_imask >> i) & 0b1) == 1) {
matches += 1;
}
for ( size_t i = 0; i < Vec::vector_element_count(); ++i ) {
if(((result_imask >> i) & 0b1) == 1) {
matches += 1;
}
}
*test_result_ptr = matches;
*reference_result_ptr = Vec::vector_element_count();
test_helper.synchronize();
return test_helper.validate();
definitions:
Expand Down
15 changes: 5 additions & 10 deletions primitive_data/primitives/ls.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -523,18 +523,13 @@ returns:
description: "Vector containing 0 in all lanes."
testing:
- test_name: "default"
requires: ["set1"]
requires: ["storeu", "set1"]
implementation: |
using T = typename Vec::base_type;
testing::test_memory_helper_t<Vec> test_helper{Vec::vector_element_count(), Vec::vector_element_count(), false};
bool allOk = true;
testing::test_memory_helper_t<Vec> test_helper{ Vec::vector_element_count(), false };
auto reference_result_ptr = test_helper.result_ref();
auto test_result_ptr = test_helper.result_target();
auto vec = set_zero<Vec>();
storeu<Vec>(test_result_ptr, vec);
for (size_t i = 0; i < Vec::vector_element_count(); ++i) {
reference_result_ptr[i] = (T)0;
}
storeu<Vec>(reference_result_ptr, set1<Vec>(0));
storeu<Vec>(test_result_ptr, set_zero<Vec>());
test_helper.synchronize();
return test_helper.validate();
definitions:
Expand Down Expand Up @@ -675,7 +670,7 @@ testing:
using T = typename Vec::base_type;
std::size_t count = Vec::vector_element_count();
testing::test_memory_helper_t<Vec> test_helper{1, count, false};
testing::test_memory_helper_t<Vec> test_helper{count, false};
auto reference_result_ptr = test_helper.result_ref();
auto test_result_ptr = test_helper.result_target();
Expand Down
69 changes: 31 additions & 38 deletions primitive_data/primitives/mask.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -299,37 +299,24 @@ testing:
implementation: |
using T = typename Vec::base_type;
typename Vec::mask_type mask = to_mask<Vec>(integral_all_true<Vec>());
bool allOk = true;
auto vec = to_vector<Vec>(mask);
auto vec_arr = to_array<Vec>(vec);
if constexpr (std::is_integral<T>::value){
for(int i = 0; i < Vec::vector_element_count(); i++){
T temp = vec_arr[i];
for(int j = 0; j < sizeof(T)*8; j++){
allOk &= ((temp >> j) & 0b1);
}
}
}else if constexpr (std::is_same<T, double>::value){
for(int i = 0; i < Vec::vector_element_count(); i++){
T temp = vec_arr[i];
allOk &= (static_cast<int64_t>(temp) == std::numeric_limits<int64_t>::min());
}
}else{
for(int i = 0; i < Vec::vector_element_count(); i++){
T temp = vec_arr[i];
allOk &= (static_cast<int32_t>(temp) == std::numeric_limits<int32_t>::min());
}
}
return allOk;
testing::test_memory_helper_t<Vec> test_helper{Vec::vector_element_count(), false};
auto reference_result_ptr = test_helper.result_ref();
auto test_result_ptr = test_helper.result_target();
storeu<Vec>(reference_result_ptr, inv<Vec>(set_zero<Vec>()));
storeu<Vec>(test_result_ptr, vec);
test_helper.synchronize();
return test_helper.validate();
- test_name: "no_mask"
requires: ["to_mask", "integral_all_false", "storeu", "set_zero"]
implementation: |
using T = typename Vec::base_type;
typename Vec::mask_type mask = to_mask<Vec>(integral_all_false<Vec>());
auto vec = to_vector<Vec>(mask);
testing::test_memory_helper_t<Vec> test_helper{0, Vec::vector_element_count(), false};
testing::test_memory_helper_t<Vec> test_helper{Vec::vector_element_count(), false};
auto reference_result_ptr = test_helper.result_ref();
auto test_result_ptr = test_helper.result_target();
Expand Down Expand Up @@ -917,34 +904,40 @@ returns:
description: "Numer of bits set to 1."
testing:
- test_name: "default"
includes: ["<random>", "<limits>"]
implementation: |
using mask_t = typename Vec::imask_type;
std::size_t element_count = 1024;
// Generate random Mask
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<mask_t> dist(std::numeric_limits<mask_t>::min(), std::numeric_limits<mask_t>::max());
std::size_t mask_count = 1024;
testing::test_memory_helper_t<Vec> test_helper{ 1, false };
auto reference_result_ptr = test_helper.result_ref();
auto test_result_ptr = test_helper.result_target();
bool allOk = true;
if constexpr (std::is_same<bool, typename Vec::mask_type>::value){
for(std::size_t i = 0; i < element_count; i++){
mask_t mask = dist(gen);
auto result = mask_population_count<Vec>(mask);
allOk &= (result == (mask & 0b1));
for(std::size_t i = 0; i < mask_count; i++){
mask_t mask;
testing::rnd_init(&mask, 1);
*reference_result_ptr = (mask & 0b1);
*test_result_ptr = mask_population_count<Vec>(mask);
test_helper.synchronize();
allOk &= test_helper.validate();
}
}else{
for(std::size_t i = 0; i < element_count; i++){
mask_t mask = dist(gen);
for(std::size_t i = 0; i < mask_count; i++){
mask_t mask;
testing::rnd_init(&mask, 1);
std::size_t count = 0;
for(std::size_t j = 0; j < sizeof(mask_t)*8; j++){
if((mask >> j) & 0b1){
count++;
}
}
auto result = mask_population_count<Vec>(mask);
allOk &= (result == count);
*reference_result_ptr = count;
*test_result_ptr = mask_population_count<Vec>(mask);
test_helper.synchronize();
allOk &= test_helper.validate();
}
}
return allOk;
Expand Down
9 changes: 6 additions & 3 deletions primitive_data/primitives/misc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ testing:
implementation: |
using mask_t = typename Vec::imask_type;
std::size_t element_count = 1024;
testing::test_memory_helper_t<Vec> test_helper{element_count, Vec::vector_element_count(), false};
testing::test_memory_helper_t<Vec> test_helper{element_count, 1, false};
bool allOk = true;
auto reference_data_ptr = test_helper.data_ref();
auto reference_result_ptr = test_helper.result_ref();
Expand All @@ -192,9 +192,12 @@ testing:
bitmask |= (static_cast<mask_t>(1) << (k - i));
}
}
*reference_result_ptr = bitmask;
auto vec = loadu<Vec>(&test_data_ptr[i]);
auto mask_result = conflict_free<Vec>(integral_all_true<Vec>(), vec);
allOk &= (bitmask == mask_result);
*test_result_ptr = conflict_free<Vec>(integral_all_true<Vec>(), vec);
test_helper.synchronize();
allOk &= test_helper.validate();
}
return allOk;
definitions:
Expand Down

0 comments on commit 99986c5

Please sign in to comment.