From a81dfc5a0fa00a9a5c2fbaf835b5127e956917b1 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Thu, 8 Dec 2016 20:28:43 +0300 Subject: [PATCH] Fix the limitation of supported input files. Actually .cu and .cuda was supported. + All the file names are allowed, including file names without extension. [IMPORTANT] To hipify CUDA input file, which name is not *.cu, please add option "-x cuda" after tool's options ending marker "--", for instance: ./hipify-clang NeuralNet -- -x cuda This option will go to clang itself, not the hipify tool. --- hipamd/hipify-clang/src/Cuda2Hip.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/hipamd/hipify-clang/src/Cuda2Hip.cpp b/hipamd/hipify-clang/src/Cuda2Hip.cpp index 87a69e8cb9..2c934aebbc 100644 --- a/hipamd/hipify-clang/src/Cuda2Hip.cpp +++ b/hipamd/hipify-clang/src/Cuda2Hip.cpp @@ -2110,19 +2110,18 @@ int main(int argc, const char **argv) { if (dst.empty()) { dst = fileSources[0]; if (!Inplace) { - size_t pos = dst.rfind(".cu"); - if (pos != std::string::npos) { - dst = dst.substr(0, pos) + ".hip.cu"; + size_t pos = dst.rfind("."); + if (pos != std::string::npos && pos+1 < dst.size()) { + dst = dst.substr(0, pos) + ".hip." + dst.substr(pos+1, dst.size()-pos-1); } else { - llvm::errs() << "Input .cu file was not specified.\n"; - return 1; + dst += ".hip.cu"; } } } else { if (Inplace) { - llvm::errs() << "Conflict: both -o and -inplace options are specified."; + llvm::errs() << "Conflict: both -o and -inplace options are specified.\n"; } - dst += ".cu"; + dst += ".hip"; } // copy source file since tooling makes changes "inplace" std::ifstream source(fileSources[0], std::ios::binary); @@ -2172,7 +2171,7 @@ int main(int argc, const char **argv) { Result = Rewrite.overwriteChangedFiles(); if (!Inplace) { - size_t pos = dst.rfind(".cu"); + size_t pos = dst.rfind("."); if (pos != std::string::npos) { rename(dst.c_str(), dst.substr(0, pos).c_str()); }