Esempio n. 1
0
void AIOwrapper::load_ARblock(type_precision** Ar, int &y_blockSize)
{
        srand (Fhandler->Aseed);
        re_random_vec(Fhandler->Ar,Fhandler->n*Fhandler->r*Fhandler->Ar_blockSize);
        Fhandler->Aseed+=13;
        (*Ar) = Fhandler->Ar;
}
Esempio n. 2
0
void cpu_benchmark(int n, int samples, double &duration, double &GFLOPS)
{
    type_precision* A = new type_precision[n * n];
    type_precision* B = new type_precision[n * n];
    type_precision* C = new type_precision[n * n];

    cputime_type start_tick, end_tick;
    duration = 9999999999.0;
    int b = 0;

    for (int i = 0; i < samples; i++)
    {
        re_random_vec(A, n*n);
        re_random_vec(B, n*n);
        re_random_vec(C, n*n);

        get_ticks(start_tick);
        cblas_sgemm(CblasColMajor, CblasNoTrans, CblasNoTrans, n, n, n,
                 1.0, A, n, B, n, 1.0, C, n);
        get_ticks(end_tick);
        duration = min(duration, static_cast<double>(ticks2sec(end_tick, start_tick)));
        int a = 0;
        for (int j = 0; j < n * n ; j++)
        {
            a += A[j] + B[j] + C[j];
        }
        b += a;
    }
    //!2nnn - nn + 2nn (from+c)
    GFLOPS = gemm_flops(n, n, n, 0);

    cout << b;

    delete []A;
    delete []B;
    delete []C;
}
Esempio n. 3
0
void* AIOwrapper::async_io( void *ptr )
{
    type_fileh* Fhandler = (type_fileh *)ptr;
    int size,tmp_y_blockSize;

    struct timespec timeToWait;



    while(1)
    {

        while(!Fhandler->empty_buffers.empty() && Fhandler->y_to_readSize)
        {
            tmp_y_blockSize = Fhandler->y_blockSize;
            if(Fhandler->y_to_readSize < Fhandler->y_blockSize)
                tmp_y_blockSize = Fhandler->n%Fhandler->y_blockSize;

            Fhandler->y_to_readSize -= tmp_y_blockSize;
            size = Fhandler->n * tmp_y_blockSize;


            pthread_mutex_lock(&(Fhandler->m_buff_upd));
            type_buffElement* tobeFilled = Fhandler->empty_buffers.front();
            Fhandler->empty_buffers.pop();
            pthread_mutex_unlock(&(Fhandler->m_buff_upd));

            tobeFilled->size = tmp_y_blockSize;

            FILE *fp;
            fp = fopen("benchmark.bin", "rb");
            fread (tobeFilled->buff,sizeof(type_precision),size,fp);
            fclose(fp);

            int old_seed = Fhandler->seed;
            srand (old_seed);
            re_random_vec(tobeFilled->buff , size );
            Fhandler->seed += 75;

            pthread_mutex_lock(&(Fhandler->m_buff_upd));
            Fhandler->full_buffers.push(tobeFilled);
            //  cout << "\nStoring " << tobeFilled << endl;
            pthread_mutex_unlock(&(Fhandler->m_buff_upd));

            pthread_mutex_lock(&(Fhandler->m_read));
            pthread_cond_signal( &(Fhandler->condition_read ));
            pthread_mutex_unlock(&(Fhandler->m_read));

        }


#ifdef WINDOWS
        SYSTEMTIME time;
        GetSystemTime(&time);

        timeToWait.tv_sec = time.wSecond + 500/1000;
        long int morenanos = (500%1000)*1000000;
        timeToWait.tv_nsec = time.wMilliseconds*1000 + morenanos ;
#else
        clock_gettime(CLOCK_REALTIME, &timeToWait);
        timeToWait.tv_nsec += 150;
#endif

        pthread_mutex_lock(&(Fhandler->m_more));
        pthread_cond_timedwait( &(Fhandler->condition_more), &(Fhandler->m_more), &timeToWait );
        pthread_mutex_unlock( &(Fhandler->m_more ));

        pthread_mutex_lock(&(Fhandler->m_read));
        pthread_cond_signal( &(Fhandler->condition_read ));
        pthread_mutex_unlock(&(Fhandler->m_read));

    }


//
//            //!induce realistic fileread delay

}
Esempio n. 4
0
void AIOwrapper::load_AL(type_precision** AL)
{
    re_random_vec(Fhandler->AL,Fhandler->n*Fhandler->l);
    (*AL) = Fhandler->AL;
}
Esempio n. 5
0
void AIOwrapper::load_Yblock(type_precision** Y, int &y_blockSize)
{

    if(!SYNC_IO)
    {
        int status;
        int createstatus = 0;

        while(Fhandler->full_buffers.empty())
        {
            pthread_mutex_lock(&(Fhandler->m_more));
            pthread_cond_signal( &(Fhandler->condition_more ));
            pthread_mutex_unlock(&(Fhandler->m_more));
//            if(AIOSignalEnabled)
//                cout << " IOP " << flush;
            pthread_mutex_lock(&(Fhandler->m_read));
            pthread_cond_wait( &(Fhandler->condition_read), &(Fhandler->m_read ));
            pthread_mutex_unlock(&(Fhandler->m_read));
        }


        //!read new rdy buffer
        pthread_mutex_lock(&(Fhandler->m_buff_upd));
            if(Fhandler->currentBuff)
                Fhandler->empty_buffers.push(Fhandler->currentBuff);
            Fhandler->currentBuff = Fhandler->full_buffers.front();
            Fhandler->full_buffers.pop();

        //cout << "\nReading " << Fhandler->currentBuff << endl;
        Fhandler->Yb = Fhandler->currentBuff->buff;
        y_blockSize = Fhandler->currentBuff->size;
        pthread_mutex_unlock(&(Fhandler->m_buff_upd));



        pthread_mutex_lock(&(Fhandler->m_more));
        pthread_cond_signal( &(Fhandler->condition_more ));
        pthread_mutex_unlock(&(Fhandler->m_more));
    }
    else
    {

        int size,tmp_y_blockSize;

            tmp_y_blockSize = Fhandler->y_blockSize;
            if(Fhandler->y_to_readSize < Fhandler->y_blockSize)
                tmp_y_blockSize = Fhandler->n%Fhandler->y_blockSize;

            Fhandler->y_to_readSize -= tmp_y_blockSize;
            size = Fhandler->n * tmp_y_blockSize;
            y_blockSize = tmp_y_blockSize;

            FILE *fp;
            fp = fopen("benchmark.bin", "rb");
            fread (Fhandler->Yb,sizeof(type_precision),size,fp);
            fclose(fp);

            int old_seed = Fhandler->seed;
            srand (old_seed);
            re_random_vec(Fhandler->Yb , size );

            Fhandler->seed += 2;
            srand (time(NULL));

    }

    (*Y) = Fhandler->Yb;


}