lmoffatt / macro_dr

GNU General Public License v3.0
1 stars 1 forks source link

FuncMap refactorization #73

Closed lmoffatt closed 9 months ago

lmoffatt commented 9 months ago

So: here are the changes

  1. Memoization, Time_it and Test_it will become single threaded.
  2. F_on_thread dissapears
  3. FuncMap gets F_on_thread functionality (method f)
  4. Two new methods are created fork (n)-> creates a vector of FuncMap and operator+= vector with the corresponding operators += for each Function wrapper.
lmoffatt commented 9 months ago

Time_it_st is the single threaded implementation of Time_it. commit 9bd47dd

lmoffatt commented 9 months ago

Now we should see how Memoization is used.

Lets see:

var::Thread_Memoizer(
          var::F(Calc_Qdt_step{},
                 [](auto &&...x) {
                   auto m = Macro_DMR{};
                   return m.calc_Qdt_ATP_step(std::forward<decltype(x)>(x)...);
                 }),
          var::Memoiza_all_values<Maybe_error<Qdt>, ATP_step, double>{},
          num_scouts_per_ensemble / 2),
lmoffatt commented 9 months ago

so, we have two options: Option one we remove the thread function of Thread_Memoizer. Option two we make the Memoiza_all_values to include the function.

I guess the first option is better. So we create Single_Thread_Memoizer 63b5183

lmoffatt commented 9 months ago

Test_it is partially implemented (is right now mostly a copy of Time_it)

lmoffatt commented 9 months ago

Now I implement FuncMapSt

we have to implement several new methods/functions

  1. Fork(n)---> here we have a problem since we cannot copy a stream (but we can copy a filename and more than that we can add an index to it!9 2 method f
  2. operator +=vector implemented in a208d3b
lmoffatt commented 9 months ago

Now the problem is how to integrate the new functionality into the old code.

  1. build a new get_Function_Table-->get_Function_TableSt (561e47b)
lmoffatt commented 9 months ago

Now my problem is that both the new code and the old code uses FuncMaps and I dont know if it is a good idea to have two copies of that.

So, there are two bads:

  1. duplicate a sizeable portion of the code
  2. change a lot of old code without compiling in the middle and without reversibility.
lmoffatt commented 9 months ago

The solution is simple: make both interfaces or FuncMap and FuncMapSt temporarilty the same in this way we can make the FuncMapSt code to compile and then by removing the temporarily changes we remove FuncMap altogether

lmoffatt commented 9 months ago

The first part is to integrate FuncMapSt into existing code.

I did it d58cf11 and it compiles for main and old_code

lmoffatt commented 9 months ago

Run it, and it gave weird results (waaay too many min violation errors). It turned out that the logic of Memoization clearance was flawed. Solved in commit 678bc74