@@ -1855,7 +1855,7 @@ cdef class SyclDevice(_SyclDevice):
18551855 raise ValueError (" Internal error: NULL device vector encountered" )
18561856 return _get_devices(cDVRef)
18571857
1858- def can_access_peer_access_supported (self , peer ):
1858+ def can_access_peer (self , peer , value = " access_supported " ):
18591859 """ Returns ``True`` if this device (``self``) can enable peer access
18601860 to USM device memory on ``peer``, ``False`` otherwise.
18611861
@@ -1869,60 +1869,50 @@ cdef class SyclDevice(_SyclDevice):
18691869 peer (:class:`dpctl.SyclDevice`):
18701870 The :class:`dpctl.SyclDevice` instance to check for peer access
18711871 by this device.
1872+ value (str, optional):
1873+ Specifies the kind of peer access being queried
18721874
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``.
18771878
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.
18831883
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.
18971886
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.
19021889
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"``
19131891
19141892 Returns:
19151893 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``.
19191896
19201897 Raises:
19211898 TypeError:
19221899 If ``peer`` is not :class:`dpctl.SyclDevice`.
19231900 """
19241901 cdef SyclDevice p_dev
19251902
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+ )
19261916 if not isinstance (peer, SyclDevice):
19271917 raise TypeError (
19281918 " peer device must be a `dpctl.SyclDevice`, got "
@@ -1933,7 +1923,7 @@ cdef class SyclDevice(_SyclDevice):
19331923 return DPCTLDevice_CanAccessPeer(
19341924 self ._device_ref,
19351925 p_dev.get_device_ref(),
1936- _peer_access._atomics_supported
1926+ access_type
19371927 )
19381928 return False
19391929
@@ -2002,11 +1992,10 @@ cdef class SyclDevice(_SyclDevice):
20021992 )
20031993 p_dev = < SyclDevice> peer
20041994 _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+ )
20101999 return
20112000
20122001 @property
0 commit comments