这一行:
static_assert(
sycl::is_device_copyable<sycl::float3>::value,
"The vector types should be copyable."
);
sycl 中所有向量类型均因静态断言错误而失败。这是使用:
dpcpp -v
Intel(R) oneAPI DPC++/C++ Compiler 2022.1.0 (2022.1.0.20220316)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/intel/oneapi/compiler/2022.1.0/linux/bin-llvm
通过命令行使用
-fsycl
。
不应该将
sycl::vec
向量类型标记为设备可复制吗?
我正在编写一个 USM 管理器结构,所以我的解决方法是使用:
template <typename... Types>
constexpr bool are_all_types_device_copyable()
{
return (
(sycl::is_device_copyable<Types>::value ||
is_sycl_vec_v<Types>)&&...
);
}
哪里
is_sycl_vec
是:
template <typename>
struct is_sycl_vec : public std::false_type
{
};
template <typename dataT, int numElements>
struct is_sycl_vec<sycl::vec<dataT, numElements>> : public std::true_type
{
};
template <typename T>
constexpr bool is_sycl_vec_v = is_sycl_vec<T>::value;
你解决了吗?我的张量类中的 std::vector 不可复制。怎么改呢
class Tensor{ public: ITYPE ndims; ITYPE *dims; ITYPE totNnz; ITYPE nFibers; ITYPE *accessK; ITYPE *fbrLikeSlcInds; bool switchBC = false; // if true change matrix rand() to 1 std::vector<ITYPE> modeOrder; std::vector<ITYPE> fbrCount; ITYPE **inds; DTYPE *vals; // std::vector<vector<ITYPE>> inds; // std::vector<DTYPE> vals; std::vector<vector<ITYPE>> fbrPtr; std::vector<vector<ITYPE>> fbrIdx; std::vector<vector<ITYPE>> slcMapperBin; ITYPE *nnzPerSlice; ITYPE *fiberPerSlice; ITYPE *nnzPerFiber; ITYPE *denseSlcPtr; ITYPE *partPerNnz; ITYPE *totnnzPerPart; unordered_map<pair<ITYPE, ITYPE>, ITYPE, boost::hash<pair<ITYPE, ITYPE>>> fbrHashTbl; // map<pair<ITYPE, ITYPE>, ITYPE> fbrHashTbl; };
std::vector(对于任何 T)不是设备可复制的,因为它不是普通可复制的。因为它是用户提供的(而不是隐式定义的)。
请找到以下链接, https://registry.khronos.org/SYCL/specs/sycl-2020/html/sycl-2020.html#sec::device.copyable