feat: ability to exclude cl devices from being used (#801)

This commit is contained in:
wozeparrot
2023-05-25 20:31:29 -04:00
committed by GitHub
parent 3c465470f2
commit fca5028d78

View File

@@ -23,7 +23,7 @@ class _CL:
def __init__(self):
platforms: List[List[cl.Device]] = [y for y in ([x.get_devices(device_type=cl.device_type.GPU) for x in cl.get_platforms()] + [x.get_devices(device_type=cl.device_type.CPU) for x in cl.get_platforms()]) if len(y)]
if DEBUG >= 1: print(f"using {platforms[getenv('CL_PLATFORM', 0)]}")
self.cl_ctx: cl.Context = cl.Context(devices=platforms[getenv('CL_PLATFORM', 0)])
self.cl_ctx: cl.Context = cl.Context(devices=[x for x in platforms[getenv('CL_PLATFORM', 0)] if x.name not in getenv('CL_EXCLUDE', "").split(",")])
self.cl_queue: List[cl.CommandQueue] = [cl.CommandQueue(self.cl_ctx, device=device, properties=cl.command_queue_properties.PROFILING_ENABLE) for device in self.cl_ctx.devices]
def synchronize(self):
for q in self.cl_queue: q.finish()