Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PYCUDA setting NVCC arguments

Tags:

python

pycuda

if i have any small pycuda code such as the one below, how can i access options of the nvcc compiler? for example if i want to set -maxrregcount 20 (or any other argument), how would i accomplish that>

import pycuda.autoinit
import pycuda.driver as drv
import numpy

from pycuda.compiler import SourceModule
mod = SourceModule("""
__global__ void multiply_them(float *dest, float *a, float *b)
{
  const int i = threadIdx.x;
  dest[i] = a[i] * b[i];
}
""")

multiply_them = mod.get_function("multiply_them")

a = numpy.random.randn(400).astype(numpy.float32)
b = numpy.random.randn(400).astype(numpy.float32)

dest = numpy.zeros_like(a)
multiply_them(
        drv.Out(dest), drv.In(a), drv.In(b),
        block=(400,1,1), grid=(1,1))

print dest-a*b
like image 237
Hannan Avatar asked Sep 05 '26 02:09

Hannan


1 Answers

well i found that the answer is rather simple all we need to do is add the code below..

mod = SourceModule("""
__global__ void multiply_them(float *dest, float *a, float *b)
{
  const int i = threadIdx.x;
  dest[i] = a[i] * b[i];
}
""",options=['--maxrregcount=20'])
like image 183
Hannan Avatar answered Sep 07 '26 16:09

Hannan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!