// 定义一些有颜色的输出宏 #define RESET "\033[0m" #define BLACK "\033[30m"/* Black */ #define RED "\033[31m"/* Red */ #define GREEN "\033[32m"/* Green */ #define YELLOW "\033[33m"/* Yellow */ #define BLUE "\033[34m"/* Blue */ #define MAGENTA "\033[35m"/* Magenta */ #define CYAN "\033[36m"/* Cyan */ #define WHITE "\033[37m"/* White */ #define GPT "\033[94m"/* gpt-blue */
// or complex usage of preprocessor directives in C++ #if !defined(CC_USED__) || CC_USED_ABI_VERSION != __GXX_ABI_VERSION \ || __GNUC_MINOR__ < CC_USED_MINOR__ \ || __GNUC_MINOR == CC_USED_MINOR__ && __GNUC_PATCHLEVEL__ < CC_USED_PATCH_LEVEL #error This kit requires gcc 3.2.x or 3.3.x with a version >= compiler version of the kit #endif
structAfterReturn { ~AfterReturn() { // This code will run when an AfterReturn object goes out of scope cout << "after return" << endl; } };
intfoo() { AfterReturn guard; // This variable goes out of scope on return cout << "returning..." << endl; return5; // This is when the destructor of "guard" will be executed }
intmain() { cout << foo() << endl; return0; }
//The above program prints returning... after return 5
#7 Object "/home/anaconda3/envs/t00906153_bindCore/lib/python3.8/site-packages/torch/lib/libtorch_cpu.so", at 0xffff792072fb, in torch::autograd::Engine::thread_init(int, std::shared_ptr<torch::autograd::ReadyQueue> const&, bool) #6 Object "/home/anaconda3/envs/t00906153_bindCore/lib/python3.8/site-packages/torch/lib/libtorch_cpu.so", at 0xffff7920f1b3, in torch::autograd::Engine::thread_main(std::shared_ptr<torch::autograd::GraphTask> const&) #5 Object "/home/anaconda3/envs/t00906153_bindCore/lib/python3.8/site-packages/torch/lib/libtorch_cpu.so", at 0xffff79205f7b, in torch::autograd::set_device(int) #4 Object "/home/anaconda3/envs/t00906153_bindCore/lib/python3.8/site-packages/torch_npu/lib/libtorch_npu.so", at 0xffff3785d98f, in #3 Object "/home/anaconda3/envs/t00906153_bindCore/lib/python3.8/site-packages/torch_npu/lib/libtorch_npu.so", at 0xffff3785d723, in #2 Object "/home/anaconda3/envs/t00906153_bindCore/lib/python3.8/site-packages/torch_npu/lib/libtorch_npu.so", at 0xffff3790c9e3, in c10_npu::SetDevice(signed char) #1 Object "/home/anaconda3/envs/t00906153_bindCore/lib/python3.8/site-packages/torch_npu/lib/libtorch_npu.so", at 0xffff378daf47, in #0 Object "/home/anaconda3/envs/t00906153_bindCore/lib/python3.8/site-packages/torch_npu/lib/libtorch_npu.so", at 0xffff37941837, in
修改为debug模式编译。
1 2 3 4 5 6 7 8
#7 Object "/home/anaconda3/envs/t00906153_bindCore/bin/python3.8", at 0x42be83, in function_code_fastcall #6 Object "/home/anaconda3/envs/t00906153_bindCore/bin/python3.8", at 0x433cb7, in _PyEval_EvalFrameDefault #5 Object "/home/anaconda3/envs/t00906153_bindCore/bin/python3.8", at 0x4716bb, in cfunction_vectorcall_NOARGS #4 Object "/home/anaconda3/envs/t00906153_bindCore/lib/python3.8/site-packages/torch_npu/lib/libtorch_npu.so", at 0xfffdc51e6d57, in THNPModule_initExtension(_object*, _object*) #3 Object "/home/anaconda3/envs/t00906153_bindCore/lib/python3.8/site-packages/torch_npu/lib/libtorch_npu.so", at 0xfffdc4788433, in c10_npu::NpuSysCtrl::Initialize(int) #2 Object "/home/anaconda3/envs/t00906153_bindCore/lib/python3.8/site-packages/torch_npu/lib/libtorch_npu.so", at 0xfffdc47592cf, in c10_npu::SetDevice(signed char) #1 Object "/home/anaconda3/envs/t00906153_bindCore/lib/python3.8/site-packages/torch_npu/lib/libtorch_npu.so", at 0xfffdc475810f, in c10_npu::SetThreadAffinity(signed char) #0 Object "/home/anaconda3/envs/t00906153_bindCore/lib/python3.8/site-packages/torch_npu/lib/libtorch_npu.so", at 0xfffdc4757407, in printStack()
------------------------------ #12 Object "/root/Victima/sniper/lib/sniper", at 0x49a938, in TraceThread::run() Source "/root/Victima/sniper/common/trace_frontend/trace_thread.cc", line 921, in run [0x49a938] 918: break; 919: 920: case InstMode::DETAILED: > 921: handleInstructionDetailed(inst, next_inst, prfmdl); 922: break; 923: 924: default: ------------------------------
------------------------------ #11 Object "/root/Victima/sniper/lib/sniper", at 0x498f6d, in TraceThread::handleInstructionDetailed(Sift::Instruction&, Sift::Instruction&, PerformanceModel*) Source "/root/Victima/sniper/common/trace_frontend/trace_thread.cc", line 768, in handleInstructionDetailed [0x498f6d] 766: // simulate 767: passBY("performance model simulate iterate"); > 768: prfmdl->iterate(); 769: } 770: 771: void TraceThread::addDetailedMemoryInfo(DynamicInstruction *dynins, Sift::Instruction &inst, const dl::DecodedInst &decoded_inst, uint32_t mem_idx, Operand::Direction op_type, bool is_prefetch, PerformanceModel *prfmdl) ------------------------------
------------------------------ #10 Object "/root/Victima/sniper/lib/sniper", at 0x45543b, in PerformanceModel::iterate() Source "/root/Victima/sniper/common/performance_model/performance_model.cc", line 309, in iterate [0x45543b] 306: LOG_ASSERT_ERROR(!ins->instruction->isIdle(), "Idle instructions should not make it here!"); 307: 308: if (!m_fastforward && m_enabled) > 309: handleInstruction(ins); 310: 311: delete ins; ------------------------------