Skip to content
Snippets Groups Projects
Commit 83e097c0 authored by Mikael Djurfeldt's avatar Mikael Djurfeldt
Browse files

Add and use runtime.finalize()

parent b6a8787e
No related branches found
No related tags found
No related merge requests found
......@@ -47,3 +47,5 @@ runtime = music.Runtime(setup, timestep)
times = takewhile(lambda t: t <= stoptime, runtime)
for time in times:
pass
runtime.finalize()
......@@ -47,3 +47,5 @@ for t in times:
out.insertEvent(when, index, music.Index.GLOBAL)
nextStep, nextEvents = step()
runtime.finalize()
......@@ -35,3 +35,5 @@ runtime = setup.runtime(timestep)
times = takewhile(lambda t: t <= stoptime, runtime)
for time in times:
pass
runtime.finalize()
......@@ -36,3 +36,5 @@ for t in times:
out.insertMessage(when, msg)
nextStep, nextEvents = step()
runtime.finalize()
......@@ -27,3 +27,5 @@ for time in times:
sys.stdout.write(
"t={}\treceiver {}: received Hello from sender {}\n".
format(time, rank, srank))
runtime.finalize()
......@@ -22,3 +22,5 @@ times = takewhile(lambda t: t < stoptime, runtime)
for time in times:
data[0] = rank
sys.stdout.write("t={}\tsender {}: Hello!\n".format(time, rank))
runtime.finalize()
......@@ -44,3 +44,5 @@ runtime = music.Runtime(setup, timestep)
times = takewhile(lambda t: t <= stoptime, runtime)
for time in times:
pass
runtime.finalize()
......@@ -54,3 +54,5 @@ for t in times:
out.insertEvent(when, i, index)
nextStep, nextEvents = step()
runtime.finalize()
......@@ -186,6 +186,7 @@ cdef class Runtime(object):
cdef CRuntime* ptr
cdef readonly MPI.Intracomm comm
cdef set ports
cdef int isFinalized
###########################################################
......
......@@ -518,6 +518,7 @@ cdef class Runtime(object):
def __cinit__(self, Setup setup, double h):
self.ptr = new CRuntime(setup.ptr, h)
self.ports = setup.ports
self.isFinalized = 0
setup.null()
cdef MPI.Intracomm comm = MPI.Intracomm()
......@@ -525,7 +526,8 @@ cdef class Runtime(object):
self.comm = comm
def __dealloc__(self):
self.ptr.finalize()
if not self.isFinalized:
self.ptr.finalize()
for p in self.ports:
p.null()
......@@ -533,8 +535,13 @@ cdef class Runtime(object):
del self.ptr
def time(self): return self.ptr.time()
def tick(self): tick(self.ptr)
def finalize(self):
self.isFinalized = 1
self.ptr.finalize()
def __iter__(self):
cdef CRuntime* ptr = self.ptr
while True:
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment