Exemplo n.º 1
0
static int EMSA_PKCSv15(const Ipp8u* msgDg, int lenMsgDg,
                        const Ipp8u* fixPS, int lenFixPS,
                              Ipp8u*   pEM, int lenEM)
{
   /*
   // encoded message format:
   //    EM = 00 || 01 || PS=(FF..FF) || 00 || T
   //    T = fixPS || msgDg
   //    len(PS) >= 8
   */
   int  tLen = lenFixPS + lenMsgDg;

   if(lenEM >= tLen+11) {
      int psLen = lenEM - 3 - tLen;

      PaddBlock(0xFF, pEM, lenEM);
      pEM[0] = 0x00;
      pEM[1] = 0x01;
      pEM[2+psLen] = 0x00;
      CopyBlock(fixPS, pEM+3+psLen, lenFixPS);
      CopyBlock(msgDg, pEM+3+psLen+lenFixPS, lenMsgDg);
      return 1;
   }
   else
      return 0; /* encoded message length too long */
}
/************************************************************************
* Function: void SlideRectangle(void)
*                                                                       
* Overview: New screen slides-in overwriting the old screen
*                                                                       
* Input:    param1 (GFXTransition()) -> Pixel-block size to expand
*           param2 (GFXTransition()) -> Sliding direction LEFT_TO_RIGHT/RIGHT_TO_LEFT/TOP_TO_BOTTOM/BOTTOM_TO_TOP
*                                                                       
* Output:   none
*                                                                       
************************************************************************/
void SlideRectangle(void)
{
    SHORT x, y;
    WORD blocksize = _param1;
    WORD direction = _param2;
    
    if(blocksize == 0)
    {
        blocksize = 1;
    }
    else if(blocksize > GFX_TRANSITION_MAX_BLOCKSIZE)
    {
        blocksize = GFX_TRANSITION_MAX_BLOCKSIZE;
    }
    
    direction = GFXTranslateDirection(direction, DISP_ORIENTATION);
    
    while(IsDeviceBusy());
    
    if(direction == LEFT_TO_RIGHT)
    {
        for(x = Width; x > 0; x -= blocksize)
        {
            CopyBlock(_srcpageaddr, _destpageaddr, ((DWORD)Starty * DISP_HOR_RESOLUTION) + Startx + x - blocksize, ((DWORD)Starty * DISP_HOR_RESOLUTION) + Startx, Width - x + blocksize, Height);
            DelayMs(_delay_ms);
            while(IsDeviceBusy());
        }
    }
    else if(direction == RIGHT_TO_LEFT)
    {
        for(x = Width; x > 0; x -= blocksize)
        {
            CopyBlock(_srcpageaddr, _destpageaddr, ((DWORD)Starty * DISP_HOR_RESOLUTION) + Startx, ((DWORD)Starty * DISP_HOR_RESOLUTION) + Startx + x - blocksize, Width - x + blocksize, Height);
            DelayMs(_delay_ms);
            while(IsDeviceBusy());
        }
    }
    else if(direction == TOP_TO_BOTTOM)
    {
        for(y = Height; y > 0; y -= blocksize)
        {
            CopyBlock(_srcpageaddr, _destpageaddr, ((DWORD)(Starty + y - blocksize) * DISP_HOR_RESOLUTION) + Startx, ((DWORD)Starty * DISP_HOR_RESOLUTION) + Startx, Width, Height - y + blocksize);
            DelayMs(_delay_ms);
            while(IsDeviceBusy());
        }
    }
    else if(direction == BOTTOM_TO_TOP)
    {
        for(y = Height; y > 0; y -= blocksize)
        {
            CopyBlock(_srcpageaddr, _destpageaddr, ((DWORD)Starty * DISP_HOR_RESOLUTION) + Startx, ((DWORD)(Starty + y - blocksize) * DISP_HOR_RESOLUTION) + Startx, Width, Height - y + blocksize);
            DelayMs(_delay_ms);
            while(IsDeviceBusy());
        }
    }
    PlainCopyRectangle();
}
/************************************************************************
* Function: void ExpandRectangle(void)
*                                                                       
* Overview: Expanding rectangle from the mid to the periphery
*                                                                       
* Input:    param1 (GFXTransition()) -> Pixel-block size to expand
*                                                                       
* Output:   none
*                                                                       
************************************************************************/
void ExpandRectangle(void)
{
    #define SCALE 100

    WORD x = Width / 2;
    WORD y = Height / 2;
    WORD den = (x > y)? y: x;
    WORD xpitch = x * SCALE / den;
    WORD ypitch = y * SCALE / den;
    WORD i;
    WORD blocksize = _param1;
    
    if(blocksize == 0)
    {
        blocksize = 1;
    }
    else if(blocksize > GFX_TRANSITION_MAX_BLOCKSIZE)
    {
        blocksize = GFX_TRANSITION_MAX_BLOCKSIZE;
    }
    
    while(IsDeviceBusy());
    
    for(i = 0; i <= den; i += blocksize)
    {
        CopyBlock(_srcpageaddr, _destpageaddr, ((DWORD)(Starty + y) * DISP_HOR_RESOLUTION) + Startx + x, ((DWORD)(Starty + y) * DISP_HOR_RESOLUTION) + Startx + x, 2 * xpitch * i / SCALE, 2 * ypitch * i / SCALE);
        DelayMs(_delay_ms);
        while(IsDeviceBusy());
        x = (Width / 2) - ((i * xpitch) / SCALE);
        y = (Height / 2) - ((i * ypitch) / SCALE);
    }
    PlainCopyRectangle();
}
void VPictureData_EMF::FromMacHandle(void* inMacHandle)
{
	_ReleaseDataProvider();
	_DisposeMetaFile();
	if(inMacHandle)
	{
		VSize datasize=GetMacAllocator()->GetSize(inMacHandle);
		if(datasize)
		{
			fPicHandle=GetMacAllocator()->Allocate(GetMacAllocator()->GetSize(inMacHandle));
			if(fPicHandle)
			{
				GetMacAllocator()->Lock(fPicHandle);
				GetMacAllocator()->Lock(inMacHandle);
				CopyBlock(*(char**)inMacHandle,*(char**)fPicHandle,datasize);
				GetMacAllocator()->Unlock(fPicHandle);
				GetMacAllocator()->Unlock(inMacHandle);
			}
		}
		else
			fPicHandle=NULL;
	}
	else
	{
		fPicHandle=NULL;
	}
}
Exemplo n.º 5
0
VOID
GuiCopyFromTextModeBuffer(PTEXTMODE_SCREEN_BUFFER Buffer,
                          PGUI_CONSOLE_DATA GuiData)
{
    /*
     * This function supposes that the system clipboard was opened.
     */

    BOOL LineSelection = GuiData->LineSelection;

    DPRINT("Selection is (%d|%d) to (%d|%d) in %s mode\n",
           GuiData->Selection.srSelection.Left,
           GuiData->Selection.srSelection.Top,
           GuiData->Selection.srSelection.Right,
           GuiData->Selection.srSelection.Bottom,
           (LineSelection ? "line" : "block"));

    if (!LineSelection)
    {
        CopyBlock(Buffer, &GuiData->Selection.srSelection);
    }
    else
    {
        COORD Begin, End;

        GetSelectionBeginEnd(&Begin, &End,
                             &GuiData->Selection.dwSelectionAnchor,
                             &GuiData->Selection.srSelection);

        CopyLines(Buffer, &Begin, &End);
    }
}
/************************************************************************
* Function: void ContractLine(void)
*                                                                       
* Overview: Expanding line from the mid to the periphery
*                                                                       
* Input:    param1 (GFXTransition())  -> Pixel-block size to expand
*               param2 (GFXTransition()) ->  Direction of transition - HORIZONTAL/VERTICAL
*                                                                       
* Output:   none
*                                                                       
************************************************************************/
void ContractLine(void)
{    
    WORD blocksize = _param1;
    WORD direction = _param2;

    if(blocksize == 0)
    {
        blocksize = 1;
    }
    else if(blocksize > GFX_TRANSITION_MAX_BLOCKSIZE)
    {
        blocksize = GFX_TRANSITION_MAX_BLOCKSIZE;
    }
    
    direction = GFXTranslateDirection(direction, DISP_ORIENTATION);

    while(IsDeviceBusy());

    if(direction == HORIZONTAL)
    {
        WORD i;
        
        for(i = 0; i < Width / (2 * blocksize); i++)
        {
            CopyBlock(_srcpageaddr, _destpageaddr, ((DWORD)Starty * DISP_HOR_RESOLUTION) + Startx, ((DWORD)Starty * DISP_HOR_RESOLUTION) + Startx, (i + 1) * blocksize, Height);
            CopyBlock(_srcpageaddr, _destpageaddr, ((DWORD)Starty * DISP_HOR_RESOLUTION) + Startx + Width - (i * blocksize) - blocksize, ((DWORD)Starty * DISP_HOR_RESOLUTION) + Startx + Width - (i * blocksize) - blocksize, (i + 1) * blocksize, Height);
            DelayMs(_delay_ms);
            while(IsDeviceBusy());
        }
    }
    else if(direction == VERTICAL)
    {
        WORD i;
        
        for(i = 0; i < Height / (2 * blocksize); i++)
        {
            CopyBlock(_srcpageaddr, _destpageaddr, (DWORD)Starty * DISP_HOR_RESOLUTION + Startx, (DWORD)Starty * DISP_HOR_RESOLUTION + Startx, Width, (i + 1) * blocksize);
            CopyBlock(_srcpageaddr, _destpageaddr, (DWORD)(Starty + Height - (i * blocksize) - blocksize) * DISP_HOR_RESOLUTION + Startx, (DWORD)(Starty + Height - (i * blocksize) - blocksize) * DISP_HOR_RESOLUTION + Startx, Width, (i + 1) * blocksize);
            DelayMs(_delay_ms);
            while(IsDeviceBusy());
        }
    }

    PlainCopyRectangle();
}
Exemplo n.º 7
0
void FillBlock(const block* prev_block, const block* ref_block, block* next_block, const uint64_t* Sbox) {
    block blockR;
    CopyBlock(&blockR,ref_block);
    XORBlock(&blockR,prev_block);
    block block_tmp;
    CopyBlock(&block_tmp, &blockR);

    uint64_t x = 0;
    if (Sbox != NULL) {
        x = blockR.v[0] ^ blockR.v[ARGON2_WORDS_IN_BLOCK - 1];
        for (int i = 0; i < 6 * 16; ++i) {
            uint32_t x1 = x >> 32;
            uint32_t x2 = x & 0xFFFFFFFF;
            uint64_t y = Sbox[x1 & ARGON2_SBOX_MASK];
            uint64_t z = Sbox[(x2 & ARGON2_SBOX_MASK) + ARGON2_SBOX_SIZE / 2];
            x = (uint64_t) x1 * (uint64_t) x2;
            x += y;
            x ^= z;
        }
    }
/************************************************************************
* Function: void ContractRectangle(void)
*                                                                       
* Overview: Expanding rectangle from the mid to the periphery
*                                                                       
* Input:    param1 (GFXTransition()) -> Pixel-block size to expand
*                                                                       
* Output:   none
*                                                                       
************************************************************************/
void ContractRectangle(void)
{
    #define SCALE 100

    WORD x = Width / 2;
    WORD y = Height / 2;
    WORD den = (x > y)? y: x;
    WORD xpitch = x * SCALE / den;
    WORD ypitch = y * SCALE / den;
    WORD i;
    WORD blocksize = _param1;
    
    if(blocksize == 0)
    {
        blocksize = 1;
    }
    else if(blocksize > GFX_TRANSITION_MAX_BLOCKSIZE)
    {
        blocksize = GFX_TRANSITION_MAX_BLOCKSIZE;
    }
    
    while(IsDeviceBusy());
    
    for(i = 0; i <= den; i += blocksize)
    {
        x = (i * xpitch) / SCALE;
        y = (i * ypitch) / SCALE;
        CopyBlock(_srcpageaddr, _destpageaddr, ((DWORD)Starty * DISP_HOR_RESOLUTION) + Startx, ((DWORD)Starty * DISP_HOR_RESOLUTION) + Startx, x, Height);
        CopyBlock(_srcpageaddr, _destpageaddr, ((DWORD)Starty * DISP_HOR_RESOLUTION) + Startx + Width - x - 1, ((DWORD)Starty * DISP_HOR_RESOLUTION) + Startx + Width - x - 1, x, Height);
        CopyBlock(_srcpageaddr, _destpageaddr, ((DWORD)Starty * DISP_HOR_RESOLUTION) + Startx, ((DWORD)Starty * DISP_HOR_RESOLUTION) + Startx, Width, y);
        CopyBlock(_srcpageaddr, _destpageaddr, ((DWORD)(Starty + Height - y - 1) * DISP_HOR_RESOLUTION) + Startx, ((DWORD)(Starty + Height - y - 1) * DISP_HOR_RESOLUTION) + Startx, Width, y);
        DelayMs(_delay_ms);
        while(IsDeviceBusy());
    }
    PlainCopyRectangle();
}
VPictureData_EMF::VPictureData_EMF(const VPictureData_EMF& inData)
:inherited(inData)
{
	_Init();
	if(!fDataProvider && inData.fPicHandle)
	{
		VSize datasize;
		datasize=GetMacAllocator()->GetSize(inData.fPicHandle);
		fPicHandle=GetMacAllocator()->Allocate(datasize);
		if(fPicHandle)
		{
			GetMacAllocator()->Lock(fPicHandle);
			GetMacAllocator()->Lock(inData.fPicHandle);
			CopyBlock(*(char**)inData.fPicHandle,*(char**)fPicHandle,datasize);
			GetMacAllocator()->Unlock(fPicHandle);
			GetMacAllocator()->Unlock(inData.fPicHandle);
		}
		_SetSafe();
	}
}
/************************************************************************
* Function: void PlainCopyRectangle(void)
*                                                                       
* Overview: No transition effect (Sudden transition effect)
*                                                                       
* Input:    none                                                          
*                                                                       
* Output:   none
*                                                                       
************************************************************************/
void PlainCopyRectangle(void)
{
    while(IsDeviceBusy());
    CopyBlock(_srcpageaddr, _destpageaddr, ((DWORD)Starty * DISP_HOR_RESOLUTION) + Startx, ((DWORD)Starty * DISP_HOR_RESOLUTION) + Startx, Width, Height);
    while(IsDeviceBusy());
}
Exemplo n.º 11
0
HRESULT UpdateArchive(IInStream *inStream, ISequentialOutStream *outStream,
    const CObjectVector<NArchive::NTar::CItemEx> &inputItems,
    const CObjectVector<CUpdateItemInfo> &updateItems,
    IArchiveUpdateCallback *updateCallback)
{
  COutArchive outArchive;
  outArchive.Create(outStream);

  UInt64 complexity = 0;

  int i;
  for(i = 0; i < updateItems.Size(); i++)
  {
    const CUpdateItemInfo &updateItem = updateItems[i];
    if (updateItem.NewData)
      complexity += updateItem.Size;
    else
      complexity += inputItems[updateItem.IndexInArchive].GetFullSize();
    complexity += kOneItemComplexity;
  }

  RINOK(updateCallback->SetTotal(complexity));

  complexity = 0;

  for(i = 0; i < updateItems.Size(); i++)
  {
    RINOK(updateCallback->SetCompleted(&complexity));

    CLocalProgress *localProgressSpec = new CLocalProgress;
    CMyComPtr<ICompressProgressInfo> localProgress = localProgressSpec;
    localProgressSpec->Init(updateCallback, true);
  
    CLocalCompressProgressInfo *localCompressProgressSpec = new CLocalCompressProgressInfo;
    CMyComPtr<ICompressProgressInfo> compressProgress = localCompressProgressSpec;

    localCompressProgressSpec->Init(localProgress, &complexity, NULL);

    const CUpdateItemInfo &updateItem = updateItems[i];
    CItem item;
    if (updateItem.NewProperties)
    {
      item.Mode = 0777;
      item.Name = (updateItem.Name);
      if (updateItem.IsDirectory)
      {
         item.LinkFlag = NFileHeader::NLinkFlag::kDirectory;
         item.Size = 0;
      }
      else
      {
         item.LinkFlag = NFileHeader::NLinkFlag::kNormal;
         item.Size = updateItem.Size;
      }
      item.ModificationTime = updateItem.Time;
      item.DeviceMajorDefined = false;
      item.DeviceMinorDefined = false;
      item.UID = 0;
      item.GID = 0;
      memmove(item.Magic, NFileHeader::NMagic::kEmpty, 8);
    }
    else
    {
      const CItemEx &existItemInfo = inputItems[updateItem.IndexInArchive];
      item = existItemInfo;
    }
    if (updateItem.NewData)
    {
      item.Size = updateItem.Size;
      if (item.Size == UInt64(Int64(-1)))
        return E_INVALIDARG;
    }
    else
    {
      const CItemEx &existItemInfo = inputItems[updateItem.IndexInArchive];
      item.Size = existItemInfo.Size;
    }
  
    if (updateItem.NewData)
    {
      CMyComPtr<ISequentialInStream> fileInStream;
      HRESULT res = updateCallback->GetStream(updateItem.IndexInClient, &fileInStream);
      if (res != S_FALSE)
      {
        RINOK(res);
        RINOK(outArchive.WriteHeader(item));
        if (!updateItem.IsDirectory)
        {
          UInt64 totalSize;
          RINOK(CopyBlock(fileInStream, outStream, compressProgress, &totalSize));
          if (totalSize != item.Size)
            return E_FAIL;
          RINOK(outArchive.FillDataResidual(item.Size));
        }
      }
      complexity += updateItem.Size;
      RINOK(updateCallback->SetOperationResult(
          NArchive::NUpdate::NOperationResult::kOK));
    }
    else
    {
      CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
      CMyComPtr<CLimitedSequentialInStream> inStreamLimited(streamSpec);
      const CItemEx &existItemInfo = inputItems[updateItem.IndexInArchive];
      if (updateItem.NewProperties)
      {
        RINOK(outArchive.WriteHeader(item));
        RINOK(inStream->Seek(existItemInfo.GetDataPosition(), 
            STREAM_SEEK_SET, NULL));
        streamSpec->Init(inStream, existItemInfo.Size);
      }
      else
      {
        RINOK(inStream->Seek(existItemInfo.HeaderPosition, 
            STREAM_SEEK_SET, NULL));
        streamSpec->Init(inStream, existItemInfo.GetFullSize());
      }
      RINOK(CopyBlock(inStreamLimited, outStream, compressProgress));
      RINOK(outArchive.FillDataResidual(existItemInfo.Size));
      complexity += existItemInfo.GetFullSize();
    }
    complexity += kOneItemComplexity;
  }
  return outArchive.WriteFinishHeader();
}
Exemplo n.º 12
0
int16 ModKern(  CONST_TTFACC_FILEBUFFERINFO * pInputBufferInfo, TTFACC_FILEBUFFERINFO * pOutputBufferInfo, 
              CONST uint8 *puchKeepGlyphList, 
              CONST uint16 usGlyphListCount,
              CONST uint16 usFormat,
              uint32 *pulNewOutOffset)
{
uint32 ulOffset;
uint32 ulSourceOffset;
uint32 ulTargetOffset;
KERN_HEADER KernHeader;
KERN_SUB_HEADER  KernSubHeader;
uint16 i;
uint16 usSubtableLength;
uint16 usBytesRead;
int16 errCode = NO_ERROR;
    /* read kern table header */

    
    if (usFormat == TTFDELTA_DELTA) /* only formats for which this is valid */
    {
        MarkTableForDeletion(pOutputBufferInfo, KERN_TAG);
        return NO_ERROR;
    }
    if ((errCode = CopyTableOver(pOutputBufferInfo, pInputBufferInfo, KERN_TAG, pulNewOutOffset)) != NO_ERROR)  
    {
        if (errCode == ERR_FORMAT)
            return NO_ERROR;    /* not required */
        return errCode;
    }

    if (usFormat == TTFDELTA_SUBSET1)   /* need to keep the full kern table as we will send only once */
        return NO_ERROR;

    ulOffset = TTTableOffset( pOutputBufferInfo, KERN_TAG );
    if ( ulOffset == 0L )
        return ERR_GENERIC;    /* should have been copied over */
    if ((errCode = ReadGeneric( pOutputBufferInfo, (uint8 *) &KernHeader, SIZEOF_KERN_HEADER, KERN_HEADER_CONTROL, ulOffset, &usBytesRead )) != NO_ERROR)
        return errCode;

    /* read each subtable.  If it is a format 0 subtable, remove
    kern pairs involving deleted glyphs.  Otherwise, copy
    the table down to its new location */

    ulSourceOffset = ulOffset + usBytesRead;
    ulTargetOffset = ulSourceOffset;
    for ( i = 0; i < KernHeader.nTables; i++ )
    {
        /* read subtable header */
        if ((errCode = ReadGeneric( pOutputBufferInfo, (uint8 *) &KernSubHeader, SIZEOF_KERN_SUB_HEADER, KERN_SUB_HEADER_CONTROL, ulSourceOffset, &usBytesRead )) != NO_ERROR)
            return errCode;

        /* copy data to new location to cover any gaps left by shortening the previous
        format 0 subtable. Nothing happens first time around. */

        if ((errCode = CopyBlock( pOutputBufferInfo, ulTargetOffset, ulSourceOffset, KernSubHeader.length )) != NO_ERROR)
            return errCode;
        ulSourceOffset += KernSubHeader.length;

        /* if subtable is format 0, shorten it by deleting kern pairs
        involving deleted glyphs */

        if ( KernSubHeader.format == 0 )
        {
            if ((errCode = AdjustKernFormat0( pOutputBufferInfo, puchKeepGlyphList, usGlyphListCount, KernSubHeader, ulTargetOffset, usBytesRead, &usSubtableLength)) != NO_ERROR)
                return errCode;
            ulTargetOffset += usSubtableLength;
        }
        else
            ulTargetOffset += KernSubHeader.length;
    }

    /* Write out revised table length */
    if (ulTargetOffset == ulOffset + GetGenericSize( KERN_HEADER_CONTROL )) /* no Kern data written */
        MarkTableForDeletion(pOutputBufferInfo, KERN_TAG);
    else
        errCode = UpdateDirEntry( pOutputBufferInfo, KERN_TAG, ulTargetOffset - ulOffset );
    *pulNewOutOffset = ulTargetOffset;
    return errCode;
}
Exemplo n.º 13
0
//------------------------------------------------------------------------------------------------------------------------------
// perform a (inter-level) restriction
void restriction(level_type * level_c, int id_c, level_type *level_f, int id_f, int restrictionType){
  uint64_t _timeCommunicationStart = CycleTime();
  uint64_t _timeStart,_timeEnd;
  int buffer=0;
  int n;
  int my_tag = (level_f->tag<<4) | 0x5;




  #ifdef USE_MPI
  // by convention, level_f allocates a combined array of requests for both level_f sends and level_c recvs...
  int nMessages = level_c->restriction[restrictionType].num_recvs + level_f->restriction[restrictionType].num_sends;
  MPI_Request *recv_requests = level_f->restriction[restrictionType].requests;
  MPI_Request *send_requests = level_f->restriction[restrictionType].requests + level_c->restriction[restrictionType].num_recvs;


  // loop through packed list of MPI receives and prepost Irecv's...
  _timeStart = CycleTime();
  #ifdef USE_MPI_THREAD_MULTIPLE
  #pragma omp parallel for schedule(dynamic,1)
  #endif
  for(n=0;n<level_c->restriction[restrictionType].num_recvs;n++){
    MPI_Irecv(level_c->restriction[restrictionType].recv_buffers[n],
              level_c->restriction[restrictionType].recv_sizes[n],
              MPI_DOUBLE,
              level_c->restriction[restrictionType].recv_ranks[n],
              my_tag,
              MPI_COMM_WORLD,
              &recv_requests[n]
    );
  }
  _timeEnd = CycleTime();
  level_f->cycles.restriction_recv += (_timeEnd-_timeStart);


  // pack MPI send buffers...
  _timeStart = CycleTime();
  PRAGMA_THREAD_ACROSS_BLOCKS(level_f,buffer,level_f->restriction[restrictionType].num_blocks[0])
  for(buffer=0;buffer<level_f->restriction[restrictionType].num_blocks[0];buffer++){RestrictBlock(level_c,id_c,level_f,id_f,&level_f->restriction[restrictionType].blocks[0][buffer],restrictionType);}
  _timeEnd = CycleTime();
  level_f->cycles.restriction_pack += (_timeEnd-_timeStart);

 
  // loop through MPI send buffers and post Isend's...
  _timeStart = CycleTime();
  #ifdef USE_MPI_THREAD_MULTIPLE
  #pragma omp parallel for schedule(dynamic,1)
  #endif
  for(n=0;n<level_f->restriction[restrictionType].num_sends;n++){
    MPI_Isend(level_f->restriction[restrictionType].send_buffers[n],
              level_f->restriction[restrictionType].send_sizes[n],
              MPI_DOUBLE,
              level_f->restriction[restrictionType].send_ranks[n],
              my_tag,
              MPI_COMM_WORLD,
              &send_requests[n]
    );
  }
  _timeEnd = CycleTime();
  level_f->cycles.restriction_send += (_timeEnd-_timeStart);
  #endif


  // perform local restriction[restrictionType]... try and hide within Isend latency... 
  _timeStart = CycleTime();
  PRAGMA_THREAD_ACROSS_BLOCKS(level_f,buffer,level_f->restriction[restrictionType].num_blocks[1])
  for(buffer=0;buffer<level_f->restriction[restrictionType].num_blocks[1];buffer++){RestrictBlock(level_c,id_c,level_f,id_f,&level_f->restriction[restrictionType].blocks[1][buffer],restrictionType);}
  _timeEnd = CycleTime();
  level_f->cycles.restriction_local += (_timeEnd-_timeStart);


  // wait for MPI to finish...
  #ifdef USE_MPI 
  _timeStart = CycleTime();
  if(nMessages)MPI_Waitall(nMessages,level_f->restriction[restrictionType].requests,level_f->restriction[restrictionType].status);
  _timeEnd = CycleTime();
  level_f->cycles.restriction_wait += (_timeEnd-_timeStart);


  // unpack MPI receive buffers 
  _timeStart = CycleTime();
  PRAGMA_THREAD_ACROSS_BLOCKS(level_f,buffer,level_c->restriction[restrictionType].num_blocks[2])
  for(buffer=0;buffer<level_c->restriction[restrictionType].num_blocks[2];buffer++){CopyBlock(level_c,id_c,&level_c->restriction[restrictionType].blocks[2][buffer]);}
  _timeEnd = CycleTime();
  level_f->cycles.restriction_unpack += (_timeEnd-_timeStart);


  #endif
 
 
  level_f->cycles.restriction_total += (uint64_t)(CycleTime()-_timeCommunicationStart);
}
Exemplo n.º 14
0
int     TetrisPlay(int param)
{
    static int flag = 0;
    if(!flag){
        flag = 1;
        InitialMatrix();
        CreateBlock(&curBlock);

        // Create next block
        CreateBlock(&nextBlock);
        GetCurrentLine(curBlock.y);
        DisplayScoreLevel();
    }

    //while(1)
    {
        int key;
        TetrisAction action;
        DebugDump();

        // Check valid
        if(!CheckBlock(&curBlock,TA_None)){
            // Game over
            printf("Game over!\n");
        }

        key = GetKey();
        switch(key){
            case KEY_LEFT:
                action = TA_Left;
                score++;
                break;
            case KEY_RIGHT:
                action = TA_Right;
                score+=10;
                break;
            case KEY_UP:
                action = TA_Rotate;
                score+=100;
                break;
            case KEY_DOWN:
                action = TA_Down;
                score+=1000;
                break;
            case KEY_PAUSE:
                break;
            default:
                action = TA_Down;
                break;
        }
        if(CheckBlock(&curBlock,action)){
            MoveBlock(&curBlock,action);
        }else if(action == TA_Down){
            ScoreUp(DropBlock(&curBlock));
            CopyBlock(&curBlock,&nextBlock);
            CreateBlock(&nextBlock);
            GetCurrentLine(curBlock.y);
        }
    }
    return 0;
}
Exemplo n.º 15
0
PRIVATE int16 CompressCmapSubTables(TTFACC_FILEBUFFERINFO * pOutputBufferInfo,  /* ttfacc info */
                    CMAP_TABLELOC *pCmapTableLoc, /* array of CmapSubTable locators */
                    uint16 usSubTableCount, /* count of that array */
                    uint32 ulCmapOffset, /* offset to cmap table */
                    uint32 ulSubTableOffset, /* offset to beginning of Subtables */
                    uint32 ulCmapOldLength,    /* length of old cmap table - not to be exceeded */
                    uint32 *pulCmapNewLength)
{
IndexOffset *pIndexArray;  /* local array of structures to keep track of new offsets of sorted subtables */
CMAP_SUBHEADER_GEN CmapSubHeader;    
int16 errCode = NO_ERROR;
uint32 ulCurrentOffset;
uint32 ulLastOffset;
uint16 usIndex;
uint32 ulCmapTableLength = 0;
uint32 ulCmapSubTableDirOffset;
uint32 ulPadOffset;
uint16 i,j;
uint16 usBytesRead;
uint16 usPadBytes;

    pIndexArray = (IndexOffset *) Mem_Alloc(usSubTableCount * sizeof(*pIndexArray));
    if (pIndexArray == NULL)
        return ERR_MEM;
    
    /* sort them by old offsets, so we can move the blocks in order */
    SortCmapSubByOffset(pCmapTableLoc, usSubTableCount, pIndexArray); 

    ulCurrentOffset = ulSubTableOffset; /* end of the Cmap Directories */
    ulLastOffset = 0;
    for (i = 0; i < usSubTableCount; ++i)    /* process each subtable */
    {
        usIndex = pIndexArray[i].usIndex;
        /* check to see if this offset is the same as the last one copied. If so, ignore, as it has already been copied */
        if (i > 0 && pCmapTableLoc[usIndex].offset == ulLastOffset) /* we're pointing to some already copied data */
        {
            pIndexArray[i].ulNewOffset = pIndexArray[i-1].ulNewOffset;
            continue;
        }
        /* read the CmapSub Header */
         if ((errCode = ReadCmapLength(pOutputBufferInfo, &CmapSubHeader, ulCmapOffset + pCmapTableLoc[usIndex].offset, &usBytesRead)) != NO_ERROR)
            break;
        /* do we need to pad? */

        ulPadOffset = ulCurrentOffset;
        ulCurrentOffset = (ulPadOffset + 1) & ~1;      /* we may need to pad, but do it after we move data in case we would overwrite data */
        usPadBytes = (uint16) (ulCurrentOffset - ulPadOffset);

        if (ulCmapTableLength + usPadBytes + CmapSubHeader.length > ulCmapOldLength) /* if we are about to exceed the bounds */
        {
            errCode = ERR_WOULD_GROW;  /* can't do it. Bail and restore the old cmap table */
            break;
        }
        pIndexArray[i].ulNewOffset = ulCurrentOffset-ulCmapOffset;    /* calculate the new offset of the cmap subtable, and store in local structure */
        ulLastOffset = pCmapTableLoc[usIndex].offset;
        /* now copy the subtable to it's new locations */
        if ((errCode = CopyBlock(pOutputBufferInfo, ulCurrentOffset, ulCmapOffset + pCmapTableLoc[usIndex].offset,CmapSubHeader.length)) != NO_ERROR)
            break;
        for (j = 0; j < usPadBytes; ++j)
            WriteByte(pOutputBufferInfo,(uint8) 0, ulPadOffset+j);     /* now clear out those pad bytes */

        ulCurrentOffset += CmapSubHeader.length;
        ulCmapTableLength = ulCurrentOffset - ulCmapOffset;  /* to update the Font Directory values */
    } 
    if (errCode == NO_ERROR)
    {
        for (i = 0; i < usSubTableCount; ++i) /* now set the new offsets - retrieved from the local structure array */
            pCmapTableLoc[pIndexArray[i].usIndex].offset = pIndexArray[i].ulNewOffset;

        ulCmapSubTableDirOffset = ulCmapOffset + GetGenericSize( CMAP_HEADER_CONTROL );
        for (i = 0; i < usSubTableCount; ++i) /* now write the new offsets in their original order (Plat/encoding order) */
        {
              if ((errCode = WriteGeneric(pOutputBufferInfo, (uint8 *) &(pCmapTableLoc[i]), SIZEOF_CMAP_TABLELOC, CMAP_TABLELOC_CONTROL, ulCmapSubTableDirOffset, &usBytesRead)) != NO_ERROR)
                break; 
            ulCmapSubTableDirOffset += usBytesRead;  /* for next time around */
        }
    }
    Mem_Free(pIndexArray);
    if (errCode == NO_ERROR)
        /* now update the Directory Entry for the file */
        errCode = UpdateDirEntry(pOutputBufferInfo, CMAP_TAG, ulCmapTableLength);

    *pulCmapNewLength = ulCmapTableLength;

    return errCode;
}
Exemplo n.º 16
0
unsigned long UserWinProcedure(HWND Window,HMSG Message,long Param1,long Param2)
{
  int hlist,i,j;
  float Midf;
  switch (Message)
  {
     case DIALOGBOXOK:
            GetPrintPara();
            if (PG.Blocks>0)
                PG.Enable=1;
            else
                PG.Enable=0;
            return(DialogDefaultProcedure(Window, Message, Param1, Param2));
     case DIALOGBOXCANCEL:
            PG.Enable=0;
            return(DialogDefaultProcedure(Window, Message, Param1, Param2));
     case REDRAWMESSAGE:
            i=DialogDefaultProcedure(Window, Message, Param1, Param2);
            WaitMessageEmpty();
            InitOver=1;
            InitPrintCut();
            CurrentBlock=0;
            SetPrintPara();
            REFLASH;
            MessageInsert(PrintCutWin[wPAGEADDWIN],WINDOWINIT,0l,0l);
            ListSetCurrent(WindowList(PrintCutWin[wPAGEADDWIN]),CurrentBlock);
            
            REFLASHADD;
            return i;
            break;
     case WINDOWINIT:
            InitOver=0;

            i=DialogDefaultProcedure(Window, Message, Param1, Param2);
            //WaitMessageEmpty();
            return i;
            break;
     case ADDWIN:
            GetPrintPara();
            if (PG.Blocks<99) PG.Blocks++;
            CurrentBlock=PG.Blocks-1;
            if (CurrentBlock>0) CopyBlock(CurrentBlock,CurrentBlock-1);
            else InitBlock(CurrentBlock);
            SetPrintPara();
            hlist = WindowList(PrintCutWin[wPAGEADDWIN]);
            MessageGo(PrintCutWin[wPAGEADDWIN],WINDOWINIT,0,0);
            MessageGo(PrintCutWin[wPAGEADDWIN],WMPAINT,0,ListGetHeight(hlist)*CHARHEIGHT);
            if (CurrentBlock>=7)
             ListSetTop(hlist,CurrentBlock-7);
            else
            ListSetTop(hlist,0);
            ListSetCurrent(hlist,CurrentBlock);
            MessageGo(PrintCutWin[wPAGEADDWIN],REDRAWMESSAGE,0L,
                MAKELONG(WindowGetWidth(PrintCutWin[wPAGEADDWIN]),
                WindowGetHeight(PrintCutWin[wPAGEADDWIN])) );
            //MessageGo(PrintCutWin[wPAGEADDWIN],KEYDOWN,UP,0l);
            //MessageGo(PrintCutWin[wPAGEADDWIN],KEYDOWN,DOWN,0l);
            //ListSetTop(hlist,0);
            REFLASH;
            break;
     case DELETEWIN:
            GetPrintPara();
            for (i=CurrentBlock+1;i<PG.Blocks;i++) CopyBlock1(i-1,i);
            if (PG.Blocks>0) PG.Blocks--;
            if (CurrentBlock>=PG.Blocks&&CurrentBlock) CurrentBlock=PG.Blocks-1;
            SetPrintPara();
            hlist = WindowList(PrintCutWin[wPAGEADDWIN]);
            MessageGo(PrintCutWin[wPAGEADDWIN],WINDOWINIT,0,0);
            MessageGo(PrintCutWin[wPAGEADDWIN],WMPAINT,0,ListGetHeight(hlist)*CHARHEIGHT);
            if (CurrentBlock>=7)
             ListSetTop(hlist,CurrentBlock-7);
            else
            ListSetTop(hlist,0);
            ListSetCurrent(hlist,CurrentBlock);
            MessageGo(PrintCutWin[wPAGEADDWIN],REDRAWMESSAGE,0L,
                MAKELONG(WindowGetWidth(PrintCutWin[wPAGEADDWIN]),
                WindowGetHeight(PrintCutWin[wPAGEADDWIN])) );
            REFLASH;
            break;
     case DELETETAILWIN:
            GetPrintPara();
            PG.Blocks=CurrentBlock;
            if (CurrentBlock>=PG.Blocks&&CurrentBlock) CurrentBlock=PG.Blocks-1;
            SetPrintPara();
            hlist = WindowList(PrintCutWin[wPAGEADDWIN]);
            MessageGo(PrintCutWin[wPAGEADDWIN],WINDOWINIT,0,0);
            MessageGo(PrintCutWin[wPAGEADDWIN],WMPAINT,0,ListGetHeight(hlist)*CHARHEIGHT);
            if (CurrentBlock>=7)
             ListSetTop(hlist,CurrentBlock-7);
            else
            ListSetTop(hlist,0);
            ListSetCurrent(hlist,CurrentBlock);
            MessageGo(PrintCutWin[wPAGEADDWIN],REDRAWMESSAGE,0L,
                MAKELONG(WindowGetWidth(PrintCutWin[wPAGEADDWIN]),
                WindowGetHeight(PrintCutWin[wPAGEADDWIN])) );
            REFLASH;
            break;
     case COPYWIN:
            i=GetPrintPara();
            if (i<0)
              switch(i)
                {
                    case -99:
                        {
                        if (MessageBox("设置打印纸","     确认您的打印机可使用\n"
                                                    "     您所定义的纸张大小, \n"
                                                    "       否则,打印可能出错!"
                        ,2,1)) break;
                        }
                        PaperW=Tmp1;
                        PaperH=Tmp2;
                        if (PaperW<20.0) PaperW=20.0;
                        if (PaperW>1100.0) PaperW=1100.0;
                        if (PaperH<20.0) PaperH=20.0;
                        if (PaperH>1100.0) PaperH=1100.0;
                        printer->xpixel=PaperW*PrinterDPI/25.4;
                        printer->ypixel=PaperH*PrinterDPI/25.4;
                        InitPrintCut();
                        break;
                    case -5:               //Tmp1 = Scale
                        Tmp2=PageH*Tmp4;
                        Tmp1=PageW*Tmp3;
                        if (PG.Blocks)
                        {
                          j=(PG.PageBlock[0].Rotate&1);

                        }
                        else
                          j=0;
                        if (j)
                          {
                            Midf=Tmp2;
                            Tmp2=Tmp1;
                            Tmp1=Midf;
                          }
                    case -1:

                        if (Tmp1>5.0f)
                        {
                            Midf=0.0f;
                            ColLeadNum=0;
                            while (Midf+Tmp1<PaperW)
                             {
                                Midf +=Tmp1;
                                ColLead[ColLeadNum++]=Midf;
                             }
                        }

                        if (Tmp2>5.0f)
                        {
                            Midf=0.0f;
                            RowLeadNum=0;
                            while (Midf+Tmp1<PaperH)
                             {
                                Midf +=Tmp2;
                                RowLead[RowLeadNum++]=Midf;
                             }
                        }
                        break;
                    case -2:
                        ColLeadNum=0;
                        RowLeadNum=0;
                        break;
                    case -3:
                        ColLeadNum=0;
                        break;
                    case -4:
                        RowLeadNum=0;
                        break;
                    case -6:             //Auto Scale Fit
                        if (!PG.Blocks) break;
                        PG.Blocks=0;
                        CurrentBlock=0;
                        hlist=PG.PageBlock[0].Rotate;
                        for (i=0;i<RowLeadNum;i++)
                        {
                         for (j=0;j<ColLeadNum;j++)
                          {
                              if (GetColWidth(j)-5.0f>Tmp1+Tmp3&&
                                 GetRowHeight(i)-5.0f>Tmp2+Tmp4)
                              {
                                if (hlist&1)
                                {
                                    PG.PageBlock[PG.Blocks].Yscale=(GetColWidth(j)-Tmp1-Tmp3)/PageH;
                                    PG.PageBlock[PG.Blocks].Xscale=(GetRowHeight(i)-Tmp2-Tmp4)/PageW;
                                }
                                else
                                {
                                    PG.PageBlock[PG.Blocks].Xscale=(GetColWidth(j)-Tmp1-Tmp3)/PageW;
                                    PG.PageBlock[PG.Blocks].Yscale=(GetRowHeight(i)-Tmp2-Tmp4)/PageH;
                                }

                                PG.PageBlock[PG.Blocks].Xoffset=GetColOffset(j)+Tmp1;
                                PG.PageBlock[PG.Blocks].Yoffset=GetRowOffset(i)+Tmp3;
                                PG.PageBlock[PG.Blocks].PageOffset=0;
                                PG.PageBlock[PG.Blocks++].Rotate=hlist;
                              }
                              if (PG.Blocks>=99) break;
                          }
                          if (PG.Blocks>=99) break;
                        }
                        break;
                    case -7:             //Auto Scale Fit
                        if (!PG.Blocks) break;
                        PG.Blocks=0;
                        CurrentBlock=0;
                        hlist=PG.PageBlock[0].Rotate;
                        for (i=0;i<=RowLeadNum;i++)
                        {
                         for (j=0;j<=ColLeadNum;j++)
                          {
                              if (GetColWidth(j)-5.0f>Tmp1+Tmp3&&
                                 GetRowHeight(i)-5.0f>Tmp2+Tmp4)
                              {
                                if (hlist&1)
                                {
                                    PG.PageBlock[PG.Blocks].Yscale=(GetColWidth(j)-Tmp1-Tmp3)/PageH;
                                    PG.PageBlock[PG.Blocks].Xscale=(GetRowHeight(i)-Tmp2-Tmp4)/PageW;
                                }
                                else
                                {
                                    PG.PageBlock[PG.Blocks].Xscale=(GetColWidth(j)-Tmp1-Tmp3)/PageW;
                                    PG.PageBlock[PG.Blocks].Yscale=(GetRowHeight(i)-Tmp2-Tmp4)/PageH;
                                }

                                PG.PageBlock[PG.Blocks].Xoffset=GetColOffset(j)+Tmp1;
                                PG.PageBlock[PG.Blocks].Yoffset=GetRowOffset(i)+Tmp3;
                                PG.PageBlock[PG.Blocks].PageOffset=0;
                                PG.PageBlock[PG.Blocks++].Rotate=hlist;
                              }
                              if (PG.Blocks>=99) break;
                          }
                          if (PG.Blocks>=99) break;
                        }
                        break;

                    case -8:
                        if (!PG.Blocks) break;
                        PG.Blocks=0;
                        CurrentBlock=0;
                        for (i=0;i<RowLeadNum;i++)
                        {
                         for (j=0;j<ColLeadNum;j++)
                          {
                              if (GetColWidth(j)-5.0f>Tmp1&&
                                 GetRowHeight(i)-5.0f>Tmp2)
                              {
                                PG.PageBlock[PG.Blocks].Xoffset=GetColOffset(j)+Tmp1;
                                PG.PageBlock[PG.Blocks].Yoffset=GetRowOffset(i)+Tmp2;
                                PG.PageBlock[PG.Blocks].Xscale=PG.PageBlock[0].Xscale;
                                PG.PageBlock[PG.Blocks].Yscale=PG.PageBlock[0].Yscale;
                                PG.PageBlock[PG.Blocks].PageOffset=0;
                                PG.PageBlock[PG.Blocks++].Rotate=PG.PageBlock[0].Rotate;
                              }
                              if (PG.Blocks>=99) break;
                          }
                          if (PG.Blocks>=99) break;
                        }
                        break;
                    case -9:
                        if (!PG.Blocks) break;
                        PG.Blocks=0;
                        CurrentBlock=0;
                        for (i=0;i<=RowLeadNum;i++)
                        {
                         for (j=0;j<=ColLeadNum;j++)
                          {
                              if (GetColWidth(j)-5.0f>Tmp1&&
                                 GetRowHeight(i)-5.0f>Tmp2)
                              {
                                PG.PageBlock[PG.Blocks].Xoffset=GetColOffset(j)+Tmp1;
                                PG.PageBlock[PG.Blocks].Yoffset=GetRowOffset(i)+Tmp2;
                                PG.PageBlock[PG.Blocks].Xscale=PG.PageBlock[0].Xscale;
                                PG.PageBlock[PG.Blocks].Yscale=PG.PageBlock[0].Yscale;
                                PG.PageBlock[PG.Blocks].PageOffset=0;
                                PG.PageBlock[PG.Blocks++].Rotate=PG.PageBlock[0].Rotate;
                              }
                              if (PG.Blocks>=99) break;
                          }
                          if (PG.Blocks>=99) break;
                        }
                        break;

                }
            REFLASH;
            REFLASHADD;
            break;
     default:
            return(DialogDefaultProcedure(Window, Message, Param1, Param2));
  }
  /* return(DialogDefaultProcedure(Window, Message, Param1, Param2)); */
  return(TRUE);
}
Exemplo n.º 17
0
/*
// Expansion of key for Rijndael's Encryption
*/
void ExpandRijndaelKey(const Ipp8u* pKey, int NK, int NB, int NR, int nKeys,
                       Ipp8u* pEncKeys, Ipp8u* pDecKeys)
{
   Ipp32u* enc_keys = (Ipp32u*)pEncKeys;
   Ipp32u* dec_keys = (Ipp32u*)pDecKeys;
   /* convert security key to WORD and save into the enc_key array */
   int n;
   for(n=0; n<NK; n++)
      enc_keys[n] = BYTES_TO_WORD(pKey[4*n+0], pKey[4*n+1], pKey[4*n+2], pKey[4*n+3]);

   /* 128-bits Key */
   if(NK128 == NK) {
      const Ipp32u* rtbl = RconTbl;
      Ipp32u k0 = enc_keys[0];
      Ipp32u k1 = enc_keys[1];
      Ipp32u k2 = enc_keys[2];
      Ipp32u k3 = enc_keys[3];

      for(n=NK128; n<nKeys; n+=NK128) {
         /* key expansion: extract bytes, substitute via Sbox and rotate */
         k0 ^= BYTES_TO_WORD( RijEncSbox[EBYTE(k3,1)],
                              RijEncSbox[EBYTE(k3,2)],
                              RijEncSbox[EBYTE(k3,3)],
                              RijEncSbox[EBYTE(k3,0)] ) ^ *rtbl++;

         k1 ^= k0;
         k2 ^= k1;
         k3 ^= k2;

         /* add key expansion */
         enc_keys[n  ] = k0;
         enc_keys[n+1] = k1;
         enc_keys[n+2] = k2;
         enc_keys[n+3] = k3;
      }
   }

   /* 192-bits Key */
   else if(NK192 == NK) {
      const Ipp32u* rtbl = RconTbl;
      Ipp32u k0 = enc_keys[0];
      Ipp32u k1 = enc_keys[1];
      Ipp32u k2 = enc_keys[2];
      Ipp32u k3 = enc_keys[3];
      Ipp32u k4 = enc_keys[4];
      Ipp32u k5 = enc_keys[5];

      for(n=NK192; n<nKeys; n+=NK192) {
         /* key expansion: extract bytes, substitute via Sbox and rorate */
         k0 ^= BYTES_TO_WORD( RijEncSbox[EBYTE(k5,1)],
                              RijEncSbox[EBYTE(k5,2)],
                              RijEncSbox[EBYTE(k5,3)],
                              RijEncSbox[EBYTE(k5,0)] ) ^ *rtbl++;
         k1 ^= k0;
         k2 ^= k1;
         k3 ^= k2;
         k4 ^= k3;
         k5 ^= k4;

         /* add key expansion */
         enc_keys[n  ] = k0;
         enc_keys[n+1] = k1;
         enc_keys[n+2] = k2;
         enc_keys[n+3] = k3;
         enc_keys[n+4] = k4;
         enc_keys[n+5] = k5;
      }
   }

   /* 256-bits Key */
   else {
      const Ipp32u* rtbl = RconTbl;
      Ipp32u k0 = enc_keys[0];
      Ipp32u k1 = enc_keys[1];
      Ipp32u k2 = enc_keys[2];
      Ipp32u k3 = enc_keys[3];
      Ipp32u k4 = enc_keys[4];
      Ipp32u k5 = enc_keys[5];
      Ipp32u k6 = enc_keys[6];
      Ipp32u k7 = enc_keys[7];

      for(n=NK256; n<nKeys; n+=NK256) {
         /* key expansion: extract bytes, substitute via Sbox and rorate */
         k0 ^= BYTES_TO_WORD( RijEncSbox[EBYTE(k7,1)],
                              RijEncSbox[EBYTE(k7,2)],
                              RijEncSbox[EBYTE(k7,3)],
                              RijEncSbox[EBYTE(k7,0)] ) ^ *rtbl++;
         k1 ^= k0;
         k2 ^= k1;
         k3 ^= k2;

         k4 ^= BYTES_TO_WORD( RijEncSbox[EBYTE(k3,0)],
                              RijEncSbox[EBYTE(k3,1)],
                              RijEncSbox[EBYTE(k3,2)],
                              RijEncSbox[EBYTE(k3,3)] );
         k5 ^= k4;
         k6 ^= k5;
         k7 ^= k6;

         /* add key expansion */
         enc_keys[n  ] = k0;
         enc_keys[n+1] = k1;
         enc_keys[n+2] = k2;
         enc_keys[n+3] = k3;
         enc_keys[n+4] = k4;
         enc_keys[n+5] = k5;
         enc_keys[n+6] = k6;
         enc_keys[n+7] = k7;
      }
   }


   /*
   // Key Expansion for Decryption
   */

   /* copy keys */
   CopyBlock(enc_keys, dec_keys, sizeof(Ipp32u)*nKeys);

   /* update decryption keys */
   for(n=NB; n<NR*NB; n++)
      dec_keys[n] = InvMixColumn(dec_keys[n], InvMixCol_Tbl);
}
Exemplo n.º 18
0
//------------------------------------------------------------------------------------------------------------------------------
// Samuel Williams
// [email protected]
// Lawrence Berkeley National Lab
//------------------------------------------------------------------------------------------------------------------------------
// perform a (intra-level) ghost zone exchange
//  NOTE exchange_boundary() only exchanges the boundary.
//  It will not enforce any boundary conditions
//  BC's are either the responsibility of a separate function or should be fused into the stencil
void exchange_boundary(level_type * level, int id, int justFaces){
  uint64_t _timeCommunicationStart = CycleTime();
  uint64_t _timeStart,_timeEnd;
  int buffer=0;
  int n;

  if(justFaces)justFaces=1;else justFaces=0;  // must be 0 or 1 in order to index into exchange_ghosts[]

  #ifdef USE_MPI
  int nMessages = level->exchange_ghosts[justFaces].num_recvs + level->exchange_ghosts[justFaces].num_sends;
  //MPI_Request *recv_requests = level->exchange_ghosts[justFaces].requests;
  //MPI_Request *send_requests = level->exchange_ghosts[justFaces].requests + level->exchange_ghosts[justFaces].num_recvs;
  MPI_Request *send_requests = level->exchange_ghosts[justFaces].requests;
  MPI_Request *recv_requests = level->exchange_ghosts[justFaces].requests + level->exchange_ghosts[justFaces].num_sends;

  // loop through packed list of MPI receives and prepost Irecv's...
  _timeStart = CycleTime();
  #ifdef USE_MPI_THREAD_MULTIPLE
  #pragma omp parallel for schedule(dynamic,1)
  #endif
  for(n=0;n<level->exchange_ghosts[justFaces].num_recvs;n++){
    MPI_Irecv(level->exchange_ghosts[justFaces].recv_buffers[n],
              level->exchange_ghosts[justFaces].recv_sizes[n],
              MPI_DOUBLE,
              level->exchange_ghosts[justFaces].recv_ranks[n],
              0, // by convention, ghost zone exchanges use tag=0
              MPI_COMM_WORLD,
              //&level->exchange_ghosts[justFaces].requests[n]
              //&recv_requests[n]
              &recv_requests[n]
    );
  }
  _timeEnd = CycleTime();
  level->cycles.ghostZone_recv += (_timeEnd-_timeStart);


  // pack MPI send buffers...
  _timeStart = CycleTime();
  #pragma omp parallel for if(level->exchange_ghosts[justFaces].num_blocks[0]>1) schedule(static,1)
  for(buffer=0;buffer<level->exchange_ghosts[justFaces].num_blocks[0];buffer++){CopyBlock(level,id,&level->exchange_ghosts[justFaces].blocks[0][buffer]);}
  _timeEnd = CycleTime();
  level->cycles.ghostZone_pack += (_timeEnd-_timeStart);


  // loop through MPI send buffers and post Isend's...
  _timeStart = CycleTime();
  #ifdef USE_MPI_THREAD_MULTIPLE
  #pragma omp parallel for schedule(dynamic,1)
  #endif
  for(n=0;n<level->exchange_ghosts[justFaces].num_sends;n++){
    MPI_Isend(level->exchange_ghosts[justFaces].send_buffers[n],
              level->exchange_ghosts[justFaces].send_sizes[n],
              MPI_DOUBLE,
              level->exchange_ghosts[justFaces].send_ranks[n],
              0, // by convention, ghost zone exchanges use tag=0
              MPI_COMM_WORLD,
              &send_requests[n]
              //&level->exchange_ghosts[justFaces].requests[n+level->exchange_ghosts[justFaces].num_recvs]
                                              // requests[0..num_recvs-1] were used by recvs.  So sends start at num_recvs
    );
  }
  _timeEnd = CycleTime();
  level->cycles.ghostZone_send += (_timeEnd-_timeStart);
  #endif


  // exchange locally... try and hide within Isend latency...
  _timeStart = CycleTime();
  #pragma omp parallel for if(level->exchange_ghosts[justFaces].num_blocks[1]>1) schedule(static,1)
  for(buffer=0;buffer<level->exchange_ghosts[justFaces].num_blocks[1];buffer++){CopyBlock(level,id,&level->exchange_ghosts[justFaces].blocks[1][buffer]);}
  _timeEnd = CycleTime();
  level->cycles.ghostZone_local += (_timeEnd-_timeStart);


  // wait for MPI to finish...
  #ifdef USE_MPI
  _timeStart = CycleTime();
  if(nMessages)MPI_Waitall(nMessages,level->exchange_ghosts[justFaces].requests,level->exchange_ghosts[justFaces].status);
  _timeEnd = CycleTime();
  level->cycles.ghostZone_wait += (_timeEnd-_timeStart);


  // unpack MPI receive buffers
  _timeStart = CycleTime();
  #pragma omp parallel for if(level->exchange_ghosts[justFaces].num_blocks[2]>1) schedule(static,1)
  for(buffer=0;buffer<level->exchange_ghosts[justFaces].num_blocks[2];buffer++){CopyBlock(level,id,&level->exchange_ghosts[justFaces].blocks[2][buffer]);}
  _timeEnd = CycleTime();
  level->cycles.ghostZone_unpack += (_timeEnd-_timeStart);
  #endif


  level->cycles.ghostZone_total += (uint64_t)(CycleTime()-_timeCommunicationStart);
}