User`s guide
Cray XMT™ Programming Environment User’s Guide
#define NetworkToHost(b,l) ByteSwap((b),(l))
#define HostToNetwork(b,l) ByteSwap((b),(l))
#endif
// The LUC client runs on the XMT login node, and acts as
// the application user interface.
// Return value is 0 for success, 1 for error.
int client(luc_endpoint_id_t serverID)
{
double input[NREDUCE]; // input data
double output; // result
size_t in_size = sizeof(double) * NREDUCE; // input size in bytes
size_t out_size = sizeof(double); // output size in bytes
luc_error_t err; // result code from LUC calls
// Initialize the input data.
for (int i=0;i < NREDUCE;i++) input[i] = i;
// Create the LUC client endpoint.
LucEndpoint *clientEndpoint = luc_allocate_endpoint(LUC_CLIENT_ONLY);
// Initialize the endpoint (connect to the server).
err = clientEndpoint->startService();
if (err != LUC_ERR_OK)
{
fprintf(stderr,"client: LUC startService error %d\n",err);
delete clientEndpoint; // free memory
return 1; // error
}
HostToNetwork(input,in_size); // convert data to network byte order
// Send the request to the server and wait for a response.
// In this example, the array of values to be summed is sent,
// and the sum is returned as the result.
err = clientEndpoint->remoteCallSync(serverID, svc_type, reduce_func_idx,
input, in_size, &output, &out_size);
if (err != LUC_ERR_OK)
{
// err contains a LUC error code.
fprintf(stderr,"client: LUC remoteCallSync error %d\n",err);
}
else
{
// out_size contains the size of data returned in outbuf
NetworkToHost(&output,out_size); // convert data to host byte order
printf("The sum of the %d values is %lf\n",NREDUCE,output);
}
clientEndpoint->stopService(); // disconnect from the server
delete clientEndpoint; // free memory
return (err != LUC_ERR_OK) ? 1 : 0;
}
62 S–2479–20