numba-cuda 0.6.0__py3-none-any.whl → 0.7.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
numba_cuda/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.0
1
+ 0.7.0
@@ -427,6 +427,8 @@ def kernel_fixup(kernel, debug):
427
427
  if tm_name == 'types':
428
428
  types = tm_value
429
429
  types.operands = types.operands[1:]
430
+ if config.DUMP_LLVM:
431
+ types._clear_string_cache()
430
432
 
431
433
  # Mark as a kernel for NVVM
432
434
 
@@ -199,12 +199,52 @@ class NVVM(object):
199
199
 
200
200
 
201
201
  class CompilationUnit(object):
202
- def __init__(self):
202
+ """
203
+ A CompilationUnit is a set of LLVM modules that are compiled to PTX or
204
+ LTO-IR with NVVM.
205
+
206
+ Compilation options are accepted as a dict mapping option names to values,
207
+ with the following considerations:
208
+
209
+ - Underscores (`_`) in option names are converted to dashes (`-`), to match
210
+ NVVM's option name format.
211
+ - Options that take a value will be emitted in the form "-<name>=<value>".
212
+ - Booleans passed as option values will be converted to integers.
213
+ - Options which take no value (such as `-gen-lto`) should have a value of
214
+ `None` and will be emitted in the form "-<name>".
215
+
216
+ For documentation on NVVM compilation options, see the CUDA Toolkit
217
+ Documentation:
218
+
219
+ https://docs.nvidia.com/cuda/libnvvm-api/index.html#_CPPv418nvvmCompileProgram11nvvmProgramiPPKc
220
+ """
221
+
222
+ def __init__(self, options):
203
223
  self.driver = NVVM()
204
224
  self._handle = nvvm_program()
205
225
  err = self.driver.nvvmCreateProgram(byref(self._handle))
206
226
  self.driver.check_error(err, 'Failed to create CU')
207
227
 
228
+ def stringify_option(k, v):
229
+ k = k.replace('_', '-')
230
+
231
+ if v is None:
232
+ return f'-{k}'.encode('utf-8')
233
+
234
+ if isinstance(v, bool):
235
+ v = int(v)
236
+
237
+ return f'-{k}={v}'.encode('utf-8')
238
+
239
+ options = [stringify_option(k, v) for k, v in options.items()]
240
+ option_ptrs = (c_char_p * len(options))(*[c_char_p(x) for x in options])
241
+
242
+ # We keep both the options and the pointers to them so that options are
243
+ # not destroyed before we've used their values
244
+ self.options = options
245
+ self.option_ptrs = option_ptrs
246
+ self.n_options = len(options)
247
+
208
248
  def __del__(self):
209
249
  driver = NVVM()
210
250
  err = driver.nvvmDestroyProgram(byref(self._handle))
@@ -230,60 +270,35 @@ class CompilationUnit(object):
230
270
  len(buffer), None)
231
271
  self.driver.check_error(err, 'Failed to add module')
232
272
 
233
- def compile(self, **options):
234
- """Perform Compilation.
235
-
236
- Compilation options are accepted as keyword arguments, with the
237
- following considerations:
238
-
239
- - Underscores (`_`) in option names are converted to dashes (`-`), to
240
- match NVVM's option name format.
241
- - Options that take a value will be emitted in the form
242
- "-<name>=<value>".
243
- - Booleans passed as option values will be converted to integers.
244
- - Options which take no value (such as `-gen-lto`) should have a value
245
- of `None` passed in and will be emitted in the form "-<name>".
246
-
247
- For documentation on NVVM compilation options, see the CUDA Toolkit
248
- Documentation:
249
-
250
- https://docs.nvidia.com/cuda/libnvvm-api/index.html#_CPPv418nvvmCompileProgram11nvvmProgramiPPKc
273
+ def verify(self):
251
274
  """
252
-
253
- def stringify_option(k, v):
254
- k = k.replace('_', '-')
255
-
256
- if v is None:
257
- return f'-{k}'
258
-
259
- if isinstance(v, bool):
260
- v = int(v)
261
-
262
- return f'-{k}={v}'
263
-
264
- options = [stringify_option(k, v) for k, v in options.items()]
265
-
266
- c_opts = (c_char_p * len(options))(*[c_char_p(x.encode('utf8'))
267
- for x in options])
268
- # verify
269
- err = self.driver.nvvmVerifyProgram(self._handle, len(options), c_opts)
275
+ Run the NVVM verifier on all code added to the compilation unit.
276
+ """
277
+ err = self.driver.nvvmVerifyProgram(self._handle, self.n_options,
278
+ self.option_ptrs)
270
279
  self._try_error(err, 'Failed to verify\n')
271
280
 
272
- # compile
273
- err = self.driver.nvvmCompileProgram(self._handle, len(options), c_opts)
281
+ def compile(self):
282
+ """
283
+ Compile all modules added to the compilation unit and return the
284
+ resulting PTX or LTO-IR (depending on the options).
285
+ """
286
+ err = self.driver.nvvmCompileProgram(self._handle, self.n_options,
287
+ self.option_ptrs)
274
288
  self._try_error(err, 'Failed to compile\n')
275
289
 
276
- # get result
277
- reslen = c_size_t()
278
- err = self.driver.nvvmGetCompiledResultSize(self._handle, byref(reslen))
290
+ # Get result
291
+ result_size = c_size_t()
292
+ err = self.driver.nvvmGetCompiledResultSize(self._handle,
293
+ byref(result_size))
279
294
 
280
295
  self._try_error(err, 'Failed to get size of compiled result.')
281
296
 
282
- output_buffer = (c_char * reslen.value)()
297
+ output_buffer = (c_char * result_size.value)()
283
298
  err = self.driver.nvvmGetCompiledResult(self._handle, output_buffer)
284
299
  self._try_error(err, 'Failed to get compiled result.')
285
300
 
286
- # get log
301
+ # Get log
287
302
  self.log = self.get_log()
288
303
  if self.log:
289
304
  warnings.warn(self.log, category=NvvmWarning)
@@ -615,40 +630,44 @@ def llvm_replace(llvmir):
615
630
  for decl, fn in replacements:
616
631
  llvmir = llvmir.replace(decl, fn)
617
632
 
618
- llvmir = llvm140_to_70_ir(llvmir)
633
+ llvmir = llvm150_to_70_ir(llvmir)
619
634
 
620
635
  return llvmir
621
636
 
622
637
 
623
- def compile_ir(llvmir, **opts):
638
+ def compile_ir(llvmir, **options):
624
639
  if isinstance(llvmir, str):
625
640
  llvmir = [llvmir]
626
641
 
627
- if opts.pop('fastmath', False):
628
- opts.update({
642
+ if options.pop('fastmath', False):
643
+ options.update({
629
644
  'ftz': True,
630
645
  'fma': True,
631
646
  'prec_div': False,
632
647
  'prec_sqrt': False,
633
648
  })
634
649
 
635
- cu = CompilationUnit()
636
- libdevice = LibDevice()
650
+ cu = CompilationUnit(options)
637
651
 
638
652
  for mod in llvmir:
639
653
  mod = llvm_replace(mod)
640
654
  cu.add_module(mod.encode('utf8'))
655
+ cu.verify()
656
+
657
+ # We add libdevice following verification so that it is not subject to the
658
+ # verifier's requirements
659
+ libdevice = LibDevice()
641
660
  cu.lazy_add_module(libdevice.get())
642
661
 
643
- return cu.compile(**opts)
662
+ return cu.compile()
644
663
 
645
664
 
646
665
  re_attributes_def = re.compile(r"^attributes #\d+ = \{ ([\w\s]+)\ }")
647
666
 
648
667
 
649
- def llvm140_to_70_ir(ir):
668
+ def llvm150_to_70_ir(ir):
650
669
  """
651
- Convert LLVM 14.0 IR for LLVM 7.0.
670
+ Convert LLVM 15.0 IR for LLVM 7.0.
652
671
  """
653
672
  buf = []
654
673
  for line in ir.splitlines():
@@ -261,7 +261,8 @@ class TestLinker(CUDATestCase):
261
261
 
262
262
 
263
263
  @unittest.skipIf(
264
- not PYNVJITLINK_INSTALLED, reason="Pynvjitlink is not installed"
264
+ not PYNVJITLINK_INSTALLED or not TEST_BIN_DIR,
265
+ reason="pynvjitlink not enabled"
265
266
  )
266
267
  class TestLinkerUsage(CUDATestCase):
267
268
  """Test that whether pynvjitlink can be enabled by both environment variable
@@ -1,4 +1,4 @@
1
- from numba.tests.support import override_config
1
+ from numba.tests.support import (override_config, captured_stdout)
2
2
  from numba.cuda.testing import skip_on_cudasim
3
3
  from numba import cuda
4
4
  from numba.core import types
@@ -268,7 +268,7 @@ class TestCudaDebugInfo(CUDATestCase):
268
268
  three_device_fns(kernel_debug=False, leaf_debug=True)
269
269
  three_device_fns(kernel_debug=False, leaf_debug=False)
270
270
 
271
- def test_kernel_args_types(self):
271
+ def _test_kernel_args_types(self):
272
272
  sig = (types.int32, types.int32)
273
273
 
274
274
  @cuda.jit("void(int32, int32)", debug=True, opt=False)
@@ -298,6 +298,15 @@ class TestCudaDebugInfo(CUDATestCase):
298
298
  match = re.compile(pat).search(llvm_ir)
299
299
  self.assertIsNotNone(match, msg=llvm_ir)
300
300
 
301
+ def test_kernel_args_types(self):
302
+ self._test_kernel_args_types()
303
+
304
+ def test_kernel_args_types_dump(self):
305
+ # see issue#135
306
+ with override_config('DUMP_LLVM', 1):
307
+ with captured_stdout():
308
+ self._test_kernel_args_types()
309
+
301
310
 
302
311
  if __name__ == '__main__':
303
312
  unittest.main()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: numba-cuda
3
- Version: 0.6.0
3
+ Version: 0.7.0
4
4
  Summary: CUDA target for Numba
5
5
  Author: Anaconda Inc., NVIDIA Corporation
6
6
  License: BSD 2-clause
@@ -1,6 +1,6 @@
1
1
  _numba_cuda_redirector.pth,sha256=cmfMMmV0JPh3yEpl4bGeM9AuXiVVMSo6Z_b7RaQL3XE,30
2
2
  _numba_cuda_redirector.py,sha256=QKJmYICSQvjvph0Zw9OW015MsuKxIF28GPFjR35AXLM,2681
3
- numba_cuda/VERSION,sha256=l6XW5UCmEg0Jw53bZn4Ojiusf8wv_vgTuC4I_WA2W84,6
3
+ numba_cuda/VERSION,sha256=ln2a-xATRmZxZvLnboGRC8GQSI19QdUMoAcunZLwDjI,6
4
4
  numba_cuda/__init__.py,sha256=atXeUvJKR3JHcAiCFbXCVOJQUHgB1TulmsqSL_9RT3Q,114
5
5
  numba_cuda/_version.py,sha256=jbdUsbR7sVllw0KxQNB0-FMd929CGg3kH2fhHdrlkuc,719
6
6
  numba_cuda/numba/cuda/__init__.py,sha256=idyVHOObC9lTYnp62v7rVprSacRM4d5F6vhXfG5ElTI,621
@@ -9,7 +9,7 @@ numba_cuda/numba/cuda/api_util.py,sha256=aQfUV2-4RM_oGVvckMjbMr5e3effOQNX04v1T0O
9
9
  numba_cuda/numba/cuda/args.py,sha256=HloHkw_PQal2DT-I70Xf_XbnGObS1jiUgcRrQ85Gq28,1978
10
10
  numba_cuda/numba/cuda/cg.py,sha256=9V1uZqyGOJX1aFd9c6GAPbLSqq83lE8LoP-vxxrKENY,1490
11
11
  numba_cuda/numba/cuda/codegen.py,sha256=ghdYBKZ3Mzk2UlLE64HkrAjb60PN9fibSNkWFRQuj4M,13184
12
- numba_cuda/numba/cuda/compiler.py,sha256=aWP_aunOOw8RZsTKf-S3YdH5MDkY6kLN5Xr5B2XgOfk,24214
12
+ numba_cuda/numba/cuda/compiler.py,sha256=zwTPJ7JkW3dj8rkAuYFh3jBSpT4qNow97YcXluhPatI,24323
13
13
  numba_cuda/numba/cuda/cpp_function_wrappers.cu,sha256=iv84_F6Q9kFjV_kclrQz1msh6Dud8mI3qNkswTid7Qc,953
14
14
  numba_cuda/numba/cuda/cuda_fp16.h,sha256=1IC0mdNdkvKbvAe0-f4uYVS7WFrVqOyI1nRUbBiqr6A,126844
15
15
  numba_cuda/numba/cuda/cuda_fp16.hpp,sha256=vJ7NUr2X2tKhAP7ojydAiCoOjVO6n4QGoXD6m9Srrlw,89130
@@ -60,7 +60,7 @@ numba_cuda/numba/cuda/cudadrv/linkable_code.py,sha256=bWBvnndrzWu24SXm7cilCwNFXS
60
60
  numba_cuda/numba/cuda/cudadrv/mappings.py,sha256=-dTPHvAkDjdH6vS5OjgrB71AFuqKO6CRgf7hpOk2wiw,802
61
61
  numba_cuda/numba/cuda/cudadrv/ndarray.py,sha256=HtULWWFyDlgqvrH5459yyPTvU4UbUo2DSdtcNfvbH00,473
62
62
  numba_cuda/numba/cuda/cudadrv/nvrtc.py,sha256=XM9_Vllv7HzH5wZIR2lwFictyX68XDtNbyLkXlL6NTI,11003
63
- numba_cuda/numba/cuda/cudadrv/nvvm.py,sha256=cAoQmZ0bO8i3wPTQq5D0UeMtfnXdGebqYpU4W0kUIEY,24237
63
+ numba_cuda/numba/cuda/cudadrv/nvvm.py,sha256=AgrWDNnGfIjvnTsQcEix60EnhFSI8Nbg7oOf5VWk87g,25038
64
64
  numba_cuda/numba/cuda/cudadrv/rtapi.py,sha256=WdeUoWzsYNYodx8kMRLVIjnNs0QzwpCihd2Q0AaqItE,226
65
65
  numba_cuda/numba/cuda/cudadrv/runtime.py,sha256=Tj9ACrzQqNmDSO6xfpzw12EsQknSywQ-ZGuWMbDdHnQ,4255
66
66
  numba_cuda/numba/cuda/kernels/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -111,7 +111,7 @@ numba_cuda/numba/cuda/tests/cudadrv/test_is_fp16.py,sha256=0KPe4E9wOZsSV_0QI0Lmj
111
111
  numba_cuda/numba/cuda/tests/cudadrv/test_linker.py,sha256=_l2_EQEko2Jet5ooj4XMT0L4BjOuqLjbONGj1_MVI50,10161
112
112
  numba_cuda/numba/cuda/tests/cudadrv/test_managed_alloc.py,sha256=kYXYMkx_3GPAITKp4reLeM8KSzKkpxiC8nxnBvXpaTA,4979
113
113
  numba_cuda/numba/cuda/tests/cudadrv/test_mvc.py,sha256=984jATSa01SRoSrVqxPeO6ujJ7w2jsnZa39ABInFLVI,1529
114
- numba_cuda/numba/cuda/tests/cudadrv/test_nvjitlink.py,sha256=oZywLDuX-l1LJvIIU4QCsE7UCwtIKbBP7u6GxVDpD_g,11316
114
+ numba_cuda/numba/cuda/tests/cudadrv/test_nvjitlink.py,sha256=EPS4-U2tnqFCG-QF-9j2POMKaYiWogHIbpknMwdYGD8,11335
115
115
  numba_cuda/numba/cuda/tests/cudadrv/test_nvvm_driver.py,sha256=DF7KV5uh-yMztks0f47NhpalV64dvsNy-f8HY6GhAhE,7373
116
116
  numba_cuda/numba/cuda/tests/cudadrv/test_pinned.py,sha256=u_TthSS2N-2J4eBIuF4PGg33AjD-wxly7MKpz0vRAKc,944
117
117
  numba_cuda/numba/cuda/tests/cudadrv/test_profiler.py,sha256=MQWZx1j3lbEpWmIpQ1bV9szrGOV3VHN0QrEnJRjAhW4,508
@@ -146,7 +146,7 @@ numba_cuda/numba/cuda/tests/cudapy/test_cuda_array_interface.py,sha256=73FCQbNaA
146
146
  numba_cuda/numba/cuda/tests/cudapy/test_cuda_jit_no_types.py,sha256=y7cNQZOZJo5Sv16ql3E5QaRksw-U3RkXss9YDcNeiTk,2137
147
147
  numba_cuda/numba/cuda/tests/cudapy/test_datetime.py,sha256=2in1Cq8y9zAFoka7H72wF1D0awEd3n7bv56sUPgoNAQ,3508
148
148
  numba_cuda/numba/cuda/tests/cudapy/test_debug.py,sha256=3MYNiMe75rgBF1T0vsJ7r-nkW5jPvov_tDms9KXo2UU,3449
149
- numba_cuda/numba/cuda/tests/cudapy/test_debuginfo.py,sha256=jI43jMbPS9Rbr3YI2mZBrDwH9MGjmyVlczv7QxxPoAs,10993
149
+ numba_cuda/numba/cuda/tests/cudapy/test_debuginfo.py,sha256=SbeIIASsv5eZapp6i9KZlztN3-OPFiXg6YmtbYIh0eY,11288
150
150
  numba_cuda/numba/cuda/tests/cudapy/test_device_func.py,sha256=eDVymTQXTzW0WeAgTMDKYtOi1YAM310IUxGp3Y1ICjs,13162
151
151
  numba_cuda/numba/cuda/tests/cudapy/test_dispatcher.py,sha256=oX-l_L4H8rME1IolwhAyordSGJ152nnuqGAFdWjfgas,26587
152
152
  numba_cuda/numba/cuda/tests/cudapy/test_enums.py,sha256=0GWiwvZ1FTzSl1FfMxttkWaWrowASfXrSDT8XAR4ZHw,3560
@@ -245,8 +245,8 @@ numba_cuda/numba/cuda/tests/test_binary_generation/Makefile,sha256=P2WzCc5d64JGq
245
245
  numba_cuda/numba/cuda/tests/test_binary_generation/generate_raw_ltoir.py,sha256=V0raLZLGSiWbE_K-JluI0CnmNkXbhlMVj-TH7P1OV8E,5014
246
246
  numba_cuda/numba/cuda/tests/test_binary_generation/test_device_functions.cu,sha256=cUf-t6ZM9MK_x7X_aKwsrKW1LdR97XcpR-qnYr5faOE,453
247
247
  numba_cuda/numba/cuda/tests/test_binary_generation/undefined_extern.cu,sha256=q3oxZziT8KDodeNcEBiWULH6vMrHCWucmJmtrg8C0d0,128
248
- numba_cuda-0.6.0.dist-info/LICENSE,sha256=eHeYE-XjASmwbxfsP5AImgfzRwZurZGqH1f6OFwJ4io,1326
249
- numba_cuda-0.6.0.dist-info/METADATA,sha256=iNU56EXHsnAcAcwgNXglPh6H47Quz31_-6r9RevpJ_Q,1836
250
- numba_cuda-0.6.0.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
251
- numba_cuda-0.6.0.dist-info/top_level.txt,sha256=C50SsH-8tXDmt7I0Y3nlJYhS5s6pqWflCPdobe9vx2M,11
252
- numba_cuda-0.6.0.dist-info/RECORD,,
248
+ numba_cuda-0.7.0.dist-info/LICENSE,sha256=eHeYE-XjASmwbxfsP5AImgfzRwZurZGqH1f6OFwJ4io,1326
249
+ numba_cuda-0.7.0.dist-info/METADATA,sha256=tq7106PKB0M6Qf-HpEjH_BoUBndW2MA7XsFVAKmbbqc,1836
250
+ numba_cuda-0.7.0.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
251
+ numba_cuda-0.7.0.dist-info/top_level.txt,sha256=C50SsH-8tXDmt7I0Y3nlJYhS5s6pqWflCPdobe9vx2M,11
252
+ numba_cuda-0.7.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.8.2)
2
+ Generator: setuptools (76.0.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5