Skip to content

Commit 899b91f

Browse files
committed
Implement helper function DeviceAttributesSupport to check if a device supports any number of attributes
1 parent 858da0e commit 899b91f

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

tests/catch/include/utils.hh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ inline constexpr size_t kPageSize = 4096;
2929
} // anonymous namespace
3030

3131
template <typename T>
32-
void MemcpyArrayCompare(T* const expected, T* const actual, const size_t num_elements) {
32+
void ArrayMismatch(T* const expected, T* const actual, const size_t num_elements) {
3333
const auto ret = std::mismatch(expected, expected + num_elements, actual);
3434
if (ret.first != expected + num_elements) {
3535
const auto idx = std::distance(expected, ret.first);
@@ -84,4 +84,15 @@ inline void LaunchDelayKernel(const std::chrono::milliseconds interval, const hi
8484
// Clock rate is in kHz => number of clock ticks in a millisecond
8585
HIP_CHECK(hipDeviceGetAttribute(&ticks_per_ms, hipDeviceAttributeClockRate, 0));
8686
Delay<<<1, 1, 0, stream>>>(interval.count(), ticks_per_ms);
87+
}
88+
89+
template <typename... Attributes>
90+
inline bool DeviceAttributesSupport(const int device, Attributes... attributes) {
91+
constexpr auto DeviceAttributeSupport = [](const int device,
92+
const hipDeviceAttribute_t attribute) {
93+
int value = 0;
94+
HIP_CHECK(hipDeviceGetAttribute(&value, attribute, device));
95+
return value;
96+
};
97+
return (... && DeviceAttributeSupport(device, attributes));
8798
}

0 commit comments

Comments
 (0)