Skip to content
Open
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
5 changes: 3 additions & 2 deletions sycl/unittests/SYCL2020/KernelBundleStateFiltering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,9 @@ ur_result_t redefinedUrProgramCreate(void *pParams) {

ur_result_t redefinedUrProgramCreateWithBinary(void *pParams) {
auto params = *static_cast<ur_program_create_with_binary_params_t *>(pParams);
for (uint32_t i = 0; i < *params.pnumDevices; ++i)
redefinedUrProgramCreateCommon(*params.pppBinaries[i]);
// All numDevices entries of ppBinaries point to the same image, so only the
// first one needs to be tracked.
redefinedUrProgramCreateCommon(**params.pppBinaries);
return UR_RESULT_SUCCESS;
}

Expand Down
17 changes: 7 additions & 10 deletions sycl/unittests/helpers/MockDeviceImage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,11 +378,10 @@ inline MockProperty makeSpecConstant(std::vector<char> &ValData,
std::initializer_list<uint32_t> IDs,
std::initializer_list<uint32_t> Offsets,
std::tuple<T...> DefaultValues) {
const size_t PropByteArraySize = sizeof...(T) * sizeof(uint32_t) * 3;
const uint64_t PropByteArraySize = sizeof...(T) * sizeof(uint32_t) * 3;
std::vector<char> DescData;
DescData.resize(8 + PropByteArraySize);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would then replace this "8" with sizeof(PropByteArraySize) since it seems to be related and makes intention more obvious.

std::uninitialized_copy(&PropByteArraySize, &PropByteArraySize + 8,
DescData.data());
std::memcpy(DescData.data(), &PropByteArraySize, sizeof(PropByteArraySize));

if (ValData.empty())
ValData.resize(8); // Reserve first 8 bytes for array size.
Expand All @@ -397,8 +396,7 @@ inline MockProperty makeSpecConstant(std::vector<char> &ValData,
decltype(DefaultValues)>::type));
// Update raw data array size
uint64_t NewValSize = ValData.size();
std::uninitialized_copy(&NewValSize, &NewValSize + sizeof(uint64_t),
ValData.data());
std::memcpy(ValData.data(), &NewValSize, sizeof(NewValSize));
}

auto FillData = [PrevOffset = 0, PrevSize, &ValData, &IDs, &Offsets,
Expand Down Expand Up @@ -516,10 +514,10 @@ inline MockProperty makeAspectsProp(const std::vector<sycl::aspect> &Aspects) {
std::vector<char> ValData(BYTES_FOR_SIZE +
Aspects.size() * sizeof(sycl::aspect));
uint64_t ValDataSize = ValData.size();
std::uninitialized_copy(&ValDataSize, &ValDataSize + sizeof(uint64_t),
ValData.data());
std::memcpy(ValData.data(), &ValDataSize, sizeof(ValDataSize));
auto *AspectsPtr = reinterpret_cast<const unsigned char *>(&Aspects[0]);
std::uninitialized_copy(AspectsPtr, AspectsPtr + Aspects.size(),
std::uninitialized_copy(AspectsPtr,
AspectsPtr + Aspects.size() * sizeof(sycl::aspect),
Comment thread
uditagarwal97 marked this conversation as resolved.
ValData.data() + BYTES_FOR_SIZE);
return {"aspects", ValData, SYCL_PROPERTY_TYPE_BYTE_ARRAY};
}
Expand All @@ -528,8 +526,7 @@ inline MockProperty makeReqdWGSizeProp(const std::vector<int> &ReqdWGSize) {
const size_t BYTES_FOR_SIZE = 8;
std::vector<char> ValData(BYTES_FOR_SIZE + ReqdWGSize.size() * sizeof(int));
uint64_t ValDataSize = ValData.size();
std::uninitialized_copy(&ValDataSize, &ValDataSize + sizeof(uint64_t),
ValData.data());
std::memcpy(ValData.data(), &ValDataSize, sizeof(ValDataSize));
auto *ReqdWGSizePtr = reinterpret_cast<const unsigned char *>(&ReqdWGSize[0]);
std::uninitialized_copy(ReqdWGSizePtr,
ReqdWGSizePtr + ReqdWGSize.size() * sizeof(int),
Expand Down
Loading