User`s guide
Cray XMT™ Programming Environment User’s Guide
err = svrEndpoint->registerRemoteCall(svc_type, reduce_func_idx, reduce);
if (err != LUC_ERR_OK)
{
fprintf(stderr,"client: LUC registerRemoteCall error %d\n",err);
delete svrEndpoint;
return 1; // error
}
// Begin offering services (begin listening for requests).
err = svrEndpoint->startService(threadCount);
if (err != LUC_ERR_OK)
{
fprintf(stderr,"client: LUC startService error %d\n",err);
delete svrEndpoint;
return 1; // error
}
// Print out the endpoint id for the server. This value is a required
// input for the client.
fprintf(stderr,"server: Server ready.
My endpoint id is %ld\n",svrEndpoint->getMyEndpointId());
// At this point, the main server thread waits while requests
// to the server are handled by other threads.
// A "terminate server" client request can be defined by the
// application to handle server shutdown, or else the server can
// simply be killed when the server is no longer needed.
// For this example, the server waits until it is killed.
getc(stdin);
// The server has been requested to shut down.
svrEndpoint->stopService(); // stop listening for requests
delete svrEndpoint; // free memory
return 0;
}
// The main program either calls the server routine or the client
// routine. The server (-s) should be started first, then the
// client (-c id) can be run multiple times.
// Shut down by killing the server process.
int main(int argc, char **argv)
{
luc_endpoint_id_t id;
int i;
while ((i = getopt(argc,argv,"c:s")) != EOF)
{
switch (i)
{
case 'c':
id = strtoul(optarg, NULL, 0);
return client(id); // make a request to server with this endpoint id
case 's':
return server(1); // start server with 1 request-processing thread
}
}
64 S–2479–20