Skip to content
This repository was archived by the owner on Jan 25, 2023. It is now read-only.

Added parfor lower message #43

Merged
merged 4 commits into from
Oct 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion numba/dppl/dppl_lowerer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1012,8 +1012,11 @@ def lower_parfor_rollback(lowerer, parfor):

try:
_lower_parfor_gufunc(lowerer, parfor)
if numba.dppl.compiler.DEBUG:
msg = "Parfor lowered on DPPL-device"
print(msg, parfor.loc)
except Exception as e:
msg = ("Failed to lower parfor on GPU")
msg = "Failed to lower parfor on DPPL-device"
warnings.warn(NumbaPerformanceWarning(msg, parfor.loc))
raise e
finally:
Expand Down
2 changes: 1 addition & 1 deletion numba/dppl/tests/dppl/test_dppl_fallback.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def run_dppl():
ref_result = ref()

np.testing.assert_array_equal(dppl_result, ref_result)
self.assertTrue('Failed to lower parfor on GPU' in err)
self.assertTrue('Failed to lower parfor on DPPL-device' in err)


if __name__ == '__main__':
Expand Down
31 changes: 31 additions & 0 deletions numba/dppl/tests/dppl/test_parfor_lower_message.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import numpy as np
import numba
from numba import dppl, njit, prange
from numba.dppl.testing import unittest, DPPLTestCase
from numba.tests.support import captured_stdout
import dpctl.ocldrv as ocldrv


def prange_example():
n = 10
a = np.ones((n, n), dtype=np.float64)
b = np.ones((n, n), dtype=np.float64)
c = np.ones((n, n), dtype=np.float64)
for i in prange(n):
a[i] = b[i] + c[i]


@unittest.skipUnless(ocldrv.has_gpu_device, 'test only on GPU system')
class TestParforMessage(DPPLTestCase):
def test_parfor_message(self):
numba.dppl.compiler.DEBUG = 1
jitted = njit(parallel={'offload':True})(prange_example)

with captured_stdout() as got:
jitted()

self.assertTrue('Parfor lowered on DPPL-device' in got.getvalue())


if __name__ == '__main__':
unittest.main()