HPX_HOST_DEVICE HPX_FORCEINLINE static T call(T t, std::size_t max_count, Stride& offset, std::true_type) { if (is_negative(offset)) { offset = Stride(negate( // NVCC seems to have a bug with std::min... max_count < std::size_t(negate(offset)) ? max_count : negate(offset) )); return T(t + offset); } // NVCC seems to have a bug with std::min... offset = Stride(max_count < std::size_t(offset) ? max_count : offset); return T(t + offset); }
HPX_HOST_DEVICE HPX_FORCEINLINE static Iter call(Iter iter, std::size_t max_count, Stride& offset, std::false_type) { // advance through the end or max number of elements // NVCC seems to have a bug with std::min... offset = Stride(max_count < std::size_t(offset) ? max_count : offset); std::advance(iter, offset); return iter; }
HPX_HOST_DEVICE HPX_FORCEINLINE static Iter call(Iter iter, std::size_t max_count, Stride& offset, std::true_type) { // advance through the end or max number of elements if (!is_negative(offset)) { // NVCC seems to have a bug with std::min... offset = Stride(max_count < std::size_t(offset) ? max_count : offset); std::advance(iter, offset); } else { offset = negate(Stride( // NVCC seems to have a bug with std::min... max_count < negate(offset) ? max_count : negate(offset) )); std::advance(iter, offset); } return iter; }
HPX_HOST_DEVICE HPX_FORCEINLINE static Iter call(Iter iter, std::size_t max_count, Stride& offset) { // anything less than a bidirectional iterator does not support // negative offsets HPX_ASSERT(!std::is_signed<Stride>::value || !is_negative(offset)); // NVCC seems to have a bug with std::min... Stride count = Stride(max_count < std::size_t(offset) ? max_count : offset); // advance through the end or max number of elements for (/**/; count != 0; (void)++iter, --count) /**/; offset -= count; return iter; }
std::shared_ptr<SL::Remote_Access_Library::Utilities::Image> SL::Remote_Access_Library::Utilities::Image::CreateImage(unsigned int h, unsigned int w, const char * data, size_t pixel_stride) { assert(pixel_stride == 3 || pixel_stride == 4); auto img = CreateImage(h, w); img->Size = h*w*img->Stride(); if (pixel_stride == 4) { memcpy(img->data(), data, img->Size); } else { auto dst = (unsigned int*)img->data(); auto src = data; for (decltype(h*w) i = 0; i < h*w; i++) { auto srcdata = *((unsigned int*)src); *dst++ = (srcdata & 0xffffff00) | 0x000000ff; src += 3; } } return img; }
inline void createTensor4dDesc(cudnnTensorDescriptor_t* desc, Size size) { createTensor4dDesc<Dtype>(desc, size, Stride(size)); }