copperhead icon indicating copy to clipboard operation
copperhead copied to clipboard

error: no suitable user-defined conversion from "Tresult" to "copperhead::sequence<copperhead::cuda_tag, long, 0>" exists

Open dybber opened this issue 11 years ago • 0 comments

I get this error from trying to execute the following program. Calling sobol directly works fine, but when mapping in sobol1D something goes wrong.

from math import sqrt, trunc
from copperhead import *
import numpy as np

dirvs0 = cuarray(np.array([2147483648,1073741824,2684354560,1342177280,
                           2281701376,603979776,301989888,754974720,
                           1988100096,2654994432,136314880,1678770176,
                           2988965888,2098462720,4272029696,3125346304,
                           438599680,1226522624,3300237312,3816001536,
                           4135585792,3728737280,2820672000,873465088,
                           975702144,1494483520,3970040096,2538144464,
                           1822721896,3613084132,3432358018,2271450689]
                          ,dtype=np.int64))

@cu
def normalise(x):
    twoPow32 = 4294967296
    return float32(x) / twoPow32 # pow(2.0, 32)

@cu
def bitVector(e):
    n_directions = 32
    def isbitset(i):
        if (e & (1 << i)) > 0:
            return 1
        else:
            return 0
    return map(isbitset, range(n_directions))

@cu
def sobol(v,i):
    return normalise(reduce(op_xor,(map(op_mul, v, bitVector(i))),0))

@cu
def sobol1D(v,m):
    def f(i):
        return sobol(v,i)
    return map(f, range(m+1))

print(sobol1D(dirvs0,10))

I can attach the complete error message if you are not able to reproduce it

dybber avatar May 02 '13 14:05 dybber