// ************************************************************************** // This file is property of and copyright by the CBM HLT Project * // CBM Experiment at FAIR, All rights reserved. * // * // * // Primary Authors: Igor Kulakov * // Maksym Zyzak * // Ivan Kisel * // * // Permission to use, copy, modify and distribute this software and its * // documentation strictly for non-commercial purposes is hereby granted * // without fee, provided that the above copyright notice appears in all * // copies and that both the copyright notice and this permission notice * // appear in the supporting documentation. The authors make no claims * // about the suitability of this software for any purpose. It is * // provided "as is" without express or implied warranty. * // * //*************************************************************************** #include #include #include #include #include "pthread.h" using namespace std; //#include "L1AlgoInter.h" #include "TaskManager.h" #include "InputDataArray.h" #include "L1AlgoInputMCData.h" #include "TStopwatch.h" int main(int argc, char **argv) { int iVerbose = 0; int firstEvent = 0; int lastEvent = 0; int StartTime = -1; int nThreads = 1; bool fullTiming = 0; string filePrefix = "./Events/"; for( int i=1; i < argc; i++ ){ if ( !std::strcmp( argv[i], "-h" ) || !std::strcmp( argv[i], "--help" ) || !std::strcmp( argv[i], "-help" ) ) { // usage(argv[0]); return 0; } else if ( !std::strcmp( argv[i], "-perf" ) ) { iVerbose = 1; } else if ( !std::strcmp( argv[i], "-VerboseLevel" ) && ++i < argc ) { iVerbose = atoi( argv[i] ); } else if ( !std::strcmp( argv[i], "-NThreads" ) && ++i < argc ) { nThreads = atoi( argv[i] ); } else if ( !std::strcmp( argv[i], "-time" ) ) { fullTiming = true; } else if ( !std::strcmp( argv[i], "-dir" ) && ++i < argc ) { filePrefix = argv[i]; } else if ( !std::strcmp( argv[i], "-StartTime" ) && ++i < argc ) { StartTime = atoi( argv[i] ); } else if ( !std::strcmp( argv[i], "-ev" ) && ++i < argc ) { firstEvent = atoi( argv[i] ); if (++i < argc){ lastEvent = atoi( argv[i] ); // std::cout << "Only process events " << firstEvent << ",..," << lastEvent << std::endl; } else{ lastEvent = firstEvent; // std::cout << "Only process event " << lastEvent << std::endl; } } else { firstEvent = atoi( argv[i] ); lastEvent = firstEvent; // std::cout << "Only process event " << lastEvent << std::endl; } } // int s; // cpu_set_t cpuset; // int cpuId = 0; // pthread_t thread = pthread_self(); // CPU_ZERO(&cpuset); // CPU_SET(cpuId, &cpuset); // s = pthread_setaffinity_np(thread, sizeof(cpu_set_t), &cpuset); map threadNumberToCpuMap; for(int iProc=0; iProc<4; iProc++) { for(int i=0; i<8; i++){ threadNumberToCpuMap[2*i+0 + iProc*20] = 4*i + iProc; threadNumberToCpuMap[2*i+1 + iProc*20] = 4*i + 32 + iProc; } for(int i=0; i<2; i++){ threadNumberToCpuMap[2*i+0 + 16 + iProc*20] = 4*i + iProc + 64; threadNumberToCpuMap[2*i+1 + 16 + iProc*20] = 4*i + 8 + iProc + 64; } } //lxir039 // for (int i=0; i<8; i++){ // threadNumberToCpuMap[2*i+0] = 15-i; // threadNumberToCpuMap[2*i+1] = 15-(i+8); // } omp_set_num_threads(nThreads); #pragma omp parallel { int s; cpu_set_t cpuset; int cpuId = threadNumberToCpuMap[omp_get_thread_num()]; pthread_t thread = pthread_self(); // CPU_ZERO(&cpuset); // CPU_SET(cpuId, &cpuset); // s = pthread_setaffinity_np(thread, sizeof(cpu_set_t), &cpuset); } vector McDataHit; vector McDataHit2; InputDataArray InputData; //buffer for raw events data InputMCDataArray InputMCData; { std::string LocalfilePrefix = filePrefix; LocalfilePrefix += "/"; const int NEventsToRead = lastEvent+1; InputData.fInput = new L1AlgoInputData[NEventsToRead]; InputData.fSettings = new L1AlgoInputSettings; InputMCData.fMCInput = new L1AlgoInputMCData[NEventsToRead]; if(!InputData.fSettings->ReadSettingsFromFile(LocalfilePrefix.data(), iVerbose)) { std::cout << "Setting can not be read" << std::endl; exit(0); } for ( int kEvents = 0; kEvents <= lastEvent; kEvents++ ) { if (!InputData.fInput[kEvents].ReadHitsFromFile(LocalfilePrefix.data(), NEventsToRead, iVerbose)) { cout << "Hits Data for Event " << kEvents << " can't be read." << std::endl; break; } if(iVerbose>0) { // if (!InputMCData.fMCInput[kEvents].ReadMCDataFromFile(LocalfilePrefix.data(), NEventsToRead, iVerbose, McDataHit, McDataHit2)) { if (!InputMCData.fMCInput[kEvents].ReadMCDataFromFile(LocalfilePrefix.data(), NEventsToRead, iVerbose, McDataHit, McDataHit2)) { cout << "MC Data for Event " << kEvents << " can't be read." << std::endl; break; } } } } TaskManager manager(nThreads); // manager.SetNThreads(nThreads); manager.Init( InputData.fSettings, iVerbose ); for ( int iE = firstEvent; iE <= lastEvent; iE++ ) { cout<0) manager.SetData( &(InputData.fInput[iE]), &(InputMCData.fMCInput[iE]), McDataHit, McDataHit2 ); else manager.SetData( &(InputData.fInput[iE]), 0, McDataHit, McDataHit2 ); // if(iVerbose>0) manager.SetData( &(InputData.fInput[iE]), &(InputMCData.fMCInput[iE]) ); // else manager.SetData( &(InputData.fInput[iE]) ); manager.Run(); } if(iVerbose>0) manager.PrintEff(); return 0; }