mirror of
https://github.com/PacktPublishing/Hands-On-GPU-Programming-with-CUDA-C-and-Python-3.x-Second-Edition.git
synced 2025-07-21 12:51:06 +02:00
Create simple_scankernel1.py
This commit is contained in:
10
Chapter03/simple_scankernel1.py
Normal file
10
Chapter03/simple_scankernel1.py
Normal file
@@ -0,0 +1,10 @@
|
||||
import numpy as np
|
||||
import pycuda.autoinit
|
||||
from pycuda import gpuarray
|
||||
from pycuda.scan import InclusiveScanKernel
|
||||
|
||||
seq = np.array([1,100,-3,-10000, 4, 10000, 66, 14, 21],dtype=np.int32)
|
||||
seq_gpu = gpuarray.to_gpu(seq)
|
||||
max_gpu = InclusiveScanKernel(np.int32, "a > b ? a : b")
|
||||
print(max_gpu(seq_gpu).get()[-1])
|
||||
print(np.max(seq))
|
Reference in New Issue
Block a user