diff --git a/llvm/projects/gpu_profiler/offline_profiler.cpp b/llvm/projects/gpu_profiler/offline_profiler.cpp index 25ca45241c29e7a0f8edb0518d8347a185caf5a4..23543323df7f54c3c84bd53793876df43c7e9fbe 100644 --- a/llvm/projects/gpu_profiler/offline_profiler.cpp +++ b/llvm/projects/gpu_profiler/offline_profiler.cpp @@ -201,11 +201,11 @@ private: } // Executes the program to be profiled - void runProgram(const char * const program) { + void runProgram(const std::string& program) { // Tell the profiling thread to start, execute the program that needs // to be profiled, and then tell the profiling thread to stop. start_ = true; - const auto result = std::system(program); + const auto result = std::system(program.c_str()); stop_ = true; } @@ -471,7 +471,7 @@ public: sys_stream_.close(); } - void profile(const char * const program, const int iterations) { + void profile(const std::string& program, const int iterations) { iterations_ = iterations; resetGlobal(); @@ -568,16 +568,26 @@ public: int main(int argc, char *argv[]) { if (argc < NUM_ARGS) { - std::cout << "Usage: " << argv[0] << " <program> <iterations> <tensor output file> [power output file]\n"; + std::cout << "Usage: " << argv[0] << " <program> <params> END_PARAM <iterations> <tensor output file> [power output file]\n"; exit(1); } + std::string program(argv[1]); + size_t i = 2; + for (; i < argc; i++){ + if (std::string(argv[i]) == "END_PARAM"){ + break; + } + program += " " + std::string(argv[i]); + } + i += 1; + Profiler pp; - pp.profile(argv[1], std::stoi(argv[2])); - pp.dumpTensorInfo(argv[3]); + pp.profile(program, std::stoi(argv[i + 1])); + pp.dumpTensorInfo(argv[i + 2]); if (argc > NUM_ARGS) - pp.dumpPowerReadings(argv[4]); + pp.dumpPowerReadings(argv[i + 3]); return 0; }