![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Global reduction operations are those that collect data from all of the compute nodes, and reduce the data to a single value, or an array of values. These include operations such as global summations, global maximums and minimums, and global logicals. These macros begin with the prefix PRF_G and are defined in prf.h. Global summation macros are identified by the suffix SUM, global maximums by HIGH, and global minimums by LOW. The suffixes AND and OR identify global logicals.
The variable data types for each macro are identified in the macro name, where R denotes real data types, I denotes integers, and L denotes logicals. For example, the macro PRF_GISUM finds the summation of integers over the compute nodes.
Each of the global reduction macros discussed in the following sections has two different versions: one takes a single variable argument, while the other takes a variable array. Macros with a 1 appended to the end of the name take one argument, and return a single variable as the global reduction result. For example, the macro PRF_GIHIGH1(x) expands to a function that takes one argument x and computes the maximum of the variable x amongst all of the compute nodes, and returns it. The result can then be assigned to another variable (e.g., y), as shown in the following example.
Example: Global Reduction Variable Macro
{ int y; int x = myid; y = PRF_GIHIGH1(x); /* y now contains the same number (compute_node_count - 1) on all the nodes */ } |
Macros without a 1 suffix, on the other hand, compute global reduction variable arrays. These macros take three arguments: x, N, and iwork where x is an array, N is the number of elements in the array, and iwork is an array that is of the same type and size as x which is needed for temporary storage. Macros of this type are passed an array x and the elements of array x are filled with the new result after returning from the function. For example, the macro PRF_GIHIGH(x,N,iwork) expands to a function that computes the maximum of each element of the array x over all the compute nodes, uses the array iwork for temporary storage, and modifies array x by replacing each element with its resulting global maximum. The function does not return a value.
Example: Global Reduction Variable Array Macro
{ real x[N], iwork[N]; /* The elements of x are set in the working array here and will have different values on each compute node. In this case, x[0] could be the maximum cell temperature of all the cells on the compute node. x[1] the maximum pressure, x[2] the maximum density, etc. */ PRF_GRHIGH(x,N,iwork); /* The maximum value for each value over all the compute nodes is found here */ /* The elements of x on each compute node now hold the same maximum values over all the compute nodes for temperature, pressure, density, etc. */ } |
Global Summations
Macros that can be used to compute global sums of variables are identified by the suffix SUM. PRF_GISUM1 and PRF_GISUM compute the global sum of integer variables and integer variable arrays, respectively.
PRF_GRSUM1(x) computes the global sum of a real variable x across all compute nodes. The global sum is of type float when running a single precision version of ANSYS FLUENT and type double when running the double precision version. Alternatively, PRF_GRSUM(x,N,iwork) computes the global sum of a float variable array for single precision and double when running double precision.
Global Summations | |
Macro | Action |
PRF_GISUM1(x) | Returns sum of integer x over all compute nodes. |
PRF_GISUM(x,N,iwork) | Sets x to contain sums over all compute nodes. |
PRF_GRSUM1(x) | Returns sum of x over all compute nodes; |
float if single precision, double if double precision. | |
PRF_GRSUM(x,N,iwork) | Sets x to contain sums over all compute nodes; |
float array if single precision, double array if double | |
precision. | |
Global Maximums and Minimums
Macros that can be used to compute global maximums and minimums of variables are identified by the suffixes HIGH and LOW, respectively. PRF_GIHIGH1 and PRF_GIHIGH compute the global maximum of integer variables and integer variable arrays, respectively.
PRF_GRHIGH1(x) computes the global maximum of a real variable x across all compute nodes. The value of the global maximum is of type float when running the single precision version of ANSYS FLUENT and type double when running the double precision version.
PRF_GRHIGH(x,N,iwork) computes the global maximum of a real variable array, similar to the description of PRF_GRSUM(x,N,iwork) on the previous page. The same naming convention used for PRF_GHIGH macros applies to PRF_GLOW.
Global Maximums | |
Macro | Action |
PRF_GIHIGH1(x) | Returns maximum of integer x over all compute nodes. |
PRF_GIHIGH(x,N,iwork) | Sets x to contain maximums over all compute nodes. |
PRF_GRHIGH1(x) | Returns maximums of x over all compute nodes; |
float if single precision, double if double precision. | |
PRF_GRHIGH(x,N,iwork) | Sets x to contain maximums over all compute nodes; |
float array if single precision, double array if double | |
precision. | |
Global Minimums | |
Macro | Action |
PRF_GILOW1(x) | Returns minimum of integer x over all compute nodes. |
PRF_GILOW(x,N,iwork) | Sets x to contain minimums over all compute nodes. |
PRF_GRLOW1(x) | Returns minimum of x over all compute nodes; |
float if single precision, double if double precision. | |
PRF_GRLOW(x,N,iwork) | Sets x to contain minimums over all compute nodes; |
float array if single precision, double array | |
if double precision. | |
Global Logicals
Macros that can be used to compute global logical ANDs and logical ORs are identified by the suffixes AND and OR, respectively. PRF_GLOR1(x) computes the global logical OR of variable x across all compute nodes. PRF_GLOR(x,N,iwork) computes the global logical OR of variable array x. The elements of x are set to TRUE if any of the corresponding elements on the compute nodes are TRUE.
By contrast, PRF_GLAND(x) computes the global logical AND across all compute nodes and PRF_GLAND(x,N,iwork) computes the global logical AND of variable array x. The elements of x are set to TRUE if all of the corresponding elements on the compute nodes are TRUE.
Global Logicals | |
Macro | Action |
PRF_GLOR1(x) | TRUE when variable x is TRUE for any of the compute nodes |
PRF_GLOR(x,N,work) | TRUE when any of the elements in variable array x is TRUE |
PRF_GLAND1(x) | TRUE when variable x is TRUE for all compute nodes |
PRF_GLAND(x,N,iwork) | TRUE when every element in variable array x is TRUE |
Global Synchronization
PRF_GSYNC() can be used when you want to globally synchronize compute nodes before proceeding with the next operation. When you insert a PRF_GSYNC macro in your UDF, no commands beyond it will execute until the preceding commands in the source code have been completed on all of the compute nodes. Synchronization may also be useful when debugging your function.