maedoc / libtvb

TVB C library
6 stars 8 forks source link

Move output handling to separate thread #133

Open maedoc opened 8 years ago

maedoc commented 8 years ago

Output handling requires lightweight calculation, I/O and memory access that's entirely independent of the integration, so it should be fairly easy to move this work to a separate thread, as the solver pushes new data to root output at every time step. The solver current waits for a status flag from the root output, but since future result doesn't affect past, if the output returns a failure asynchronously, the solver can stop and no harm done.

This would require additionally mutexing the malloc routines, as they are used in the sd_out_mem implementation.

TinyCThread may be useful for avoiding platform specific code.

paramhanji commented 8 years ago

I was looking through the relevant code and have a basic understanding. The solver waits for a status flag from output here. Please correct me if this is wrong.

Also, what does sd_out -> apply() do? It hasn't been implemented yet.

maedoc commented 8 years ago

waits for a status flag from output

Yes

s sd_out -> apply() do? It hasn't been implemented yet.

It is implemented by each of the outputs, see for example file output here

paramhanji commented 8 years ago

Isn't it necessary for apply() function to run on the same thread as the solver? Since it outputs the current state. But apply() is definitely part of the output handler..