Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import gc
import numpy as np
import pyopencl as cl
import pyopencl.array as cla
import threading
import sys
import time
ctx = cl.create_some_context(answers=['0', '1'])
queue = cl.CommandQueue(ctx)
def create_nanny(n=1):
# creates NannyEvent caught in reference cycle
for i in range(n):
acl = cla.zeros(queue, shape=(8,1), dtype=np.float32)
a = acl.get()
evt = cl.enqueue_copy(queue, acl.data, a)
l = [evt, a]
l.append(l)
def create_nanny_nanny(n1=10, n2=100, name='nannynanny'):
for i1 in range(n2):
create_nanny(n1)
print (name, i1)
sys.stdout.flush()
#gc.set_debug(gc.DEBUG_STATS)
gc.set_threshold(5)
T1 = threading.Thread(target=create_nanny_nanny, args=(10,1000, 'thread 1'))
T2 = threading.Thread(target=create_nanny_nanny, args=(10,1000, 'thread 2'))
T1.start()
T2.start()
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import gc
import numpy as np
import pyopencl as cl
import pyopencl.array as cla
import threading
import sys
import time
ctx = cl.create_some_context(answers=['0', '1'])
queue = cl.CommandQueue(ctx)
def create_nanny(n=1):
# creates NannyEvent caught in reference cycle
for i in range(n):
acl = cla.zeros(queue, shape=(8,1), dtype=np.float32)
a = acl.get()
evt = cl.enqueue_copy(queue, acl.data, a)
l = [evt, a]
l.append(l)
def create_nanny_nanny(n1=10, n2=100, name='nannynanny'):
for i1 in range(n2):
create_nanny(n1)
print (name, i1)
sys.stdout.flush()
#gc.set_debug(gc.DEBUG_STATS)
gc.set_threshold(5)
T1 = threading.Thread(target=create_nanny_nanny, args=(10,1000, 'thread 1'))
T2 = threading.Thread(target=create_nanny_nanny, args=(10,1000, 'thread 2'))
T1.start()
T2.start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment