Example #1
0
bool myMasterFunc()
{
    releaseThreads();

    // do my chunk of work
    work[0].work_func( 0 );

    waitForThreads();

    bool ret = true;

    for(int n = 0; n < nWorkers; n++)
    {
        if( work[n].ret == false ) ret = false;
    }

    return( ret );
}
Example #2
0
void shutdownThreads()
{
#ifdef MEM_MULTICORE
    int n;

    for( n = 1; n < nWorkers; n++ )
    {
        work[n].exit = true;
        work[n].work_func = NULL;
    }

    releaseThreads();
    waitForThreads();

    for(int n = 1; n < nWorkers; n++)
    {
        WaitForSingleObject( tn[n], INFINITE );
    }
#endif
}
Example #3
0
void launchThreads()
{
#ifdef MEM_MULTICORE
    int *nArg = (int*)malloc(sizeof(int) *(nWorkers + 1));
    int n;
    for( n = 1; n < nWorkers; n++ )
    {
        nArg[n] = n;
        work[n].exit = false;
        work[n].work_func = NULL;

        tn[n] = (HANDLE) _beginthreadex( NULL, 0, myThreadFunc, (void *) (&nArg[n]), 0, &tid[n] );
    }

    // XXX if this isn't here subsequent barrier roundtrips
    // are more expensive. Why?
    releaseThreads();
    waitForThreads();
    if(nArg)
        free(nArg);
#endif
}
Example #4
0
__dllexport void LockStepTaskScheduler::leave(const size_t threadID, const size_t numThreads)
{
    assert(threadID == 0);
    releaseThreads(numThreads);
}