A computer implemented method, system and computer program product for
accessing threadprivate memory for threadprivate variables in a parallel
program during program compilation. A computer implemented method for
accessing threadprivate variables in a parallel program during program
compilation includes aggregating threadprivate variables in the program,
replacing references of the threadprivate variables by indirect
references, moving address load operations of the threadprivate
variables, and replacing the address load operations of the threadprivate
variables by calls to runtime routines to access the threadprivate
memory. The invention enables a compiler to minimize the runtime routines
call times to access the threadprivate variables, thus improving program
performance.