@@ -1855,7 +1855,7 @@ cdef class SyclDevice(_SyclDevice):
1855
1855
raise ValueError (" Internal error: NULL device vector encountered" )
1856
1856
return _get_devices(cDVRef)
1857
1857
1858
- def can_access_peer_access_supported (self , peer ):
1858
+ def can_access_peer (self , peer , value = " access_supported " ):
1859
1859
""" Returns ``True`` if this device (``self``) can enable peer access
1860
1860
to USM device memory on ``peer``, ``False`` otherwise.
1861
1861
@@ -1869,60 +1869,50 @@ cdef class SyclDevice(_SyclDevice):
1869
1869
peer (:class:`dpctl.SyclDevice`):
1870
1870
The :class:`dpctl.SyclDevice` instance to check for peer access
1871
1871
by this device.
1872
+ value (str, optional):
1873
+ Specifies the kind of peer access being queried
1872
1874
1873
- Returns:
1874
- bool:
1875
- ``True`` if this device may access USM device memory on
1876
- ``peer`` when peer access is enabled, otherwise ``False``.
1875
+ - ``"access_supported"``
1876
+ Returns ``True`` if it is possible for this device to
1877
+ enable peer access to USM device memory on ``peer``.
1877
1878
1878
- Raises:
1879
- TypeError:
1880
- If ``peer`` is not :class:`dpctl.SyclDevice`.
1881
- """
1882
- cdef SyclDevice p_dev
1879
+ - ``"atomics_supported"``
1880
+ Returns ``True`` if it is possible for this device to
1881
+ concurrently access and atomically modify USM device
1882
+ memory on ``peer`` when enabled.
1883
1883
1884
- if not isinstance (peer, SyclDevice):
1885
- raise TypeError (
1886
- " peer device must be a `dpctl.SyclDevice`, got "
1887
- f" {type(peer)}"
1888
- )
1889
- p_dev = < SyclDevice> peer
1890
- if _check_peer_access(self , p_dev):
1891
- return DPCTLDevice_CanAccessPeer(
1892
- self ._device_ref,
1893
- p_dev.get_device_ref(),
1894
- _peer_access._access_supported
1895
- )
1896
- return False
1884
+ If ``False`` is returned, these operations result in
1885
+ undefined behavior.
1897
1886
1898
- def can_access_peer_atomics_supported (self , peer ):
1899
- """ Returns ``True`` if this device (``self``) can concurrently access
1900
- and modify USM device memory on ``peer`` when peer access is enabled,
1901
- ``False`` otherwise.
1887
+ Note: atomics must have ``memory_scope::system`` when
1888
+ modifying memory on a peer device.
1902
1889
1903
- If peer access is supported, it may be enabled by calling
1904
- :meth:`.enable_peer_access`.
1905
-
1906
- For details, see
1907
- :oneapi_peer_access:`DPC++ peer access SYCL extension <>`.
1908
-
1909
- Args:
1910
- peer (:class:`dpctl.SyclDevice`):
1911
- The :class:`dpctl.SyclDevice` instance to check for concurrent
1912
- peer access and modification by this device.
1890
+ Default: ``"access_supported"``
1913
1891
1914
1892
Returns:
1915
1893
bool:
1916
- ``True`` if this device may concurrently access and modify USM
1917
- device memory on ``peer`` when peer access is enabled,
1918
- otherwise ``False``.
1894
+ ``True`` if this device may access USM device memory on
1895
+ ``peer`` when peer access is enabled, otherwise ``False``.
1919
1896
1920
1897
Raises:
1921
1898
TypeError:
1922
1899
If ``peer`` is not :class:`dpctl.SyclDevice`.
1923
1900
"""
1924
1901
cdef SyclDevice p_dev
1925
1902
1903
+ if not isinstance (value, str ):
1904
+ raise TypeError (
1905
+ f" Expected `value` to be of type str, got {type(value)}"
1906
+ )
1907
+ if value == " access_supported" :
1908
+ access_type = _peer_access._access_supported
1909
+ elif value == " atomics_supported" :
1910
+ access_type = _peer_access._atomics_supported
1911
+ else :
1912
+ raise ValueError (
1913
+ " `value` must be 'access_supported' or 'atomics_supported', "
1914
+ f" got {value}"
1915
+ )
1926
1916
if not isinstance (peer, SyclDevice):
1927
1917
raise TypeError (
1928
1918
" peer device must be a `dpctl.SyclDevice`, got "
@@ -1933,7 +1923,7 @@ cdef class SyclDevice(_SyclDevice):
1933
1923
return DPCTLDevice_CanAccessPeer(
1934
1924
self ._device_ref,
1935
1925
p_dev.get_device_ref(),
1936
- _peer_access._atomics_supported
1926
+ access_type
1937
1927
)
1938
1928
return False
1939
1929
@@ -2002,11 +1992,10 @@ cdef class SyclDevice(_SyclDevice):
2002
1992
)
2003
1993
p_dev = < SyclDevice> peer
2004
1994
_raise_invalid_peer_access(self , p_dev)
2005
- if _check_peer_access(self , p_dev):
2006
- DPCTLDevice_DisablePeerAccess(
2007
- self ._device_ref,
2008
- p_dev.get_device_ref()
2009
- )
1995
+ DPCTLDevice_DisablePeerAccess(
1996
+ self ._device_ref,
1997
+ p_dev.get_device_ref()
1998
+ )
2010
1999
return
2011
2000
2012
2001
@property
0 commit comments