void writeDataToLMem(uint64_t *dataIn, int size, int sizeBytes, int burstLengthInBytes, max_engine_t *engine, max_file_t *maxfile) { printf("size=%d, sizeBytes=%d, burstLengthInBytes=%d\n", size, sizeBytes, burstLengthInBytes); printf("Performing max_actions_init()\n"); max_actions_t *actions = max_actions_init(maxfile, NULL); printf("Done\n"); max_set_ticks(actions, "KernelLMem_Write_CommandAndDataStream", size); max_set_uint64t(actions, "KernelLMem_Write_CommandAndDataStream", "totalBursts", size * 8 / burstLengthInBytes); max_set_uint64t(actions, "KernelLMem_Write_CommandAndDataStream", "wordsPerBurst", burstLengthInBytes / 8); max_set_ticks(actions, "KernelLMem_Read_CommandAndDataStream", 0); max_set_uint64t(actions, "KernelLMem_Read_CommandAndDataStream", "totalBursts", size * 8 / burstLengthInBytes); max_set_uint64t(actions, "KernelLMem_Read_CommandAndDataStream", "wordsPerBurst", burstLengthInBytes / 8); max_run(engine, actions); max_reset_engine(engine); max_queue_input(actions, "fromCpu", dataIn, sizeBytes); max_lmem_set_interrupt_on(actions, "toLmem"); printf("Performing max_run()\n"); max_run(engine, actions); printf("Done\n"); max_actions_free(actions); }
void readDataFromLMem(uint64_t *dataOut, int size, int sizeBytes, int burstLengthInBytes, max_engine_t *engine, max_file_t *maxfile) { max_actions_t *actions = max_actions_init(maxfile, NULL); max_set_ticks(actions, "KernelLMem_Write_CommandAndDataStream", 0); max_set_uint64t(actions, "KernelLMem_Write_CommandAndDataStream", "totalBursts", size * 8 / burstLengthInBytes); max_set_uint64t(actions, "KernelLMem_Write_CommandAndDataStream", "wordsPerBurst", burstLengthInBytes / 8); max_set_ticks(actions, "KernelLMem_Read_CommandAndDataStream", size); max_set_uint64t(actions, "KernelLMem_Read_CommandAndDataStream", "totalBursts", size * 8 / burstLengthInBytes); max_set_uint64t(actions, "KernelLMem_Read_CommandAndDataStream", "wordsPerBurst", burstLengthInBytes / 8); max_run(engine, actions); max_reset_engine(engine); max_queue_output(actions, "toCpu", dataOut, sizeBytes); max_run(engine, actions); max_actions_free(actions); }
/** * Runs the main action to compute a predictor or corrector step */ void AirfoilDFEInterface::runMainAction(int k, double cfl, double gam, double gm1, double eps, double *rms) { int cpuresind = 0; int schedind = 0; for (int d = 1; d < (*domain).ndomain; d++){ for (int res_edge_iter = 0; res_edge_iter < (*domain).nedge[d]; res_edge_iter++){ int thispart = d; int thisind = res_edge_iter; for (int i = 0; i < 2; i++){ int thiscellpart = (*domain).ecellpart[thispart][thisind*2+i]; int thiscellind = (*domain).ecellind[thispart][thisind*2+i]; if (reads[7*schedind+3] == 1){ for (int j = 0; j < 4; j++) { cpu_res_qpadt[cpuresind*5+j] = (*domain).q[thiscellpart][4*thiscellind+j]; } cpu_res_qpadt[cpuresind*5+4] = (*domain).adt[thiscellpart][thiscellind]; cpuresind ++; } schedind ++ ; } } } max_actions_t * act = max_actions_init(maxfile, NULL); max_set_ticks(act, "AirfoilDFEAdtKernel", (*domain).ncellcomputedfe); max_set_uint64t(act, "AirfoilDFEAdtKernel", "numTicks", (*domain).ncellcomputedfe); max_set_double(act, "AirfoilDFEAdtKernel", "cfl", cfl); max_set_double(act, "AirfoilDFEAdtKernel", "gam", gam); max_set_double(act, "AirfoilDFEAdtKernel", "gm1", gm1); max_lmem_linear(act, "adtQ", memAddresses[q], memAddresses[q+1] - memAddresses[q]); max_lmem_linear(act, "adtDxRead", memAddresses[adtDx], adtDxDatSize); max_set_ticks(act, "AirfoilDFEResKernel", resFlushTicks); max_set_double(act, "AirfoilDFEResKernel", "gm1", gm1); max_set_double(act, "AirfoilDFEResKernel", "eps", eps); max_set_uint64t(act, "AirfoilDFEResKernel", "nTicks", resFlushTicks); max_queue_input(act, "cpu_qpadt_to_res", cpu_res_qpadt, cpuQpadtSize); max_lmem_linear(act, "resReadOnly", memAddresses[resReadOnly], resReadOnlyDatSize); max_queue_output(act,"cpu_res_from_res", dfe_res_res, passtorescount*sizeof(double)*4); double * rmsOut = (double *) malloc(16*sizeof(double)); max_set_ticks(act,"AirfoilDFEUpdateKernel", (*domain).ncellcomputedfe); max_set_uint64t(act, "AirfoilDFEUpdateKernel", "numCells", (*domain).ncellcomputedfe); max_set_uint64t(act, "AirfoilDFEUpdateKernel", "doSaveQold", k==1); max_lmem_linear(act, "updateQ", memAddresses[q], memAddresses[q+1] - memAddresses[q]); max_lmem_linear(act, "updateQold", memAddresses[qold], memAddresses[qold+1] - memAddresses[qold]); max_queue_output(act,"rmsOut", rmsOut, 16*sizeof(double)); if (k == 0) { max_ignore_lmem(act, "updateSaveQold"); } else { max_lmem_linear(act, "updateSaveQold", memAddresses[qold], memAddresses[qold+1] - memAddresses[qold]); } max_ignore_lmem(act, "setupWrite"); max_ignore_lmem(act, "qRead"); max_run(engine, act); max_actions_free(act); for (int i = 0; i < 16; i++) (*rms) += rmsOut[i]; cpuresind = 0; schedind = 0; for (int d = 1; d < (*domain).ndomain; d++){ for (int res_edge_iter = 0; res_edge_iter < (*domain).nedge[d]; res_edge_iter++){ int thispart = d; int thisind = res_edge_iter; for (int i = 0; i < 2; i++){ int thiscellpart = (*domain).ecellpart[thispart][thisind*2+i]; int thiscellind = (*domain).ecellind[thispart][thisind*2+i]; if (reads[7*schedind+3] == 1){ for (int j = 0; j < 4; j++) { (*domain).res[thiscellpart][4*thiscellind+j] += dfe_res_res[cpuresind*4+j]; } cpuresind ++; } schedind ++ ; } } } }