Hi,

I'm trying to do some updates to a state which is a binary array. gputid is
a GPU thread class (https://wiki.tiker.net/PyCuda/Examples/MultipleThreads)
and it stores the state and the index of the array to be updated in another
class which can be accessed with gputid.mp.x_gpu and gputid.mp.neuron_gpu
respectively. Below is my kernel that takes in the gputid and performs the
update of the state. However, it the output of the code is not consistent
as it runs into errors and executes perfectly when i run it multiple times.
The error msg makes no sense to me:

File "/root/anaconda3/lib/python3.6/site-packages/pycuda/driver.py", line
447, in function_prepared_call
    func._set_block_shape(*block)
pycuda._driver.LogicError: cuFuncSetBlockShape failed: invalid resource
handle


My code:

def local_update(gputid):
    mod = SourceModule("""
    __global__ void local_update(int *x_gpu, float *n_gpu)
    {
        int tid = threadIdx.x + blockDim.x * blockIdx.x;

        if (tid == (int)(n_gpu[0]))
        {
            x_gpu[tid] = 1 - x_gpu[tid];
        }
    }
    """)

    gputid.ctx.push()
    x_gpu = gputid.mp.x_gpu
    n_gpu = gputid.mp.neuron_gpu

    func = mod.get_function("local_update")
    func.prepare("PP")


    grid = (1,1)
    block = (gputid.mp.d,1,1)

    func.prepared_call(grid, block, x_gpu, n_gpu)
    gputid.ctx.pop()
    print ('1Pain')
_______________________________________________
PyCUDA mailing list
PyCUDA@tiker.net
https://lists.tiker.net/listinfo/pycuda

Reply via email to