To run a parallel program compiled by KAP on an SMP system, you must define the following symbols:
Replace <integer> with the number of parallel threads to use. The number of parallel threads is equal usually to the number of processors on the system. Do not specify more parallel threads than there are processors to avoid performance degradation.
Increasing the number of threads may result in the need to increase the stack size of your system, as explained in the following KMP_STACKSIZE description.
The KMP_STACKSIZE <integer> environment logical specifies the threads stack size in bytes. Replace <integer> with the desired stack size in bytes. KMP_STACKSIZE should be as large as the largest stack size given in the annotated listing. The default setting is 1 megabyte.
Two indications that your system stack size is too small:
DEC threads Last Chance handler: thread 1 exiting on status exception 0x177db005 Exception: Invalid memory address (dce / thd)
kcc /ckapargs='/conc' large.c KAP/Digital_VMS_C V3.1 k271906 970317 08-Apr-1997 15:38:26 ### in line 620 function EVALWW of file large.c ### Routine PKEVALWW requires the parallel STACKSIZE must be at least 221544 bytes. ### in line 978 function EVALFW of file large.c ### Routine PKEVALFW requires the parallel STACKSIZE must be at least 221400 bytes.
Ask your system manager to increase the stacksize. The KAP annotated source file and the preprocessing warning message tell you how much to increase KMP_STACKSIZE.
The KMP_SPINLOCKS <on/off> environment logical sets the synchronization mechanism:
on
- causes KAP to use spinlock
synchronization. Spinlock synchronization means that threads
"spin" in a loop and consume CPU time while waiting to acquire
a resource. Spinlocks, however, can be a more efficient
synchronization method than mutexes. Spinlocks are appropriate
to use when the system can be dedicated to the parallelized
application.
off
- causes KAP to use mutex
synchronization. Mutex (mutual exclusion) synchronization
allows only one thread at a time to access a resource shared
by multiple threads.
For example, to run a program on a multiprocessor system with 4 parallel threads, a thread stack size of 1 megabyte, and mutex synchronization, set the environment logicals as follows:
define PARALLEL 4 define KMP_STACKSIZE 100000 define KMP_SPINLOCKS off
kcc /ckapargs=(/conc) myprog.c
define PARALLEL 1
kcc /ckapargs=(/noconc) myprog.c