Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
akeley98 committed Jun 5, 2017
1 parent 2de6481 commit 744eb07
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ There are few guarantees on the `output` pointer because it directly points to a

## mediocre_combine implementation (WIP)

If you want to figure out how the library really works (good luck!), the answer lies somewhere in `src/combine.c`. The other source files implement MediocreInput and MediocreFunctor instances; `src/combine.c` is what actually enables them to work together. Basically, what we do is launch a bunch of threads (`thread_count` of them) that run the MediocreFunctor's `loop_function`, so that they're all waiting for commands from the library. We then pass control to the MediocreInput `loop_function`. We trick the user into doing work for us by adapting that input `loop_function` as the "main loop" for the entire combine operation. To do this, we have the `MediocreInputControl` structure do some bookkeeping on how much of the arrays we have processed so far (so we know how far we are in the iteration) and some bookkeeping on the MediocreFunctor threads launched for us. In each iteration of the MediocreInput's `loop_function`, we do some extra work when the MediocreInput asks for a command in each iteration (since the function `mediocre_input_control_get` accesses the `MediocreInputControl` structure); this work includes giving commands to the MediocreFunctor `loop_function`s running in the launched threads and updating the `MediocrInputControl` bookkeeping.
If you want to figure out how the library really works (good luck!), the answer lies somewhere in `src/combine.c`. The other source files implement MediocreInput and MediocreFunctor instances; `src/combine.c` is what actually enables them to work together. Basically, what we do is launch a bunch of threads (`thread_count` of them) that run the MediocreFunctor's `loop_function`, so that they're all waiting for commands from the library. We then pass control to the MediocreInput `loop_function`. We trick the user into doing work for us by adapting that input `loop_function` as the "main loop" for the entire combine operation. To do this, we have the `MediocreInputControl` structure do some bookkeeping on how much of the arrays we have processed so far (so we know how far we are in the iteration) and some bookkeeping on the MediocreFunctor threads launched for us. In each iteration of the MediocreInput's `loop_function`, we do some extra work when the MediocreInput asks for a command in each iteration (since the function `mediocre_input_control_get` accesses the `MediocreInputControl` structure); this work includes giving commands to the MediocreFunctor `loop_function`s running in the launched threads and updating the `MediocreInputControl` bookkeeping.

I should write some better design notes later. For now, consider setting the global variable `mediocre_combine_verbose` to true and running `mediocre_combine`. Stare at the output and the many comments in `src/combine.c` and you may achieve nirvana.

Expand Down

0 comments on commit 744eb07

Please sign in to comment.