[ANSYS, Inc. Logo] return to home search
next up previous contents index

7.5.2 Communicating Between the Host and Node Processes

There are two sets of similar macros that can be used to send data between the host and the compute nodes: host_to_node_type_num and node_to_host_type_num.



Host-to-Node Data Transfer


To send data from the host process to all the node processes (indirectly via compute node-0) we use macros of the form:

host_to_node_type_num(val_1,val_2,...,val_num);

where `num' is the number of variables that will be passed in the argument list and `type' is the data type of the variables that will be passed. The maximum number of variables that can be passed is 7. Arrays and strings can also be passed from host to nodes, one at a time, as shown in the examples below.

Examples

/*  integer and real variables passed from host to nodes  */
host_to_node_int_1(count);
host_to_node_real_7(len1, len2, width1, width2, breadth1, breadth2, vol);

/*  string and array variables passed from host to nodes  */
char wall_name[]="wall-17";
int thread_ids[10] = {1,29,5,32,18,2,55,21,72,14};

host_to_node_string(wall_name,8); /* remember terminating NUL character */
host_to_node_int(thread_ids,10);

Note that these host_to_node communication macros do not need to be "protected'' by compiler directives for parallel UDFs, because all of these macros automatically do the following:

The most common use for this set of macros is to pass parameters or boundary conditions from the host to the nodes processes. See the example UDF in Section  7.8 for a demonstration of usage.



Node-to-Host Data Transfer


To send data from compute node-0 to the host process we use macros of the form:

node_to_host_type_num(val_1,val_2,...,val_num);

where `num' is the number of variables that will be passed in the argument list and `type' is the data type of the variables that will be passed. The maximum number of variables that can be passed is 7. Arrays and strings can also be passed from host to nodes, one at a time, as shown in the examples below.

Note that unlike the host_to_node macros which pass data from the host process to all of the compute nodes (indirectly via compute node-0), node_to_host macros pass data only from compute node-0 to the host.

Examples

/*  integer and real variables passed from compute node-0 to host  */
node_to_host_int_1(count);
node_to_host_real_7(len1, len2, width1, width2, breadth1, breadth2, vol);

/*  string and array variables passed from compute node-0 to host  */
char *string;
int string_length;
real vel[ND_ND];

node_to_host_string(string,string_length);
node_to_host_real(vel,ND_ND);

node_to_host macros do not need to be protected by compiler directives (e.g., #if RP_NODE) since they automatically do the following:

The most common usage for this set of macros is to pass global reduction results from compute node-0 to the host process. In cases where the value that is to be passed is computed by all of the compute nodes, there must be some sort of collection (such as a summation) of the data from all the compute nodes onto compute node-0 before the single collected (summed) value can be sent. Refer to the example UDF in Section  7.8 for a demonstration of usage and Section  7.5.4 for a full list of global reduction operations.


next up previous contents index Previous: 7.5.1 Compiler Directives
Up: 7.5 Macros for Parallel
Next: 7.5.3 Predicates
Release 12.0 © ANSYS, Inc. 2009-01-14