Gather data from all tasks in a parallel application and perform an operation, such as addition, finding minimum, or maximum on the data. All tasks have the reduced data after the call.
Operation | Meaning | Works for data types |
---|---|---|
"+" or "sum" or "SUM" | Addition | reals, integers, complex |
"min" or "MIN" | Minimum value | reals, integers |
"max" or "MAX" | Maximum value | reals, integers |
"*" or "prod"or "PROD" | Product | reals, integers, complex |
"and" or "AND" | Logical and | logical |
"or" or "OR" | Logical or | logical |
"xor" or "XOR" | Logical xor | logical |
"and" or "AND" | bit-wise and | integer |
"or" or "OR" | bit-wise or | integer |
"xor" or "XOR" | bit-wise xor | integer |
Value | Meaning |
---|---|
ccm_reproducible |
Force the reduction operation to return the same value whenever the function is applied on the same arguments appearing in the same order. |
ccm_fast |
Potentially use a faster reduction operation that may violate the reproducability condition given above. |
|
[ccm_host:~/ccm/source]% ccm_allreduce_x1
min # seconds from midnight is 58320.3
average # seconds from midnight is 58320.3
max # seconds from midnight is 58320.3
average of hours 16
average of minutes 12
average of seconds 0
average of milliseconds 319
min # seconds from midnight is 58320.3
average # seconds from midnight is 58320.3
max # seconds from midnight is 58320.3
average of hours 16
average of minutes 12
average of seconds 0
average of milliseconds 319
[ccm_host:~/ccm/source] %
The call to ccm_init initializes the communication package and obtains the number of tasks in the application and the id for each task. The program gets the time and converts it to a real value, local_time. All tasks set gtime_sum=0. The application calls ccm_allreduce with local_time as input, first to get the global minimum, then the sum and finally the maximum on all tasks. The program calls ccm_allreduce with an integer array, time_info_array, as input and using the "+" operation. This returns the sum of the time information from each task in an array. Output is printed on the last and zeroth task. The call to ccm_close closes the communication package. |
|
[ccm_host:~/ccm/source]% ccm_allreduce_x2
xout= 7.01010084152222 0.000000000000000
xout= 7.01010084152222 3.00000000000000
[ccm_host:~/ccm/source] %
The call to ccm_init initializes the communication package and sets myid to the id of each task. Xout is set equal to myid and the first element of xin is set to a function of myid and the second to -1. The application does a sum operation with the result printed on task 0. Only the first value of xout is changed because the application sends only a single element, xin(1:1). The program uses the "fast" protocol in the first call to ccm_reduce. The program uses the "reproducible" protocol in the second call to ccm_reduce and prints output on the last task. The reproducible protocol will always return the same result for a given set of inputs. This may not happen with the fast protocol. |