Skip to content
Closed
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
54 changes: 28 additions & 26 deletions sycl/unittests/Extensions/DeviceGlobal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "detail/kernel_program_cache.hpp"

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

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

static sycl::unittest::PiImage 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.
PiPropertySet PropSet;
PiProperty DevGlobInfo =
MockPropertySet PropSet;
MockProperty DevGlobInfo =
makeDeviceGlobalInfo(DeviceGlobalName, sizeof(int) * 2, 0);
PropSet.insert(__SYCL_PI_PROPERTY_SET_SYCL_DEVICE_GLOBALS,
PiArray<PiProperty>{std::move(DevGlobInfo)});
Array<MockProperty>{std::move(DevGlobInfo)});

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

PiArray<PiOffloadEntry> Entries =
Array<MockOffloadEntry> Entries =
makeEmptyKernels({DeviceGlobalTestKernelName});

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

return Img;
}

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

// Call device global map initializer explicitly to mimic the integration
Expand All @@ -98,30 +99,31 @@ static sycl::unittest::PiImage generateDeviceGlobalImgScopeImage() {
DeviceGlobalImgScopeName);

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

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

PiArray<PiOffloadEntry> Entries =
Array<MockOffloadEntry> Entries =
makeEmptyKernels({DeviceGlobalImgScopeTestKernelName});

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

return Img;
}

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

Expand Down
25 changes: 13 additions & 12 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/PiImage.hpp>
#include <helpers/MockDeviceImage.hpp>
#include <helpers/PiMock.hpp>

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

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

PiPropertySet PropSet;
MockPropertySet PropSet;

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

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

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

return Img;
}

namespace {
sycl::unittest::PiImage Imgs[] = {generateMemopsImage()};
sycl::unittest::MockDeviceImage Imgs[] = {generateMemopsImage()};
sycl::unittest::PiImageArray<1> ImgArray{Imgs};

size_t LastMemopsQuery = 0;
Expand Down
16 changes: 8 additions & 8 deletions sycl/unittests/Extensions/VirtualFunctions/RuntimeLinking.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/PiImage.hpp>
#include <helpers/MockDeviceImage.hpp>
#include <helpers/PiMock.hpp>
#include <helpers/RuntimeLinkingCommon.hpp>

Expand Down Expand Up @@ -44,11 +44,11 @@ KERNEL_INFO(KernelG)
} // namespace _V1
} // namespace sycl

static sycl::unittest::PiImage
static sycl::unittest::MockDeviceImage
generateImage(std::initializer_list<std::string> KernelNames,
const std::string &VFSets, bool UsesVFSets, unsigned char Magic) {
sycl::unittest::PiPropertySet PropSet;
sycl::unittest::PiArray<sycl::unittest::PiProperty> 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 @@ -59,7 +59,7 @@ generateImage(std::initializer_list<std::string> KernelNames,
Storage.back() = '\0';
const std::string PropName =
UsesVFSets ? "uses-virtual-functions-set" : "virtual-functions-set";
sycl::unittest::PiProperty Prop(PropName, Storage,
sycl::unittest::MockProperty Prop(PropName, Storage,
PI_PROPERTY_TYPE_BYTE_ARRAY);

Props.push_back(Prop);
Expand All @@ -68,10 +68,10 @@ generateImage(std::initializer_list<std::string> KernelNames,

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

sycl::unittest::PiArray<sycl::unittest::PiOffloadEntry> Entries =
sycl::unittest::Array<sycl::unittest::MockOffloadEntry> Entries =
sycl::unittest::makeEmptyKernels(KernelNames);

sycl::unittest::PiImage Img{
sycl::unittest::MockDeviceImage Img{
PI_DEVICE_BINARY_TYPE_SPIRV, // Format
__SYCL_PI_DEVICE_BINARY_TARGET_SPIRV64, // DeviceTargetSpec
"", // Compile options
Expand Down Expand Up @@ -102,7 +102,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::PiImage 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
1 change: 0 additions & 1 deletion sycl/unittests/SYCL2020/DeviceGetInfoAspects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#include <sycl/sycl.hpp>

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

#include <gtest/gtest.h>
Expand Down
28 changes: 15 additions & 13 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/PiImage.hpp>
#include <helpers/MockDeviceImage.hpp>
#include <helpers/PiMock.hpp>

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

static sycl::unittest::PiImage
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;

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

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

PiArray<PiOffloadEntry> Entries = makeEmptyKernels(KernelNames);
Array<MockOffloadEntry> Entries = makeEmptyKernels(KernelNames);

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

return Img;
}

static sycl::unittest::PiImage 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 Down
12 changes: 6 additions & 6 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/PiImage.hpp>
#include <helpers/MockDeviceImage.hpp>
#include <helpers/PiMock.hpp>

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

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

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

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

PiArray<PiOffloadEntry> Entries = makeEmptyKernels(KernelNames);
Array<MockOffloadEntry> Entries = makeEmptyKernels(KernelNames);

PiImage Img{BinaryType, // Format
MockDeviceImage Img{BinaryType, // Format
DeviceTargetSpec,
"", // Compile options
"", // Link options
Expand All @@ -50,7 +50,7 @@ generateDefaultImage(std::initializer_list<std::string> KernelNames,
return Img;
}

static sycl::unittest::PiImage Imgs[] = {
static sycl::unittest::MockDeviceImage Imgs[] = {
generateDefaultImage({"TestKernel"}, PI_DEVICE_BINARY_TYPE_SPIRV,
__SYCL_PI_DEVICE_BINARY_TARGET_SPIRV64),
generateDefaultImage({"TestKernelExeOnly"}, PI_DEVICE_BINARY_TYPE_NATIVE,
Expand Down
24 changes: 12 additions & 12 deletions sycl/unittests/SYCL2020/KernelBundleStateFiltering.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/PiImage.hpp>
#include <helpers/MockDeviceImage.hpp>
#include <helpers/PiMock.hpp>

#include <gtest/gtest.h>
Expand All @@ -35,26 +35,26 @@ MOCK_INTEGRATION_HEADER(KernelE)
namespace {

std::set<const void *> TrackedImages;
sycl::unittest::PiImage
sycl::unittest::MockDeviceImage
generateDefaultImage(std::initializer_list<std::string> KernelNames,
pi_device_binary_type BinaryType,
const char *DeviceTargetSpec) {
using namespace sycl::unittest;

PiPropertySet PropSet;
MockPropertySet PropSet;

static unsigned char NImage = 0;
std::vector<unsigned char> Bin{NImage++};

PiArray<PiOffloadEntry> Entries = makeEmptyKernels(KernelNames);
Array<MockOffloadEntry> Entries = makeEmptyKernels(KernelNames);

PiImage 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)};
const void *BinaryPtr = Img.getBinaryPtr();
TrackedImages.insert(BinaryPtr);

Expand All @@ -69,7 +69,7 @@ generateDefaultImage(std::initializer_list<std::string> KernelNames,
// Image 5: input, KernelE
// Image 6: exe, KernelE
// Image 7: exe. KernelE
sycl::unittest::PiImage Imgs[] = {
sycl::unittest::MockDeviceImage Imgs[] = {
generateDefaultImage({"KernelA", "KernelB"}, PI_DEVICE_BINARY_TYPE_SPIRV,
__SYCL_PI_DEVICE_BINARY_TARGET_SPIRV64),
generateDefaultImage({"KernelA"}, PI_DEVICE_BINARY_TYPE_NATIVE,
Expand Down
Loading