Gather data from all tasks in a parallel application to a single task while performing an operation, such as addition, finding minimium, or maximum on the data. By default, the zeroeth task in the parallel application holds 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|
Force the reduction operation to return
the same value whenever the function is
applied on the same arguments appearing
in the same order.
Potentially use a faster recudtion operation
that may violate the reproducability condition
Xin can be one of the Fortran data types: integer, real, double precision, complex, logical. It can be a scaler or an array. For arrays, the operation is element wise. On the root task, xout must be large enough to hold the data that is sent.
[ccm_host:~/ccm/source]% ccm_reduce_x1 min # seconds from midnight is 48276.2 average # seconds from midnight is 48306.8 max # seconds from midnight is 48381.2 average of hours 13 average of minutes 24 average of seconds 36 average of milliseconds 324 [ccm_host:~/ccm/source] %
The call to ccm_init initializes the communication package. The call to ccm_int contains the optional argument num_procs=numprocs to get the number of tasks in the application. The time is then obtained and converted to a real value, local_time. All tasks set gtime_sum=0. The application calls ccm_reduce with local_time as input, first to get the global minimum, then the sum and finally the maximum on all tasks. The reduced value is returned only to the root task, so after these calls to ccm_reduce gtime_sum will have a nonzero value only the root. The program calls ccm_reduce with an integer array, time_info_array, as input and using the "+" operation. On the root task, we have the sum of the time information from each task returned in an array. The root task prints this information. The call to ccm_close closes the communication package.
[ccm_host:~/ccm/source]% ccm_reduce_x2 xout= 46.0101008415222 2.00000000000000 xout= 46.0101008415222 2.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 returned to task 2. 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. The reproducible protocol will always return the same result for a given set of inputs. This may not happen with the fast protocol.