Commit d6e1a821 authored by Po-Yen, Chen's avatar Po-Yen, Chen
Browse files

Avoid invoking (host) STL algorithms

parent 3dc20da8
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#include "ck/utility/functional2.hpp" #include "ck/utility/functional2.hpp"
#include "ck/utility/math.hpp" #include "ck/utility/math.hpp"
#include <algorithm>
#include <array> #include <array>
#include <cstddef> #include <cstddef>
#include <cstdint> #include <cstdint>
...@@ -44,24 +43,36 @@ struct get_carrier<3> ...@@ -44,24 +43,36 @@ struct get_carrier<3>
public: public:
__device__ inline carrier(value_type value) noexcept __device__ inline carrier(value_type value) noexcept
{ {
std::copy_n(reinterpret_cast<const std::byte*>(&value), bytes.size(), bytes.data()); auto from = reinterpret_cast<const std::byte*>(&value);
for(auto to = bytes.begin(); to != bytes.end(); ++to, ++from)
{
*to = *from;
}
} }
// method to trigger template substitution failure // method to trigger template substitution failure
__device__ inline carrier& operator=(const carrier& other) noexcept __device__ inline carrier& operator=(const carrier& other) noexcept
{ {
std::copy_n(other.bytes.data(), bytes.size(), bytes.data()); auto from = other.bytes.begin();
for(auto to = bytes.begin(); to != bytes.end(); ++to, ++from)
{
*to = *from;
}
return *this; return *this;
} }
__device__ inline operator value_type() const noexcept __device__ inline operator value_type() const noexcept
{ {
std::array<std::byte, sizeof(value_type)> value; std::byte result[sizeof(value_type)];
std::copy_n(bytes.data(), bytes.size(), value.data()); auto to = result;
for(auto from = bytes.begin(); from != bytes.end(); ++to, ++from)
{
*to = *from;
}
return *reinterpret_cast<const value_type*>(value.data()); return *reinterpret_cast<const value_type*>(result);
} }
}; };
}; };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment