void LLDriverParam::resetDrivenParams() { mDriven.clear(); mDriven.reserve(getInfo()->mDrivenInfoList.size()); }
bool CFlashTool::readFromMTD( const std::string & filename, int globalProgressEnd ) { int fd1; long filesize; int globalProgressBegin = 0; if(statusViewer) statusViewer->showLocalStatus(0); if (mtdDevice.empty()) { ErrorMessage = "mtd-device not set"; return false; } if( (fd = open( mtdDevice.c_str(), O_RDONLY )) < 0 ) { ErrorMessage = g_Locale->getText(LOCALE_FLASHUPDATE_CANTOPENMTD); return false; } if (!getInfo()) { close(fd); return false; } if( (fd1 = open( filename.c_str(), O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)) < 0 ) { ErrorMessage = g_Locale->getText(LOCALE_FLASHUPDATE_CANTOPENFILE); close(fd); return false; } if(statusViewer) globalProgressBegin = statusViewer->getGlobalStatus(); filesize = CMTDInfo::getInstance()->getMTDSize(mtdDevice); unsigned char buf[meminfo.writesize]; unsigned mtdoffset = 0; long fsize = filesize; while(fsize > 0) { unsigned block = meminfo.writesize; if (isnand) { unsigned blockstart = mtdoffset & ~(meminfo.erasesize - 1); if (blockstart == mtdoffset) { while (mtdoffset < meminfo.size) { printf("CFlashTool::readFromMTD: read block at %x\n", mtdoffset); loff_t offset = mtdoffset; int ret = ioctl(fd, MEMGETBADBLOCK, &offset); if (ret == 0) break; printf("CFlashTool::readFromMTD: bad block at %x, skipping..\n", mtdoffset); mtdoffset += meminfo.erasesize; fsize -= meminfo.erasesize; lseek(fd, mtdoffset, SEEK_SET); continue; } if (mtdoffset >= meminfo.size) { printf("CFlashTool::readFromMTD: end of device...\n"); break; } } } read(fd, buf, block); write(fd1, buf, block); fsize -= block; mtdoffset += meminfo.writesize; char prog = char(100-(100./filesize*fsize)); if(statusViewer) { statusViewer->showLocalStatus(prog); if(globalProgressEnd!=-1) { int globalProg = globalProgressBegin + int((globalProgressEnd-globalProgressBegin) * prog/100. ); statusViewer->showGlobalStatus(globalProg); } } } if(statusViewer) statusViewer->showLocalStatus(100); close(fd); close(fd1); return true; }
int main() { getInfo(); printf("Mac Version: %d.%d.%d\n", maj, min, bug); }
void MPHFAlgorithm<span,Abundance_t,NodeState_t>::populate () { size_t nb_iterated = 0; size_t n = _abundanceMap->size(); _nb_abundances_above_precision = 0; /** We need a progress object. */ tools::dp::IteratorListener* delegate = createIteratorListener(_solidCounts->getNbItems(),messages[3]); LOCAL (delegate); setProgress (new ProgressCustom(delegate)); SubjectIterator<Count>* itKmers = new SubjectIterator<Count> (_solidCounts->iterator(), _solidCounts->getNbItems()/100); itKmers->addObserver (_progress); LOCAL (itKmers); // TODO parallize that std::vector<int> & _abundanceDiscretization = _abundanceMap->_abundanceDiscretization ; int max_abundance_discrete = _abundanceDiscretization[_abundanceDiscretization.size()-2]; // set counts and at the same time, test the mphf for (itKmers->first(); !itKmers->isDone(); itKmers->next()) { //cout << "kmer: " << itKmers->item().value.toString(21) << std::endl; /** We get the hash code of the current item. */ typename AbundanceMap::Hash::Code h = _abundanceMap->getCode (itKmers->item().value); /** Little check. */ if (h >= n) { throw Exception ("MPHF check: value out of bounds"); } /** We get the abundance of the current kmer. */ int abundance = itKmers->item().abundance; if (abundance > max_abundance_discrete) { _nb_abundances_above_precision++; abundance = max_abundance_discrete; } //get first cell strictly greater than abundance std::vector<int>::iterator up = std::upper_bound(_abundanceDiscretization.begin(), _abundanceDiscretization.end(), abundance); up--; // get previous cell int idx = up- _abundanceDiscretization.begin() ; /** We set the abundance of the current kmer. */ _abundanceMap->at (h) = idx; nb_iterated ++; } if (nb_iterated != n && n > 3) { throw Exception ("ERROR during abundance population: itKmers iterated over %d/%d kmers only", nb_iterated, n); } #if 1 // you know what? let's always test if the MPHF does not have collisions, it won't hurt. check (); #endif /** We gather some statistics. */ getInfo()->add (1, "stats"); getInfo()->add (2, "nb_keys", "%ld", _abundanceMap->size()); getInfo()->add (2, "data_size", "%ld", _dataSize); getInfo()->add (2, "bits_per_key", "%.3f", (float)(_dataSize*8)/(float)_abundanceMap->size()); getInfo()->add (2, "prec", "%d", MAX_ABUNDANCE); getInfo()->add (2, "nb_abund_above_prec", "%d", _nb_abundances_above_precision); getInfo()->add (1, getTimeInfo().getProperties("time")); }
osg::ref_ptr<ossimPlanetImage> ossimPlanetSrtmElevationDatabase::getTexture(ossim_uint32 level, ossim_uint64 row, ossim_uint64 col, const ossimPlanetGridUtility& utility) { OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex); if(!theOpenFlag) { return 0; } if(!theEnableFlag) { return 0; } double minLat; double minLon; double maxLat; double maxLon; ossim_uint32 width = utility.getTileWidth(); ossim_uint32 height = utility.getTileHeight(); utility.getLatLonBounds(minLat, minLon, maxLat, maxLon, level, row, col); if(!theExtents->intersectsLatLon(minLat, minLon, maxLat, maxLon)) { return 0; } double deltaX; double deltaY; utility.getWidthHeightInDegrees(deltaX, deltaY, level, row, col); double deltaLat = deltaY/height; // double deltaLon = deltaX/width; ossimDpt gsd = ossimGpt().metersPerDegree(); gsd.y *= deltaLat; osg::ref_ptr<ossimPlanetImage> texture = 0; if(!theExtents->intersectsScale(gsd.y-FLT_EPSILON, gsd.y+FLT_EPSILON))//gsd.y <= theExtents.theMaxGsd) { return 0; } double minSubRectLat = ossim::max(theExtents->getMinLat(), minLat); double minSubRectLon = ossim::max(theExtents->getMinLon(), minLon); double maxSubRectLat = ossim::min(theExtents->getMaxLat(), maxLat); double maxSubRectLon = ossim::min(theExtents->getMaxLon(), maxLon); ossim_int32 wholeMinLat = (ossim_int32)std::floor(minSubRectLat); ossim_int32 wholeMinLon = (ossim_int32)std::floor(minSubRectLon); ossim_int32 wholeMaxLat = (ossim_int32)std::floor(maxSubRectLat); ossim_int32 wholeMaxLon = (ossim_int32)std::floor(maxSubRectLon); ossim_int32 lat = wholeMaxLat; ossim_int32 lon = wholeMinLon; // ossim_uint32 addedFiles = 0; // std::vector<ossimDpt> latLonOrigins; std::vector<std::string> latLonOrigins; for(;lat >= wholeMinLat; --lat) { lon = wholeMinLon; for(;lon <= wholeMaxLon; ++lon) { ossimFilename filename = buildFilename(lat, lon); if(filename != "") { latLonOrigins.push_back(filename); } } } if(latLonOrigins.size() == 0) { return 0; } ossim_uint32 idx = 0; ossim_uint32 numberOfFilesNeeded = latLonOrigins.size(); texture = new ossimPlanetImage(ossimPlanetTerrainTileId(0, level, col, row)); ossimRefPtr<ossimImageData> compositeData = new ossimImageData(0, OSSIM_FLOAT32, 1, width, height); compositeData->setNullPix(OSSIMPLANET_NULL_HEIGHT, 0); compositeData->initialize(); std::vector<ossimPlanetGridUtility::GridPoint> points; utility.createGridPoints(points, level, row, col, height, width); ossim_uint32 idxPts = 0; ossim_uint32 nPoints = points.size(); osg::Vec3d latLonPoint; double minValue = 1.0/DBL_EPSILON -1; double maxValue = -1.0/DBL_EPSILON +1; for(idx = 0; idx < numberOfFilesNeeded;++idx) { osg::ref_ptr<ossimPlanetSrtmElevationDatabase::SrtmInfo> srtmFile = getInfo(latLonOrigins[idx]); if(srtmFile.valid()) { ossim_float32* bufPtr = (ossim_float32*)compositeData->getBuf(); for(idxPts = 0; idxPts < nPoints; ++idxPts) { utility.getLatLon(latLonPoint, points[idxPts]); if((*bufPtr == OSSIMPLANET_NULL_HEIGHT)&& (latLonPoint[0] >= srtmFile->theMinLat)&& (latLonPoint[0] <= srtmFile->theMaxLat)&& (latLonPoint[1] >= srtmFile->theMinLon)&& (latLonPoint[1] <= srtmFile->theMaxLon)) { utility.getLatLon(latLonPoint, points[idxPts]); double h = srtmFile->theSrtmHandler->getHeightAboveMSL(ossimGpt(latLonPoint[0], latLonPoint[1])); if(!ossim::isnan(h)) { *bufPtr = h; if(*bufPtr < minValue) { minValue = *bufPtr; } if(*bufPtr > maxValue) { maxValue = *bufPtr; } } } ++bufPtr; } } } compositeData->validate(); if(compositeData->getDataObjectStatus() != OSSIM_EMPTY) { texture->fromOssimImage(compositeData, false); if(minValue < maxValue) { texture->setMinMax(minValue, maxValue); } } else { texture = 0; } return texture; }
struct tm File::getLastAccessTime() { return *::gmtime(&getInfo().st_atime); }
bool File::exists() { getInfo(); return exist; }
//----------------------------------------------------------------------------- // apply() //----------------------------------------------------------------------------- void LLPolyMorphTarget::apply( ESex avatar_sex ) { if (!mMorphData || mNumMorphMasksPending > 0) { return; } mLastSex = avatar_sex; // perform differential update of morph F32 delta_weight = ( getSex() & avatar_sex ) ? (mCurWeight - mLastWeight) : (getDefaultWeight() - mLastWeight); // store last weight mLastWeight += delta_weight; if (delta_weight != 0.f) { llassert(!mMesh->isLOD()); LLVector3 *coords = mMesh->getWritableCoords(); LLVector3 *scaled_normals = mMesh->getScaledNormals(); LLVector3 *normals = mMesh->getWritableNormals(); LLVector3 *scaled_binormals = mMesh->getScaledBinormals(); LLVector3 *binormals = mMesh->getWritableBinormals(); LLVector4 *clothing_weights = mMesh->getWritableClothingWeights(); LLVector2 *tex_coords = mMesh->getWritableTexCoords(); F32 *maskWeightArray = (mVertMask) ? mVertMask->getMorphMaskWeights() : NULL; for(U32 vert_index_morph = 0; vert_index_morph < mMorphData->mNumIndices; vert_index_morph++) { S32 vert_index_mesh = mMorphData->mVertexIndices[vert_index_morph]; F32 maskWeight = 1.f; if (maskWeightArray) { maskWeight = maskWeightArray[vert_index_morph]; } coords[vert_index_mesh] += mMorphData->mCoords[vert_index_morph] * delta_weight * maskWeight; if (getInfo()->mIsClothingMorph && clothing_weights) { LLVector3 clothing_offset = mMorphData->mCoords[vert_index_morph] * delta_weight * maskWeight; LLVector4* clothing_weight = &clothing_weights[vert_index_mesh]; clothing_weight->mV[VX] += clothing_offset.mV[VX]; clothing_weight->mV[VY] += clothing_offset.mV[VY]; clothing_weight->mV[VZ] += clothing_offset.mV[VZ]; clothing_weight->mV[VW] = maskWeight; } // calculate new normals based on half angles scaled_normals[vert_index_mesh] += mMorphData->mNormals[vert_index_morph] * delta_weight * maskWeight * NORMAL_SOFTEN_FACTOR; LLVector3 normalized_normal = scaled_normals[vert_index_mesh]; normalized_normal.normVec(); normals[vert_index_mesh] = normalized_normal; // calculate new binormals scaled_binormals[vert_index_mesh] += mMorphData->mBinormals[vert_index_morph] * delta_weight * maskWeight * NORMAL_SOFTEN_FACTOR; LLVector3 tangent = scaled_binormals[vert_index_mesh] % normalized_normal; LLVector3 normalized_binormal = normalized_normal % tangent; normalized_binormal.normVec(); binormals[vert_index_mesh] = normalized_binormal; tex_coords[vert_index_mesh] += mMorphData->mTexCoords[vert_index_morph] * delta_weight * maskWeight; } // now apply volume changes for( volume_list_t::iterator iter = mVolumeMorphs.begin(); iter != mVolumeMorphs.end(); iter++ ) { LLPolyVolumeMorph* volume_morph = &(*iter); LLVector3 scale_delta = volume_morph->mScale * delta_weight; LLVector3 pos_delta = volume_morph->mPos * delta_weight; volume_morph->mVolume->setScale(volume_morph->mVolume->getScale() + scale_delta); volume_morph->mVolume->setPosition(volume_morph->mVolume->getPosition() + pos_delta); } } if (mNext) { mNext->apply(avatar_sex); } }
BOOL LLTexLayerParamAlpha::getMultiplyBlend() const { return ((LLTexLayerParamAlphaInfo *)getInfo())->mMultiplyBlend; }
void Engine::Graphics::Draw2DObject(Drawable & object){ D3DXMATRIX transMat, scaleMat, rotMat, worldMat; D3DXMatrixIdentity(&transMat); D3DXMatrixIdentity(&scaleMat); D3DXMatrixIdentity(&rotMat); D3DXMatrixIdentity(&worldMat); D3DXMatrixScaling(&scaleMat, object.getScale().x, object.getScale().y, object.getScale().z); D3DXMatrixTranslation(&transMat, object.getTranslate().x, object.getTranslate().y, object.getTranslate().z); D3DXMatrixRotationYawPitchRoll(&rotMat, D3DXToRadian(object.getRotate().y),D3DXToRadian(object.getRotate().x), D3DXToRadian(object.getRotate().z)); D3DXMatrixMultiply(&scaleMat, &scaleMat, &rotMat); D3DXMatrixMultiply(&worldMat, &scaleMat, &transMat); Engine::DX::instance()->getSprite()->SetTransform(&worldMat); Engine::DX::instance()->getSprite()->Draw( getTexture(object.getHandle()), object.getIsSpriteSheet() ? &object.getRect() : 0, object.getIsSpriteSheet() ? &dVec3(object.getWidth() * 0.5f, object.getHeight() * 0.5f, 0.0f) : &dVec3(getInfo(object.getHandle()).Width *0.5f, getInfo(object.getHandle()).Height *0.5f, 0.0f), 0, object.getColor()); }
void Engine::Graphics::render(Drawable object, Camera *cam) { D3DXMATRIX transMat, scaleMat, rotMat, worldMat; D3DXMatrixIdentity(&transMat); D3DXMatrixIdentity(&scaleMat); D3DXMatrixIdentity(&rotMat); D3DXMatrixIdentity(&worldMat); if(!object.get3D()) { D3DXMatrixScaling(&scaleMat, object.getScale().x, object.getScale().y, object.getScale().z); D3DXMatrixTranslation(&transMat, object.getTranslate().x, object.getTranslate().y, object.getTranslate().z); D3DXMatrixRotationYawPitchRoll(&rotMat, D3DXToRadian(object.getRotate().y),D3DXToRadian(object.getRotate().x), D3DXToRadian(object.getRotate().z)); D3DXMatrixMultiply(&scaleMat, &scaleMat, &rotMat); D3DXMatrixMultiply(&worldMat, &scaleMat, &transMat); Engine::DX::instance()->getSprite()->SetTransform(&worldMat); Engine::DX::instance()->getSprite()->Draw( getTexture(object.getHandle()), object.getIsSpriteSheet() ? &object.getRect() : 0, object.getIsSpriteSheet() ? &dVec3(object.getWidth() * 0.5f, object.getHeight() * 0.5f, 0.0f) : &dVec3(getInfo(object.getHandle()).Width *0.5f, getInfo(object.getHandle()).Height *0.5f, 0.0f), 0, object.getColor()); } if(object.get3D()) { //camera.setLookAt(object.getTranslate().x, object.getTranslate().y, object.getTranslate().z); //camera.setProj(800,600); D3DXMATRIX WIT; UINT numPasses = 0; m_Effect->Begin(&numPasses, 0); Mesh *tempMesh = getMesh(object.getHandle()); for(UINT i = 0; i < numPasses; i++) { m_Effect->BeginPass(i); D3DXMatrixScaling(&scaleMat, object.getScale().x, object.getScale().y, object.getScale().z); D3DXMatrixTranslation(&transMat, object.getTranslate().x, object.getTranslate().y, object.getTranslate().z); D3DXMatrixRotationYawPitchRoll(&rotMat, D3DXToRadian(object.getRotate().y),D3DXToRadian(object.getRotate().x), D3DXToRadian(object.getRotate().z)); D3DXMatrixMultiply(&scaleMat, &scaleMat, &rotMat); D3DXMatrixMultiply(&worldMat, &scaleMat, &transMat); D3DXMatrixInverse(&WIT, 0, &worldMat); D3DXMatrixTranspose(&WIT, &WIT); m_Effect->SetMatrix("worldViewProjMat", &(worldMat * cam->getView() * cam->getProjection())); m_Effect->SetMatrix("worldInverseTransposeMat", &WIT); m_Effect->SetMatrix("worldMat", &worldMat); for(DWORD i = 0; i < tempMesh->getNumMaterials(); i++) { m_Effect->SetValue("ambientMaterial", &tempMesh->getMeshMaterial()[i].Ambient, sizeof(D3DXCOLOR)); m_Effect->SetValue("diffuseMaterial", &tempMesh->getMeshMaterial()[i].Diffuse, sizeof(D3DXCOLOR)); m_Effect->SetValue("specularMaterial", &tempMesh->getMeshMaterial()[i].Specular, sizeof(D3DXCOLOR)); m_Effect->SetFloat("specularPower", tempMesh->getMeshMaterial()[i].Power); if(object.getHasTexture()) { m_Effect->SetTexture("tex", tempMesh->getMeshTexture()[i]); m_Effect->SetBool("isTex", true); }else m_Effect->SetBool("isTex", false); m_Effect->CommitChanges(); tempMesh->getMesh()->DrawSubset(i); } m_Effect->EndPass(); //tempMesh = nullptr; } m_Effect->End(); } }
void CDlgCfgPSTNBreakLine::OnCfgPSTNBreakLineBtnSet() { // TODO: Add your control notification handler code here getInfo(); SetConfigToDevice(); }
RawData* DAT2::open(const std::string& file) const { const RawDataDAT2::s_info& info = getInfo(file); return new RawData(new RawDataDAT2(getVFS(), m_datpath, info)); }
/** * If a contact is selected send out a signal to get there info. */ void ChatRoomControlImp::infoClicked(){ if ( buddyList->currentItem() == -1) QMessageBox::information(this, "Kinkatta - Message","Select a buddy.", QMessageBox::Ok); else emit ( getInfo(buddyList->currentText()) ); }
struct tm File::getLastModifiedTime() { return *::gmtime(&getInfo().st_mtime); }
BOOL LLTexLayerParamAlpha::render(S32 x, S32 y, S32 width, S32 height) { BOOL success = TRUE; if (!mTexLayer) { return success; } F32 effective_weight = (mTexLayer->getTexLayerSet()->getAvatar()->getSex() & getSex()) ? mCurWeight : getDefaultWeight(); BOOL weight_changed = effective_weight != mCachedEffectiveWeight; if (getSkip()) { return success; } LLTexLayerParamAlphaInfo *info = (LLTexLayerParamAlphaInfo *)getInfo(); gGL.flush(); if (info->mMultiplyBlend) { gGL.blendFunc(LLRender::BF_DEST_ALPHA, LLRender::BF_ZERO); // Multiplication: approximates a min() function } else { gGL.setSceneBlendType(LLRender::BT_ADD); // Addition: approximates a max() function } if (!info->mStaticImageFileName.empty() && !mStaticImageInvalid) { if (mStaticImageTGA.isNull()) { // Don't load the image file until we actually need it the first time. Like now. mStaticImageTGA = LLTexLayerStaticImageList::getInstance()->getImageTGA(info->mStaticImageFileName); // We now have something in one of our caches LLTexLayerSet::sHasCaches |= mStaticImageTGA.notNull() ? TRUE : FALSE; if (mStaticImageTGA.isNull()) { llwarns << "Unable to load static file: " << info->mStaticImageFileName << llendl; mStaticImageInvalid = TRUE; // don't try again. return FALSE; } } const S32 image_tga_width = mStaticImageTGA->getWidth(); const S32 image_tga_height = mStaticImageTGA->getHeight(); if (!mCachedProcessedTexture || (mCachedProcessedTexture->getWidth() != image_tga_width) || (mCachedProcessedTexture->getHeight() != image_tga_height) || (weight_changed)) { // llinfos << "Building Cached Alpha: " << mName << ": (" << mStaticImageRaw->getWidth() << ", " << mStaticImageRaw->getHeight() << ") " << effective_weight << llendl; mCachedEffectiveWeight = effective_weight; if (!mCachedProcessedTexture) { mCachedProcessedTexture = LLViewerTextureManager::getLocalTexture(image_tga_width, image_tga_height, 1, FALSE); // We now have something in one of our caches LLTexLayerSet::sHasCaches |= mCachedProcessedTexture ? TRUE : FALSE; mCachedProcessedTexture->setExplicitFormat(GL_ALPHA8, GL_ALPHA); } // Applies domain and effective weight to data as it is decoded. Also resizes the raw image if needed. mStaticImageRaw = NULL; mStaticImageRaw = new LLImageRaw; mStaticImageTGA->decodeAndProcess(mStaticImageRaw, info->mDomain, effective_weight); mNeedsCreateTexture = TRUE; } if (mCachedProcessedTexture) { { // Create the GL texture, and then hang onto it for future use. if (mNeedsCreateTexture) { mCachedProcessedTexture->createGLTexture(0, mStaticImageRaw); mNeedsCreateTexture = FALSE; gGL.getTexUnit(0)->bind(mCachedProcessedTexture); mCachedProcessedTexture->setAddressMode(LLTexUnit::TAM_CLAMP); } LLGLSNoAlphaTest gls_no_alpha_test; gGL.getTexUnit(0)->bind(mCachedProcessedTexture); gl_rect_2d_simple_tex(width, height); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); stop_glerror(); } } // Don't keep the cache for other people's avatars // (It's not really a "cache" in that case, but the logic is the same) if (!mAvatar->isSelf()) { mCachedProcessedTexture = NULL; } } else { LLGLDisable no_alpha(GL_ALPHA_TEST); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.color4f(0.f, 0.f, 0.f, effective_weight); gl_rect_2d_simple(width, height); } return success; }
struct tm File::getLastStatusChangedTime() { return *::gmtime(&getInfo().st_ctime); }
OsStatus MpeIPPGAmr::initEncode(void) { int lCallResult; ippStaticInit(); strcpy((char*)m_pCodec->codecName, "IPP_GSMAMR"); m_pCodec->lIsVad = 1; // Load codec by name from command line lCallResult = LoadUSCCodecByName(m_pCodec, NULL); if (lCallResult < 0) { return OS_FAILED; } // Get USC codec params lCallResult = USCCodecAllocInfo(&m_pCodec->uscParams, NULL); if (lCallResult < 0) { return OS_FAILED; } lCallResult = USCCodecGetInfo(&m_pCodec->uscParams, NULL); if (lCallResult < 0) { return OS_FAILED; } // Get its supported format details lCallResult = GetUSCCodecParamsByFormat(m_pCodec, BY_NAME, NULL); if (lCallResult < 0) { return OS_FAILED; } // Set params for encode USC_PCMType streamType; streamType.bitPerSample = getInfo()->getNumBitsPerSample(); streamType.nChannels = getInfo()->getNumChannels(); streamType.sample_frequency = getInfo()->getSamplingRate(); lCallResult = SetUSCEncoderPCMType(&m_pCodec->uscParams, LINEAR_PCM, &streamType, NULL); if (lCallResult < 0) { return OS_FAILED; } // instead of SetUSCEncoderParams(...) m_pCodec->uscParams.pInfo->params.direction = USC_ENCODE; m_pCodec->uscParams.pInfo->params.law = 0; m_pCodec->uscParams.pInfo->params.modes.bitrate = m_bitrate; m_pCodec->uscParams.pInfo->params.modes.vad = ms_bEnableVAD ? 1 : 0; // Alloc memory for the codec lCallResult = USCCodecAlloc(&m_pCodec->uscParams, NULL); if (lCallResult < 0) { return OS_FAILED; } // Init decoder lCallResult = USCEncoderInit(&m_pCodec->uscParams, NULL, NULL); if (lCallResult < 0) { return OS_FAILED; } // Allocate memory for the output buffer. Size of output buffer is equal // to the size of 1 frame m_pInputBuffer = (Ipp8s *)ippsMalloc_8s(m_pCodec->uscParams.pInfo->params.framesize); m_pOutputBuffer = (Ipp8u *)ippsMalloc_8u(m_pCodec->uscParams.pInfo->maxbitsize + 10); m_storedFramesCount = 0; return OS_SUCCESS; }
off_t File::getSize() { return getInfo().st_size; }
void __RPC_STUB callAny_getInfo( PRPC_MESSAGE _pRpcMessage ) { long _RetVal; MIDL_STUB_MESSAGE _StubMsg; wchar_t __RPC_FAR *provider; handle_t session; RPC_STATUS _Status; ((void)(_Status)); NdrServerInitializeNew( _pRpcMessage, &_StubMsg, &callAny_StubDesc); session = _pRpcMessage->Handle; ( wchar_t __RPC_FAR * )provider = 0; RpcTryFinally { RpcTryExcept { if ( (_pRpcMessage->DataRepresentation & 0X0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION ) NdrConvert( (PMIDL_STUB_MESSAGE) &_StubMsg, (PFORMAT_STRING) &__MIDL_ProcFormatString.Format[22] ); if(_StubMsg.Buffer > _StubMsg.BufferEnd) { RpcRaiseException(RPC_X_BAD_STUB_DATA); } } RpcExcept( RPC_BAD_STUB_DATA_EXCEPTION_FILTER ) { RpcRaiseException(RPC_X_BAD_STUB_DATA); } RpcEndExcept if(260 * 2 < 0) { RpcRaiseException(RPC_X_INVALID_BOUND); } provider = NdrAllocate(&_StubMsg,260 * 2); _RetVal = getInfo(session,provider); _StubMsg.BufferLength = 12U + 10U; _StubMsg.MaxCount = 260; NdrConformantStringBufferSize( (PMIDL_STUB_MESSAGE) &_StubMsg, (unsigned char __RPC_FAR *)provider, (PFORMAT_STRING) &__MIDL_TypeFormatString.Format[112] ); _StubMsg.BufferLength += 16; _pRpcMessage->BufferLength = _StubMsg.BufferLength; _Status = I_RpcGetBuffer( _pRpcMessage ); if ( _Status ) RpcRaiseException( _Status ); _StubMsg.Buffer = (unsigned char __RPC_FAR *) _pRpcMessage->Buffer; _StubMsg.MaxCount = 260; NdrConformantStringMarshall( (PMIDL_STUB_MESSAGE)& _StubMsg, (unsigned char __RPC_FAR *)provider, (PFORMAT_STRING) &__MIDL_TypeFormatString.Format[112] ); _StubMsg.Buffer = (unsigned char __RPC_FAR *)(((long)_StubMsg.Buffer + 3) & ~ 0x3); *(( long __RPC_FAR * )_StubMsg.Buffer)++ = _RetVal; } RpcFinally { _StubMsg.MaxCount = 260; NdrPointerFree( &_StubMsg, (unsigned char __RPC_FAR *)provider, &__MIDL_TypeFormatString.Format[108] ); } RpcEndFinally _pRpcMessage->BufferLength = (unsigned int)((long)_StubMsg.Buffer - (long)_pRpcMessage->Buffer); }
bool File::isDir() { return getInfo().st_mode & S_IFDIR; }
plugMainUnion plugMain(DWORD functionCode, DWORD inputValue, DWORD instanceID) #endif { plugMainUnion retval; // declare pPlugObj - pointer to this instance CFreeFrameGLPlugin* pPlugObj; // typecast DWORD into pointer to a CFreeFrameGLPlugin pPlugObj = (CFreeFrameGLPlugin*) instanceID; switch (functionCode) { case FF_GETINFO: retval.PISvalue = (PluginInfoStruct*)getInfo(); break; case FF_INITIALISE: retval.ivalue = initialise(); break; case FF_DEINITIALISE: retval.ivalue = deInitialise(); break; case FF_GETNUMPARAMETERS: retval.ivalue = getNumParameters(); break; case FF_GETPARAMETERNAME: retval.svalue = getParameterName(inputValue); break; case FF_GETPARAMETERDEFAULT: retval.ivalue = getParameterDefault(inputValue); break; case FF_GETPLUGINCAPS: retval.ivalue = getPluginCaps(inputValue); break; case FF_GETEXTENDEDINFO: retval.ivalue = (DWORD) getExtendedInfo(); break; case FF_GETPARAMETERTYPE: retval.ivalue = getParameterType(inputValue); break; case FF_GETPARAMETERDISPLAY: if (pPlugObj != NULL) retval.svalue = pPlugObj->GetParameterDisplay(inputValue); else retval.svalue = (char*)FF_FAIL; break; case FF_SETPARAMETER: if (pPlugObj != NULL) retval.ivalue = pPlugObj->SetParameter((const SetParameterStruct*) inputValue); else retval.ivalue = FF_FAIL; break; case FF_GETPARAMETER: if (pPlugObj != NULL) retval.ivalue = pPlugObj->GetParameter(inputValue); else retval.ivalue = FF_FAIL; break; case FF_INSTANTIATEGL: retval.ivalue = (DWORD)instantiateGL((const FFGLViewportStruct *)inputValue); break; case FF_DEINSTANTIATEGL: if (pPlugObj != NULL) retval.ivalue = deInstantiateGL(pPlugObj); else retval.ivalue = FF_FAIL; break; case FF_GETIPUTSTATUS: if (pPlugObj != NULL) retval.ivalue = pPlugObj->GetInputStatus(inputValue); else retval.ivalue = FF_FAIL; break; case FF_PROCESSOPENGL: if (pPlugObj != NULL) { ProcessOpenGLStruct *pogls = (ProcessOpenGLStruct *)inputValue; if (pogls!=NULL) retval.ivalue = pPlugObj->ProcessOpenGL(pogls); else retval.ivalue = FF_FAIL; } else retval.ivalue = FF_FAIL; break; case FF_SETTIME: if (pPlugObj != NULL) { double *inputTime = (double *)inputValue; if (inputTime!=NULL) retval.ivalue = pPlugObj->SetTime(*inputTime); else retval.ivalue = FF_FAIL; } else retval.ivalue = FF_FAIL; break; //these old FF functions must always fail for FFGL plugins case FF_INSTANTIATE: case FF_DEINSTANTIATE: case FF_PROCESSFRAME: case FF_PROCESSFRAMECOPY: default: retval.ivalue = FF_FAIL; break; } return retval; }
osg::ref_ptr<ossimPlanetImage> ossimPlanetSrtmElevationDatabase::getTexture(ossim_uint32 width, ossim_uint32 height, const ossimPlanetTerrainTileId& tileId, const ossimPlanetGrid& grid, ossim_int32 padding) { if(!theEnableFlag) { return 0; } osg::ref_ptr<ossimPlanetImage> texture; ossimPlanetGrid::GridBound bound; ossimPlanetGrid::GridBound tileBound; if(grid.findGridBound(tileId.face(), ossimPlanetGrid::ModelPoint(theExtents->getMinLon(), theExtents->getMinLat()), ossimPlanetGrid::ModelPoint(theExtents->getMaxLon(), theExtents->getMaxLat()), bound)) { grid.bounds(tileId,tileBound); if(!tileBound.toDrect().intersects(bound.toDrect())) { return 0; } } osg::Vec2d deltaXY; grid.widthHeightInModelSpace(tileId, deltaXY); double deltaLat = (deltaXY[1])/(double)(height); ossimDpt gsd = ossimGpt().metersPerDegree(); gsd.y *= deltaLat; if(gsd.y < theExtents->getMaxScale()) { ossimPlanetGrid::ModelPoints points; grid.createModelPoints(tileId, width, height, points, padding); ossim_uint32 idxPts = 0; ossim_uint32 nPoints = points.size(); ossimPlanetGrid::ModelPoint* optimizedOutPtr = &points.front(); texture = new ossimPlanetImage(tileId); ossimRefPtr<ossimImageData> compositeData = new ossimImageData(0, OSSIM_FLOAT32, 1, width+2*padding, height+2*padding); compositeData->setNullPix(OSSIMPLANET_NULL_HEIGHT, 0); compositeData->initialize(); texture->setPadding(padding); ossim_float32* bufPtr = (ossim_float32*)compositeData->getBuf(); ossimElevManager* manager = ossimElevManager::instance(); double minValue = 999999999.0; double maxValue = -999999999.0; for(idxPts = 0; idxPts < nPoints; ++idxPts,++optimizedOutPtr) { double h = manager->getHeightAboveEllipsoid(ossimGpt((*optimizedOutPtr).y(), (*optimizedOutPtr).x())); if(!ossim::isnan(h)) { *bufPtr = h; } ++bufPtr; } compositeData->validate(); if(compositeData->getDataObjectStatus() != OSSIM_EMPTY) { texture->fromOssimImage(compositeData, false); if(minValue < maxValue) { texture->setMinMax(minValue, maxValue); } } else { texture = 0; } } #if 0 if(!theOpenFlag) { return 0; } if(!theEnableFlag) { return 0; } osg::ref_ptr<ossimPlanetImage> texture; ossimPlanetGrid::GridBound bound; ossimPlanetGrid::GridBound tileBound; if(grid.findGridBound(tileId.face(), ossimPlanetGrid::ModelPoint(theExtents->getMinLon(), theExtents->getMinLat()), ossimPlanetGrid::ModelPoint(theExtents->getMaxLon(), theExtents->getMaxLat()), bound)) { grid.bounds(tileId,tileBound); if(!tileBound.toDrect().intersects(bound.toDrect())) { return 0; } } osg::Vec2d deltaXY; grid.widthHeightInModelSpace(tileId, deltaXY); double deltaLat = (deltaXY[1])/(double)(height); double deltaLon = (deltaXY[0])/(double)(width); ossimDpt gsd = ossimGpt().metersPerDegree(); gsd.y *= deltaLat; if(gsd.y < theExtents->getMaxScale()) { ossimPlanetGrid::ModelPoints points; grid.createModelPoints(tileId, width, height, points, padding); ossim_float64 minModelX, minModelY, maxModelX, maxModelY; ossim_uint32 idxPts = 0; ossim_uint32 nPoints = points.size(); minModelX = points[0].x(); maxModelX = minModelX; minModelY = points[0].y(); maxModelY = minModelY; ossimPlanetGrid::ModelPoint* optimizedOutPtr = &points.front(); ++optimizedOutPtr; for(idxPts = 1; idxPts < nPoints; ++idxPts,++optimizedOutPtr) { if(optimizedOutPtr->x() < minModelX) minModelX = optimizedOutPtr->x(); if(optimizedOutPtr->x() > maxModelX) maxModelX = optimizedOutPtr->x(); if(optimizedOutPtr->y() < minModelY) minModelY = optimizedOutPtr->y(); if(optimizedOutPtr->y() > maxModelY) maxModelY = optimizedOutPtr->y(); } ossim_int32 wholeMinY = (ossim_int32)std::floor(minModelY); ossim_int32 wholeMinX = (ossim_int32)std::floor(minModelX); ossim_int32 wholeMaxY = (ossim_int32)std::floor(maxModelY); ossim_int32 wholeMaxX = (ossim_int32)std::floor(maxModelX); ossim_int32 lat = wholeMaxY; ossim_int32 lon = wholeMinX; // std::vector<ossimDpt> latLonOrigins; std::vector<std::string> latLonOrigins; for(;lat >= wholeMinY; --lat) { lon = wholeMinX; for(;lon <= wholeMaxX; ++lon) { ossimFilename filename = buildFilename(lat, lon); if(filename != "") { latLonOrigins.push_back(filename); } } } osg::Vec3d latLonPoint; double minValue = 1.0/DBL_EPSILON -1; double maxValue = -1.0/DBL_EPSILON +1; if(latLonOrigins.size() == 0) { return 0; } ossim_uint32 idx = 0; ossim_uint32 numberOfFilesNeeded = latLonOrigins.size(); texture = new ossimPlanetImage(tileId); ossimRefPtr<ossimImageData> compositeData = new ossimImageData(0, OSSIM_FLOAT32, 1, width+2*padding, height+2*padding); compositeData->setNullPix(OSSIMPLANET_NULL_HEIGHT, 0); compositeData->initialize(); texture->setPadding(padding); for(idx = 0; idx < numberOfFilesNeeded;++idx) { osg::ref_ptr<ossimPlanetSrtmElevationDatabase::SrtmInfo> srtmFile = getInfo(latLonOrigins[idx]); if(srtmFile.valid()) { ossim_float64 nullHeight = srtmFile->theSrtmHandler->getNullHeightValue(); ossim_float32* bufPtr = (ossim_float32*)compositeData->getBuf(); optimizedOutPtr = &points.front(); for(idxPts = 0; idxPts < nPoints; ++idxPts,++optimizedOutPtr) { if((*bufPtr == OSSIMPLANET_NULL_HEIGHT)&& (optimizedOutPtr->y() >= srtmFile->theMinLat)&& (optimizedOutPtr->y() <= srtmFile->theMaxLat)&& (optimizedOutPtr->x() >= srtmFile->theMinLon)&& (optimizedOutPtr->x() <= srtmFile->theMaxLon)) { double h = srtmFile->theSrtmHandler->getHeightAboveMSL(ossimGpt(optimizedOutPtr->y(), optimizedOutPtr->x())); if(!ossim::isnan(h)&& (h!=nullHeight)) { if(theGeoRefModel.valid()) { h+=theGeoRefModel->getGeoidOffset(optimizedOutPtr->y(), optimizedOutPtr->x()); } *bufPtr = h; if(h < minValue) { minValue = h; } if(h > maxValue) { maxValue = h; } } else { *bufPtr = 0; } } ++bufPtr; } } } compositeData->validate(); if(compositeData->getDataObjectStatus() != OSSIM_EMPTY) { texture->fromOssimImage(compositeData, false); if(minValue < maxValue) { texture->setMinMax(minValue, maxValue); } } else { texture = 0; } } #endif return texture; }
void loadLiteral(const char *filename, FILE *f, u1 *littype /*out*/, Word *literal /*out*/, const StringTabEntry *strings, HashTable *itbls, HashTable *closures) { u4 i; *littype = fget_u1(f); switch (*littype) { case LIT_INT: *literal = (Word)fget_varsint(f); break; case LIT_CHAR: *literal = (Word)fget_varuint(f); break; case LIT_WORD: *literal = (Word)fget_varuint(f); break; case LIT_FLOAT: *literal = (Word)fget_u4(f); break; case LIT_STRING: i = fget_varuint(f); *literal = (Word)strings[i].str; break; case LIT_CLOSURE: { char *clname = loadId(f, strings, "."); Closure *cl = HashTable_lookup(closures, clname); if (cl == NULL) { // 1st forward ref, create the link cl = xmalloc(sizeof(ClosureHeader) + sizeof(Word)); setInfo(cl, NULL); cl->payload[0] = (Word)literal; *literal = (Word)NULL; LD_DBG_PR(2, "Creating forward reference %p for `%s', %p\n", cl, clname, literal); HashTable_insert(closures, clname, cl); } else if (getInfo(cl) == NULL) { // forward ref (not the first), insert into linked list LD_DBG_PR(2, "Linking forward reference %p (%s, target: %p)\n", cl, clname, literal); *literal = (Word)cl->payload[0]; cl->payload[0] = (Word)literal; xfree(clname); } else { *literal = (Word)cl; xfree(clname); } } break; case LIT_INFO: { char *infoname = loadId(f, strings, "."); InfoTable *info = HashTable_lookup(itbls, infoname); FwdRefInfoTable *info2; if (info == NULL) { // 1st forward ref info2 = xmalloc(sizeof(FwdRefInfoTable)); info2->i.type = INVALID_OBJECT; info2->next = (void**)literal; *literal = (Word)NULL; HashTable_insert(itbls, infoname, info2); } else if (info->type == INVALID_OBJECT) { // subsequent forward ref info2 = (FwdRefInfoTable*)info; *literal = (Word)info2->next; info2->next = (void**)literal; xfree(infoname); } else { *literal = (Word)info; xfree(infoname); } } break; default: fprintf(stderr, "ERROR: Unknown literal type (%d) " "when loading file: %s\n", *littype, filename); exit(1); } }
bool CFlashTool::erase(int globalProgressEnd) { erase_info_t lerase; int globalProgressBegin = 0; if( (fd = open( mtdDevice.c_str(), O_RDWR )) < 0 ) { printf("CFlashTool::erase: cant open %s\n", mtdDevice.c_str()); ErrorMessage = g_Locale->getText(LOCALE_FLASHUPDATE_CANTOPENMTD); return false; } if (!getInfo()) { close(fd); return false; } CNeutrinoApp::getInstance()->stopDaemonsForFlash(); #ifndef VFD_UPDATE CVFD::getInstance()->ShowText("Erase Flash"); #endif if(statusViewer) { globalProgressBegin = statusViewer->getGlobalStatus(); statusViewer->paint(); statusViewer->showLocalStatus(0); statusViewer->showGlobalStatus(globalProgressBegin); } lerase.length = meminfo.erasesize; for (lerase.start = 0; lerase.start < meminfo.size; lerase.start += meminfo.erasesize) { /* printf( "Erasing %s erase size %x start %x size %x\n", mtdDevice.c_str(), meminfo.erasesize, lerase.start, meminfo.size ); */ int prog = int(lerase.start*100./meminfo.size); if(statusViewer) { statusViewer->showLocalStatus(prog); if(globalProgressEnd!=-1) { int globalProg = globalProgressBegin + int((globalProgressEnd-globalProgressBegin) * prog/100. ); statusViewer->showGlobalStatus(globalProg); } } if (isnand) { loff_t offset = lerase.start; int ret = ioctl(fd, MEMGETBADBLOCK, &offset); if (ret > 0) { printf("Erasing: bad block at %x, skipping..\n", lerase.start); continue; } } if(ioctl( fd, MEMERASE, &lerase) != 0) { ErrorMessage = g_Locale->getText(LOCALE_FLASHUPDATE_ERASEFAILED); close(fd); return false; } printf( "Erasing %u Kbyte @ 0x%08X -- %2u %% complete.\n", meminfo.erasesize/1024, lerase.start, prog); } printf("\n"); close(fd); return true; }
/*! */ LightSourceInfo UniformLightSourceSampler::getInfo( const IntersectionInfo& /* info */, const Object* light_source) const noexcept { return getInfo(light_source); }
void Server_Game::doStartGameIfReady() { Server_DatabaseInterface *databaseInterface = room->getServer()->getDatabaseInterface(); QMutexLocker locker(&gameMutex); if (getPlayerCount() < maxPlayers) return; QMapIterator<int, Server_Player *> playerIterator(players); while (playerIterator.hasNext()) { Server_Player *p = playerIterator.next().value(); if (!p->getReadyStart() && !p->getSpectator()) return; } playerIterator.toFront(); while (playerIterator.hasNext()) { Server_Player *p = playerIterator.next().value(); if (!p->getSpectator()) p->setupZones(); } gameStarted = true; playerIterator.toFront(); while (playerIterator.hasNext()) { Server_Player *player = playerIterator.next().value(); player->setConceded(false); player->setReadyStart(false); } if (firstGameStarted) { currentReplay->set_duration_seconds(secondsElapsed - startTimeOfThisGame); replayList.append(currentReplay); currentReplay = new GameReplay; currentReplay->set_replay_id(databaseInterface->getNextReplayId()); ServerInfo_Game *gameInfo = currentReplay->mutable_game_info(); getInfo(*gameInfo); gameInfo->set_started(false); Event_GameStateChanged omniscientEvent; createGameStateChangedEvent(&omniscientEvent, 0, true, true); GameEventContainer *replayCont = prepareGameEvent(omniscientEvent, -1); replayCont->set_seconds_elapsed(0); replayCont->clear_game_id(); currentReplay->add_event_list()->CopyFrom(*replayCont); delete replayCont; startTimeOfThisGame = secondsElapsed; } else firstGameStarted = true; sendGameStateToPlayers(); activePlayer = -1; nextTurn(); locker.unlock(); ServerInfo_Game gameInfo; gameInfo.set_room_id(room->getId()); gameInfo.set_game_id(gameId); gameInfo.set_started(true); emit gameInfoChanged(gameInfo); }
BOOL LLFloaterAbout::postBuild() { center(); LLViewerTextEditor *support_widget = getChild<LLViewerTextEditor>("support_editor", true); LLViewerTextEditor *credits_widget = getChild<LLViewerTextEditor>("credits_editor", true); getChild<LLUICtrl>("copy_btn")->setCommitCallback( boost::bind(&LLFloaterAbout::onClickCopyToClipboard, this)); #if LL_WINDOWS getWindow()->incBusyCount(); getWindow()->setCursor(UI_CURSOR_ARROW); #endif LLSD info(getInfo()); #if LL_WINDOWS getWindow()->decBusyCount(); getWindow()->setCursor(UI_CURSOR_ARROW); #endif std::ostringstream support; // Render the LLSD from getInfo() as a format_map_t LLStringUtil::format_map_t args; // For reasons I don't yet understand, [ReleaseNotes] is not part of the // default substitution strings whereas [APP_NAME] is. But it works to // simply copy it into these specific args. args["ReleaseNotes"] = LLTrans::getString("ReleaseNotes"); for (LLSD::map_const_iterator ii(info.beginMap()), iend(info.endMap()); ii != iend; ++ii) { if (! ii->second.isArray()) { // Scalar value if (ii->second.isUndefined()) { args[ii->first] = getString("none"); } else { // don't forget to render value asString() args[ii->first] = ii->second.asString(); } } else { // array value: build KEY_0, KEY_1 etc. entries for (LLSD::Integer n(0), size(ii->second.size()); n < size; ++n) { args[STRINGIZE(ii->first << '_' << n)] = ii->second[n].asString(); } } } // Now build the various pieces support << getString("AboutHeader", args); if (info.has("REGION")) { support << "\n\n" << getString("AboutPosition", args); } support << "\n\n" << getString("AboutSystem", args); support << "\n"; if (info.has("GRAPHICS_DRIVER_VERSION")) { support << "\n" << getString("AboutDriver", args); } support << "\n" << getString("AboutLibs", args); if (info.has("COMPILER")) { support << "\n" << getString("AboutCompiler", args); } if (info.has("PACKETS_IN")) { support << '\n' << getString("AboutTraffic", args); } support_widget->appendText(support.str(), FALSE, LLStyle::Params() .color(LLUIColorTable::instance().getColor("TextFgReadOnlyColor"))); support_widget->blockUndo(); // Fix views support_widget->setEnabled(FALSE); support_widget->startOfDoc(); credits_widget->setEnabled(FALSE); credits_widget->startOfDoc(); return TRUE; }
void Task::stdOut( bool full) const { std::cout << getInfo( full) << std::endl; }
int main(void) { cl_context context = 0; cl_command_queue command_waiting_line = 0; cl_program program = 0; cl_device_id device_id = 0; cl_kernel kernel = 0; // int numberOfMemoryObjects = 3; cl_mem memoryObjects[3] = {0, 0, 0}; cl_platform_id platform_id = NULL; cl_uint ret_num_devices; cl_int errorNumber; cl_int ret; /* Load the source code containing the kernel*/ char fileName[] = "source/parallel/composition_population.cl"; FILE *fp; char *source_str; size_t source_size; fp = fopen(fileName, "r"); cl_uint ret_num_platforms; if (!fp) { fprintf(stderr, "Failed to load kernel %s:%d.\n", __FILE__, __LINE__); exit(1); } source_str = (char *)malloc(MAX_SOURCE_SIZE); source_size = fread(source_str, 1, MAX_SOURCE_SIZE, fp); fclose(fp); // printf("file: %s :file", source_str); getInfo(); ret = clGetPlatformIDs(1, &platform_id, &ret_num_platforms); if (!success_verification(ret)) { // cleanUpOpenCL(context, command_waiting_line, program, kernel, // memoryObjects, // numberOfMemoryObjects); fprintf(stderr, "Failed to get platform id's. %s:%d\n", __FILE__, __LINE__); return 1; } ret = clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_DEFAULT, 1, &device_id, &ret_num_devices); if (!success_verification(ret)) { // cleanUpOpenCL(context, command_waiting_line, program, kernel, // memoryObjects, // numberOfMemoryObjects); fprintf(stderr, "Failed to get OpenCL devices. %s:%d\n", __FILE__, __LINE__); return 1; } context = clCreateContext(NULL, 1, &device_id, NULL, NULL, &ret); if (!success_verification(ret)) { // cleanUpOpenCL(context, command_waiting_line, program, kernel, // memoryObjects, // numberOfMemoryObjects); fprintf(stderr, "Failed to create an OpenCL context. %s:%d\n", __FILE__, __LINE__); return 1; } #ifdef CL_VERSION_2_0 command_waiting_line = clCreateCommandQueueWithProperties(context, device_id, 0, &ret); #else command_waiting_line = clCreateCommandQueue(context, device_id, 0, &ret); #endif if (!success_verification(ret)) { // cleanUpOpenCL(context, command_waiting_line, program, kernel, // memoryObjects, // numberOfMemoryObjects); fprintf(stderr, "Failed to create the OpenCL command queue. %s:%d\n", __FILE__, __LINE__); return 1; } /* create program */ program = clCreateProgramWithSource(context, 1, (const char **)&source_str, (const size_t *)&source_size, &ret); if (!success_verification(ret)) { // cleanUpOpenCL(context, command_waiting_line, program, kernel, // memoryObjects, // numberOfMemoryObjects); fprintf(stderr, "Failed to create OpenCL program. %s:%d\n", __FILE__, __LINE__); return 1; } /* Build Kernel Program */ ret = clBuildProgram(program, 1, &device_id, NULL, NULL, NULL); if (!success_verification(ret)) { // cleanUpOpenCL(context, command_waiting_line, program, kernel, // memoryObjects, // numberOfMemoryObjects); fprintf(stderr, "Failed to build OpenCL program. %s:%d\n", __FILE__, __LINE__); return 1; } kernel = clCreateKernel(program, "composition_population", &errorNumber); if (!success_verification(errorNumber)) { // cleanUpOpenCL(context, command_waiting_line, program, kernel, // memoryObjects, // numberOfMemoryObjects); fprintf(stderr, "Failed to create OpenCL kernel. %s:%d\n", __FILE__, __LINE__); return 1; } /* [Setup memory] */ /* Number of elements in the arrays of input and output data. */ /* The buffers are the size of the arrays. */ uint16_t activity_atom_size = MAX_INDEPENDENTCLAUSE_TABLET * 1; uint8_t program_size = 1; uint8_t population_size = 4; size_t activity_atom_byte_size = activity_atom_size * sizeof(v16us); uint16_t population_byte_size = (uint16_t)(program_size * (uint16_t)(population_size * sizeof(v16us))); /* * Ask the OpenCL implementation to allocate buffers for the data. * We ask the OpenCL implemenation to allocate memory rather than allocating * it on the CPU to avoid having to copy the data later. * The read/write flags relate to accesses to the memory from within the * kernel. */ int createMemoryObjectsSuccess = TRUE; memoryObjects[0] = clCreateBuffer(context, CL_MEM_READ_ONLY | CL_MEM_ALLOC_HOST_PTR, activity_atom_byte_size, NULL, &errorNumber); createMemoryObjectsSuccess &= success_verification(errorNumber); memoryObjects[1] = clCreateBuffer(context, CL_MEM_WRITE_ONLY | CL_MEM_ALLOC_HOST_PTR, population_byte_size, NULL, &errorNumber); createMemoryObjectsSuccess &= success_verification(errorNumber); memoryObjects[2] = clCreateBuffer(context, CL_MEM_WRITE_ONLY | CL_MEM_ALLOC_HOST_PTR, newspaper_byte_size, NULL, &errorNumber); createMemoryObjectsSuccess &= success_verification(errorNumber); if (!createMemoryObjectsSuccess) { // cleanUpOpenCL(context, command_waiting_line, program, kernel, // memoryObjects, // numberOfMemoryObjects); fprintf(stderr, "Failed to create OpenCL buffer. %s:%d\n", __FILE__, __LINE__); return 1; } /* [Setup memory] */ /* [Map the buffers to pointers] */ /* Map the memory buffers created by the OpenCL implementation to pointers so * we can access them on the CPU. */ int mapMemoryObjectsSuccess = TRUE; v16us *activity_atom = (v16us *)clEnqueueMapBuffer( command_waiting_line, memoryObjects[0], CL_TRUE, CL_MAP_WRITE, 0, activity_atom_byte_size, 0, NULL, NULL, &errorNumber); mapMemoryObjectsSuccess &= success_verification(errorNumber); // cl_int *inputB = (cl_int *)clEnqueueMapBuffer( // command_waiting_line, memoryObjects[1], CL_TRUE, CL_MAP_WRITE, 0, // bufferSize, 0, // NULL, NULL, &errorNumber); // mapMemoryObjectsSuccess &= success_verification(errorNumber); if (!mapMemoryObjectsSuccess) { // cleanUpOpenCL(context, command_waiting_line, program, kernel, // memoryObjects, // numberOfMemoryObjects); fprintf(stderr, "Failed to map buffer. %s:%d\n", __FILE__, __LINE__); return 1; } /* [Map the buffers to pointers] */ /* [Initialize the input data] */ const char *activity_atom_text = "nyistu htoftu hnattu hnamtu"; const uint16_t activity_atom_text_size = (uint16_t)(strlen(activity_atom_text)); const char *quiz_independentClause_list_text = "zrundoka hwindocayu hwindokali" "hwindoka tyutdocayu tyindokali" "tyutdoka tyutdocayu hfutdokali" "tyindoka fwandocayu nyatdokali"; //"bu.hnac.2.hnac.buka bu.hnac.2.hnac.buca yu " //"bu.hnac.4.hnac.bukali"; const uint16_t quiz_independentClause_list_text_size = (uint16_t)strlen(quiz_independentClause_list_text); uint16_t quiz_independentClause_list_size = 4; v16us quiz_independentClause_list[8]; uint16_t text_remainder = 0; // uint16_t program_worth = 0; uint64_t random_seed = 0x0123456789ABCDEF; uint16_t tablet_indexFinger = 0; // uint8_t champion = 0; // uint16_t champion_worth = 0; // v16us program_; // v16us population[4]; memset(quiz_independentClause_list, 0, (size_t)(quiz_independentClause_list_size * TABLET_LONG * WORD_THICK)); text_code(activity_atom_text_size, activity_atom_text, &activity_atom_size, activity_atom, &text_remainder); assert(text_remainder == 0); text_code(quiz_independentClause_list_text_size, quiz_independentClause_list_text, &quiz_independentClause_list_size, quiz_independentClause_list, &text_remainder); /* [Initialize the input data] */ /* [Un-map the buffers] */ /* * Unmap the memory objects as we have finished using them from the CPU side. * We unmap the memory because otherwise: * - reads and writes to that memory from inside a kernel on the OpenCL side * are undefined. * - the OpenCL implementation cannot free the memory when it is finished. */ if (!success_verification( clEnqueueUnmapMemObject(command_waiting_line, memoryObjects[0], activity_atom, 0, NULL, NULL))) { // cleanUpOpenCL(context, command_waiting_line, program, kernel, // memoryObjects, // numberOfMemoryObjects); fprintf(stderr, "Unmapping memory objects failed %s:%d\n", __FILE__, __LINE__); return 1; } // if (!success_verification(clEnqueueUnmapMemObject(command_waiting_line, // memoryObjects[1], // inputB, 0, NULL, NULL))) { // cleanUpOpenCL(context, command_waiting_line, program, kernel, // memoryObjects, // numberOfMemoryObjects); // cerr << "Unmapping memory objects failed " << __FILE__ << ":" << __LINE__ // << endl; // return 1; //} /* [Un-map the buffers] */ /* [Set the kernel arguments] */ int setKernelArgumentsSuccess = TRUE; printf("arg0\n"); setKernelArgumentsSuccess &= success_verification(clSetKernelArg( kernel, 0, sizeof(uint8_t), (uint8_t *)&activity_atom_size)); printf("arg1\n"); setKernelArgumentsSuccess &= success_verification( clSetKernelArg(kernel, 1, sizeof(cl_mem), &memoryObjects[0])); printf("arg2\n"); setKernelArgumentsSuccess &= success_verification( clSetKernelArg(kernel, 2, sizeof(uint16_t), (uint16_t *)&program_size)); printf("arg3\n"); setKernelArgumentsSuccess &= success_verification( clSetKernelArg(kernel, 3, sizeof(uint8_t), (uint8_t *)&population_size)); printf("arg4\n"); setKernelArgumentsSuccess &= success_verification( clSetKernelArg(kernel, 4, sizeof(uint64_t), (uint64_t *)&random_seed)); printf("arg5\n"); setKernelArgumentsSuccess &= success_verification(clSetKernelArg(kernel, 5, sizeof(uint64_t *), NULL)); printf("arg6\n"); setKernelArgumentsSuccess &= success_verification( clSetKernelArg(kernel, 6, sizeof(cl_mem), &memoryObjects[1])); printf("arg7\n"); setKernelArgumentsSuccess &= success_verification(clSetKernelArg(kernel, 7, sizeof(uint8_t *), NULL)); printf("arg8\n"); setKernelArgumentsSuccess &= success_verification( clSetKernelArg(kernel, 8, sizeof(cl_mem), &memoryObjects[2])); if (!setKernelArgumentsSuccess) { // cleanUpOpenCL(context, command_waiting_line, program, kernel, // memoryObjects, // numberOfMemoryObjects); fprintf(stderr, "Failed setting OpenCL kernel arguments. %s:%d\n", __FILE__, __LINE__); return 1; } /* [Set the kernel arguments] */ /* An event to associate with the Kernel. Allows us to retrieve profiling * information later. */ cl_event event = 0; /* [Global work size] */ /* * Each instance of our OpenCL kernel operates on a single element of each * array so the number of * instances needed is the number of elements in the array. */ size_t globalWorksize[1] = {population_size}; size_t localWorksize[1] = {2}; /* Enqueue the kernel */ if (!success_verification(clEnqueueNDRangeKernel( command_waiting_line, kernel, 1, NULL, globalWorksize, localWorksize, 0, NULL, &event))) { // cleanUpOpenCL(context, command_waiting_line, program, kernel, // memoryObjects, // numberOfMemoryObjects); fprintf(stderr, "Failed enqueuing the kernel. %s:%d\n", __FILE__, __LINE__); return 1; } /* [Global work size] */ /* Wait for kernel execution completion. */ if (!success_verification(clFinish(command_waiting_line))) { // cleanUpOpenCL(context, command_waiting_line, program, kernel, // memoryObjects, // numberOfMemoryObjects); fprintf(stderr, "Failed waiting for kernel execution to finish. %s:%d\n", __FILE__, __LINE__); return 1; } /* Print the profiling information for the event. */ // printProfilingInfo(event); /* Release the event object. */ if (!success_verification(clReleaseEvent(event))) { // cleanUpOpenCL(context, command_waiting_line, program, kernel, // memoryObjects, // numberOfMemoryObjects); fprintf(stderr, "Failed releasing the event object. %s:%d\n", __FILE__, __LINE__); return 1; } /* Get a pointer to the output data. */ printf("clOut\n"); v16us *output = (v16us *)clEnqueueMapBuffer( command_waiting_line, memoryObjects[1], CL_TRUE, CL_MAP_READ, 0, population_byte_size, 0, NULL, NULL, &errorNumber); v16us *newspaper = (v16us *)clEnqueueMapBuffer( command_waiting_line, memoryObjects[2], CL_TRUE, CL_MAP_READ, 0, newspaper_byte_size, 0, NULL, NULL, &errorNumber); if (!success_verification(errorNumber)) { // cleanUpOpenCL(context, command_waiting_line, program, kernel, // memoryObjects, // numberOfMemoryObjects); fprintf(stderr, "Failed to map buffer. %s:%d\n", __FILE__, __LINE__); return 1; } /* [Output the results] */ /* Uncomment the following block to print results. */ for (tablet_indexFinger = 0; tablet_indexFinger < (population_size * TABLET_LONG); ++tablet_indexFinger) { if (tablet_indexFinger % 0x10 == 0) printf("\n"); printf("%04X ", (uint)((uint16_t *)output)[tablet_indexFinger]); } printf("\n"); // printf("program %04X \n", (uint)*((uint16_t *)&(output[1]))); printf("newspaper \n"); for (tablet_indexFinger = 0; tablet_indexFinger < (NEWSPAPER_LONG * TABLET_LONG); ++tablet_indexFinger) { if (tablet_indexFinger % 0x10 == 0) printf("\n"); printf("%04X ", (uint)((uint16_t *)newspaper)[tablet_indexFinger]); } printf("\n"); /* [Output the results] */ /* Unmap the memory object as we are finished using them from the CPU side. */ if (!success_verification(clEnqueueUnmapMemObject( command_waiting_line, memoryObjects[1], output, 0, NULL, NULL))) { printf("unmapping\n"); // cleanUpOpenCL(context, command_waiting_line, program, kernel, // memoryObjects, // numberOfMemoryObjects); fprintf(stderr, "Unmapping memory objects failed %s:%d\n", __FILE__, __LINE__); return 1; } if (!success_verification(clEnqueueUnmapMemObject( command_waiting_line, memoryObjects[2], newspaper, 0, NULL, NULL))) { printf("unmapping\n"); // cleanUpOpenCL(context, command_waiting_line, program, kernel, // memoryObjects, // numberOfMemoryObjects); fprintf(stderr, "Unmapping memory objects failed %s:%d\n", __FILE__, __LINE__); return 1; } printf("releasing\n"); /* Release OpenCL objects. */ // cleanUpOpenCL(context, command_waiting_line, program, kernel, // memoryObjects, // numberOfMemoryObjects); }