// // Copyright 2010 Intel Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // #include "RCCE.h" #define BUFSIZE 8 int RCCE_APP(int argc, char **argv){ int ID, ID_nb, ID_donor, nrounds, error, strlength; RCCE_FLAG flag_sent, flag_ack; double *cbuffer, *buffer, sum; char msg[RCCE_MAX_ERROR_STRING]; RCCE_init(&argc, &argv); #ifdef TESTFLAGALLOC ID=0; while (!RCCE_flag_alloc(&flag_sent)) ID++; printf("Able to allocate %d flags\n", ID); exit(0); #endif ID = RCCE_ue(); ID_nb = (ID+1)%RCCE_num_ues(); ID_donor = (ID-1+RCCE_num_ues())%RCCE_num_ues(); if (argc != 2) { if (ID==0) printf("Executable requires one parameter (number of rounds): %d\n",argc-1); return(1); } nrounds = atoi(*++argv); if (nrounds < 0) { if (ID==0) printf("Number of rounds should be non-negative: %d\n", nrounds); return(1); } /* allocate private memory and comm buffer space */ buffer = (double *) malloc(BUFSIZE*sizeof(double)); if (!buffer) printf("Mark 01: Failed to allocate private buffer on proc %d\n", ID); cbuffer = (double *) RCCE_malloc(BUFSIZE*sizeof(double)); if (!buffer) printf("Mark 02:RCCE failed to allocate %d doubles on proc %d\n", BUFSIZE, ID); /* initialize buffer with UE-specific data */ for (int i=0; i