0

My C++ program pseudo code looks like:

#omp pragma parallel
for (i=1...100000)
  write input files into a file called "$i.txt", $i is the value of i
  then do ./outside_program $i.txt and reads its inputs and do other stuff

Assume ./outside_program is thread safe. Is using openmp to write to different files in C++ thread safe?

2
  • 1
    Probably thread safe but possibly a nightmare in performance terms as the threads contend for access to the read/write head. Commented Sep 3, 2015 at 20:21
  • 1
    It seems likely that the I/O operations will serialize in the kernel or something like that. Commented Sep 4, 2015 at 0:19

1 Answer 1

1

If you are writing to different files I see no problem it is thread safe. The question is in fact not dependent of the multi-threading API you use. OpenMP, TBB, or other technology...

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.