PREV UP NEXT StackThreads/MP: version 0.77 User's Guide

10.2: Possible Slowdown by Disabling Inline

We must make sure that a procedure call expression that appears in ST_THREAD_CREATE is not inline-expanded. For example, when you write ST_THREAD_CREATE(f(x)), you must make sure procedure call f(x) is not inlined by gcc. When this condition holds, separate stack frames are allocated for f and the caller of f. StackThreads/MP runtime can then execute f and the caller in parallel by executing the two frames on different processors. This is impossible if f(...) is inlined, because their stack frames are merged. stgcc command automatically disables inlining by giving gcc suitable options (-fno-inline-functions for normal functions and -fno-default-inline for C++ member functions defined in a class definition). This is safe, but sometimes results in a noticeable slowdown compared to gcc, particularly for C++ programs.

Giving -fno-inline-functions and -fno-default-inline are very pessimistic, because we only have to make sure that inlining won't occur on parallel calls (ST_THREAD_CREATE). Inlining normal procedure calls are no problem, but the problem is we have no way to prohibit inlining of designated call sites. Here are a couple of suggestions to enable inlining sequential calls.