Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
145 changes: 0 additions & 145 deletions tests/common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -417,151 +417,6 @@ inline void if_constexpr(const F& f) {
}
}

/**
* @brief Tag to denote mapping of integer coordinates to real scale
*
* For example, if we make a one pixel wide image this pixel can have
* any coordinate in range [0.0 .. 1.0)
*/
namespace pixel_tag {
struct generic {};
/** @brief The low boundary of the pixel, equal to the integer one
* if representable
*/
struct lower : generic {};
/** @brief The upper boundary of the pixel, equal to the left limit
* lim(x-) where x is the low boundary for the next pixel
*/
struct upper: generic {};
};

// AdaptiveCpp and SimSYCL do not yet support images
#if !SYCL_CTS_COMPILING_WITH_ADAPTIVECPP && !SYCL_CTS_COMPILING_WITH_SIMSYCL

/**
* @brief Helps with retrieving the right access type for reading/writing
* an image
* @tparam dims Number of image dimensions
*/
template <int dims>
struct image_access;

/**
* @brief Specialization for one dimension
*/
template <>
struct image_access<1> {
using int_type = sycl::opencl::cl_int;
using float_type = sycl::opencl::cl_float;
static int_type get_int(const sycl::id<1>& i) {
return int_type(i.get(0));
}
static int_type get_int(const sycl::item<1>& i) {
return get_int(i.get_id());
}
static float_type get_float(const sycl::id<1>& i) {
return float_type(static_cast<float>(i.get(0)));
}
static float_type get_float(const sycl::item<1>& i) {
return get_float(i.get_id());
}
static float_type get_normalized(const pixel_tag::lower,
const sycl::id<1>& i,
const sycl::range<1>& r) {
return get_float(i) / static_cast<int>(r.get(0));
}
static float_type get_normalized(const pixel_tag::upper,
const sycl::id<1>& i,
const sycl::range<1>& r) {
const auto negative_inf =
-1.0f * std::numeric_limits<float_type>::infinity();
const auto next = get_normalized(pixel_tag::lower{}, 1 + i, r);

return sycl::nextafter(next, negative_inf);
}
};

/**
* @brief Specialization for two dimensions
*/
template <>
struct image_access<2> {
using int_type = sycl::cl_int2;
using float_type = sycl::cl_float2;
static int_type get_int(const sycl::id<2>& i) {
return int_type(i.get(0), i.get(1));
}
static int_type get_int(const sycl::item<2>& i) {
return get_int(i.get_id());
}
static float_type get_float(const sycl::id<2>& i) {
return float_type(static_cast<float>(i.get(0)),
static_cast<float>(i.get(1)));
}
static float_type get_float(const sycl::item<2>& i) {
return get_float(i.get_id());
}
static float_type get_normalized(const pixel_tag::lower,
const sycl::id<2>& i,
const sycl::range<2>& r) {
return float_type(
static_cast<float>(i.get(0)) / static_cast<int>(r.get(0)),
static_cast<float>(i.get(1)) / static_cast<int>(r.get(1)));
}
static float_type get_normalized(const pixel_tag::upper,
const sycl::id<2>& i,
const sycl::range<2>& r) {
const auto negative_inf = -1.0f * std::numeric_limits<float>::infinity();
const auto next = get_normalized(pixel_tag::lower{}, 1 + i, r);

return float_type(sycl::nextafter(next[0], negative_inf),
sycl::nextafter(next[1], negative_inf));
}
};

/**
* @brief Specialization for three dimensions
*/
template <>
struct image_access<3> {
using int_type = sycl::cl_int4;
using float_type = sycl::cl_float4;
static int_type get_int(const sycl::id<3>& i) {
return int_type(i.get(0), i.get(1), i.get(2), 0);
}
static int_type get_int(const sycl::item<3>& i) {
return get_int(i.get_id());
}
static float_type get_float(const sycl::id<3>& i) {
return float_type(static_cast<float>(i.get(0)),
static_cast<float>(i.get(1)),
static_cast<float>(i.get(2)), .0f);
}
static float_type get_float(const sycl::item<3>& i) {
return get_float(i.get_id());
}
static float_type get_normalized(const pixel_tag::lower,
const sycl::id<3>& i,
const sycl::range<3>& r) {
return float_type(
static_cast<float>(i.get(0)) / static_cast<int>(r.get(0)),
static_cast<float>(i.get(1)) / static_cast<int>(r.get(1)),
static_cast<float>(i.get(2)) / static_cast<int>(r.get(2)), .0f);
}
static float_type get_normalized(const pixel_tag::upper,
const sycl::id<3>& i,
const sycl::range<3>& r) {
const auto negative_inf = -1.0f * std::numeric_limits<float>::infinity();
const auto next = get_normalized(pixel_tag::lower{}, 1 + i, r);

return float_type(sycl::nextafter(next[0], negative_inf),
sycl::nextafter(next[1], negative_inf),
sycl::nextafter(next[2], negative_inf), .0f);
}
};

#endif

/**
* @brief Dummy template function to check type existence without generating warnings.
*/
Expand Down