![]() ![]() Now compare the same with both printf statements commented out (note that I had to increase n to 1000000 in order to get meaningful results from time): OMP_NUM_THREADS=1. This is the overhead of that text output. ![]() ![]() Note that the program spends consistently about 4x more time in system mode than in user mode. I've removed the call to omp_set_num_threads() and use OMP_NUM_THREADS instead, which allows to run the program with varying number of threads without recompiling the source. Observe those measurement timings ( n = 10000): OMP_NUM_THREADS=1. Not to mention the overhead of printf itself - it has to parse the format string, convert the integer value to a string and then send that to the stdout stream. ![]() Since the standard output is basically serial, your program serialises in the printf statements. Your program is spending more time sending text to the standard output than computing the numbers. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |