def process_results(out, xout, rout, Nglobal): print "NUM 0 coords:", sum(out.get() == 0.0) if int( os.popen( "diff ../test/test1.pdb ../test/test2.pdb | wc -l").read()): print "OUTPUTS DO NOT MATCH!!!!!!!!!!" else: print "OUTPUTS MATCH!" if int( os.popen("diff ../test/test1.pdb ../test/test1.pdb.last | wc -l"). read()): print "OUTPUT DOES NOT MATCH PREVIOUS!!!!!!!!!!" else: print "PREVIOUS OUTPUT MATCHS!" xform_pdb( nparray_to_XFORMs(xout.get())[0], "../pdb/hyda1_hash.pdb", "../test/hyda1_xform.pdb") xform_pdb( nparray_to_XFORMs(xout.get())[1], "../pdb/petf_hash.pdb", "../test/petf_xform.pdb") print rout ary = out.get() for i in range(Nglobal): dump_pdb(ary[i * len(ary) / Nglobal:(i + 1) * len(ary) / Nglobal], "../test/GI_%i.pdb" % i)
def test(): Nlocal = 64 Nglobal = 1024 ctx,queue = my_get_gpu_context() # inputs components = "psi hyd pet ldn lec".split() coords = [xyzHash("../dat/%s.xyzHash"%n).get_coord_clarray(queue) for n in components] if components[3][-1]=="c": hyd_stub = "stubrev(vec"+str(hyd_N_N)+",vec"+str(hyd_N_CA)+",vec"+str(hyd_N_C)+")" elif components[3][-1]=="n": hyd_stub = "stubrev(vec"+str(hyd_C_C)+",vec"+str(hyd_C_CA)+",vec"+str(hyd_C_N)+")" else: assert "CAN'T DETERMINE ORIENTATIN OF HYDA1 LINKER!!!"==None if components[4][-1]=="c": pet_stub = "stubrev(vec"+str(pet_N_N)+",vec"+str(pet_N_CA)+",vec"+str(pet_N_C)+")" elif components[4][-1]=="n": pet_stub = "stubrev(vec"+str(pet_C_C)+",vec"+str(pet_C_CA)+",vec"+str(pet_C_N)+")" else: assert "CAN'T DETERMINE ORIENTATIN OF HYDA1 LINKER!!!"==None npsi,nhyd,npet = (coords[i].size/3 for i in (0,1,2)) nlkh,nlkp = 23*3,32*3 ntot = npsi+nhyd+npet+nlkh+nlkp ranlux = pyopencl.array.empty(queue, (112*Nglobal,), dtype=numpy.int8); ranlux.fill(17) python_seed = random.getrandbits(31) # outputs out = pyopencl.array.empty(queue, (3*ntot*Nglobal,), dtype=numpy.float32) print out.size*4/1024/1024 xout = pyopencl.array.empty(queue, (12*10,) , dtype=numpy.float32) rout = pyopencl.array.empty(queue, (Nglobal,) , dtype=numpy.float32) # run kargs = [x.data for x in coords+[ranlux,out,xout,rout] ] if os.path.exists("../test/test1.pdb"): os.rename("../test/test1.pdb","../test/test1.pdb.last") print "build" my_test_kernel = pyopencl.Program(ctx,KERN%vars()).build(OPTS).my_test_kernel # print "run 1" # my_test_kernel(queue,( 1 ,Nglobal),( 1 ,1), *kargs ); dump_pdb(out.get()[0:],"../test/test1.pdb") print "run 2" my_test_kernel(queue,(Nlocal,Nglobal),(Nlocal,1), *kargs ); dump_pdb(out.get()[0:],"../test/test2.pdb")
def process_results(out,xout,rout,NG): print "NUM 0 coords:",sum(out.get()==0.0) if int(os.popen("diff ../test/test1.pdb ../test/test2.pdb | wc -l").read()): print "OUTPUTS DO NOT MATCH!!!!!!!!!!" else: print "OUTPUTS MATCH!" if int(os.popen("diff ../test/test1.pdb ../test/test1.pdb.last | wc -l").read()): print "OUTPUT DOES NOT MATCH PREVIOUS!!!!!!!!!!" else: print "PREVIOUS OUTPUT MATCHS!" ary = out.get() for i in range(NG): dump_pdb(ary[i*len(ary)/NG:(i+1)*len(ary)/NG],"../test/GI_%i.pdb"%i)
def test(): Nlocal = 64 Nglobal = 1024 ctx, queue = my_get_gpu_context() # inputs components = "psi hyd pet ldn lec".split() coords = [ xyzHash("../dat/%s.xyzHash" % n).get_coord_clarray(queue) for n in components ] if components[3][-1] == "c": hyd_stub = "stubrev(vec" + str(hyd_N_N) + ",vec" + str( hyd_N_CA) + ",vec" + str(hyd_N_C) + ")" elif components[3][-1] == "n": hyd_stub = "stubrev(vec" + str(hyd_C_C) + ",vec" + str( hyd_C_CA) + ",vec" + str(hyd_C_N) + ")" else: assert "CAN'T DETERMINE ORIENTATIN OF HYDA1 LINKER!!!" == None if components[4][-1] == "c": pet_stub = "stubrev(vec" + str(pet_N_N) + ",vec" + str( pet_N_CA) + ",vec" + str(pet_N_C) + ")" elif components[4][-1] == "n": pet_stub = "stubrev(vec" + str(pet_C_C) + ",vec" + str( pet_C_CA) + ",vec" + str(pet_C_N) + ")" else: assert "CAN'T DETERMINE ORIENTATIN OF HYDA1 LINKER!!!" == None npsi, nhyd, npet = (coords[i].size / 3 for i in (0, 1, 2)) nlkh, nlkp = 23 * 3, 32 * 3 ntot = npsi + nhyd + npet + nlkh + nlkp ranlux = pyopencl.array.empty(queue, (112 * Nglobal, ), dtype=numpy.int8) ranlux.fill(17) python_seed = random.getrandbits(31) # outputs out = pyopencl.array.empty(queue, (3 * ntot * Nglobal, ), dtype=numpy.float32) print out.size * 4 / 1024 / 1024 xout = pyopencl.array.empty(queue, (12 * 10, ), dtype=numpy.float32) rout = pyopencl.array.empty(queue, (Nglobal, ), dtype=numpy.float32) # run kargs = [x.data for x in coords + [ranlux, out, xout, rout]] if os.path.exists("../test/test1.pdb"): os.rename("../test/test1.pdb", "../test/test1.pdb.last") print "build" my_test_kernel = pyopencl.Program(ctx, KERN % vars()).build(OPTS).my_test_kernel # print "run 1" # my_test_kernel(queue,( 1 ,Nglobal),( 1 ,1), *kargs ); dump_pdb(out.get()[0:],"../test/test1.pdb") print "run 2" my_test_kernel(queue, (Nlocal, Nglobal), (Nlocal, 1), *kargs) dump_pdb(out.get()[0:], "../test/test2.pdb")
def process_results(out,xout,rout,Nglobal): print "NUM 0 coords:",sum(out.get()==0.0) if int(os.popen("diff ../test/test1.pdb ../test/test2.pdb | wc -l").read()): print "OUTPUTS DO NOT MATCH!!!!!!!!!!" else: print "OUTPUTS MATCH!" if int(os.popen("diff ../test/test1.pdb ../test/test1.pdb.last | wc -l").read()): print "OUTPUT DOES NOT MATCH PREVIOUS!!!!!!!!!!" else: print "PREVIOUS OUTPUT MATCHS!" xform_pdb(nparray_to_XFORMs(xout.get())[0],"../pdb/hyda1_hash.pdb","../test/hyda1_xform.pdb") xform_pdb(nparray_to_XFORMs(xout.get())[1],"../pdb/petf_hash.pdb" ,"../test/petf_xform.pdb") print rout ary = out.get() for i in range(Nglobal): dump_pdb(ary[i*len(ary)/Nglobal:(i+1)*len(ary)/Nglobal],"../test/GI_%i.pdb"%i)
def process_results(out, xout, rout, NG): print "NUM 0 coords:", sum(out.get() == 0.0) if int( os.popen( "diff ../test/test1.pdb ../test/test2.pdb | wc -l").read()): print "OUTPUTS DO NOT MATCH!!!!!!!!!!" else: print "OUTPUTS MATCH!" if int( os.popen("diff ../test/test1.pdb ../test/test1.pdb.last | wc -l"). read()): print "OUTPUT DOES NOT MATCH PREVIOUS!!!!!!!!!!" else: print "PREVIOUS OUTPUT MATCHS!" ary = out.get() for i in range(NG): dump_pdb(ary[i * len(ary) / NG:(i + 1) * len(ary) / NG], "../test/GI_%i.pdb" % i)