First do not compile any of the UPC source files in your application with a compile-time specified value. Then, at runtime, provide the -fupc-threads-n option on the command line, just after the executable program's file name. The UPC runtime strips off all of the initial command line arguments that begin with the prefix -fupc-, and passes the remaining arguments to your application's main program. The following example, shows how this is done:
% cat dynamic.upc #include#include int
main () { if (MYTHREAD == 0)
printf ("There are %d UPC threads.\n", THREADS); } % upc dynamic.upc -o dynamic % dynamic -fupc-threads-7 There are 7 UPC threads.Article is in the following categories:
KB » Usage of GNU UPC






How do I specify the value of THREADS (dynamically) at runtime?
Email This Article