Skip to content

Commit 1742622

Browse files
Added DPCTLDevice_GetProfilingTimerResolution
1 parent 8ad3e1c commit 1742622

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

libsyclinterface/include/dpctl_sycl_device_interface.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,3 +587,14 @@ DPCTLDevice_GetParentDevice(__dpctl_keep const DPCTLSyclDeviceRef DRef);
587587
*/
588588
DPCTL_API
589589
size_t DPCTLDevice_Hash(__dpctl_keep const DPCTLSyclDeviceRef DRef);
590+
591+
/*!
592+
* @brief Wrapper over
593+
* device.get_info<info::device::profiling_timer_resolution>
594+
*
595+
* @param DRef Opaque pointer to a sycl::device
596+
* @return Returns the resolution of device timer in nanoseconds.
597+
*/
598+
DPCTL_API
599+
size_t DPCTLDevice_GetProfilingTimerResolution(
600+
__dpctl_keep const DPCTLSyclDeviceRef DRef);

libsyclinterface/source/dpctl_sycl_device_interface.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,3 +648,16 @@ size_t DPCTLDevice_Hash(__dpctl_keep const DPCTLSyclDeviceRef DRef)
648648
return 0;
649649
}
650650
}
651+
652+
size_t DPCTLDevice_GetProfilingTimerResolution(
653+
__dpctl_keep const DPCTLSyclDeviceRef DRef)
654+
{
655+
if (DRef) {
656+
auto D = unwrap(DRef);
657+
return D->get_info<info::device::profiling_timer_resolution>();
658+
}
659+
else {
660+
error_handler("Argument DRef is null", __FILE__, __func__, __LINE__);
661+
return 0;
662+
}
663+
}

libsyclinterface/tests/test_sycl_device_interface.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,14 @@ TEST_P(TestDPCTLSyclDeviceInterface, ChkGetParentDevice)
375375
EXPECT_TRUE(pDRef == nullptr);
376376
}
377377

378+
TEST_P(TestDPCTLSyclDeviceInterface, ChkGetProfilingTimerResolution)
379+
{
380+
size_t res = 0;
381+
EXPECT_NO_FATAL_FAILURE(res =
382+
DPCTLDevice_GetProfilingTimerResolution(DRef));
383+
EXPECT_TRUE(res != 0);
384+
}
385+
378386
INSTANTIATE_TEST_SUITE_P(DPCTLDeviceFns,
379387
TestDPCTLSyclDeviceInterface,
380388
::testing::Values("opencl",
@@ -673,3 +681,11 @@ TEST_F(TestDPCTLSyclDeviceNullArgs, ChkHash)
673681
EXPECT_NO_FATAL_FAILURE(hash = DPCTLDevice_Hash(Null_DRef));
674682
ASSERT_TRUE(hash == 0);
675683
}
684+
685+
TEST_F(TestDPCTLSyclDeviceNullArgs, ChkGetProfilingTimerResolution)
686+
{
687+
size_t res = 1;
688+
EXPECT_NO_FATAL_FAILURE(
689+
res = DPCTLDevice_GetProfilingTimerResolution(Null_DRef));
690+
ASSERT_TRUE(res == 0);
691+
}

0 commit comments

Comments
 (0)