void CS_OutputPrologue (const CodeSeg* S) /* If the given code segment is a code segment for a function, output the * assembler prologue into the file. That is: Output a comment header, switch * to the correct segment and enter the local function scope. If the code * segment is global, do nothing. */ { /* Get the function associated with the code segment */ SymEntry* Func = S->Func; /* If the code segment is associated with a function, print a function * header and enter a local scope. Be sure to switch to the correct * segment before outputing the function label. */ if (Func) { /* Get the function descriptor */ CS_PrintFunctionHeader (S); WriteOutput (".segment\t\"%s\"\n\n.proc\t_%s", S->SegName, Func->Name); if (IsQualNear (Func->Type)) { WriteOutput (": near"); } else if (IsQualFar (Func->Type)) { WriteOutput (": far"); } WriteOutput ("\n\n"); } }
/*------------------------------------------------------------------------------ ------------------------------------------------------------------------------*/ void CropWriteOutput(FILE *foutput, u8 *imageData, u32 cropDisplay, H264SwDecInfo *decInfo) { u8 *tmpImage = NULL; u32 tmp, picSize; if (cropDisplay && decInfo->croppingFlag) { picSize = decInfo->cropParams.cropOutWidth * decInfo->cropParams.cropOutHeight; picSize = (3 * picSize)/2; tmpImage = malloc(picSize); if (tmpImage == NULL) exit(1); tmp = CropPicture(tmpImage, imageData, decInfo->picWidth, decInfo->picHeight, &(decInfo->cropParams)); if (tmp) exit(1); WriteOutput(foutput, tmpImage, picSize); free(tmpImage); } else { picSize = decInfo->picWidth * decInfo->picHeight; picSize = (3 * picSize)/2; WriteOutput(foutput, imageData, picSize); } }
void WriteFullProcMLP::Loop() { std::cout << "Loop varSet = " << varSet << std::endl; addVariables(); FillMLP(varSet); WriteHeader(); WriteInput(); WriteCategory(); WriteCount("var1", "input", "trackSip2dSig"); //********Chunk for Combined BvsDUSG and BvsC starts*********** WriteNormalize(); WriteSplitters(); if (writeSplittersForNonMultiple) WriteSplittersForNonMultiple(); WriteLRx(); WriteLRall(); WriteLRsplit(); WriteOptional(); if (writeMatrices) {WriteMatrices(); WriteOutput("input", "jetPt"); return;} WriteProcMLP(mlp); WriteBiasNorm(procBiasNorm+tagVtx, "var1", procMLP+tagVtx, "var1"); WriteLRBias(procLike+tagVtx, "var1", procBiasNorm+tagVtx, "var1"); //********Chunk for Combined BvsDUSG and BvsC starts*********** if (Flavour != "Combined") { WriteOutput(procLike+tagVtx, "var1"); return; } tagVtx = "C"; //Need to reset Vector for ProcOptional Oprocess.clear(); Oid.clear(); //Need to reset mlp with the corresponding variables with C instead of "DUSG" tag FillMLP(varSet); //For combined xml, copy previuos structure from WriteNormalize to WriteLRBias // then add ProcLinear and output //**************Insert here Chunk for Combined: begin************** WriteNormalize(); WriteSplitters(); if (writeSplittersForNonMultiple) WriteSplittersForNonMultiple(); WriteLRx(); WriteLRall(); WriteLRsplit(); WriteOptional(); if (writeMatrices) {WriteMatrices(); WriteOutput("input", "jetPt"); return;} WriteProcMLP(mlp); WriteBiasNorm(procBiasNorm+tagVtx, "var1", procMLP+tagVtx, "var1"); WriteLRBias(procLike+tagVtx, "var1", procBiasNorm+tagVtx, "var1"); //**************Insert here Chunk for Combined: end**************** WriteLinear(); WriteOutput(procLinear, "var1"); }
tbool CVorbisEncoder::Finalize_Descendant() { if (miOutputSamplesTotal > 0) { // Actually done any processing? // Tell the library we're at end of stream so that it can handle // the last frame and mark end of stream in the output properly vorbis_analysis_wrote(&vd,0); while(vorbis_analysis_blockout(&vd,&vb)==1){ /* analysis, assume we want to use bitrate management */ vorbis_analysis(&vb,NULL); vorbis_bitrate_addblock(&vb); while(vorbis_bitrate_flushpacket(&vd,&op)){ /* weld the packet into the bitstream */ ogg_stream_packetin(&os,&op); /* write out pages (if any) */ tbool bEOS = false; while(!bEOS){ int result=ogg_stream_pageout(&os,&og); if(result==0)break; //fwrite(og.header,1,og.header_len,stdout); //fwrite(og.body,1,og.body_len,stdout); WriteOutput((char*)og.header, og.header_len); WriteOutput((char*)og.body, og.body_len); /* this could be set above, but for illustrative purposes, I do it here (to show that vorbis does know where the stream ends) */ if(ogg_page_eos(&og))bEOS=1; } } } /* clean up and exit. vorbis_info_clear() must be called last */ ogg_stream_clear(&os); vorbis_block_clear(&vb); vorbis_dsp_clear(&vd); vorbis_comment_clear(&vc); vorbis_info_clear(&vi); /* ogg_page and ogg_packet structs always point to storage in libvorbis. They're never freed or manipulated directly */ } tfloat fSecs = ((tfloat)miOutputSamplesTotal) / miOutputSampleFreq; tfloat fKbps = muiBytesTotalOutput * 8.0f / (fSecs * 1000); std::cout << "Done (wrote " << muiBytesTotalOutput << " bytes, " << fSecs << " secs, avg rate " << fKbps << " kbps)\n\n"; return true; }
static void CS_PrintFunctionHeader (const CodeSeg* S) /* Print a comment with the function signature to the output file */ { /* Get the associated function */ const SymEntry* Func = S->Func; /* If this is a global code segment, do nothing */ if (Func) { WriteOutput ("; ---------------------------------------------------------------\n" "; "); PrintFuncSig (OutputFile, Func->Name, Func->Type); WriteOutput ("\n" "; ---------------------------------------------------------------\n" "\n"); } }
void RunWorkload() { // Execute the workload to build the log std::vector<std::thread> thread_group; oid_t num_threads = state.backend_count; double max_duration = std::numeric_limits<double>::min(); durations.reserve(num_threads); // Launch a group of threads for (oid_t thread_itr = 0; thread_itr < num_threads; ++thread_itr) { thread_group.push_back(std::thread(RunBackend, thread_itr)); } // Join the threads with the main thread for (oid_t thread_itr = 0; thread_itr < num_threads; ++thread_itr) { thread_group[thread_itr].join(); } // Compute max duration for (oid_t thread_itr = 0; thread_itr < num_threads; ++thread_itr) { max_duration = std::max(max_duration, durations[thread_itr]); } double throughput = (state.transaction_count * num_threads)/max_duration; WriteOutput(throughput); }
void CDevice::Process() { if (m_output.empty()) Log("%s: starting", m_name.c_str()); else Log("%s: starting with output \"%s\"", m_name.c_str(), m_output.c_str()); if (m_setpriority) { sched_param param = {}; param.sched_priority = m_threadpriority; int returnv = pthread_setschedparam(m_thread, SCHED_FIFO, ¶m); if (returnv == 0) Log("%s: successfully set thread priority to %i", m_name.c_str(), m_threadpriority); else LogError("%s: error setting thread priority to %i: %s", m_name.c_str(), m_threadpriority, GetErrno(returnv).c_str()); } int64_t setuptime; while(!m_stop) { //keep trying to set up the device every 10 seconds while(!m_stop) { Log("%s: setting up", m_name.c_str()); setuptime = GetTimeUs(); if (!SetupDevice()) { CloseDevice(); LogError("%s: setting up failed, retrying in 10 seconds", m_name.c_str()); USleep(10000000LL, &m_stop); } else { Log("%s: setup succeeded", m_name.c_str()); break; } } //keep calling writeoutput until we're asked to stop or writeoutput fails while(!m_stop) { if (!WriteOutput()) { //make sure to wait at least one second before trying to set up again Log("%s: io operation failed, retry to setup", m_name.c_str()); USleep(Max(1000000LL - (GetTimeUs() - setuptime), 0)); break; } } CloseDevice(); Log("%s: closed", m_name.c_str()); } Log("%s: stopped", m_name.c_str()); }
/** * @brief recover the database and check the tuples */ void DoRecovery() { //===--------------------------------------------------------------------===// // RECOVERY //===--------------------------------------------------------------------===// // Reset log manager state auto& log_manager = peloton::logging::LogManager::GetInstance(); log_manager.ResetLogStatus(); log_manager.ResetFrontendLoggers(); Timer<std::milli> timer; std::thread thread; timer.Start(); // Do recovery StartLogging(thread); // Synchronize and finish recovery if (log_manager.EndLogging()) { thread.join(); } else { LOG_ERROR("Failed to terminate logging thread"); } timer.Stop(); // Recovery time (in ms) if (state.experiment_type == EXPERIMENT_TYPE_RECOVERY) { WriteOutput(timer.GetDuration()); } }
bool ReadContactAndWrite(char *hash) { __xdata static char txcontac[512]; if (!GetTxContacts((const unsigned char * const )hash, (void* const ) &txcontac, 512)) { LogPrint("GetTxContacts error",sizeof("GetTxContacts error"),STRING); return false; } if(!DeleteData((const unsigned char * const )hash,32)) { LogPrint("DeleteDataDB error",sizeof("DeleteDataDB error"),STRING); return false; } CONTRACT* pContract = (CONTRACT*)txcontac; VM_OPERATE ret; char accountid[6] = {0}; if(GetScriptID(&accountid)) { ret.type =REG_ID; ret.opeatortype = MINUS_FREE; memcpy(ret.accountid,&accountid,sizeof(ret.accountid)); memcpy(&ret.money,&pContract->nPayMoney,sizeof(Int64)); LogPrint(&accountid,32,HEX); WriteOutput(&ret,1); } char *strContace = pContract->buffer; unsigned short len = pContract->len; while(len) { ACCOUNT_INFO accountinfo; memcpy(&accountinfo,strContace,sizeof(ACCOUNT_INFO)); memcpy(ret.accountid,&accountinfo.account,sizeof(ret.accountid)); memcpy(&ret.money,&accountinfo.nReciMoney,sizeof(Int64)); ret.opeatortype = ADD_FREE; len -= sizeof(ACCOUNT_INFO); // LogPrint(&accountinfo.account,32,HEX); WriteOutput(&ret,1); strContace = strContace +sizeof(ACCOUNT_INFO); } return true; }
void CS_OutputEpilogue (const CodeSeg* S) /* If the given code segment is a code segment for a function, output the * assembler epilogue into the file. That is: Close the local function scope. */ { if (S->Func) { WriteOutput ("\n.endproc\n\n"); } }
static void WriteDebugOutput (CodeSeg* S, const char* Step) /* Write a separator line into the debug file if the flag is on */ { if (DebugOptOutput) { /* Output a separator */ WriteOutput ("=========================================================================\n"); /* Output a header line */ if (Step == 0) { /* Initial output */ WriteOutput ("Initial code for function `%s':\n", S->Func? S->Func->Name : "<global>"); } else { WriteOutput ("Code after applying `%s':\n", Step); } /* Output the code segment */ CS_Output (S); } }
void GetOutput(NET* Net, INT* Output, BOOL Protocoling) { INT i; for (i=1; i<=Net->OutputLayer->Units; i++) { Output[i-1] = Net->OutputLayer->Output[i]; } if (Protocoling) { WriteOutput(Net, Output); } }
// Main Entry Point void RunBenchmark() { // Create and load the user table CreateYCSBDatabase(); LoadYCSBDatabase(); // Run the workload RunWorkload(); WriteOutput(); }
/* Между вызовами Write и между итерациями цикла внутри Write поддерживается следующий инвариант. Входной буфер - может содержать данные next_in - начало входного буфера avail_in - размер этих данных Выходной буфер - всегда пустой next_out - начало выходного буфера avail_out - размер выходного буфера */ void DeflateStream::Write(const void* data, size_t size) { try { //если финализация уже была выполнена, то записывать данные нельзя if(finalized) THROW("Stream already finalized"); //запомнить параметры буферов Bytef* inputBuffer = zstream.next_in; Bytef* outputBuffer = zstream.next_out; unsigned outputSize = zstream.avail_out; //пока есть данные while(size) { //приписать данные к концу входного буфера unsigned toRead = (unsigned)std::min<size_t>(size, inputBufferSize - zstream.avail_in); memcpy(zstream.next_in + zstream.avail_in, data, toRead); zstream.avail_in += toRead; data = (char*)data + toRead; size -= toRead; //если входной буфер переполнен if(zstream.avail_in >= inputBufferSize) { //выполнить сжатие данных switch(deflate(&zstream, Z_NO_FLUSH)) { case Z_OK: case Z_BUF_ERROR: break; default: THROW("Compression error"); } //записать данные в выходной поток WriteOutput(outputBuffer, outputSize - zstream.avail_out); //перенести данные, которые остались во входном буфере, в его начало memmove(inputBuffer, zstream.next_in, zstream.avail_in); zstream.next_in = inputBuffer; //очистить выходной буфер zstream.next_out = outputBuffer; zstream.avail_out = outputSize; } } } catch(Exception* exception) { THROW_SECONDARY("Can't compress data", exception); } }
// Main Entry Point void RunBenchmark() { // Create the database CreateTPCCDatabase(); // Load the database LoadTPCCDatabase(); // Run the workload RunWorkload(); // Emit throughput WriteOutput(state.throughput); }
/* Во время и после Flush указанный для Write инвариант не выполняется. */ void DeflateStream::Flush() { try { //если финализация уже была выполнена, закончить if(finalized) return; //запомнить параметры выходного буфера Bytef* outputBuffer = zstream.next_out; unsigned outputSize = zstream.avail_out; //цикл, пока компрессия не завершена for(;;) { //выполнять компрессию int result = deflate(&zstream, Z_FINISH); //обработка ошибок switch(result) { case Z_STREAM_END: case Z_OK: break; default: THROW("Compression error"); } //записать вывод в поток WriteOutput(outputBuffer, outputSize - zstream.avail_out); //очистить выходной буфер zstream.next_out = outputBuffer; zstream.avail_out = outputSize; //если это конец, закончить if(result == Z_STREAM_END) break; } //завершить сжатие if(deflateEnd(&zstream) != Z_OK) THROW("Finalize stream error"); //установить флажок завершенности finalized = true; } catch(Exception* exception) { THROW_SECONDARY("Can't finalize compression", exception); } }
// // Main Routine // int main(int argc, const char *argv[]) { if(argc < 4) FatalError("Usage: qbin2c <infile> <outfile> <symbol>"); // read input file ReadInput(argv[1]); // write output file WriteOutput(argv[1], argv[2], argv[3]); printf("%s written successfully.\n", argv[2]); return 0; }
void CDevice::Process() { if (m_output.empty()) Log("%s: starting", m_name.c_str()); else Log("%s: starting with output \"%s\"", m_name.c_str(), m_output.c_str()); int64_t setuptime; while(!m_stop) { //keep trying to set up the device every 10 seconds while(!m_stop) { Log("%s: setting up", m_name.c_str()); setuptime = GetTimeUs(); if (!SetupDevice()) { CloseDevice(); LogError("%s: setting up failed, retrying in 10 seconds", m_name.c_str()); USleep(10000000LL, &m_stop); } else { Log("%s: setup succeeded", m_name.c_str()); break; } } //keep calling writeoutput until we're asked to stop or writeoutput fails while(!m_stop) { if (!WriteOutput()) { //make sure to wait at least one second before trying to set up again USleep(Max(1000000LL - (GetTimeUs() - setuptime), 0)); break; } } CloseDevice(); Log("%s: closed", m_name.c_str()); } Log("%s: stopped", m_name.c_str()); }
int main(int argc, char* argv[]) { TStr InFile,OutFile; int Dimensions, WalkLen, NumWalks, WinSize, Iter; double ParamP, ParamQ; bool Directed, Weighted, Verbose, OutputWalks; ParseArgs(argc, argv, InFile, OutFile, Dimensions, WalkLen, NumWalks, WinSize, Iter, Verbose, ParamP, ParamQ, Directed, Weighted, OutputWalks); PWNet InNet = PWNet::New(); TIntFltVH EmbeddingsHV; TVVec <TInt, int64> WalksVV; ReadGraph(InFile, Directed, Weighted, Verbose, InNet); node2vec(InNet, ParamP, ParamQ, Dimensions, WalkLen, NumWalks, WinSize, Iter, Verbose, OutputWalks, WalksVV, EmbeddingsHV); WriteOutput(OutFile, EmbeddingsHV, WalksVV, OutputWalks); return 0; }
static void writeconsole_2 (const TCHAR *buffer) { DWORD temp; if (!consoleopen) openconsole (); if (consoleopen > 0) { WriteOutput (buffer, _tcslen (buffer)); } else if (realconsole) { fputws (buffer, stdout); fflush (stdout); } else if (consoleopen < 0) { WriteConsole (stdoutput, buffer, _tcslen (buffer), &temp, 0); } }
void Console::keyReleaseEvent(QKeyEvent* e) { QString key = e->text(); if (key != "") { inputBuffer.append(key); if (!mapped_io) { WriteOutput(key); // Do not echo input when using mem mapped IO } // Release the call on ReadChar (if any) that is blocked waiting for input. // l->exit(); } }
void Solve( const ImageFloat& inputImage, const Mask& mask, ImageFloat& outputImage, const BVarInitializer& bVarInitializer, int translateSolutionX, int translateSolutionY) { // Build mapping from each unknown pixel's row major index to its // "unknown" index. UnknownVars unknownVars(inputImage.GetWidth(), inputImage.GetHeight(), mask); if (unknownVars.GetNum() > 0) { // Solve Au = b for all 3 channels at once AAndBVars aAndBVars(inputImage, mask, bVarInitializer, unknownVars); unknownVars.Solve(aAndBVars); WriteOutput(unknownVars, mask, outputImage, translateSolutionX, translateSolutionY); } }
int CTorrentBuilder::Run() { if ( m_pSection.Lock() ) { m_nTotalSize = 0; m_nTotalPos = 0; m_pFileSize = NULL; m_pFileSHA1 = NULL; m_pFileED2K = NULL; m_pFileMD5 = NULL; m_pPieceSHA1 = NULL; m_pSection.Unlock(); } if ( ScanFiles() && ! m_bAbort ) { if ( ProcessFiles() && WriteOutput() ) m_bFinished = TRUE; } if ( m_pSection.Lock() ) { delete [] m_pPieceSHA1; m_pPieceSHA1 = NULL; delete [] m_pFileMD5; m_pFileMD5 = NULL; delete [] m_pFileED2K; m_pFileED2K = NULL; delete [] m_pFileSHA1; m_pFileSHA1 = NULL; delete [] m_pFileSize; m_pFileSize = NULL; m_sThisFile.Empty(); m_bActive = FALSE; m_pSection.Unlock(); } return 0; }
//================================================ void DriverFSU15_C() { BYTE i; __DI(); i=ADDR; Fsu15.Info.bits.Addr =i; if(i!=ADDR_NODE) { setState(Initialisation); ADDR_NODE =ADDR; } Fsu15.Info.bits.Mode=MODE; Fsu15.Info.bits.F1=PG_F1; #ifdef PLATA_FSU15 Fsu15.Info.bits.F2=PG_F2; #endif WriteOutput(); ReadTest(); __EI(); }
// Main Entry Point void RunBenchmark() { if (state.gc_mode == true) { gc::GCManagerFactory::Configure(state.gc_backend_count); } gc::GCManagerFactory::GetInstance().StartGC(); // Create the database CreateTPCCDatabase(); // Load the database LoadTPCCDatabase(); // Run the workload RunWorkload(); gc::GCManagerFactory::GetInstance().StopGC(); // Emit throughput WriteOutput(); }
int main(int argc, char* argv[]) { if (argc == 3) { UIDBands* bandtable; MyString bandnames[32]; int nobands; nobands = GetBandNames(bandnames,argv[1]); if (nobands) { bandtable = new UIDBands[nobands]; if (bandtable) { PullBandInfo(bandnames,nobands,bandtable); WriteOutput(bandtable,nobands,argv[2]); delete []bandtable; } } } return 0; }
OMX_ERRORTYPE OmxDecTestBase::FillBufferDone(OMX_OUT OMX_HANDLETYPE aComponent, OMX_OUT OMX_PTR aAppData, OMX_OUT OMX_BUFFERHEADERTYPE* aBuffer) { OSCL_UNUSED_ARG(aComponent); OSCL_UNUSED_ARG(aAppData); PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxDecTestBase::FillBufferDone() - IN")); //Check the validity of buffer if (NULL == aBuffer || OMX_DirOutput != aBuffer->nOutputPortIndex) { PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "OmxDecTestBase::FillBufferDone() - ERROR, Invalid buffer found in callback, OUT")); iState = StateError; RunIfNotReady(); return OMX_ErrorBadParameter; } OMX_U8* pOutputBuffer; OMX_U32 ii = 0; pOutputBuffer = (OMX_U8*)(aBuffer->pBuffer); //Output buffer has been freed by component & can now be passed again in FillThisBuffer call if (NULL != aBuffer) { if (0 != aBuffer->nFilledLen) { if (WriteOutput(pOutputBuffer, aBuffer->nFilledLen)) { /* Clear the output buffer after writing to file, * so that there is no chance of getting it written again while flushing port */ aBuffer->nFilledLen = 0; PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxDecTestBase::FillBufferDone() - Frame %i processed Timestamp %d", iFramesWritten, aBuffer->nTimeStamp)); iFramesWritten++; } else { PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "OmxDecTestBase::FillBufferDone() - ERROR, Failed to write output to file")); } } } while (((OMX_U32) ipOutBuffer[ii] != (OMX_U32) aBuffer) && (ii < iOutBufferCount)) { ii++; } if (iOutBufferCount != ii) { //If the buffer is already returned and then a callback comes for same buffer //report an error and stop if (OMX_TRUE == ipOutReleased[ii]) { PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "OmxDecTestBase::FillBufferDone() - ERROR, Same bufer with index %d returned twice", ii)); iState = StateError; RunIfNotReady(); } ipOutReleased[ii] = OMX_TRUE; PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "OmxDecTestBase::FillBufferDone() - Output buffer with index %d marked free", ii)); } else { PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "OmxDecTestBase::FillBufferDone() - ERROR, Invalid buffer found in callback, cannot mark it free")); iState = StateError; RunIfNotReady(); } //To simulate output busy condition iCount++; if (0 == (iCount % 5)) { iStopOutput = OMX_TRUE; } if (0 >= iPendingCommands) { RunIfNotReady(); } PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "OmxDecTestBase::FillBufferDone() - OUT")); return OMX_ErrorNone; }
VAttrList VNCM(VAttrList list,VImage mask,VShort minval,VShort first,VShort length,VFloat threshold) { VAttrList out_list=NULL; VAttrListPosn posn; VImage src[NSLICES],map=NULL; VImage dest=NULL; size_t b,r,c,i,j,i1,n,m,nt,last,ntimesteps,nrows,ncols,nslices; gsl_matrix_float *mat=NULL; float *A=NULL,*ev=NULL; /* ** get image dimensions */ i = ntimesteps = nrows = ncols = 0; for (VFirstAttr (list, & posn); VAttrExists (& posn); VNextAttr (& posn)) { if (VGetAttrRepn (& posn) != VImageRepn) continue; VGetAttrValue (& posn, NULL,VImageRepn, & src[i]); if (VPixelRepn(src[i]) != VShortRepn) continue; if (VImageNBands(src[i]) > ntimesteps) ntimesteps = VImageNBands(src[i]); if (VImageNRows(src[i]) > nrows) nrows = VImageNRows(src[i]); if (VImageNColumns(src[i]) > ncols) ncols = VImageNColumns(src[i]); i++; if (i >= NSLICES) VError(" too many slices"); } nslices = i; /* get time steps to include */ if (length < 1) length = ntimesteps-2; last = first + length -1; if (last >= ntimesteps) last = ntimesteps-1; if (first < 0) first = 1; nt = last - first + 1; i1 = first+1; if (nt < 2) VError(" not enough timesteps, nt= %d",nt); fprintf(stderr,"# ntimesteps: %d, first= %d, last= %d, nt= %d\n", (int)ntimesteps,(int)first,(int)last,(int)nt); /* count number of voxels */ n = 0; for (b=0; b<nslices; b++) { if (VImageNRows(src[b]) < 2) continue; for (r=0; r<nrows; r++) { for (c=0; c<ncols; c++) { if (VPixel(src[b],i1,r,c,VShort) < minval) continue; if (VGetPixel(mask,b,r,c) < 0.5) continue; n++; } } } fprintf(stderr," nvoxels: %ld\n",(long)n); /* ** voxel addresses */ map = VCreateImage(1,5,n,VFloatRepn); if (map == NULL) VError(" error allocating addr map"); VFillImage(map,VAllBands,0); VPixel(map,0,3,0,VFloat) = nslices; VPixel(map,0,3,1,VFloat) = nrows; VPixel(map,0,3,2,VFloat) = ncols; i = 0; for (b=0; b<nslices; b++) { if (VImageNRows(src[b]) < 2) continue; for (r=0; r<nrows; r++) { for (c=0; c<ncols; c++) { if (VPixel(src[b],i1,r,c,VShort) < minval) continue; if (VGetPixel(mask,b,r,c) < 0.5) continue; VPixel(map,0,0,i,VFloat) = b; VPixel(map,0,1,i,VFloat) = r; VPixel(map,0,2,i,VFloat) = c; i++; } } } /* ** avoid casting to float, copy data to matrix */ mat = gsl_matrix_float_calloc(n,nt); for (i=0; i<n; i++) { b = VPixel(map,0,0,i,VFloat); r = VPixel(map,0,1,i,VFloat); c = VPixel(map,0,2,i,VFloat); float *ptr = gsl_matrix_float_ptr(mat,i,0); int k; j = 0; for (k=first; k<=last; k++) { if (j >= mat->size2) VError(" j= %d %d",j,mat->size2); if (k >= VImageNBands(src[b])) VError(" k= %d %d",k, VImageNBands(src[b])); *ptr++ = (float) VPixel(src[b],k,r,c,VShort); j++; } } /* ** compute similarity matrix */ m = (n*(n+1))/2; fprintf(stderr," matrix computation, n= %ld...\n",(long)n); A = (float *) calloc(m,sizeof(float)); if (!A) VError(" err allocating correlation matrix"); memset(A,0,m*sizeof(float)); size_t progress=0; #pragma omp parallel for shared(progress) private(j) schedule(guided) firstprivate(mat,A) for (i=0; i<n; i++) { if (i%100 == 0) fprintf(stderr," %d00\r",(int)(++progress)); const float *arr1 = gsl_matrix_float_const_ptr(mat,i,0); for (j=0; j<i; j++) { const float *arr2 = gsl_matrix_float_const_ptr(mat,j,0); const double v = Correlation(arr1,arr2,nt); const size_t k=j+i*(i+1)/2; if (k >= m) VError(" illegal addr k= %d, m= %d",k,m); A[k] = (float)v; } } fprintf(stderr," matrix done.\n"); gsl_matrix_float_free(mat); /* ** eigenvector centrality */ ev = (float *) VCalloc(n,sizeof(float)); DegreeCentrality(A,ev,n,threshold); dest = WriteOutput(src[0],map,nslices,nrows,ncols,ev,n); VSetAttr(VImageAttrList(dest),"name",NULL,VStringRepn,"DegreeCM"); out_list = VCreateAttrList(); VAppendAttr(out_list,"image",NULL,VImageRepn,dest); return out_list; }
/** * @brief writing a simple log file */ bool PrepareLogFile() { // Clean up log directory CleanUpLogDirectory(); // start a thread for logging auto& log_manager = logging::LogManager::GetInstance(); log_manager.SetLogDirectoryName(state.log_file_dir); log_manager.SetLogFileName(state.log_file_dir + "/" + logging::WriteBehindFrontendLogger::wbl_log_path); if (log_manager.ContainsFrontendLogger() == true) { LOG_ERROR("another logging thread is running now"); return false; } // Get an instance of the storage manager to force posix_fallocate // to be invoked before we begin benchmarking auto& storage_manager = storage::StorageManager::GetInstance(); auto tmp = storage_manager.Allocate(BACKEND_TYPE_MM, 1024); storage_manager.Release(BACKEND_TYPE_MM, tmp); // Pick sync commit mode switch (state.asynchronous_mode) { case ASYNCHRONOUS_TYPE_SYNC: log_manager.SetSyncCommit(true); break; case ASYNCHRONOUS_TYPE_ASYNC: case ASYNCHRONOUS_TYPE_DISABLED: log_manager.SetSyncCommit(false); break; case ASYNCHRONOUS_TYPE_INVALID: throw Exception("Invalid asynchronous mode : " + std::to_string(state.asynchronous_mode)); } Timer<> timer; std::thread thread; // Initializing logging module StartLogging(thread); timer.Start(); // Build the log BuildLog(); // Stop frontend logger if in a valid logging mode if (peloton_logging_mode != LOGGING_TYPE_INVALID) { // Wait for the mode transition :: LOGGING -> TERMINATE -> SLEEP if (log_manager.EndLogging()) { thread.join(); } } timer.Stop(); // Pick metrics based on benchmark type double throughput = 0; double latency = 0; if (state.benchmark_type == BENCHMARK_TYPE_YCSB) { throughput = ycsb::state.throughput; latency = ycsb::state.latency; } else if (state.benchmark_type == BENCHMARK_TYPE_TPCC) { throughput = tpcc::state.throughput; latency = tpcc::state.latency; } // Log the build log time if (state.experiment_type == EXPERIMENT_TYPE_THROUGHPUT) { WriteOutput(throughput); } else if (state.experiment_type == EXPERIMENT_TYPE_LATENCY) { WriteOutput(latency); } return true; }
void Run(const Vector<String>& arguments) { if (arguments.Size() < 2) { ErrorExit( "Usage: OgreImporter <input file> <output file> [options]\n\n" "Options:\n" "-l Output a material list file\n" "-na Do not output animations\n" "-nm Do not output morphs\n" "-r Output only rotations from animations\n" "-s Split each submesh into own vertex buffer\n" "-t Generate tangents\n" "-mb <x> Maximum number of bones per submesh, default 64\n" ); } bool generateTangents = false; bool splitSubMeshes = false; bool exportAnimations = true; bool exportMorphs = true; bool rotationsOnly = false; bool saveMaterialList = false; if (arguments.Size() > 2) { for (unsigned i = 2; i < arguments.Size(); ++i) { if (arguments[i].Length() > 1 && arguments[i][0] == '-') { String argument = arguments[i].Substring(1).ToLower(); if (argument == "l") saveMaterialList = true; else if (argument == "r") rotationsOnly = true; else if (argument == "s") splitSubMeshes = true; else if (argument == "t") generateTangents = true; else if (argument.Length() == 2 && argument[0] == 'n') { switch (tolower(argument[1])) { case 'a': exportAnimations = false; break; case 'm': exportMorphs = false; break; } break; } else if (argument == "mb" && i < arguments.Size() - 1) { maxBones_ = ToUInt(arguments[i + 1]); if (maxBones_ < 1) maxBones_ = 1; ++i; } } } } LoadMesh(arguments[0], generateTangents, splitSubMeshes, exportMorphs); WriteOutput(arguments[1], exportAnimations, rotationsOnly, saveMaterialList); PrintLine("Finished"); }