I'm currently working on a project where one of the 4 versions of the same algorithm (involving different parallel programing frameworks + its sequential analogous) can be called each time the program runs.
The arguments for all these 4 are the same and the parallel framework details would be handled inside the functions themselves.
I'm all new to C++ so really don't know if it is possible to change which code the function()
points to and select the right version based on a command-line argument.
Warning: hideous pseudocode ahead:
switch(version){
case OMP:
// make function() point to 1st version
case CUDA:
// ... to function2()
case OCL:
// ... to function3()
case SEQ:
default:
// ... to function0()
}
// ...
while(condition){
// call function()
}
So I'm trying to figure out an elegant way of doing this while having the different algorithms in separate files and just handling I/O in the main routine. Some behavioral pattern?