Skip to content

[SYCL][NFC] Use common mock kernel info base in unit tests #8736

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
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
27 changes: 7 additions & 20 deletions sycl/unittests/Extensions/DeviceGlobal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "detail/context_impl.hpp"
#include "detail/kernel_program_cache.hpp"

#include <helpers/MockKernelInfo.hpp>
#include <helpers/PiImage.hpp>
#include <helpers/PiMock.hpp>

Expand Down Expand Up @@ -42,31 +43,17 @@ sycl::ext::oneapi::experimental::device_global<
namespace sycl {
__SYCL_INLINE_VER_NAMESPACE(_V1) {
namespace detail {
template <> struct KernelInfo<DeviceGlobalTestKernel> {
static constexpr unsigned getNumParams() { return 0; }
static const kernel_param_desc_t &getParamDesc(int) {
static kernel_param_desc_t Dummy;
return Dummy;
}
template <>
struct KernelInfo<DeviceGlobalTestKernel>
: public unittest::MockKernelInfoBase {
static constexpr const char *getName() { return DeviceGlobalTestKernelName; }
static constexpr bool isESIMD() { return false; }
static constexpr bool callsThisItem() { return false; }
static constexpr bool callsAnyThisFreeFunction() { return false; }
static constexpr int64_t getKernelSize() { return 1; }
};
template <> struct KernelInfo<DeviceGlobalImgScopeTestKernel> {
static constexpr unsigned getNumParams() { return 0; }
static const kernel_param_desc_t &getParamDesc(int) {
static kernel_param_desc_t Dummy;
return Dummy;
}
template <>
struct KernelInfo<DeviceGlobalImgScopeTestKernel>
: public unittest::MockKernelInfoBase {
static constexpr const char *getName() {
return DeviceGlobalImgScopeTestKernelName;
}
static constexpr bool isESIMD() { return false; }
static constexpr bool callsThisItem() { return false; }
static constexpr bool callsAnyThisFreeFunction() { return false; }
static constexpr int64_t getKernelSize() { return 1; }
};
} // namespace detail
} // __SYCL_INLINE_VER_NAMESPACE(_V1)
Expand Down
29 changes: 13 additions & 16 deletions sycl/unittests/Extensions/USMMemcpy2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <detail/queue_impl.hpp>

#include <helpers/MockKernelInfo.hpp>
#include <helpers/PiImage.hpp>
#include <helpers/PiMock.hpp>

Expand All @@ -23,7 +24,9 @@ constexpr const char *USMMemcpyHelperKernelNameChar = "__usmmemcpy2d_char";
namespace sycl {
__SYCL_INLINE_VER_NAMESPACE(_V1) {
namespace detail {
template <> struct KernelInfo<class __usmfill2d<long>> {
template <>
struct KernelInfo<class __usmfill2d<long>>
: public unittest::MockKernelInfoBase {
static constexpr const char *getName() { return USMFillHelperKernelNameLong; }
static constexpr unsigned getNumParams() { return 7; }
static const kernel_param_desc_t &getParamDesc(int Idx) {
Expand All @@ -39,15 +42,14 @@ template <> struct KernelInfo<class __usmfill2d<long>> {
};
return DummySignature[Idx];
}
static constexpr bool isESIMD() { return false; }
static constexpr bool callsThisItem() { return false; }
static constexpr bool callsAnyThisFreeFunction() { return false; }
static constexpr int64_t getKernelSize() {
return 2 * sizeof(void *) + 2 * sizeof(sycl::id<2>) + 3 * sizeof(size_t);
}
};

template <> struct KernelInfo<class __usmfill2d<unsigned char>> {
template <>
struct KernelInfo<class __usmfill2d<unsigned char>>
: public unittest::MockKernelInfoBase {
static constexpr const char *getName() { return USMFillHelperKernelNameChar; }
static constexpr unsigned getNumParams() { return 7; }
static const kernel_param_desc_t &getParamDesc(int Idx) {
Expand All @@ -63,15 +65,14 @@ template <> struct KernelInfo<class __usmfill2d<unsigned char>> {
};
return DummySignature[Idx];
}
static constexpr bool isESIMD() { return false; }
static constexpr bool callsThisItem() { return false; }
static constexpr bool callsAnyThisFreeFunction() { return false; }
static constexpr int64_t getKernelSize() {
return 2 * sizeof(void *) + 2 * sizeof(sycl::id<2>) + 3 * sizeof(size_t);
}
};

template <> struct KernelInfo<class __usmmemcpy2d<long>> {
template <>
struct KernelInfo<class __usmmemcpy2d<long>>
: public unittest::MockKernelInfoBase {
static constexpr const char *getName() {
return USMMemcpyHelperKernelNameLong;
}
Expand All @@ -90,15 +91,14 @@ template <> struct KernelInfo<class __usmmemcpy2d<long>> {
};
return DummySignature[Idx];
}
static constexpr bool isESIMD() { return false; }
static constexpr bool callsThisItem() { return false; }
static constexpr bool callsAnyThisFreeFunction() { return false; }
static constexpr int64_t getKernelSize() {
return 2 * sizeof(void *) + 2 * sizeof(sycl::id<2>) + 4 * sizeof(size_t);
}
};

template <> struct KernelInfo<class __usmmemcpy2d<unsigned char>> {
template <>
struct KernelInfo<class __usmmemcpy2d<unsigned char>>
: public unittest::MockKernelInfoBase {
static constexpr const char *getName() {
return USMMemcpyHelperKernelNameChar;
}
Expand All @@ -117,9 +117,6 @@ template <> struct KernelInfo<class __usmmemcpy2d<unsigned char>> {
};
return DummySignature[Idx];
}
static constexpr bool isESIMD() { return false; }
static constexpr bool callsThisItem() { return false; }
static constexpr bool callsAnyThisFreeFunction() { return false; }
static constexpr int64_t getKernelSize() {
return 2 * sizeof(void *) + 2 * sizeof(sycl::id<2>) + 4 * sizeof(size_t);
}
Expand Down
135 changes: 23 additions & 112 deletions sycl/unittests/SYCL2020/IsCompatible.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <sycl/sycl.hpp>

#include <helpers/MockKernelInfo.hpp>
#include <helpers/PiImage.hpp>
#include <helpers/PiMock.hpp>

Expand All @@ -16,141 +17,51 @@ class TestKernelACC;
namespace sycl {
__SYCL_INLINE_VER_NAMESPACE(_V1) {
namespace detail {
template <> struct KernelInfo<TestKernelCPU> {
static constexpr unsigned getNumParams() { return 0; }
static const kernel_param_desc_t &getParamDesc(int) {
static kernel_param_desc_t Dummy;
return Dummy;
}
template <>
struct KernelInfo<TestKernelCPU> : public unittest::MockKernelInfoBase {
static constexpr const char *getName() { return "TestKernelCPU"; }
static constexpr bool isESIMD() { return false; }
static constexpr bool callsThisItem() { return false; }
static constexpr bool callsAnyThisFreeFunction() { return false; }
static constexpr int64_t getKernelSize() { return 1; }
};

} // namespace detail
} // __SYCL_INLINE_VER_NAMESPACE(_V1)
} // namespace sycl

namespace sycl {
__SYCL_INLINE_VER_NAMESPACE(_V1) {
namespace detail {
template <> struct KernelInfo<TestKernelCPUInvalidReqdWGSize1D> {
static constexpr unsigned getNumParams() { return 0; }
static const kernel_param_desc_t &getParamDesc(int) {
static kernel_param_desc_t Dummy;
return Dummy;
template <>
struct KernelInfo<TestKernelCPUInvalidReqdWGSize1D>
: public unittest::MockKernelInfoBase {
static constexpr const char *getName() {
return "TestKernelCPUInvalidReqdWGSize1D";
}
static constexpr const char *getName() { return "TestKernelCPUInvalidReqdWGSize1D"; }
static constexpr bool isESIMD() { return false; }
static constexpr bool callsThisItem() { return false; }
static constexpr bool callsAnyThisFreeFunction() { return false; }
static constexpr int64_t getKernelSize() { return 1; }
};

} // namespace detail
} // __SYCL_INLINE_VER_NAMESPACE(_V1)
} // namespace sycl

namespace sycl {
__SYCL_INLINE_VER_NAMESPACE(_V1) {
namespace detail {
template <> struct KernelInfo<TestKernelCPUInvalidReqdWGSize2D> {
static constexpr unsigned getNumParams() { return 0; }
static const kernel_param_desc_t &getParamDesc(int) {
static kernel_param_desc_t Dummy;
return Dummy;
template <>
struct KernelInfo<TestKernelCPUInvalidReqdWGSize2D>
: public unittest::MockKernelInfoBase {
static constexpr const char *getName() {
return "TestKernelCPUInvalidReqdWGSize2D";
}
static constexpr const char *getName() { return "TestKernelCPUInvalidReqdWGSize2D"; }
static constexpr bool isESIMD() { return false; }
static constexpr bool callsThisItem() { return false; }
static constexpr bool callsAnyThisFreeFunction() { return false; }
static constexpr int64_t getKernelSize() { return 1; }
};

} // namespace detail
} // __SYCL_INLINE_VER_NAMESPACE(_V1)
} // namespace sycl

namespace sycl {
__SYCL_INLINE_VER_NAMESPACE(_V1) {
namespace detail {
template <> struct KernelInfo<TestKernelCPUInvalidReqdWGSize3D> {
static constexpr unsigned getNumParams() { return 0; }
static const kernel_param_desc_t &getParamDesc(int) {
static kernel_param_desc_t Dummy;
return Dummy;
}
template <>
struct KernelInfo<TestKernelCPUInvalidReqdWGSize3D>
: public unittest::MockKernelInfoBase {
static constexpr const char *getName() {
return "TestKernelCPUInvalidReqdWGSize3D";
}
static constexpr bool isESIMD() { return false; }
static constexpr bool callsThisItem() { return false; }
static constexpr bool callsAnyThisFreeFunction() { return false; }
static constexpr int64_t getKernelSize() { return 1; }
};

} // namespace detail
} // __SYCL_INLINE_VER_NAMESPACE(_V1)
} // namespace sycl

namespace sycl {
__SYCL_INLINE_VER_NAMESPACE(_V1) {
namespace detail {
template <> struct KernelInfo<TestKernelCPUValidReqdWGSize3D> {
static constexpr unsigned getNumParams() { return 0; }
static const kernel_param_desc_t &getParamDesc(int) {
static kernel_param_desc_t Dummy;
return Dummy;
}
template <>
struct KernelInfo<TestKernelCPUValidReqdWGSize3D>
: public unittest::MockKernelInfoBase {
static constexpr const char *getName() {
return "TestKernelCPUValidReqdWGSize3D";
}
static constexpr bool isESIMD() { return false; }
static constexpr bool callsThisItem() { return false; }
static constexpr bool callsAnyThisFreeFunction() { return false; }
static constexpr int64_t getKernelSize() { return 1; }
};

} // namespace detail
} // __SYCL_INLINE_VER_NAMESPACE(_V1)
} // namespace sycl

namespace sycl {
__SYCL_INLINE_VER_NAMESPACE(_V1) {
namespace detail {
template <> struct KernelInfo<TestKernelGPU> {
static constexpr unsigned getNumParams() { return 0; }
static const kernel_param_desc_t &getParamDesc(int) {
static kernel_param_desc_t Dummy;
return Dummy;
}
template <>
struct KernelInfo<TestKernelGPU> : public unittest::MockKernelInfoBase {
static constexpr const char *getName() { return "TestKernelGPU"; }
static constexpr bool isESIMD() { return false; }
static constexpr bool callsThisItem() { return false; }
static constexpr bool callsAnyThisFreeFunction() { return false; }
static constexpr int64_t getKernelSize() { return 1; }
};

} // namespace detail
} // __SYCL_INLINE_VER_NAMESPACE(_V1)
} // namespace sycl

namespace sycl {
__SYCL_INLINE_VER_NAMESPACE(_V1) {
namespace detail {
template <> struct KernelInfo<TestKernelACC> {
static constexpr unsigned getNumParams() { return 0; }
static const kernel_param_desc_t &getParamDesc(int) {
static kernel_param_desc_t Dummy;
return Dummy;
}
template <>
struct KernelInfo<TestKernelACC> : public unittest::MockKernelInfoBase {
static constexpr const char *getName() { return "TestKernelACC"; }
static constexpr bool isESIMD() { return false; }
static constexpr bool callsThisItem() { return false; }
static constexpr bool callsAnyThisFreeFunction() { return false; }
static constexpr int64_t getKernelSize() { return 1; }
};

} // namespace detail
Expand Down
37 changes: 7 additions & 30 deletions sycl/unittests/SYCL2020/KernelBundle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <detail/kernel_bundle_impl.hpp>
#include <sycl/sycl.hpp>

#include <helpers/MockKernelInfo.hpp>
#include <helpers/PiImage.hpp>
#include <helpers/PiMock.hpp>

Expand All @@ -22,43 +23,19 @@ class TestKernelWithAspects;
namespace sycl {
__SYCL_INLINE_VER_NAMESPACE(_V1) {
namespace detail {
template <> struct KernelInfo<TestKernel> {
static constexpr unsigned getNumParams() { return 0; }
static const kernel_param_desc_t &getParamDesc(int) {
static kernel_param_desc_t Dummy;
return Dummy;
}
template <>
struct KernelInfo<TestKernel> : public unittest::MockKernelInfoBase {
static constexpr const char *getName() { return "TestKernel"; }
static constexpr bool isESIMD() { return false; }
static constexpr bool callsThisItem() { return false; }
static constexpr bool callsAnyThisFreeFunction() { return false; }
static constexpr int64_t getKernelSize() { return 1; }
};

template <> struct KernelInfo<TestKernelExeOnly> {
static constexpr unsigned getNumParams() { return 0; }
static const kernel_param_desc_t &getParamDesc(int) {
static kernel_param_desc_t Dummy;
return Dummy;
}
template <>
struct KernelInfo<TestKernelExeOnly> : public unittest::MockKernelInfoBase {
static constexpr const char *getName() { return "TestKernelExeOnly"; }
static constexpr bool isESIMD() { return false; }
static constexpr bool callsThisItem() { return false; }
static constexpr bool callsAnyThisFreeFunction() { return false; }
static constexpr int64_t getKernelSize() { return 1; }
};

template <> struct KernelInfo<TestKernelWithAspects> {
static constexpr unsigned getNumParams() { return 0; }
static const kernel_param_desc_t &getParamDesc(int) {
static kernel_param_desc_t Dummy;
return Dummy;
}
template <>
struct KernelInfo<TestKernelWithAspects> : public unittest::MockKernelInfoBase {
static constexpr const char *getName() { return "TestKernelWithAspects"; }
static constexpr bool isESIMD() { return false; }
static constexpr bool callsThisItem() { return false; }
static constexpr bool callsAnyThisFreeFunction() { return false; }
static constexpr int64_t getKernelSize() { return 1; }
};

} // namespace detail
Expand Down
Loading