A helper package to easily time Numba CUDA GPU events
Project description
Numba GPU Timer
A helper package to easily time Numba CUDA GPU events.
Compatibility
As this package uses Numba, refer to the Numba compatibility guide.
Installation
Using Pip: pip3 install gpu_timer
.
Example
import math
import numpy as np
from numba import cuda
from numba_timer import cuda_timer
@cuda.jit
def increment_a_2D_array(an_array):
x, y = cuda.grid(2)
if x < an_array.shape[0] and y < an_array.shape[1]:
an_array[x, y] += 1
an_array = np.zeros((2, 100))
threadsperblock = (16, 16)
blockspergrid_x = math.ceil(an_array.shape[0] / threadsperblock[0])
blockspergrid_y = math.ceil(an_array.shape[1] / threadsperblock[1])
blockspergrid = (blockspergrid_x, blockspergrid_y)
timer = cuda_timer.Timer()
timer.start()
increment_a_2D_array[blockspergrid, threadsperblock](an_array)
timer.stop()
print(f'Elapsed time for run 1: {timer.elapsed()} ms')
timer.start()
increment_a_2D_array[blockspergrid, threadsperblock](an_array)
timer.stop()
print(f'Elapsed time for run 2: {timer.elapsed()} ms')
Numba specific code is borrowed from the Numba documentation.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
numba_timer-0.1.1.tar.gz
(2.0 kB
view hashes)
Built Distribution
Close
Hashes for numba_timer-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba38389f837e4cef23a32705d307e5ad124056d9dbdfb82433601f4924f8219b |
|
MD5 | c05f110d940b546e8bc00dc31ae976c9 |
|
BLAKE2b-256 | 21384e39b2173388132fa21fe4d469516b1e1430b91298f0946dea1ce7525ebe |