Skip to content

Two new device descriptors added #1530

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 5 commits into from
Feb 6, 2024
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
2 changes: 2 additions & 0 deletions dpctl/_backend.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ cdef extern from "syclinterface/dpctl_sycl_device_interface.h":
cdef size_t *DPCTLDevice_GetSubGroupSizes(const DPCTLSyclDeviceRef DRef,
size_t *res_len)
cdef uint32_t DPCTLDevice_GetPartitionMaxSubDevices(const DPCTLSyclDeviceRef DRef)
cdef uint32_t DPCTLDevice_GetMaxClockFrequency(const DPCTLSyclDeviceRef DRef)
cdef uint64_t DPCTLDevice_GetMaxMemAllocSize(const DPCTLSyclDeviceRef DRef)


cdef extern from "syclinterface/dpctl_sycl_device_manager.h":
Expand Down
26 changes: 26 additions & 0 deletions dpctl/_sycl_device.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ from ._backend cimport ( # noqa: E211
DPCTLDevice_GetImage3dMaxHeight,
DPCTLDevice_GetImage3dMaxWidth,
DPCTLDevice_GetLocalMemSize,
DPCTLDevice_GetMaxClockFrequency,
DPCTLDevice_GetMaxComputeUnits,
DPCTLDevice_GetMaxMemAllocSize,
DPCTLDevice_GetMaxNumSubGroups,
DPCTLDevice_GetMaxReadImageArgs,
DPCTLDevice_GetMaxWorkGroupSize,
Expand Down Expand Up @@ -1294,6 +1296,30 @@ cdef class SyclDevice(_SyclDevice):
raise RuntimeError("Failed to get device timer resolution.")
return timer_res

@property
def max_clock_frequency(self):
""" Maximal clock frequency in MHz.

Returns:
int: Frequency in MHz
"""
cdef uint32_t clock_fr = DPCTLDevice_GetMaxClockFrequency(
self._device_ref
)
return clock_fr

@property
def max_mem_alloc_size(self):
""" Maximum size of memory object than can be allocated.

Returns:
int: Maximum size of memory object in bytes
"""
cdef uint64_t max_alloc_sz = DPCTLDevice_GetMaxMemAllocSize(
self._device_ref
)
return max_alloc_sz

@property
def global_mem_cache_type(self):
""" Global device cache memory type.
Expand Down
15 changes: 15 additions & 0 deletions dpctl/tests/_device_attributes_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,19 @@ def check_device_type(device):
assert type(dt) is dpctl.device_type


def check_max_clock_frequency(device):
freq = device.max_clock_frequency
assert isinstance(freq, int)
# FIXME: Change to freq > 0 after transition to 2024.1
assert freq >= 0


def check_max_mem_alloc_size(device):
mmas = device.max_mem_alloc_size
assert isinstance(mmas, int)
assert mmas > 0


def check_global_mem_cache_type(device):
gmc_ty = device.global_mem_cache_type
assert type(gmc_ty) is dpctl.global_mem_cache_type
Expand Down Expand Up @@ -719,6 +732,8 @@ def check_global_mem_cache_line_size(device):
check_global_mem_cache_type,
check_global_mem_cache_size,
check_global_mem_cache_line_size,
check_max_clock_frequency,
check_max_mem_alloc_size,
]


Expand Down
22 changes: 22 additions & 0 deletions libsyclinterface/include/dpctl_sycl_device_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,28 @@ DPCTL_API
uint32_t DPCTLDevice_GetGlobalMemCacheLineSize(
__dpctl_keep const DPCTLSyclDeviceRef DRef);

/*!
* @brief Wrapper over
* device.get_info<info::device::max_clock_frequency>
*
* @param DRef Opaque pointer to a sycl::device
* @return Returns the maximum clock frequency in MHz as uint32_t.
*/
DPCTL_API
uint32_t
DPCTLDevice_GetMaxClockFrequency(__dpctl_keep const DPCTLSyclDeviceRef DRef);

/*!
* @brief Wrapper over
* device.get_info<info::device::max_mem_alloc_size>
*
* @param DRef Opaque pointer to a sycl::device
* @return Returns the maximum size of memory object in bytes as uint64_t.
*/
DPCTL_API
uint64_t
DPCTLDevice_GetMaxMemAllocSize(__dpctl_keep const DPCTLSyclDeviceRef DRef);

/*!
* @brief Wrapper over
* device.get_info<info::device::global_mem_cache_size>
Expand Down
26 changes: 26 additions & 0 deletions libsyclinterface/source/dpctl_sycl_device_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,32 @@ uint32_t DPCTLDevice_GetGlobalMemCacheLineSize(
}
}

uint32_t
DPCTLDevice_GetMaxClockFrequency(__dpctl_keep const DPCTLSyclDeviceRef DRef)
{
if (DRef) {
auto D = unwrap<device>(DRef);
return D->get_info<info::device::max_clock_frequency>();
}
else {
error_handler("Argument DRef is null", __FILE__, __func__, __LINE__);
return 0;
}
}

uint64_t
DPCTLDevice_GetMaxMemAllocSize(__dpctl_keep const DPCTLSyclDeviceRef DRef)
{
if (DRef) {
auto D = unwrap<device>(DRef);
return D->get_info<info::device::max_mem_alloc_size>();
}
else {
error_handler("Argument DRef is null", __FILE__, __func__, __LINE__);
return 0;
}
}

uint64_t
DPCTLDevice_GetGlobalMemCacheSize(__dpctl_keep const DPCTLSyclDeviceRef DRef)
{
Expand Down
31 changes: 31 additions & 0 deletions libsyclinterface/tests/test_sycl_device_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,13 @@ TEST_P(TestDPCTLSyclDeviceInterface, ChkGetProfilingTimerResolution)
EXPECT_TRUE(res != 0);
}

TEST_P(TestDPCTLSyclDeviceInterface, ChkGetMaxMemAllocSize)
{
uint64_t res = 0;
EXPECT_NO_FATAL_FAILURE(res = DPCTLDevice_GetMaxMemAllocSize(DRef));
EXPECT_TRUE(res != 0);
}

TEST_P(TestDPCTLSyclDeviceInterface, ChkGetGlobalMemCacheSize)
{
uint64_t res = 0;
Expand All @@ -509,6 +516,16 @@ TEST_P(TestDPCTLSyclDeviceInterface, ChkGetGlobalMemCacheLineSize)
EXPECT_TRUE(res != 0);
}

TEST_P(TestDPCTLSyclDeviceInterface, ChkGetGetMaxClockFrequency)
{
uint32_t res = 0;
EXPECT_NO_FATAL_FAILURE(res = DPCTLDevice_GetMaxClockFrequency(DRef));
// FIXME: uncomment once coverage build transitions away
// FIXME: from using DPC++ 2023.2
EXPECT_TRUE(res >= 0);
// EXPECT_TRUE(res != 0);
}

TEST_P(TestDPCTLSyclDeviceInterface, ChkGetGlobalMemCacheType)
{
DPCTLGlobalMemCacheType res = DPCTL_MEM_CACHE_TYPE_INDETERMINATE;
Expand Down Expand Up @@ -833,6 +850,13 @@ TEST_F(TestDPCTLSyclDeviceNullArgs, ChkGetProfilingTimerResolution)
ASSERT_TRUE(res == 0);
}

TEST_F(TestDPCTLSyclDeviceNullArgs, ChkGetMaxMemAllocSize)
{
uint64_t res = 1;
EXPECT_NO_FATAL_FAILURE(res = DPCTLDevice_GetMaxMemAllocSize(Null_DRef));
ASSERT_TRUE(res == 0);
}

TEST_F(TestDPCTLSyclDeviceNullArgs, ChkGetGlobalMemCacheSize)
{
uint64_t res = 1;
Expand All @@ -848,6 +872,13 @@ TEST_F(TestDPCTLSyclDeviceNullArgs, ChkGetGlobalMemCacheLineSize)
ASSERT_TRUE(res == 0);
}

TEST_F(TestDPCTLSyclDeviceNullArgs, ChkGetMaxClockFrequency)
{
uint32_t res = 1;
EXPECT_NO_FATAL_FAILURE(res = DPCTLDevice_GetMaxClockFrequency(Null_DRef));
ASSERT_TRUE(res == 0);
}

TEST_F(TestDPCTLSyclDeviceNullArgs, ChkGetGlobalMemCacheType)
{
DPCTLGlobalMemCacheType res = DPCTL_MEM_CACHE_TYPE_NONE;
Expand Down