Example #1
0
static void* __thread_worker(void *thread_input) {

    int my_tid = ((thread_struct*)thread_input)->tid;
    //connect
    functionStruct* localFunction = ((thread_struct*)thread_input)->function;
    void *thread_prepare_out = localFunction->prepare(thread_input,localFunction->prepare_in);   
    printf("this tid = %d\n",my_tid); 

    benchmarkConfig *bc = ((thread_struct*)thread_input)->bc;
    //use the benchmark; 
    benchmarkInfo *benchmark = initBenchmark(bc->totalCount);
    benchmark = loadData(benchmark);
    kvPair *tempPair;
    char *key,*value;
    long long total_start = s_time();

    int i;
    for(i=0;i<bc->totalCount;i++) {
        tempPair = getKvPair(benchmark);
        long long start = us_time();
        localFunction->operation_out = localFunction->operation((void*)tempPair,thread_input,thread_prepare_out);
        long long end = us_time();
        addDuration(benchmark,end-start);
    }

    long long total_end = s_time();
    localFunction->end_out = localFunction->end(thread_input,thread_prepare_out);
    char temp[11] = "pip";
    sprintf(temp+3,"%d",my_tid);
    //after benchmark
    setFileName(benchmark,temp);
    flushResults(benchmark);
    
    return (void*)0;
}
Example #2
0
    void process()
    {
        CWorkUnitWriteMasterBase::process();

        unsigned nslaves = container.queryJob().querySlaves();

        CMessageBuffer mb;
        unsigned s=0;
        for (; s<nslaves; s++)
        {
            loop
            {
                if (!container.queryJob().queryJobComm().send(mb, s+1, mpTag)) return;
                if (!receiveMsg(mb, s+1, mpTag)) return;
                if (0 == mb.length())
                    break;
                unsigned numGot;
                mb.read(numGot);
                unsigned l=mb.remaining();
                if (workunitWriteLimit && totalSize+resultData.length()+l > workunitWriteLimit)
                {
                    StringBuffer errMsg("Dataset too large to output to workunit (limit is set to ");
                    errMsg.append(workunitWriteLimit/0x100000).append(") megabytes, in result (");
                    if (resultName.length())
                        errMsg.append("name=").append(resultName);
                    else
                        errMsg.append("sequence=").append(resultSeq);
                    errMsg.append(")");
                    throw MakeThorException(TE_WorkUnitWriteLimitExceeded, "%s", errMsg.str());
                }
                resultData.append(l, mb.readDirect(l));
                mb.clear();
                numResults += numGot;

                if (-1 != flushThreshold && resultData.length() >= (unsigned)flushThreshold)
                    flushResults();
            }
        }
        flushResults(true);
    }
Example #3
0
void parasol(char *command, int argc, char *argv[])
/* parasol - Parasol program - for launching programs in parallel on a computer cluster. */
{
char *subType = argv[0];

hubRudp = rudpMustOpen();
if (sameString(command, "add"))
    {
    if (argc < 1)
        usage();
    if (sameString(subType, "machine"))
	{
	if (argc != 3 && argc != 8)
	    usage();
	addMachine(argc, argv);
	}
    else if (sameString(subType, "job"))
	{
	if (argc < 2)
	    usage();
        addJob(argc-1, argv+1, optionExists("verbose"));
	}
    else if (sameString(subType, "spoke"))
        addSpoke();
    else
        usage();
    }
else if (sameString(command, "clear"))
    {
    if (argc != 1)
	usage();
    if (sameString(subType, "sick"))
	{
        clearSickBatch();
	}
    else
        usage();
    }
else if (sameString(command, "check"))
    {
    if (argc != 1)
	usage();
    if (sameString(subType, "dead"))
	{
        checkDeadNodesASAP();
	}
    else
        usage();
    }
else if (sameString(command, "remove"))
    {
    if (argc < 2)
        usage();
    if (sameString(subType, "machine"))
	{
	if (argc < 3)
	    usage();
        removeMachine(argv[1],argv[2]);
	}
    else if (sameString(subType, "job"))
        removeJob(argv[1]);
    else if (sameString(subType, "jobs"))
        removeUserJobs(argv[1], argc-2, argv+2);
    else
        usage();
    }
else if (sameString(command, "list"))
    {
    if (argc != 1)
        usage();
    if (sameString(subType, "machine") || sameString(subType, "machines"))
        hubCommandAndPrint("listMachines");
    else if (sameString(subType, "job") || sameString(subType, "jobs"))
	{
        if (optionExists("extended"))
	    hubCommandAndPrint("listJobsExtended");
        else
	    hubCommandAndPrint("listJobs");
	}
    else if (sameString(subType, "user") || sameString(subType, "users"))
        hubCommandAndPrint("listUsers");
    else if (sameString(subType, "batch") || sameString(subType, "batches"))
        hubCommandAndPrint("listBatches");
    else if (sameString(subType, "sick"))
        hubCommandAndPrint("listSick");
    else
        usage();
    }
else if (sameString(command, "pstat"))
    {
    pstat();
    }
else if (sameString(command, "pstat2"))
    {
    pstat2();
    }
else if (sameString(command, "plan"))
    {
    hubCommandAndPrint("plan");
    }
else if (sameString(command, "ping"))
    {
    int count = 1;
    if (argc >= 1)
        {
	if (!isdigit(argv[0][0]))
	    usage();
	count = atoi(argv[0]);
	}
    ping(count);
    }
else if (sameString(command, "status"))
    status();
else if (sameString(command, "flushResults"))
    {
    if (argc != 0)
        usage();
    flushResults();
    }
/* Not providing at this time for fear of abuse 
else if (sameString(command, "freeBatch"))
    {
    if (argc != 0)
        usage();
    freeBatch();
    }
*/
else
    usage();
}