@@ -1829,26 +1829,24 @@ cdef class SyclDevice(_SyclDevice):
18291829
18301830 if not isinstance (peer, SyclDevice):
18311831 raise TypeError (
1832- " second argument must be a `dpctl.SyclDevice`, got "
1832+ " peer device must be a `dpctl.SyclDevice`, got "
18331833 f" {type(peer)}"
18341834 )
18351835 p_dev = < SyclDevice> peer
1836+
1837+ _peer_access_backends = [
1838+ _backend_type._CUDA,
1839+ _backend_type._HIP,
1840+ _backend_type._LEVEL_ZERO
1841+ ]
18361842 BTy1 = DPCTLDevice_GetBackend(self ._device_ref)
1837- if (
1838- BTy1 != _backend_type._CUDA and
1839- BTy1 != _backend_type._HIP and
1840- BTy1 != _backend_type._LEVEL_ZERO
1841- ):
1843+ if BTy1 not in _peer_access_backends:
18421844 raise ValueError (
18431845 " Peer access not supported for backend "
18441846 f" {_backend_type_to_filter_string_part(BTy1)}"
18451847 )
18461848 BTy2 = DPCTLDevice_GetBackend(p_dev.get_device_ref())
1847- if (
1848- BTy2 != _backend_type._CUDA and
1849- BTy2 != _backend_type._HIP and
1850- BTy2 != _backend_type._LEVEL_ZERO
1851- ):
1849+ if BTy2 not in _peer_access_backends:
18521850 raise ValueError (
18531851 " Peer access not supported for backend "
18541852 f" {_backend_type_to_filter_string_part(BTy2)}"
@@ -1895,26 +1893,24 @@ cdef class SyclDevice(_SyclDevice):
18951893
18961894 if not isinstance (peer, SyclDevice):
18971895 raise TypeError (
1898- " second argument must be a `dpctl.SyclDevice`, got "
1896+ " peer device must be a `dpctl.SyclDevice`, got "
18991897 f" {type(peer)}"
19001898 )
19011899 p_dev = < SyclDevice> peer
1900+
1901+ _peer_access_backends = [
1902+ _backend_type._CUDA,
1903+ _backend_type._HIP,
1904+ _backend_type._LEVEL_ZERO
1905+ ]
19021906 BTy1 = DPCTLDevice_GetBackend(self ._device_ref)
1903- if (
1904- BTy1 != _backend_type._CUDA and
1905- BTy1 != _backend_type._HIP and
1906- BTy1 != _backend_type._LEVEL_ZERO
1907- ):
1907+ if BTy1 not in _peer_access_backends:
19081908 raise ValueError (
19091909 " Peer access not supported for backend "
19101910 f" {_backend_type_to_filter_string_part(BTy1)}"
19111911 )
19121912 BTy2 = DPCTLDevice_GetBackend(p_dev.get_device_ref())
1913- if (
1914- BTy2 != _backend_type._CUDA and
1915- BTy2 != _backend_type._HIP and
1916- BTy2 != _backend_type._LEVEL_ZERO
1917- ):
1913+ if BTy2 not in _peer_access_backends:
19181914 raise ValueError (
19191915 " Peer access not supported for backend "
19201916 f" {_backend_type_to_filter_string_part(BTy2)}"
@@ -1953,28 +1949,26 @@ cdef class SyclDevice(_SyclDevice):
19531949
19541950 if not isinstance (peer, SyclDevice):
19551951 raise TypeError (
1956- " second argument must be a `dpctl.SyclDevice`, got "
1952+ " peer device must be a `dpctl.SyclDevice`, got "
19571953 f" {type(peer)}"
19581954 )
19591955 p_dev = < SyclDevice> peer
1956+
1957+ _peer_access_backends = [
1958+ _backend_type._CUDA,
1959+ _backend_type._HIP,
1960+ _backend_type._LEVEL_ZERO
1961+ ]
19601962 BTy1 = (
19611963 DPCTLDevice_GetBackend(self ._device_ref)
19621964 )
1963- if (
1964- BTy1 != _backend_type._CUDA and
1965- BTy1 != _backend_type._HIP and
1966- BTy1 != _backend_type._LEVEL_ZERO
1967- ):
1965+ if BTy1 not in _peer_access_backends:
19681966 raise ValueError (
19691967 " Peer access not supported for backend "
19701968 f" {_backend_type_to_filter_string_part(BTy1)}"
19711969 )
19721970 BTy2 = DPCTLDevice_GetBackend(p_dev.get_device_ref())
1973- if (
1974- BTy2 != _backend_type._CUDA and
1975- BTy2 != _backend_type._HIP and
1976- BTy2 != _backend_type._LEVEL_ZERO
1977- ):
1971+ if BTy2 not in _peer_access_backends:
19781972 raise ValueError (
19791973 " Peer access not supported for backend "
19801974 f" {_backend_type_to_filter_string_part(BTy2)}"
@@ -2007,26 +2001,24 @@ cdef class SyclDevice(_SyclDevice):
20072001
20082002 if not isinstance (peer, SyclDevice):
20092003 raise TypeError (
2010- " second argument must be a `dpctl.SyclDevice`, got "
2004+ " peer device must be a `dpctl.SyclDevice`, got "
20112005 f" {type(peer)}"
20122006 )
20132007 p_dev = < SyclDevice> peer
2008+
2009+ _peer_access_backends = [
2010+ _backend_type._CUDA,
2011+ _backend_type._HIP,
2012+ _backend_type._LEVEL_ZERO
2013+ ]
20142014 BTy1 = DPCTLDevice_GetBackend(self ._device_ref)
2015- if (
2016- BTy1 != _backend_type._CUDA and
2017- BTy1 != _backend_type._HIP and
2018- BTy1 != _backend_type._LEVEL_ZERO
2019- ):
2015+ if BTy1 not in _peer_access_backends:
20202016 raise ValueError (
20212017 " Peer access not supported for backend "
20222018 f" {_backend_type_to_filter_string_part(BTy1)}"
20232019 )
20242020 BTy2 = DPCTLDevice_GetBackend(p_dev.get_device_ref())
2025- if (
2026- BTy2 != _backend_type._CUDA and
2027- BTy2 != _backend_type._HIP and
2028- BTy2 != _backend_type._LEVEL_ZERO
2029- ):
2021+ if BTy2 not in _peer_access_backends:
20302022 raise ValueError (
20312023 " Peer access not supported for backend "
20322024 f" {_backend_type_to_filter_string_part(BTy2)}"
0 commit comments