/******************************************************* Mosel Example Problems ====================== file runrtparqueued.c ````````````````````` Running several instances of a model from another Mosel model. - Queuing submodels for parallel execution in a distributed architecture (one or several models per node) - Before running this model, you need to set up the list NodeList with machine names/addresses of your local network. All nodes that are used need to have the same version of Xpress installed and suitably licensed, and the server "xprmsrv" must have been started on these machines. The maximum number of models per node in array MaxMod needs to be adapted to the number of executions licensed on the corresponding nodes. All files are local to the root node, no write access is required at remote nodes. (c) 2012 Fair Isaac Corporation author: S. Heipcke & Y. Colombani, Apr. 2012 *******************************************************/ #include #include #include #include "xprd.h" #define J 10 /* Number of jobs to run */ #define NUMPAR 2 /* Number of parallel model executions */ /* (preferrably <= no. of processors) */ #define MAXQSIZE 20 /* Maximum number of elements in a queue (>=J) */ /* Use the name or IP address of a machine in your local network, or "" for current node */ const char *NodeList[]={"localhost","localhost"}; #define NodeListSize (sizeof(NodeList)/sizeof(NodeList[0])) #define nbNodes (NodeListSizelastId) lastId=XPRDgetnumber(modPar[nct]); nct++; } jobid=malloc(sizeof(int)*(lastId+1)); modid=malloc(sizeof(int)*(lastId+1)); modNode=malloc(sizeof(char *)*(lastId+1)); for(j=0;j0) /* Start a new run if queue not empty */ start_next_job(&JobList,sender); } } for(n=0;nsize>=MAXQSIZE) return -1; else { q->buf[q->head++]=e; if(q->head>=MAXQSIZE) q->head=0; return ++q->size; } } /**********************************/ /* Remove an element from a queue */ /**********************************/ int queue_get(s_queue *q) { int rts; if(q->size<1) return -1; else { rts=q->buf[q->tail++]; if(q->tail>=MAXQSIZE) q->tail=0; q->size--; return rts; } } /***************************/ /* Get the size of a queue */ /***************************/ int queue_size(s_queue *q) { return q->size; }