@@ -1796,7 +1796,7 @@ cdef class SyclDevice(_SyclDevice):
1796
1796
raise ValueError (" Internal error: NULL device vector encountered" )
1797
1797
return _get_devices(cDVRef)
1798
1798
1799
- def can_access_peer (self , peer ):
1799
+ def can_access_peer_access_supported (self , peer ):
1800
1800
""" Returns ``True`` if `self` can enable peer access
1801
1801
to `peer`, ``False`` otherwise.
1802
1802
@@ -1809,14 +1809,45 @@ cdef class SyclDevice(_SyclDevice):
1809
1809
bool:
1810
1810
``True`` if `self` can enable peer access
1811
1811
to `peer`, otherwise ``False``.
1812
+
1813
+ Raises:
1814
+ TypeError:
1815
+ If `peer` is not `dpctl.SyclDevice`.
1816
+ ValueError:
1817
+ If the backend associated with `self` or `peer` does not
1818
+ support peer access.
1812
1819
"""
1813
1820
cdef SyclDevice p_dev
1821
+ cdef _backend_type BTy1
1822
+ cdef _backend_type BTy2
1823
+
1814
1824
if not isinstance (peer, SyclDevice):
1815
1825
raise TypeError (
1816
1826
" second argument must be a `dpctl.SyclDevice`, got "
1817
1827
f" {type(peer)}"
1818
1828
)
1819
1829
p_dev = < SyclDevice> peer
1830
+ BTy1 = DPCTLDevice_GetBackend(self ._device_ref)
1831
+ if (
1832
+ BTy1 != _backend_type._CUDA and
1833
+ BTy1 != _backend_type._HIP and
1834
+ BTy1 != _backend_type._LEVEL_ZERO
1835
+ ):
1836
+ raise ValueError (
1837
+ " Peer access not supported for backend "
1838
+ f" {_backend_type_to_filter_string_part(BTy1)}"
1839
+ )
1840
+ BTy2 = DPCTLDevice_GetBackend(p_dev.get_device_ref())
1841
+ if (
1842
+ BTy2 != _backend_type._CUDA and
1843
+ BTy2 != _backend_type._HIP and
1844
+ BTy2 != _backend_type._LEVEL_ZERO
1845
+ ):
1846
+ raise ValueError (
1847
+ " Peer access not supported for backend "
1848
+ f" {_backend_type_to_filter_string_part(BTy2)}"
1849
+ )
1850
+
1820
1851
return DPCTLDevice_CanAccessPeer(
1821
1852
self ._device_ref,
1822
1853
p_dev.get_device_ref(),
@@ -1837,14 +1868,45 @@ cdef class SyclDevice(_SyclDevice):
1837
1868
``True`` if `self` can enable peer access
1838
1869
to and can atomically modify memory on `peer`,
1839
1870
otherwise ``False``.
1871
+
1872
+ Raises:
1873
+ TypeError:
1874
+ If `peer` is not `dpctl.SyclDevice`.
1875
+ ValueError:
1876
+ If the backend associated with `self` or `peer` does not
1877
+ support peer access.
1840
1878
"""
1841
1879
cdef SyclDevice p_dev
1880
+ cdef _backend_type BTy1
1881
+ cdef _backend_type BTy2
1882
+
1842
1883
if not isinstance (peer, SyclDevice):
1843
1884
raise TypeError (
1844
1885
" second argument must be a `dpctl.SyclDevice`, got "
1845
1886
f" {type(peer)}"
1846
1887
)
1847
1888
p_dev = < SyclDevice> peer
1889
+ BTy1 = DPCTLDevice_GetBackend(self ._device_ref)
1890
+ if (
1891
+ BTy1 != _backend_type._CUDA and
1892
+ BTy1 != _backend_type._HIP and
1893
+ BTy1 != _backend_type._LEVEL_ZERO
1894
+ ):
1895
+ raise ValueError (
1896
+ " Peer access not supported for backend "
1897
+ f" {_backend_type_to_filter_string_part(BTy1)}"
1898
+ )
1899
+ BTy2 = DPCTLDevice_GetBackend(p_dev.get_device_ref())
1900
+ if (
1901
+ BTy2 != _backend_type._CUDA and
1902
+ BTy2 != _backend_type._HIP and
1903
+ BTy2 != _backend_type._LEVEL_ZERO
1904
+ ):
1905
+ raise ValueError (
1906
+ " Peer access not supported for backend "
1907
+ f" {_backend_type_to_filter_string_part(BTy2)}"
1908
+ )
1909
+
1848
1910
return DPCTLDevice_CanAccessPeer(
1849
1911
self ._device_ref,
1850
1912
p_dev.get_device_ref(),
@@ -1861,17 +1923,45 @@ cdef class SyclDevice(_SyclDevice):
1861
1923
enable peer access to.
1862
1924
1863
1925
Raises:
1926
+ TypeError:
1927
+ If `peer` is not `dpctl.SyclDevice`.
1864
1928
ValueError:
1865
- If the ``DPCTLDevice_GetComponentDevices`` call returned
1866
- ``NULL`` instead of a ``DPCTLDeviceVectorRef`` object .
1929
+ If the backend associated with `self` or `peer` does not
1930
+ support peer access .
1867
1931
"""
1868
1932
cdef SyclDevice p_dev
1933
+ cdef _backend_type BTy1
1934
+ cdef _backend_type BTy2
1935
+
1869
1936
if not isinstance (peer, SyclDevice):
1870
1937
raise TypeError (
1871
1938
" second argument must be a `dpctl.SyclDevice`, got "
1872
1939
f" {type(peer)}"
1873
1940
)
1874
1941
p_dev = < SyclDevice> peer
1942
+ BTy1 = (
1943
+ DPCTLDevice_GetBackend(self ._device_ref)
1944
+ )
1945
+ if (
1946
+ BTy1 != _backend_type._CUDA and
1947
+ BTy1 != _backend_type._HIP and
1948
+ BTy1 != _backend_type._LEVEL_ZERO
1949
+ ):
1950
+ raise ValueError (
1951
+ " Peer access not supported for backend "
1952
+ f" {_backend_type_to_filter_string_part(BTy1)}"
1953
+ )
1954
+ BTy2 = DPCTLDevice_GetBackend(p_dev.get_device_ref())
1955
+ if (
1956
+ BTy2 != _backend_type._CUDA and
1957
+ BTy2 != _backend_type._HIP and
1958
+ BTy2 != _backend_type._LEVEL_ZERO
1959
+ ):
1960
+ raise ValueError (
1961
+ " Peer access not supported for backend "
1962
+ f" {_backend_type_to_filter_string_part(BTy2)}"
1963
+ )
1964
+
1875
1965
DPCTLDevice_EnablePeerAccess(self ._device_ref, p_dev.get_device_ref())
1876
1966
return
1877
1967
@@ -1884,17 +1974,43 @@ cdef class SyclDevice(_SyclDevice):
1884
1974
disable peer access to.
1885
1975
1886
1976
Raises:
1977
+ TypeError:
1978
+ If `peer` is not `dpctl.SyclDevice`.
1887
1979
ValueError:
1888
- If the ``DPCTLDevice_GetComponentDevices`` call returned
1889
- ``NULL`` instead of a ``DPCTLDeviceVectorRef`` object .
1980
+ If the backend associated with `self` or `peer` does not
1981
+ support peer access .
1890
1982
"""
1891
1983
cdef SyclDevice p_dev
1984
+ cdef _backend_type BTy1
1985
+ cdef _backend_type BTy2
1986
+
1892
1987
if not isinstance (peer, SyclDevice):
1893
1988
raise TypeError (
1894
1989
" second argument must be a `dpctl.SyclDevice`, got "
1895
1990
f" {type(peer)}"
1896
1991
)
1897
1992
p_dev = < SyclDevice> peer
1993
+ BTy1 = DPCTLDevice_GetBackend(self ._device_ref)
1994
+ if (
1995
+ BTy1 != _backend_type._CUDA and
1996
+ BTy1 != _backend_type._HIP and
1997
+ BTy1 != _backend_type._LEVEL_ZERO
1998
+ ):
1999
+ raise ValueError (
2000
+ " Peer access not supported for backend "
2001
+ f" {_backend_type_to_filter_string_part(BTy1)}"
2002
+ )
2003
+ BTy2 = DPCTLDevice_GetBackend(p_dev.get_device_ref())
2004
+ if (
2005
+ BTy2 != _backend_type._CUDA and
2006
+ BTy2 != _backend_type._HIP and
2007
+ BTy2 != _backend_type._LEVEL_ZERO
2008
+ ):
2009
+ raise ValueError (
2010
+ " Peer access not supported for backend "
2011
+ f" {_backend_type_to_filter_string_part(BTy2)}"
2012
+ )
2013
+
1898
2014
DPCTLDevice_DisablePeerAccess(self ._device_ref, p_dev.get_device_ref())
1899
2015
return
1900
2016
0 commit comments