Statistiques
| Révision :

root / Epidevomath / float.py @ 109

Historique | Voir | Annoter | Télécharger (652 octet)

1
import numpy as np
2
import pyopencl as cl
3
import pyopencl.array as cl_array
4

    
5

    
6
deviceID = 0
7
platformID = 0
8
workGroup=(1,1)
9

    
10
N = 10
11
testData = np.zeros(N, dtype=cl_array.vec.float4)
12

    
13
dev = cl.get_platforms()[platformID].get_devices()[deviceID]
14

    
15
ctx = cl.Context([dev])
16
queue = cl.CommandQueue(ctx)
17
mf = cl.mem_flags
18
Data_In = cl.Buffer(ctx, mf.READ_WRITE, testData.nbytes)
19

    
20

    
21
prg = cl.Program(ctx, """
22

23
__kernel void   Pack_Cmplx( __global float4* Data_In, int  N)
24
{
25
  int gid = get_global_id(0);
26

27
  Data_In[gid] = 1;
28
}
29
 """).build()
30

    
31
prg.Pack_Cmplx(queue, (N,1), workGroup, Data_In, np.int32(N))
32
cl.enqueue_copy(queue, testData, Data_In)
33

    
34

    
35
print testData