Beispiel #1
0
ocrGuid_t mainEdt(){
/*
mainEdt is executed first
Creates the datablocks
creates realmain as a FINISH EDT
creates wrap up to depend on realmain
launches realmain (wrapup waits until realmain is done)
*/
    u64 i;
    u64 *dummy;
    ocrGuid_t realMain, GSsharedBlock, userSharedBlock, realMainTemplate, output, wrapup, wrapupTemplate;
    PRINTF("Preconditioned driver\n");
    PRINTF("Number of timesteps is %d \n", T);
    PRINTF("Number of workers is %d \n", N);
    PRINTF("Rows per worker %d \n", M);
    ocrEdtTemplateCreate(&wrapupTemplate, wrapupEdt, 0, 1);
    ocrEdtTemplateCreate(&realMainTemplate, realMainEdt, 0, 2);
    ocrEdtCreate(&realMain, realMainTemplate, EDT_PARAM_DEF, NULL, EDT_PARAM_DEF, NULL, EDT_PROP_FINISH, NULL_GUID, &output);
    ocrDbCreate(&GSsharedBlock, (void **) &dummy, sizeof(GSsharedBlock_t), 0, NULL_GUID, NO_ALLOC);
    ocrDbCreate(&userSharedBlock, (void **) &dummy, sizeof(userSharedBlock_t), 0, NULL_GUID, NO_ALLOC);
    ocrEdtCreate(&wrapup, wrapupTemplate, EDT_PARAM_DEF, NULL, EDT_PARAM_DEF, NULL, EDT_PROP_FINISH, NULL_GUID, NULL_GUID);
    ocrAddDependence(output, wrapup, 0, DB_MODE_RW);
    ocrAddDependence(userSharedBlock, realMain, 0, DB_MODE_RW);
    ocrAddDependence(GSsharedBlock, realMain, 1, DB_MODE_RW);
    return NULL_GUID;
}
Beispiel #2
0
int main(int argc, const char * argv[]) {
    ocrConfig_t ocrConfig;
    ocrParseArgs(argc, argv, &ocrConfig);
    ocrInit(&ocrConfig);

    ocrGuid_t terminateEdtGuid;
    ocrGuid_t terminateEdtTemplateGuid;
    ocrEdtTemplateCreate(&terminateEdtTemplateGuid, terminateEdt, 0 /*paramc*/, 1 /*depc*/);
    ocrEdtCreate(&terminateEdtGuid, terminateEdtTemplateGuid, EDT_PARAM_DEF, /*paramv=*/NULL, EDT_PARAM_DEF, /*depv=*/NULL,
                    /*properties=*/0, NULL_GUID, /*outEvent=*/NULL);

    ocrGuid_t outputEventGuid;
    ocrGuid_t rootEdtGuid;
    ocrGuid_t rootEdtTemplateGuid;
    ocrEdtTemplateCreate(&rootEdtTemplateGuid, rootEdt, 0 /*paramc*/, 0 /*depc*/);
    ocrEdtCreate(&rootEdtGuid, rootEdtTemplateGuid, EDT_PARAM_DEF, /*paramv=*/NULL, EDT_PARAM_DEF, /*depv=*/NULL,
                    /*properties=*/EDT_PROP_FINISH, NULL_GUID, /*outEvent=*/&outputEventGuid);

    // When output-event will be satisfied, the whole task sub-tree
    // spawned by rootEdt will be done, and shutdownEdt is called.
    ocrAddDependence(outputEventGuid, terminateEdtGuid, 0, DB_MODE_RO);

    ocrFinalize();
    return 0;
}
// Handles the second part of the Cooley-Tukey algorithm, performing calculations on
// The entire set of coefficients. The work is again split to be computed in parallel
// by a number of slaves.
ocrGuid_t fftEndEdt(u32 paramc, u64* paramv, u32 depc, ocrEdtDep_t depv[]) {
	int i;
	ocrGuid_t startGuid = paramv[0];
	ocrGuid_t endGuid = paramv[1];
	ocrGuid_t endSlaveGuid = paramv[2];
	float *data_in = (float*)depv[0].ptr;
	float *data_real = (float*)depv[1].ptr;
	float *data_imag = (float*)depv[2].ptr;
	ocrGuid_t dataGuids[3] = { depv[0].guid, depv[1].guid, depv[2].guid };
	u64 N = paramv[3];
	u64 step = paramv[4];
	u64 offset = paramv[5];
	bool verbose = paramv[7];
	u64 serialBlockSize = paramv[8];
	float *x_in = (float*)data_in+offset;
	float *X_real = (float*)(data_real+offset);
	float *X_imag = (float*)(data_imag+offset);
	if(verbose) {
		PRINTF("Reached end phase for step %d\n",step);
		PRINTF("paramc: %d\n",paramc);
	}

	if(N/2 > serialBlockSize) {
		ocrGuid_t slaveGuids[(N/2)/serialBlockSize];
		u64 slaveParamv[5 * (N/2)/serialBlockSize];

		if(verbose) {
			PRINTF("Creating %d slaves for N=%d\n",(N/2)/serialBlockSize,N);
		}
		
		for(i=0;i<(N/2)/serialBlockSize;i++) {
			slaveParamv[i*5] = N;
			slaveParamv[i*5+1] = step;
			slaveParamv[i*5+2] = offset;
			slaveParamv[i*5+3] = i*serialBlockSize;
			slaveParamv[i*5+4] = (i+1)*serialBlockSize;

			ocrEdtCreate(slaveGuids+i, endSlaveGuid, EDT_PARAM_DEF, slaveParamv+i*5, EDT_PARAM_DEF, dataGuids, EDT_PROP_NONE, NULL_GUID, NULL);
		}
	} else {
		ocrGuid_t slaveGuids[1];
		u64 slaveParamv[5];
		
		slaveParamv[0] = N;
		slaveParamv[1] = step;
		slaveParamv[2] = offset;
		slaveParamv[3] = 0;
		slaveParamv[4] = N/2;

		ocrEdtCreate(slaveGuids, endSlaveGuid, EDT_PARAM_DEF, slaveParamv, EDT_PARAM_DEF, dataGuids, EDT_PROP_NONE, NULL_GUID, NULL);
	}
	return NULL_GUID;
}
ocrGuid_t fftStartEdt(u32 paramc, u64* paramv, u32 depc, ocrEdtDep_t depv[]) {
	int i;
	ocrGuid_t startGuid = paramv[0];
	ocrGuid_t endGuid = paramv[1];
	ocrGuid_t endSlaveGuid = paramv[2];
	float *data = (float*)depv[0].ptr;
	ocrGuid_t dataGuid = depv[0].guid;
	u64 N = paramv[3];
	u64 step = paramv[4];
	u64 offset = paramv[5];
	u64 x_in_offset = paramv[6];
	bool verbose = paramv[7];
	u64 serialBlockSize = paramv[8];
	float *x_in = (float*)data;
	float *X_real = (float*)(data+offset + N*step);
	float *X_imag = (float*)(data+offset + 2*N*step);
	if(verbose) {
		PRINTF("Step %d offset: %d N*step: %d\n", step, offset, N*step);
	}
	

	if(N <= serialBlockSize) {
		ditfft2(X_real, X_imag, x_in+x_in_offset, N, step);
	} else {
		// DFT even side
		u64 childParamv[9] = { startGuid, endGuid, endSlaveGuid, N/2, 2 * step, 0 + offset, x_in_offset, verbose, serialBlockSize };
		u64 childParamv2[9] = { startGuid, endGuid, endSlaveGuid, N/2, 2 * step, N/2 + offset, x_in_offset + step, verbose, serialBlockSize };
		
		if(verbose) {
			PRINTF("Creating children of size %d\n",N/2);
		}
		ocrGuid_t edtGuid, edtGuid2, endEdtGuid, finishEventGuid, finishEventGuid2;

		ocrEdtCreate(&edtGuid, startGuid, EDT_PARAM_DEF, childParamv, EDT_PARAM_DEF, NULL_GUID, EDT_PROP_FINISH, NULL_GUID, &finishEventGuid);
		ocrEdtCreate(&edtGuid2, startGuid, EDT_PARAM_DEF, childParamv2, EDT_PARAM_DEF, NULL_GUID, EDT_PROP_FINISH, NULL_GUID, &finishEventGuid2);
		if(verbose) {
			PRINTF("finishEventGuid after create: %lu\n",finishEventGuid);
		}

		ocrGuid_t endDependencies[3] = { dataGuid, finishEventGuid, finishEventGuid2 };
		// Do calculations after having divided and conquered
		ocrEdtCreate(&endEdtGuid, endGuid, EDT_PARAM_DEF, paramv, EDT_PARAM_DEF, endDependencies, EDT_PROP_FINISH, NULL_GUID, NULL);

		ocrAddDependence(dataGuid, edtGuid, 0, DB_MODE_ITW);
		ocrAddDependence(dataGuid, edtGuid2, 0, DB_MODE_ITW);
	}

	if(verbose) {
		PRINTF("Task with size %d completed\n",N);
	}
	return NULL_GUID;
}
Beispiel #5
0
ocrGuid_t mainEdt(u32 paramc, u64* paramv, u32 depc, ocrEdtDep_t depv[]) {
    u64 affinityCount;
    ocrAffinityCount(AFFINITY_PD, &affinityCount);
    ocrGuid_t dbAffGuid;
    ocrGuid_t * dbAffPtr;
    ocrDbCreate(&dbAffGuid, (void **)&dbAffPtr, sizeof(ocrGuid_t) * affinityCount, DB_PROP_SINGLE_ASSIGNMENT, NULL_HINT, NO_ALLOC);
    ocrAffinityGet(AFFINITY_PD, &affinityCount, dbAffPtr);
    ASSERT(affinityCount >= 1);

    // create local edt that depends on the remote edt, the db is automatically cloned
    ocrGuid_t remoteEdtTemplateGuid;
    ocrEdtTemplateCreate(&remoteEdtTemplateGuid, remoteEdt, 0, 1);

    ocrGuid_t eventsGuid[COUNT_EDT];
    ocrGuid_t dbsGuid[COUNT_EDT];
    u64 i = 0;
    while(i < COUNT_EDT) {
        ocrEventCreate(&eventsGuid[i],OCR_EVENT_ONCE_T, EVT_PROP_NONE);
        ocrGuid_t * dbPtr;
        ocrDbCreate(&dbsGuid[i], (void **)&dbPtr, sizeof(ocrGuid_t)*2, DB_PROP_SINGLE_ASSIGNMENT, NULL_HINT, NO_ALLOC);
        dbPtr[0] = eventsGuid[i];
        dbPtr[1] = dbAffPtr[i%affinityCount];
        ocrDbRelease(dbsGuid[i]);
        i++;
    }
    ocrDbRelease(dbAffGuid);

    // Setup shutdown EDT
    ocrGuid_t shutdownEdtTemplateGuid;
    ocrEdtTemplateCreate(&shutdownEdtTemplateGuid, shutdownEdt, 0, COUNT_EDT);
    ocrHint_t edtHint;
    ocrHintInit( &edtHint, OCR_HINT_EDT_T );

    ocrGuid_t shutdownEdtGuid;
    ocrEdtCreate(&shutdownEdtGuid, shutdownEdtTemplateGuid, 0, NULL, EDT_PARAM_DEF, eventsGuid,
                 EDT_PROP_NONE, NULL_HINT, NULL);

    // Spawn 'COUNT_EDT' EDTs, each satisfying its event
    i = 0;
    while(i < COUNT_EDT) {
        ocrSetHintValue( & edtHint, OCR_HINT_EDT_AFFINITY, ocrAffinityToHintValue( dbAffPtr[i%affinityCount]) );
        // Create EDTs
        ocrGuid_t edtGuid;
        ocrEdtCreate(&edtGuid, remoteEdtTemplateGuid, 0, NULL, EDT_PARAM_DEF, &dbsGuid[i],
            EDT_PROP_NONE, &edtHint, NULL);
        i++;
    }

    return NULL_GUID;
}
Beispiel #6
0
ocrGuid_t mainEdt(u32 paramc, u64* paramv, u32 depc, ocrEdtDep_t depv[]) {

    u64 arraySize = 100;
    //Create argument vector to hold array size
    u64 nparamv[1];
    nparamv[0] = arraySize;

    u64 * dataArray;
    ocrGuid_t dataGuid;
    //Create datablock to hold a block of 'array size' u64 elements
    ocrDbCreate(&dataGuid,(void **) &dataArray, sizeof(u64)*arraySize,
                /*flags=*/0, /*loc=*/NULL_GUID, NO_ALLOC);

    ocrGuid_t stepAEdtTemplateGuid;
    ocrEdtTemplateCreate(&stepAEdtTemplateGuid, stepA_edt, 1 /*paramc*/, 1 /*depc*/);

    // Create the EDT not specifying the dependence vector at creation
    ocrGuid_t stepAEdtGuid;
    ocrEdtCreate(&stepAEdtGuid, stepAEdtTemplateGuid, EDT_PARAM_DEF, nparamv, 1, NULL,
                /*prop=*/EDT_PROP_NONE, NULL_GUID, NULL);

    ocrGuid_t triggerEventGuid;
    //TODO Setup event used to trigger stepA
    //END-TODO

    //TODO Setup dependence between event and stepA's EDTs slot 0
    //END-TODO

    //TODO Satisfy the event with the datablock
    //END-TODO

    return NULL_GUID;
}
Beispiel #7
0
ocrGuid_t mainEdt(u32 paramc, u64* paramv, u32 depc, ocrEdtDep_t depv[]) {
    // Current thread is '0' and goes on with user code.
    ocrGuid_t e0;
    ocrEventCreate(&e0, OCR_EVENT_ONCE_T, EVT_PROP_TAKES_ARG);

    // Creates the EDTa
    ocrGuid_t edtGuid;
    ocrGuid_t taskForEdtTemplateGuid;
    ocrEdtTemplateCreate(&taskForEdtTemplateGuid, taskForEdt, 0 /*paramc*/, 2/*depc*/);
    ocrEdtCreate(&edtGuid, taskForEdtTemplateGuid, EDT_PARAM_DEF, /*paramv=*/NULL, EDT_PARAM_DEF, /*depv=*/NULL,
                 /*properties=*/0, NULL_HINT, /*outEvent=*/NULL);

    // Register a dependence between an event and an edt
    ocrAddDependence(e0, edtGuid, 0, DB_MODE_CONST);
    ocrAddDependence(e0, edtGuid, 1, DB_MODE_CONST);

    int *k;
    ocrGuid_t dbGuid;
    ocrDbCreate(&dbGuid,(void **) &k,
                sizeof(int), /*flags=*/DB_PROP_NONE,
                /*location=*/NULL_HINT,
                NO_ALLOC);
    *k = 42;

    // Satisfy event's chain head
    ocrEventSatisfy(e0, dbGuid);

    return NULL_GUID;
}
Beispiel #8
0
ocrGuid_t mainEdt(u32 paramc, u64* paramv, u32 depc, ocrEdtDep_t depv[]) {
    ocrGuid_t tplGuid;
    ocrEdtTemplateCreate(&tplGuid, otherEdt, 0 /*paramc*/, 2 /*depc*/);
    ocrGuid_t edtGuid;
    ocrGuid_t ndepv[2];
    ndepv[0] = UNINITIALIZED_GUID;
    ndepv[1] = UNINITIALIZED_GUID;
    ocrEdtCreate(&edtGuid, tplGuid, 0, NULL, 2, ndepv, EDT_PROP_NONE, NULL_HINT, NULL);
    ocrEdtTemplateDestroy(tplGuid);

    ocrGuid_t db1Guid;
    u64 * db1Ptr;
    ocrDbCreate(&db1Guid, (void**) &db1Ptr, sizeof(u64), DB_PROP_NONE, NULL_HINT, NO_ALLOC);
    db1Ptr[0] = 1;
    ocrDbRelease(db1Guid);

    ocrGuid_t db2Guid;
    u64 * db2Ptr;
    ocrDbCreate(&db2Guid, (void**) &db2Ptr, sizeof(u64), DB_PROP_NONE, NULL_HINT, NO_ALLOC);
    db2Ptr[0] = 2;
    ocrDbRelease(db2Guid);

    ocrAddDependence(db1Guid, edtGuid, 0, DB_MODE_RO);
    ocrAddDependence(db2Guid, edtGuid, 1, DB_MODE_RO);

    return NULL_GUID;
}
Beispiel #9
0
void test () {
    // Current thread is '0' and goes on with user code.
    ocrGuid_t eventGuid;
    ocrEventCreate(&eventGuid, OCR_EVENT_STICKY_T, true);

    // Creates the EDT
    ocrGuid_t edtGuid;
    ocrGuid_t taskForEdtTemplateGuid;
    ocrEdtTemplateCreate(&taskForEdtTemplateGuid, taskForEdt, 0 /*paramc*/, 1 /*depc*/);

    ocrEdtCreate(&edtGuid, taskForEdtTemplateGuid, EDT_PARAM_DEF, /*paramv=*/NULL,
                 EDT_PARAM_DEF, /*depv=*/NULL, 0, NULL_GUID, NULL);

    // Register a dependence between an event and an edt
    ocrAddDependence(eventGuid, edtGuid, 0, DB_MODE_RO);

    int *k;
    ocrGuid_t db_guid;
    ocrDbCreate(&db_guid,(void **) &k,
            sizeof(int), /*flags=*/FLAGS,
            /*location=*/NULL_GUID,
            NO_ALLOC);
    *k = 42;

    ocrEventSatisfy(eventGuid, db_guid);
}
// Performs one entire iteration of FFT.
// These are meant to be chained serially for timing and testing.
ocrGuid_t fftIterationEdt(u32 paramc, u64* paramv, u32 depc, ocrEdtDep_t depv[]) {
	ocrGuid_t startTempGuid = paramv[0];
	ocrGuid_t endTempGuid = paramv[1];
	ocrGuid_t endSlaveTempGuid = paramv[2];
	u64 N = paramv[3];
	bool verbose = paramv[4];
	u64 serialBlockSize = paramv[5];
	float *x_in = (float*)depv[0].ptr;
	float *X_real = (float*)depv[1].ptr;
	float *X_imag = (float*)depv[2].ptr;
	int i;

	if(verbose) {
		PRINTF("Hello from EDT %lu\n",paramv[6]);
	}

	u64 edtParamv[9] = { startTempGuid, endTempGuid, endSlaveTempGuid, N, 1 /* step size */, 0 /* offset */, 0 /* x_in_offset */, verbose, serialBlockSize };
	ocrGuid_t dependencies[3] = { depv[0].guid, depv[1].guid, depv[2].guid };

	if(verbose) {
		PRINTF("Creating iteration child\n");
	}
	ocrGuid_t edtGuid;
	ocrEdtCreate(&edtGuid, startTempGuid, EDT_PARAM_DEF, edtParamv, EDT_PARAM_DEF, dependencies, EDT_PROP_FINISH, NULL_GUID, NULL_GUID);

	return NULL_GUID;
}
Beispiel #11
0
ocrGuid_t mainEdt(u32 paramc, u64* paramv, u32 depc, ocrEdtDep_t depv[]) {
    u64 affinityCount;
    ocrAffinityCount(AFFINITY_PD, &affinityCount);
    ocrGuid_t dbAffGuid;
    ocrGuid_t * dbAffPtr;
    ocrDbCreate(&dbAffGuid, (void **)&dbAffPtr, sizeof(ocrGuid_t) * affinityCount, DB_PROP_SINGLE_ASSIGNMENT, NULL_HINT, NO_ALLOC);
    ocrAffinityGet(AFFINITY_PD, &affinityCount, dbAffPtr);
    ASSERT(affinityCount >= 1);
    ocrGuid_t affinityGuid = dbAffPtr[affinityCount-1];
    ocrDbRelease(dbAffGuid);

    // Finish EDT potentially remote, but spawning all children on the same node
    ocrGuid_t finishEdtTemplateGuid;
    ocrEdtTemplateCreate(&finishEdtTemplateGuid, finishEdt, 0, 0);
    ocrHint_t edtHint;
    ocrHintInit( &edtHint, OCR_HINT_EDT_T );
    ocrSetHintValue( & edtHint, OCR_HINT_EDT_AFFINITY, ocrAffinityToHintValue( affinityGuid) );

    PRINTF("mainEdt: spawning remote finish-EDT\n");
    ocrGuid_t edtGuid;
    ocrEdtCreate(&edtGuid, finishEdtTemplateGuid, 0, NULL, EDT_PARAM_DEF, 0,
        EDT_PROP_NONE, &edtHint, NULL);

    return NULL_GUID;
}
Beispiel #12
0
ocrGuid_t mainEdt(u32 paramc, u64* paramv, u32 depc, ocrEdtDep_t depv[]) {
    // Create a DB
    void * dbPtr;
    ocrGuid_t dbGuid;
    u64 nbElem = NB_ELEM_DB;
    ocrDbCreate(&dbGuid, &dbPtr, sizeof(TYPE_ELEM_DB) * NB_ELEM_DB, 0, NULL_HINT, NO_ALLOC);
    int v = 1;
    int i = 0;
    int * data = (int *) dbPtr;
    while (i < nbElem) {
        data[i] = v++;
        i++;
    }
    ocrDbRelease(dbGuid);
    PRINTF("[local] mainEdt: local DB guid is "GUIDF", dbPtr=%p\n", GUIDA(dbGuid), dbPtr);

    // create local edt that depends on the remote edt, the db is automatically cloned
    ocrGuid_t readerEdtTemplateGuid;
    ocrEdtTemplateCreate(&readerEdtTemplateGuid, readerEdt, 0, 3);

    ocrGuid_t dbGuids [3] = {dbGuid, dbGuid, dbGuid};
    ocrGuid_t readerEdtGuid;
    ocrEdtCreate(&readerEdtGuid, readerEdtTemplateGuid, 0, NULL, 3, dbGuids,
                 EDT_PROP_NONE, NULL_HINT, NULL);

    return NULL_GUID;
}
Beispiel #13
0
int main (int argc, char ** argv) {
    ocrEdt_t fctPtrArray [1];
    fctPtrArray[0] = &task_for_edt;
    ocrInit(&argc, argv, 1, fctPtrArray);

    // Current thread is '0' and goes on with user code.
    ocrGuid_t event_guid;
    ocrEventCreate(&event_guid, OCR_EVENT_STICKY_T, true);

    // Creates the EDT
    ocrGuid_t edt_guid;

    ocrEdtCreate(&edt_guid, task_for_edt, /*paramc=*/0, /*params=*/ NULL,
                 /*paramv=*/NULL, /*properties=*/0,
                 /*depc=*/1, /*depv=*/NULL);

    // Register a dependence between an event and an edt
    ocrAddDependence(event_guid, edt_guid, 0);
    // Schedule the EDT (will run when dependences satisfied)
    ocrEdtSchedule(edt_guid);

    int *k;
    ocrGuid_t db_guid;
    ocrDbCreate(&db_guid, (void **) &k, sizeof(int), /*flags=*/FLAGS,
                /*location=*/NULL, NO_ALLOC);
    *k = 42;

    ocrEventSatisfy(event_guid, db_guid);

    ocrCleanup();

    return 0;
}
Beispiel #14
0
ocrGuid_t realMainEdt(u32 paramc, u64 *paramv, u32 depc, ocrEdtDep_t depv[]){
/*
paramv[0]: number of workers for GSi to create
depv
0: userSharedBlock
1: GSsharedBlock
realMain launches the GS initialization
*/
    u64 i, mynode;
    ocrGuid_t once;
    userSharedBlock_t * uSB = depv[0].ptr;
    GSsharedBlock_t * SB = depv[1].ptr;
    SB->numnodes = N;  //setting the number of "ranks"   REQUIRED
    ocrEdtTemplateCreate(&(uSB->cgTemplate), cgTask, 3, 4);
    SB->userBlock = depv[0].guid;   //passed through GSiEDT to computeInitEdt
    ocrGuid_t gsBlock, GSi, sticky, dummy;
    ocrEdtTemplateCreate(&(SB->GSiTemplate), GSiEdt, 3, 2);  //needed both to launch GSiEDT and inside for cloning REQUIRED
    ocrDbCreate(&(gsBlock), (void**) &dummy, sizeof(gsBlock_t), 0, NULL_GUID, NO_ALLOC); //needed for GSiEDT   REQUIRED
//create and luanch GSiEdt
    u64 GSparamvout[3] = {0, NULL_GUID, NULL_GUID};  //REQUIRED
    ocrEdtCreate(&GSi, SB->GSiTemplate, EDT_PARAM_DEF, GSparamvout, EDT_PARAM_DEF, NULL_GUID, EDT_PROP_NONE, NULL_GUID, NULL_GUID);  //REQUIRED
    ocrDbRelease(depv[1].guid);
    ocrAddDependence(depv[1].guid, GSi, 0, DB_MODE_RW);  //REQUIRED
    ocrAddDependence(gsBlock, GSi, 1, DB_MODE_RW);  //REQUIRED
    return NULL_GUID;
}
Beispiel #15
0
ocrGuid_t mainEdt(u32 paramc, u64* paramv, u32 depc, ocrEdtDep_t depv[]) {
    // Current thread is '0' and goes on with user code.
    ocrGuid_t ndepv[1];
    ocrGuid_t eventGuid;
    ocrEventCreate(&eventGuid, OCR_EVENT_STICKY_T, true);
    ndepv[0] = eventGuid;

    // Creates the EDT
    u32 nparamc = 1;
    u64 nparamv = 32;

    // 'ndepv' stores dependencies, so no need to call
    // ocrAddDependence later on to register events.
    ocrGuid_t edtGuid;
    ocrGuid_t taskForEdtTemplateGuid;
    ocrEdtTemplateCreate(&taskForEdtTemplateGuid, taskForEdt, nparamc, 1 /*depc*/);
    ocrEdtCreate(&edtGuid, taskForEdtTemplateGuid, EDT_PARAM_DEF, &nparamv, EDT_PARAM_DEF, /*depv=*/ndepv,
                 /*properties=*/0, NULL_HINT, /*outEvent=*/NULL);

    int *k;
    ocrGuid_t dbGuid;
    ocrDbCreate(&dbGuid,(void **) &k,
                sizeof(int), /*flags=*/DB_PROP_NONE,
                /*location=*/NULL_HINT,
                NO_ALLOC);
    *k = 42;

    ocrEventSatisfy(eventGuid, dbGuid);

    return NULL_GUID;
}
Beispiel #16
0
ocrGuid_t mainEdt(u32 paramc, u64* paramv, u32 depc, ocrEdtDep_t depv[]) {
    // Creates a data block
    int *k;
    ocrGuid_t dbGuid;
    ocrDbCreate(&dbGuid,(void **) &k,
            sizeof(int), /*flags=*/0,
            /*location=*/NULL_GUID,
            NO_ALLOC);
    *k = 42;

    ocrGuid_t eventGuid;
    ocrEventCreate(&eventGuid, OCR_EVENT_STICKY_T, true);

    // Creates the EDT
    ocrGuid_t edtGuid;
    ocrGuid_t taskForEdtTemplateGuid;
    ocrEdtTemplateCreate(&taskForEdtTemplateGuid, taskForEdt, 0 /*paramc*/, 1 /*depc*/);
    ocrEdtCreate(&edtGuid, taskForEdtTemplateGuid, EDT_PARAM_DEF, /*paramv=*/NULL, EDT_PARAM_DEF, /*depv=*/NULL,
                    /*properties=*/0, NULL_GUID, /*outEvent=*/NULL);

    ocrAddDependence(eventGuid, edtGuid, 0, DB_MODE_RO);

    // Register a dependence between a db and an event
    // (equivalent to directly satisfying the DB)
    ocrAddDependence(dbGuid, eventGuid, 0, DB_MODE_RO);

    // No need to satisfy as addDependence is equivalent to a satisfy
    // when the source is a datablock

    return NULL_GUID;
}
Beispiel #17
0
// Create an event at the current affinity and writes
// the GUID into the domainSetup data-structure.
void domainSetup(ocrGuid_t userSetupDoneEvt, domainSetup_t * dsetup) {
    // This is for the domain kernel to callback and stop the timer
    ocrGuid_t stopTimerEvt;
    ocrEventCreate(&stopTimerEvt, OCR_EVENT_ONCE_T, true);

    // Create an EDT at a remote affinity to:
    // - Create a remote latch event and initialize it
    // - Hook that event to the local event declared above
    // - write back the guid of the remote latch event into the setup DB

    // - userSetupDoneEvt: to be satisfied when setup is done
    // - stopTimerEvt: to be satisfied when domain kernel is done
    dsetup->userSetupDoneEvt = userSetupDoneEvt;
    dsetup->stopTimerEvt = stopTimerEvt;

    u64 affinityCount;
    ocrAffinityCount(AFFINITY_PD, &affinityCount);
    ocrGuid_t remoteAffGuid;
    ocrAffinityGetAt(AFFINITY_PD, affinityCount-1, &remoteAffGuid);
    ocrHint_t edtHint;
    ocrHintInit(&edtHint, OCR_HINT_EDT_T);
    ocrSetHintValue(&edtHint, OCR_HINT_EDT_AFFINITY, ocrAffinityToHintValue(remoteAffGuid));
    ocrGuid_t edtTemplGuid;
    ocrEdtTemplateCreate(&edtTemplGuid, remoteSetupUserEdt, 0, 1);
    ocrGuid_t edtGuid;
    ocrEdtCreate(&edtGuid, edtTemplGuid,
                 0, NULL, 1, NULL, EDT_PROP_NONE, &edtHint, NULL);
    // EW addresses the race that the current caller owns the DB and we're
    // trying to start the remote setup EDT concurrently. Since we do not have
    // the caller event we can't setup a proper dependence and rely on EW instead.
    ocrAddDependence(dsetup->self, edtGuid, 0, DB_MODE_EW);
    ocrEdtTemplateDestroy(edtTemplGuid);
}
Beispiel #18
0
// This is the "key" EDT that is responsible for spawning all the workers
ocrGuid_t keyEdt ( u32 paramc, u64* paramv, u32 depc, ocrEdtDep_t depv[]) {
    ocrGuid_t templateGuid;
    ocrEdtTemplateCreate(&templateGuid, workerEdt, 0, 0);

    ocrGuid_t edtGuid;
    ocrEdtCreate(&edtGuid, templateGuid, 0, NULL, 0, NULL, EDT_PROP_FINISH, NULL_HINT, NULL);
    return NULL_GUID;
}
Beispiel #19
0
//TODO: This is pretty much 'combine' but with different depv
void iterate(ocrGuid_t * edtGuid, ocrGuid_t edtTemplGuid,
            ocrGuid_t prevDoneEvt, ocrGuid_t dataGuid, ocrGuid_t nextDoneEvt) {
    u64 paramv[1];
    paramv[0] = (u64) nextDoneEvt.guid;
    ocrGuid_t depv[2];
    depv[0] = dataGuid;
    depv[1] = prevDoneEvt;
    ocrEdtCreate(edtGuid, edtTemplGuid,
                 1, paramv, 2, depv, EDT_PROP_NONE, NULL_HINT, NULL);
}
Beispiel #20
0
ocrGuid_t mainEdt ( u32 paramc, u64* paramv, u32 depc, ocrEdtDep_t depv[]) {
    u64 size = -1;
    u64 offset = -1;
    u32 i = 0;
    u64 argc;

    void *programArg = depv[0].ptr;
    argc = getArgc(programArg);
    if ( argc !=  4 ) {
        PRINTF("Usage: ./basicIO offset size fileName \n");
        ocrShutdown();
        return 1;
    }

    offset = atoi(getArgv(programArg, 1));
    size = atoi(getArgv(programArg, 2));
    u64 nparamv[2];
    nparamv[0] = offset;
    nparamv[1] = size;
    FILE *in;
    in = fopen(getArgv(programArg, 3), "r");
    if( !in ) {
        PRINTF("Cannot find file: %s\n", getArgv(programArg, 3));
        ocrShutdown();
        return NULL_GUID;
    }
    ocrGuid_t dataGuid;
    // Data can be passed as parameter also , there was no
    // necessary need of creating data block  in this example.
    // Its has been created for demo purpose
    //Create datablock to hold a block of 'size' elements
    u64 *inputarr;
    ocrDbCreate(&dataGuid, (void**)&inputarr, sizeof(u64)*size,0,NULL_GUID, NO_ALLOC);
#ifndef TG_ARCH
    while(fscanf(in,"%llu\n",&inputarr[i++])!=EOF);
#else
    fread(inputarr, sizeof(u64),size , in);

#endif
    fclose(in);

    ocrGuid_t addEdtTemplateGuid;
    ocrEdtTemplateCreate(&addEdtTemplateGuid, add_edt, 2 /*paramc*/, 1 /*depc*/);
    ocrGuid_t add_edt_guid;
    // Create the EDT not specifying the dependence vector at creation
    ocrEdtCreate(&add_edt_guid, addEdtTemplateGuid, EDT_PARAM_DEF, nparamv,1,NULL ,EDT_PROP_FINISH , NULL_GUID, NULL);

    ocrGuid_t triggerEventGuid;
    ocrEventCreate(&triggerEventGuid, OCR_EVENT_STICKY_T, true);

    ocrAddDependence(triggerEventGuid, add_edt_guid, 0, DB_MODE_EW);
    ocrEventSatisfy(triggerEventGuid, dataGuid);
    return NULL_GUID;
}
Beispiel #21
0
ocrGuid_t mainEdt(u32 paramc, u64* paramv, u32 depc, ocrEdtDep_t depv[]) {
    ocrGuid_t e0;
    ocrEventCreate(&e0, OCR_EVENT_STICKY_T, false);
    ocrGuid_t terminateEdtGuid;
    ocrGuid_t terminateEdtTemplateGuid;
    ocrEdtTemplateCreate(&terminateEdtTemplateGuid, terminateEdt, 0 /*paramc*/, EDT_PARAM_UNK /*depc*/);
    ocrEdtCreate(&terminateEdtGuid, terminateEdtTemplateGuid, EDT_PARAM_DEF, NULL, 1, NULL_GUID,
                    /*properties=*/EDT_PROP_FINISH, NULL_GUID, /*outEvent=*/ NULL);
    ocrAddDependence(e0, terminateEdtGuid, 0, DB_MODE_RO);
    ocrEventSatisfy(e0, NULL_GUID);
    return NULL_GUID;
}
ocrGuid_t mainEdt(u32 paramc, u64* paramv, u32 depc, ocrEdtDep_t depv[]) {
    ocrGuid_t terminateEdtGuid;
    ocrGuid_t terminateEdtTemplateGuid;
    ocrEdtTemplateCreate(&terminateEdtTemplateGuid, terminateEdt, EDT_PARAM_UNK /*paramc*/, 0 /*depc*/);
    u8 res = ocrEdtCreate(&terminateEdtGuid, terminateEdtTemplateGuid, 1, NULL, 0, NULL,
                 /*properties=*/EDT_PROP_FINISH, NULL_HINT, /*outEvent=*/ NULL);
    ASSERT(!res);
    if(res) {
        ocrAbort(res);
    }
    return NULL_GUID;
}
Beispiel #23
0
void chain(ocrGuid_t * edtGuid, ocrGuid_t edtTemplGuid, ocrGuid_t affinity,
            ocrGuid_t prevDoneEvt, ocrGuid_t nextDoneEvt) {
    u64 paramv[1];
    paramv[0] = (u64) nextDoneEvt.guid;
    ocrGuid_t depv[1];
    depv[0] = prevDoneEvt;
    ocrHint_t edtHint;
    ocrHintInit(&edtHint, OCR_HINT_EDT_T);
    ocrSetHintValue(&edtHint, OCR_HINT_EDT_AFFINITY, ocrAffinityToHintValue(affinity));
    ocrEdtCreate(edtGuid, edtTemplGuid,
                 1, paramv, 1, depv, EDT_PROP_NONE, &edtHint, NULL);
}
Beispiel #24
0
ocrGuid_t finishEdt(u32 paramc, u64* paramv, u32 depc, ocrEdtDep_t depv[]) {
    ocrGuid_t edtTemplateGuid;
    ocrEdtTemplateCreate(&edtTemplateGuid, remoteEdt, 0, 1);

    ocrGuid_t eventsGuid[COUNT_EDT];
    ocrGuid_t dbsGuid[COUNT_EDT];
    u64 i = 0;
    while(i < COUNT_EDT) {
        ocrEventCreate(&eventsGuid[i],OCR_EVENT_ONCE_T, EVT_PROP_NONE);
        ocrGuid_t * dbPtr;
        ocrDbCreate(&dbsGuid[i], (void **)&dbPtr, sizeof(ocrGuid_t), DB_PROP_SINGLE_ASSIGNMENT, NULL_HINT, NO_ALLOC);
        dbPtr[0] = eventsGuid[i];
        ocrDbRelease(dbsGuid[i]);
        i++;
    }

    // Setup shutdown EDT
    ocrGuid_t shutdownEdtTemplateGuid;
    ocrEdtTemplateCreate(&shutdownEdtTemplateGuid, shutdownEdt, 0, COUNT_EDT);

    ocrGuid_t shutdownEdtGuid;
    ocrEdtCreate(&shutdownEdtGuid, shutdownEdtTemplateGuid, 0, NULL, EDT_PARAM_DEF, eventsGuid,
                 EDT_PROP_NONE, NULL_HINT, NULL);
    ocrGuid_t currentAffinity;
    ocrAffinityGetCurrent(&currentAffinity);

    ocrHint_t edtHint;
    ocrHintInit( &edtHint, OCR_HINT_EDT_T );
    ocrSetHintValue( & edtHint, OCR_HINT_EDT_AFFINITY, ocrAffinityToHintValue( currentAffinity) );
    // Spawn 'COUNT_EDT' EDTs, each satisfying its event
    i = 0;
    while(i < COUNT_EDT) {
        // Create EDTs
        ocrGuid_t edtGuid;
        ocrEdtCreate(&edtGuid, edtTemplateGuid, 0, NULL, EDT_PARAM_DEF, &dbsGuid[i],
            EDT_PROP_NONE, &edtHint, NULL);
        i++;
    }
    return NULL_GUID;
}
Beispiel #25
0
void combine(ocrGuid_t * edtGuid, ocrGuid_t edtTemplGuid, ocrGuid_t affinity,
             ocrGuid_t firstEvt, ocrGuid_t secondEvt, ocrGuid_t resultEvt) {
    u64 paramv[1];
    paramv[0] = (u64) resultEvt.guid;
    ocrGuid_t depv[2];
    depv[0] = firstEvt;
    depv[1] = secondEvt;
    ocrHint_t edtHint;
    ocrHintInit(&edtHint, OCR_HINT_EDT_T);
    ocrSetHintValue(&edtHint, OCR_HINT_EDT_AFFINITY, ocrAffinityToHintValue(affinity));
    ocrEdtCreate(edtGuid, edtTemplGuid,
                 1, paramv, 2, depv, EDT_PROP_NONE, &edtHint, NULL);
}
Beispiel #26
0
inline static void lapacke_dpotrf_task_prescriber (ocrGuid_t edtTemp, u32 k,
                                                   u32 tileSize, ocrGuid_t*** lkji_event_guids) {
    ocrGuid_t seq_cholesky_task_guid;

    u64 func_args[3];
    func_args[0] = k;
    func_args[1] = tileSize;
    func_args[2] = (u64)(lkji_event_guids[k][k][k+1]);

    ocrGuid_t affinity = NULL_GUID;
    ocrEdtCreate(&seq_cholesky_task_guid, edtTemp, 3, func_args, 1, NULL, PROPERTIES, affinity, NULL);

    ocrAddDependence(lkji_event_guids[k][k][k], seq_cholesky_task_guid, 0, DB_MODE_RW);
}
Beispiel #27
0
int main(int argc, const char * argv[]) {
    ocrConfig_t ocrConfig;
    ocrGuid_t legacyCtx;
    ocrParseArgs(argc, argv, &ocrConfig);
    ocrLegacyInit(&legacyCtx, &ocrConfig);
    ocrGuid_t rootEdtGuid;
    ocrGuid_t rootEdtTemplateGuid;
    ocrEdtTemplateCreate(&rootEdtTemplateGuid, rootEdt, 0 /*paramc*/, 0 /*depc*/);
    ocrEdtCreate(&rootEdtGuid, rootEdtTemplateGuid, EDT_PARAM_DEF, /*paramv=*/NULL, EDT_PARAM_DEF, /*depv=*/NULL,
                 /*properties=*/0, NULL_HINT, /*outEvent=*/NULL);
    // This should wait for the EDT to finish
    ocrLegacyFinalize(legacyCtx, true);
    return 0;
}
Beispiel #28
0
ocrGuid_t mainEdt(u32 paramc, u64* paramv, u32 depc, ocrEdtDep_t depv[]) {
    PRINTF("Starting mainEdt\n");
    ocrGuid_t edt1_template, edt2_template, edt3_template;
    ocrGuid_t edt1, edt2, edt3, outputEvent1, outputEvent2;

    //Create templates for the EDTs
    ocrEdtTemplateCreate(&edt1_template, fun1, 0, 1);
    ocrEdtTemplateCreate(&edt2_template, fun2, 0, 1);
    ocrEdtTemplateCreate(&edt3_template, shutdownEdt, 0, 2);

    //Create the EDTs
    ocrEdtCreate(&edt1, edt1_template, EDT_PARAM_DEF, NULL, EDT_PARAM_DEF, NULL, EDT_PROP_NONE, NULL_HINT, &outputEvent1);
    ocrEdtCreate(&edt2, edt2_template, EDT_PARAM_DEF, NULL, EDT_PARAM_DEF, NULL, EDT_PROP_NONE, NULL_HINT, &outputEvent2);
    ocrEdtCreate(&edt3, edt3_template, EDT_PARAM_DEF, NULL, 2, NULL, EDT_PROP_NONE, NULL_HINT, NULL);

    //Setup dependences for the shutdown EDT
    ocrAddDependence(outputEvent1, edt3, 0, DB_MODE_CONST);
    ocrAddDependence(outputEvent2, edt3, 1, DB_MODE_CONST);

    //Start execution of the parallel EDTs
    ocrAddDependence(NULL_GUID, edt1, 0, DB_DEFAULT_MODE);
    ocrAddDependence(NULL_GUID, edt2, 0, DB_DEFAULT_MODE);
    return NULL_GUID;
}
Beispiel #29
0
inline static void cblas_dsyrk_task_prescriber ( ocrGuid_t edtTemp, u32 k, u32 j, u32 i,
                                                 u32 tileSize, ocrGuid_t*** lkji_event_guids) {
    ocrGuid_t cblas_dsyrk_task_guid;

    u64 func_args[5];
    func_args[0] = k;
    func_args[1] = j;
    func_args[2] = i;
    func_args[3] = tileSize;
    func_args[4] = (u64)(lkji_event_guids[j][j][k+1]);

    ocrGuid_t affinity = NULL_GUID;
    ocrEdtCreate(&cblas_dsyrk_task_guid, edtTemp, 5, func_args, 2, NULL, PROPERTIES, affinity, NULL);

    ocrAddDependence(lkji_event_guids[j][j][k], cblas_dsyrk_task_guid, 0, DB_MODE_RW);
    ocrAddDependence(lkji_event_guids[j][k][k+1], cblas_dsyrk_task_guid, 1, DB_MODE_RW);
}
Beispiel #30
0
ocrGuid_t mainEdt(u32 paramc, u64* paramv, u32 depc, ocrEdtDep_t depv[]) {
    u64 affinityCount;
    ocrAffinityCount(AFFINITY_PD, &affinityCount);
    ASSERT(affinityCount >= 1);
    ocrGuid_t affinities[affinityCount];
    ocrAffinityGet(AFFINITY_PD, &affinityCount, affinities);
    ocrGuid_t edtAffinity = affinities[affinityCount-1];

    ocrGuid_t edtTemplateGuid;
    ocrEdtTemplateCreate(&edtTemplateGuid, remoteEdt, 2, 0);
    ocrHint_t edtHint;
    ocrHintInit( &edtHint, OCR_HINT_EDT_T );
    ocrSetHintValue( & edtHint, OCR_HINT_EDT_AFFINITY, ocrAffinityToHintValue( edtAffinity) );
    ocrGuid_t edtGuid;
    u64 edtParamv[2] = {333,555};
    ocrEdtCreate(&edtGuid, edtTemplateGuid, EDT_PARAM_DEF, (u64*) &edtParamv, 0, NULL,
        EDT_PROP_NONE, &edtHint, NULL);
    return NULL_GUID;
}