Skip to content
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

[SYCL][NFC] Detach unit-tests naming from UR #14815

Draft
wants to merge 5 commits into
base: sycl
Choose a base branch
from
Draft
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
56 changes: 28 additions & 28 deletions sycl/unittests/Extensions/DeviceGlobal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "detail/kernel_program_cache.hpp"

#include <helpers/MockKernelInfo.hpp>
#include <helpers/UrImage.hpp>
#include <helpers/MockDeviceImage.hpp>
#include <helpers/UrMock.hpp>

#include <gtest/gtest.h>
Expand Down Expand Up @@ -53,37 +53,37 @@ struct KernelInfo<DeviceGlobalImgScopeTestKernel>
} // namespace _V1
} // namespace sycl

static sycl::unittest::UrImage generateDeviceGlobalImage() {
static sycl::unittest::MockDeviceImage generateDeviceGlobalImage() {
using namespace sycl::unittest;

// Call device global map initializer explicitly to mimic the integration
// header.
sycl::detail::device_global_map::add(&DeviceGlobal, DeviceGlobalName);

// Insert remaining device global info into the binary.
UrPropertySet PropSet;
UrProperty DevGlobInfo =
MockPropertySet PropSet;
MockProperty DevGlobInfo =
makeDeviceGlobalInfo(DeviceGlobalName, sizeof(int) * 2, 0);
PropSet.insert(__SYCL_PROPERTY_SET_SYCL_DEVICE_GLOBALS,
UrArray<UrProperty>{std::move(DevGlobInfo)});
Array<MockProperty>{std::move(DevGlobInfo)});

std::vector<unsigned char> Bin{10, 11, 12, 13, 14, 15}; // Random data

UrArray<UrOffloadEntry> Entries =
Array<MockOffloadEntry> Entries =
makeEmptyKernels({DeviceGlobalTestKernelName});

UrImage Img{SYCL_DEVICE_BINARY_TYPE_SPIRV, // Format
__SYCL_DEVICE_BINARY_TARGET_SPIRV64, // DeviceTargetSpec
"", // Compile options
"", // Link options
std::move(Bin),
std::move(Entries),
std::move(PropSet)};
MockDeviceImage Img{SYCL_DEVICE_BINARY_TYPE_SPIRV, // Format
__SYCL_DEVICE_BINARY_TARGET_SPIRV64, // DeviceTargetSpec
"", // Compile options
"", // Link options
std::move(Bin),
std::move(Entries),
std::move(PropSet)};

return Img;
}

static sycl::unittest::UrImage generateDeviceGlobalImgScopeImage() {
static sycl::unittest::MockDeviceImage generateDeviceGlobalImgScopeImage() {
using namespace sycl::unittest;

// Call device global map initializer explicitly to mimic the integration
Expand All @@ -92,32 +92,32 @@ static sycl::unittest::UrImage generateDeviceGlobalImgScopeImage() {
DeviceGlobalImgScopeName);

// Insert remaining device global info into the binary.
UrPropertySet PropSet;
UrProperty DevGlobInfo =
MockPropertySet PropSet;
MockProperty DevGlobInfo =
makeDeviceGlobalInfo(DeviceGlobalImgScopeName, sizeof(int) * 2, 1);
PropSet.insert(__SYCL_PROPERTY_SET_SYCL_DEVICE_GLOBALS,
UrArray<UrProperty>{std::move(DevGlobInfo)});
Array<MockProperty>{std::move(DevGlobInfo)});

std::vector<unsigned char> Bin{10, 11, 12, 13, 14, 15}; // Random data

UrArray<UrOffloadEntry> Entries =
Array<MockOffloadEntry> Entries =
makeEmptyKernels({DeviceGlobalImgScopeTestKernelName});

UrImage Img{SYCL_DEVICE_BINARY_TYPE_SPIRV, // Format
__SYCL_DEVICE_BINARY_TARGET_SPIRV64, // DeviceTargetSpec
"", // Compile options
"", // Link options
std::move(Bin),
std::move(Entries),
std::move(PropSet)};
MockDeviceImage Img{SYCL_DEVICE_BINARY_TYPE_SPIRV, // Format
__SYCL_DEVICE_BINARY_TARGET_SPIRV64, // DeviceTargetSpec
"", // Compile options
"", // Link options
std::move(Bin),
std::move(Entries),
std::move(PropSet)};

return Img;
}

namespace {
sycl::unittest::UrImage Imgs[] = {generateDeviceGlobalImage(),
generateDeviceGlobalImgScopeImage()};
sycl::unittest::UrImageArray<2> ImgArray{Imgs};
sycl::unittest::MockDeviceImage Imgs[] = {generateDeviceGlobalImage(),
generateDeviceGlobalImgScopeImage()};
sycl::unittest::MockDeviceImageArray<2> ImgArray{Imgs};

// Trackers.
thread_local DeviceGlobalElemType MockDeviceGlobalMem;
Expand Down
26 changes: 13 additions & 13 deletions sycl/unittests/Extensions/USMMemcpy2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <detail/queue_impl.hpp>

#include <helpers/MockKernelInfo.hpp>
#include <helpers/UrImage.hpp>
#include <helpers/MockDeviceImage.hpp>
#include <helpers/UrMock.hpp>

#include <gtest/gtest.h>
Expand Down Expand Up @@ -125,31 +125,31 @@ struct KernelInfo<class __usmmemcpy2d<unsigned char>>
} // namespace _V1
} // namespace sycl

static sycl::unittest::UrImage generateMemopsImage() {
static sycl::unittest::MockDeviceImage generateMemopsImage() {
using namespace sycl::unittest;

UrPropertySet PropSet;
MockPropertySet PropSet;

std::vector<unsigned char> Bin{10, 11, 12, 13, 14, 15}; // Random data

UrArray<UrOffloadEntry> Entries = makeEmptyKernels(
Array<MockOffloadEntry> Entries = makeEmptyKernels(
{USMFillHelperKernelNameLong, USMFillHelperKernelNameChar,
USMMemcpyHelperKernelNameLong, USMMemcpyHelperKernelNameChar});

UrImage Img{SYCL_DEVICE_BINARY_TYPE_SPIRV, // Format
__SYCL_DEVICE_BINARY_TARGET_SPIRV64, // DeviceTargetSpec
"", // Compile options
"", // Link options
std::move(Bin),
std::move(Entries),
std::move(PropSet)};
MockDeviceImage Img{SYCL_DEVICE_BINARY_TYPE_SPIRV, // Format
__SYCL_DEVICE_BINARY_TARGET_SPIRV64, // DeviceTargetSpec
"", // Compile options
"", // Link options
std::move(Bin),
std::move(Entries),
std::move(PropSet)};

return Img;
}

namespace {
sycl::unittest::UrImage Imgs[] = {generateMemopsImage()};
sycl::unittest::UrImageArray<1> ImgArray{Imgs};
sycl::unittest::MockDeviceImage Imgs[] = {generateMemopsImage()};
sycl::unittest::MockDeviceImageArray<1> ImgArray{Imgs};

ur_context_info_t LastMemopsQuery = UR_CONTEXT_INFO_NUM_DEVICES;

Expand Down
20 changes: 10 additions & 10 deletions sycl/unittests/Extensions/VirtualFunctions/RuntimeLinking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include <helpers/MockKernelInfo.hpp>
#include <helpers/RuntimeLinkingCommon.hpp>
#include <helpers/UrImage.hpp>
#include <helpers/MockDeviceImage.hpp>
#include <helpers/UrMock.hpp>

#include <gtest/gtest.h>
Expand Down Expand Up @@ -46,11 +46,11 @@ KERNEL_INFO(KernelG)
} // namespace _V1
} // namespace sycl

static sycl::unittest::UrImage
static sycl::unittest::MockDeviceImage
generateImage(std::initializer_list<std::string> KernelNames,
const std::string &VFSets, bool UsesVFSets, unsigned char Magic) {
sycl::unittest::UrPropertySet PropSet;
sycl::unittest::UrArray<sycl::unittest::UrProperty> Props;
sycl::unittest::MockPropertySet PropSet;
sycl::unittest::Array<sycl::unittest::MockProperty> Props;
uint64_t PropSize = VFSets.size();
std::vector<char> Storage(/* bytes for size */ 8 + PropSize +
/* null terminator */ 1);
Expand All @@ -61,18 +61,18 @@ generateImage(std::initializer_list<std::string> KernelNames,
Storage.back() = '\0';
const std::string PropName =
UsesVFSets ? "uses-virtual-functions-set" : "virtual-functions-set";
sycl::unittest::UrProperty Prop(PropName, Storage,
SYCL_PROPERTY_TYPE_BYTE_ARRAY);
sycl::unittest::MockProperty Prop(PropName, Storage,
SYCL_PROPERTY_TYPE_BYTE_ARRAY);

Props.push_back(Prop);
PropSet.insert(__SYCL_PROPERTY_SET_SYCL_VIRTUAL_FUNCTIONS, std::move(Props));

std::vector<unsigned char> Bin{Magic};

sycl::unittest::UrArray<sycl::unittest::UrOffloadEntry> Entries =
sycl::unittest::Array<sycl::unittest::MockOffloadEntry> Entries =
sycl::unittest::makeEmptyKernels(KernelNames);

sycl::unittest::UrImage Img{
sycl::unittest::MockDeviceImage Img{
SYCL_DEVICE_BINARY_TYPE_SPIRV, // Format
__SYCL_DEVICE_BINARY_TARGET_SPIRV64, // DeviceTargetSpec
"", // Compile options
Expand Down Expand Up @@ -103,7 +103,7 @@ static constexpr unsigned PROGRAM_F1 = 53;
// Device images with no entires are ignored by SYCL RT during registration.
// Therefore, we have to provide some kernel names to make the test work, even
// if we don't really have them/use them.
static sycl::unittest::UrImage Imgs[] = {
static sycl::unittest::MockDeviceImage Imgs[] = {
generateImage({"KernelA"}, "set-a", /* uses vf set */ true, PROGRAM_A),
generateImage({"DummyKernel0"}, "set-a", /* provides vf set */ false,
PROGRAM_A0),
Expand Down Expand Up @@ -131,7 +131,7 @@ static sycl::unittest::UrImage Imgs[] = {
generateImage({"KernelG"}, "set-f", /* uses vf set */ true, PROGRAM_F1)};

// Registers mock devices images in the SYCL RT
static sycl::unittest::UrImageArray<15> ImgArray{Imgs};
static sycl::unittest::MockDeviceImageArray<15> ImgArray{Imgs};

TEST(VirtualFunctions, SingleKernelUsesSingleVFSet) {
sycl::unittest::UrMock<> Mock;
Expand Down
2 changes: 1 addition & 1 deletion sycl/unittests/SYCL2020/DeviceGetInfoAspects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <sycl/sycl.hpp>

#include <helpers/UrImage.hpp>
#include <helpers/MockDeviceImage.hpp>
#include <helpers/UrMock.hpp>

#include <gtest/gtest.h>
Expand Down
29 changes: 15 additions & 14 deletions sycl/unittests/SYCL2020/IsCompatible.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <sycl/sycl.hpp>

#include <helpers/MockKernelInfo.hpp>
#include <helpers/UrImage.hpp>
#include <helpers/MockDeviceImage.hpp>
#include <helpers/UrMock.hpp>

#include <gtest/gtest.h>
Expand All @@ -22,30 +22,31 @@ MOCK_INTEGRATION_HEADER(TestKernelCPUValidReqdWGSize3D)
MOCK_INTEGRATION_HEADER(TestKernelGPU)
MOCK_INTEGRATION_HEADER(TestKernelACC)

static sycl::unittest::UrImage
static sycl::unittest::MockDeviceImage
generateDefaultImage(std::initializer_list<std::string> KernelNames,
const std::vector<sycl::aspect> &Aspects, const std::vector<int> &ReqdWGSize = {}) {
const std::vector<sycl::aspect> &Aspects,
const std::vector<int> &ReqdWGSize = {}) {
using namespace sycl::unittest;

UrPropertySet PropSet;
MockPropertySet PropSet;
addDeviceRequirementsProps(PropSet, Aspects, ReqdWGSize);

std::vector<unsigned char> Bin{0, 1, 2, 3, 4, 5}; // Random data

UrArray<UrOffloadEntry> Entries = makeEmptyKernels(KernelNames);
Array<MockOffloadEntry> Entries = makeEmptyKernels(KernelNames);

UrImage Img{SYCL_DEVICE_BINARY_TYPE_SPIRV, // Format
__SYCL_DEVICE_BINARY_TARGET_SPIRV64, // DeviceTargetSpec
"", // Compile options
"", // Link options
std::move(Bin),
std::move(Entries),
std::move(PropSet)};
MockDeviceImage Img{SYCL_DEVICE_BINARY_TYPE_SPIRV, // Format
__SYCL_DEVICE_BINARY_TARGET_SPIRV64, // DeviceTargetSpec
"", // Compile options
"", // Link options
std::move(Bin),
std::move(Entries),
std::move(PropSet)};

return Img;
}

static sycl::unittest::UrImage Imgs[7] = {
static sycl::unittest::MockDeviceImage Imgs[7] = {
// Images for validating checks based on max_work_group_size + aspects
generateDefaultImage({"TestKernelCPU"}, {sycl::aspect::cpu},
{32}), // 32 <= 256 (OK)
Expand All @@ -64,7 +65,7 @@ static sycl::unittest::UrImage Imgs[7] = {
generateDefaultImage({"TestKernelGPU"}, {sycl::aspect::gpu}),
generateDefaultImage({"TestKernelACC"}, {sycl::aspect::accelerator})};

static sycl::unittest::UrImageArray<7> ImgArray{Imgs};
static sycl::unittest::MockDeviceImageArray<7> ImgArray{Imgs};

static ur_result_t redefinedDeviceGetInfoCPU(void *pParams) {
auto params = *static_cast<ur_device_get_info_params_t *>(pParams);
Expand Down
26 changes: 13 additions & 13 deletions sycl/unittests/SYCL2020/KernelBundle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <sycl/sycl.hpp>

#include <helpers/MockKernelInfo.hpp>
#include <helpers/UrImage.hpp>
#include <helpers/MockDeviceImage.hpp>
#include <helpers/UrMock.hpp>

#include <gtest/gtest.h>
Expand All @@ -24,33 +24,33 @@ MOCK_INTEGRATION_HEADER(TestKernel)
MOCK_INTEGRATION_HEADER(TestKernelExeOnly)
MOCK_INTEGRATION_HEADER(TestKernelWithAspects)

static sycl::unittest::UrImage
static sycl::unittest::MockDeviceImage
generateDefaultImage(std::initializer_list<std::string> KernelNames,
sycl_device_binary_type BinaryType,
const char *DeviceTargetSpec,
const std::vector<sycl::aspect> &Aspects = {}) {
using namespace sycl::unittest;

UrPropertySet PropSet;
MockPropertySet PropSet;
if (!Aspects.empty())
addDeviceRequirementsProps(PropSet, Aspects);

std::vector<unsigned char> Bin{0, 1, 2, 3, 4, 5}; // Random data

UrArray<UrOffloadEntry> Entries = makeEmptyKernels(KernelNames);
Array<MockOffloadEntry> Entries = makeEmptyKernels(KernelNames);

UrImage Img{BinaryType, // Format
DeviceTargetSpec,
"", // Compile options
"", // Link options
std::move(Bin),
std::move(Entries),
std::move(PropSet)};
MockDeviceImage Img{BinaryType, // Format
DeviceTargetSpec,
"", // Compile options
"", // Link options
std::move(Bin),
std::move(Entries),
std::move(PropSet)};

return Img;
}

static sycl::unittest::UrImage Imgs[] = {
static sycl::unittest::MockDeviceImage Imgs[] = {
generateDefaultImage({"TestKernel"}, SYCL_DEVICE_BINARY_TYPE_SPIRV,
__SYCL_DEVICE_BINARY_TARGET_SPIRV64),
generateDefaultImage({"TestKernelExeOnly"}, SYCL_DEVICE_BINARY_TYPE_NATIVE,
Expand All @@ -61,7 +61,7 @@ static sycl::unittest::UrImage Imgs[] = {
generateDefaultImage(
{"TestKernelWithAspects"}, SYCL_DEVICE_BINARY_TYPE_NATIVE,
__SYCL_DEVICE_BINARY_TARGET_SPIRV64, {sycl::aspect::gpu})};
static sycl::unittest::UrImageArray<std::size(Imgs)> ImgArray{Imgs};
static sycl::unittest::MockDeviceImageArray<std::size(Imgs)> ImgArray{Imgs};

static ur_result_t redefinedDeviceGetInfoCPU(void *pParams) {
auto params = *static_cast<ur_device_get_info_params_t *>(pParams);
Expand Down
Loading
Loading