Boost logo

Boost :

Subject: [boost] Any interest in a framework for memoization?
From: Giacomo Drago (giacomo_at_[hidden])
Date: 2013-11-18 03:30:49


Hi,

I would like to submit a small framework for memoization I am working on
(http://projects.giacomodrago.com/c++memo/). At the moment, it is still
in a beta stage and does not comply with Boost guidelines. I would like
to know if you might be interested.

The idea is to have a tool for rapid prototyping of software components
implementing dynamic programming algorithms or, anyhow, requiring
memoization.

I paste here a simple "fibonacci" example:

----------------------

int fibonacci(int i, std::function<int(int)> prereqs) {
     if (i == 0) return 0;
     if (i <= 2) return 1;
     return prereqs(i-1) + prereqs(i-2);
}
cppmemo::CppMemo<int, int> cppMemo;
std::cout << cppMemo.getValue(30, fibonacci) << std::endl;

----------------------

The code will print 832040, without recursive calls to the "fibonacci"
function. A stack is managed "under the hood" and appropriate calls
are made to the "fibonacci" callback to gather pre-requirements
and then call the function again when they are available.

This is just a toy example. There is more to know about, including
important caveats (if you are interested, please read the documentation
carefully): some defaults for template and method parameters are useful
for conciseness but are EVIL if you don't know about them.
The framework also provides automatic parallelization (when possible).

It is important to remark that at this moment the framework relies on
fcmm (fast concurrent memoization map), a custom hashmap that is
optimized for this very purpose. This can be changed quite easily, as
fcmm is not exposed to the client.
A C++11 compliant compiler is needed.

Thanks for your attention.

Giacomo


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk