Skip to content

Commit

Permalink
Merge pull request #666 from vladimirkhashev/fix_type_pack_for_atomic…
Browse files Browse the repository at this point in the history
…_ref_tests

Fix type pack creation for atomic_ref tests
  • Loading branch information
bader committed Jun 23, 2023
2 parents b931784 + d8021d8 commit 656c356
Showing 1 changed file with 30 additions and 10 deletions.
40 changes: 30 additions & 10 deletions tests/atomic_ref/atomic_ref_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,25 +97,45 @@ inline std::string get_section_name(const std::string& type_name,
* @brief Factory function for getting type_pack with fp64 type
*/
inline auto get_atomic64_types() {
static const auto types =
#if SYCL_CTS_ENABLE_FULL_CONFORMANCE
named_type_pack<long long, unsigned long long>::generate(
"long long", "unsigned long long");
// according to C++ standard the long type might to be at least 32 bits or
// wider so if the long type is greater than 4 bytes it should be included
// into the atomic 64 type pack
if constexpr (sizeof(long) == 4) {
static const auto types =
named_type_pack<long long, unsigned long long>::generate(
"long long", "unsigned long long");
return types;
} else {
static const auto types =
named_type_pack<long, unsigned long, long long,
unsigned long long>::generate("long", "unsigned long",
"long long",
"unsigned long long");
return types;
}
#else
named_type_pack<long long>::generate("long long");
return named_type_pack<long long>::generate("long long");
#endif
return types;
}

/**
* @brief Factory function for getting type_pack with all generic types
*/
inline auto get_full_conformance_type_pack() {
static const auto types =
named_type_pack<int, unsigned int, long int, unsigned long int,
float>::generate("int", "unsigned int", "long int",
"unsigned long int", "float");
return types;
// add the long type into the standard type pack if its size is 4 bytes
if constexpr (sizeof(long) > 4) {
static const auto types =
named_type_pack<int, unsigned int, float>::generate(
"int", "unsigned int", "float");
return types;
} else {
static const auto types =
named_type_pack<int, unsigned int, long int, unsigned long int,
float>::generate("int", "unsigned int", "long int",
"unsigned long int", "float");
return types;
}
}

/**
Expand Down

0 comments on commit 656c356

Please sign in to comment.