Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
1 change: 1 addition & 0 deletions 1 dpctl/_backend.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ cdef extern from "syclinterface/dpctl_sycl_enum_types.h":
_usm_atomic_host_allocations 'usm_atomic_host_allocations',
_usm_atomic_shared_allocations 'usm_atomic_shared_allocations',
_host_debuggable 'host_debuggable',
_emulated 'emulated',

ctypedef enum _partition_affinity_domain_type 'DPCTLPartitionAffinityDomainType':
_not_applicable 'not_applicable',
Expand Down
14 changes: 14 additions & 0 deletions 14 dpctl/_sycl_device.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,20 @@ cdef class SyclDevice(_SyclDevice):
cdef _aspect_type AT = _aspect_type._host_debuggable
return DPCTLDevice_HasAspect(self._device_ref, AT)

@property
def has_aspect_emulated(self):
""" Returns ``True`` if this device is somehow emulated, ``False``
otherwise. A device with this aspect is not intended for performance,
and instead will generally have another purpose such as emulation
or profiling.

Returns:
bool:
Indicates if device is somehow emulated.
"""
cdef _aspect_type AT = _aspect_type._emulated
return DPCTLDevice_HasAspect(self._device_ref, AT)

@property
def image_2d_max_width(self):
""" Returns the maximum width of a 2D image or 1D image in pixels.
Expand Down
8 changes: 8 additions & 0 deletions 8 dpctl/tests/_device_attributes_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,13 @@ def check_has_aspect_host_debuggable(device):
pytest.fail("has_aspect_host_debuggable call failed")


def check_has_aspect_emulated(device):
try:
device.has_aspect_emulated
except Exception:
pytest.fail("has_aspect_emulated call failed")


def check_is_accelerator(device):
try:
device.is_accelerator
Expand Down Expand Up @@ -698,6 +705,7 @@ def check_global_mem_cache_line_size(device):
check_has_aspect_usm_atomic_host_allocations,
check_has_aspect_usm_atomic_shared_allocations,
check_has_aspect_host_debuggable,
check_has_aspect_emulated,
check_max_read_image_args,
check_max_write_image_args,
check_image_2d_max_width,
Expand Down
15 changes: 7 additions & 8 deletions 15 dpctl/tests/test_sycl_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,12 @@ def test_equal():
"atomic64",
"usm_atomic_host_allocations",
"usm_atomic_shared_allocations",
"emulated",
]

# SYCL 2020 spec aspects not presently
# supported in DPC++, and dpctl
list_of_unsupported_aspects = [
"emulated",
]
list_of_unsupported_aspects = []
ndgrigorian marked this conversation as resolved.
Show resolved Hide resolved


@pytest.fixture(params=list_of_supported_aspects)
Expand Down Expand Up @@ -199,14 +198,14 @@ def test_supported_aspect(supported_aspect):

def test_unsupported_aspect(unsupported_aspect):
try:
dpctl.select_device_with_aspects(unsupported_aspect)
d = dpctl.SyclDevice()
has_it = hasattr(d, "has_aspect_" + unsupported_aspect)
except dpctl.SyclDeviceCreationError:
has_it = False
if has_it:
raise AttributeError(
f"The {unsupported_aspect} aspect is now supported in dpctl"
)
except AttributeError:
pytest.skip(
f"The {unsupported_aspect} aspect is not supported in dpctl"
)


def test_handle_no_device():
Expand Down
10 changes: 10 additions & 0 deletions 10 libsyclinterface/helper/source/dpctl_utils_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@ std::string DPCTL_AspectToStr(aspect aspectTy)
case aspect::host_debuggable:
ss << "host_debuggable";
break;
case aspect::emulated:
ss << "emulated";
break;
default:
throw std::runtime_error("Unsupported aspect type");
}
Expand Down Expand Up @@ -280,6 +283,9 @@ aspect DPCTL_StrToAspectType(const std::string &aspectTyStr)
else if (aspectTyStr == "host_debuggable") {
aspectTy = aspect::host_debuggable;
}
else if (aspectTyStr == "emulated") {
aspectTy = aspect::emulated;
}
else {
// \todo handle the error
throw std::runtime_error("Unsupported aspect type");
Expand Down Expand Up @@ -326,6 +332,8 @@ aspect DPCTL_DPCTLAspectTypeToSyclAspect(DPCTLSyclAspectType AspectTy)
return aspect::usm_atomic_shared_allocations;
case DPCTLSyclAspectType::host_debuggable:
return aspect::host_debuggable;
case DPCTLSyclAspectType::emulated:
return aspect::emulated;
default:
throw std::runtime_error("Unsupported aspect type");
}
Expand Down Expand Up @@ -370,6 +378,8 @@ DPCTLSyclAspectType DPCTL_SyclAspectToDPCTLAspectType(aspect Aspect)
return DPCTLSyclAspectType::usm_atomic_shared_allocations;
case aspect::host_debuggable:
return DPCTLSyclAspectType::host_debuggable;
case aspect::emulated:
return DPCTLSyclAspectType::emulated;
default:
throw std::runtime_error("Unsupported aspect type");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ typedef enum
usm_atomic_host_allocations,
usm_atomic_shared_allocations,
host_debuggable,
emulated
} DPCTLSyclAspectType;

/*!
Expand Down
5 changes: 3 additions & 2 deletions 5 libsyclinterface/tests/test_sycl_device_aspects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ auto build_params()
sycl::aspect::usm_atomic_host_allocations),
std::make_pair("usm_atomic_shared_allocations",
sycl::aspect::usm_atomic_shared_allocations),
std::make_pair("host_debuggable", sycl::aspect::host_debuggable));
std::make_pair("host_debuggable", sycl::aspect::host_debuggable),
std::make_pair("emulated", sycl::aspect::emulated));

auto pairs =
build_param_pairs<const char *, std::pair<const char *, sycl::aspect>,
Expand Down Expand Up @@ -165,7 +166,7 @@ struct TestDPCTLSyclDeviceInterfaceAspects
auto syclAspect = GetParam().second.second;
try {
hasAspect = D->has(syclAspect);
} catch (sycl::exception const &e) {
} catch (sycl::exception const &) {
}
}

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.