Пример #1
0
/*
  get local variable
    SET_LOCAL [context local index] [scope index]

*/
void
Violet::Generator::setLocal(std::string name, Context *context)
{
  std::vector<int> operands;
  int local_index = -1;

  if( (this->scopes[scopeIndex(context)])->getParent() != NULL)
  {
    local_index = getLocalIndex(literalIndex(name),&((this->scopes[scopeIndex(context->getParent())])->local_bytes));
  }

  if(local_index < 0)
  {
    operands.push_back(
      localIndex(literalIndex(name), this->scopes[scopeIndex(context)])
    );
  }
  else
  {
    context = context->getParent();
    operands.push_back(
      localIndex(literalIndex(name), this->scopes[scopeIndex(context)])
    );
  }
  operands.push_back(scopeIndex(context));
  emit(SET_LOCAL, operands);
}
Пример #2
0
		void verify() {
			typedef std::vector<BFSVertex>::iterator Iterator;
			for (Iterator it = vertices.begin(); it != vertices.end(); it++) 
				it->verify(*this);
			while (!q.empty()) {
				dtype data = q.front();
				CkAssert(getBaseIndex(data.v) == thisIndex);
				q.pop_front();
				vertices[getLocalIndex(data.v)].check(data.level);
			}
		}
Пример #3
0
		inline void process(const dtype & data) {

			q.push_back(data);
			while (!q.empty()) {
				dtype d = q.front();
				CkAssert(getBaseIndex(d.v) == thisIndex);

				q.pop_front();
				vertices[getLocalIndex(d.v)].update(*this, d.level, d.parent);
			}
		}
Пример #4
0
/*
  get local variable
    GET_LOCAL [literal index] [scope index]
*/
void
Violet::Generator::getLocal(std::string name, Context *context)
{
  std::vector<int> operands;
  int local_index = getLocalIndex(literalIndex(name),&((this->scopes[scopeIndex(context)])->local_bytes));

  // does the local variable exist?
  if(local_index < 0 && (this->scopes[scopeIndex(context)])->getParent() != NULL )
  {
    // check the parent context
    context     = context->getParent();
    local_index = getLocalIndex(literalIndex(name),&((this->scopes[scopeIndex(context)])->local_bytes));
  }

  if(local_index < 0)
    throw std::out_of_range("Call to undefined variable '"+name+"'.");

  operands.push_back(local_index);
  operands.push_back(scopeIndex(context));
  emit(GET_LOCAL, operands);
}
Пример #5
0
int getCellScore (ProcessData * pData, ScoringData * sData, WavesData * wData, MOATypeShape * cellIndex, MOATypeElmVal * score, int * inSearchSpace, int NeighborSearch, MOATypeInd NeighbIndex) {
    int ret = 0;
    MOATypeDimn k;
    MOATypeInd NeighbFlatIndex;
    /*Check if cellIndex is found in the current scoring partition*/
    if ((NeighborSearch == 1) && (IsCellInPart(cellIndex, sData->p_index, sData->seqNum, sData->seqLen, pData->partitionSize) == 0) && 
        (getLocalIndex (cellIndex, sData->p_index, sData->seqNum, sData->seqLen, pData->partitionSize, &sData->neighbor) == 0)) {
        NeighbFlatIndex = Gamma(sData->neighbor, sData->msaAlgn->dimn, sData->msaAlgn->shape,  sData->msaAlgn->dimn, 1);
       (*score) = sData->msaAlgn->elements[NeighbFlatIndex].val;
       if (sData->msaAlgn->elements[NeighbFlatIndex].prev != NULL && sData->msaAlgn->elements[NeighbFlatIndex].prev_ub > 0 && 
           sData->NghbMOA != NULL && NeighbIndex >= 0 && NeighbIndex < sData->NghbMOA->elements_ub) {
           sData->NghbMOA->elements[NeighbIndex].prev = mmalloc(sizeof *sData->NghbMOA->elements[NeighbIndex].prev);
           sData->NghbMOA->elements[NeighbIndex].prev_ub = 1;
           sData->NghbMOA->elements[NeighbIndex].prev[0] = mmalloc(sData->seqNum * sizeof *sData->NghbMOA->elements[NeighbIndex].prev[0]);
           for (k=0;k<sData->seqNum;k++)
                sData->NghbMOA->elements[NeighbIndex].prev[0][k] = sData->msaAlgn->elements[NeighbFlatIndex].prev[0][k];
       }
    }
    else {
        /*check if neighbor's partition is included in search space*/
        MOATypeShape * partIndex = mmalloc (pData->seqNum * sizeof *partIndex);
        if  (getPartitionIndex (cellIndex, pData->seqNum, pData->seqLen, wData->partitionSize, &partIndex) == 0) {
            if ((*inSearchSpace) = isPartInSearchSpace(partIndex, wData) == 0) {
                long waveNo, partNo;
                getPartitionPosition (wData, partIndex, &waveNo, &partNo);
                if (partNo >= 0) {
                    if (myProcid == getProcID (wData, waveNo, partNo)) {                        
                        /*Check if Neighbor is found in other local partitions OCout Buffer*/
                        if(checkPrevPartitions(pData, cellIndex, score) != 0) {
                            /*average the neighboring (up to 2 strides) cell scores*/
                            (*score) = averageNeighborsScore(pData, sData, wData, cellIndex);
                        }
                    }
                    /*Check if Neighbor is already received from other processors in OCin Buffer*/
                    else if (checkRecvOC(pData, wData, cellIndex, score, 0) != 0)    
                        ret = -1;
                }
            }
        }
        free (partIndex);
    }
    return ret;
}
Пример #6
0
		void check(const CmiUInt8 & v, int level) {
			vertices[getLocalIndex(v)].check(level);
		}
Пример #7
0
		void connectVertex(const std::pair<CmiUInt8, BFSEdge> & edge) {
			vertices[getLocalIndex(edge.first)].connectVertex(edge.second);
		}