Serving the Quantitative Finance Community

 
User avatar
imirman
Topic Author
Posts: 0
Joined: September 16th, 2008, 1:07 pm

looking for C++ algorithm to evaluate a new multithreading tool

October 1st, 2008, 9:30 pm

I am looking to multicore-enable a couple C++ algorithms with our tool (Cilk++).Is there a pointer to an algorithm or two (and if possible data set) that might be an interesting application to speed up using multicore processors?Would the QuantLib library be a good place to start?thanks in advance,ilya
 
User avatar
Cuchulainn
Posts: 23029
Joined: July 16th, 2004, 7:38 am

looking for C++ algorithm to evaluate a new multithreading tool

October 5th, 2008, 9:27 am

QuoteOriginally posted by: imirmanI am looking to multicore-enable a couple C++ algorithms with our tool (Cilk++).Is there a pointer to an algorithm or two (and if possible data set) that might be an interesting application to speed up using multicore processors?thanks in advance,ilyaI have design blueprints, code and such for MT and parallel applications. For example, using task and data decomposition. Then, how to map the tasks to your products.I saw your intro to parallel processing. Do you have a technical white paper on your product and how it is used?Typical questions . why use it instead of straight OpenMP. ability to support loop-level and parallel sections. shared memory issues. support for parallel design patternsregards Daniel Duffydduffy@datasim.nl
Last edited by Cuchulainn on October 4th, 2008, 10:00 pm, edited 1 time in total.
 
User avatar
imirman
Topic Author
Posts: 0
Joined: September 16th, 2008, 1:07 pm

looking for C++ algorithm to evaluate a new multithreading tool

October 5th, 2008, 9:58 am

Hi Daniel,Relative to OpenMP:1. Cilk++ has nested parallelism that works and provides guaranteed speed-up. OpenMP has nested parallelism, but it is a memory hog and not reliable.2. Cilk++ guarantees space bounds. On P processors, Cilk++ uses no more than P times the space of a serial execution. In OpenMP, not so.3. Cilk++ has a race detector for debugging and software release. With OpenMP, you are on your own.4. Cilk++ has serial semantics. With OpenMP, you do not have this benefit – only a subset of OpenMP supports serial semantics.5. Cilk++ has a solution for global variables (a construct we invented called “hyperobjects”). OpenMP does not.regarding couple of the other questions:- Cilk++ is targeted towards shared memory systems- Cilk++ supports both loops and recursionMore details are available here: http://www.cilk.com/multicore-products/ ... -overview/ Rather than a white paper on our product specifically, we put together an e-Book on the challenges of going multicore: http://www.cilk.com/multicore-e-book/if this sounds relevant, we invite you to kick the tires on the product through the Early Visibility Program.cheers,ilya
 
User avatar
imirman
Topic Author
Posts: 0
Joined: September 16th, 2008, 1:07 pm

looking for C++ algorithm to evaluate a new multithreading tool

October 5th, 2008, 10:02 am

Daniel - I should have also mentioned this page - we've made the alpha documentation and examples public: http://www.cilk.com/resources-for-multi ... pers-only/
 
User avatar
crosshatch
Posts: 0
Joined: January 3rd, 2005, 10:19 pm

looking for C++ algorithm to evaluate a new multithreading tool

October 5th, 2008, 10:06 am

I would start with some simple barebone examples:- The obvious is a Monte-Carlo example: Price a (path dependent) option by breaking the paths up using a "cilk_for". - Price an american option using (recursive) binomial trees using "cilk_spawn" and "cilk_sync". Show us how to debug such algorithms.- Price a portfolio of options by breaking up the portfolio between threads and calling some pricing routine (either a closed-form or finite difference).- Perform QR decomposition of a large matrix. Show us the smart load balancing of Cilk.- Price a single option using finite difference in a parallel way to demonstrate thread interaction?I could possibly do it for you if you are interested...Do you have student pricing for Cilk?
 
User avatar
imirman
Topic Author
Posts: 0
Joined: September 16th, 2008, 1:07 pm

looking for C++ algorithm to evaluate a new multithreading tool

October 5th, 2008, 10:14 am

QuoteOriginally posted by: crosshatchI would start with some simple barebone examples:- The obvious is a Monte-Carlo example: Price a (path dependent) option by breaking the paths up using a "cilk_for". - Price an american option using (recursive) binomial trees using "cilk_spawn" and "cilk_sync". Show us how to debug such algorithms.- Price a portfolio of options by breaking up the portfolio between threads and calling some pricing routine (either a closed-form or finite difference).- Perform QR decomposition of a large matrix. Show us the smart load balancing of Cilk.- Price a single option using finite difference in a parallel way to demonstrate thread interaction?I could possibly do it for you if you are interested...Do you have student pricing for Cilk?Hi crosshatch,we do have student pricing - it's zero. (In fact, we'll have an open source license available, details are being worked out over the next month or so.) If you don't mind playing with a beta version that will have some rough edges (which we'll fix over the next couple months prior to shipment), you are very welcome to join the Early Visibility Program: http://www.cilk.com/Home/sign-up-pagecheers,ilya
 
User avatar
crosshatch
Posts: 0
Joined: January 3rd, 2005, 10:19 pm

looking for C++ algorithm to evaluate a new multithreading tool

October 5th, 2008, 12:37 pm

Great, will do. Looks like a nice tool.
 
User avatar
Cuchulainn
Posts: 23029
Joined: July 16th, 2004, 7:38 am

looking for C++ algorithm to evaluate a new multithreading tool

October 5th, 2008, 2:05 pm

Ilya,Here is a 101 program in OpenMP to do some vector manipulation. How does the corresponding code look like in your product?test This snippet works but not in the expected way #pragma omp parallel for for(int j=0; j < (int)vec.size(); ++j) { cout << "vec[" << j << "] = " << vec[j] << endl; }//BTW I have written a book with Dr. Joerg Kienitz on MC Frameworks in C++. I reckon they could be good test cases. The book is out early 2009. hth
Last edited by Cuchulainn on October 4th, 2008, 10:00 pm, edited 1 time in total.
 
User avatar
imirman
Topic Author
Posts: 0
Joined: September 16th, 2008, 1:07 pm

looking for C++ algorithm to evaluate a new multithreading tool

October 5th, 2008, 9:29 pm

thanks Daniel - we'll take a look and report back.
 
User avatar
imirman
Topic Author
Posts: 0
Joined: September 16th, 2008, 1:07 pm

looking for C++ algorithm to evaluate a new multithreading tool

October 6th, 2008, 4:47 pm

QuoteOriginally posted by: CuchulainnIlya,Here is a 101 program in OpenMP to do some vector manipulation. How does the corresponding code look like in your product?test This snippet works but not in the expected way #pragma omp parallel for for(int j=0; j < (int)vec.size(); ++j) { cout << "vec[" << j << "] = " << vec[j] << endl; }//BTW I have written a book with Dr. Joerg Kienitz on MC Frameworks in C++. I reckon they could be good test cases. The book is out early 2009. hthDaniel,Here's the corresponding Cilk++ code. A cilk_for with an ostream reducer will work, producing the expected results, but if the I/O is a serial bottleneck, parallelization may not accomplish much. On the other hand, if there were actual parallelizable work performed in the for loop, then a real speed-up would be possible, despite the I/O bottleneck.#include <reducer_ostream.h>cilk::hyper_ptr<cilk::reducer_ostream> os(std::cout);cilk_for(int j=0; j < (int)vec.size(); ++j){ *os << "vec[" << j << "] = " << vec[j] << std::endl;}*os << std::flush;cheers,ilya
 
User avatar
Cuchulainn
Posts: 23029
Joined: July 16th, 2004, 7:38 am

looking for C++ algorithm to evaluate a new multithreading tool

October 12th, 2008, 11:54 am

From the code snippet, it would seem that I would need to modify my sequential code (intrusive). This means it's less portable, which may or may not be a problem. With OpenMP we can just insert pragmas and switch on/off at will. And boost threads are another option. How does clik compare to these in functionality, usability, maintainability etc.?Ilya,Do you have a complete example? below is a program that shows how OpenMP loop-level parallelism works.
Last edited by Cuchulainn on October 11th, 2008, 10:00 pm, edited 1 time in total.
 
User avatar
imirman
Topic Author
Posts: 0
Joined: September 16th, 2008, 1:07 pm

looking for C++ algorithm to evaluate a new multithreading tool

October 12th, 2008, 4:53 pm

Hi Daniel,We have a bunch of complete examples here: http://www.cilk.com/resources-for-multi ... -only/Cilk++ maintains the serial semantics of your code, and to go from the Cilkified version to your serial original, or "serialization" as we call it, one just needs to null out the Cilk++ keywords (nulling out cilk_spawn and cilk_sync, and #define cilk_for as for.cheers,ilya
 
User avatar
bojan
Posts: 0
Joined: August 8th, 2008, 5:35 am

looking for C++ algorithm to evaluate a new multithreading tool

October 13th, 2008, 10:38 am

On brief review of the cilk website I did not find mention of libraries, e.g., BLAS, minimisation routines and such that are cilk-enabled. Do these exist?
 
User avatar
riskyrisk
Posts: 0
Joined: July 16th, 2004, 2:47 pm

looking for C++ algorithm to evaluate a new multithreading tool

October 13th, 2008, 12:00 pm

What's wrong with using an Erlang platform/controller to call pre-exisiting numerical C code? Seems to me functional languages lend themselves better to the new multi-distributed future. And if they just open a port to existing C routines to call you could have the best of both worlds, no?
 
User avatar
Cuchulainn
Posts: 23029
Joined: July 16th, 2004, 7:38 am

looking for C++ algorithm to evaluate a new multithreading tool

October 13th, 2008, 6:00 pm

QuoteOriginally posted by: riskyriskWhat's wrong with using an Erlang platform/controller to call pre-exisiting numerical C code? Seems to me functional languages lend themselves better to the new multi-distributed future. And if they just open a port to existing C routines to call you could have the best of both worlds, no?There are many reasons for using Erlang and many for not using it. One big problem is: (hardly) no one uses it.