Skip to content
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
2 changes: 1 addition & 1 deletion numba_cuda/numba/cuda/core/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from numba.core.errors import CompilerError
from numba.parfors.parfor import ParforDiagnostics

from numba.core.untyped_passes import ExtractByteCode, FixupArgs
from numba.cuda.core.untyped_passes import ExtractByteCode, FixupArgs
from numba.core.targetconfig import ConfigStack


Expand Down
2 changes: 1 addition & 1 deletion numba_cuda/numba/cuda/core/compiler_machinery.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from numba.cuda import utils
from numba.core.tracing import event
from numba.core.postproc import PostProcessor
from numba.core.ir_utils import enforce_no_dels, legalize_single_scope
from numba.cuda.core.ir_utils import enforce_no_dels, legalize_single_scope
import numba.core.event as ev

import numba.core.compiler_machinery as nccm
Expand Down
6 changes: 3 additions & 3 deletions numba_cuda/numba/cuda/core/ir_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1893,7 +1893,7 @@ def compile_to_numba_ir(
if typingctx and other typing inputs are available and update typemap and
calltypes.
"""
from numba.core import typed_passes
from numba.cuda.core import typed_passes

# mk_func can be actual function or make_function node, or a njit function
if hasattr(mk_func, "code"):
Expand Down Expand Up @@ -2013,8 +2013,8 @@ def __init__(self, f_ir):
# added to create valid IR.

# rebuild IR in SSA form
from numba.core.untyped_passes import ReconstructSSA
from numba.core.typed_passes import PreLowerStripPhis
from numba.cuda.core.untyped_passes import ReconstructSSA
from numba.cuda.core.typed_passes import PreLowerStripPhis

reconstruct_ssa = ReconstructSSA()
phistrip = PreLowerStripPhis()
Expand Down
2 changes: 1 addition & 1 deletion numba_cuda/numba/cuda/core/typed_passes.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
register_pass,
)
from numba.core.annotations import type_annotations
from numba.core.ir_utils import (
from numba.cuda.core.ir_utils import (
raise_on_unsupported_feature,
warn_deprecated,
check_and_legalize_ir,
Expand Down
2 changes: 1 addition & 1 deletion numba_cuda/numba/cuda/core/untyped_passes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1868,7 +1868,7 @@ def run_pass(self, state):
return False

# run as subpipeline
from numba.cuda.compiler_machinery import PassManager
from numba.cuda.core.compiler_machinery import PassManager
from numba.cuda.core.typed_passes import PartialTypeInference

pm = PassManager("literal_unroll_subpipeline")
Expand Down
2 changes: 1 addition & 1 deletion numba_cuda/numba/cuda/cuda_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import site
from pathlib import Path
from numba.core.config import IS_WIN32
from numba.misc.findlib import find_lib
from numba.cuda.misc.findlib import find_lib
from numba import config
import ctypes

Expand Down
2 changes: 1 addition & 1 deletion numba_cuda/numba/cuda/cudadrv/libs.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import sys
import ctypes

from numba.misc.findlib import find_lib
from numba.cuda.misc.findlib import find_lib
from numba.cuda.cuda_paths import get_cuda_paths
from numba.cuda.cudadrv.driver import locate_driver_and_loader, load_driver
from numba.cuda.cudadrv.error import CudaSupportError
Expand Down
71 changes: 71 additions & 0 deletions numba_cuda/numba/cuda/misc/findlib.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause

import sys
import os
import re


def get_lib_dirs():
"""
Anaconda specific
"""
if sys.platform == "win32":
# on windows, historically `DLLs` has been used for CUDA libraries,
# since approximately CUDA 9.2, `Library\bin` has been used.
dirnames = ["DLLs", os.path.join("Library", "bin")]
else:
dirnames = [
"lib",
]
libdirs = [os.path.join(sys.prefix, x) for x in dirnames]
return libdirs


DLLNAMEMAP = {
"linux": r"lib%(name)s\.so\.%(ver)s$",
"linux2": r"lib%(name)s\.so\.%(ver)s$",
"linux-static": r"lib%(name)s\.a$",
"darwin": r"lib%(name)s\.%(ver)s\.dylib$",
"win32": r"%(name)s%(ver)s\.dll$",
"win32-static": r"%(name)s\.lib$",
"bsd": r"lib%(name)s\.so\.%(ver)s$",
}

RE_VER = r"[0-9]*([_\.][0-9]+)*"


def find_lib(libname, libdir=None, platform=None, static=False):
platform = platform or sys.platform
platform = "bsd" if "bsd" in platform else platform
if static:
platform = f"{platform}-static"
if platform not in DLLNAMEMAP:
# Return empty list if platform name is undefined.
# Not all platforms define their static library paths.
return []
pat = DLLNAMEMAP[platform] % {"name": libname, "ver": RE_VER}
regex = re.compile(pat)
return find_file(regex, libdir)


def find_file(pat, libdir=None):
if libdir is None:
libdirs = get_lib_dirs()
elif isinstance(libdir, str):
libdirs = [
libdir,
]
else:
libdirs = list(libdir)
files = []
for ldir in libdirs:
try:
entries = os.listdir(ldir)
except FileNotFoundError:
continue
candidates = [
os.path.join(ldir, ent) for ent in entries if pat.match(ent)
]
files.extend([c for c in candidates if os.path.isfile(c)])
return files
2 changes: 1 addition & 1 deletion numba_cuda/numba/cuda/tests/cudadrv/test_cuda_libraries.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from numba.cuda.testing import unittest
from numba.cuda.testing import skip_on_cudasim, skip_unless_conda_cudatoolkit
from numba.misc.findlib import find_lib
from numba.cuda.misc.findlib import find_lib


@skip_on_cudasim("Library detection unsupported in the simulator")
Expand Down
13 changes: 7 additions & 6 deletions numba_cuda/numba/cuda/tests/cudapy/test_ir_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@
from numba.cuda.testing import CUDATestCase
import numba
from numba.core.registry import cpu_target
from numba.core.compiler import CompilerBase, Flags
from numba.core.compiler_machinery import PassManager
from numba.cuda.core import ir_utils, bytecode
from numba.core import types, ir, compiler, registry
from numba.core.untyped_passes import (
from numba.cuda.core.compiler import CompilerBase
from numba.cuda.flags import Flags
from numba.cuda.core.compiler_machinery import PassManager
from numba.cuda.core import ir_utils
from numba.core import types, ir, bytecode, compiler, registry
from numba.cuda.core.untyped_passes import (
ExtractByteCode,
TranslateByteCode,
FixupArgs,
IRProcessing,
)
from numba.experimental import jitclass
from numba.core.typed_passes import (
from numba.cuda.core.typed_passes import (
NopythonTypeInference,
type_inference_stage,
DeadCodeElimination,
Expand Down
4 changes: 2 additions & 2 deletions numba_cuda/numba/cuda/typing/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ def generic(self, args, kws):
Type the overloaded function by compiling the appropriate
implementation for the given args.
"""
from numba.core.typed_passes import PreLowerStripPhis
from numba.cuda.core.typed_passes import PreLowerStripPhis

disp, new_args = self._get_impl(args, kws)
if disp is None:
Expand All @@ -658,7 +658,7 @@ def generic(self, args, kws):
if not self._inline.is_never_inline:
# need to run the compiler front end up to type inference to compute
# a signature
from numba.core import typed_passes, compiler
from numba.cuda.core import typed_passes, compiler
from numba.core.inline_closurecall import InlineWorker

fcomp = disp._compiler
Expand Down