diff --git a/test/stdgpu/unordered_map.cu b/test/stdgpu/unordered_map.cu index 979f0f2e1..506326a2a 100644 --- a/test/stdgpu/unordered_map.cu +++ b/test/stdgpu/unordered_map.cu @@ -20,87 +20,85 @@ #include -namespace + +struct dummy { - struct dummy - { - // no data in dummy - }; + // no data in dummy +}; - struct vec3int16 - { - vec3int16() = default; - - STDGPU_HOST_DEVICE - vec3int16(const std::int16_t x, - const std::int16_t y, - const std::int16_t z) - : x(x), - y(y), - z(z) - { - - } - - std::int16_t x = 0; - std::int16_t y = 0; - std::int16_t z = 0; - }; - - STDGPU_HOST_DEVICE bool - operator==(const vec3int16& lhs, - const vec3int16& rhs) +struct vec3int16 +{ + vec3int16() = default; + + STDGPU_HOST_DEVICE + vec3int16(const std::int16_t x, + const std::int16_t y, + const std::int16_t z) + : x(x), + y(y), + z(z) { - return lhs.x == rhs.x - && lhs.y == rhs.y - && lhs.z == rhs.z; + } - struct less - { - inline STDGPU_HOST_DEVICE bool - operator()(const vec3int16& lhs, - const vec3int16& rhs) const - { - if (lhs.x < rhs.x) return true; - if (lhs.x > rhs.x) return false; + std::int16_t x = 0; + std::int16_t y = 0; + std::int16_t z = 0; +}; - if (lhs.y < rhs.y) return true; - if (lhs.y > rhs.y) return false; +inline STDGPU_HOST_DEVICE bool +operator==(const vec3int16& lhs, + const vec3int16& rhs) +{ + return lhs.x == rhs.x + && lhs.y == rhs.y + && lhs.z == rhs.z; +} - if (lhs.z < rhs.z) return true; - if (lhs.z > rhs.z) return false; +struct less +{ + inline STDGPU_HOST_DEVICE bool + operator()(const vec3int16& lhs, + const vec3int16& rhs) const + { + if (lhs.x < rhs.x) return true; + if (lhs.x > rhs.x) return false; - return true; - } - }; + if (lhs.y < rhs.y) return true; + if (lhs.y > rhs.y) return false; + if (lhs.z < rhs.z) return true; + if (lhs.z > rhs.z) return false; - struct hash - { - inline STDGPU_HOST_DEVICE std::size_t - operator()(const vec3int16& key) const - { - return (static_cast(key.x) * static_cast(73856093u)) - ^ (static_cast(key.y) * static_cast(19349669u)) - ^ (static_cast(key.z) * static_cast(83492791u)); - } - }; - - - inline STDGPU_HOST_DEVICE stdgpu::unordered_map::value_type - key_to_value(const vec3int16& key) - { - return stdgpu::unordered_map::value_type(key, dummy()); + return true; } +}; - inline STDGPU_HOST_DEVICE vec3int16 - value_to_key(const stdgpu::unordered_map::value_type& value) +struct hash +{ + inline STDGPU_HOST_DEVICE std::size_t + operator()(const vec3int16& key) const { - return value.first; + return (static_cast(key.x) * static_cast(73856093u)) + ^ (static_cast(key.y) * static_cast(19349669u)) + ^ (static_cast(key.z) * static_cast(83492791u)); } +}; + + +inline STDGPU_HOST_DEVICE stdgpu::unordered_map::value_type +key_to_value(const vec3int16& key) +{ + return stdgpu::unordered_map::value_type(key, dummy()); +} + + +inline STDGPU_HOST_DEVICE vec3int16 +value_to_key(const stdgpu::unordered_map::value_type& value) +{ + return value.first; } diff --git a/test/stdgpu/unordered_set.cu b/test/stdgpu/unordered_set.cu index ea7528b00..18acc3df1 100644 --- a/test/stdgpu/unordered_set.cu +++ b/test/stdgpu/unordered_set.cu @@ -20,83 +20,81 @@ #include -namespace + +struct vec3int16 { - struct vec3int16 + vec3int16() = default; + + STDGPU_HOST_DEVICE + vec3int16(const std::int16_t x, + const std::int16_t y, + const std::int16_t z) + : x(x), + y(y), + z(z) { - vec3int16() = default; - - STDGPU_HOST_DEVICE - vec3int16(const std::int16_t x, - const std::int16_t y, - const std::int16_t z) - : x(x), - y(y), - z(z) - { - } + } - std::int16_t x = 0; - std::int16_t y = 0; - std::int16_t z = 0; - }; + std::int16_t x = 0; + std::int16_t y = 0; + std::int16_t z = 0; +}; - STDGPU_HOST_DEVICE bool - operator==(const vec3int16& lhs, - const vec3int16& rhs) - { - return lhs.x == rhs.x - && lhs.y == rhs.y - && lhs.z == rhs.z; - } +inline STDGPU_HOST_DEVICE bool +operator==(const vec3int16& lhs, + const vec3int16& rhs) +{ + return lhs.x == rhs.x + && lhs.y == rhs.y + && lhs.z == rhs.z; +} - struct less +struct less +{ + inline STDGPU_HOST_DEVICE bool + operator()(const vec3int16& lhs, + const vec3int16& rhs) const { - inline STDGPU_HOST_DEVICE bool - operator()(const vec3int16& lhs, - const vec3int16& rhs) const - { - if (lhs.x < rhs.x) return true; - if (lhs.x > rhs.x) return false; + if (lhs.x < rhs.x) return true; + if (lhs.x > rhs.x) return false; - if (lhs.y < rhs.y) return true; - if (lhs.y > rhs.y) return false; + if (lhs.y < rhs.y) return true; + if (lhs.y > rhs.y) return false; - if (lhs.z < rhs.z) return true; - if (lhs.z > rhs.z) return false; + if (lhs.z < rhs.z) return true; + if (lhs.z > rhs.z) return false; - return true; - } - }; + return true; + } +}; - struct hash - { - inline STDGPU_HOST_DEVICE std::size_t - operator()(const vec3int16& key) const - { - return (static_cast(key.x) * static_cast(73856093u)) - ^ (static_cast(key.y) * static_cast(19349669u)) - ^ (static_cast(key.z) * static_cast(83492791u)); - } - }; - - - inline STDGPU_HOST_DEVICE vec3int16 - key_to_value(const vec3int16& key) +struct hash +{ + inline STDGPU_HOST_DEVICE std::size_t + operator()(const vec3int16& key) const { - return key; + return (static_cast(key.x) * static_cast(73856093u)) + ^ (static_cast(key.y) * static_cast(19349669u)) + ^ (static_cast(key.z) * static_cast(83492791u)); } +}; - inline STDGPU_HOST_DEVICE vec3int16 - value_to_key(const vec3int16& key) - { - return key; - } +inline STDGPU_HOST_DEVICE vec3int16 +key_to_value(const vec3int16& key) +{ + return key; +} + + +inline STDGPU_HOST_DEVICE vec3int16 +value_to_key(const vec3int16& key) +{ + return key; }