Skip to content

Error with Scan and temp_array #49

Description

@jejmule

Hello, I have issue using temporary array with a Scan. Here is my test code that compare the result with numpy :

import numpy as np
import reikna.cluda as cluda
from reikna.algorithms import Transpose, Scan, predicate_sum

api = cluda.ocl_api()
platforms = api.get_platforms()
#find AMD or NVIDIA platforms : I have a laptop I use that to avoid intel GPU
for platform in platforms :
if 'AMD' in str(platform) or 'NVIDIA' in str(platform):
break;

thread = api.Thread(platform.get_devices()[0])

data = np.random.rand(500,500,50).astype(np.float)2np.pi
axis = 2

data_gpu = thread.to_device(data)
temp = thread.temp_array(data.shape,np.float)
array =thread.array(data.shape,np.float)

program = Scan(data_gpu, predicate_sum(np.float),axes=[axis])
cumsum = program.compile(thread)
cumsum(temp,data_gpu)
cumsum(array,data_gpu)

res_temp = temp.get()
res_array = array.get()
res_numpy = np.cumsum(data,axis=axis)

print('Temp array error',np.linalg.norm(np.abs(res_temp)-np.abs(res_numpy)))
print('Array error',np.linalg.norm(np.abs(res_array)-np.abs(res_numpy)))

I do not retrieve the same result in both case. I am using a Scan in a larger program where I want to store the result of the Scan in a temporary array.

Can you help me to use temporary array in a Scan? Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions