Skip to content

Simplify and organize gdb tests #1224

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Mar 22, 2024
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
15 changes: 13 additions & 2 deletions .github/workflows/conda-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,11 @@ jobs:
- name: Run gdb tests
if: ${{ matrix.scope == 'gdb' }}
env:
GDB_URL: https://registrationcenter-download.intel.com/akdlm/IRC_NAS/fcea1bcd-6a63-4849-b304-906ff71dc2c0/l_dpcpp_dbg_p_2023.2.0.49333_offline.sh
GDB_INSTALLER: l_dpcpp_dbg_p_2023.2.0.49333_offline.sh
GDB_URL: https://registrationcenter-download.intel.com/akdlm/IRC_NAS/72038301-92f9-4db2-8fe0-db1fe9e9bca9/l_dpcpp_dbg_p_2024.0.1.9_offline.sh
GDB_INSTALLER: l_dpcpp_dbg_p_2024.0.1.9_offline.sh
# To read gdb communication in case test fails to determine what the
# issue is
NUMBA_DPEX_TESTING_LOG_DEBUGGING: 1
run: |
conda install pexpect
wget -nc -q ${{ env.GDB_URL }}
Expand All @@ -264,6 +267,14 @@ jobs:
export ONEAPI_ROOT=/tmp/gdb
./${{ env.GDB_INSTALLER }} -a -s --eula accept --install-dir $ONEAPI_ROOT
source $ONEAPI_ROOT/debugger/latest/env/vars.sh
# We match only major and minor version because latest gdb is not
# often available.
gdb_version=$(echo "$GDB_INSTALLER" | grep -oP '\d+\.\d+' | head -n 1)
icpx_version=$(conda list dpcpp-cpp-rt | tail -n 1 | awk '{print $2}' | grep -oP '\d+\.\d+')
if [ "$gdb_version" != "$icpx_version" ]; then
echo "Error: GDB version ($gdb_version) does not match icpx version ($icpx_version)"
exit 1
fi
pytest -q -ra --disable-warnings --pyargs ${{ env.MODULE_NAME }}.tests.debugging -vv

upload_anaconda:
Expand Down
17 changes: 12 additions & 5 deletions numba_dpex/examples/debug/side-by-side-2.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import argparse

import dpctl
import dpnp
import numba
import numpy as np

Expand All @@ -24,33 +25,39 @@ def scenario(api):
print("Using API:", api)

global_size = 10
a, b, c = arguments(global_size)

if api == "numba-ndpx-kernel":
a, b, c = ndpx_arguments(global_size)
ndpx_func_driver(a, b, c)
else:
a, b, c = numba_arguments(global_size)
numba_func_driver(a, b, c)

print(a, b, c, sep="\n")


def arguments(N, dtype=np.float32):
def numba_arguments(N, dtype=np.float32):
a = np.arange(N, dtype=dtype)
b = np.arange(N, dtype=dtype)
c = np.empty_like(a)
return a, b, c


def ndpx_arguments(N, dtype=dpnp.float32):
a = dpnp.arange(N, dtype=dtype)
b = dpnp.arange(N, dtype=dtype)
c = dpnp.empty_like(a)
return a, b, c


@numba.njit(debug=True)
def numba_func_driver(a, b, c):
for i in range(len(c)):
c[i] = numba_loop_body(i, a, b)


def ndpx_func_driver(a, b, c):
device = dpctl.select_default_device()
with dpctl.device_context(device):
kernel[ndpx.Range(len(c))](a, b, c)
kernel[ndpx.Range(len(c))](a, b, c)


@ndpx.kernel(debug=True)
Expand Down
21 changes: 14 additions & 7 deletions numba_dpex/examples/debug/side-by-side.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
import argparse

import dpctl
import dpnp
import numba
import numpy as np

import numba_dpex as ndpx


def common_loop_body(param_a, param_b):
param_c = param_a + 10 # Set breakpoint here
param_d = param_b * 0.5
param_c = param_a + numba.float32(10) # Set breakpoint here
param_d = param_b * numba.float32(0.5)
result = param_c + param_d
return result

Expand All @@ -22,33 +23,39 @@ def scenario(api):
print("Using API:", api)

global_size = 10
a, b, c = arguments(global_size)

if api == "numba-ndpx-kernel":
a, b, c = ndpx_arguments(global_size)
ndpx_func_driver(a, b, c)
else:
a, b, c = numba_arguments(global_size)
numba_func_driver(a, b, c)

print(a, b, c, sep="\n")


def arguments(N, dtype=np.float32):
def numba_arguments(N, dtype=np.float32):
a = np.arange(N, dtype=dtype)
b = np.arange(N, dtype=dtype)
c = np.empty_like(a)
return a, b, c


def ndpx_arguments(N, dtype=dpnp.float32):
a = dpnp.arange(N, dtype=dtype)
b = dpnp.arange(N, dtype=dtype)
c = dpnp.empty_like(a)
return a, b, c


@numba.njit(debug=True)
def numba_func_driver(a, b, c):
for i in range(len(c)):
c[i] = numba_loop_body(a[i], b[i])


def ndpx_func_driver(a, b, c):
device = dpctl.select_default_device()
with dpctl.device_context(device):
kernel[ndpx.Range(len(c))](a, b, c)
kernel[ndpx.Range(len(c))](a, b, c)


@ndpx.kernel(debug=True)
Expand Down
1 change: 0 additions & 1 deletion numba_dpex/examples/debug/simple_sum.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#
# SPDX-License-Identifier: Apache-2.0

import dpctl
import dpnp as np

import numba_dpex as ndpx
Expand Down
5 changes: 0 additions & 5 deletions numba_dpex/tests/_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,11 @@ def is_windows():
pytest.param("level_zero:gpu:0", marks=skip_no_level_zero_gpu),
]

skip_no_numba056 = pytest.mark.skipif(
numba_sem_version < (0, 56), reason="Need Numba 0.56 or higher"
)

skip_no_gdb = pytest.mark.skipif(
config.TESTING_SKIP_NO_DEBUGGING and not shutil.which("gdb-oneapi"),
reason="Intel® Distribution for GDB* is not available",
)


decorators = [
pytest.param(dpjit, id="dpjit"),
pytest.param(
Expand Down
65 changes: 0 additions & 65 deletions numba_dpex/tests/debugging/common.py

This file was deleted.

8 changes: 6 additions & 2 deletions numba_dpex/tests/debugging/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@

import pytest

from .gdb import gdb


@pytest.fixture
def app():
from .gdb import gdb
g = gdb()

yield g

return gdb()
g.teardown_gdb()
Loading