//start execution or continue execution of instructions //in the reservation stations. During the last execution //cycle of an instruction, call compute result void FUnitContainer::execute() { int32_t rsCount = this->RS->getRScount(); // find a reservation station that can begin execution for(int i = 0; i < rsCount; i++) { RStation * station = this->RS->getRStation(i); // if the station meets the following criteria: // an instruction waiting to execute // values in Vk and Vj and not waiting on values at locations in Qj or Qk // it has not been assigned a functional unit // it is not waiting to write it's result // we can begin execution if (station->busy && station->Qj.compare("") == 0 && station->Qk.compare("") == 0 && station->fu == NULL && !station->resultReady) { // try to find the station a functional unit FUnit * unit = FU->getFU(); // we can't begin executing this instruction because we are out of functional units. if (unit == NULL) { return; } station->fu = unit; station->ExStart = Clock::clock; // The cycle ends when the funit is complete station->ExEnd = Clock::clock + unit-> maxCycles - 1; } // if we are on the last cycle we can compute the result if(station->ExEnd == Clock::clock) { computeResult(station); } } }
// compute final result of responding postfix ElementType compute_postfix() { Stack output; int i; ElementType *p; int value; int operand1; int operand2; output = createStack(Size); // create stack with length Size i = 0; p = getArray(operand); // get operand->array while(i < getTopOfStack(operand)) { value = *(p+i++); if(value == ' ') continue; if(isOperator(value)) { operand1 = top(output); pop(output); operand2 = top(output); pop(output); value = computeResult(operand1, operand2, value); push(value, output); continue; } push(value - 48, output); } return getArray(output)[0]; }
void App::cudaProbabilisticHoughLinesV_DispCall() { if (v_disparityImage != NULL) { QImage img(*v_disparity_N_Image); std::chrono::duration<double> elapsed_seconds; cv::Vec4i line; cudaProbabilisticHoughLines(*v_disparityImage, img, line, elapsed_seconds); char txt[128]; sprintf(txt, "Cuda Probabilistic Hough Lines V-Disparity: %f", elapsed_seconds.count()); elapsedTimeLabel->setText(QString(txt).append(" s")); v_disparity_N_Label->setPixmap(QPixmap::fromImage(img)); v_disparity_N_Label->adjustSize(); computeResult(line); resultLabel->setPixmap(QPixmap::fromImage(*result)); resultLabel->adjustSize(); } }
int main(void) { Message* message = NULL; Worker worker[4] = {0}; int i; int index; int ret; ret = allocate(sizeof(Message), 0, (void **) &message); if(ret != 0) _terminate(1); receiveMessage(message); worker[0].processMessage = identityMap; worker[1].processMessage = constantMap; worker[2].processMessage = absoluteValueMap; worker[3].processMessage = modulusCoordinatesWithDimensions; index = 0; permute(worker, 0, 3, &index, message->value[PERM_FIELD]); while(1) { worker[0].inbox = message; for(i=3; i>=0; i--) { processMessage(&worker[i]); if(i<3) worker[i+1].inbox = worker[i].outbox; } if(worker[3].outbox != NULL) { computeResult(worker[3].outbox); sendMessage(worker[3].outbox); ret = deallocate(worker[3].outbox->result[0], worker[3].outbox->value[LENGTH_FIELD]*worker[3].outbox->value[WIDTH_FIELD]*sizeof(short)); if (ret != 0) _terminate(2); ret = deallocate(worker[3].outbox->result, worker[3].outbox->value[LENGTH_FIELD]*sizeof(short*)); if (ret != 0) _terminate(2); ret = deallocate(worker[3].outbox, sizeof(Message)); if (ret != 0) _terminate(2); } ret = allocate(sizeof(Message), 0, (void **) &message); if(ret != 0) _terminate(1); receiveMessage(message); } }