Skip to content
Snippets Groups Projects
Commit 146181ff authored by Veronique Legrand's avatar Veronique Legrand
Browse files

removed unuseful file for this branch

parent 1a00693e
No related branches found
No related tags found
No related merge requests found
import pyopencl as cl
import os
## Need that for being able to test on my imac on GPU and macbookpro CPU
class parmsForTesting:
def __init__(self):
self.mac_max_dim1 =-1
self.testing_on_cpu=False
if os.getenv("OSX_TESTING_ON_GPU") != None or os.getenv("OSX_TESTING_ON_CPU") != None:
self.mac_max_dim1 = 256
if os.getenv("OSX_TESTING_ON_CPU") != None:
self.testing_on_cpu=True
## Gets the number of threads that we can run on the chosen device.
# @param input: the number of elements to process (reads or sequences in our case)
# @param input: (device characteristics): maximum number of threads that we can out un dim 1.
def getNbThreads(nb_elem_to_process,device_max_thread_dim1):
remainder = nb_elem_to_process % device_max_thread_dim1
if (remainder != 0):
nb_threads_dim1 = nb_elem_to_process - remainder + device_max_thread_dim1
else:
nb_threads_dim1 = nb_elem_to_process
return nb_threads_dim1
## gets platform and device.
#
# instanciates context and command queue and also get memory flags.
def getOpenCLElements():
parms=parmsForTesting()
l_platforms = cl.get_platforms()
idx_platform = 0
idx_device = -1
gpu_found=False
type_flags = cl.device_type
for p in l_platforms:
l_devices = p.get_devices(device_type=type_flags.GPU)
if len(l_devices) > 0:
gpu_found=True
idx_device = 0 # for the moment, choose the 1rst GPU device we find
break
idx_platform += 1
platform = cl.get_platforms()[idx_platform]
if (gpu_found and not parms.testing_on_cpu):
device = platform.get_devices(device_type=type_flags.GPU)[idx_device]
#device = platform.get_devices()[0]
else:
print "Warning : No GPU found or CPU testing mode, trying to run openCL on CPU"
device = platform.get_devices(device_type=type_flags.CPU)[0]
print "will run on: "
print " Device name:", device.name
print " Device type:", cl.device_type.to_string(device.type)
print " Device memory: ", device.global_mem_size // 1024 // 1024, 'MB'
print " Device max clock speed:", device.max_clock_frequency, 'MHz'
print " Device compute units:", device.max_compute_units
print " Device max work items:", device.get_info(cl.device_info.MAX_WORK_ITEM_SIZES)
print " Device local memory:", device.get_info(cl.device_info.LOCAL_MEM_SIZE) // 1024, 'KB'
print type(device.get_info(cl.device_info.MAX_WORK_ITEM_SIZES))
#m=device.get_info(cl.device_info.MAX_WORK_ITEM_SIZES)[0]
if parms.mac_max_dim1!=-1: # need that as workaround for the buggy openCL implementation on osx. Need to run my tests.
max_dim1=parms.mac_max_dim1
else:
max_dim1=device.get_info(cl.device_info.MAX_WORK_ITEM_SIZES)[0]
ctx = cl.Context([device])
queue = cl.CommandQueue(ctx)
mf = cl.mem_flags
return ctx,queue,mf,max_dim1
## Utility method to process the result of upd_reads_nb_occ_in_sequences_str kernel
def getMaxNbOccPerSeq(o_nb_occ_foreach_extract_in_seqs,nb_reads,nb_seq):
m=0
for idx_s in range(0,nb_seq):
line_start=idx_s*2*nb_reads
tmp=o_nb_occ_foreach_extract_in_seqs[line_start+2*nb_reads-1]+o_nb_occ_foreach_extract_in_seqs[line_start+2*nb_reads-2]
if tmp>m: m=tmp
return m
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment