When I want to store the outputs of a program to a file, I typically use the following command
./program_to_run > output.txt
Today, I run a python script that calls C++ backend code, which calls an external C++ CUDA library from NVIDIA. The external C++ CUDA has logging that is printed out, and the python script also prints out stuff. I noticed that the order in which the two were printed doesn't appear to align with their execution.
e.g., my python script looks something like
import some stuff
print("beginning")
# run some calls to C++ backend which then calls NVIDIA library
When I examined output.txt, I noticed something like this
# some logging information is printed here
beginning # why is this printed after the logging information?
# some more logging information is printed here
The beginning wasn't printed at the beginning of output.txt, so I'm wondering what happened here? I don't think there is any multithreaded code, but there is parallel code in CUDA, but the python script starts out in serial, so shouldn't I see the string beginning at the beginning of output.txt?