コード例 #1
0
ファイル: matmul3d.C プロジェクト: quinoacomputing/quinoa
void Compute::resetArrays() {
    int indexX = thisIndex.x;
    int indexY = thisIndex.y;
    int indexZ = thisIndex.z;

    float tmp;

    for(int i=indexZ*subBlockDimXz; i<(indexZ+1)*subBlockDimXz; i++)
        for(int j=0; j<blockDimY; j++) {
            tmp = (float)drand48();
            while(tmp > MAX_LIMIT || tmp < (-1)*MAX_LIMIT)
                tmp = (float)drand48();

            A[i*blockDimY + j] = tmp;
        }

    for(int j=indexX*subBlockDimYx; j<(indexX+1)*subBlockDimYx; j++)
        for(int k=0; k<blockDimZ; k++) {
            tmp = (float)drand48();
            while(tmp > MAX_LIMIT || tmp < (-1)*MAX_LIMIT)
                tmp = (float)drand48();

            B[j*blockDimZ + k] = tmp;
        }

    for(int i=0; i<blockDimX; i++)
        for(int k=0; k<blockDimZ; k++) {
            C[i*blockDimZ + k] = 0.0;
#if USE_CKDIRECT
            tmpC[i*blockDimZ + k] = 0.0;
#endif
        }

    sendA();
    sendB();
}
コード例 #2
0
ファイル: matmul3d.C プロジェクト: brog2610/quinoa
void Compute::beginCopying() {
  sendA();
  sendB();
}
コード例 #3
0
ファイル: motor_control.c プロジェクト: hewr1993/robocup
static void motor_thread_main()
{
    motor_init();
    while (1) {

        pthread_mutex_lock(&task_mutex);
        if (mutex_flag == 1) {
            // sendSTOP();
            // mylogfd (-1, "%s %d\n", "----", task_segNum);
            if (task_segList != NULL) {
                free(task_segList);
                task_segList = NULL;
            }
            sliceTask(current);
            mylogfd (1, "%s %d\n", "New Task", task_segNum);
            mutex_flag = 0;
        }
        pthread_mutex_unlock(&task_mutex);
//mylogfd (1, "[moto] %d %d\n", task_segIdx, task_segNum);
        if (task_segIdx >= task_segNum)	{
            mylogfd(MOTOFD,"[moto]main:job done\n");
            pthread_mutex_lock(&task_mutex);
            job_done = 1;
	    job_over = 1;
            mylogfd (1, "[moto] job done\n");
            pthread_mutex_unlock(&task_mutex);
            //		sendSTOP();
            //sendAA(preleft,preright,0);
            pthread_mutex_lock(&stop_mutex);
        } else {
            //mylogfd(1,"x");
            if (task_segIdx == 0) {
                if (((fabs(preleft - task_segList[task_segIdx].lspeed) > MINV)
                        ||(fabs(preright - task_segList[task_segIdx].rspeed) > MINV))
                        &&(fabs(preleft > 10))) {
                    preleft = preleft/2;
                    preright = preright/2;
                    sendAA(preleft,preright,0);
                    usleep(1000000 * 0.1);
                    continue;
                }
            }
            //mylogfd(-1,"[Control]/motor/main:deal with the task_seg\n");
            if (task_segList[task_segIdx].type == TASK_ROTA) {
                if (task_segList[task_segIdx].dur_time == 0) {
                    mylogfd(1,"time = 0\n");
                    task_segIdx ++;
                    continue;
                }
                sendA(task_segList[task_segIdx].lspeed,
                      task_segList[task_segIdx].rspeed,0,1);
                usleep(1000000 * task_segList[task_segIdx].dur_time);
            } else if (task_segList[task_segIdx].type == TASK_STOP) {
                sendSTOP();
            } else if (task_segList[task_segIdx].type == TASK_WITH_BALL) {
                sendAA(task_segList[task_segIdx].lspeed,
                       task_segList[task_segIdx].rspeed,0);
                usleep(1000000 * task_segList[task_segIdx].dur_time);
            } else if (task_segList[task_segIdx].type == TASK_RUN) {
                sendAA(task_segList[task_segIdx].lspeed+left_flag,
                       task_segList[task_segIdx].rspeed+right_flag,0);
                usleep(1000000 * task_segList[task_segIdx].dur_time);
            } else if (task_segList[task_segIdx].type == TASK_CATCH_BALL) {
                sendAA(task_segList[task_segIdx].lspeed,
                       task_segList[task_segIdx].rspeed,0);
                usleep(1000000 * task_segList[task_segIdx].dur_time);
            }
            preleft = task_segList[task_segIdx].lspeed;
            preright = task_segList[task_segIdx].rspeed;
            task_segIdx++;
        }
    }
}