I am trying to use my R9 280 GPU with pyopencl but i cant get it to work as my python and pyopencl knowledge is a bit on the dry side. I wonder anyone help me out or at least direct me to the right direction. Below simple python script reads upload.txt to memory and and tries to match randomly created numbers after using basic multiply function. Basicly i cannot write a kernel for this to work. As you see it is only opening the job for gpu and needs a kernel to work on reading the file, checking randomly created numbers and writing the match to a file. Thanks in advance.
#! /usr/bin/env python
import random
import pyopencl as cl
from os import environ, system
def Multiply(x,y):
return 4*y/x
environ["PYOPENCL_CTX"]="0"
ctx = cl.create_some_context()
queue = cl.CommandQueue(ctx)
run = True
target = open("upload.txt", 'rb')
readit = target.read()
while run:
r = 8;
p = random.randrange(1,5000);
q = Multiply(r,p);
z = str(q);
print z;
if z in readit:
file = open('found.txt', 'ab')
file.write(str(z))
file.close()
print "Found ",z
run = False