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
2 changes: 1 addition & 1 deletion sycl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ set(SYCL_MINOR_VERSION 7)
set(SYCL_PATCH_VERSION 0)
# Don't forget to re-enable sycl_symbols_windows.dump once we leave ABI-breaking
# window!
set(SYCL_DEV_ABI_VERSION 16)
set(SYCL_DEV_ABI_VERSION 17)
if (SYCL_ADD_DEV_VERSION_POSTFIX)
set(SYCL_VERSION_POSTFIX "-${SYCL_DEV_ABI_VERSION}")
endif()
Expand Down
85 changes: 49 additions & 36 deletions sycl/include/sycl/detail/pi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,9 @@ class DeviceBinaryImage {
friend class DeviceBinaryImage;
bool isAvailable() const { return !(Begin == nullptr); }

private:
PropertyRange() : Begin(nullptr), End(nullptr) {}

private:
// Searches for a property set with given name and constructs a
// PropertyRange spanning all its elements. If property set is not found,
// the range will span zero elements.
Expand All @@ -294,8 +295,8 @@ class DeviceBinaryImage {
};

public:
DeviceBinaryImage(pi_device_binary Bin) { init(Bin); }
DeviceBinaryImage() : Bin(nullptr){};
DeviceBinaryImage(pi_device_binary Bin);
DeviceBinaryImage();

virtual void print() const;
virtual void dump(std::ostream &Out) const;
Expand Down Expand Up @@ -348,40 +349,29 @@ class DeviceBinaryImage {
/// And for an interger specialization constant, the list of tuples will look
/// like:
/// { ID5, 0, 4 }
const PropertyRange &getSpecConstants() const { return SpecConstIDMap; }
const PropertyRange getSpecConstantsDefaultValues() const {
// We can't have this variable as a class member, since it would break
// the ABI backwards compatibility.
DeviceBinaryImage::PropertyRange SpecConstDefaultValuesMap;
SpecConstDefaultValuesMap.init(
Bin, __SYCL_PI_PROPERTY_SET_SPEC_CONST_DEFAULT_VALUES_MAP);
return SpecConstDefaultValuesMap;
const PropertyRange &getSpecConstants() const {
return getBinProperty(PropertyOffsetID::SpecConstIDMap);
}
const PropertyRange &getSpecConstantsDefaultValues() const {
return getBinProperty(PropertyOffsetID::SpecConstDefaultValuesMap);
}
const PropertyRange &getDeviceLibReqMask() const {
return getBinProperty(PropertyOffsetID::DeviceLibReqMask);
}
const PropertyRange &getDeviceLibReqMask() const { return DeviceLibReqMask; }
const PropertyRange &getKernelParamOptInfo() const {
return KernelParamOptInfo;
return getBinProperty(PropertyOffsetID::KernelParamOptInfo);
}
const PropertyRange &getAssertUsed() const {
return getBinProperty(PropertyOffsetID::AssertUsed);
}
const PropertyRange getAssertUsed() const {
// We can't have this variable as a class member, since it would break
// the ABI backwards compatibility.
PropertyRange AssertUsed;
AssertUsed.init(Bin, __SYCL_PI_PROPERTY_SET_SYCL_ASSERT_USED);
return AssertUsed;
const PropertyRange &getProgramMetadata() const {
return getBinProperty(PropertyOffsetID::ProgramMetadata);
}
const PropertyRange &getProgramMetadata() const { return ProgramMetadata; }
const PropertyRange getExportedSymbols() const {
// We can't have this variable as a class member, since it would break
// the ABI backwards compatibility.
DeviceBinaryImage::PropertyRange ExportedSymbols;
ExportedSymbols.init(Bin, __SYCL_PI_PROPERTY_SET_SYCL_EXPORTED_SYMBOLS);
return ExportedSymbols;
const PropertyRange &getExportedSymbols() const {
return getBinProperty(PropertyOffsetID::ExportedSymbols);
}
const PropertyRange getDeviceGlobals() const {
// We can't have this variable as a class member, since it would break
// the ABI backwards compatibility.
DeviceBinaryImage::PropertyRange DeviceGlobals;
DeviceGlobals.init(Bin, __SYCL_PI_PROPERTY_SET_SYCL_DEVICE_GLOBALS);
return DeviceGlobals;
const PropertyRange &getDeviceGlobals() const {
return getBinProperty(PropertyOffsetID::DeviceGlobals);
}
virtual ~DeviceBinaryImage() {}

Expand All @@ -391,10 +381,33 @@ class DeviceBinaryImage {

pi_device_binary Bin;
pi::PiDeviceBinaryType Format = PI_DEVICE_BINARY_TYPE_NONE;
DeviceBinaryImage::PropertyRange SpecConstIDMap;
DeviceBinaryImage::PropertyRange DeviceLibReqMask;
DeviceBinaryImage::PropertyRange KernelParamOptInfo;
DeviceBinaryImage::PropertyRange ProgramMetadata;

enum class PropertyOffsetID : uint16_t {
SpecConstIDMap = 0,
SpecConstDefaultValuesMap = 1,
DeviceLibReqMask = 2,
KernelParamOptInfo = 3,
AssertUsed = 4,
ProgramMetadata = 5,
ExportedSymbols = 6,
DeviceGlobals = 7,
// New property offsets must be added before PropertyOffsetIDSize and after
// all others.
PropertyOffsetIDSize = 8
};

const PropertyRange &getBinProperty(PropertyOffsetID Offset) const {
return BinProperties[static_cast<size_t>(Offset)];
}

PropertyRange &getBinProperty(PropertyOffsetID Offset) {
return BinProperties[static_cast<size_t>(Offset)];
}

// Contains all property ranges read from the binary image.
// NOTE: This should be resized inside the source files to ensure the most
// up-to-date view of PropertyOffsetID.
std::vector<DeviceBinaryImage::PropertyRange> BinProperties;
};

/// Tries to determine the device binary image foramat. Returns
Expand Down
30 changes: 26 additions & 4 deletions sycl/source/detail/pi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,16 @@ std::ostream &operator<<(std::ostream &Out, const DeviceBinaryProperty &P) {
return Out;
}

DeviceBinaryImage::DeviceBinaryImage(pi_device_binary Bin)
: BinProperties(
static_cast<size_t>(PropertyOffsetID::PropertyOffsetIDSize)) {
init(Bin);
}

DeviceBinaryImage::DeviceBinaryImage()
: Bin(nullptr), BinProperties(static_cast<size_t>(
PropertyOffsetID::PropertyOffsetIDSize)) {}

void DeviceBinaryImage::print() const {
std::cerr << " --- Image " << Bin << "\n";
if (!Bin)
Expand Down Expand Up @@ -836,10 +846,22 @@ void DeviceBinaryImage::init(pi_device_binary Bin) {
// try to determine the format; may remain "NONE"
Format = getBinaryImageFormat(Bin->BinaryStart, getSize());

SpecConstIDMap.init(Bin, __SYCL_PI_PROPERTY_SET_SPEC_CONST_MAP);
DeviceLibReqMask.init(Bin, __SYCL_PI_PROPERTY_SET_DEVICELIB_REQ_MASK);
KernelParamOptInfo.init(Bin, __SYCL_PI_PROPERTY_SET_KERNEL_PARAM_OPT_INFO);
ProgramMetadata.init(Bin, __SYCL_PI_PROPERTY_SET_PROGRAM_METADATA);
getBinProperty(PropertyOffsetID::SpecConstIDMap)
.init(Bin, __SYCL_PI_PROPERTY_SET_SPEC_CONST_MAP);
getBinProperty(PropertyOffsetID::SpecConstDefaultValuesMap)
.init(Bin, __SYCL_PI_PROPERTY_SET_SPEC_CONST_DEFAULT_VALUES_MAP);
getBinProperty(PropertyOffsetID::DeviceLibReqMask)
.init(Bin, __SYCL_PI_PROPERTY_SET_DEVICELIB_REQ_MASK);
getBinProperty(PropertyOffsetID::KernelParamOptInfo)
.init(Bin, __SYCL_PI_PROPERTY_SET_KERNEL_PARAM_OPT_INFO);
getBinProperty(PropertyOffsetID::AssertUsed)
.init(Bin, __SYCL_PI_PROPERTY_SET_SYCL_ASSERT_USED);
getBinProperty(PropertyOffsetID::ProgramMetadata)
.init(Bin, __SYCL_PI_PROPERTY_SET_PROGRAM_METADATA);
getBinProperty(PropertyOffsetID::ExportedSymbols)
.init(Bin, __SYCL_PI_PROPERTY_SET_SYCL_EXPORTED_SYMBOLS);
getBinProperty(PropertyOffsetID::DeviceGlobals)
.init(Bin, __SYCL_PI_PROPERTY_SET_SYCL_DEVICE_GLOBALS);
}

} // namespace pi
Expand Down