Пример #1
0
void Block::_move_center(void)        // Correct Center On Each Rotation Status
{
        int my = 0, mx = 0;

        switch(blockId(_type) + _rotation * 4)
        {
        // BLK_I
        case 0 +  0:    my = -1, mx =  0;    break;
        case 0 +  4:    my =  0, mx = -1;    break;
        case 0 +  8:    my =  1, mx =  0;    break;
        case 0 + 12:    my =  0, mx =  1;    break;
        // BLK_S
        case 2 +  0:    my =  0, mx =  1;    break;
        case 2 +  4:    my = -1, mx =  0;    break;
        case 2 +  8:    my =  0, mx = -1;    break;
        case 2 + 12:    my =  1, mx =  0;    break;
        // BLK_Z
        case 3 +  0:    my =  0, mx = -1;    break;
        case 3 +  4:    my =  1, mx =  0;    break;
        case 3 +  8:    my =  0, mx =  1;    break;
        case 3 + 12:    my = -1, mx =  0;    break;
        default:        my =  0, mx =  0;    break;
        }

        switch (_type)
        {
        case BLK_I:
        case BLK_S:
        case BLK_Z:
                _y += my, _x += mx;
                _blocks.for_each([&](Array<int> &array) mutable -> void { array[0] -= my, array[1] -= mx; });
                break;
        case BLK_O:
        case BLK_L:
        case BLK_J:
        case BLK_T:
                break;
        case BLK_E:
                break;
        }
}
Пример #2
0
{
    unsigned long start;
    unsigned long stop;
    unsigned long currentBlockDim;
    unsigned long currentThreadId;
    unsigned long currentBlockId;
    
    start = clockCounter();
    syncThreads();    
    

    currentBlockDim = blockDim();
    currentThreadId = blockThreadId();
    currentBlockId = blockId();
        
    ON_BASIC_BLOCK_EXIT:
    {
            unsigned long offset = basicBlockCount() * basicBlockId() + currentBlockDim * currentBlockId + currentThreadId;
            globalMem[offset] = globalMem[offset] + basicBlockExecutedInstructionCount();
    }

    
   
    ON_KERNEL_EXIT:
    {
        syncThreads();
        stop = clockCounter();
        if (threadIndexX() == 0) {
            unsigned long total = basicBlockCount() * gridDim() * currentBlockDim;
            globalMem[currentBlockId * 2 + total] = stop - start;
            globalMem[currentBlockId * 2 + 1 + total] = smId();
Пример #3
0
{   
    unsigned long warpId = (blockId() * blockDim() + blockThreadId()) >> 5;

    ON_INSTRUCTION:
    BRANCH:
    {
        
        if(leastActiveThreadInWarp())
        {
            globalMem[warpId * 2] = globalMem[warpId * 2] + divergentWarp();
            globalMem[warpId * 2 + 1] = globalMem[warpId * 2 + 1] + 1;   
        }
    }
}
Пример #4
0
Acad::ErrorStatus
ArxDbgDbEntity::wblockClone(AcRxObject* pOwner, AcDbObject*& pClone,
                    AcDbIdMapping& idMap, Adesk::Boolean isPrimary) const
{
	if (ArxDbgOptions::m_instance.m_showWblockCloneDetails) {
		CString titleStr, tmpStr;
		titleStr.Format(_T("Beginning -- wblockClone: %s"),
				ArxDbgUtils::objToClassAndHandleStr(const_cast<ArxDbgDbEntity*>(this), tmpStr));
		ArxDbgUiTdmIdMap dbox(&idMap, acedGetAcadDwgView(), titleStr);
		dbox.DoModal();
	}

    AcDb::DeepCloneType type = idMap.deepCloneContext();

        // if xrefInsert or xrefBind, we know everything will
        // be cloned, so just let normal routine handle this
    if ((type == AcDb::kDcXrefBind) || (type == AcDb::kDcXrefInsert)) {
        return AcDbEntity::wblockClone(pOwner, pClone, idMap, isPrimary);
    }
		// if we've already been cloned, just return
	AcDbIdPair idPair(objectId(), AcDbObjectId::kNull, true);
    if (idMap.compute(idPair) && (idPair.value() != AcDbObjectId::kNull)) {
        return Acad::eOk;
    }

        // If isPrimary is kTrue, then override the default cloning
        // within our own cloning, which would set it to kFalse,
        // by cloning our referenced entity first.
    if (isPrimary) {
			// now ask derived classes what references they want cloned for them
		AcDbObjectIdArray refEntIds;
		AcDbIntArray refTypes;
		getCloneReferences(type, refEntIds, refTypes);

		ASSERT(refEntIds.length() == refTypes.length());

            // clone each entity we reference first and change the value
            // of isPrimary to fake it out.  Since we clone these first,
            // when the normal wblockClone is called, it will see that
            // they are already in the set of cloned objects and will not
            // try to clone it again.
        AcDbEntity* ent;
        Acad::ErrorStatus es;
		int len = refEntIds.length();
		for (int i=0; i<len; i++) {
			if (refTypes[i] == kClone) {
				es = acdbOpenAcDbEntity(ent, refEntIds[i], AcDb::kForRead);
				if (es == Acad::eOk) {
						// this method only works if they come from the same block
						// (which SHOULD always be the case!)
					if (blockId() == ent->blockId()) {
							// Use the same owner, and pass in the same isPrimary value
						AcDbObject* pSubClone = NULL;
						es = ent->wblockClone(pOwner, pSubClone, idMap, Adesk::kTrue);
						if (pSubClone != NULL)
							pSubClone->close();

						if (es != Acad::eOk) {
							ASSERT(0);
						}
					}
					else {
						ASSERT(0);
					}

					ent->close();
				}
			}
		}
    }
        // Now we can clone ourselves via calling our parent's method.
	Acad::ErrorStatus es =  AcDbEntity::wblockClone(pOwner, pClone, idMap, isPrimary);

	if (ArxDbgOptions::m_instance.m_showWblockCloneDetails) {
		CString titleStr, tmpStr;
		titleStr.Format(_T("End -- wblockClone: %s"),
				ArxDbgUtils::objToClassAndHandleStr(const_cast<ArxDbgDbEntity*>(this), tmpStr));
		ArxDbgUiTdmIdMap dbox(&idMap, acedGetAcadDwgView(), titleStr);
		dbox.DoModal();
	}

	return es;
}
Пример #5
0
{
    unsigned long threadId = blockThreadId();
    unsigned long warpId = (blockId() * blockDim() + threadId) >> 5;
    
    ON_INSTRUCTION:
    MEM_READ:
    MEM_WRITE:
    GLOBAL:
    {
        sharedMem[threadId] = computeBaseAddress();

        if(leastActiveThreadInWarp())
        {
            unsigned long uniqueCount = uniqueElementCount(sharedMem, 1);
            globalMem[warpId * 2] = globalMem[warpId * 2] + uniqueCount;
            globalMem[warpId * 2 + 1] = globalMem[warpId * 2 + 1] + 1;
        }
    }    
}