Skip to main content

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 numba_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


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.2.tar.gz (1.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

numba_timer-0.1.2-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

Details for the file numba_timer-0.1.2.tar.gz.

File metadata

  • Download URL: numba_timer-0.1.2.tar.gz
  • Upload date:
  • Size: 1.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.7.5

File hashes

Hashes for numba_timer-0.1.2.tar.gz
Algorithm Hash digest
SHA256 730ef9516d6fddb35269c86029602bc13e5aa91a85ead3345901f8e20be43ca4
MD5 7b27d3863189c6bef6bdd4e9d9bd8aac
BLAKE2b-256 7822228e5e5e29ee2b53c8f7fed638c49e8705cacd73a0595236a7053e8674a3

See more details on using hashes here.

File details

Details for the file numba_timer-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: numba_timer-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 3.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.7.5

File hashes

Hashes for numba_timer-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0493c51d4624c139d30de5123d19b70e54dec7885a095cbaa97bf66778fbec0b
MD5 eced1fc1e3ba52ca7439c14dcc3dcf3c
BLAKE2b-256 81fd202c5d3782e465b9e622091214240b463ee95955156dbdcf4cf9ffdcbe1c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page