Last active
February 7, 2019 09:47
-
-
Save geggo/d9b4016ff5b77dab262be7b30a98d862 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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