Reputation: 20076
Scenario: I have an program which can be easily parallelized using OpenMP, lets say the main loop of the program is a for loop and independent data within it, so paralleizing it would be trivial. However currently I don't parallelize it, and instead use affinity scheduling.
This program performs work on some input files specified by a folder in the command line arguments. To run this program in parallel, someone can create a bat file like so:
start \affinity 1 "1" bat1
start \affinity 2 "2" bat2
start \affinity 3 "3" bat3
start \affinity 4 "4" bat4
where bat1 - 4 is a bat file that calls main.exe
with a different input folder for each bat file. So in this case there would be 4 instances of main.exe
running on input_folder1, input_folder2, input_folder3, input_folder4
respectively.
What would be the benefits of using a library like OpenMP be instead of affinity scheduling? I figure
n
instances of a program for n
coresBut would I expect to actually see a performance boost? Why if so?
Upvotes: 0
Views: 107
Reputation: 38118
If your problem is a simply parallel, with no interaction among the data in the separate input files, then you would probably not see a speedup with OpenMP, and might even see a slow-down, since memory allocation and various other things then have to be thread-safe. Single-threaded processes can gain lots of efficiencies, and in fact do on GNU libc, where linking in POSIX threads support means you also get a slower implementation of malloc
Upvotes: 1