From 90938b804ff2ecd7982df8db4877c43477a1ab07 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Mon, 12 Dec 2016 10:16:58 -0600 Subject: [PATCH 001/281] Changed threadfences to match target parsing by hcc Change-Id: I28fcabbaacd13495b707f263fd09afaead0665fa [ROCm/hip commit: 765947aaf52caf329f4b60608580e7ca06a24dc0] --- projects/hip/src/hip_ir.ll | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/hip/src/hip_ir.ll b/projects/hip/src/hip_ir.ll index d0e2a879a3..21123dd7c0 100644 --- a/projects/hip/src/hip_ir.ll +++ b/projects/hip/src/hip_ir.ll @@ -2,12 +2,12 @@ target datalayout = "e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-i64: target triple = "amdgcn--amdhsa" -define void @__threadfence() #1 { +define linkonce_odr spir_func void @__threadfence() #1 { fence syncscope(2) seq_cst ret void } -define void @__threadfence_block() #1 { +define linkonce_odr spir_func void @__threadfence_block() #1 { fence syncscope(3) seq_cst ret void } From a5ded34092a39c8c5cabb79665adba58f9e9d79d Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Mon, 12 Dec 2016 19:57:19 +0300 Subject: [PATCH 002/281] [HIPIFY] Multiple source files support. [ROCm/hip commit: 02468d31fc11425a4531020f87a33bc9d27b7c10] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 141 +++++++++++---------- 1 file changed, 75 insertions(+), 66 deletions(-) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index c66a2b1b87..31da2537cb 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -2106,11 +2106,12 @@ void printStats(std::string fileSource, HipifyPPCallbacks &PPCallbacks, Cuda2Hip int main(int argc, const char **argv) { llvm::sys::PrintStackTraceOnErrorSignal(); - CommonOptionsParser OptionsParser(argc, argv, ToolTemplateCategory, llvm::cl::Required); + CommonOptionsParser OptionsParser(argc, argv, ToolTemplateCategory, llvm::cl::OneOrMore); std::vector fileSources = OptionsParser.getSourcePathList(); std::string dst = OutputFilename; - if (N) { - NoOutput = PrintStats = true; + if (!dst.empty() && fileSources.size() > 1) { + llvm::errs() << "Conflict: -o and multiple source files are specified.\n"; + return 1; } if (NoOutput) { if (Inplace) { @@ -2122,84 +2123,92 @@ int main(int argc, const char **argv) { return 1; } } - if (dst.empty()) { - dst = fileSources[0]; - if (!Inplace) { - 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 { - dst += ".hip.cu"; + if (N) { + NoOutput = PrintStats = true; + } + int Result = 0; + for (const auto & src : fileSources) { + if (dst.empty()) { + dst = src; + if (!Inplace) { + 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 { + dst += ".hip.cu"; + } } } - } else { - if (Inplace) { - llvm::errs() << "Conflict: both -o and -inplace options are specified.\n"; - return 1; + else { + if (Inplace) { + llvm::errs() << "Conflict: both -o and -inplace options are specified.\n"; + return 1; + } + dst += ".hip"; + } + // backup source file since tooling may change "inplace" + if (!NoBackup || !Inplace) { + std::ifstream source(src, std::ios::binary); + std::ofstream dest(Inplace ? dst + ".prehip" : dst, std::ios::binary); + dest << source.rdbuf(); + source.close(); + dest.close(); } - dst += ".hip"; - } - // backup source file since tooling may change "inplace" - if (!NoBackup || !Inplace) { - std::ifstream source(fileSources[0], std::ios::binary); - std::ofstream dest(Inplace ? dst + ".prehip" : dst, std::ios::binary); - dest << source.rdbuf(); - source.close(); - dest.close(); - } - RefactoringTool Tool(OptionsParser.getCompilations(), dst); - ast_matchers::MatchFinder Finder; - HipifyPPCallbacks PPCallbacks(&Tool.getReplacements()); - Cuda2HipCallback Callback(&Tool.getReplacements(), &Finder, &PPCallbacks); + RefactoringTool Tool(OptionsParser.getCompilations(), dst); + ast_matchers::MatchFinder Finder; + HipifyPPCallbacks PPCallbacks(&Tool.getReplacements()); + Cuda2HipCallback Callback(&Tool.getReplacements(), &Finder, &PPCallbacks); - addAllMatchers(Finder, &Callback); + addAllMatchers(Finder, &Callback); - auto action = newFrontendActionFactory(&Finder, &PPCallbacks); - std::vector compilationStages; - compilationStages.push_back("--cuda-host-only"); - Tool.appendArgumentsAdjuster(getInsertArgumentAdjuster(compilationStages[0], ArgumentInsertPosition::BEGIN)); - Tool.appendArgumentsAdjuster(getInsertArgumentAdjuster("-std=c++11")); + auto action = newFrontendActionFactory(&Finder, &PPCallbacks); + std::vector compilationStages; + compilationStages.push_back("--cuda-host-only"); + Tool.appendArgumentsAdjuster(getInsertArgumentAdjuster(compilationStages[0], ArgumentInsertPosition::BEGIN)); + Tool.appendArgumentsAdjuster(getInsertArgumentAdjuster("-std=c++11")); #if defined(HIPIFY_CLANG_RES) - Tool.appendArgumentsAdjuster(getInsertArgumentAdjuster("-resource-dir=" HIPIFY_CLANG_RES)); + Tool.appendArgumentsAdjuster(getInsertArgumentAdjuster("-resource-dir=" HIPIFY_CLANG_RES)); #endif - Tool.appendArgumentsAdjuster(getClangSyntaxOnlyAdjuster()); - int Result = Tool.run(action.get()); - Tool.clearArgumentsAdjusters(); + Tool.appendArgumentsAdjuster(getClangSyntaxOnlyAdjuster()); + Result += Tool.run(action.get()); + Tool.clearArgumentsAdjusters(); - LangOptions DefaultLangOptions; - IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions(); - TextDiagnosticPrinter DiagnosticPrinter(llvm::errs(), &*DiagOpts); - DiagnosticsEngine Diagnostics( + LangOptions DefaultLangOptions; + IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions(); + TextDiagnosticPrinter DiagnosticPrinter(llvm::errs(), &*DiagOpts); + DiagnosticsEngine Diagnostics( IntrusiveRefCntPtr(new DiagnosticIDs()), &*DiagOpts, &DiagnosticPrinter, false); - DEBUG(dbgs() << "Replacements collected by the tool:\n"); - for (const auto &r : Tool.getReplacements()) { - DEBUG(dbgs() << r.toString() << "\n"); - } + DEBUG(dbgs() << "Replacements collected by the tool:\n"); + for (const auto &r : Tool.getReplacements()) { + DEBUG(dbgs() << r.toString() << "\n"); + } - SourceManager Sources(Diagnostics, Tool.getFiles()); - Rewriter Rewrite(Sources, DefaultLangOptions); + SourceManager Sources(Diagnostics, Tool.getFiles()); + Rewriter Rewrite(Sources, DefaultLangOptions); - if (!Tool.applyAllReplacements(Rewrite)) { - DEBUG(dbgs() << "Skipped some replacements.\n"); - } - if (!NoOutput) { - Result = Rewrite.overwriteChangedFiles(); - } - if (!Inplace && !NoOutput) { - size_t pos = dst.rfind("."); - if (pos != std::string::npos) { - rename(dst.c_str(), dst.substr(0, pos).c_str()); + if (!Tool.applyAllReplacements(Rewrite)) { + DEBUG(dbgs() << "Skipped some replacements.\n"); + } + if (!NoOutput) { + Result += Rewrite.overwriteChangedFiles(); + } + if (!Inplace && !NoOutput) { + size_t pos = dst.rfind("."); + if (pos != std::string::npos) { + rename(dst.c_str(), dst.substr(0, pos).c_str()); + } + } + if (NoOutput) { + remove(dst.c_str()); + } + dst.clear(); + if (PrintStats) { + printStats(src, PPCallbacks, Callback); } } - if (NoOutput) { - remove(dst.c_str()); - } - if (PrintStats) { - printStats(fileSources[0], PPCallbacks, Callback); - } - return Result; } From b2377f20ba91f0ff99370fee6a5d4d0284631bef Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Mon, 12 Dec 2016 20:03:01 +0300 Subject: [PATCH 003/281] [HIPIFY] Rename -n to -examine [ROCm/hip commit: 95ae5145118a804170bf6aef0c40406be6691f42] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index 31da2537cb..b4e364c52f 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -2019,7 +2019,7 @@ static cl::opt PrintStats("print-stats", cl::value_desc("print-stats"), cl::cat(ToolTemplateCategory)); -static cl::opt N("n", +static cl::opt Examine("examine", cl::desc("Combines -no-output and -print-stats options"), cl::value_desc("n"), cl::cat(ToolTemplateCategory)); @@ -2123,7 +2123,7 @@ int main(int argc, const char **argv) { return 1; } } - if (N) { + if (Examine) { NoOutput = PrintStats = true; } int Result = 0; From 4fd6a82aaff452e2f1dbc30b7826bdb6be2ff362 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Tue, 13 Dec 2016 18:01:08 +0300 Subject: [PATCH 004/281] [HIPIFY] Code refactoring and total stat collecting + Single base class for Preprocessor and MatchFinder classes. + Total Stats for multiple files is added. [ROCm/hip commit: ad3ec15d8507b60116faa00220743b69c4c8225a] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 187 ++++++++++++--------- 1 file changed, 103 insertions(+), 84 deletions(-) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index b4e364c52f..4f37bb9365 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -85,6 +85,7 @@ const char *counterNames[CONV_LAST] = { "special_func", "stream", "event", "ctx", "module", "cache", "err", "def", "tex", "other", "include", "include_cuda_main_header", "type", "literal", "numeric_literal"}; + enum ApiTypes { API_DRIVER = 0, API_RUNTIME, @@ -97,6 +98,15 @@ const char *apiNames[API_LAST] = { namespace { +int64_t countRepsTotal[CONV_LAST] = { 0 }; +int64_t countApiRepsTotal[API_LAST] = { 0 }; + +struct hipCounter { + StringRef hipName; + ConvTypes countType; + ApiTypes countApiType; +}; + struct cuda2hipMap { cuda2hipMap() { @@ -1317,13 +1327,7 @@ struct cuda2hipMap { //cuda2hipRename["cublasDrotmg_v2"] = {"hipblasDrotmg", CONV_MATH_FUNC, API_BLAS}; } - struct HipNames { - StringRef hipName; - ConvTypes countType; - ApiTypes countApiType; - }; - - SmallDenseMap cuda2hipRename; + SmallDenseMap cuda2hipRename; std::set cudaExcludes; }; @@ -1333,36 +1337,52 @@ StringRef unquoteStr(StringRef s) { return s; } -static void processString(StringRef s, const cuda2hipMap &map, - Replacements *Replace, SourceManager &SM, - SourceLocation start, - int64_t countReps[CONV_LAST], - int64_t countApiReps[API_LAST]) { - size_t begin = 0; - while ((begin = s.find("cu", begin)) != StringRef::npos) { - const size_t end = s.find_first_of(" ", begin + 4); - StringRef name = s.slice(begin, end); - const auto found = map.cuda2hipRename.find(name); - if (found != map.cuda2hipRename.end()) { - StringRef repName = found->second.hipName; - countReps[CONV_LITERAL]++; - countApiReps[API_RUNTIME]++; - SourceLocation sl = start.getLocWithOffset(begin + 1); - Replacement Rep(SM, sl, name.size(), repName); - Replace->insert(Rep); - } - if (end == StringRef::npos) - break; - begin = end + 1; +class Cuda2Hip { +public: + Cuda2Hip(Replacements *R): Replace(R) {} + + int64_t countReps[CONV_LAST] = { 0 }; + int64_t countApiReps[API_LAST] = { 0 }; + +protected: + struct cuda2hipMap N; + Replacements *Replace; + + virtual void updateCounters(const hipCounter & counter) { + countReps[counter.countType]++; + countRepsTotal[counter.countType]++; + countApiReps[counter.countApiType]++; + countApiRepsTotal[counter.countApiType]++; } -} + + void processString(StringRef s, SourceManager &SM, SourceLocation start) { + size_t begin = 0; + while ((begin = s.find("cu", begin)) != StringRef::npos) { + const size_t end = s.find_first_of(" ", begin + 4); + StringRef name = s.slice(begin, end); + const auto found = N.cuda2hipRename.find(name); + if (found != N.cuda2hipRename.end()) { + StringRef repName = found->second.hipName; + hipCounter counter = { "", CONV_LITERAL, API_RUNTIME }; + updateCounters(counter); + SourceLocation sl = start.getLocWithOffset(begin + 1); + Replacement Rep(SM, sl, name.size(), repName); + Replace->insert(Rep); + } + if (end == StringRef::npos) { + break; + } + begin = end + 1; + } + } +}; class Cuda2HipCallback; -class HipifyPPCallbacks : public PPCallbacks, public SourceFileCallbacks { +class HipifyPPCallbacks : public PPCallbacks, public SourceFileCallbacks, public Cuda2Hip { public: HipifyPPCallbacks(Replacements *R) - : SeenEnd(false), _sm(nullptr), _pp(nullptr), Replace(R) {} + : Cuda2Hip(R), SeenEnd(false), _sm(nullptr), _pp(nullptr) {} virtual bool handleBeginSource(CompilerInstance &CI, StringRef Filename) override { @@ -1389,8 +1409,7 @@ public: const auto found = N.cuda2hipRename.find(file_name); if (found != N.cuda2hipRename.end()) { StringRef repName = found->second.hipName; - countReps[found->second.countType]++; - countApiReps[found->second.countApiType]++; + updateCounters(found->second); DEBUG(dbgs() << "Include file found: " << file_name << "\n" << "SourceLocation:" << filename_range.getBegin().printToString(*_sm) << "\n" @@ -1418,8 +1437,7 @@ public: const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { StringRef repName = found->second.hipName; - countReps[found->second.countType]++; - countApiReps[found->second.countApiType]++; + updateCounters(found->second); SourceLocation sl = T.getLocation(); DEBUG(dbgs() << "Identifier " << name << " found in definition of macro " @@ -1465,8 +1483,7 @@ public: const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { StringRef repName = found->second.hipName; - countReps[found->second.countType]++; - countApiReps[found->second.countApiType]++; + updateCounters(found->second); DEBUG(dbgs() << "Identifier " << name << " found as an actual argument in expansion of macro " @@ -1488,16 +1505,14 @@ public: if (found != N.cuda2hipRename.end()) { sl = sl_macro; StringRef repName = found->second.hipName; - countReps[found->second.countType]++; - countApiReps[found->second.countApiType]++; + updateCounters(found->second); Replacement Rep(*_sm, sl, length, repName); Replace->insert(Rep); } } else { if (tok.is(tok::string_literal)) { StringRef s(tok.getLiteralData(), tok.getLength()); - processString(unquoteStr(s), N, Replace, *_sm, tok.getLocation(), - countReps, countApiReps); + processString(unquoteStr(s), *_sm, tok.getLocation()); } } } @@ -1513,18 +1528,14 @@ public: void setSourceManager(SourceManager *sm) { _sm = sm; } void setPreprocessor(Preprocessor *pp) { _pp = pp; } void setMatch(Cuda2HipCallback *match) { Match = match; } - int64_t countReps[CONV_LAST] = { 0 }; - int64_t countApiReps[API_LAST] = { 0 }; private: SourceManager *_sm; Preprocessor *_pp; Cuda2HipCallback *Match; - Replacements *Replace; - struct cuda2hipMap N; }; -class Cuda2HipCallback : public MatchFinder::MatchCallback { +class Cuda2HipCallback : public MatchFinder::MatchCallback, public Cuda2Hip { private: void convertKernelDecl(const FunctionDecl *kernelDecl, const MatchFinder::MatchResult &Result) { SourceManager *SM = Result.SourceManager; @@ -1579,8 +1590,7 @@ private: } } if (bReplace) { - countReps[found->second.countType]++; - countApiReps[found->second.countApiType]++; + updateCounters(found->second); Replacement Rep(*SM, sl, length, repName); Replace->insert(Rep); } @@ -1653,8 +1663,8 @@ private: SM->getCharacterData(launchKernel->getLocStart()); Replacement Rep(*SM, launchKernel->getLocStart(), length, OS.str()); Replace->insert(Rep); - countReps[CONV_KERN]++; - countApiReps[API_RUNTIME]++; + hipCounter counter = { "", CONV_KERN, API_RUNTIME }; + updateCounters(counter); return true; } return false; @@ -1675,8 +1685,7 @@ private: const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { StringRef repName = found->second.hipName; - countReps[found->second.countType]++; - countApiReps[found->second.countApiType]++; + updateCounters(found->second); SourceLocation sl = threadIdx->getLocStart(); SourceManager *SM = Result.SourceManager; Replacement Rep(*SM, sl, name.size(), repName); @@ -1695,8 +1704,7 @@ private: const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { StringRef repName = found->second.hipName; - countReps[found->second.countType]++; - countApiReps[found->second.countApiType]++; + updateCounters(found->second); SourceLocation sl = enumConstantRef->getLocStart(); SourceManager *SM = Result.SourceManager; Replacement Rep(*SM, sl, name.size(), repName); @@ -1719,8 +1727,7 @@ private: const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { StringRef repName = found->second.hipName; - countReps[found->second.countType]++; - countApiReps[found->second.countApiType]++; + updateCounters(found->second); SourceLocation sl = enumConstantDecl->getLocStart(); SourceManager *SM = Result.SourceManager; Replacement Rep(*SM, sl, name.size(), repName); @@ -1742,8 +1749,7 @@ private: const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { StringRef repName = found->second.hipName; - countReps[found->second.countType]++; - countApiReps[found->second.countApiType]++; + updateCounters(found->second); SourceLocation sl = typedefVar->getLocStart(); SourceManager *SM = Result.SourceManager; Replacement Rep(*SM, sl, name.size(), repName); @@ -1763,8 +1769,7 @@ private: const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { StringRef repName = found->second.hipName; - countReps[found->second.countType]++; - countApiReps[found->second.countApiType]++; + updateCounters(found->second); TypeLoc TL = structVar->getTypeSourceInfo()->getTypeLoc(); SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); SourceManager *SM = Result.SourceManager; @@ -1784,8 +1789,7 @@ private: const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { StringRef repName = found->second.hipName; - countReps[found->second.countType]++; - countApiReps[found->second.countApiType]++; + updateCounters(found->second); TypeLoc TL = structVarPtr->getTypeSourceInfo()->getTypeLoc(); SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); SourceManager *SM = Result.SourceManager; @@ -1807,8 +1811,7 @@ private: const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { StringRef repName = found->second.hipName; - countReps[found->second.countType]++; - countApiReps[found->second.countApiType]++; + updateCounters(found->second); TypeLoc TL = typeInfo->getTypeLoc(); SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); SourceManager *SM = Result.SourceManager; @@ -1852,8 +1855,8 @@ private: StringRef repName = Twine("HIP_DYNAMIC_SHARED(" + typeName + ", " + varName + ")").toStringRef(tmpData); Replacement Rep(*SM, slStart, repLength, repName); Replace->insert(Rep); - countReps[CONV_MEM]++; - countApiReps[API_RUNTIME]++; + hipCounter counter = { "", CONV_MEM, API_RUNTIME }; + updateCounters(counter); } } return true; @@ -1872,8 +1875,7 @@ private: const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { StringRef repName = found->second.hipName; - countReps[found->second.countType]++; - countApiReps[found->second.countApiType]++; + updateCounters(found->second); TypeLoc TL = paramDecl->getTypeSourceInfo()->getTypeLoc(); SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); SourceManager *SM = Result.SourceManager; @@ -1897,8 +1899,7 @@ private: const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { StringRef repName = found->second.hipName; - countReps[found->second.countType]++; - countApiReps[found->second.countApiType]++; + updateCounters(found->second); TypeLoc TL = paramDeclPtr->getTypeSourceInfo()->getTypeLoc(); SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); SourceManager *SM = Result.SourceManager; @@ -1925,7 +1926,7 @@ private: if (sLiteral->getCharByteWidth() == 1) { StringRef s = sLiteral->getString(); SourceManager *SM = Result.SourceManager; - processString(s, N, Replace, *SM, sLiteral->getLocStart(), countReps, countApiReps); + processString(s, *SM, sLiteral->getLocStart()); } return true; } @@ -1934,7 +1935,7 @@ private: public: Cuda2HipCallback(Replacements *Replace, ast_matchers::MatchFinder *parent, HipifyPPCallbacks *PPCallbacks) - : Replace(Replace), owner(parent), PP(PPCallbacks) { + : Cuda2Hip(Replace), owner(parent), PP(PPCallbacks) { PP->setMatch(this); } @@ -1962,19 +1963,14 @@ public: SourceManager *SM = Result.SourceManager; Replacement Rep(*SM, SM->getLocForStartOfFile(SM->getMainFileID()), 0, repName); Replace->insert(Rep); - countReps[CONV_INCLUDE_CUDA_MAIN_H]++; - countApiReps[API_RUNTIME]++; + hipCounter counter = { "", CONV_INCLUDE_CUDA_MAIN_H, API_RUNTIME }; + updateCounters(counter); } } - int64_t countReps[CONV_LAST] = { 0 }; - int64_t countApiReps[API_LAST] = { 0 }; - private: - Replacements *Replace; ast_matchers::MatchFinder *owner; HipifyPPCallbacks *PP; - struct cuda2hipMap N; }; void HipifyPPCallbacks::handleEndSource() { @@ -1983,8 +1979,8 @@ void HipifyPPCallbacks::handleEndSource() { StringRef repName = "#include \n"; Replacement Rep(*_sm, _sm->getLocForStartOfFile(_sm->getMainFileID()), 0, repName); Replace->insert(Rep); - countReps[CONV_INCLUDE_CUDA_MAIN_H]++; - countApiReps[API_RUNTIME]++; + hipCounter counter = { "", CONV_INCLUDE_CUDA_MAIN_H, API_RUNTIME }; + updateCounters(counter); } } @@ -2088,12 +2084,12 @@ void addAllMatchers(ast_matchers::MatchFinder &Finder, Cuda2HipCallback *Callbac Callback); } -void printStats(std::string fileSource, HipifyPPCallbacks &PPCallbacks, Cuda2HipCallback &Callback) { +int64_t printStats(std::string fileSource, HipifyPPCallbacks &PPCallbacks, Cuda2HipCallback &Callback) { int64_t sum = 0; for (int i = 0; i < CONV_LAST; i++) { sum += Callback.countReps[i] + PPCallbacks.countReps[i]; } - llvm::outs() << "info: converted " << sum << " CUDA->HIP refs ( "; + llvm::outs() << "Info: converted " << sum << " CUDA->HIP refs ( "; for (int i = 0; i < CONV_LAST; i++) { llvm::outs() << counterNames[i] << ':' << Callback.countReps[i] + PPCallbacks.countReps[i] << ' '; } @@ -2102,6 +2098,23 @@ void printStats(std::string fileSource, HipifyPPCallbacks &PPCallbacks, Cuda2Hip llvm::outs() << apiNames[i] << ':' << Callback.countApiReps[i] + PPCallbacks.countApiReps[i] << ' '; } llvm::outs() << ") in \'" << fileSource << "\'\n"; + return sum; +} + +void printAllStats(int64_t totalFiles, int64_t convertedFiles) { + int64_t sum = 0; + for (int i = 0; i < CONV_LAST; i++) { + sum += countRepsTotal[i]; + } + llvm::outs() << "Info: totally converted " << sum << " CUDA->HIP refs ( "; + for (int i = 0; i < CONV_LAST; i++) { + llvm::outs() << counterNames[i] << ':' << countRepsTotal[i] << ' '; + } + llvm::outs() << "), by APIs ( "; + for (int i = 0; i < API_LAST; i++) { + llvm::outs() << apiNames[i] << ':' << countApiRepsTotal[i] << ' '; + } + llvm::outs() << ") in " << convertedFiles << " files of " << totalFiles << " processed files.\n"; } int main(int argc, const char **argv) { @@ -2127,6 +2140,7 @@ int main(int argc, const char **argv) { NoOutput = PrintStats = true; } int Result = 0; + size_t filesTransleted = fileSources.size(); for (const auto & src : fileSources) { if (dst.empty()) { dst = src; @@ -2207,8 +2221,13 @@ int main(int argc, const char **argv) { } dst.clear(); if (PrintStats) { - printStats(src, PPCallbacks, Callback); + if (0 == printStats(src, PPCallbacks, Callback)) { + filesTransleted--; + } } } + if (PrintStats && fileSources.size() > 1) { + printAllStats(fileSources.size(), filesTransleted); + } return Result; } From 8ad8f7ce261c0850af488b426078f24955d78cf1 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Tue, 13 Dec 2016 09:18:34 -0600 Subject: [PATCH 005/281] added half math addition ISA support Change-Id: I293b771f695b499b795d7e53f600c9e4fe2a2071 [ROCm/hip commit: a6fe6222c44490476e87dd0e2b7668a82247be7f] --- projects/hip/include/hip/hcc_detail/hip_fp16.h | 16 ++++++++++++++++ projects/hip/src/hip_fp16.cpp | 5 +++++ projects/hip/src/hip_ir.ll | 5 +++++ 3 files changed, 26 insertions(+) diff --git a/projects/hip/include/hip/hcc_detail/hip_fp16.h b/projects/hip/include/hip/hcc_detail/hip_fp16.h index bcf2605f28..445df78eb4 100644 --- a/projects/hip/include/hip/hcc_detail/hip_fp16.h +++ b/projects/hip/include/hip/hcc_detail/hip_fp16.h @@ -25,6 +25,10 @@ THE SOFTWARE. #include "hip/hip_runtime.h" +#define __CLANG_VERSION__ __clang_major__ * 10 + __clang_minor__ + +#if __CLANG_VERSION__ == 35 + typedef struct{ unsigned x: 16; } __half; @@ -175,3 +179,15 @@ __device__ __half2 __lowhigh2highlow(const __half2 a); __device__ __half2 __low2half2(const __half2 a, const __half2 b); #endif + +#if __CLANG_VERSION__ == 40 + +typedef __fp16 __half; +extern "C" __half __hip_hadd_clang40_gfx803(__half a, __half b); + +__device__ inline __half __hadd(__half a, __half b){ + return __hip_hadd_clang40_gfx803(a, b); +} + +#endif +#endif diff --git a/projects/hip/src/hip_fp16.cpp b/projects/hip/src/hip_fp16.cpp index 1a9d04474f..5d01f73cf7 100644 --- a/projects/hip/src/hip_fp16.cpp +++ b/projects/hip/src/hip_fp16.cpp @@ -22,6 +22,8 @@ THE SOFTWARE. #include"hip/hip_fp16.h" +#if __CLANG_VERSION__ == 35 + static const unsigned sign_val = 0x8000; static const __half __half_value_one_float = {0x3C00}; static const __half __half_value_zero_float = {0x0}; @@ -372,3 +374,6 @@ __device__ __half2 __lowhigh2highlow(const __half2 a){ __device__ __half2 __low2half2(const __half2 a, const __half2 b){ return {a.q, b.q}; } + +#endif + diff --git a/projects/hip/src/hip_ir.ll b/projects/hip/src/hip_ir.ll index 21123dd7c0..078dc3eed5 100644 --- a/projects/hip/src/hip_ir.ll +++ b/projects/hip/src/hip_ir.ll @@ -34,4 +34,9 @@ define linkonce_odr spir_func i32 @__rocm_hadd(i32 %in1, i32 %in2) { ret i32 %val } +define linkonce_odr spir_func half @__hip_hadd_clang40_gfx803(half %a, half %b) { + %val = tail call half asm "v_add_f16 $0, $1, $2","=v,v,v"(half %a, half %b) + ret half %val +} + attributes #1 = { alwaysinline nounwind } From ada705544fb0006f47debd1384f3b3e39bafa139 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Tue, 13 Dec 2016 14:41:36 -0600 Subject: [PATCH 006/281] added few type reinterpret cast device functions 1. __int_as_float 2. __hiloint2double Change-Id: Id247c196887b24a12090f0521bf91e13afeec733 [ROCm/hip commit: 04ab5f7f5611987f1c99d1b937f46cf9bbf1488e] --- projects/hip/CMakeLists.txt | 3 +- projects/hip/include/hip/device_functions.h | 33 +++++++++++ .../include/hip/hcc_detail/device_functions.h | 32 ++++++++++ .../include/hip/hcc_detail/hip_vector_types.h | 3 - projects/hip/src/device_functions.cpp | 58 +++++++++++++++++++ 5 files changed, 125 insertions(+), 4 deletions(-) create mode 100644 projects/hip/include/hip/device_functions.h create mode 100644 projects/hip/include/hip/hcc_detail/device_functions.h create mode 100644 projects/hip/src/device_functions.cpp diff --git a/projects/hip/CMakeLists.txt b/projects/hip/CMakeLists.txt index 6f9a819c4d..c76410f06d 100644 --- a/projects/hip/CMakeLists.txt +++ b/projects/hip/CMakeLists.txt @@ -177,7 +177,8 @@ if(HIP_PLATFORM STREQUAL "hcc") set(SOURCE_FILES_DEVICE src/device_util.cpp src/hip_ldg.cpp - src/hip_fp16.cpp) + src/hip_fp16.cpp + src/device_functions.cpp) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -L${HCC_HOME}/lib -lmcwamp -Wl,-Bsymbolic") add_library(hip_hcc SHARED ${SOURCE_FILES_RUNTIME}) diff --git a/projects/hip/include/hip/device_functions.h b/projects/hip/include/hip/device_functions.h new file mode 100644 index 0000000000..838bad8f0c --- /dev/null +++ b/projects/hip/include/hip/device_functions.h @@ -0,0 +1,33 @@ +/* +Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#ifndef HIP_DEVICE_FUNCTIONS_H +#define HIP_DEVICE_FUNCTIONS_H + +#include + +#if defined(__HIP_PLATFORM_HCC__) && !defined (__HIP_PLATFORM_NVCC__) +#include +#elif defined(__HIP_PLATFORM_NVCC__) && !defined (__HIP_PLATFORM_HCC__) +#include +#else +#error("Must define exactly one of __HIP_PLATFORM_HCC__ or __HIP_PLATFORM_NVCC__"); +#endif + +#endif diff --git a/projects/hip/include/hip/hcc_detail/device_functions.h b/projects/hip/include/hip/hcc_detail/device_functions.h new file mode 100644 index 0000000000..8fa870664f --- /dev/null +++ b/projects/hip/include/hip/hcc_detail/device_functions.h @@ -0,0 +1,32 @@ +/* +Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#ifndef HIP_HCC_DETAIL_DEVICE_FUNCTIONS_H +#define HIP_HCC_DETAIL_DEVICE_FUNCTIONS_H + +#include "hip_runtime.h" + +__device__ float __int_as_float (int x); + +__device__ double __hiloint2double (int hi, int lo); + +extern __HIP_DEVICE__ double __longlong_as_double(long long int x); +extern __HIP_DEVICE__ long long int __double_as_longlong(double x); + +#endif diff --git a/projects/hip/include/hip/hcc_detail/hip_vector_types.h b/projects/hip/include/hip/hcc_detail/hip_vector_types.h index ffe15a27a4..7c48985996 100644 --- a/projects/hip/include/hip/hcc_detail/hip_vector_types.h +++ b/projects/hip/include/hip/hcc_detail/hip_vector_types.h @@ -343,9 +343,6 @@ __HIP_DEVICE__ double2 make_double2(double, double ); __HIP_DEVICE__ double3 make_double3(double, double, double ); __HIP_DEVICE__ double4 make_double4(double, double, double, double ); -extern __HIP_DEVICE__ double __longlong_as_double(long long int x); -extern __HIP_DEVICE__ long long int __double_as_longlong(double x); - /* ///--- diff --git a/projects/hip/src/device_functions.cpp b/projects/hip/src/device_functions.cpp new file mode 100644 index 0000000000..30a09e6e02 --- /dev/null +++ b/projects/hip/src/device_functions.cpp @@ -0,0 +1,58 @@ +/* +Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#include + +extern "C" float __hip_int_as_float(int); + +typedef struct { + signed int hi; + signed int lo; +} __hip_signed_2; + +typedef struct { +union { + double d; + long long int lli; + __hip_signed_2 s2; +} ; +} __hip_64bit_struct; + +typedef struct { +union { + float f; + unsigned int ui; + signed int si; +}; +} __hip_32bit_struct; + +__device__ float __int_as_float (int x) { + __hip_32bit_struct s; + s.si = x; + return s.f; +} + +__device__ double __hiloint2double (int hi, int lo) { + __hip_64bit_struct s; + s.s2.hi = hi; + s.s2.lo = lo; + return s.d; +} + + From 1a7ecbcd0467b154f195e5b5071aa8e233eb81c1 Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Tue, 13 Dec 2016 15:07:04 -0600 Subject: [PATCH 007/281] Add USE_IPC to disable use of IPC APIs. Set to 0. [ROCm/hip commit: b30e4b4781c980e0979e8687f4bcc504c95c3139] --- projects/hip/src/hip_hcc.h | 3 +++ projects/hip/src/hip_memory.cpp | 13 ++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/projects/hip/src/hip_hcc.h b/projects/hip/src/hip_hcc.h index 82290bc489..b5417080e0 100644 --- a/projects/hip/src/hip_hcc.h +++ b/projects/hip/src/hip_hcc.h @@ -34,6 +34,7 @@ THE SOFTWARE. #endif #define USE_DISPATCH_HSA_KERNEL 1 +#define USE_IPC 0 // @@ -375,7 +376,9 @@ struct LockedBase { class ihipIpcMemHandle_t { public: +#if USE_IPC hsa_amd_ipc_memory_t ipc_handle; ///< ipc memory handle on ROCr +#endif char reserved[HIP_IPC_HANDLE_SIZE]; size_t psize; }; diff --git a/projects/hip/src/hip_memory.cpp b/projects/hip/src/hip_memory.cpp index f2ab6d19a0..7aa6ef4942 100644 --- a/projects/hip/src/hip_memory.cpp +++ b/projects/hip/src/hip_memory.cpp @@ -1056,11 +1056,15 @@ hipError_t hipIpcGetMemHandle(hipIpcMemHandle_t* handle, void* devPtr){ // Save the size of the pointer to hipIpcMemHandle (*handle)->psize = psize; +#if USE_IPC // Create HSA ipc memory hsa_status_t hsa_status = hsa_amd_ipc_memory_create(devPtr, psize, &(*handle)->ipc_handle); if(hsa_status!= HSA_STATUS_SUCCESS) hipStatus = hipErrorMemoryAllocation; +#else + hipStatus = hipErrorRuntimeOther; +#endif return hipStatus; } @@ -1069,6 +1073,7 @@ hipError_t hipIpcOpenMemHandle(void** devPtr, hipIpcMemHandle_t handle, unsigned // HIP_INIT_API ( devPtr, handle.handle , flags); hipError_t hipStatus = hipSuccess; +#if USE_IPC // Get the current device agent. hc::accelerator acc; hsa_agent_t *agent = static_cast(acc.get_hsa_agent()); @@ -1080,7 +1085,9 @@ hipError_t hipIpcOpenMemHandle(void** devPtr, hipIpcMemHandle_t handle, unsigned hsa_amd_ipc_memory_attach(&handle->ipc_handle, handle->psize, 1, agent, devPtr); if(hsa_status != HSA_STATUS_SUCCESS) hipStatus = hipErrorMapBufferObjectFailed; - +#else + hipStatus = hipErrorRuntimeOther; +#endif return hipStatus; } @@ -1088,10 +1095,14 @@ hipError_t hipIpcCloseMemHandle(void *devPtr){ HIP_INIT_API ( devPtr ); hipError_t hipStatus = hipSuccess; +#if USE_IPC hsa_status_t hsa_status = hsa_amd_ipc_memory_detach(devPtr); if(hsa_status != HSA_STATUS_SUCCESS) return hipErrorInvalidResourceHandle; +#else + hipStatus = hipErrorRuntimeOther; +#endif return hipStatus; } From 0b445d68de8fb005e9fef31ba538ec5ee0846308 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Tue, 13 Dec 2016 20:06:56 -0600 Subject: [PATCH 008/281] disabled compiler flag hcc 4.0 for half support Change-Id: I32175113f4c05d43310b3a05c2a14e12f6d48b09 [ROCm/hip commit: ed39a7f43bcc284997593e4acf12faa2a602b617] --- .../hip/include/hip/hcc_detail/hip_fp16.h | 22 +++++++++---------- projects/hip/src/hip_fp16.cpp | 3 --- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/hip_fp16.h b/projects/hip/include/hip/hcc_detail/hip_fp16.h index 445df78eb4..735f915bd2 100644 --- a/projects/hip/include/hip/hcc_detail/hip_fp16.h +++ b/projects/hip/include/hip/hcc_detail/hip_fp16.h @@ -27,7 +27,16 @@ THE SOFTWARE. #define __CLANG_VERSION__ __clang_major__ * 10 + __clang_minor__ -#if __CLANG_VERSION__ == 35 +#ifdef HIP_HALF_HW_SUPPORT + +typedef __fp16 __half; +extern "C" __half __hip_hadd_clang40_gfx803(__half a, __half b); + +__device__ inline __half __hadd(__half a, __half b){ + return __hip_hadd_clang40_gfx803(a, b); +} + +#else typedef struct{ unsigned x: 16; @@ -178,16 +187,5 @@ __device__ __half2 __lowhigh2highlow(const __half2 a); __device__ __half2 __low2half2(const __half2 a, const __half2 b); -#endif - -#if __CLANG_VERSION__ == 40 - -typedef __fp16 __half; -extern "C" __half __hip_hadd_clang40_gfx803(__half a, __half b); - -__device__ inline __half __hadd(__half a, __half b){ - return __hip_hadd_clang40_gfx803(a, b); -} - #endif #endif diff --git a/projects/hip/src/hip_fp16.cpp b/projects/hip/src/hip_fp16.cpp index 5d01f73cf7..63d91eb107 100644 --- a/projects/hip/src/hip_fp16.cpp +++ b/projects/hip/src/hip_fp16.cpp @@ -22,7 +22,6 @@ THE SOFTWARE. #include"hip/hip_fp16.h" -#if __CLANG_VERSION__ == 35 static const unsigned sign_val = 0x8000; static const __half __half_value_one_float = {0x3C00}; @@ -375,5 +374,3 @@ __device__ __half2 __low2half2(const __half2 a, const __half2 b){ return {a.q, b.q}; } -#endif - From d4b7fe8385be4b05975eb5ddd0cbf02c0f5c88ac Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Tue, 13 Dec 2016 20:20:58 -0600 Subject: [PATCH 009/281] added simple half math ops Change-Id: I10b1d1023a9e5f2ba63f28c4a2bbe60ee49a8aee [ROCm/hip commit: 7c7d948fc6d9dd33b5e7d531f60fbc04a67cb444] --- .../hip/include/hip/hcc_detail/hip_fp16.h | 37 +++++++++++++++++-- projects/hip/src/hip_ir.ll | 17 ++++++++- 2 files changed, 50 insertions(+), 4 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/hip_fp16.h b/projects/hip/include/hip/hcc_detail/hip_fp16.h index 735f915bd2..5acf114518 100644 --- a/projects/hip/include/hip/hcc_detail/hip_fp16.h +++ b/projects/hip/include/hip/hcc_detail/hip_fp16.h @@ -30,10 +30,41 @@ THE SOFTWARE. #ifdef HIP_HALF_HW_SUPPORT typedef __fp16 __half; -extern "C" __half __hip_hadd_clang40_gfx803(__half a, __half b); +extern "C" __half __hip_hadd_gfx803(__half a, __half b); +extern "C" __half __hip_hfma_gfx803(__half a, __half b); +extern "C" __half __hip_hmul_gfx803(__half a, __half b); +extern "C" __half __hip_hsub_gfx803(__half a, __half b); -__device__ inline __half __hadd(__half a, __half b){ - return __hip_hadd_clang40_gfx803(a, b); +__device__ inline __half __hadd(__half a, __half b) { + return __hip_hadd_gfx803(a, b); +} + +__device__ inline __half __hadd_sat(__half a, __half b) { + return __hip_add_gfx803(a, b); +} + +__device__ inline __half __hfma(__half a, __half b) { + return __hip_hfma_gfx803(a, b); +} + +__device__ inline __half __hfma_sat(__half a, __half b) { + return __hip_hfma_gfx803(a, b); +} + +__device__ inline __half __hmul(__half a, __half b) { + return __hip_hmul_gfx803(a, b); +} + +__device__ inline __half __hmul_sat(__half a, __half b) { + return __hip_hmul_gfx803(a, b); +} + +__device__ inline __half __hsub(__half a, __half b) { + return __hip_hsub_gfx803(a, b); +} + +__device__ inline __half __hsub_sat(__half a, __half b) { + return __hip_hsub_gfx803(a, b); } #else diff --git a/projects/hip/src/hip_ir.ll b/projects/hip/src/hip_ir.ll index 078dc3eed5..623be19084 100644 --- a/projects/hip/src/hip_ir.ll +++ b/projects/hip/src/hip_ir.ll @@ -34,9 +34,24 @@ define linkonce_odr spir_func i32 @__rocm_hadd(i32 %in1, i32 %in2) { ret i32 %val } -define linkonce_odr spir_func half @__hip_hadd_clang40_gfx803(half %a, half %b) { +define linkonce_odr spir_func half @__hip_hadd_gfx803(half %a, half %b) #1 { %val = tail call half asm "v_add_f16 $0, $1, $2","=v,v,v"(half %a, half %b) ret half %val } +define linkonce_odr spir_func half @__hip_hfma_gfx803(half %a, half %b, half %c) #1 { + %val = tail call half asm "v_fma_f16 $0, $1, $2, $3","=v,v,v,v"(half %a, half %b, half %c) + ret half %val +} + +define linkonce_odr spir_func half @__hip_hmul_gfx803(half %a, half %b) #1 { + %val = tail call half asm "v_mul_f16 $0, $1, $2","=v,v,v"(half %a, half %b) + ret half %val +} + +define linkonce_odr spir_func half @__hip_hsub_gfx803(half %a, half %b) #1 { + %val = tail call half asm "v_sub_f16 $0, $1, $2","=v,v,v"(half %a, half %b) + ret half %val +} + attributes #1 = { alwaysinline nounwind } From 1c6c61824764093a37f363e77c0bd78f3b53489b Mon Sep 17 00:00:00 2001 From: Sandeep Kumar Date: Wed, 14 Dec 2016 15:49:40 +0530 Subject: [PATCH 010/281] Fixes in Makefile of couple of samples - modified Makefile for hipblas_saxpy to replaced hcblas.so with hipblas.so as part of HCSWAP-100 - Resolved missing separator issue in peer2peer cookbook Makefile Change-Id: I678fea267eee1481f02da09379339ed78d3f95f2 [ROCm/hip commit: d78649b9787e083705d3e67dd406dd9da5ff42c6] --- .../hip/samples/2_Cookbook/8_peer2peer/Makefile | 13 +++++++------ .../hip/samples/7_Advanced/hipblas_saxpy/Makefile | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/projects/hip/samples/2_Cookbook/8_peer2peer/Makefile b/projects/hip/samples/2_Cookbook/8_peer2peer/Makefile index 5cb7473921..0bf9e6f93e 100644 --- a/projects/hip/samples/2_Cookbook/8_peer2peer/Makefile +++ b/projects/hip/samples/2_Cookbook/8_peer2peer/Makefile @@ -1,6 +1,6 @@ HIP_PATH?= $(wildcard /opt/rocm/hip) ifeq (,$(HIP_PATH)) - HIP_PATH=../../.. + HIP_PATH=../../.. endif HIPCC=$(HIP_PATH)/bin/hipcc @@ -22,14 +22,15 @@ CXX=$(HIPCC) $(EXECUTABLE): $(OBJECTS) - $(HIPCC) $(OBJECTS) -o $@ + $(HIPCC) $(OBJECTS) -o $@ + test: $(EXECUTABLE) - $(EXECUTABLE) + $(EXECUTABLE) clean: -rm -f $(EXECUTABLE) -rm -f $(OBJECTS) -rm -f $(HIP_PATH)/src/*.o + rm -f $(EXECUTABLE) + rm -f $(OBJECTS) + rm -f $(HIP_PATH)/src/*.o diff --git a/projects/hip/samples/7_Advanced/hipblas_saxpy/Makefile b/projects/hip/samples/7_Advanced/hipblas_saxpy/Makefile index ed88be2dd0..8586e75d25 100644 --- a/projects/hip/samples/7_Advanced/hipblas_saxpy/Makefile +++ b/projects/hip/samples/7_Advanced/hipblas_saxpy/Makefile @@ -12,7 +12,7 @@ endif ifeq (${HIP_PLATFORM}, hcc) HCBLAS_ROOT?= $(wildcard /opt/rocm/hcblas) HIPCC_FLAGS += -stdlib=libc++ -I$(HCBLAS_ROOT)/include - LIBS = -L$(HCBLAS_ROOT)/lib -lhcblas + LIBS = -L$(HCBLAS_ROOT)/lib -lhipblas -rpath $(HIP_PATH)/lib endif From 727aab2304205750ecbf6fe1af84be240fa0786f Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Wed, 14 Dec 2016 14:18:48 -0600 Subject: [PATCH 011/281] added half2 support Change-Id: I0f3b9b7037fed97e80ec99f5369c75a63f001aae [ROCm/hip commit: d2daf6ad75a2c4496ea8e18f17cfe97f6f31c2aa] --- .../hip/include/hip/hcc_detail/hip_fp16.h | 21 +++++++++++++++++-- projects/hip/src/hip_fp16.cpp | 3 ++- projects/hip/src/hip_ir.ll | 5 +++++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/hip_fp16.h b/projects/hip/include/hip/hcc_detail/hip_fp16.h index 5acf114518..3b03174708 100644 --- a/projects/hip/include/hip/hcc_detail/hip_fp16.h +++ b/projects/hip/include/hip/hcc_detail/hip_fp16.h @@ -27,20 +27,30 @@ THE SOFTWARE. #define __CLANG_VERSION__ __clang_major__ * 10 + __clang_minor__ -#ifdef HIP_HALF_HW_SUPPORT +#if __CLANG_VERSION__ == 40 typedef __fp16 __half; + +typedef struct __attribute__((aligned(4))){ + int a; +} __half2; + extern "C" __half __hip_hadd_gfx803(__half a, __half b); extern "C" __half __hip_hfma_gfx803(__half a, __half b); extern "C" __half __hip_hmul_gfx803(__half a, __half b); extern "C" __half __hip_hsub_gfx803(__half a, __half b); +extern "C" int __hip_hadd2_gfx803(int a, int b); +extern "C" int __hip_hfma2_gfx803(int a, int b); +extern "C" int __hip_hmul2_gfx803(int a, int b); +extern "C" int __hip_hsub2_gfx803(int a, int b); + __device__ inline __half __hadd(__half a, __half b) { return __hip_hadd_gfx803(a, b); } __device__ inline __half __hadd_sat(__half a, __half b) { - return __hip_add_gfx803(a, b); + return __hip_hadd_gfx803(a, b); } __device__ inline __half __hfma(__half a, __half b) { @@ -67,6 +77,13 @@ __device__ inline __half __hsub_sat(__half a, __half b) { return __hip_hsub_gfx803(a, b); } + +__device__ inline __half2 __hadd2(__half2 a, __half2 b) { + __half2 ret; + ret.a = __hip_hadd2_gfx803(a.a, b.a); + return ret; +} + #else typedef struct{ diff --git a/projects/hip/src/hip_fp16.cpp b/projects/hip/src/hip_fp16.cpp index 63d91eb107..3bf6bd395f 100644 --- a/projects/hip/src/hip_fp16.cpp +++ b/projects/hip/src/hip_fp16.cpp @@ -22,6 +22,7 @@ THE SOFTWARE. #include"hip/hip_fp16.h" +#if __CLANG_VERSION__ == 35 static const unsigned sign_val = 0x8000; static const __half __half_value_one_float = {0x3C00}; @@ -373,4 +374,4 @@ __device__ __half2 __lowhigh2highlow(const __half2 a){ __device__ __half2 __low2half2(const __half2 a, const __half2 b){ return {a.q, b.q}; } - +#endif diff --git a/projects/hip/src/hip_ir.ll b/projects/hip/src/hip_ir.ll index 623be19084..831c4159f0 100644 --- a/projects/hip/src/hip_ir.ll +++ b/projects/hip/src/hip_ir.ll @@ -54,4 +54,9 @@ define linkonce_odr spir_func half @__hip_hsub_gfx803(half %a, half %b) #1 { ret half %val } +define linkonce_odr spir_func i32 @__hip_hadd2_gfx803(i32 %a i32 %b) #1 { + %val = tail call i32 asm "v_add_f16_sdwa $0, $1, $2 dst_sel:WORD_0 dst_unused:UNUSED_PRESERVE src0_sel:WORD_0 src1_sel:WORD_0","=v,v,v"(i32 %a, i32 %b) + ret i32 %val +} + attributes #1 = { alwaysinline nounwind } From 4ebb6e569ff0fa5da9fca5a0e8a76ea94307820e Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Wed, 14 Dec 2016 16:50:16 -0600 Subject: [PATCH 012/281] fixed compilation issues Change-Id: I96692538736e2e4f2da9dba9c8c29a164aec4c0d [ROCm/hip commit: 68c57c38ffe899d355511741e543d899edd425c5] --- projects/hip/include/hip/hcc_detail/hip_fp16.h | 2 +- projects/hip/src/hip_ir.ll | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/hip_fp16.h b/projects/hip/include/hip/hcc_detail/hip_fp16.h index 3b03174708..fb6cd0a44c 100644 --- a/projects/hip/include/hip/hcc_detail/hip_fp16.h +++ b/projects/hip/include/hip/hcc_detail/hip_fp16.h @@ -27,7 +27,7 @@ THE SOFTWARE. #define __CLANG_VERSION__ __clang_major__ * 10 + __clang_minor__ -#if __CLANG_VERSION__ == 40 +#ifdef HIP_HALF_HW_SUPPORT typedef __fp16 __half; diff --git a/projects/hip/src/hip_ir.ll b/projects/hip/src/hip_ir.ll index 831c4159f0..4b7bd3b10e 100644 --- a/projects/hip/src/hip_ir.ll +++ b/projects/hip/src/hip_ir.ll @@ -54,7 +54,7 @@ define linkonce_odr spir_func half @__hip_hsub_gfx803(half %a, half %b) #1 { ret half %val } -define linkonce_odr spir_func i32 @__hip_hadd2_gfx803(i32 %a i32 %b) #1 { +define linkonce_odr spir_func i32 @__hip_hadd2_gfx803(i32 %a, i32 %b) #1 { %val = tail call i32 asm "v_add_f16_sdwa $0, $1, $2 dst_sel:WORD_0 dst_unused:UNUSED_PRESERVE src0_sel:WORD_0 src1_sel:WORD_0","=v,v,v"(i32 %a, i32 %b) ret i32 %val } From beb82e510994ca38c69f8ba5956f02487207ee47 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Tue, 13 Dec 2016 23:48:04 +0100 Subject: [PATCH 013/281] Fixes a typo: perforamnce -> performance Change-Id: I85e3b3d22c98c16556227283bfb33530e1bce2cf [ROCm/hip commit: 961b7890c194e1236cee89e1a97b6d463108ef7b] --- projects/hip/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/hip/README.md b/projects/hip/README.md index 83d041786e..802bed75b3 100644 --- a/projects/hip/README.md +++ b/projects/hip/README.md @@ -89,7 +89,7 @@ The HIP Runtime API code and compute kernel definition can exist in the same sou ## HIP Portability and Compiler Technology HIP C++ code can be compiled with either : - On the Nvidia CUDA platform, HIP provides header file which translate from the HIP runtime APIs to CUDA runtime APIs. The header file contains mostly inlined - functions and thus has very low overhead - developers coding in HIP should expect the same perforamnce as coding in native CUDA. The code is then + functions and thus has very low overhead - developers coding in HIP should expect the same performance as coding in native CUDA. The code is then compiled with nvcc, the standard C++ compiler provided with the CUDA SDK. Developers can use any tools supported by the CUDA SDK including the CUDA profiler and debugger. - On the AMD ROCm platform, HIP provides a header and runtime library built on top of hcc compiler. The HIP runtime implements HIP streams, events, and memory APIs, From d3ca48fc455fbabfe9d2c2282df737b298148e5e Mon Sep 17 00:00:00 2001 From: Martin Schleiss Date: Wed, 14 Dec 2016 00:13:30 +0100 Subject: [PATCH 014/281] Fix various typos Conflicts: README.md Change-Id: Ie296d503d16121a62fed1a208352ec2b81c97fd9 [ROCm/hip commit: 263dcfed834b73760def2df4816c2bbc8bf17706] --- projects/hip/CONTRIBUTING.md | 6 +++--- projects/hip/README.md | 4 ++-- projects/hip/RELEASE.md | 4 ++-- projects/hip/docs/markdown/hip_kernel_language.md | 2 +- projects/hip/docs/markdown/hip_porting_driver_api.md | 6 +++--- projects/hip/docs/markdown/hip_porting_guide.md | 2 +- projects/hip/docs/markdown/hip_terms2.md | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/projects/hip/CONTRIBUTING.md b/projects/hip/CONTRIBUTING.md index f6ed47acef..81c4bc8c32 100644 --- a/projects/hip/CONTRIBUTING.md +++ b/projects/hip/CONTRIBUTING.md @@ -93,7 +93,7 @@ Differences or limitations of HIP APIs as compared to CUDA APIs should be clearl ## Coding Guidelines (in brief) - Code Indentation: - Tabs should be expanded to spaces. - - Use 4 spaces indendation. + - Use 4 spaces indentation. - Capitalization and Naming - Prefer camelCase for HIP interfaces and internal symbols. Note HCC uses _ for separator. This guideline is not yet consistently followed in HIP code - eventual compliance is aspirational. @@ -120,7 +120,7 @@ Differences or limitations of HIP APIs as compared to CUDA APIs should be clearl - HIP_INIT_API() should be placed at the start of each top-level HIP API. This function will make sure the HIP runtime is initialized, and also constructs an appropriate API string for tracing and CodeXL marker tracing. The arguments to HIP_INIT_API should match - those of the parent fucntion. + those of the parent function. - ihipLogStatus should only be called from top-level HIP APIs,and should be called to log and return the error code. The error code is used by the GetLastError and PeekLastError functions - if a HIP API simply returns, then the error will not be logged correctly. @@ -161,4 +161,4 @@ doxygen bug list. ## Other Tips: ### Markdown Editing -Recommended to use an offline Markown viewer to review documentation, such as Markdown Preview Plus extension in Chrome browser, or Remarkable. +Recommended to use an offline Markdown viewer to review documentation, such as Markdown Preview Plus extension in Chrome browser, or Remarkable. diff --git a/projects/hip/README.md b/projects/hip/README.md index 802bed75b3..f61c3b106a 100644 --- a/projects/hip/README.md +++ b/projects/hip/README.md @@ -88,7 +88,7 @@ The HIP Runtime API code and compute kernel definition can exist in the same sou ## HIP Portability and Compiler Technology HIP C++ code can be compiled with either : -- On the Nvidia CUDA platform, HIP provides header file which translate from the HIP runtime APIs to CUDA runtime APIs. The header file contains mostly inlined +- On the NVIDIA CUDA platform, HIP provides header file which translate from the HIP runtime APIs to CUDA runtime APIs. The header file contains mostly inlined functions and thus has very low overhead - developers coding in HIP should expect the same performance as coding in native CUDA. The code is then compiled with nvcc, the standard C++ compiler provided with the CUDA SDK. Developers can use any tools supported by the CUDA SDK including the CUDA profiler and debugger. @@ -120,7 +120,7 @@ make ## More Examples -The GitHub repot [HIP-Examples](https://github.com/GPUOpen-ProfessionalCompute-Tools/HIP-Examples.git) contains a hipified vesion of the popular Rodinia benchmark suite. +The GitHub repository [HIP-Examples](https://github.com/GPUOpen-ProfessionalCompute-Tools/HIP-Examples.git) contains a hipified version of the popular Rodinia benchmark suite. The README with the procedures and tips the team used during this porting effort is here: [Rodinia Porting Guide](https://github.com/GPUOpen-ProfessionalCompute-Tools/HIP-Examples/blob/master/rodinia_3.0/hip/README.hip_porting) ## Tour of the HIP Directories diff --git a/projects/hip/RELEASE.md b/projects/hip/RELEASE.md index a7c770f611..34eab60833 100644 --- a/projects/hip/RELEASE.md +++ b/projects/hip/RELEASE.md @@ -3,7 +3,7 @@ We have attempted to document known bugs and limitations - in particular the [HIP Kernel Language](docs/markdown/hip_kernel_language.md) document uses the phrase "Under Development", and the [HIP Runtime API bug list](http://gpuopen-professionalcompute-tools.github.io/HIP/bug.html) lists known bugs. Upcoming: -- Stability: Enforce perioidic host synchronization to reclaim resources if the application has launched a large +- Stability: Enforce periodic host synchronization to reclaim resources if the application has launched a large number of commands (>1K) without synchronizing. - Register keyword now silently ignored on HCC (previously would emit warning). - Doc updates: Add some more frequently asked questions to FAQ, fix TOC in some files, review. @@ -73,7 +73,7 @@ Date: 2016.04.25 - Create static library and link. - Set HIP_PATH to install. - Make hipDevice and hipStream thread-safe. - - Prefered hipStream usage is still to create new streams for each new thread, but it works even if you don;t. + - Preferred hipStream usage is still to create new streams for each new thread, but it works even if you don;t. - Improve automated platform detection: If AMD GPU is installed and detected by driver, default HIP_PLATFORM to hcc. - HIP_TRACE_API now prints arguments to the HIP function (in addition to name of function). - Deprecate hipDeviceGetProp (Replace with hipGetDeviceProp) diff --git a/projects/hip/docs/markdown/hip_kernel_language.md b/projects/hip/docs/markdown/hip_kernel_language.md index f84868987c..3fd4ea9aca 100644 --- a/projects/hip/docs/markdown/hip_kernel_language.md +++ b/projects/hip/docs/markdown/hip_kernel_language.md @@ -105,7 +105,7 @@ HIP parses the `__noinline__` and `__forceinline__` keywords and converts them t ``` -// Example psuedocode introducing hipLaunchKernel: +// Example pseudo code introducing hipLaunchKernel: __global__ MyKernel(hipLaunchParm lp, float *A, float *B, float *C, size_t N) { ... diff --git a/projects/hip/docs/markdown/hip_porting_driver_api.md b/projects/hip/docs/markdown/hip_porting_driver_api.md index b0ac3ecf1d..5093291baa 100644 --- a/projects/hip/docs/markdown/hip_porting_driver_api.md +++ b/projects/hip/docs/markdown/hip_porting_driver_api.md @@ -31,8 +31,8 @@ accelerator language front-end. Here, NVCC is not used. Instead, the environm different kernel language or different compilation flow. Other environments have many kernels and do not want them to be all loaded automatically. The Module functions can be used to load the generated code objects and launch kernels. -As we will see below, HIP defines a Module API which provides similar explict control over code -object managemenet. +As we will see below, HIP defines a Module API which provides similar explicit control over code +object management. ### cuCtx API The Driver API defines "Context" and "Devices" as separate entities. @@ -144,7 +144,7 @@ table shows the type equivalence to enable this interaction. The hipModule interface does not support the hipModuleLoadEx function, which is used to control PTX compilaton options. HCC does not use PTX and does not support the same compilation options. In fact, HCC code objects always contain fully compiled ISA and do not require additional compilation as part of the load step. -Code which requires this functionaly should use platform-specific coding, calling `cuModuleLoadEx` +Code which requires this functionally should use platform-specific coding, calling `cuModuleLoadEx` on the NVCC path and hipModuleLoad on the hcc path. For example: ``` diff --git a/projects/hip/docs/markdown/hip_porting_guide.md b/projects/hip/docs/markdown/hip_porting_guide.md index c530df5098..e0e74c0f89 100644 --- a/projects/hip/docs/markdown/hip_porting_guide.md +++ b/projects/hip/docs/markdown/hip_porting_guide.md @@ -1,5 +1,5 @@ # HIP Porting Guide -In addition to providing a portable C++ programmming environement for GPUs, HIP is designed to ease +In addition to providing a portable C++ programming environment for GPUs, HIP is designed to ease the porting of existing CUDA code into the HIP environment. This section describes the available tools and provides practical suggestions on how to port CUDA code and work through common issues. diff --git a/projects/hip/docs/markdown/hip_terms2.md b/projects/hip/docs/markdown/hip_terms2.md index 9603807925..be859ffb32 100644 --- a/projects/hip/docs/markdown/hip_terms2.md +++ b/projects/hip/docs/markdown/hip_terms2.md @@ -13,7 +13,7 @@ The default device can be set with hipSetDevice. - hcc = Heterogeneous Compute Compiler (https://bitbucket.org/multicoreware/hcc/wiki/Home). - hipify - tool to convert CUDA(R) code to portable C++ code. -- hipconfig - tool to report various confoguration properties of the target platform. +- hipconfig - tool to report various configuration properties of the target platform. - nvcc = nvcc compiler, do not capitalize. - hcc = heterogeneous compute compiler, do not capitalize. From 92dae66b21649b4f3bd98971eab6b6eb389c586a Mon Sep 17 00:00:00 2001 From: Martin Schleiss Date: Wed, 14 Dec 2016 00:18:13 +0100 Subject: [PATCH 015/281] Fix another typo [ROCm/hip commit: b1eace4348c9bfdadc1f94103c4b15517e902b33] --- projects/hip/docs/markdown/hip_faq.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/hip/docs/markdown/hip_faq.md b/projects/hip/docs/markdown/hip_faq.md index 70ad94ba43..7a41e38bd4 100644 --- a/projects/hip/docs/markdown/hip_faq.md +++ b/projects/hip/docs/markdown/hip_faq.md @@ -107,7 +107,7 @@ However, we can provide a rough summary of the features included in each CUDA SD ### What libraries does HIP support? HIP includes growing support for the 4 key math libraries using hcBlas, hcFft, hcrng, and hcsparse). -These offer pointer-based memory interfaces (as opposed to opaque buffers) and can be easily interfaces with other HCC code. Developers should use conditional compliation if portability to nvcc systems is desired - using calls to cu* routines on one path and hc* routines on the other. +These offer pointer-based memory interfaces (as opposed to opaque buffers) and can be easily interfaces with other HCC code. Developers should use conditional compilation if portability to nvcc systems is desired - using calls to cu* routines on one path and hc* routines on the other. - [hcblas](https://bitbucket.org/multicoreware/hcblas) - [hcfft](https://bitbucket.org/multicoreware/hcfft) @@ -132,7 +132,7 @@ HIP offers several benefits over OpenCL: Both HIP and CUDA are dialects of C++, and thus porting between them is relatively straightforward. Both dialects support templates, classes, lambdas, and other C++ constructs. As one example, the hipify tool was originally a perl script that used simple text conversions from CUDA to HIP. -HIP and CUDA provide similar math library calls as well. In summary, the HIP philospohy was to make the HIP language close enough to CUDA that the porting effort is relatively simple. +HIP and CUDA provide similar math library calls as well. In summary, the HIP philosophy was to make the HIP language close enough to CUDA that the porting effort is relatively simple. This reduces the potential for error, and also makes it easy to automate the translation. HIP's goal is to quickly get the ported program running on both platforms with little manual intervention, so that the programmer can focus on performance optimizations. From fd99cec62debf6c87b2b2889bd019c9480c124ee Mon Sep 17 00:00:00 2001 From: Brecht Carlier Date: Wed, 14 Dec 2016 21:41:21 +0100 Subject: [PATCH 016/281] Update hip_faq.md Fixed navigation and list. [ROCm/hip commit: 05b3e2928d367723cc6c832854ad495863605499] --- projects/hip/docs/markdown/hip_faq.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/projects/hip/docs/markdown/hip_faq.md b/projects/hip/docs/markdown/hip_faq.md index 7a41e38bd4..0b79976988 100644 --- a/projects/hip/docs/markdown/hip_faq.md +++ b/projects/hip/docs/markdown/hip_faq.md @@ -10,7 +10,7 @@ - [What specific version of CUDA does HIP support?](#what-specific-version-of-cuda-does-hip-support) - [What libraries does HIP support?](#what-libraries-does-hip-support) - [How does HIP compare with OpenCL?](#how-does-hip-compare-with-opencl) -- [How does porting CUDA to HIP compare to porting CUDA to OpenCL?] +- [How does porting CUDA to HIP compare to porting CUDA to OpenCL?](#how-does-porting-cuda-to-hip-compare-to-porting-cuda-to-opencl) - [What hardware does HIP support?](#what-hardware-does-hip-support) - [Does Hipify automatically convert all source code?](#does-hipify-automatically-convert-all-source-code) - [What is NVCC?](#what-is-nvcc) @@ -53,7 +53,6 @@ At a high-level, the following features are not supported: - Graphics interoperation with OpenGL or Direct3D - CUDA Driver API (Under Development) - CUDA IPC Functions (Under Development) - - CUDA array, mipmappedArray and pitched memory - MemcpyToSymbol functions - Queue priority controls @@ -196,8 +195,8 @@ HIP will set the platform to HCC if it sees that the AMD graphics driver is inst Sometimes this isn't what you want - you can force HIP to recognize the platform by setting HIP_PLATFORM to hcc (or nvcc) ``` export HIP_PLATFORM=hcc - ``` + One symptom of this problem is the message "error: 'unknown error'(11) at square.hipref.cpp:56". This can occur if you have a CUDA installation on an AMD platform, and HIP incorrectly detects the platform as nvcc. HIP may be able to compile the application using the nvcc tool-chain, but will generate this error at runtime since the platform does not have a CUDA device. The fix is to set HIP_PLATFORM=hcc and rebuild the issue. If you see issues related to incorrect platform detection, please file an issue with the GitHub issue tracker so we can improve HIP's platform detection logic. From e29cc18289704cce7756ec1c5657e70183edb4db Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Thu, 15 Dec 2016 21:00:34 +0300 Subject: [PATCH 017/281] [HIPIFY] nested macro is not hipified, when it isAnyIdentifier Fix for https://github.com/GPUOpen-ProfessionalCompute-Tools/HIP/issues/55 [ROCm/hip commit: 2383d9bc1a6049e1257fe8bffba5cacf3d797c8b] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index 4f37bb9365..064f4ad4e1 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -1465,11 +1465,11 @@ public: // to workaround the 'const' MacroArgs passed into this hook. const Token *start = Args->getUnexpArgument(i); size_t len = Args->getArgLength(start) + 1; - #if (LLVM_VERSION_MAJOR >= 3) && (LLVM_VERSION_MINOR >= 9) +#if (LLVM_VERSION_MAJOR >= 3) && (LLVM_VERSION_MINOR >= 9) _pp->EnterTokenStream(ArrayRef(start, len), false); - #else +#else _pp->EnterTokenStream(start, len, false, false); - #endif +#endif do { toks.push_back(Token()); Token &tk = toks.back(); @@ -1489,8 +1489,17 @@ public: << " found as an actual argument in expansion of macro " << macroName << "\n" << "will be replaced with: " << repName << "\n"); + size_t length = name.size(); SourceLocation sl = tok.getLocation(); - Replacement Rep(*_sm, sl, name.size(), repName); + if (_sm->isMacroBodyExpansion(sl)) { + LangOptions DefaultLangOptions; + SourceLocation sl_macro = _sm->getExpansionLoc(sl); + SourceLocation sl_end = Lexer::getLocForEndOfToken(sl_macro, 0, *_sm, DefaultLangOptions); + length = _sm->getCharacterData(sl_end) - _sm->getCharacterData(sl_macro); + name = StringRef(_sm->getCharacterData(sl_macro), length); + sl = sl_macro; + } + Replacement Rep(*_sm, sl, length, repName); Replace->insert(Rep); } } else if (tok.isLiteral()) { From 89523da1c2277dbd9311575230587c532d8990ca Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Thu, 15 Dec 2016 14:41:27 -0600 Subject: [PATCH 018/281] remove TODO file [ROCm/hip commit: 4080fe209db9e40eb92f3641746c4494886b3efd] --- .../hip/samples/1_Utils/hipCommander/TODO | 50 ------------------- 1 file changed, 50 deletions(-) delete mode 100644 projects/hip/samples/1_Utils/hipCommander/TODO diff --git a/projects/hip/samples/1_Utils/hipCommander/TODO b/projects/hip/samples/1_Utils/hipCommander/TODO deleted file mode 100644 index 4c835cfced..0000000000 --- a/projects/hip/samples/1_Utils/hipCommander/TODO +++ /dev/null @@ -1,50 +0,0 @@ -_ Add AQL kernel. -_ Fix &*kernel command so the kernel name/type is an argument not a new command. - -_ Add command to parse only. -_ Add regression to parse all the hcm files. - -_ Partition HCC, HIP, HSA, OpenCL commands into separate files. - - -_ Show time for back-to-back copies. -_ Add variables. - %loopcnt - - ./hipCommander %loopcnt=4 - -_ Add datasize command. - - -_ Add ( ) to parsing. -_ Add argument parsing and checking. - -_ Add verbose option to print each step of setup. - - print deliniater between setup and run. Add run start message. - - - print sizes of all buffers. - - print each command before running. - - show start/stop of timer routine. - -_ -_ Clear documentation on what each oepration does. -_ Add time instrumentation for each command. -_ Add pcie atomic. - - -_ Add tests for negative cases, ie endloop w/o opening loop. - - -README tips ---- -- HIP_API_TRACE combined with -v is useful to track the exact commands generates by hipCommander. - - -Other ideas: ---- -[ ] Perf guide : stream creation very slow on HCC and should be avoided. - - -Scratch: - - From 5a3c11dd9aff6ac474035af8aa40160b40540f59 Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Thu, 15 Dec 2016 14:42:02 -0600 Subject: [PATCH 019/281] fix copyright [ROCm/hip commit: 8ed38bae692ce1cd67dee54fcf71a78a0e97b2ae] --- projects/hip/src/device_util.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/projects/hip/src/device_util.cpp b/projects/hip/src/device_util.cpp index 7efb12d2d0..5452e1c905 100644 --- a/projects/hip/src/device_util.cpp +++ b/projects/hip/src/device_util.cpp @@ -14,7 +14,8 @@ all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ From 70f125f2a82c4141bd23019ba022c18483fe8443 Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Thu, 15 Dec 2016 14:42:27 -0600 Subject: [PATCH 020/281] Fix typo [ROCm/hip commit: bd19bb4074591e2aa6865b7689dda2884033cdb0] --- projects/hip/docs/markdown/hip_profiling.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/hip/docs/markdown/hip_profiling.md b/projects/hip/docs/markdown/hip_profiling.md index 21133100ec..0c55acf85e 100644 --- a/projects/hip/docs/markdown/hip_profiling.md +++ b/projects/hip/docs/markdown/hip_profiling.md @@ -335,7 +335,7 @@ HIP provides 3 environment variables in the HIP_*_BLOCKING family. These introd These options cause HCC to serialize. Useful if you have libraries or code which is calling HCC kernels directly rather than using HIP. - HCC_SERIALZIE_KERNELS : 0x1=pre-serialize before each kernel launch, 0x2=post-serialize after each kernel launch., 0x3= pre- and post- serialize. -- HCC_SERIALIZE_COPY : 0x1=pre-serialize before each async copy, 0x2=post-serialize after each async copy., 0x3= pre- and post- serialize.0 +- HCC_SERIALIZE_COPY : 0x1=pre-serialize before each async copy, 0x2=post-serialize after each async copy., 0x3= pre- and post- serialize. - HSA_ENABLE_SDMA=0 : Causes host-to-device and device-to-host copies to use compute shader blit kernels rather than the dedicated DMA copy engines. Compute shader copies have low latency (typically < 5us) and can achieve approximately 80% of the bandwidth of the DMA copy engine. This flag is useful to isolate issues with the hardware copy engines. - HSA_ENABLE_INTERRUPT=0 : Causes completion signals to be detected with memory-based polling rather than interrupts. Can be useful to diagnose interrupt storm issues in the driver. From fcdaa05a4d70569412164391efb86bb72ac7ccfe Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Fri, 16 Dec 2016 08:55:11 -0600 Subject: [PATCH 021/281] Print limits on CUDA devices [ROCm/hip commit: 43635f51dc5448386c32f471b51e6088bf9e732d] --- .../hip/samples/1_Utils/hipInfo/hipInfo.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/projects/hip/samples/1_Utils/hipInfo/hipInfo.cpp b/projects/hip/samples/1_Utils/hipInfo/hipInfo.cpp index 42a879e732..cf4660eae7 100644 --- a/projects/hip/samples/1_Utils/hipInfo/hipInfo.cpp +++ b/projects/hip/samples/1_Utils/hipInfo/hipInfo.cpp @@ -63,6 +63,14 @@ double bytesToGB(size_t s) return (double)s / (1024.0*1024.0*1024.0); } +#define printLimit(w1, limit, units) \ +{\ + size_t val;\ + cudaDeviceGetLimit(&val, limit);\ + std::cout << setw(w1) << #limit": " << val << " " << units << std::endl;\ +} + + void printDeviceProp (int deviceId) { using namespace std; @@ -144,6 +152,17 @@ void printDeviceProp (int deviceId) cout << endl; +#ifdef __HIP_PLATFORM_NVCC__ + // Limits: + cout << endl; + printLimit(w1, cudaLimitStackSize, "bytes/thread"); + printLimit(w1, cudaLimitPrintfFifoSize, "bytes/device"); + printLimit(w1, cudaLimitMallocHeapSize, "bytes/device"); + printLimit(w1, cudaLimitDevRuntimeSyncDepth, "grids"); + printLimit(w1, cudaLimitDevRuntimePendingLaunchCount, "launches"); +#endif + + cout << endl; From d93219fc0070350e4706296c7be416db28c9c572 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Fri, 16 Dec 2016 09:24:59 -0600 Subject: [PATCH 022/281] disabled half native support as inline asm is not working Change-Id: I3073d8ae39eed321987f0f2f0e689eec4cdbb48c [ROCm/hip commit: 2665ad2762ccb3c58f4ca1e62431af6e411f1920] --- .../hip/include/hip/hcc_detail/hip_fp16.h | 4 +- projects/hip/src/hip_fp16.cpp | 3 -- projects/hip/src/hip_ir.ll | 45 ------------------- 3 files changed, 1 insertion(+), 51 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/hip_fp16.h b/projects/hip/include/hip/hcc_detail/hip_fp16.h index fb6cd0a44c..d51a5d1fcd 100644 --- a/projects/hip/include/hip/hcc_detail/hip_fp16.h +++ b/projects/hip/include/hip/hcc_detail/hip_fp16.h @@ -25,9 +25,7 @@ THE SOFTWARE. #include "hip/hip_runtime.h" -#define __CLANG_VERSION__ __clang_major__ * 10 + __clang_minor__ - -#ifdef HIP_HALF_HW_SUPPORT +#if 0 typedef __fp16 __half; diff --git a/projects/hip/src/hip_fp16.cpp b/projects/hip/src/hip_fp16.cpp index 3bf6bd395f..1a9d04474f 100644 --- a/projects/hip/src/hip_fp16.cpp +++ b/projects/hip/src/hip_fp16.cpp @@ -22,8 +22,6 @@ THE SOFTWARE. #include"hip/hip_fp16.h" -#if __CLANG_VERSION__ == 35 - static const unsigned sign_val = 0x8000; static const __half __half_value_one_float = {0x3C00}; static const __half __half_value_zero_float = {0x0}; @@ -374,4 +372,3 @@ __device__ __half2 __lowhigh2highlow(const __half2 a){ __device__ __half2 __low2half2(const __half2 a, const __half2 b){ return {a.q, b.q}; } -#endif diff --git a/projects/hip/src/hip_ir.ll b/projects/hip/src/hip_ir.ll index 4b7bd3b10e..472038df6a 100644 --- a/projects/hip/src/hip_ir.ll +++ b/projects/hip/src/hip_ir.ll @@ -12,51 +12,6 @@ define linkonce_odr spir_func void @__threadfence_block() #1 { ret void } -define linkonce_odr spir_func i32 @__rocm_dp4a(i32 %in1, i32 %in2, i32 %in3) { - %val1 = tail call i32 asm "v_mul_u32_u24_sdwa $0, $1, $2 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:BYTE_0 src1_sel:BYTE_0","=v,v,v"(i32 %in1, i32 %in2) - %ret1 = add i32 %val1, %in3 - %val2 = tail call i32 asm "v_mul_u32_u24_sdwa $0, $1, $2 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:BYTE_1 src1_sel:BYTE_1","=v,v,v"(i32 %in1, i32 %in2) - %ret2 = add i32 %ret1, %val2 - %val3 = tail call i32 asm "v_mul_u32_u24_sdwa $0, $1, $2 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:BYTE_2 src1_sel:BYTE_2","=v,v,v"(i32 %in1, i32 %in2) - %ret3 = add i32 %val3, %ret2 - %val4 = tail call i32 asm "v_mul_u32_u24_sdwa $0, $1, $2 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:BYTE_3 src1_sel:BYTE_3","=v,v,v"(i32 %in1, i32 %in2) - %ret4 = add i32 %val4, %ret3 - ret i32 %ret4 -} -define linkonce_odr spir_func i32 @__rocm_hfma(i32 %in1, i32 %in2, i32 %in3) { - tail call void asm "v_mac_f16 $0, $1, $2","v,v,v"(i32 %in1, i32 %in2, i32 %in3) - ret i32 %in3 -} - -define linkonce_odr spir_func i32 @__rocm_hadd(i32 %in1, i32 %in2) { - %val = tail call i32 asm "v_add_f16 $0, $1, $2","=v,v,v"(i32 %in1, i32 %in2) - ret i32 %val -} - -define linkonce_odr spir_func half @__hip_hadd_gfx803(half %a, half %b) #1 { - %val = tail call half asm "v_add_f16 $0, $1, $2","=v,v,v"(half %a, half %b) - ret half %val -} - -define linkonce_odr spir_func half @__hip_hfma_gfx803(half %a, half %b, half %c) #1 { - %val = tail call half asm "v_fma_f16 $0, $1, $2, $3","=v,v,v,v"(half %a, half %b, half %c) - ret half %val -} - -define linkonce_odr spir_func half @__hip_hmul_gfx803(half %a, half %b) #1 { - %val = tail call half asm "v_mul_f16 $0, $1, $2","=v,v,v"(half %a, half %b) - ret half %val -} - -define linkonce_odr spir_func half @__hip_hsub_gfx803(half %a, half %b) #1 { - %val = tail call half asm "v_sub_f16 $0, $1, $2","=v,v,v"(half %a, half %b) - ret half %val -} - -define linkonce_odr spir_func i32 @__hip_hadd2_gfx803(i32 %a, i32 %b) #1 { - %val = tail call i32 asm "v_add_f16_sdwa $0, $1, $2 dst_sel:WORD_0 dst_unused:UNUSED_PRESERVE src0_sel:WORD_0 src1_sel:WORD_0","=v,v,v"(i32 %a, i32 %b) - ret i32 %val -} attributes #1 = { alwaysinline nounwind } From ae83f93ba484e5102049b56cfe1bd3b8c2edc222 Mon Sep 17 00:00:00 2001 From: Rahul Garg Date: Sat, 17 Dec 2016 16:53:03 +0530 Subject: [PATCH 023/281] Mapped hipDevice_t to int Change-Id: I6cfa56c42b7cd04aa0e0bce510c0d72d34ea211a [ROCm/hip commit: 263a9614ffa4ca9f658a9013a3c072fdccb76bdf] --- .../include/hip/hcc_detail/hip_runtime_api.h | 14 +-------- projects/hip/src/hip_context.cpp | 14 +++++---- projects/hip/src/hip_device.cpp | 30 +++++-------------- projects/hip/tests/src/hipDrvGetPCIBusId.cpp | 3 +- 4 files changed, 20 insertions(+), 41 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h index 52e59ed17a..b2cfa59d71 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h @@ -53,7 +53,7 @@ extern "C" { typedef struct ihipCtx_t *hipCtx_t; // Note many APIs also use integer deviceIds as an alternative to the device pointer: -typedef struct ihipDevice_t *hipDevice_t; +typedef int hipDevice_t; typedef struct ihipStream_t *hipStream_t; @@ -1904,18 +1904,6 @@ hipError_t hipIpcCloseMemHandle(void *devPtr); } /* extern "c" */ #endif -#ifdef __cplusplus -/** - * @brief Returns a PCI Bus Id string for the device. - * @param [out] pciBusId - * @param [in] len - * @param [hipDevice_t] device - * - * @returns #hipSuccess, #hipErrorInavlidDevice - */ -hipError_t hipDeviceGetPCIBusId (char *pciBusId,int len,hipDevice_t device); -#endif - /** *------------------------------------------------------------------------------------------------- *------------------------------------------------------------------------------------------------- diff --git a/projects/hip/src/hip_context.cpp b/projects/hip/src/hip_context.cpp index 8a2451671c..b38a6c3b74 100644 --- a/projects/hip/src/hip_context.cpp +++ b/projects/hip/src/hip_context.cpp @@ -57,8 +57,8 @@ hipError_t hipCtxCreate(hipCtx_t *ctx, unsigned int flags, hipDevice_t device) { HIP_INIT_API(ctx, flags, device); // FIXME - review if we want to init hipError_t e = hipSuccess; - - *ctx = new ihipCtx_t(device, g_deviceCnt, flags); + auto deviceHandle = ihipGetDevice(device); + *ctx = new ihipCtx_t(deviceHandle, g_deviceCnt, flags); ihipSetTlsDefaultCtx(*ctx); tls_ctxStack.push(*ctx); @@ -69,11 +69,13 @@ hipError_t hipDeviceGet(hipDevice_t *device, int deviceId) { HIP_INIT_API(device, deviceId); // FIXME - review if we want to init - *device = ihipGetDevice(deviceId); + auto deviceHandle = ihipGetDevice(deviceId); hipError_t e = hipSuccess; - if (*device == NULL) { + if (deviceHandle == NULL) { e = hipErrorInvalidDevice; + } else { + *device = deviceId; } return ihipLogStatus(e); @@ -199,9 +201,11 @@ hipError_t hipCtxGetDevice(hipDevice_t *device) if(ctx == nullptr) { e = hipErrorInvalidContext; + // TODO *device = nullptr; } else { - *device = (ihipDevice_t*)ctx->getDevice(); + auto deviceHandle = ctx->getDevice(); + *device = deviceHandle->_deviceId; } return ihipLogStatus(e); } diff --git a/projects/hip/src/hip_device.cpp b/projects/hip/src/hip_device.cpp index bf45125b60..1cfdaa619d 100644 --- a/projects/hip/src/hip_device.cpp +++ b/projects/hip/src/hip_device.cpp @@ -321,9 +321,8 @@ hipError_t hipDeviceComputeCapability(int *major, int *minor, hipDevice_t device { HIP_INIT_API(major,minor, device); hipError_t e = hipSuccess; - int deviceId= device->_deviceId; - e = ihipDeviceGetAttribute(major, hipDeviceAttributeComputeCapabilityMajor, deviceId); - e = ihipDeviceGetAttribute(minor, hipDeviceAttributeComputeCapabilityMinor, deviceId); + e = ihipDeviceGetAttribute(major, hipDeviceAttributeComputeCapabilityMajor, device); + e = ihipDeviceGetAttribute(minor, hipDeviceAttributeComputeCapabilityMinor, device); return ihipLogStatus(e); } @@ -331,28 +330,13 @@ hipError_t hipDeviceGetName(char *name,int len,hipDevice_t device) { HIP_INIT_API(name,len, device); hipError_t e = hipSuccess; - int nameLen = strlen(device->_props.name); + auto deviceHandle = ihipGetDevice(device); + int nameLen = strlen(deviceHandle->_props.name); if(nameLen <= len) - memcpy(name,device->_props.name,nameLen); + memcpy(name,deviceHandle->_props.name,nameLen); return ihipLogStatus(e); } -#ifdef __cplusplus -hipError_t hipDeviceGetPCIBusId (char *pciBusId,int len,hipDevice_t device) -{ - HIP_INIT_API(pciBusId, len, device); - hipError_t e = hipSuccess; - int deviceId= device->_deviceId; - int tempPciBusId = 0; - e = ihipDeviceGetAttribute( &tempPciBusId, hipDeviceAttributePciBusId, deviceId); - if( e == hipSuccess) { - std::string tempPciStr = std::to_string(tempPciBusId); - memcpy( pciBusId , tempPciStr.c_str() , tempPciStr.length() ); - } - return ihipLogStatus(e); -} -#endif - hipError_t hipDeviceGetPCIBusId (char *pciBusId,int len, int device) { HIP_INIT_API(pciBusId, len, device); @@ -365,11 +349,13 @@ hipError_t hipDeviceGetPCIBusId (char *pciBusId,int len, int device) } return ihipLogStatus(e); } + hipError_t hipDeviceTotalMem (size_t *bytes,hipDevice_t device) { HIP_INIT_API(bytes, device); hipError_t e = hipSuccess; - *bytes= device->_props.totalGlobalMem; + auto deviceHandle = ihipGetDevice(device); + *bytes= deviceHandle->_props.totalGlobalMem; return ihipLogStatus(e); } diff --git a/projects/hip/tests/src/hipDrvGetPCIBusId.cpp b/projects/hip/tests/src/hipDrvGetPCIBusId.cpp index 21c49c194c..15c86b2214 100644 --- a/projects/hip/tests/src/hipDrvGetPCIBusId.cpp +++ b/projects/hip/tests/src/hipDrvGetPCIBusId.cpp @@ -27,7 +27,8 @@ int main(){ hipInit(0); hipDevice_t device; hipDeviceGet(&device, 0); - char pciBusId[100]; + char pciBusId[10]; + memset(pciBusId,0,10); hipDeviceGetPCIBusId(pciBusId,100,device); printf("PCI Bus ID= %s\n",pciBusId); return 0; From 74023080981e781e953f5333003aaa7ab31d0015 Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Sat, 17 Dec 2016 07:19:22 -0600 Subject: [PATCH 024/281] Refactor Module and Function APIs. - hipFunction_t is now returned by value. This eliminates dynamic allocation / memory management complexity in the module. Removed the kernel name so the structure is just 16 bytes now. - Moved the hsa_executable_load_module and hsa_executable_freeze calls to the hipModuleLoad and hipModuleLoadData calls. - Apply sharedMemBytes in hipModuleLaunchKernel to group segment size (not private). [ROCm/hip commit: 4d29885be3652c75c75d5d31d7009dc65d0a9815] --- .../include/hip/hcc_detail/hip_runtime_api.h | 9 ++- projects/hip/src/hip_hcc.h | 35 +--------- projects/hip/src/hip_module.cpp | 64 ++++++++++--------- projects/hip/src/trace_helper.h | 9 +++ 4 files changed, 52 insertions(+), 65 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h index b2cfa59d71..e38f1d6982 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h @@ -33,7 +33,7 @@ THE SOFTWARE. #include #include -//#include "hip/hip_hcc.h" +#include #if defined (__HCC__) && (__hcc_workweek__ < 16155) #error("This version of HIP requires a newer version of HCC."); @@ -72,7 +72,12 @@ typedef struct ihipIpcEventHandle_t *hipIpcEventHandle_t; typedef struct ihipModule_t *hipModule_t; -typedef struct ihipFunction_t *hipFunction_t; +struct ihipModuleSymbol_t{ + hsa_executable_symbol_t _hsaSymbol; + uint64_t _object; // The kernel object. +}; + +typedef struct ihipModuleSymbol_t hipFunction_t; typedef void* hipDeviceptr_t; diff --git a/projects/hip/src/hip_hcc.h b/projects/hip/src/hip_hcc.h index b5417080e0..4075c2b068 100644 --- a/projects/hip/src/hip_hcc.h +++ b/projects/hip/src/hip_hcc.h @@ -383,26 +383,6 @@ public: size_t psize; }; -class ihipFunction_t{ -public: - ihipFunction_t(const char *name) { - size_t nameSz = strlen(name); - char *kernelName = (char*)malloc(nameSz); - strncpy(kernelName, name, nameSz); - _kernelName = kernelName; - }; - - ~ihipFunction_t() { - if (_kernelName) { - free((void*)_kernelName); - _kernelName = NULL; - }; - }; -public: - const char *_kernelName; - hsa_executable_symbol_t _kernelSymbol; - uint64_t _kernel; -}; class ihipModule_t { public: @@ -412,20 +392,7 @@ public: void *ptr; size_t size; - ihipModule_t() : executable(), object(), fileName(), ptr(nullptr), size(0), hipFunctionTable() {} - ~ihipModule_t() { - for (int i = 0; i < hipFunctionTable.size(); ++i) { - ihipFunction_t *func = hipFunctionTable[i]; - delete func; - } - hipFunctionTable.clear(); - } - - void registerFunction(ihipFunction_t* func) { - hipFunctionTable.push_back(func); - } -private: - std::vector hipFunctionTable; + ihipModule_t() : executable(), object(), fileName(), ptr(nullptr), size(0) {} }; template diff --git a/projects/hip/src/hip_module.cpp b/projects/hip/src/hip_module.cpp index badeac2dcd..cb56fb3b4a 100644 --- a/projects/hip/src/hip_module.cpp +++ b/projects/hip/src/hip_module.cpp @@ -35,6 +35,11 @@ THE SOFTWARE. //TODO Use Pool APIs from HCC to get memory regions. +#define CHECK_HSA(hsaStatus, hipStatus) \ +if (hsaStatus != HSA_STATUS_SUCCESS) {\ + return ihipLogStatus(hipStatus);\ +} + namespace hipdrv { hsa_status_t findSystemRegions(hsa_region_t region, void *data){ @@ -154,9 +159,13 @@ hipError_t hipModuleLoad(hipModule_t *module, const char *fname){ } status = hsa_executable_create(HSA_PROFILE_FULL, HSA_EXECUTABLE_STATE_UNFROZEN, NULL, &(*module)->executable); - if(status != HSA_STATUS_SUCCESS){ - return ihipLogStatus(hipErrorNotInitialized); - } + CHECK_HSA(status, hipErrorNotInitialized); + + status = hsa_executable_load_code_object((*module)->executable, agent, (*module)->object, NULL); + CHECK_HSA(status, hipErrorNotInitialized); + + status = hsa_executable_freeze((*module)->executable, NULL); + CHECK_HSA(status, hipErrorNotInitialized); } } @@ -189,7 +198,7 @@ hipError_t hipModuleUnload(hipModule_t hmod) return ihipLogStatus(ret); } -hipError_t ihipModuleGetFunction(hipFunction_t *func, hipModule_t hmod, const char *name){ +hipError_t ihipModuleGetSymbol(hipFunction_t *func, hipModule_t hmod, const char *name){ auto ctx = ihipGetTlsDefaultCtx(); hipError_t ret = hipSuccess; @@ -201,27 +210,21 @@ hipError_t ihipModuleGetFunction(hipFunction_t *func, hipModule_t hmod, const ch ret = hipErrorInvalidContext; }else{ - *func = new ihipFunction_t(name); - hmod->registerFunction(*func); int deviceId = ctx->getDevice()->_deviceId; ihipDevice_t *currentDevice = ihipGetDevice(deviceId); hsa_agent_t gpuAgent = (hsa_agent_t)currentDevice->_hsaAgent; - hsa_status_t status; - status = hsa_executable_load_code_object(hmod->executable, gpuAgent, hmod->object, NULL); - if(status != HSA_STATUS_SUCCESS){ - return ihipLogStatus(hipErrorNotInitialized); - } - status = hsa_executable_freeze(hmod->executable, NULL); - status = hsa_executable_get_symbol(hmod->executable, NULL, name, gpuAgent, 0, &(*func)->_kernelSymbol); + + hsa_status_t status; + status = hsa_executable_get_symbol(hmod->executable, NULL, name, gpuAgent, 0, &(func->_hsaSymbol)); if(status != HSA_STATUS_SUCCESS){ return ihipLogStatus(hipErrorNotFound); } - status = hsa_executable_symbol_get_info((*func)->_kernelSymbol, + status = hsa_executable_symbol_get_info(func->_hsaSymbol, HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_OBJECT, - &(*func)->_kernel); + &func->_object); if(status != HSA_STATUS_SUCCESS){ return ihipLogStatus(hipErrorNotFound); @@ -234,7 +237,7 @@ hipError_t ihipModuleGetFunction(hipFunction_t *func, hipModule_t hmod, const ch hipError_t hipModuleGetFunction(hipFunction_t *hfunc, hipModule_t hmod, const char *name){ HIP_INIT_API(hfunc, hmod, name); - return ihipModuleGetFunction(hfunc, hmod, name); + return ihipModuleGetSymbol(hfunc, hmod, name); } @@ -275,7 +278,7 @@ hipError_t hipModuleLaunchKernel(hipFunction_t f, } uint32_t groupSegmentSize; - hsa_status_t status = hsa_executable_symbol_get_info(f->_kernelSymbol, + hsa_status_t status = hsa_executable_symbol_get_info(f._hsaSymbol, HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_GROUP_SEGMENT_SIZE, &groupSegmentSize); if(status != HSA_STATUS_SUCCESS){ @@ -283,20 +286,19 @@ hipError_t hipModuleLaunchKernel(hipFunction_t f, } uint32_t privateSegmentSize; - status = hsa_executable_symbol_get_info(f->_kernelSymbol, + status = hsa_executable_symbol_get_info(f._hsaSymbol, HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_PRIVATE_SEGMENT_SIZE, &privateSegmentSize); if(status != HSA_STATUS_SUCCESS){ return ihipLogStatus(hipErrorNotFound); } - privateSegmentSize += sharedMemBytes; /* Kernel argument preparation. */ grid_launch_parm lp; - hStream = ihipPreLaunchKernel(hStream, 0, 0, &lp, f->_kernelName); + hStream = ihipPreLaunchKernel(hStream, 0, 0, &lp, "ModuleKernel"); #if USE_DISPATCH_HSA_KERNEL @@ -315,7 +317,7 @@ hipError_t hipModuleLaunchKernel(hipFunction_t f, aql.grid_size_z = blockDimZ * gridDimZ; aql.group_segment_size = groupSegmentSize; aql.private_segment_size = privateSegmentSize; - aql.kernel_object = f->_kernel; + aql.kernel_object = f._object; aql.setup = 3 << HSA_KERNEL_DISPATCH_PACKET_SETUP_DIMENSIONS; aql.header = (HSA_PACKET_TYPE_KERNEL_DISPATCH << HSA_PACKET_HEADER_TYPE) | (1 << HSA_PACKET_HEADER_BARRIER) | @@ -356,7 +358,7 @@ hipError_t hipModuleLaunchKernel(hipFunction_t f, Launch AQL packet */ hStream->launchModuleKernel(*lp.av, signal, blockDimX, blockDimY, blockDimZ, - gridDimX, gridDimY, gridDimZ, groupSegmentSize, privateSegmentSize, kern, kernArgSize, f->_kernel); + gridDimX, gridDimY, gridDimZ, groupSegmentSize, privateSegmentSize, kern, kernArgSize, f->_object); /* @@ -384,7 +386,7 @@ hipError_t hipModuleLaunchKernel(hipFunction_t f, #endif // USE_DISPATCH_HSA_KERNEL - ihipPostLaunchKernel(f->_kernelName, hStream, lp); + ihipPostLaunchKernel("ModuleKernel", hStream, lp); } @@ -405,9 +407,9 @@ hipError_t hipModuleGetGlobal(hipDeviceptr_t *dptr, size_t *bytes, } else{ hipFunction_t func; - ihipModuleGetFunction(&func, hmod, name); + ihipModuleGetSymbol(&func, hmod, name); *bytes = PrintSymbolSizes(hmod->ptr, name) + sizeof(amd_kernel_code_t); - *dptr = reinterpret_cast(func->_kernel); + *dptr = reinterpret_cast(func._object); return ihipLogStatus(ret); } } @@ -419,7 +421,7 @@ hipError_t hipModuleLoadData(hipModule_t *module, const void *image) hipError_t ret = hipSuccess; if(image == NULL || module == NULL){ return ihipLogStatus(hipErrorNotInitialized); - }else{ + } else { auto ctx = ihipGetTlsDefaultCtx(); *module = new ihipModule_t; int deviceId = ctx->getDevice()->_deviceId; @@ -452,9 +454,13 @@ hipError_t hipModuleLoadData(hipModule_t *module, const void *image) } status = hsa_executable_create(HSA_PROFILE_FULL, HSA_EXECUTABLE_STATE_UNFROZEN, NULL, &(*module)->executable); - if(status != HSA_STATUS_SUCCESS){ - return ihipLogStatus(hipErrorNotInitialized); - } + CHECK_HSA(status, hipErrorNotInitialized); + + status = hsa_executable_load_code_object((*module)->executable, agent, (*module)->object, NULL); + CHECK_HSA(status, hipErrorNotInitialized); + + status = hsa_executable_freeze((*module)->executable, NULL); + CHECK_HSA(status, hipErrorNotInitialized); } return ihipLogStatus(ret); } diff --git a/projects/hip/src/trace_helper.h b/projects/hip/src/trace_helper.h index e75b492e0c..bde40d0690 100644 --- a/projects/hip/src/trace_helper.h +++ b/projects/hip/src/trace_helper.h @@ -72,6 +72,15 @@ inline std::string ToString(hipEvent_t v) return ss.str(); }; +// hipEvent_t specialization. TODO - maybe add an event ID for debug? +template <> +inline std::string ToString(hipFunction_t v) +{ + std::ostringstream ss; + ss << "0x" << std::hex << v._object; + return ss.str(); +}; + // hipStream_t From f97cffdc488d5c51f6eaaa43b70c21e288f84b50 Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Sat, 17 Dec 2016 07:20:30 -0600 Subject: [PATCH 025/281] Remove USE_DISPATCH_HSA_KERNEL=0 path. [ROCm/hip commit: 6ed7e1c1c1ffea08ec02b3325822e68c05aff45b] --- projects/hip/src/hip_hcc.cpp | 51 ---------------------------- projects/hip/src/hip_hcc.h | 2 -- projects/hip/src/hip_module.cpp | 60 --------------------------------- 3 files changed, 113 deletions(-) diff --git a/projects/hip/src/hip_hcc.cpp b/projects/hip/src/hip_hcc.cpp index 84794b02fb..b4568a8457 100644 --- a/projects/hip/src/hip_hcc.cpp +++ b/projects/hip/src/hip_hcc.cpp @@ -387,57 +387,6 @@ void ihipStream_t::lockclose_postKernelCommand(const char * kernelName, hc::acce }; - - -#if USE_DISPATCH_HSA_KERNEL==0 -// Precursor: the stream is already locked,specifically so this routine can enqueue work into the specified av. -void ihipStream_t::launchModuleKernel( - hc::accelerator_view av, - hsa_signal_t signal, - uint32_t blockDimX, - uint32_t blockDimY, - uint32_t blockDimZ, - uint32_t gridDimX, - uint32_t gridDimY, - uint32_t gridDimZ, - uint32_t groupSegmentSize, - uint32_t privateSegmentSize, - void *kernarg, - size_t kernSize, - uint64_t kernel){ - hsa_status_t status; - hsa_queue_t *Queue = (hsa_queue_t*)av.get_hsa_queue(); - const uint32_t queue_mask = Queue->size-1; - uint32_t packet_index = hsa_queue_load_write_index_relaxed(Queue); - hsa_kernel_dispatch_packet_t *dispatch_packet = &(((hsa_kernel_dispatch_packet_t*)(Queue->base_address))[packet_index & queue_mask]); - - dispatch_packet->completion_signal = signal; - dispatch_packet->workgroup_size_x = blockDimX; - dispatch_packet->workgroup_size_y = blockDimY; - dispatch_packet->workgroup_size_z = blockDimZ; - dispatch_packet->grid_size_x = blockDimX * gridDimX; - dispatch_packet->grid_size_y = blockDimY * gridDimY; - dispatch_packet->grid_size_z = blockDimZ * gridDimZ; - dispatch_packet->group_segment_size = groupSegmentSize; - dispatch_packet->private_segment_size = privateSegmentSize; - dispatch_packet->kernarg_address = kernarg; - dispatch_packet->kernel_object = kernel; - uint16_t header = (HSA_PACKET_TYPE_KERNEL_DISPATCH << HSA_PACKET_HEADER_TYPE) | - (1 << HSA_PACKET_HEADER_BARRIER) | - (HSA_FENCE_SCOPE_SYSTEM << HSA_PACKET_HEADER_ACQUIRE_FENCE_SCOPE) | - (HSA_FENCE_SCOPE_SYSTEM << HSA_PACKET_HEADER_RELEASE_FENCE_SCOPE); - - uint16_t setup = 3 << HSA_KERNEL_DISPATCH_PACKET_SETUP_DIMENSIONS; - uint32_t header32 = header | (setup << 16); - - __atomic_store_n((uint32_t*)(dispatch_packet), header32, __ATOMIC_RELEASE); - - hsa_queue_store_write_index_relaxed(Queue, packet_index + 1); - hsa_signal_store_relaxed(Queue->doorbell_signal, packet_index); -} -#endif - - //============================================================================= // Recompute the peercnt and the packed _peerAgents whenever a peer is added or deleted. // The packed _peerAgents can efficiently be used on each memory allocation. diff --git a/projects/hip/src/hip_hcc.h b/projects/hip/src/hip_hcc.h index 4075c2b068..ac4d493862 100644 --- a/projects/hip/src/hip_hcc.h +++ b/projects/hip/src/hip_hcc.h @@ -33,9 +33,7 @@ THE SOFTWARE. #error("This version of HIP requires a newer version of HCC."); #endif -#define USE_DISPATCH_HSA_KERNEL 1 #define USE_IPC 0 -// //--- diff --git a/projects/hip/src/hip_module.cpp b/projects/hip/src/hip_module.cpp index cb56fb3b4a..65eab494b8 100644 --- a/projects/hip/src/hip_module.cpp +++ b/projects/hip/src/hip_module.cpp @@ -300,7 +300,6 @@ hipError_t hipModuleLaunchKernel(hipFunction_t f, grid_launch_parm lp; hStream = ihipPreLaunchKernel(hStream, 0, 0, &lp, "ModuleKernel"); -#if USE_DISPATCH_HSA_KERNEL hsa_kernel_dispatch_packet_t aql; @@ -325,65 +324,6 @@ hipError_t hipModuleLaunchKernel(hipFunction_t f, (HSA_FENCE_SCOPE_SYSTEM << HSA_PACKET_HEADER_RELEASE_FENCE_SCOPE); lp.av->dispatch_hsa_kernel(&aql, config[1] /* kernarg*/, kernArgSize); -#else - - /* - Create signal - */ - - hsa_signal_t signal; - status = hsa_signal_create(1, 0, NULL, &signal); - if(status != HSA_STATUS_SUCCESS){ - return ihipLogStatus(hipErrorNotFound); - } - - /* - Allocate kernarg - */ - void *kern = nullptr; - - hsa_amd_memory_pool_t *pool = reinterpret_cast(lp.av->get_hsa_kernarg_region()); - status = hsa_amd_memory_pool_allocate(*pool, kernArgSize, 0, &kern); - if(status != HSA_STATUS_SUCCESS){ - return ihipLogStatus(hipErrorNotFound); - } - status = hsa_amd_agents_allow_access(1, (hsa_agent_t*)lp.av->get_hsa_agent(), 0, kern); - if(status != HSA_STATUS_SUCCESS){ - return ihipLogStatus(hipErrorNotFound); - } - memcpy(kern, config[1], kernArgSize); - - - /* - Launch AQL packet - */ - hStream->launchModuleKernel(*lp.av, signal, blockDimX, blockDimY, blockDimZ, - gridDimX, gridDimY, gridDimZ, groupSegmentSize, privateSegmentSize, kern, kernArgSize, f->_object); - - - /* - Wait for signal - */ - - hsa_signal_value_t value = hsa_signal_wait_acquire(signal, HSA_SIGNAL_CONDITION_LT, 1, UINT64_MAX, HSA_WAIT_STATE_BLOCKED); - - /* - Destroy kernarg - */ - status = hsa_amd_memory_pool_free(kern); - if(status != HSA_STATUS_SUCCESS){ - return ihipLogStatus(hipErrorNotFound); - } - - /* - Destroy the signal - */ - status = hsa_signal_destroy(signal); - if(status != HSA_STATUS_SUCCESS){ - return ihipLogStatus(hipErrorNotFound); - } - -#endif // USE_DISPATCH_HSA_KERNEL ihipPostLaunchKernel("ModuleKernel", hStream, lp); From a212162612e8ab5ca7932e936bf794847a7941a2 Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Sat, 17 Dec 2016 07:21:15 -0600 Subject: [PATCH 026/281] Remove HSA dependency from hipFunction_t Place _groupSegmentSize and _privateSegmentSize inside Function, remove hsa_executable_symbol_t. [ROCm/hip commit: 8bf4bd2f7d50f51781622dcb93d4e3119bc7dba6] --- .../include/hip/hcc_detail/hip_runtime_api.h | 8 ++- projects/hip/src/hip_module.cpp | 63 ++++++++++--------- 2 files changed, 37 insertions(+), 34 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h index e38f1d6982..0be4961f03 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h @@ -30,10 +30,10 @@ THE SOFTWARE. #include #include +#include #include #include -#include #if defined (__HCC__) && (__hcc_workweek__ < 16155) #error("This version of HIP requires a newer version of HCC."); @@ -73,8 +73,10 @@ typedef struct ihipIpcEventHandle_t *hipIpcEventHandle_t; typedef struct ihipModule_t *hipModule_t; struct ihipModuleSymbol_t{ - hsa_executable_symbol_t _hsaSymbol; - uint64_t _object; // The kernel object. + uint64_t _object; // The kernel object. + uint32_t _groupSegmentSize; + uint32_t _privateSegmentSize; + //std::string _name; // TODO - review for performance cost. Name is just used for debug. }; typedef struct ihipModuleSymbol_t hipFunction_t; diff --git a/projects/hip/src/hip_module.cpp b/projects/hip/src/hip_module.cpp index 65eab494b8..19de6957e5 100644 --- a/projects/hip/src/hip_module.cpp +++ b/projects/hip/src/hip_module.cpp @@ -36,6 +36,11 @@ THE SOFTWARE. //TODO Use Pool APIs from HCC to get memory regions. #define CHECK_HSA(hsaStatus, hipStatus) \ +if (hsaStatus != HSA_STATUS_SUCCESS) {\ + return hipStatus;\ +} + +#define CHECKLOG_HSA(hsaStatus, hipStatus) \ if (hsaStatus != HSA_STATUS_SUCCESS) {\ return ihipLogStatus(hipStatus);\ } @@ -108,6 +113,7 @@ uint64_t ElfSize(const void *emi){ return total_size; } + hipError_t hipModuleLoad(hipModule_t *module, const char *fname){ HIP_INIT_API(module, fname); hipError_t ret = hipSuccess; @@ -159,19 +165,20 @@ hipError_t hipModuleLoad(hipModule_t *module, const char *fname){ } status = hsa_executable_create(HSA_PROFILE_FULL, HSA_EXECUTABLE_STATE_UNFROZEN, NULL, &(*module)->executable); - CHECK_HSA(status, hipErrorNotInitialized); + CHECKLOG_HSA(status, hipErrorNotInitialized); status = hsa_executable_load_code_object((*module)->executable, agent, (*module)->object, NULL); - CHECK_HSA(status, hipErrorNotInitialized); + CHECKLOG_HSA(status, hipErrorNotInitialized); status = hsa_executable_freeze((*module)->executable, NULL); - CHECK_HSA(status, hipErrorNotInitialized); + CHECKLOG_HSA(status, hipErrorNotInitialized); } } return ihipLogStatus(ret); } + hipError_t hipModuleUnload(hipModule_t hmod) { // TODO - improve this synchronization so it is thread-safe. @@ -214,21 +221,29 @@ hipError_t ihipModuleGetSymbol(hipFunction_t *func, hipModule_t hmod, const char ihipDevice_t *currentDevice = ihipGetDevice(deviceId); hsa_agent_t gpuAgent = (hsa_agent_t)currentDevice->_hsaAgent; - - hsa_status_t status; - status = hsa_executable_get_symbol(hmod->executable, NULL, name, gpuAgent, 0, &(func->_hsaSymbol)); + hsa_executable_symbol_t symbol; + status = hsa_executable_get_symbol(hmod->executable, NULL, name, gpuAgent, 0, &symbol); if(status != HSA_STATUS_SUCCESS){ return ihipLogStatus(hipErrorNotFound); } - status = hsa_executable_symbol_get_info(func->_hsaSymbol, + status = hsa_executable_symbol_get_info(symbol, HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_OBJECT, &func->_object); + CHECK_HSA(status, hipErrorNotFound); - if(status != HSA_STATUS_SUCCESS){ - return ihipLogStatus(hipErrorNotFound); - } + status = hsa_executable_symbol_get_info(symbol, + HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_GROUP_SEGMENT_SIZE, + &func->_groupSegmentSize); + CHECK_HSA(status, hipErrorNotFound); + + status = hsa_executable_symbol_get_info(symbol, + HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_PRIVATE_SEGMENT_SIZE, + &func->_privateSegmentSize); + CHECK_HSA(status, hipErrorNotFound); + + //func->_name = std::string(name); } return ihipLogStatus(ret); } @@ -277,27 +292,13 @@ hipError_t hipModuleLaunchKernel(hipFunction_t f, return ihipLogStatus(hipErrorInvalidValue); } - uint32_t groupSegmentSize; - hsa_status_t status = hsa_executable_symbol_get_info(f._hsaSymbol, - HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_GROUP_SEGMENT_SIZE, - &groupSegmentSize); - if(status != HSA_STATUS_SUCCESS){ - return ihipLogStatus(hipErrorNotFound); - } - - uint32_t privateSegmentSize; - status = hsa_executable_symbol_get_info(f._hsaSymbol, - HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_PRIVATE_SEGMENT_SIZE, - &privateSegmentSize); - if(status != HSA_STATUS_SUCCESS){ - return ihipLogStatus(hipErrorNotFound); - } /* Kernel argument preparation. */ grid_launch_parm lp; + //hStream = ihipPreLaunchKernel(hStream, 0, 0, &lp, f._name.empty() ? "ModuleKernel" : f._name.c_str()); hStream = ihipPreLaunchKernel(hStream, 0, 0, &lp, "ModuleKernel"); @@ -314,8 +315,8 @@ hipError_t hipModuleLaunchKernel(hipFunction_t f, aql.grid_size_x = blockDimX * gridDimX; aql.grid_size_y = blockDimY * gridDimY; aql.grid_size_z = blockDimZ * gridDimZ; - aql.group_segment_size = groupSegmentSize; - aql.private_segment_size = privateSegmentSize; + aql.group_segment_size = f._groupSegmentSize + sharedMemBytes; + aql.private_segment_size = f._privateSegmentSize; aql.kernel_object = f._object; aql.setup = 3 << HSA_KERNEL_DISPATCH_PACKET_SETUP_DIMENSIONS; aql.header = (HSA_PACKET_TYPE_KERNEL_DISPATCH << HSA_PACKET_HEADER_TYPE) | @@ -326,8 +327,8 @@ hipError_t hipModuleLaunchKernel(hipFunction_t f, lp.av->dispatch_hsa_kernel(&aql, config[1] /* kernarg*/, kernArgSize); + //ihipPostLaunchKernel(f._name.empty() ? "ModuleKernel" : f._name.c_str(), hStream, lp); ihipPostLaunchKernel("ModuleKernel", hStream, lp); - } return ihipLogStatus(ret); @@ -394,13 +395,13 @@ hipError_t hipModuleLoadData(hipModule_t *module, const void *image) } status = hsa_executable_create(HSA_PROFILE_FULL, HSA_EXECUTABLE_STATE_UNFROZEN, NULL, &(*module)->executable); - CHECK_HSA(status, hipErrorNotInitialized); + CHECKLOG_HSA(status, hipErrorNotInitialized); status = hsa_executable_load_code_object((*module)->executable, agent, (*module)->object, NULL); - CHECK_HSA(status, hipErrorNotInitialized); + CHECKLOG_HSA(status, hipErrorNotInitialized); status = hsa_executable_freeze((*module)->executable, NULL); - CHECK_HSA(status, hipErrorNotInitialized); + CHECKLOG_HSA(status, hipErrorNotInitialized); } return ihipLogStatus(ret); } From a5f13421b5e20706e7d662658a51c5a7d6f1f9ae Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Sat, 17 Dec 2016 08:54:09 -0600 Subject: [PATCH 027/281] Add name for function [ROCm/hip commit: 90c69e14bb129617c6ec6e83c5cdba74645ac407] --- projects/hip/include/hip/hcc_detail/hip_runtime_api.h | 3 +-- projects/hip/src/hip_module.cpp | 10 ++++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h index 0be4961f03..4c9cedecc4 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h @@ -30,7 +30,6 @@ THE SOFTWARE. #include #include -#include #include #include @@ -76,7 +75,7 @@ struct ihipModuleSymbol_t{ uint64_t _object; // The kernel object. uint32_t _groupSegmentSize; uint32_t _privateSegmentSize; - //std::string _name; // TODO - review for performance cost. Name is just used for debug. + char _name[64]; // TODO - review for performance cost. Name is just used for debug. }; typedef struct ihipModuleSymbol_t hipFunction_t; diff --git a/projects/hip/src/hip_module.cpp b/projects/hip/src/hip_module.cpp index 19de6957e5..74cdd8a4ae 100644 --- a/projects/hip/src/hip_module.cpp +++ b/projects/hip/src/hip_module.cpp @@ -243,7 +243,7 @@ hipError_t ihipModuleGetSymbol(hipFunction_t *func, hipModule_t hmod, const char &func->_privateSegmentSize); CHECK_HSA(status, hipErrorNotFound); - //func->_name = std::string(name); + strncpy(func->_name, name, sizeof(func->_name)); } return ihipLogStatus(ret); } @@ -297,9 +297,8 @@ hipError_t hipModuleLaunchKernel(hipFunction_t f, /* Kernel argument preparation. */ - grid_launch_parm lp; - //hStream = ihipPreLaunchKernel(hStream, 0, 0, &lp, f._name.empty() ? "ModuleKernel" : f._name.c_str()); - hStream = ihipPreLaunchKernel(hStream, 0, 0, &lp, "ModuleKernel"); + grid_launch_parm lp; // TODO - dummy arg but values are printed during debug. + hStream = ihipPreLaunchKernel(hStream, 0, 0, &lp, f._name); hsa_kernel_dispatch_packet_t aql; @@ -327,8 +326,7 @@ hipError_t hipModuleLaunchKernel(hipFunction_t f, lp.av->dispatch_hsa_kernel(&aql, config[1] /* kernarg*/, kernArgSize); - //ihipPostLaunchKernel(f._name.empty() ? "ModuleKernel" : f._name.c_str(), hStream, lp); - ihipPostLaunchKernel("ModuleKernel", hStream, lp); + ihipPostLaunchKernel(f._name, hStream, lp); } return ihipLogStatus(ret); From a93a5a41f3b69801db45a618f1ffa1169a696d67 Mon Sep 17 00:00:00 2001 From: Rahul Garg Date: Wed, 23 Nov 2016 09:50:33 +0530 Subject: [PATCH 028/281] Fix for HCSWAP-67 Change-Id: I0b2ce5ab933237947fb41d89769db3da16e5be6a Conflicts: src/hip_hcc.cpp [ROCm/hip commit: fbf7ed63a832d8ca8705c13fd68ba2575420b97d] --- projects/hip/src/hip_hcc.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/projects/hip/src/hip_hcc.cpp b/projects/hip/src/hip_hcc.cpp index b4568a8457..19d7e1169d 100644 --- a/projects/hip/src/hip_hcc.cpp +++ b/projects/hip/src/hip_hcc.cpp @@ -732,13 +732,10 @@ hipError_t ihipDevice_t::initProperties(hipDeviceProp_t* prop) _isLargeBar = _acc.has_cpu_accessible_am(); // Get Max Threads Per Multiprocessor - - HsaNodeProperties node_prop = {0}; - if(HSAKMT_STATUS_SUCCESS == hsaKmtGetNodeProperties(node, &node_prop)) { - uint32_t waves_per_cu = node_prop.MaxWavesPerSIMD; - uint32_t simd_per_cu = node_prop.NumSIMDPerCU; - prop-> maxThreadsPerMultiProcessor = prop->warpSize*waves_per_cu*simd_per_cu; - } + uint32_t max_waves_per_cu; + err = hsa_agent_get_info(_hsaAgent,(hsa_agent_info_t) HSA_AMD_AGENT_INFO_MAX_WAVES_PER_CU, &max_waves_per_cu); + DeviceErrorCheck(err); + prop-> maxThreadsPerMultiProcessor = prop->warpSize*max_waves_per_cu; // Get memory properties err = hsa_agent_iterate_regions(_hsaAgent, get_region_info, prop); From 121b909f55dd49b50daa1e3897b49b19d45aa816 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Mon, 19 Dec 2016 14:38:19 +0300 Subject: [PATCH 029/281] [HIPIFY] Reflect unsupported CUDA API refs in statistics https://github.com/GPUOpen-ProfessionalCompute-Tools/HIP/issues/53 + Unsupported refs (by HIP) are now might be listed along with the supported ones. + Warnings are added for the unhandled (by HIPIFY) refs, for instance: "warning: the following reference is not handled: 'cublasContext' [param decl ptr]." + Reflect unsupported CUDA API refs in statistics. + Occupancy API [HIP_UNSUPPORTED]. + A few CUBLAS refs are listed as HIP_UNSUPPORTED. TODO: Statistics in CSV file. [ROCm/hip commit: 3dd32e969d77c8e2dbff149a3ef40388903ca272] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 605 +++++++++++++-------- 1 file changed, 367 insertions(+), 238 deletions(-) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index 064f4ad4e1..f0711a4d89 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -54,6 +54,7 @@ using namespace clang::tooling; using namespace llvm; #define DEBUG_TYPE "cuda2hip" +#define HIP_UNSUPPORTED -1 enum ConvTypes { CONV_DRIVER = 0, @@ -65,6 +66,7 @@ enum ConvTypes { CONV_SPECIAL_FUNC, CONV_STREAM, CONV_EVENT, + CONV_OCCUPANCY, CONV_CONTEXT, CONV_MODULE, CONV_CACHE, @@ -81,10 +83,10 @@ enum ConvTypes { }; const char *counterNames[CONV_LAST] = { - "driver", "dev", "mem", "kern", "coord_func", "math_func", - "special_func", "stream", "event", "ctx", "module", "cache", - "err", "def", "tex", "other", "include", "include_cuda_main_header", - "type", "literal", "numeric_literal"}; + "driver", "dev", "mem", "kern", "coord_func", "math_func", + "special_func", "stream", "event", "occupancy", "ctx", "module", + "cache", "err", "def", "tex", "other", "include", + "include_cuda_main_header", "type", "literal", "numeric_literal"}; enum ApiTypes { API_DRIVER = 0, @@ -100,14 +102,20 @@ namespace { int64_t countRepsTotal[CONV_LAST] = { 0 }; int64_t countApiRepsTotal[API_LAST] = { 0 }; +int64_t countRepsTotalUnsupported[CONV_LAST] = { 0 }; +int64_t countApiRepsTotalUnsupported[API_LAST] = { 0 }; struct hipCounter { StringRef hipName; ConvTypes countType; ApiTypes countApiType; + int unsupported; }; struct cuda2hipMap { + SmallDenseMap cuda2hipRename; + std::set cudaExcludes; + cuda2hipMap() { // Replacement Excludes @@ -302,8 +310,8 @@ struct cuda2hipMap { cuda2hipRename["CUfunction"] = {"hipFunction_t", CONV_TYPE, API_DRIVER}; // unsupported yet by HIP - // cuda2hipRename["CUfunction_attribute_enum"] = {"hipFuncAttribute_t", CONV_TYPE, API_DRIVER}; - // cuda2hipRename["CUfunction_attribute"] = {"hipFuncAttribute_t", CONV_TYPE, API_DRIVER}; + cuda2hipRename["CUfunction_attribute_enum"] = {"hipFuncAttribute_t", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CUfunction_attribute"] = {"hipFuncAttribute_t", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; cuda2hipRename["CUfunc_cache_enum"] = {"hipFuncCache", CONV_TYPE, API_DRIVER}; cuda2hipRename["CUfunc_cache"] = {"hipFuncCache", CONV_TYPE, API_DRIVER}; @@ -321,6 +329,7 @@ struct cuda2hipMap { cuda2hipRename["CUcontext"] = {"hipCtx_t", CONV_TYPE, API_DRIVER}; cuda2hipRename["CUmodule"] = {"hipModule_t", CONV_TYPE, API_DRIVER}; cuda2hipRename["CUevent"] = {"hipEvent_t", CONV_TYPE, API_DRIVER}; + cuda2hipRename["CUevent_st"] = {"hipEvent_t", CONV_TYPE, API_DRIVER}; // Event Flags cuda2hipRename["CU_EVENT_DEFAULT"] = {"hipEventDefault", CONV_EVENT, API_DRIVER}; cuda2hipRename["CU_EVENT_BLOCKING_SYNC"] = {"hipEventBlockingSync", CONV_EVENT, API_DRIVER}; @@ -338,6 +347,15 @@ struct cuda2hipMap { // Driver cuda2hipRename["cuDriverGetVersion"] = {"hipDriverGetVersion", CONV_DRIVER, API_DRIVER}; + // Occupancy + // unsupported yet by HIP + cuda2hipRename["cudaOccupancyMaxPotentialBlockSize"] = {"hipOccupancyMaxPotentialBlockSize", CONV_OCCUPANCY, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["cudaOccupancyMaxPotentialBlockSizeWithFlags"] = {"hipOccupancyMaxPotentialBlockSizeWithFlags", CONV_OCCUPANCY, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["cudaOccupancyMaxActiveBlocksPerMultiprocessor"] = {"hipOccupancyMaxActiveBlocksPerMultiprocessor", CONV_OCCUPANCY, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags"] = {"hipOccupancyMaxActiveBlocksPerMultiprocessorWithFlags", CONV_OCCUPANCY, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["cudaOccupancyMaxPotentialBlockSizeVariableSMem"] = {"hipOccupancyMaxPotentialBlockSizeVariableSMem", CONV_OCCUPANCY, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["cudaOccupancyMaxPotentialBlockSizeVariableSMemWithFlags"] = {"hipOccupancyMaxPotentialBlockSizeVariableSMemWithFlags", CONV_OCCUPANCY, API_DRIVER, HIP_UNSUPPORTED}; + // Context cuda2hipRename["cuCtxCreate_v2"] = {"hipCtxCreate", CONV_CONTEXT, API_DRIVER}; cuda2hipRename["cuCtxDestroy_v2"] = {"hipCtxDestroy", CONV_CONTEXT, API_DRIVER}; @@ -356,8 +374,8 @@ struct cuda2hipMap { cuda2hipRename["cuCtxEnablePeerAccess"] = {"hipCtxEnablePeerAccess", CONV_CONTEXT, API_DRIVER}; cuda2hipRename["cuCtxDisablePeerAccess"] = {"hipCtxDisablePeerAccess", CONV_CONTEXT, API_DRIVER}; // unsupported yet by HIP - // cuda2hipRename["cuCtxSetLimit"] = {"hipCtxSetLimit", CONV_CONTEXT, API_DRIVER}; - // cuda2hipRename["cuCtxGetLimit"] = {"hipCtxGetLimit", CONV_CONTEXT, API_DRIVER}; + cuda2hipRename["cuCtxSetLimit"] = {"hipCtxSetLimit", CONV_CONTEXT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["cuCtxGetLimit"] = {"hipCtxGetLimit", CONV_CONTEXT, API_DRIVER, HIP_UNSUPPORTED}; // Device cuda2hipRename["cuDeviceGet"] = {"hipGetDevice", CONV_DEV, API_DRIVER}; @@ -367,7 +385,8 @@ struct cuda2hipMap { cuda2hipRename["cuDeviceGetProperties"] = {"hipGetDeviceProperties", CONV_DEV, API_DRIVER}; cuda2hipRename["cuDeviceGetPCIBusId"] = {"hipDeviceGetPCIBusId", CONV_DEV, API_DRIVER}; // unsupported yet by HIP - // cuda2hipRename["cuDeviceGetByPCIBusId"] = {"hipDeviceGetByPCIBusId", CONV_DEV, API_DRIVER}; + cuda2hipRename["cuDeviceGetByPCIBusId"] = {"hipDeviceGetByPCIBusId", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["cuDeviceTotalMem_v2"] = {"hipDeviceTotalMem", CONV_DEV, API_DRIVER}; cuda2hipRename["cuDeviceComputeCapability"] = {"hipDeviceComputeCapability", CONV_DEV, API_DRIVER}; cuda2hipRename["cuDeviceCanAccessPeer"] = {"hipDeviceCanAccessPeer", CONV_DEV, API_DRIVER}; @@ -386,14 +405,16 @@ struct cuda2hipMap { cuda2hipRename["cuModuleLoad"] = {"hipModuleLoad", CONV_MODULE, API_DRIVER}; cuda2hipRename["cuModuleLoadData"] = {"hipModuleLoadData", CONV_MODULE, API_DRIVER}; // unsupported yet by HIP - // cuda2hipRename["cuModuleLoadDataEx"] = {"hipModuleLoadDataEx", CONV_MODULE, API_DRIVER}; - // cuda2hipRename["cuModuleLoadFatBinary"] = {"hipModuleLoadFatBinary", CONV_MODULE, API_DRIVER}; + cuda2hipRename["cuModuleLoadDataEx"] = {"hipModuleLoadDataEx", CONV_MODULE, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["cuModuleLoadFatBinary"] = {"hipModuleLoadFatBinary", CONV_MODULE, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["cuModuleUnload"] = {"hipModuleUnload", CONV_MODULE, API_DRIVER}; cuda2hipRename["cuLaunchKernel"] = {"hipModuleLaunchKernel", CONV_MODULE, API_DRIVER}; // Streams // unsupported yet by HIP - // cuda2hipRename["cuStreamAddCallback"] = {"hipStreamAddCallback", CONV_STREAM, API_DRIVER}; + cuda2hipRename["cuStreamAddCallback"] = {"hipStreamAddCallback", CONV_STREAM, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["cuStreamCreate"] = {"hipStreamCreate", CONV_STREAM, API_DRIVER}; cuda2hipRename["cuStreamDestroy_v2"] = {"hipStreamDestroy", CONV_STREAM, API_DRIVER}; cuda2hipRename["cuStreamQuery"] = {"hipStreamQuery", CONV_STREAM, API_DRIVER}; @@ -415,19 +436,20 @@ struct cuda2hipMap { cuda2hipRename["cuMemcpyHtoDAsync_v2"] = {"hipMemcpyHtoDAsync", CONV_MEM, API_DRIVER}; // unsupported yet by HIP - // cuda2hipRename["cuMemsetD8_v2"] = {"hipMemsetD8", CONV_STREAM, API_DRIVER}; - // cuda2hipRename["cuMemsetD8Async"] = {"hipMemsetD8Async", CONV_STREAM, API_DRIVER}; - // cuda2hipRename["cuMemsetD2D8_v2"] = {"hipMemsetD2D8", CONV_STREAM, API_DRIVER}; - // cuda2hipRename["cuMemsetD2D8Async"] = {"hipMemsetD2D8Async", CONV_STREAM, API_DRIVER}; - // cuda2hipRename["cuMemsetD16_v2"] = {"hipMemsetD16", CONV_STREAM, API_DRIVER}; - // cuda2hipRename["cuMemsetD16Async"] = {"hipMemsetD16Async", CONV_STREAM, API_DRIVER}; - // cuda2hipRename["cuMemsetD2D16_v2"] = {"hipMemsetD2D16", CONV_STREAM, API_DRIVER}; - // cuda2hipRename["cuMemsetD2D16Async"] = {"hipMemsetD2D16Async", CONV_STREAM, API_DRIVER}; + cuda2hipRename["cuMemsetD8_v2"] = {"hipMemsetD8", CONV_STREAM, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["cuMemsetD8Async"] = {"hipMemsetD8Async", CONV_STREAM, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["cuMemsetD2D8_v2"] = {"hipMemsetD2D8", CONV_STREAM, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["cuMemsetD2D8Async"] = {"hipMemsetD2D8Async", CONV_STREAM, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["cuMemsetD16_v2"] = {"hipMemsetD16", CONV_STREAM, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["cuMemsetD16Async"] = {"hipMemsetD16Async", CONV_STREAM, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["cuMemsetD2D16_v2"] = {"hipMemsetD2D16", CONV_STREAM, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["cuMemsetD2D16Async"] = {"hipMemsetD2D16Async", CONV_STREAM, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["cuMemsetD32_v2"] = {"hipMemset", CONV_MEM, API_DRIVER}; cuda2hipRename["cuMemsetD32Async"] = {"hipMemsetAsync", CONV_MEM, API_DRIVER}; // unsupported yet by HIP - // cuda2hipRename["cuMemsetD2D32_v2"] = {"hipMemsetD2D32", CONV_STREAM, API_DRIVER}; - // cuda2hipRename["cuMemsetD2D32Async"] = {"hipMemsetD2D32Async", CONV_STREAM, API_DRIVER}; + cuda2hipRename["cuMemsetD2D32_v2"] = {"hipMemsetD2D32", CONV_STREAM, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["cuMemsetD2D32Async"] = {"hipMemsetD2D32Async", CONV_STREAM, API_DRIVER, HIP_UNSUPPORTED}; cuda2hipRename["cuMemGetInfo_v2"] = {"hipMemGetInfo", CONV_MEM, API_DRIVER}; cuda2hipRename["cuMemHostRegister_v2"] = {"hipHostRegister", CONV_MEM, API_DRIVER}; @@ -435,7 +457,8 @@ struct cuda2hipMap { // Profiler // unsupported yet by HIP - // cuda2hipRename["cuProfilerInitialize"] = {"hipProfilerInitialize", CONV_OTHER, API_DRIVER}; + cuda2hipRename["cuProfilerInitialize"] = {"hipProfilerInitialize", CONV_OTHER, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["cuProfilerStart"] = {"hipProfilerStart", CONV_OTHER, API_DRIVER}; cuda2hipRename["cuProfilerStop"] = {"hipProfilerStop", CONV_OTHER, API_DRIVER}; @@ -603,13 +626,14 @@ struct cuda2hipMap { cuda2hipRename["cudaDeviceScheduleYield"] = {"hipDeviceScheduleYield", CONV_DEV, API_RUNTIME}; // deprecated as of CUDA 4.0 and replaced with cudaDeviceScheduleBlockingSync cuda2hipRename["cudaDeviceBlockingSync"] = {"hipDeviceBlockingSync", CONV_DEV, API_RUNTIME}; - // unsupported yet - //cuda2hipRename["cudaDeviceScheduleBlockingSync"] = {"hipDeviceScheduleBlockingSync", CONV_DEV, API_RUNTIME}; - //cuda2hipRename["cudaDeviceScheduleMask"] = {"hipDeviceScheduleMask", CONV_DEV, API_RUNTIME}; + // unsupported yet by HIP + cuda2hipRename["cudaDeviceScheduleBlockingSync"] = {"hipDeviceScheduleBlockingSync", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDeviceScheduleMask"] = {"hipDeviceScheduleMask", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDeviceMapHost"] = {"hipDeviceMapHost", CONV_DEV, API_RUNTIME}; - // unsupported yet - //cuda2hipRename["cudaDeviceLmemResizeToMax"] = {"hipDeviceLmemResizeToMax", CONV_DEV, API_RUNTIME}; - //cuda2hipRename["cudaDeviceMask"] = {"hipDeviceMask", CONV_DEV, API_RUNTIME}; + // unsupported yet by HIP + cuda2hipRename["cudaDeviceLmemResizeToMax"] = {"hipDeviceLmemResizeToMax", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDeviceMask"] = {"hipDeviceMask", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // Cache config cuda2hipRename["cudaDeviceSetCacheConfig"] = {"hipDeviceSetCacheConfig", CONV_CACHE, API_RUNTIME}; @@ -627,8 +651,8 @@ struct cuda2hipMap { // Driver/Runtime cuda2hipRename["cudaDriverGetVersion"] = {"hipDriverGetVersion", CONV_DRIVER, API_RUNTIME}; - // unsupported yet - //cuda2hipRename["cudaRuntimeGetVersion"] = {"hipRuntimeGetVersion", CONV_DEV, API_RUNTIME}; + // unsupported yet by HIP + cuda2hipRename["cudaRuntimeGetVersion"] = {"hipRuntimeGetVersion", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // Peer2Peer cuda2hipRename["cudaDeviceCanAccessPeer"] = {"hipDeviceCanAccessPeer", CONV_DEV, API_RUNTIME}; @@ -651,18 +675,22 @@ struct cuda2hipMap { // Limits cuda2hipRename["cudaLimit"] = {"hipLimit_t", CONV_DEV, API_RUNTIME}; - // unsupported yet - //cuda2hipRename["cudaLimitStackSize"] = {"hipLimitStackSize", CONV_DEV, API_RUNTIME}; - //cuda2hipRename["cudaLimitPrintfFifoSize"] = {"hipLimitPrintfFifoSize", CONV_DEV, API_RUNTIME}; - // unsupported yet + // unsupported yet by HIP + cuda2hipRename["cudaLimitStackSize"] = {"hipLimitStackSize", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaLimitPrintfFifoSize"] = {"hipLimitPrintfFifoSize", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaLimitMallocHeapSize"] = {"hipLimitMallocHeapSize", CONV_DEV, API_RUNTIME}; - //cuda2hipRename["cudaLimitDevRuntimeSyncDepth"] = {"hipLimitPrintfFifoSize", CONV_DEV, API_RUNTIME}; - //cuda2hipRename["cudaLimitDevRuntimePendingLaunchCount"] = {"hipLimitMallocHeapSize", CONV_DEV, API_RUNTIME}; + + // unsupported yet by HIP + cuda2hipRename["cudaLimitDevRuntimeSyncDepth"] = {"hipLimitPrintfFifoSize", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaLimitDevRuntimePendingLaunchCount"] = {"hipLimitMallocHeapSize", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDeviceGetLimit"] = {"hipDeviceGetLimit", CONV_DEV, API_RUNTIME}; // Profiler - // unsupported yet - //cuda2hipRename["cudaProfilerInitialize"] = {"hipProfilerInitialize", CONV_OTHER, API_RUNTIME}; + // unsupported yet by HIP + cuda2hipRename["cudaProfilerInitialize"] = {"hipProfilerInitialize", CONV_OTHER, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaProfilerStart"] = {"hipProfilerStart", CONV_OTHER, API_RUNTIME}; cuda2hipRename["cudaProfilerStop"] = {"hipProfilerStop", CONV_OTHER, API_RUNTIME}; cuda2hipRename["cudaChannelFormatDesc"] = {"hipChannelFormatDesc", CONV_TEX, API_RUNTIME}; @@ -694,103 +722,109 @@ struct cuda2hipMap { cuda2hipRename["CUBLAS_STATUS_NOT_SUPPORTED"] = {"HIPBLAS_STATUS_INTERNAL_ERROR", CONV_NUMERIC_LITERAL, API_BLAS}; // Blas Fill Modes // unsupported yet by hipblas/hcblas - //cuda2hipRename["cublasFillMode_t"] = {"hipblasFillMode_t", CONV_TYPE, API_BLAS}; - //cuda2hipRename["CUBLAS_FILL_MODE_LOWER"] = {"HIPBLAS_FILL_MODE_LOWER", CONV_NUMERIC_LITERAL, API_BLAS}; - //cuda2hipRename["CUBLAS_FILL_MODE_UPPER"] = {"HIPBLAS_FILL_MODE_UPPER", CONV_NUMERIC_LITERAL, API_BLAS}; + cuda2hipRename["cublasFillMode_t"] = {"hipblasFillMode_t", CONV_TYPE, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["CUBLAS_FILL_MODE_LOWER"] = {"HIPBLAS_FILL_MODE_LOWER", CONV_NUMERIC_LITERAL, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["CUBLAS_FILL_MODE_UPPER"] = {"HIPBLAS_FILL_MODE_UPPER", CONV_NUMERIC_LITERAL, API_BLAS, HIP_UNSUPPORTED}; // Blas Diag Types // unsupported yet by hipblas/hcblas - //cuda2hipRename["cublasDiagType_t"] = {"hipblasDiagType_t", CONV_TYPE, API_BLAS}; - //cuda2hipRename["CUBLAS_DIAG_NON_UNIT"] = {"HIPBLAS_DIAG_NON_UNIT", CONV_NUMERIC_LITERAL, API_BLAS}; - //cuda2hipRename["CUBLAS_DIAG_UNIT"] = {"HIPBLAS_DIAG_UNIT", CONV_NUMERIC_LITERAL, API_BLAS}; + cuda2hipRename["cublasDiagType_t"] = {"hipblasDiagType_t", CONV_TYPE, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["CUBLAS_DIAG_NON_UNIT"] = {"HIPBLAS_DIAG_NON_UNIT", CONV_NUMERIC_LITERAL, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["CUBLAS_DIAG_UNIT"] = {"HIPBLAS_DIAG_UNIT", CONV_NUMERIC_LITERAL, API_BLAS, HIP_UNSUPPORTED}; // Blas Side Modes // unsupported yet by hipblas/hcblas - //cuda2hipRename["cublasSideMode_t"] = {"hipblasSideMode_t", CONV_TYPE, API_BLAS}; - //cuda2hipRename["CUBLAS_SIDE_LEFT"] = {"HIPBLAS_SIDE_LEFT", CONV_NUMERIC_LITERAL, API_BLAS}; - //cuda2hipRename["CUBLAS_SIDE_RIGHT"] = {"HIPBLAS_SIDE_RIGHT", CONV_NUMERIC_LITERAL, API_BLAS}; + cuda2hipRename["cublasSideMode_t"] = {"hipblasSideMode_t", CONV_TYPE, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["CUBLAS_SIDE_LEFT"] = {"HIPBLAS_SIDE_LEFT", CONV_NUMERIC_LITERAL, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["CUBLAS_SIDE_RIGHT"] = {"HIPBLAS_SIDE_RIGHT", CONV_NUMERIC_LITERAL, API_BLAS, HIP_UNSUPPORTED}; // Blas Pointer Modes // unsupported yet by hipblas/hcblas - //cuda2hipRename["cublasPointerMode_t"] = {"hipblasPointerMode_t", CONV_TYPE, API_BLAS}; - //cuda2hipRename["CUBLAS_POINTER_MODE_HOST"] = {"HIPBLAS_POINTER_MODE_HOST", CONV_NUMERIC_LITERAL, API_BLAS}; - //cuda2hipRename["CUBLAS_POINTER_MODE_DEVICE"] = {"HIPBLAS_POINTER_MODE_DEVICE", CONV_NUMERIC_LITERAL, API_BLAS}; + cuda2hipRename["cublasPointerMode_t"] = {"hipblasPointerMode_t", CONV_TYPE, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["CUBLAS_POINTER_MODE_HOST"] = {"HIPBLAS_POINTER_MODE_HOST", CONV_NUMERIC_LITERAL, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["CUBLAS_POINTER_MODE_DEVICE"] = {"HIPBLAS_POINTER_MODE_DEVICE", CONV_NUMERIC_LITERAL, API_BLAS, HIP_UNSUPPORTED}; // Blas Atomics Modes // unsupported yet by hipblas/hcblas - //cuda2hipRename["cublasAtomicsMode_t"] = {"hipblasAtomicsMode_t", CONV_TYPE, API_BLAS}; - //cuda2hipRename["CUBLAS_ATOMICS_NOT_ALLOWED"] = {"HIPBLAS_ATOMICS_NOT_ALLOWED", CONV_NUMERIC_LITERAL, API_BLAS}; - //cuda2hipRename["CUBLAS_ATOMICS_ALLOWED"] = {"HIPBLAS_ATOMICS_ALLOWED", CONV_NUMERIC_LITERAL, API_BLAS}; + cuda2hipRename["cublasAtomicsMode_t"] = {"hipblasAtomicsMode_t", CONV_TYPE, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["CUBLAS_ATOMICS_NOT_ALLOWED"] = {"HIPBLAS_ATOMICS_NOT_ALLOWED", CONV_NUMERIC_LITERAL, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["CUBLAS_ATOMICS_ALLOWED"] = {"HIPBLAS_ATOMICS_ALLOWED", CONV_NUMERIC_LITERAL, API_BLAS, HIP_UNSUPPORTED}; // Blas Data Type // unsupported yet by hipblas/hcblas - //cuda2hipRename["cublasDataType_t"] = {"hipblasDataType_t", CONV_TYPE, API_BLAS}; - //cuda2hipRename["CUBLAS_DATA_FLOAT"] = {"HIPBLAS_DATA_FLOAT", CONV_NUMERIC_LITERAL, API_BLAS}; - //cuda2hipRename["CUBLAS_DATA_DOUBLE"] = {"HIPBLAS_DATA_DOUBLE", CONV_NUMERIC_LITERAL, API_BLAS}; - //cuda2hipRename["CUBLAS_DATA_HALF"] = {"HIPBLAS_DATA_HALF", CONV_NUMERIC_LITERAL, API_BLAS}; - //cuda2hipRename["CUBLAS_DATA_INT8"] = {"HIPBLAS_DATA_INT8", CONV_NUMERIC_LITERAL, API_BLAS}; + cuda2hipRename["cublasDataType_t"] = {"hipblasDataType_t", CONV_TYPE, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["CUBLAS_DATA_FLOAT"] = {"HIPBLAS_DATA_FLOAT", CONV_NUMERIC_LITERAL, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["CUBLAS_DATA_DOUBLE"] = {"HIPBLAS_DATA_DOUBLE", CONV_NUMERIC_LITERAL, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["CUBLAS_DATA_HALF"] = {"HIPBLAS_DATA_HALF", CONV_NUMERIC_LITERAL, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["CUBLAS_DATA_INT8"] = {"HIPBLAS_DATA_INT8", CONV_NUMERIC_LITERAL, API_BLAS, HIP_UNSUPPORTED}; // Blas1 (v1) Routines - cuda2hipRename["cublasCreate"] = {"hipblasCreate", CONV_MATH_FUNC, API_BLAS}; - cuda2hipRename["cublasDestroy"] = {"hipblasDestroy", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasCreate"] = {"hipblasCreate", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasDestroy"] = {"hipblasDestroy", CONV_MATH_FUNC, API_BLAS}; - cuda2hipRename["cublasSetVector"] = {"hipblasSetVector", CONV_MATH_FUNC, API_BLAS}; - cuda2hipRename["cublasGetVector"] = {"hipblasGetVector", CONV_MATH_FUNC, API_BLAS}; - cuda2hipRename["cublasSetMatrix"] = {"hipblasSetMatrix", CONV_MATH_FUNC, API_BLAS}; - cuda2hipRename["cublasGetMatrix"] = {"hipblasGetMatrix", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasSetVector"] = {"hipblasSetVector", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasGetVector"] = {"hipblasGetVector", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasSetMatrix"] = {"hipblasSetMatrix", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasGetMatrix"] = {"hipblasGetMatrix", CONV_MATH_FUNC, API_BLAS}; // unsupported yet by hipblas/hcblas - //cuda2hipRename["cublasGetMatrixAsync"] = {"hipblasGetMatrixAsync", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasSetMatrixAsync"] = {"hipblasSetMatrixAsync", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasGetMatrixAsync"] = {"hipblasGetMatrixAsync", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasSetMatrixAsync"] = {"hipblasSetMatrixAsync", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // NRM2 - //cuda2hipRename["cublasSnrm2"] = {"hipblasSnrm2", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDnrm2"] = {"hipblasDnrm2", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasScnrm2"] = {"hipblasScnrm2", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDznrm2"] = {"hipblasDznrm2", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSnrm2"] = {"hipblasSnrm2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDnrm2"] = {"hipblasDnrm2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasScnrm2"] = {"hipblasScnrm2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDznrm2"] = {"hipblasDznrm2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // DOT - cuda2hipRename["cublasSdot"] = {"hipblasSdot", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasSdot"] = {"hipblasSdot", CONV_MATH_FUNC, API_BLAS}; // there is no such a function in CUDA - cuda2hipRename["cublasSdotBatched"] = {"hipblasSdotBatched",CONV_MATH_FUNC, API_BLAS}; - cuda2hipRename["cublasDdot"] = {"hipblasDdot", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasSdotBatched"] = {"hipblasSdotBatched",CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasDdot"] = {"hipblasDdot", CONV_MATH_FUNC, API_BLAS}; // there is no such a function in CUDA - cuda2hipRename["cublasDdotBatched"] = {"hipblasDdotBatched", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCdotu"] = {"hipblasCdotu", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCdotc"] = {"hipblasCdotc", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZdotu"] = {"hipblasZdotu", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZdotc"] = {"hipblasZdotc", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasDdotBatched"] = {"hipblasDdotBatched", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasCdotu"] = {"hipblasCdotu", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCdotc"] = {"hipblasCdotc", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZdotu"] = {"hipblasZdotu", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZdotc"] = {"hipblasZdotc", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // SCAL - cuda2hipRename["cublasSscal"] = {"hipblasSscal", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasSscal"] = {"hipblasSscal", CONV_MATH_FUNC, API_BLAS}; // there is no such a function in CUDA - cuda2hipRename["cublasSscalBatched"] = {"hipblasSscalBatched", CONV_MATH_FUNC, API_BLAS}; - cuda2hipRename["cublasDscal"] = {"hipblasDscal", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasSscalBatched"] = {"hipblasSscalBatched", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasDscal"] = {"hipblasDscal", CONV_MATH_FUNC, API_BLAS}; // there is no such a function in CUDA - cuda2hipRename["cublasDscalBatched"] = {"hipblasDscalBatched", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCscal"] = {"hipblasCscal", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCsscal"] = {"hipblasCsscal", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZscal"] = {"hipblasZscal", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZdscal"] = {"hipblasZdscal", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasDscalBatched"] = {"hipblasDscalBatched", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasCscal"] = {"hipblasCscal", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCsscal"] = {"hipblasCsscal", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZscal"] = {"hipblasZscal", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZdscal"] = {"hipblasZdscal", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // AXPY - cuda2hipRename["cublasSaxpy"] = {"hipblasSaxpy", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasSaxpy"] = {"hipblasSaxpy", CONV_MATH_FUNC, API_BLAS}; // there is no such a function in CUDA - cuda2hipRename["cublasSaxpyBatched"] = {"hipblasSaxpyBatched", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDaxpy"] = {"hipblasDaxpy", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCaxpy"] = {"hipblasCaxpy", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZaxpy"] = {"hipblasZaxpy", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasSaxpyBatched"] = {"hipblasSaxpyBatched", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasDaxpy"] = {"hipblasDaxpy", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCaxpy"] = {"hipblasCaxpy", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZaxpy"] = {"hipblasZaxpy", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // COPY - cuda2hipRename["cublasScopy"] = {"hipblasScopy", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasScopy"] = {"hipblasScopy", CONV_MATH_FUNC, API_BLAS}; // there is no such a function in CUDA - cuda2hipRename["cublasScopyBatched"] = {"hipblasScopyBatched", CONV_MATH_FUNC, API_BLAS}; - cuda2hipRename["cublasDcopy"] = {"hipblasDcopy", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasScopyBatched"] = {"hipblasScopyBatched", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasDcopy"] = {"hipblasDcopy", CONV_MATH_FUNC, API_BLAS}; // there is no such a function in CUDA - cuda2hipRename["cublasDcopyBatched"] = {"hipblasDcopyBatched", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCcopy"] = {"hipblasCcopy", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZcopy"] = {"hipblasZcopy", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasDcopyBatched"] = {"hipblasDcopyBatched", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasCcopy"] = {"hipblasCcopy", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZcopy"] = {"hipblasZcopy", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // SWAP - //cuda2hipRename["cublasSswap"] = {"hipblasSswap", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDswap"] = {"hipblasDswap", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCswap"] = {"hipblasCswap", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZswap"] = {"hipblasZswap", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSswap"] = {"hipblasSswap", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDswap"] = {"hipblasDswap", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCswap"] = {"hipblasCswap", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZswap"] = {"hipblasZswap", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // AMAX //cuda2hipRename["cublasIsamax"] = {"hipblasIsamax", CONV_MATH_FUNC, API_BLAS}; @@ -941,15 +975,21 @@ struct cuda2hipMap { // Blas3 (v1) Routines // GEMM cuda2hipRename["cublasSgemm"] = {"hipblasSgemm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDgemm"] = {"hipblasDgemm", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasDgemm"] = {"hipblasDgemm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCgemm"] = {"hipblasCgemm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZgemm"] = {"hipblasZgemm", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasZgemm"] = {"hipblasZgemm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // BATCH GEMM cuda2hipRename["cublasSgemmBatched"] = {"hipblasSgemmBatched", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDgemmBatched"] = {"hipblasDgemmBatched", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasDgemmBatched"] = {"hipblasDgemmBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCgemmBatched"] = {"hipblasCgemmBatched", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZgemmBatched"] = {"hipblasZgemmBatched", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasZgemmBatched"] = {"hipblasZgemmBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // SYRK //cuda2hipRename["cublasSsyrk"] = {"hipblasSsyrk", CONV_MATH_FUNC, API_BLAS}; @@ -1255,6 +1295,7 @@ struct cuda2hipMap { // DOT cuda2hipRename["cublasSdot_v2"] = {"hipblasSdot", CONV_MATH_FUNC, API_BLAS}; cuda2hipRename["cublasDdot_v2"] = {"hipblasDdot", CONV_MATH_FUNC, API_BLAS}; + //cuda2hipRename["cublasCdotu_v2"] = {"hipblasCdotu", CONV_MATH_FUNC, API_BLAS}; //cuda2hipRename["cublasCdotc_v2"] = {"hipblasCdotc", CONV_MATH_FUNC, API_BLAS}; //cuda2hipRename["cublasZdotu_v2"] = {"hipblasZdotu", CONV_MATH_FUNC, API_BLAS}; @@ -1326,9 +1367,6 @@ struct cuda2hipMap { //cuda2hipRename["cublasSrotmg_v2"] = {"hipblasSrotmg", CONV_MATH_FUNC, API_BLAS}; //cuda2hipRename["cublasDrotmg_v2"] = {"hipblasDrotmg", CONV_MATH_FUNC, API_BLAS}; } - - SmallDenseMap cuda2hipRename; - std::set cudaExcludes; }; StringRef unquoteStr(StringRef s) { @@ -1343,16 +1381,25 @@ public: int64_t countReps[CONV_LAST] = { 0 }; int64_t countApiReps[API_LAST] = { 0 }; + int64_t countRepsUnsupported[CONV_LAST] = { 0 }; + int64_t countApiRepsUnsupported[API_LAST] = { 0 }; protected: struct cuda2hipMap N; Replacements *Replace; virtual void updateCounters(const hipCounter & counter) { - countReps[counter.countType]++; - countRepsTotal[counter.countType]++; - countApiReps[counter.countApiType]++; - countApiRepsTotal[counter.countApiType]++; + if (counter.unsupported) { + countRepsUnsupported[counter.countType]++; + countRepsTotalUnsupported[counter.countType]++; + countApiRepsUnsupported[counter.countApiType]++; + countApiRepsTotalUnsupported[counter.countApiType]++; + } else { + countReps[counter.countType]++; + countRepsTotal[counter.countType]++; + countApiReps[counter.countApiType]++; + countApiRepsTotal[counter.countApiType]++; + } } void processString(StringRef s, SourceManager &SM, SourceLocation start) { @@ -1363,11 +1410,15 @@ protected: const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { StringRef repName = found->second.hipName; - hipCounter counter = { "", CONV_LITERAL, API_RUNTIME }; + hipCounter counter = { "", CONV_LITERAL, API_RUNTIME, found->second.unsupported }; updateCounters(counter); - SourceLocation sl = start.getLocWithOffset(begin + 1); - Replacement Rep(SM, sl, name.size(), repName); - Replace->insert(Rep); + if (!counter.unsupported) { + SourceLocation sl = start.getLocWithOffset(begin + 1); + Replacement Rep(SM, sl, name.size(), repName); + Replace->insert(Rep); + } + } else { + // llvm::outs() << "warning: the following reference is not handled: '" << name << "' [string literal].\n"; } if (end == StringRef::npos) { break; @@ -1408,20 +1459,23 @@ public: if (is_angled) { const auto found = N.cuda2hipRename.find(file_name); if (found != N.cuda2hipRename.end()) { - StringRef repName = found->second.hipName; updateCounters(found->second); - DEBUG(dbgs() << "Include file found: " << file_name << "\n" - << "SourceLocation:" - << filename_range.getBegin().printToString(*_sm) << "\n" - << "Will be replaced with " << repName << "\n"); - SourceLocation sl = filename_range.getBegin(); - SourceLocation sle = filename_range.getEnd(); - const char *B = _sm->getCharacterData(sl); - const char *E = _sm->getCharacterData(sle); - SmallString<128> tmpData; - Replacement Rep(*_sm, sl, E - B, - Twine("<" + repName + ">").toStringRef(tmpData)); - Replace->insert(Rep); + if (!found->second.unsupported) { + StringRef repName = found->second.hipName; + DEBUG(dbgs() << "Include file found: " << file_name << "\n" + << "SourceLocation:" + << filename_range.getBegin().printToString(*_sm) << "\n" + << "Will be replaced with " << repName << "\n"); + SourceLocation sl = filename_range.getBegin(); + SourceLocation sle = filename_range.getEnd(); + const char *B = _sm->getCharacterData(sl); + const char *E = _sm->getCharacterData(sle); + SmallString<128> tmpData; + Replacement Rep(*_sm, sl, E - B, Twine("<" + repName + ">").toStringRef(tmpData)); + Replace->insert(Rep); + } + } else { +// llvm::outs() << "warning: the following reference is not handled: '" << file_name << "' [inclusion directive].\n"; } } } @@ -1436,17 +1490,21 @@ public: StringRef name = T.getIdentifierInfo()->getName(); const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { - StringRef repName = found->second.hipName; updateCounters(found->second); - SourceLocation sl = T.getLocation(); - DEBUG(dbgs() << "Identifier " << name - << " found in definition of macro " - << MacroNameTok.getIdentifierInfo()->getName() << "\n" - << "will be replaced with: " << repName << "\n" - << "SourceLocation: " << sl.printToString(*_sm) - << "\n"); - Replacement Rep(*_sm, sl, name.size(), repName); - Replace->insert(Rep); + if (!found->second.unsupported) { + StringRef repName = found->second.hipName; + SourceLocation sl = T.getLocation(); + DEBUG(dbgs() << "Identifier " << name + << " found in definition of macro " + << MacroNameTok.getIdentifierInfo()->getName() << "\n" + << "will be replaced with: " << repName << "\n" + << "SourceLocation: " << sl.printToString(*_sm) + << "\n"); + Replacement Rep(*_sm, sl, name.size(), repName); + Replace->insert(Rep); + } + } else { + // llvm::outs() << "warning: the following reference is not handled: '" << name << "' [macro].\n"; } } } @@ -1465,42 +1523,50 @@ public: // to workaround the 'const' MacroArgs passed into this hook. const Token *start = Args->getUnexpArgument(i); size_t len = Args->getArgLength(start) + 1; -#if (LLVM_VERSION_MAJOR >= 3) && (LLVM_VERSION_MINOR >= 9) + #if (LLVM_VERSION_MAJOR >= 3) && (LLVM_VERSION_MINOR >= 9) _pp->EnterTokenStream(ArrayRef(start, len), false); -#else + #else _pp->EnterTokenStream(start, len, false, false); -#endif + #endif + int j = 0; do { toks.push_back(Token()); Token &tk = toks.back(); _pp->Lex(tk); + j++; } while (toks.back().isNot(tok::eof)); _pp->RemoveTopOfLexerStack(); // end of stolen code + j = 0; for (auto tok : toks) { if (tok.isAnyIdentifier()) { StringRef name = tok.getIdentifierInfo()->getName(); const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { - StringRef repName = found->second.hipName; updateCounters(found->second); - DEBUG(dbgs() - << "Identifier " << name - << " found as an actual argument in expansion of macro " - << macroName << "\n" - << "will be replaced with: " << repName << "\n"); - size_t length = name.size(); - SourceLocation sl = tok.getLocation(); - if (_sm->isMacroBodyExpansion(sl)) { - LangOptions DefaultLangOptions; - SourceLocation sl_macro = _sm->getExpansionLoc(sl); - SourceLocation sl_end = Lexer::getLocForEndOfToken(sl_macro, 0, *_sm, DefaultLangOptions); - length = _sm->getCharacterData(sl_end) - _sm->getCharacterData(sl_macro); - name = StringRef(_sm->getCharacterData(sl_macro), length); - sl = sl_macro; + if (!found->second.unsupported) { + StringRef repName = found->second.hipName; + DEBUG(dbgs() + << "Identifier " << name + << " found as an actual argument in expansion of macro " + << macroName << "\n" + << "will be replaced with: " << repName << "\n"); + size_t length = name.size(); + SourceLocation sl = tok.getLocation(); + if (_sm->isMacroBodyExpansion(sl)) { + LangOptions DefaultLangOptions; + SourceLocation sl_macro = _sm->getExpansionLoc(sl); + SourceLocation sl_end = Lexer::getLocForEndOfToken(sl_macro, 0, *_sm, DefaultLangOptions); + length = _sm->getCharacterData(sl_end) - _sm->getCharacterData(sl_macro); + name = StringRef(_sm->getCharacterData(sl_macro), length); + sl = sl_macro; + } + Replacement Rep(*_sm, sl, length, repName); + Replace->insert(Rep); } - Replacement Rep(*_sm, sl, length, repName); - Replace->insert(Rep); + } + else { + // llvm::outs() << "warning: the following reference is not handled: '" << name << "' [macro expansion].\n"; } } else if (tok.isLiteral()) { SourceLocation sl = tok.getLocation(); @@ -1512,11 +1578,15 @@ public: StringRef name = StringRef(_sm->getCharacterData(sl_macro), length); const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { - sl = sl_macro; - StringRef repName = found->second.hipName; updateCounters(found->second); - Replacement Rep(*_sm, sl, length, repName); - Replace->insert(Rep); + if (!found->second.unsupported) { + StringRef repName = found->second.hipName; + sl = sl_macro; + Replacement Rep(*_sm, sl, length, repName); + Replace->insert(Rep); + } + } else { + // llvm::outs() << "warning: the following reference is not handled: '" << name << "' [literal macro expansion].\n"; } } else { if (tok.is(tok::string_literal)) { @@ -1525,6 +1595,7 @@ public: } } } + j++; } } } @@ -1579,30 +1650,36 @@ private: StringRef name = funcDcl->getDeclName().getAsString(); const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { - SourceManager *SM = Result.SourceManager; - StringRef repName = found->second.hipName; - SourceLocation sl = call->getLocStart(); - size_t length = name.size(); - bool bReplace = true; - if (SM->isMacroArgExpansion(sl)) { - sl = SM->getImmediateSpellingLoc(sl); - } else if (SM->isMacroBodyExpansion(sl)) { - LangOptions DefaultLangOptions; - SourceLocation sl_macro = SM->getExpansionLoc(sl); - SourceLocation sl_end = Lexer::getLocForEndOfToken(sl_macro, 0, *SM, DefaultLangOptions); - length = SM->getCharacterData(sl_end) - SM->getCharacterData(sl_macro); - StringRef macroName = StringRef(SM->getCharacterData(sl_macro), length); - if (N.cudaExcludes.end() != N.cudaExcludes.find(macroName)) { - bReplace = false; - } else { - sl = sl_macro; + if (!found->second.unsupported) { + SourceManager *SM = Result.SourceManager; + StringRef repName = found->second.hipName; + SourceLocation sl = call->getLocStart(); + size_t length = name.size(); + bool bReplace = true; + if (SM->isMacroArgExpansion(sl)) { + sl = SM->getImmediateSpellingLoc(sl); + } else if (SM->isMacroBodyExpansion(sl)) { + LangOptions DefaultLangOptions; + SourceLocation sl_macro = SM->getExpansionLoc(sl); + SourceLocation sl_end = Lexer::getLocForEndOfToken(sl_macro, 0, *SM, DefaultLangOptions); + length = SM->getCharacterData(sl_end) - SM->getCharacterData(sl_macro); + StringRef macroName = StringRef(SM->getCharacterData(sl_macro), length); + if (N.cudaExcludes.end() != N.cudaExcludes.find(macroName)) { + bReplace = false; + } else { + sl = sl_macro; + } } - } - if (bReplace) { + if (bReplace) { + updateCounters(found->second); + Replacement Rep(*SM, sl, length, repName); + Replace->insert(Rep); + } + } else { updateCounters(found->second); - Replacement Rep(*SM, sl, length, repName); - Replace->insert(Rep); } + } else { + llvm::outs() << "warning: the following reference is not handled: '" << name << "' [function call].\n"; } return true; } @@ -1693,12 +1770,16 @@ private: name = Twine(name + "." + memberName).toStringRef(tmpData); const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { - StringRef repName = found->second.hipName; updateCounters(found->second); - SourceLocation sl = threadIdx->getLocStart(); - SourceManager *SM = Result.SourceManager; - Replacement Rep(*SM, sl, name.size(), repName); - Replace->insert(Rep); + if (!found->second.unsupported) { + StringRef repName = found->second.hipName; + SourceLocation sl = threadIdx->getLocStart(); + SourceManager *SM = Result.SourceManager; + Replacement Rep(*SM, sl, name.size(), repName); + Replace->insert(Rep); + } + } else { + llvm::outs() << "warning: the following reference is not handled: '" << name << "' [builtin].\n"; } } } @@ -1712,12 +1793,16 @@ private: StringRef name = enumConstantRef->getDecl()->getNameAsString(); const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { - StringRef repName = found->second.hipName; updateCounters(found->second); - SourceLocation sl = enumConstantRef->getLocStart(); - SourceManager *SM = Result.SourceManager; - Replacement Rep(*SM, sl, name.size(), repName); - Replace->insert(Rep); + if (!found->second.unsupported) { + StringRef repName = found->second.hipName; + SourceLocation sl = enumConstantRef->getLocStart(); + SourceManager *SM = Result.SourceManager; + Replacement Rep(*SM, sl, name.size(), repName); + Replace->insert(Rep); + } + } else { + llvm::outs() << "warning: the following reference is not handled: '" << name << "' [enum constant ref].\n"; } return true; } @@ -1735,12 +1820,16 @@ private: } const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { - StringRef repName = found->second.hipName; updateCounters(found->second); - SourceLocation sl = enumConstantDecl->getLocStart(); - SourceManager *SM = Result.SourceManager; - Replacement Rep(*SM, sl, name.size(), repName); - Replace->insert(Rep); + if (!found->second.unsupported) { + StringRef repName = found->second.hipName; + SourceLocation sl = enumConstantDecl->getLocStart(); + SourceManager *SM = Result.SourceManager; + Replacement Rep(*SM, sl, name.size(), repName); + Replace->insert(Rep); + } + } else { + llvm::outs() << "warning: the following reference is not handled: '" << name << "' [enum constant decl].\n"; } return true; } @@ -1757,12 +1846,16 @@ private: StringRef name = QT.getAsString(); const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { - StringRef repName = found->second.hipName; updateCounters(found->second); - SourceLocation sl = typedefVar->getLocStart(); - SourceManager *SM = Result.SourceManager; - Replacement Rep(*SM, sl, name.size(), repName); - Replace->insert(Rep); + if (!found->second.unsupported) { + StringRef repName = found->second.hipName; + SourceLocation sl = typedefVar->getLocStart(); + SourceManager *SM = Result.SourceManager; + Replacement Rep(*SM, sl, name.size(), repName); + Replace->insert(Rep); + } + } else { + llvm::outs() << "warning: the following reference is not handled: '" << name << "' [typedef var].\n"; } return true; } @@ -1777,13 +1870,17 @@ private: ->getNameAsString(); const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { - StringRef repName = found->second.hipName; updateCounters(found->second); - TypeLoc TL = structVar->getTypeSourceInfo()->getTypeLoc(); - SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); - SourceManager *SM = Result.SourceManager; - Replacement Rep(*SM, sl, name.size(), repName); - Replace->insert(Rep); + if (!found->second.unsupported) { + StringRef repName = found->second.hipName; + TypeLoc TL = structVar->getTypeSourceInfo()->getTypeLoc(); + SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); + SourceManager *SM = Result.SourceManager; + Replacement Rep(*SM, sl, name.size(), repName); + Replace->insert(Rep); + } + } else { + llvm::outs() << "warning: the following reference is not handled: '" << name << "' [struct var].\n"; } return true; } @@ -1797,13 +1894,17 @@ private: StringRef name = t->getPointeeCXXRecordDecl()->getName(); const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { - StringRef repName = found->second.hipName; updateCounters(found->second); - TypeLoc TL = structVarPtr->getTypeSourceInfo()->getTypeLoc(); - SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); - SourceManager *SM = Result.SourceManager; - Replacement Rep(*SM, sl, name.size(), repName); - Replace->insert(Rep); + if (!found->second.unsupported) { + StringRef repName = found->second.hipName; + TypeLoc TL = structVarPtr->getTypeSourceInfo()->getTypeLoc(); + SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); + SourceManager *SM = Result.SourceManager; + Replacement Rep(*SM, sl, name.size(), repName); + Replace->insert(Rep); + } + } else { + llvm::outs() << "warning: the following reference is not handled: '" << name << "' [struct var ptr].\n"; } } return true; @@ -1819,13 +1920,17 @@ private: StringRef name = type->getAsCXXRecordDecl()->getName(); const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { - StringRef repName = found->second.hipName; updateCounters(found->second); - TypeLoc TL = typeInfo->getTypeLoc(); - SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); - SourceManager *SM = Result.SourceManager; - Replacement Rep(*SM, sl, name.size(), repName); - Replace->insert(Rep); + if (!found->second.unsupported) { + StringRef repName = found->second.hipName; + TypeLoc TL = typeInfo->getTypeLoc(); + SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); + SourceManager *SM = Result.SourceManager; + Replacement Rep(*SM, sl, name.size(), repName); + Replace->insert(Rep); + } + } else { + llvm::outs() << "warning: the following reference is not handled: '" << name << "' [struct sizeof].\n"; } return true; } @@ -1883,13 +1988,17 @@ private: } const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { - StringRef repName = found->second.hipName; updateCounters(found->second); - TypeLoc TL = paramDecl->getTypeSourceInfo()->getTypeLoc(); - SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); - SourceManager *SM = Result.SourceManager; - Replacement Rep(*SM, sl, name.size(), repName); - Replace->insert(Rep); + if (!found->second.unsupported) { + StringRef repName = found->second.hipName; + TypeLoc TL = paramDecl->getTypeSourceInfo()->getTypeLoc(); + SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); + SourceManager *SM = Result.SourceManager; + Replacement Rep(*SM, sl, name.size(), repName); + Replace->insert(Rep); + } + } else { + llvm::outs() << "warning: the following reference is not handled: '" << name << "' [param decl].\n"; } return true; } @@ -1907,13 +2016,17 @@ private: : StringRef(QT.getAsString()); const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { - StringRef repName = found->second.hipName; updateCounters(found->second); - TypeLoc TL = paramDeclPtr->getTypeSourceInfo()->getTypeLoc(); - SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); - SourceManager *SM = Result.SourceManager; - Replacement Rep(*SM, sl, name.size(), repName); - Replace->insert(Rep); + if (!found->second.unsupported) { + StringRef repName = found->second.hipName; + TypeLoc TL = paramDeclPtr->getTypeSourceInfo()->getTypeLoc(); + SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); + SourceManager *SM = Result.SourceManager; + Replacement Rep(*SM, sl, name.size(), repName); + Replace->insert(Rep); + } + } else { + llvm::outs() << "warning: the following reference is not handled: '" << name << "' [param decl ptr].\n"; } } return true; @@ -1936,6 +2049,7 @@ private: StringRef s = sLiteral->getString(); SourceManager *SM = Result.SourceManager; processString(s, *SM, sLiteral->getLocStart()); +// llvm::outs() << "!!!!!!: the following reference is processed as string_Literal: '" << unquoteStr(s) << "' [literal macro expansion].\n"; } return true; } @@ -2098,7 +2212,7 @@ int64_t printStats(std::string fileSource, HipifyPPCallbacks &PPCallbacks, Cuda2 for (int i = 0; i < CONV_LAST; i++) { sum += Callback.countReps[i] + PPCallbacks.countReps[i]; } - llvm::outs() << "Info: converted " << sum << " CUDA->HIP refs ( "; + llvm::outs() << "info: converted " << sum << " CUDA->HIP refs ( "; for (int i = 0; i < CONV_LAST; i++) { llvm::outs() << counterNames[i] << ':' << Callback.countReps[i] + PPCallbacks.countReps[i] << ' '; } @@ -2107,6 +2221,21 @@ int64_t printStats(std::string fileSource, HipifyPPCallbacks &PPCallbacks, Cuda2 llvm::outs() << apiNames[i] << ':' << Callback.countApiReps[i] + PPCallbacks.countApiReps[i] << ' '; } llvm::outs() << ") in \'" << fileSource << "\'\n"; + int64_t sum_unsupported = 0; + for (int i = 0; i < CONV_LAST; i++) { + sum_unsupported += Callback.countRepsUnsupported[i] + PPCallbacks.countRepsUnsupported[i]; + } + if (sum_unsupported > 0) { + llvm::outs() << "info: unconverted " << sum_unsupported << " CUDA->HIP refs ( "; + for (int i = 0; i < CONV_LAST; i++) { + llvm::outs() << counterNames[i] << ':' << Callback.countRepsUnsupported[i] + PPCallbacks.countRepsUnsupported[i] << ' '; + } + llvm::outs() << "), by APIs ( "; + for (int i = 0; i < API_LAST; i++) { + llvm::outs() << apiNames[i] << ':' << Callback.countApiRepsUnsupported[i] + PPCallbacks.countApiRepsUnsupported[i] << ' '; + } + llvm::outs() << ") in \'" << fileSource << "\'\n"; + } return sum; } @@ -2115,7 +2244,7 @@ void printAllStats(int64_t totalFiles, int64_t convertedFiles) { for (int i = 0; i < CONV_LAST; i++) { sum += countRepsTotal[i]; } - llvm::outs() << "Info: totally converted " << sum << " CUDA->HIP refs ( "; + llvm::outs() << "info: totally converted " << sum << " CUDA->HIP refs ( "; for (int i = 0; i < CONV_LAST; i++) { llvm::outs() << counterNames[i] << ':' << countRepsTotal[i] << ' '; } From 191e8fc08e4cb2162bcb6e9a653f27fffb28ac53 Mon Sep 17 00:00:00 2001 From: Rahul Garg Date: Tue, 20 Dec 2016 23:25:16 +0530 Subject: [PATCH 030/281] Removed redundant GetPCIBusID int version function Change-Id: I37f2ff87d09fcfb1e3b104c44c51f606fcb83c01 [ROCm/hip commit: 4704547bab722ecb99a72e5bda631065b300a848] --- projects/hip/include/hip/nvcc_detail/hip_runtime_api.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h b/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h index 5f5931cf1b..7df6706186 100644 --- a/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h @@ -770,11 +770,6 @@ inline static hipError_t hipDeviceGetName(char *name,int len,hipDevice_t device) return hipCUResultTohipError(cuDeviceGetName(name,len,device)); } -inline static hipError_t hipDeviceGetPCIBusId(char* pciBusId,int len,int device) -{ - return hipCUDAErrorTohipError(cudaDeviceGetPCIBusId(pciBusId,len,device)); -} - inline static hipError_t hipDeviceGetPCIBusId(char* pciBusId,int len,hipDevice_t device) { return hipCUResultTohipError(cuDeviceGetPCIBusId(pciBusId,len,device)); From 0215c67ba6220f2852eb8a992d6528aef2639dd2 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Wed, 21 Dec 2016 23:08:01 +0300 Subject: [PATCH 031/281] [HIPIFY] Statistics in CSV file. + Stats by CUDA ref name. + Conversion %. TODO: Calculation of changed code amount, based on actually replaced bytes. [ROCm/hip commit: 4bb8bf8dab2ae03aa95848202c34b905efddead3] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 1222 ++++++++++++-------- 1 file changed, 737 insertions(+), 485 deletions(-) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index f0711a4d89..39ae5ba47f 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -47,6 +47,7 @@ THE SOFTWARE. #include #include #include +#include using namespace clang; using namespace clang::ast_matchers; @@ -96,14 +97,52 @@ enum ApiTypes { }; const char *apiNames[API_LAST] = { - "CUDA", "CUDA RT", "CUBLAS"}; + "CUDA Driver API", "CUDA RT API", "CUBLAS API"}; + +// Set up the command line options +static cl::OptionCategory ToolTemplateCategory("CUDA to HIP source translator options"); + +static cl::opt OutputFilename("o", + cl::desc("Output filename"), + cl::value_desc("filename"), + cl::cat(ToolTemplateCategory)); + +static cl::opt Inplace("inplace", + cl::desc("Modify input file inplace, replacing input with hipified " + "output, save backup in .prehip file"), + cl::value_desc("inplace"), + cl::cat(ToolTemplateCategory)); + +static cl::opt NoBackup("no-backup", + cl::desc("Don't create a backup file for the hipified source"), + cl::value_desc("no-backup"), + cl::cat(ToolTemplateCategory)); + +static cl::opt NoOutput("no-output", + cl::desc("Don't write any translated output to stdout"), + cl::value_desc("no-output"), + cl::cat(ToolTemplateCategory)); + +static cl::opt PrintStats("print-stats", + cl::desc("Print translation statistics"), + cl::value_desc("print-stats"), + cl::cat(ToolTemplateCategory)); + +static cl::opt Examine("examine", + cl::desc("Combines -no-output and -print-stats options"), + cl::value_desc("n"), + cl::cat(ToolTemplateCategory)); + +static cl::extrahelp CommonHelp(CommonOptionsParser::HelpMessage); namespace { -int64_t countRepsTotal[CONV_LAST] = { 0 }; -int64_t countApiRepsTotal[API_LAST] = { 0 }; -int64_t countRepsTotalUnsupported[CONV_LAST] = { 0 }; -int64_t countApiRepsTotalUnsupported[API_LAST] = { 0 }; +uint64_t countRepsTotal[CONV_LAST] = { 0 }; +uint64_t countApiRepsTotal[API_LAST] = { 0 }; +uint64_t countRepsTotalUnsupported[CONV_LAST] = { 0 }; +uint64_t countApiRepsTotalUnsupported[API_LAST] = { 0 }; +std::map cuda2hipConvertedTotal; +std::map cuda2hipUnconvertedTotal; struct hipCounter { StringRef hipName; @@ -113,7 +152,7 @@ struct hipCounter { }; struct cuda2hipMap { - SmallDenseMap cuda2hipRename; + std::map cuda2hipRename; std::set cudaExcludes; cuda2hipMap() { @@ -705,6 +744,8 @@ struct cuda2hipMap { //---------------------------------------BLAS-------------------------------------// // Blas types cuda2hipRename["cublasHandle_t"] = {"hipblasHandle_t", CONV_TYPE, API_BLAS}; + // TODO: dereferencing: typedef struct cublasContext *cublasHandle_t; + cuda2hipRename["cublasContext"] = {"hipblasHandle_t", CONV_TYPE, API_BLAS}; // Blas operations cuda2hipRename["cublasOperation_t"] = {"hipblasOperation_t", CONV_TYPE, API_BLAS}; cuda2hipRename["CUBLAS_OP_N"] = {"HIPBLAS_OP_N", CONV_NUMERIC_LITERAL, API_BLAS}; @@ -827,545 +868,629 @@ struct cuda2hipMap { cuda2hipRename["cublasZswap"] = {"hipblasZswap", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // AMAX - //cuda2hipRename["cublasIsamax"] = {"hipblasIsamax", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasIdamax"] = {"hipblasIdamax", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasIcamax"] = {"hipblasIcamax", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasIzamax"] = {"hipblasIzamax", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasIsamax"] = {"hipblasIsamax", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasIdamax"] = {"hipblasIdamax", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasIcamax"] = {"hipblasIcamax", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasIzamax"] = {"hipblasIzamax", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // AMIN - //cuda2hipRename["cublasIsamin"] = {"hipblasIsamin", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasIdamin"] = {"hipblasIdamin", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasIcamin"] = {"hipblasIcamin", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasIzamin"] = {"hipblasIzamin", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasIsamin"] = {"hipblasIsamin", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasIdamin"] = {"hipblasIdamin", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasIcamin"] = {"hipblasIcamin", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasIzamin"] = {"hipblasIzamin", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // ASUM - cuda2hipRename["cublasSasum"] = {"hipblasSasum", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasSasum"] = {"hipblasSasum", CONV_MATH_FUNC, API_BLAS}; // there is no such a function in CUDA - cuda2hipRename["cublasSasumBatched"] = {"hipblasSasumBatched", CONV_MATH_FUNC, API_BLAS}; - cuda2hipRename["cublasDasum"] = {"hipblasDasum", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasSasumBatched"] = {"hipblasSasumBatched", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasDasum"] = {"hipblasDasum", CONV_MATH_FUNC, API_BLAS}; // there is no such a function in CUDA - cuda2hipRename["cublasDasumBatched"] = {"hipblasDasumBatched", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasScasum"] = {"hipblasScasum", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDzasum"] = {"hipblasDzasum", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasDasumBatched"] = {"hipblasDasumBatched", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasScasum"] = {"hipblasScasum", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDzasum"] = {"hipblasDzasum", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // ROT - //cuda2hipRename["cublasSrot"] = {"hipblasSrot", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDrot"] = {"hipblasDrot", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCrot"] = {"hipblasCrot", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCsrot"] = {"hipblasCsrot", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZrot"] = {"hipblasZrot", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZdrot"] = {"hipblasZdrot", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSrot"] = {"hipblasSrot", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDrot"] = {"hipblasDrot", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCrot"] = {"hipblasCrot", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCsrot"] = {"hipblasCsrot", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZrot"] = {"hipblasZrot", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZdrot"] = {"hipblasZdrot", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // ROTG - //cuda2hipRename["cublasSrotg"] = {"hipblasSrotg", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDrotg"] = {"hipblasDrotg", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCrotg"] = {"hipblasCrotg", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZrotg"] = {"hipblasZrotg", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSrotg"] = {"hipblasSrotg", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDrotg"] = {"hipblasDrotg", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCrotg"] = {"hipblasCrotg", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZrotg"] = {"hipblasZrotg", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // ROTM - //cuda2hipRename["cublasSrotm"] = {"hipblasSrotm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDrotm"] = {"hipblasDrotm", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSrotm"] = {"hipblasSrotm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDrotm"] = {"hipblasDrotm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // ROTMG - //cuda2hipRename["cublasSrotmg"] = {"hipblasSrotmg", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDrotmg"] = {"hipblasDrotmg", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSrotmg"] = {"hipblasSrotmg", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDrotmg"] = {"hipblasDrotmg", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // GEMV - cuda2hipRename["cublasSgemv"] = {"hipblasSgemv", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasSgemv"] = {"hipblasSgemv", CONV_MATH_FUNC, API_BLAS}; // there is no such a function in CUDA - cuda2hipRename["cublasSgemvBatched"] = {"hipblasSgemvBatched", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDgemv"] = {"hipblasDgemv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCgemv"] = {"hipblasCgemv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZgemv"] = {"hipblasZgemv", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasSgemvBatched"] = {"hipblasSgemvBatched", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasDgemv"] = {"hipblasDgemv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCgemv"] = {"hipblasCgemv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZgemv"] = {"hipblasZgemv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // GBMV - //cuda2hipRename["cublasSgbmv"] = {"hipblasSgbmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDgbmv"] = {"hipblasDgbmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCgbmv"] = {"hipblasCgbmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZgbmv"] = {"hipblasZgbmv", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSgbmv"] = {"hipblasSgbmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDgbmv"] = {"hipblasDgbmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCgbmv"] = {"hipblasCgbmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZgbmv"] = {"hipblasZgbmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // TRMV - //cuda2hipRename["cublasStrmv"] = {"hipblasStrmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDtrmv"] = {"hipblasDtrmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCtrmv"] = {"hipblasCtrmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZtrmv"] = {"hipblasZtrmv", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasStrmv"] = {"hipblasStrmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDtrmv"] = {"hipblasDtrmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCtrmv"] = {"hipblasCtrmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZtrmv"] = {"hipblasZtrmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // TBMV - //cuda2hipRename["cublasStbmv"] = {"hipblasStbmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDtbmv"] = {"hipblasDtbmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCtbmv"] = {"hipblasCtbmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZtbmv"] = {"hipblasZtbmv", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasStbmv"] = {"hipblasStbmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDtbmv"] = {"hipblasDtbmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCtbmv"] = {"hipblasCtbmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZtbmv"] = {"hipblasZtbmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // TPMV - //cuda2hipRename["cublasStpmv"] = {"hipblasStpmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDtpmv"] = {"hipblasDtpmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCtpmv"] = {"hipblasCtpmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZtpmv"] = {"hipblasZtpmv", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasStpmv"] = {"hipblasStpmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDtpmv"] = {"hipblasDtpmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCtpmv"] = {"hipblasCtpmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZtpmv"] = {"hipblasZtpmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // TRSV - //cuda2hipRename["cublasStrsv"] = {"hipblasStrsv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDtrsv"] = {"hipblasDtrsv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCtrsv"] = {"hipblasCtrsv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZtrsv"] = {"hipblasZtrsv", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasStrsv"] = {"hipblasStrsv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDtrsv"] = {"hipblasDtrsv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCtrsv"] = {"hipblasCtrsv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZtrsv"] = {"hipblasZtrsv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // TPSV - //cuda2hipRename["cublasStpsv"] = {"hipblasStpsv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDtpsv"] = {"hipblasDtpsv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCtpsv"] = {"hipblasCtpsv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZtpsv"] = {"hipblasZtpsv", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasStpsv"] = {"hipblasStpsv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDtpsv"] = {"hipblasDtpsv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCtpsv"] = {"hipblasCtpsv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZtpsv"] = {"hipblasZtpsv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // TBSV - //cuda2hipRename["cublasStbsv"] = {"hipblasStbsv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDtbsv"] = {"hipblasDtbsv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCtbsv"] = {"hipblasCtbsv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZtbsv"] = {"hipblasZtbsv", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasStbsv"] = {"hipblasStbsv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDtbsv"] = {"hipblasDtbsv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCtbsv"] = {"hipblasCtbsv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZtbsv"] = {"hipblasZtbsv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // SYMV/HEMV - //cuda2hipRename["cublasSsymv"] = {"hipblasSsymv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDsymv"] = {"hipblasDsymv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCsymv"] = {"hipblasCsymv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZsymv"] = {"hipblasZsymv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasChemv"] = {"hipblasChemv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZhemv"] = {"hipblasZhemv", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSsymv"] = {"hipblasSsymv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDsymv"] = {"hipblasDsymv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCsymv"] = {"hipblasCsymv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZsymv"] = {"hipblasZsymv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasChemv"] = {"hipblasChemv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZhemv"] = {"hipblasZhemv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // SBMV/HBMV - //cuda2hipRename["cublasSsbmv"] = {"hipblasSsbmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDsbmv"] = {"hpiblasDsbmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasChbmv"] = {"hipblasChbmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZhbmv"] = {"hipblasZhbmv", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSsbmv"] = {"hipblasSsbmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDsbmv"] = {"hpiblasDsbmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasChbmv"] = {"hipblasChbmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZhbmv"] = {"hipblasZhbmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // SPMV/HPMV - //cuda2hipRename["cublasSspmv"] = {"hipblasSspmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDspmv"] = {"hipblasDspmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasChpmv"] = {"hipblasChpmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZhpmv"] = {"hipblasZhpmv", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSspmv"] = {"hipblasSspmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDspmv"] = {"hipblasDspmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasChpmv"] = {"hipblasChpmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZhpmv"] = {"hipblasZhpmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // GER - cuda2hipRename["cublasSger"] = {"hipblasSger", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDger"] = {"hipblasDger", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCgeru"] = {"hipblasCgeru", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCgerc"] = {"hipblasCgerc", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZgeru"] = {"hipblasZgeru", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZgerc"] = {"hipblasZgerc", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasSger"] = {"hipblasSger", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasDger"] = {"hipblasDger", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCgeru"] = {"hipblasCgeru", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCgerc"] = {"hipblasCgerc", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZgeru"] = {"hipblasZgeru", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZgerc"] = {"hipblasZgerc", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // SYR/HER - //cuda2hipRename["cublasSsyr"] = {"hipblasSsyr", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDsyr"] = {"hipblasDsyr", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCher"] = {"hipblasCher", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZher"] = {"hipblasZher", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSsyr"] = {"hipblasSsyr", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDsyr"] = {"hipblasDsyr", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCher"] = {"hipblasCher", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZher"] = {"hipblasZher", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // SPR/HPR - //cuda2hipRename["cublasSspr"] = {"hipblasSspr", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDspr"] = {"hipblasDspr", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasChpr"] = {"hipblasChpr", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZhpr"] = {"hipblasZhpr", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSspr"] = {"hipblasSspr", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDspr"] = {"hipblasDspr", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasChpr"] = {"hipblasChpr", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZhpr"] = {"hipblasZhpr", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // SYR2/HER2 - //cuda2hipRename["cublasSsyr2"] = {"hipblasSsyr2", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDsyr2"] = {"hipblasDsyr2", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCher2"] = {"hipblasCher2", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZher2"] = {"hipblasZher2", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSsyr2"] = {"hipblasSsyr2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDsyr2"] = {"hipblasDsyr2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCher2"] = {"hipblasCher2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZher2"] = {"hipblasZher2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // SPR2/HPR2 - //cuda2hipRename["cublasSspr2"] = {"hipblasSspr2", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDspr2"] = {"hipblasDspr2", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasChpr2"] = {"hipblasChpr2", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZhpr2"] = {"hipblasZhpr2", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSspr2"] = {"hipblasSspr2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDspr2"] = {"hipblasDspr2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasChpr2"] = {"hipblasChpr2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZhpr2"] = {"hipblasZhpr2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // Blas3 (v1) Routines // GEMM - cuda2hipRename["cublasSgemm"] = {"hipblasSgemm", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasSgemm"] = {"hipblasSgemm", CONV_MATH_FUNC, API_BLAS}; // unsupported yet by hipblas/hcblas - cuda2hipRename["cublasDgemm"] = {"hipblasDgemm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDgemm"] = {"hipblasDgemm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; - cuda2hipRename["cublasCgemm"] = {"hipblasCgemm", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasCgemm"] = {"hipblasCgemm", CONV_MATH_FUNC, API_BLAS}; // unsupported yet by hipblas/hcblas - cuda2hipRename["cublasZgemm"] = {"hipblasZgemm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZgemm"] = {"hipblasZgemm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // BATCH GEMM - cuda2hipRename["cublasSgemmBatched"] = {"hipblasSgemmBatched", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasSgemmBatched"] = {"hipblasSgemmBatched", CONV_MATH_FUNC, API_BLAS}; // unsupported yet by hipblas/hcblas - cuda2hipRename["cublasDgemmBatched"] = {"hipblasDgemmBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDgemmBatched"] = {"hipblasDgemmBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; - cuda2hipRename["cublasCgemmBatched"] = {"hipblasCgemmBatched", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasCgemmBatched"] = {"hipblasCgemmBatched", CONV_MATH_FUNC, API_BLAS}; // unsupported yet by hipblas/hcblas - cuda2hipRename["cublasZgemmBatched"] = {"hipblasZgemmBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZgemmBatched"] = {"hipblasZgemmBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // SYRK - //cuda2hipRename["cublasSsyrk"] = {"hipblasSsyrk", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDsyrk"] = {"hipblasDsyrk", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCsyrk"] = {"hipblasCsyrk", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZsyrk"] = {"hipblasZsyrk", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSsyrk"] = {"hipblasSsyrk", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDsyrk"] = {"hipblasDsyrk", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCsyrk"] = {"hipblasCsyrk", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZsyrk"] = {"hipblasZsyrk", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // HERK - //cuda2hipRename["cublasCherk"] = {"hipblasCherk", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZherk"] = {"hipblasZherk", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasCherk"] = {"hipblasCherk", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZherk"] = {"hipblasZherk", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // SYR2K - //cuda2hipRename["cublasSsyr2k"] = {"hipblasSsyr2k", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDsyr2k"] = {"hipblasDsyr2k", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCsyr2k"] = {"hipblasCsyr2k", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZsyr2k"] = {"hipblasZsyr2k", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSsyr2k"] = {"hipblasSsyr2k", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDsyr2k"] = {"hipblasDsyr2k", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCsyr2k"] = {"hipblasCsyr2k", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZsyr2k"] = {"hipblasZsyr2k", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // SYRKX - eXtended SYRK - // cublasSsyrkx - // cublasDsyrkx - // cublasCsyrkx - // cublasZsyrkx + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSsyrkx"] = {"hipblasSsyrkx", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDsyrkx"] = {"hipblasDsyrkx", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCsyrkx"] = {"hipblasCsyrkx", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZsyrkx"] = {"hipblasZsyrkx", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + // HER2K - //cuda2hipRename["cublasCher2k"] = {"hipblasCher2k", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZher2k"] = {"hipblasZher2k", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasCher2k"] = {"hipblasCher2k", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZher2k"] = {"hipblasZher2k", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // HERKX - eXtended HERK - // cublasCherkx - // cublasZherkx + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasCherkx"] = {"hipblasCherkx", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZherkx"] = {"hipblasZherkx", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // SYMM - //cuda2hipRename["cublasSsymm"] = {"hipblasSsymm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDsymm"] = {"hipblasDsymm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCsymm"] = {"hipblasCsymm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZsymm"] = {"hipblasZsymm", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSsymm"] = {"hipblasSsymm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDsymm"] = {"hipblasDsymm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCsymm"] = {"hipblasCsymm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZsymm"] = {"hipblasZsymm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // HEMM - //cuda2hipRename["cublasChemm"] = {"hipblasChemm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZhemm"] = {"hipblasZhemm", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasChemm"] = {"hipblasChemm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZhemm"] = {"hipblasZhemm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // TRSM - //cuda2hipRename["cublasStrsm"] = {"hipblasStrsm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDtrsm"] = {"hipblasDtrsm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCtrsm"] = {"hipblasCtrsm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZtrsm"] = {"hipblasZtrsm", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasStrsm"] = {"hipblasStrsm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDtrsm"] = {"hipblasDtrsm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCtrsm"] = {"hipblasCtrsm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZtrsm"] = {"hipblasZtrsm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // TRSM - Batched Triangular Solver - //cuda2hipRename["cublasStrsmBatched"] = {"hipblasStrsmBatched", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDtrsmBatched"] = {"hipblasDtrsmBatched", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCtrsmBatched"] = {"hipblasCtrsmBatched", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZtrsmBatched"] = {"hipblasZtrsmBatched", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasStrsmBatched"] = {"hipblasStrsmBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDtrsmBatched"] = {"hipblasDtrsmBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCtrsmBatched"] = {"hipblasCtrsmBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZtrsmBatched"] = {"hipblasZtrsmBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // TRMM - //cuda2hipRename["cublasStrmm"] = {"hipblasStrmm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDtrmm"] = {"hipblasDtrmm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCtrmm"] = {"hipblasCtrmm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZtrmm"] = {"hipblasZtrmm", CONV_MATH_FUNC, API_BLAS}; - - - // TO SUPPORT OR NOT? (cublas_api.h) - // ------------------------ CUBLAS BLAS - like extension + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasStrmm"] = {"hipblasStrmm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDtrmm"] = {"hipblasDtrmm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCtrmm"] = {"hipblasCtrmm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZtrmm"] = {"hipblasZtrmm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + // ------------------------ CUBLAS BLAS - like extension (cublas_api.h) // GEAM - // cublasSgeam - // cublasDgeam - // cublasCgeam - // cublasZgeam + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSgeam"] = {"hipblasSgeam", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDgeam"] = {"hipblasDgeam", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCgeam"] = {"hipblasCgeam", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZgeam"] = {"hipblasZgeam", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // GETRF - Batched LU - // cublasSgetrfBatched - // cublasDgetrfBatched - // cublasCgetrfBatched - // cublasZgetrfBatched + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSgetrfBatched"] = {"hipblasSgetrfBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDgetrfBatched"] = {"hipblasDgetrfBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCgetrfBatched"] = {"hipblasCgetrfBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZgetrfBatched"] = {"hipblasZgetrfBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // Batched inversion based on LU factorization from getrf - // cublasSgetriBatched - // cublasDgetriBatched - // cublasCgetriBatched - // cublasZgetriBatched + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSgetriBatched"] = {"hipblasSgetriBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDgetriBatched"] = {"hipblasDgetriBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCgetriBatched"] = {"hipblasCgetriBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZgetriBatched"] = {"hipblasZgetriBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // Batched solver based on LU factorization from getrf - // cublasSgetrsBatched - // cublasDgetrsBatched - // cublasCgetrsBatched - // cublasZgetrsBatched + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSgetrsBatched"] = {"hipblasSgetrsBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDgetrsBatched"] = {"hipblasDgetrsBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCgetrsBatched"] = {"hipblasCgetrsBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZgetrsBatched"] = {"hipblasZgetrsBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // TRSM - Batched Triangular Solver - // cublasStrsmBatched - // cublasDtrsmBatched - // cublasCtrsmBatched - // cublasZtrsmBatched + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasStrsmBatched"] = {"hipblasStrsmBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDtrsmBatched"] = {"hipblasDtrsmBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCtrsmBatched"] = {"hipblasCtrsmBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZtrsmBatched"] = {"hipblasZtrsmBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // MATINV - Batched - // cublasSmatinvBatched - // cublasDmatinvBatched - // cublasCmatinvBatched - // cublasZmatinvBatched + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSmatinvBatched"] = {"hipblasSmatinvBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDmatinvBatched"] = {"hipblasDmatinvBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCmatinvBatched"] = {"hipblasCmatinvBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZmatinvBatched"] = {"hipblasZmatinvBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // Batch QR Factorization - // cublasSgeqrfBatched - // cublasDgeqrfBatched - // cublasCgeqrfBatched - // cublasZgeqrfBatched + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSgeqrfBatched"] = {"hipblasSgeqrfBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDgeqrfBatched"] = {"hipblasDgeqrfBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCgeqrfBatched"] = {"hipblasCgeqrfBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZgeqrfBatched"] = {"hipblasZgeqrfBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // Least Square Min only m >= n and Non-transpose supported - // cublasSgelsBatched - // cublasDgelsBatched - // cublasCgelsBatched - // cublasZgelsBatched + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSgelsBatched"] = {"hipblasSgelsBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDgelsBatched"] = {"hipblasDgelsBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCgelsBatched"] = {"hipblasCgelsBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZgelsBatched"] = {"hipblasZgelsBatched", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // DGMM - // cublasSdgmm - // cublasDdgmm - // cublasCdgmm - // cublasZdgmm + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSdgmm"] = {"hipblasSdgmm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDdgmm"] = {"hipblasDdgmm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCdgmm"] = {"hipblasCdgmm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZdgmm"] = {"hipblasZdgmm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // TPTTR - Triangular Pack format to Triangular format - // cublasStpttr - // cublasDtpttr - // cublasCtpttr - // cublasZtpttr + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasStpttr"] = {"hipblasStpttr", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDtpttr"] = {"hipblasDtpttr", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCtpttr"] = {"hipblasCtpttr", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZtpttr"] = {"hipblasZtpttr", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // TRTTP - Triangular format to Triangular Pack format - // cublasStrttp - // cublasDtrttp - // cublasCtrttp - // cublasZtrttp + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasStrttp"] = {"hipblasStrttp", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDtrttp"] = {"hipblasDtrttp", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCtrttp"] = {"hipblasCtrttp", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZtrttp"] = {"hipblasZtrttp", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // Blas2 (v2) Routines - cuda2hipRename["cublasCreate_v2"] = {"hipblasCreate", CONV_MATH_FUNC, API_BLAS}; - cuda2hipRename["cublasDestroy_v2"] = {"hipblasDestroy", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasCreate_v2"] = {"hipblasCreate", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasDestroy_v2"] = {"hipblasDestroy", CONV_MATH_FUNC, API_BLAS}; // unsupported yet by hipblas/hcblas - //cuda2hipRename["cublasGetVersion_v2"] = {"hipblasGetVersion", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasSetStream_v2"] = {"hipblasSetStream", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasGetStream_v2"] = {"hipblasGetStream", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasGetPointerMode_v2"] = {"hipblasGetPointerMode", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasSetPointerMode_v2"] = {"hipblasSetPointerMode", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasGetVersion_v2"] = {"hipblasGetVersion", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasSetStream_v2"] = {"hipblasSetStream", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasGetStream_v2"] = {"hipblasGetStream", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasGetPointerMode_v2"] = {"hipblasGetPointerMode", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasSetPointerMode_v2"] = {"hipblasSetPointerMode", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // GEMV - cuda2hipRename["cublasSgemv_v2"] = {"hipblasSgemv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDgemv_v2"] = {"hipblasDgemv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCgemv_v2"] = {"hipblasCgemv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZgemv_v2"] = {"hipblasZgemv", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasSgemv_v2"] = {"hipblasSgemv", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasDgemv_v2"] = {"hipblasDgemv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCgemv_v2"] = {"hipblasCgemv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZgemv_v2"] = {"hipblasZgemv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // GBMV - //cuda2hipRename["cublasSgbmv_v2"] = {"hipblasSgbmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDgbmv_v2"] = {"hipblasDgbmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCgbmv_v2"] = {"hipblasCgbmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZgbmv_v2"] = {"hipblasZgbmv", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSgbmv_v2"] = {"hipblasSgbmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDgbmv_v2"] = {"hipblasDgbmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCgbmv_v2"] = {"hipblasCgbmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZgbmv_v2"] = {"hipblasZgbmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // TRMV - //cuda2hipRename["cublasStrmv_v2"] = {"hipblasStrmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDtrmv_v2"] = {"hipblasDtrmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCtrmv_v2"] = {"hipblasCtrmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZtrmv_v2"] = {"hipblasZtrmv", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasStrmv_v2"] = {"hipblasStrmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDtrmv_v2"] = {"hipblasDtrmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCtrmv_v2"] = {"hipblasCtrmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZtrmv_v2"] = {"hipblasZtrmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // TBMV - //cuda2hipRename["cublasStbmv_v2"] = {"hipblasStbmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDtbmv_v2"] = {"hipblasDtbmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCtbmv_v2"] = {"hipblasCtbmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZtbmv_v2"] = {"hipblasZtbmv", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasStbmv_v2"] = {"hipblasStbmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDtbmv_v2"] = {"hipblasDtbmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCtbmv_v2"] = {"hipblasCtbmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZtbmv_v2"] = {"hipblasZtbmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // TPMV - //cuda2hipRename["cublasStpmv_v2"] = {"hipblasStpmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDtpmv_v2"] = {"hipblasDtpmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCtpmv_v2"] = {"hipblasCtpmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZtpmv_v2"] = {"hipblasZtpmv", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasStpmv_v2"] = {"hipblasStpmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDtpmv_v2"] = {"hipblasDtpmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCtpmv_v2"] = {"hipblasCtpmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZtpmv_v2"] = {"hipblasZtpmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // TRSV - //cuda2hipRename["cublasStrsv_v2"] = {"hipblasStrsv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDtrsv_v2"] = {"hipblasDtrsv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCtrsv_v2"] = {"hipblasCtrsv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZtrsv_v2"] = {"hipblasZtrsv", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasStrsv_v2"] = {"hipblasStrsv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDtrsv_v2"] = {"hipblasDtrsv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCtrsv_v2"] = {"hipblasCtrsv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZtrsv_v2"] = {"hipblasZtrsv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // TPSV - //cuda2hipRename["cublasStpsv_v2"] = {"hipblasStpsv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDtpsv_v2"] = {"hipblasDtpsv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCtpsv_v2"] = {"hipblasCtpsv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZtpsv_v2"] = {"hipblasZtpsv", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasStpsv_v2"] = {"hipblasStpsv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDtpsv_v2"] = {"hipblasDtpsv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCtpsv_v2"] = {"hipblasCtpsv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZtpsv_v2"] = {"hipblasZtpsv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // TBSV - //cuda2hipRename["cublasStbsv_v2"] = {"hipblasStbsv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDtbsv_v2"] = {"hipblasDtbsv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCtbsv_v2"] = {"hipblasCtbsv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZtbsv_v2"] = {"hipblasZtbsv", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasStbsv_v2"] = {"hipblasStbsv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDtbsv_v2"] = {"hipblasDtbsv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCtbsv_v2"] = {"hipblasCtbsv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZtbsv_v2"] = {"hipblasZtbsv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // SYMV/HEMV - //cuda2hipRename["cublasSsymv_v2"] = {"hipblasSsymv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDsymv_v2"] = {"hipblasDsymv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCsymv_v2"] = {"hipblasCsymv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZsymv_v2"] = {"hipblasZsymv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasChemv_v2"] = {"hipblasChemv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZhemv_v2"] = {"hipblasZhemv", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSsymv_v2"] = {"hipblasSsymv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDsymv_v2"] = {"hipblasDsymv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCsymv_v2"] = {"hipblasCsymv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZsymv_v2"] = {"hipblasZsymv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasChemv_v2"] = {"hipblasChemv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZhemv_v2"] = {"hipblasZhemv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // SBMV/HBMV - //cuda2hipRename["cublasSsbmv_v2"] = {"hipblasSsbmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDsbmv_v2"] = {"hpiblasDsbmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasChbmv_v2"] = {"hipblasChbmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZhbmv_v2"] = {"hipblasZhbmv", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSsbmv_v2"] = {"hipblasSsbmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDsbmv_v2"] = {"hpiblasDsbmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasChbmv_v2"] = {"hipblasChbmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZhbmv_v2"] = {"hipblasZhbmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // SPMV/HPMV - //cuda2hipRename["cublasSspmv_v2"] = {"hipblasSspmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDspmv_v2"] = {"hipblasDspmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasChpmv_v2"] = {"hipblasChpmv", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZhpmv_v2"] = {"hipblasZhpmv", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSspmv_v2"] = {"hipblasSspmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDspmv_v2"] = {"hipblasDspmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasChpmv_v2"] = {"hipblasChpmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZhpmv_v2"] = {"hipblasZhpmv", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // GER - cuda2hipRename["cublasSger_v2"] = {"hipblasSger", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDger_v2"] = {"hipblasDger", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCgeru_v2"] = {"hipblasCgeru", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCgerc_v2"] = {"hipblasCgerc", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZgeru_v2"] = {"hipblasZgeru", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZgerc_v2"] = {"hipblasZgerc", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasSger_v2"] = {"hipblasSger", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasDger_v2"] = {"hipblasDger", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCgeru_v2"] = {"hipblasCgeru", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCgerc_v2"] = {"hipblasCgerc", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZgeru_v2"] = {"hipblasZgeru", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZgerc_v2"] = {"hipblasZgerc", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // SYR/HER - //cuda2hipRename["cublasSsyr_v2"] = {"hipblasSsyr", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDsyr_v2"] = {"hipblasDsyr", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCsyr_v2"] = {"hipblasCsyr", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZsyr_v2"] = {"hipblasZsyr", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCher_v2"] = {"hipblasCher", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZher_v2"] = {"hipblasZher", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSsyr_v2"] = {"hipblasSsyr", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDsyr_v2"] = {"hipblasDsyr", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCsyr_v2"] = {"hipblasCsyr", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZsyr_v2"] = {"hipblasZsyr", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCher_v2"] = {"hipblasCher", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZher_v2"] = {"hipblasZher", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // SPR/HPR - //cuda2hipRename["cublasSspr_v2"] = {"hipblasSspr", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDspr_v2"] = {"hipblasDspr", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasChpr_v2"] = {"hipblasChpr", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZhpr_v2"] = {"hipblasZhpr", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSspr_v2"] = {"hipblasSspr", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDspr_v2"] = {"hipblasDspr", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasChpr_v2"] = {"hipblasChpr", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZhpr_v2"] = {"hipblasZhpr", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // SYR2/HER2 - //cuda2hipRename["cublasSsyr2_v2"] = {"hipblasSsyr2", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDsyr2_v2"] = {"hipblasDsyr2", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCsyr2_v2"] = {"hipblasCsyr2", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZsyr2_v2"] = {"hipblasZsyr2", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCher2_v2"] = {"hipblasCher2", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZher2_v2"] = {"hipblasZher2", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSsyr2_v2"] = {"hipblasSsyr2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDsyr2_v2"] = {"hipblasDsyr2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCsyr2_v2"] = {"hipblasCsyr2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZsyr2_v2"] = {"hipblasZsyr2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCher2_v2"] = {"hipblasCher2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZher2_v2"] = {"hipblasZher2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // SPR2/HPR2 - //cuda2hipRename["cublasSspr2_v2"] = {"hipblasSspr2", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDspr2_v2"] = {"hipblasDspr2", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasChpr2_v2"] = {"hipblasChpr2", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZhpr2_v2"] = {"hipblasZhpr2", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSspr2_v2"] = {"hipblasSspr2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDspr2_v2"] = {"hipblasDspr2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasChpr2_v2"] = {"hipblasChpr2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZhpr2_v2"] = {"hipblasZhpr2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // Blas3 (v2) Routines // GEMM - cuda2hipRename["cublasSgemm_v2"] = {"hipblasSgemm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDgemm_v2"] = {"hipblasDgemm", CONV_MATH_FUNC, API_BLAS}; - cuda2hipRename["cublasCgemm_v2"] = {"hipblasCgemm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZgemm_v2"] = {"hipblasZgemm", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasSgemm_v2"] = {"hipblasSgemm", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasDgemm_v2"] = {"hipblasDgemm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + + cuda2hipRename["cublasCgemm_v2"] = {"hipblasCgemm", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasZgemm_v2"] = {"hipblasZgemm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; //IO in FP16 / FP32, computation in float - // cublasSgemmEx + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSgemmEx"] = {"hipblasSgemmEx", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // SYRK - //cuda2hipRename["cublasSsyrk_v2"] = {"hipblasSsyrk", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDsyrk_v2"] = {"hipblasDsyrk", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCsyrk_v2"] = {"hipblasCsyrk", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZsyrk_v2"] = {"hipblasZsyrk", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSsyrk_v2"] = {"hipblasSsyrk", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDsyrk_v2"] = {"hipblasDsyrk", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCsyrk_v2"] = {"hipblasCsyrk", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZsyrk_v2"] = {"hipblasZsyrk", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // HERK - //cuda2hipRename["cublasCherk_v2"] = {"hipblasCherk", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZherk_v2"] = {"hipblasZherk", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasCherk_v2"] = {"hipblasCherk", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZherk_v2"] = {"hipblasZherk", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // SYR2K - //cuda2hipRename["cublasSsyr2k_v2"] = {"hipblasSsyr2k", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDsyr2k_v2"] = {"hipblasDsyr2k", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCsyr2k_v2"] = {"hipblasCsyr2k", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZsyr2k_v2"] = {"hipblasZsyr2k", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSsyr2k_v2"] = {"hipblasSsyr2k", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDsyr2k_v2"] = {"hipblasDsyr2k", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCsyr2k_v2"] = {"hipblasCsyr2k", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZsyr2k_v2"] = {"hipblasZsyr2k", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // HER2K - //cuda2hipRename["cublasCher2k_v2"] = {"hipblasCher2k", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZher2k_v2"] = {"hipblasZher2k", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasCher2k_v2"] = {"hipblasCher2k", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZher2k_v2"] = {"hipblasZher2k", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // SYMM - //cuda2hipRename["cublasSsymm_v2"] = {"hipblasSsymm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDsymm_v2"] = {"hipblasDsymm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCsymm_v2"] = {"hipblasCsymm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZsymm_v2"] = {"hipblasZsymm", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSsymm_v2"] = {"hipblasSsymm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDsymm_v2"] = {"hipblasDsymm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCsymm_v2"] = {"hipblasCsymm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZsymm_v2"] = {"hipblasZsymm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // HEMM - //cuda2hipRename["cublasChemm_v2"] = {"hipblasChemm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZhemm_v2"] = {"hipblasZhemm", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasChemm_v2"] = {"hipblasChemm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZhemm_v2"] = {"hipblasZhemm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // TRSM - //cuda2hipRename["cublasStrsm_v2"] = {"hipblasStrsm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDtrsm_v2"] = {"hipblasDtrsm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCtrsm_v2"] = {"hipblasCtrsm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZtrsm_v2"] = {"hipblasZtrsm", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasStrsm_v2"] = {"hipblasStrsm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDtrsm_v2"] = {"hipblasDtrsm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCtrsm_v2"] = {"hipblasCtrsm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZtrsm_v2"] = {"hipblasZtrsm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // TRMM - //cuda2hipRename["cublasStrmm_v2"] = {"hipblasStrmm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDtrmm_v2"] = {"hipblasDtrmm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCtrmm_v2"] = {"hipblasCtrmm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZtrmm_v2"] = {"hipblasZtrmm", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasStrmm_v2"] = {"hipblasStrmm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDtrmm_v2"] = {"hipblasDtrmm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCtrmm_v2"] = {"hipblasCtrmm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZtrmm_v2"] = {"hipblasZtrmm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // NRM2 - //cuda2hipRename["cublasSnrm2_v2"] = {"hipblasSnrm2", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDnrm2_v2"] = {"hipblasDnrm2", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasScnrm2_v2"] = {"hipblasScnrm2", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDznrm2_v2"] = {"hipblasDznrm2", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSnrm2_v2"] = {"hipblasSnrm2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDnrm2_v2"] = {"hipblasDnrm2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasScnrm2_v2"] = {"hipblasScnrm2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDznrm2_v2"] = {"hipblasDznrm2", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // DOT - cuda2hipRename["cublasSdot_v2"] = {"hipblasSdot", CONV_MATH_FUNC, API_BLAS}; - cuda2hipRename["cublasDdot_v2"] = {"hipblasDdot", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasSdot_v2"] = {"hipblasSdot", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasDdot_v2"] = {"hipblasDdot", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCdotu_v2"] = {"hipblasCdotu", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCdotc_v2"] = {"hipblasCdotc", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZdotu_v2"] = {"hipblasZdotu", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZdotc_v2"] = {"hipblasZdotc", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasCdotu_v2"] = {"hipblasCdotu", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCdotc_v2"] = {"hipblasCdotc", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZdotu_v2"] = {"hipblasZdotu", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZdotc_v2"] = {"hipblasZdotc", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // SCAL - cuda2hipRename["cublasSscal_v2"] = {"hipblasSscal", CONV_MATH_FUNC, API_BLAS}; - cuda2hipRename["cublasDscal_v2"] = {"hipblasDscal", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCscal_v2"] = {"hipblasCscal", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCsscal_v2"] = {"hipblasCsscal", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZscal_v2"] = {"hipblasZscal", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZdscal_v2"] = {"hipblasZdscal", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasSscal_v2"] = {"hipblasSscal", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasDscal_v2"] = {"hipblasDscal", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasCscal_v2"] = {"hipblasCscal", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCsscal_v2"] = {"hipblasCsscal", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZscal_v2"] = {"hipblasZscal", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZdscal_v2"] = {"hipblasZdscal", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // AXPY - cuda2hipRename["cublasSaxpy_v2"] = {"hipblasSaxpy", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDaxpy_v2"] = {"hipblasDaxpy", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCaxpy_v2"] = {"hipblasCaxpy", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZaxpy_v2"] = {"hipblasZaxpy", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasSaxpy_v2"] = {"hipblasSaxpy", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasDaxpy_v2"] = {"hipblasDaxpy", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCaxpy_v2"] = {"hipblasCaxpy", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZaxpy_v2"] = {"hipblasZaxpy", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // COPY - cuda2hipRename["cublasScopy_v2"] = {"hipblasScopy", CONV_MATH_FUNC, API_BLAS}; - cuda2hipRename["cublasDcopy_v2"] = {"hipblasDcopy", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCcopy_v2"] = {"hipblasCcopy", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZcopy_v2"] = {"hipblasZcopy", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasScopy_v2"] = {"hipblasScopy", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasDcopy_v2"] = {"hipblasDcopy", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasCcopy_v2"] = {"hipblasCcopy", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZcopy_v2"] = {"hipblasZcopy", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // SWAP - //cuda2hipRename["cublasSswap_v2"] = {"hipblasSswap", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDswap_v2"] = {"hipblasDswap", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCswap_v2"] = {"hipblasCswap", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZswap_v2"] = {"hipblasZswap", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSswap_v2"] = {"hipblasSswap", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDswap_v2"] = {"hipblasDswap", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCswap_v2"] = {"hipblasCswap", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZswap_v2"] = {"hipblasZswap", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // AMAX - //cuda2hipRename["cublasIsamax_v2"] = {"hipblasIsamax", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasIdamax_v2"] = {"hipblasIdamax", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasIcamax_v2"] = {"hipblasIcamax", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasIzamax_v2"] = {"hipblasIzamax", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasIsamax_v2"] = {"hipblasIsamax", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasIdamax_v2"] = {"hipblasIdamax", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasIcamax_v2"] = {"hipblasIcamax", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasIzamax_v2"] = {"hipblasIzamax", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // AMIN - //cuda2hipRename["cublasIsamin_v2"] = {"hipblasIsamin", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasIdamin_v2"] = {"hipblasIdamin", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasIcamin_v2"] = {"hipblasIcamin", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasIzamin_v2"] = {"hipblasIzamin", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasIsamin_v2"] = {"hipblasIsamin", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasIdamin_v2"] = {"hipblasIdamin", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasIcamin_v2"] = {"hipblasIcamin", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasIzamin_v2"] = {"hipblasIzamin", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // ASUM - cuda2hipRename["cublasSasum_v2"] = {"hipblasSasum", CONV_MATH_FUNC, API_BLAS}; - cuda2hipRename["cublasDasum_v2"] = {"hipblasDasum", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasScasum_v2"] = {"hipblasScasum", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDzasum_v2"] = {"hipblasDzasum", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasSasum_v2"] = {"hipblasSasum", CONV_MATH_FUNC, API_BLAS}; + cuda2hipRename["cublasDasum_v2"] = {"hipblasDasum", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasScasum_v2"] = {"hipblasScasum", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDzasum_v2"] = {"hipblasDzasum", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // ROT - //cuda2hipRename["cublasSrot_v2"] = {"hipblasSrot", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDrot_v2"] = {"hipblasDrot", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCrot_v2"] = {"hipblasCrot", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCsrot_v2"] = {"hipblasCsrot", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZrot_v2"] = {"hipblasZrot", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZdrot_v2"] = {"hipblasZdrot", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSrot_v2"] = {"hipblasSrot", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDrot_v2"] = {"hipblasDrot", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCrot_v2"] = {"hipblasCrot", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCsrot_v2"] = {"hipblasCsrot", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZrot_v2"] = {"hipblasZrot", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZdrot_v2"] = {"hipblasZdrot", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // ROTG - //cuda2hipRename["cublasSrotg_v2"] = {"hipblasSrotg", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDrotg_v2"] = {"hipblasDrotg", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasCrotg_v2"] = {"hipblasCrotg", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasZrotg_v2"] = {"hipblasZrotg", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSrotg_v2"] = {"hipblasSrotg", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDrotg_v2"] = {"hipblasDrotg", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasCrotg_v2"] = {"hipblasCrotg", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasZrotg_v2"] = {"hipblasZrotg", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // ROTM - //cuda2hipRename["cublasSrotm_v2"] = {"hipblasSrotm", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDrotm_v2"] = {"hipblasDrotm", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSrotm_v2"] = {"hipblasSrotm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDrotm_v2"] = {"hipblasDrotm", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // ROTMG - //cuda2hipRename["cublasSrotmg_v2"] = {"hipblasSrotmg", CONV_MATH_FUNC, API_BLAS}; - //cuda2hipRename["cublasDrotmg_v2"] = {"hipblasDrotmg", CONV_MATH_FUNC, API_BLAS}; + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasSrotmg_v2"] = {"hipblasSrotmg", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasDrotmg_v2"] = {"hipblasDrotmg", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; } }; @@ -1379,16 +1504,43 @@ class Cuda2Hip { public: Cuda2Hip(Replacements *R): Replace(R) {} - int64_t countReps[CONV_LAST] = { 0 }; - int64_t countApiReps[API_LAST] = { 0 }; - int64_t countRepsUnsupported[CONV_LAST] = { 0 }; - int64_t countApiRepsUnsupported[API_LAST] = { 0 }; + uint64_t countReps[CONV_LAST] = { 0 }; + uint64_t countApiReps[API_LAST] = { 0 }; + uint64_t countRepsUnsupported[CONV_LAST] = { 0 }; + uint64_t countApiRepsUnsupported[API_LAST] = { 0 }; + std::map cuda2hipConverted; + std::map cuda2hipUnconverted; protected: struct cuda2hipMap N; Replacements *Replace; - virtual void updateCounters(const hipCounter & counter) { + void updateCountersExt(const hipCounter &counter, const std::string &cudaName) { + std::map *map = &cuda2hipConverted; + std::map *mapTotal = &cuda2hipConvertedTotal; + if (counter.unsupported) { + map = &cuda2hipUnconverted; + mapTotal = &cuda2hipUnconvertedTotal; + } + auto found = map->find(cudaName); + if (found == map->end()) { + map->insert(std::pair(cudaName, 1)); + } else { + found->second++; + } + auto foundT = mapTotal->find(cudaName); + if (foundT == mapTotal->end()) { + mapTotal->insert(std::pair(cudaName, 1)); + } else { + foundT->second++; + } + } + + virtual void updateCounters(const hipCounter &counter, const std::string &cudaName) { + if (!PrintStats) { + return; + } + updateCountersExt(counter, cudaName); if (counter.unsupported) { countRepsUnsupported[counter.countType]++; countRepsTotalUnsupported[counter.countType]++; @@ -1410,15 +1562,15 @@ protected: const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { StringRef repName = found->second.hipName; - hipCounter counter = { "", CONV_LITERAL, API_RUNTIME, found->second.unsupported }; - updateCounters(counter); + hipCounter counter = {"", CONV_LITERAL, API_RUNTIME, found->second.unsupported}; + updateCounters(counter, name.str()); if (!counter.unsupported) { SourceLocation sl = start.getLocWithOffset(begin + 1); Replacement Rep(SM, sl, name.size(), repName); Replace->insert(Rep); } } else { - // llvm::outs() << "warning: the following reference is not handled: '" << name << "' [string literal].\n"; + // llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [string literal].\n"; } if (end == StringRef::npos) { break; @@ -1459,7 +1611,7 @@ public: if (is_angled) { const auto found = N.cuda2hipRename.find(file_name); if (found != N.cuda2hipRename.end()) { - updateCounters(found->second); + updateCounters(found->second, file_name.str()); if (!found->second.unsupported) { StringRef repName = found->second.hipName; DEBUG(dbgs() << "Include file found: " << file_name << "\n" @@ -1475,7 +1627,7 @@ public: Replace->insert(Rep); } } else { -// llvm::outs() << "warning: the following reference is not handled: '" << file_name << "' [inclusion directive].\n"; +// llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << file_name << "' [inclusion directive].\n"; } } } @@ -1490,7 +1642,7 @@ public: StringRef name = T.getIdentifierInfo()->getName(); const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { - updateCounters(found->second); + updateCounters(found->second, name.str()); if (!found->second.unsupported) { StringRef repName = found->second.hipName; SourceLocation sl = T.getLocation(); @@ -1504,7 +1656,7 @@ public: Replace->insert(Rep); } } else { - // llvm::outs() << "warning: the following reference is not handled: '" << name << "' [macro].\n"; + // llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [macro].\n"; } } } @@ -1543,7 +1695,7 @@ public: StringRef name = tok.getIdentifierInfo()->getName(); const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { - updateCounters(found->second); + updateCounters(found->second, name.str()); if (!found->second.unsupported) { StringRef repName = found->second.hipName; DEBUG(dbgs() @@ -1564,9 +1716,8 @@ public: Replacement Rep(*_sm, sl, length, repName); Replace->insert(Rep); } - } - else { - // llvm::outs() << "warning: the following reference is not handled: '" << name << "' [macro expansion].\n"; + } else { + // llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [macro expansion].\n"; } } else if (tok.isLiteral()) { SourceLocation sl = tok.getLocation(); @@ -1578,7 +1729,7 @@ public: StringRef name = StringRef(_sm->getCharacterData(sl_macro), length); const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { - updateCounters(found->second); + updateCounters(found->second, name.str()); if (!found->second.unsupported) { StringRef repName = found->second.hipName; sl = sl_macro; @@ -1586,7 +1737,7 @@ public: Replace->insert(Rep); } } else { - // llvm::outs() << "warning: the following reference is not handled: '" << name << "' [literal macro expansion].\n"; + // llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [literal macro expansion].\n"; } } else { if (tok.is(tok::string_literal)) { @@ -1671,15 +1822,15 @@ private: } } if (bReplace) { - updateCounters(found->second); + updateCounters(found->second, name.str()); Replacement Rep(*SM, sl, length, repName); Replace->insert(Rep); } } else { - updateCounters(found->second); + updateCounters(found->second, name.str()); } } else { - llvm::outs() << "warning: the following reference is not handled: '" << name << "' [function call].\n"; + llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [function call].\n"; } return true; } @@ -1687,7 +1838,8 @@ private: } bool cudaLaunchKernel(const MatchFinder::MatchResult &Result) { - if (const CUDAKernelCallExpr *launchKernel = Result.Nodes.getNodeAs("cudaLaunchKernel")) { + StringRef refName = "cudaLaunchKernel"; + if (const CUDAKernelCallExpr *launchKernel = Result.Nodes.getNodeAs(refName)) { SmallString<40> XStr; raw_svector_ostream OS(XStr); StringRef calleeName; @@ -1749,8 +1901,8 @@ private: SM->getCharacterData(launchKernel->getLocStart()); Replacement Rep(*SM, launchKernel->getLocStart(), length, OS.str()); Replace->insert(Rep); - hipCounter counter = { "", CONV_KERN, API_RUNTIME }; - updateCounters(counter); + hipCounter counter = {"hipLaunchKernel", CONV_KERN, API_RUNTIME}; + updateCounters(counter, refName.str()); return true; } return false; @@ -1770,7 +1922,7 @@ private: name = Twine(name + "." + memberName).toStringRef(tmpData); const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { - updateCounters(found->second); + updateCounters(found->second, name.str()); if (!found->second.unsupported) { StringRef repName = found->second.hipName; SourceLocation sl = threadIdx->getLocStart(); @@ -1779,7 +1931,7 @@ private: Replace->insert(Rep); } } else { - llvm::outs() << "warning: the following reference is not handled: '" << name << "' [builtin].\n"; + llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [builtin].\n"; } } } @@ -1793,7 +1945,7 @@ private: StringRef name = enumConstantRef->getDecl()->getNameAsString(); const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { - updateCounters(found->second); + updateCounters(found->second, name.str()); if (!found->second.unsupported) { StringRef repName = found->second.hipName; SourceLocation sl = enumConstantRef->getLocStart(); @@ -1802,7 +1954,7 @@ private: Replace->insert(Rep); } } else { - llvm::outs() << "warning: the following reference is not handled: '" << name << "' [enum constant ref].\n"; + llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [enum constant ref].\n"; } return true; } @@ -1820,7 +1972,7 @@ private: } const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { - updateCounters(found->second); + updateCounters(found->second, name.str()); if (!found->second.unsupported) { StringRef repName = found->second.hipName; SourceLocation sl = enumConstantDecl->getLocStart(); @@ -1829,7 +1981,7 @@ private: Replace->insert(Rep); } } else { - llvm::outs() << "warning: the following reference is not handled: '" << name << "' [enum constant decl].\n"; + llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [enum constant decl].\n"; } return true; } @@ -1846,7 +1998,7 @@ private: StringRef name = QT.getAsString(); const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { - updateCounters(found->second); + updateCounters(found->second, name.str()); if (!found->second.unsupported) { StringRef repName = found->second.hipName; SourceLocation sl = typedefVar->getLocStart(); @@ -1855,7 +2007,7 @@ private: Replace->insert(Rep); } } else { - llvm::outs() << "warning: the following reference is not handled: '" << name << "' [typedef var].\n"; + llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [typedef var].\n"; } return true; } @@ -1870,7 +2022,7 @@ private: ->getNameAsString(); const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { - updateCounters(found->second); + updateCounters(found->second, name.str()); if (!found->second.unsupported) { StringRef repName = found->second.hipName; TypeLoc TL = structVar->getTypeSourceInfo()->getTypeLoc(); @@ -1880,7 +2032,7 @@ private: Replace->insert(Rep); } } else { - llvm::outs() << "warning: the following reference is not handled: '" << name << "' [struct var].\n"; + llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [struct var].\n"; } return true; } @@ -1894,7 +2046,7 @@ private: StringRef name = t->getPointeeCXXRecordDecl()->getName(); const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { - updateCounters(found->second); + updateCounters(found->second, name.str()); if (!found->second.unsupported) { StringRef repName = found->second.hipName; TypeLoc TL = structVarPtr->getTypeSourceInfo()->getTypeLoc(); @@ -1904,7 +2056,7 @@ private: Replace->insert(Rep); } } else { - llvm::outs() << "warning: the following reference is not handled: '" << name << "' [struct var ptr].\n"; + llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [struct var ptr].\n"; } } return true; @@ -1920,7 +2072,7 @@ private: StringRef name = type->getAsCXXRecordDecl()->getName(); const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { - updateCounters(found->second); + updateCounters(found->second, name.str()); if (!found->second.unsupported) { StringRef repName = found->second.hipName; TypeLoc TL = typeInfo->getTypeLoc(); @@ -1930,7 +2082,7 @@ private: Replace->insert(Rep); } } else { - llvm::outs() << "warning: the following reference is not handled: '" << name << "' [struct sizeof].\n"; + llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [struct sizeof].\n"; } return true; } @@ -1938,7 +2090,8 @@ private: } bool cudaSharedIncompleteArrayVar(const MatchFinder::MatchResult &Result) { - if (const VarDecl *sharedVar = Result.Nodes.getNodeAs("cudaSharedIncompleteArrayVar")) { + StringRef refName = "cudaSharedIncompleteArrayVar"; + if (const VarDecl *sharedVar = Result.Nodes.getNodeAs(refName)) { // Example: extern __shared__ uint sRadix1[]; if (sharedVar->hasExternalFormalLinkage()) { QualType QT = sharedVar->getType(); @@ -1969,8 +2122,8 @@ private: StringRef repName = Twine("HIP_DYNAMIC_SHARED(" + typeName + ", " + varName + ")").toStringRef(tmpData); Replacement Rep(*SM, slStart, repLength, repName); Replace->insert(Rep); - hipCounter counter = { "", CONV_MEM, API_RUNTIME }; - updateCounters(counter); + hipCounter counter = {"HIP_DYNAMIC_SHARED", CONV_MEM, API_RUNTIME}; + updateCounters(counter, refName.str()); } } return true; @@ -1988,7 +2141,7 @@ private: } const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { - updateCounters(found->second); + updateCounters(found->second, name.str()); if (!found->second.unsupported) { StringRef repName = found->second.hipName; TypeLoc TL = paramDecl->getTypeSourceInfo()->getTypeLoc(); @@ -1998,7 +2151,7 @@ private: Replace->insert(Rep); } } else { - llvm::outs() << "warning: the following reference is not handled: '" << name << "' [param decl].\n"; + llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [param decl].\n"; } return true; } @@ -2016,7 +2169,7 @@ private: : StringRef(QT.getAsString()); const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { - updateCounters(found->second); + updateCounters(found->second, name.str()); if (!found->second.unsupported) { StringRef repName = found->second.hipName; TypeLoc TL = paramDeclPtr->getTypeSourceInfo()->getTypeLoc(); @@ -2026,7 +2179,7 @@ private: Replace->insert(Rep); } } else { - llvm::outs() << "warning: the following reference is not handled: '" << name << "' [param decl ptr].\n"; + llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [param decl ptr].\n"; } } return true; @@ -2049,7 +2202,6 @@ private: StringRef s = sLiteral->getString(); SourceManager *SM = Result.SourceManager; processString(s, *SM, sLiteral->getLocStart()); -// llvm::outs() << "!!!!!!: the following reference is processed as string_Literal: '" << unquoteStr(s) << "' [literal macro expansion].\n"; } return true; } @@ -2086,8 +2238,8 @@ public: SourceManager *SM = Result.SourceManager; Replacement Rep(*SM, SM->getLocForStartOfFile(SM->getMainFileID()), 0, repName); Replace->insert(Rep); - hipCounter counter = { "", CONV_INCLUDE_CUDA_MAIN_H, API_RUNTIME }; - updateCounters(counter); + hipCounter counter = {"", CONV_INCLUDE_CUDA_MAIN_H, API_RUNTIME}; + updateCounters(counter, ""); } } @@ -2102,49 +2254,13 @@ void HipifyPPCallbacks::handleEndSource() { StringRef repName = "#include \n"; Replacement Rep(*_sm, _sm->getLocForStartOfFile(_sm->getMainFileID()), 0, repName); Replace->insert(Rep); - hipCounter counter = { "", CONV_INCLUDE_CUDA_MAIN_H, API_RUNTIME }; - updateCounters(counter); + hipCounter counter = {"", CONV_INCLUDE_CUDA_MAIN_H, API_RUNTIME}; + updateCounters(counter, ""); } } } // end anonymous namespace -// Set up the command line options -static cl::OptionCategory ToolTemplateCategory("CUDA to HIP source translator options"); - -static cl::opt OutputFilename("o", - cl::desc("Output filename"), - cl::value_desc("filename"), - cl::cat(ToolTemplateCategory)); - -static cl::opt Inplace("inplace", - cl::desc("Modify input file inplace, replacing input with hipified " - "output, save backup in .prehip file"), - cl::value_desc("inplace"), - cl::cat(ToolTemplateCategory)); - -static cl::opt NoBackup("no-backup", - cl::desc("Don't create a backup file for the hipified source"), - cl::value_desc("no-backup"), - cl::cat(ToolTemplateCategory)); - -static cl::opt NoOutput("no-output", - cl::desc("Don't write any translated output to stdout"), - cl::value_desc("no-output"), - cl::cat(ToolTemplateCategory)); - -static cl::opt PrintStats("print-stats", - cl::desc("Print translation statistics"), - cl::value_desc("print-stats"), - cl::cat(ToolTemplateCategory)); - -static cl::opt Examine("examine", - cl::desc("Combines -no-output and -print-stats options"), - cl::value_desc("n"), - cl::cat(ToolTemplateCategory)); - -static cl::extrahelp CommonHelp(CommonOptionsParser::HelpMessage); - void addAllMatchers(ast_matchers::MatchFinder &Finder, Cuda2HipCallback *Callback) { Finder.addMatcher(callExpr(isExpansionInMainFile(), callee(functionDecl(matchesName("cu.*")))) @@ -2207,52 +2323,182 @@ void addAllMatchers(ast_matchers::MatchFinder &Finder, Cuda2HipCallback *Callbac Callback); } -int64_t printStats(std::string fileSource, HipifyPPCallbacks &PPCallbacks, Cuda2HipCallback &Callback) { - int64_t sum = 0; +int64_t printStats(const std::string &csvFile, const std::string &srcFile, HipifyPPCallbacks &PPCallbacks, Cuda2HipCallback &Callback) { + std::ofstream csv(csvFile, std::ios::app); + int64_t sum = 0, sum_interm = 0; + std::string str; + const std::string hipify_info = "[HIPIFY] info: ", separator = ";"; for (int i = 0; i < CONV_LAST; i++) { sum += Callback.countReps[i] + PPCallbacks.countReps[i]; } - llvm::outs() << "info: converted " << sum << " CUDA->HIP refs ( "; - for (int i = 0; i < CONV_LAST; i++) { - llvm::outs() << counterNames[i] << ':' << Callback.countReps[i] + PPCallbacks.countReps[i] << ' '; - } - llvm::outs() << "), by APIs ( "; - for (int i = 0; i < API_LAST; i++) { - llvm::outs() << apiNames[i] << ':' << Callback.countApiReps[i] + PPCallbacks.countApiReps[i] << ' '; - } - llvm::outs() << ") in \'" << fileSource << "\'\n"; int64_t sum_unsupported = 0; for (int i = 0; i < CONV_LAST; i++) { sum_unsupported += Callback.countRepsUnsupported[i] + PPCallbacks.countRepsUnsupported[i]; } - if (sum_unsupported > 0) { - llvm::outs() << "info: unconverted " << sum_unsupported << " CUDA->HIP refs ( "; - for (int i = 0; i < CONV_LAST; i++) { - llvm::outs() << counterNames[i] << ':' << Callback.countRepsUnsupported[i] + PPCallbacks.countRepsUnsupported[i] << ' '; - } - llvm::outs() << "), by APIs ( "; - for (int i = 0; i < API_LAST; i++) { - llvm::outs() << apiNames[i] << ':' << Callback.countApiRepsUnsupported[i] + PPCallbacks.countApiRepsUnsupported[i] << ' '; - } - llvm::outs() << ") in \'" << fileSource << "\'\n"; + if (sum > 0 || sum_unsupported > 0) { + str = "file \'" + srcFile + "\' statistics:\n"; + llvm::outs() << "\n" << hipify_info << str; + csv << "\n" << str; + str = "CONVERTED refs count"; + llvm::outs() << hipify_info << str << ": " << sum << "\n"; + csv << "\n" << str << separator << sum << "\n"; + str = "UNCONVERTED refs count"; + csv << str << separator << sum_unsupported << "\n"; + str = "Conversion %"; + long conv = 100 - std::lround(double(sum_unsupported*100)/double(sum + sum_unsupported)); + csv << str << separator << conv << "%\n"; } + if (sum > 0) { + csv << "\nCUDA ref type" << separator << "Count\n"; + for (int i = 0; i < CONV_LAST; i++) { + sum_interm = Callback.countReps[i] + PPCallbacks.countReps[i]; + if (0 == sum_interm) { + continue; + } + llvm::outs() << " " << counterNames[i] << ": " << sum_interm << "\n"; + csv << counterNames[i] << separator << sum_interm << "\n"; + } + llvm::outs() << hipify_info << "CONVERTED refs by API:\n"; + csv << "\nCUDA API" << separator << "Count\n"; + for (int i = 0; i < API_LAST; i++) { + llvm::outs() << " " << apiNames[i] << ": " << Callback.countApiReps[i] + PPCallbacks.countApiReps[i] << "\n"; + csv << apiNames[i] << separator << Callback.countApiReps[i] + PPCallbacks.countApiReps[i] << "\n"; + } + for (const auto & it : PPCallbacks.cuda2hipConverted) { + const auto found = Callback.cuda2hipConverted.find(it.first); + if (found == Callback.cuda2hipConverted.end()) { + Callback.cuda2hipConverted.insert(std::pair(it.first, 1)); + } else { + found->second += it.second; + } + } + llvm::outs() << hipify_info << "CONVERTED refs by names:\n"; + csv << "\nCUDA ref name" << separator << "Count\n"; + for (const auto & it : Callback.cuda2hipConverted) { + llvm::outs() << " " << it.first << ": " << it.second << "\n"; + csv << it.first << separator << it.second << "\n"; + } + } + if (sum_unsupported > 0) { + str = "UNCONVERTED refs count"; + llvm::outs() << hipify_info << str << ": " << sum_unsupported << "\n"; + csv << "\n" << str << separator << sum_unsupported << "\n"; + csv << "\nUNCONVERTED CUDA ref type" << separator << "Count\n"; + for (int i = 0; i < CONV_LAST; i++) { + sum_interm = Callback.countRepsUnsupported[i] + PPCallbacks.countRepsUnsupported[i]; + if (0 == sum_interm) { + continue; + } + llvm::outs() << " " << counterNames[i] << ": " << sum_interm << "\n"; + csv << counterNames[i] << separator << sum_interm << "\n"; + } + llvm::outs() << hipify_info << "UNCONVERTED refs by API:\n"; + csv << "\nUNCONVERTED CUDA API" << separator << "Count\n"; + for (int i = 0; i < API_LAST; i++) { + llvm::outs() << " " << apiNames[i] << ": " << Callback.countApiRepsUnsupported[i] + PPCallbacks.countApiRepsUnsupported[i] << "\n"; + csv << apiNames[i] << separator << Callback.countApiRepsUnsupported[i] + PPCallbacks.countApiRepsUnsupported[i] << "\n"; + } + for (const auto & it : PPCallbacks.cuda2hipUnconverted) { + const auto found = Callback.cuda2hipUnconverted.find(it.first); + if (found == Callback.cuda2hipUnconverted.end()) { + Callback.cuda2hipUnconverted.insert(std::pair(it.first, 1)); + } else { + found->second += it.second; + } + } + llvm::outs() << hipify_info << "UNCONVERTED refs by names:\n"; + csv << "\nUNCONVERTED CUDA ref name" << separator << "Count\n"; + for (const auto & it : Callback.cuda2hipUnconverted) { + llvm::outs() << " " << it.first << ": " << it.second << "\n"; + csv << it.first << separator << it.second << "\n"; + } + } + csv.close(); return sum; } -void printAllStats(int64_t totalFiles, int64_t convertedFiles) { - int64_t sum = 0; +void printAllStats(const std::string &csvFile, int64_t totalFiles, int64_t convertedFiles) { + std::ofstream csv(csvFile, std::ios::app); + int64_t sum = 0, sum_interm = 0; + std::string str; + const std::string hipify_info = "[HIPIFY] info: ", separator = ";"; for (int i = 0; i < CONV_LAST; i++) { sum += countRepsTotal[i]; } - llvm::outs() << "info: totally converted " << sum << " CUDA->HIP refs ( "; + int64_t sum_unsupported = 0; for (int i = 0; i < CONV_LAST; i++) { - llvm::outs() << counterNames[i] << ':' << countRepsTotal[i] << ' '; + sum_unsupported += countRepsTotalUnsupported[i]; } - llvm::outs() << "), by APIs ( "; - for (int i = 0; i < API_LAST; i++) { - llvm::outs() << apiNames[i] << ':' << countApiRepsTotal[i] << ' '; + if (sum > 0 || sum_unsupported > 0) { + str = "TOTAL statistics:\n"; + llvm::outs() << "\n" << hipify_info << str; + csv << "\n" << str; + str = "CONVERTED files"; + llvm::outs() << " " << str << ": " << convertedFiles << "\n"; + csv << "\n" << str << separator << convertedFiles << "\n"; + str = "PROCESSED files"; + llvm::outs() << " " << str << ": " << totalFiles << "\n"; + csv << str << separator << totalFiles << "\n"; + str = "CONVERTED refs count"; + llvm::outs() << hipify_info << str << ": " << sum << "\n"; + csv << str << separator << sum << "\n"; + str = "UNCONVERTED refs count"; + csv << str << separator << sum_unsupported << "\n"; + str = "Conversion %"; + long conv = 100 - std::lround(double(sum_unsupported * 100) / double(sum + sum_unsupported)); + csv << str << separator << conv << "%\n"; } - llvm::outs() << ") in " << convertedFiles << " files of " << totalFiles << " processed files.\n"; + + if (sum > 0) { + csv << "\nCUDA ref type" << separator << "Count\n"; + for (int i = 0; i < CONV_LAST; i++) { + sum_interm = countRepsTotal[i]; + if (0 == sum_interm) { + continue; + } + llvm::outs() << " " << counterNames[i] << ": " << sum_interm << "\n"; + csv << counterNames[i] << separator << sum_interm << "\n"; + } + llvm::outs() << hipify_info << "CONVERTED refs by API:\n"; + csv << "\nCUDA API" << separator << "Count\n"; + for (int i = 0; i < API_LAST; i++) { + llvm::outs() << " " << apiNames[i] << ": " << countApiRepsTotal[i] << "\n"; + csv << apiNames[i] << separator << countApiRepsTotal[i] << "\n"; + } + llvm::outs() << hipify_info << "CONVERTED refs by names:\n"; + csv << "\nCUDA ref name" << separator << "Count\n"; + for (const auto & it : cuda2hipConvertedTotal) { + llvm::outs() << " " << it.first << ": " << it.second << "\n"; + csv << it.first << separator << it.second << "\n"; + } + } + if (sum_unsupported > 0) { + str = "UNCONVERTED refs count"; + llvm::outs() << hipify_info << str << ": " << sum_unsupported << "\n"; + csv << "\n" << str << separator << sum_unsupported << "\n"; + csv << "\nUNCONVERTED CUDA ref type" << separator << "Count\n"; + for (int i = 0; i < CONV_LAST; i++) { + sum_interm = countRepsTotalUnsupported[i]; + if (0 == sum_interm) { + continue; + } + llvm::outs() << " " << counterNames[i] << ": " << sum_interm << "\n"; + csv << counterNames[i] << separator << sum_interm << "\n"; + } + llvm::outs() << hipify_info << "UNCONVERTED refs by API:\n"; + csv << "\nUNCONVERTED CUDA API" << separator << "Count\n"; + for (int i = 0; i < API_LAST; i++) { + llvm::outs() << " " << apiNames[i] << ": " << countApiRepsTotalUnsupported[i] << "\n"; + csv << apiNames[i] << separator << countApiRepsTotalUnsupported[i] << "\n"; + } + llvm::outs() << hipify_info << "UNCONVERTED refs by names:\n"; + csv << "\nUNCONVERTED CUDA ref name" << separator << "Count\n"; + for (const auto & it : cuda2hipUnconvertedTotal) { + llvm::outs() << " " << it.first << ": " << it.second << "\n"; + csv << it.first << separator << it.second << "\n"; + } + } + csv.close(); } int main(int argc, const char **argv) { @@ -2261,16 +2507,16 @@ int main(int argc, const char **argv) { std::vector fileSources = OptionsParser.getSourcePathList(); std::string dst = OutputFilename; if (!dst.empty() && fileSources.size() > 1) { - llvm::errs() << "Conflict: -o and multiple source files are specified.\n"; + llvm::errs() << "[HIPIFY] conflict: -o and multiple source files are specified.\n"; return 1; } if (NoOutput) { if (Inplace) { - llvm::errs() << "Conflict: both -no-output and -inplace options are specified.\n"; + llvm::errs() << "[HIPIFY] conflict: both -no-output and -inplace options are specified.\n"; return 1; } if (!dst.empty()) { - llvm::errs() << "Conflict: both -no-output and -o options are specified.\n"; + llvm::errs() << "[HIPIFY] conflict: both -no-output and -o options are specified.\n"; return 1; } } @@ -2278,7 +2524,11 @@ int main(int argc, const char **argv) { NoOutput = PrintStats = true; } int Result = 0; + std::string csv = "hipify_stats.csv"; size_t filesTransleted = fileSources.size(); + if (PrintStats && filesTransleted > 1) { + std::remove(csv.c_str()); + } for (const auto & src : fileSources) { if (dst.empty()) { dst = src; @@ -2286,15 +2536,13 @@ int main(int argc, const char **argv) { 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 { + } else { dst += ".hip.cu"; } } - } - else { + } else { if (Inplace) { - llvm::errs() << "Conflict: both -o and -inplace options are specified.\n"; + llvm::errs() << "[HIPIFY] conflict: both -o and -inplace options are specified.\n"; return 1; } dst += ".hip"; @@ -2357,15 +2605,19 @@ int main(int argc, const char **argv) { if (NoOutput) { remove(dst.c_str()); } - dst.clear(); if (PrintStats) { - if (0 == printStats(src, PPCallbacks, Callback)) { + if (fileSources.size() == 1) { + csv = dst + ".csv"; + std::remove(csv.c_str()); + } + if (0 == printStats(csv, src, PPCallbacks, Callback)) { filesTransleted--; } } + dst.clear(); } if (PrintStats && fileSources.size() > 1) { - printAllStats(fileSources.size(), filesTransleted); + printAllStats(csv, fileSources.size(), filesTransleted); } return Result; } From c1ac04322a7984bf1b15562e77e9badc26af62ac Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Wed, 21 Dec 2016 15:28:27 -0600 Subject: [PATCH 032/281] Increment API sequence number. Change name to tls_tidInfo [ROCm/hip commit: 37d8cafb12104ba32d7b8de038ad342c81592338] --- projects/hip/src/hip_hcc.cpp | 10 +++++----- projects/hip/src/hip_hcc.h | 16 +++++++++------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/projects/hip/src/hip_hcc.cpp b/projects/hip/src/hip_hcc.cpp index 19d7e1169d..14cfd61982 100644 --- a/projects/hip/src/hip_hcc.cpp +++ b/projects/hip/src/hip_hcc.cpp @@ -123,7 +123,7 @@ std::vector g_dbStopTriggers; thread_local hipError_t tls_lastHipError = hipSuccess; -thread_local ShortTid tls_shortTid; +thread_local TidInfo tls_tidInfo; @@ -133,8 +133,8 @@ thread_local ShortTid tls_shortTid; //================================================================================================= void recordApiTrace(std::string *fullStr, const std::string &apiStr) { - auto apiSeqNum = tls_shortTid.incApiSeqNum(); - auto tid = tls_shortTid.tid(); + auto apiSeqNum = tls_tidInfo.apiSeqNum(); + auto tid = tls_tidInfo.tid(); if ((tid < g_dbStartTriggers.size()) && (apiSeqNum >= g_dbStartTriggers[tid].nextTrigger())) { printf ("info: resume profiling at %lu\n", apiSeqNum); @@ -214,7 +214,7 @@ hipError_t ihipSynchronize(void) //================================================================================================= // ihipStream_t: //================================================================================================= -ShortTid::ShortTid() : +TidInfo::TidInfo() : _apiSeqNum(0) { _shortTid = g_lastShortTid.fetch_add(1); @@ -1373,7 +1373,7 @@ void ihipPrintKernelLaunch(const char *kernelName, const grid_launch_parm *lp, c std::stringstream os_pre; std::stringstream os; os_pre << "<grid_dim << " groupDim:" << lp->group_dim diff --git a/projects/hip/src/hip_hcc.h b/projects/hip/src/hip_hcc.h index ac4d493862..ed85f1494c 100644 --- a/projects/hip/src/hip_hcc.h +++ b/projects/hip/src/hip_hcc.h @@ -66,10 +66,10 @@ extern int HIP_DISABLE_HW_KERNEL_DEP; // Class to assign a short TID to each new thread, for HIP debugging purposes. -class ShortTid { +class TidInfo { public: - ShortTid() ; + TidInfo() ; int tid() const { return _shortTid; }; uint64_t incApiSeqNum() { return ++_apiSeqNum; }; @@ -106,7 +106,7 @@ private: //--- //Extern tls extern thread_local hipError_t tls_lastHipError; -extern thread_local ShortTid tls_shortTid; +extern thread_local TidInfo tls_tidInfo; extern std::vector g_dbStartTriggers; extern std::vector g_dbStopTriggers; @@ -162,7 +162,7 @@ extern const char *API_COLOR_END; // Compile support for trace markers that are displayed on CodeXL GUI at start/stop of each function boundary. -// TODO - currently we print the trace message at the beginning. if we waited, we could also include return codes, and any values returned +// TODO - currently we print the trace message at the beginning. if we waited, we could also tls_tidInfo return codes, and any values returned // through ptr-to-args (ie the pointers allocated by hipMalloc). #if COMPILE_HIP_ATP_MARKER #include "CXLActivityLogger.h" @@ -184,6 +184,7 @@ extern void recordApiTrace(std::string *fullStr, const std::string &apiStr); #if COMPILE_HIP_ATP_MARKER || (COMPILE_HIP_TRACE_API & 0x1) #define API_TRACE(...)\ {\ + tls_tidInfo.incApiSeqNum();\ if (HIP_PROFILE_API || (COMPILE_HIP_DB && HIP_TRACE_API)) {\ std::string apiStr = std::string(__func__) + " (" + ToString(__VA_ARGS__) + ')';\ std::string fullStr;\ @@ -194,7 +195,8 @@ extern void recordApiTrace(std::string *fullStr, const std::string &apiStr); } #else // Swallow API_TRACE -#define API_TRACE(...) +#define API_TRACE(...)\ + tls_tidInfo.incApiSeqNum(); #endif @@ -217,7 +219,7 @@ extern void recordApiTrace(std::string *fullStr, const std::string &apiStr); tls_lastHipError = localHipStatus;\ \ if ((COMPILE_HIP_TRACE_API & 0x2) && HIP_TRACE_API) {\ - fprintf(stderr, " %ship-api tid:%d.%lu %-30s ret=%2d (%s)>>%s\n", (localHipStatus == 0) ? API_COLOR:KRED, tls_shortTid.tid(),tls_shortTid.apiSeqNum(), __func__, localHipStatus, ihipErrorString(localHipStatus), API_COLOR_END);\ + fprintf(stderr, " %ship-api tid:%d.%lu %-30s ret=%2d (%s)>>%s\n", (localHipStatus == 0) ? API_COLOR:KRED, tls_tidInfo.tid(),tls_tidInfo.apiSeqNum(), __func__, localHipStatus, ihipErrorString(localHipStatus), API_COLOR_END);\ }\ if (HIP_PROFILE_API) { MARKER_END(); }\ localHipStatus;\ @@ -258,7 +260,7 @@ static const DbName dbName [] = if (HIP_DB & (1<<(trace_level))) {\ char msgStr[1000];\ snprintf(msgStr, 2000, __VA_ARGS__);\ - fprintf (stderr, " %ship-%s tid:%d:%s%s", dbName[trace_level]._color, dbName[trace_level]._shortName, tls_shortTid.tid(), msgStr, KNRM); \ + fprintf (stderr, " %ship-%s tid:%d:%s%s", dbName[trace_level]._color, dbName[trace_level]._shortName, tls_tidInfo.tid(), msgStr, KNRM); \ }\ } #else From 63ab898d17e747beceeeb09dfbba3ad7dccfb6e4 Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Thu, 22 Dec 2016 15:30:38 +0530 Subject: [PATCH 033/281] hip_hcc package changes - updated hip_hcc package creation dependencies - support build hip_hcc package for HCC-1.0 Change-Id: Idf23e415eff8cb352a8906191c79bd822c7618e7 [ROCm/hip commit: 9b6d1588baaf4216b6e009958af221c73c8adf3d] --- projects/hip/CMakeLists.txt | 5 ++++- projects/hip/packaging/hip_hcc.txt | 21 ++++++++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/projects/hip/CMakeLists.txt b/projects/hip/CMakeLists.txt index c76410f06d..508880104d 100644 --- a/projects/hip/CMakeLists.txt +++ b/projects/hip/CMakeLists.txt @@ -78,6 +78,9 @@ if(HIP_PLATFORM STREQUAL "hcc") add_to_config(_buildInfo HCC_VERSION) string(REPLACE "-" ";" HCC_VERSION_LIST ${HCC_VERSION}) list(GET HCC_VERSION_LIST 0 HCC_PACKAGE_VERSION) + string(REPLACE "." ";" HCC_VERSION_LIST ${HCC_PACKAGE_VERSION}) + list(GET HCC_VERSION_LIST 0 HCC_VERSION_MAJOR) + list(GET HCC_VERSION_LIST 1 HCC_VERSION_MINOR) # Determine HSA_PATH if(NOT DEFINED HSA_PATH) @@ -269,7 +272,7 @@ add_custom_target(pkg_hip_hcc COMMAND ${CMAKE_COMMAND} . COMMAND cp *.rpm ${PROJECT_BINARY_DIR} COMMAND cp *.tar.gz ${PROJECT_BINARY_DIR} WORKING_DIRECTORY ${BUILD_DIR} - DEPENDS hip_hcc) + DEPENDS hip_hcc hip_device hip_hcc_static) # Package: hip_nvcc set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/packages/hip_nvcc) diff --git a/projects/hip/packaging/hip_hcc.txt b/projects/hip/packaging/hip_hcc.txt index 00a62ab14c..18314a9b6d 100644 --- a/projects/hip/packaging/hip_hcc.txt +++ b/projects/hip/packaging/hip_hcc.txt @@ -12,7 +12,15 @@ install(FILES @hip_SOURCE_DIR@/src/hip_ir.ll DESTINATION lib) ############################# set(CPACK_SET_DESTDIR TRUE) set(CPACK_INSTALL_PREFIX "/opt/rocm/hip") -set(CPACK_PACKAGE_NAME "hip_hcc") +if(@HCC_VERSION_MAJOR@ EQUAL 0) + set(CPACK_PACKAGE_NAME "hip_hcc") + set(HCC_PACKAGE_NAME "hcc_lc") + set(HIP_PACKAGE_CONFLICTS "hip_hcc_exp") +else() + set(CPACK_PACKAGE_NAME "hip_hcc_exp") + set(HCC_PACKAGE_NAME "hcc") + set(HIP_PACKAGE_CONFLICTS "hip_hcc") +endif() set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "HIP: Heterogenous-computing Interface for Portability [HCC]") set(CPACK_PACKAGE_VENDOR "Advanced Micro Devices, Inc.") set(CPACK_PACKAGE_CONTACT "Maneesh Gupta ") @@ -25,19 +33,22 @@ set(CPACK_GENERATOR "TGZ;DEB;RPM") set(CPACK_BINARY_DEB "ON") set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${PROJECT_BINARY_DIR}/postinst;${PROJECT_BINARY_DIR}/prerm") if(@COMPILE_HIP_ATP_MARKER@) - set(CPACK_DEBIAN_PACKAGE_DEPENDS "hip_base (= ${CPACK_PACKAGE_VERSION}), hcc_lc (= @HCC_PACKAGE_VERSION@), rocm-profiler") + set(CPACK_DEBIAN_PACKAGE_DEPENDS "hip_base (= ${CPACK_PACKAGE_VERSION}), ${HCC_PACKAGE_NAME} (= @HCC_PACKAGE_VERSION@), rocm-profiler") else() - set(CPACK_DEBIAN_PACKAGE_DEPENDS "hip_base (= ${CPACK_PACKAGE_VERSION}), hcc_lc (= @HCC_PACKAGE_VERSION@)") + set(CPACK_DEBIAN_PACKAGE_DEPENDS "hip_base (= ${CPACK_PACKAGE_VERSION}), ${HCC_PACKAGE_NAME} (= @HCC_PACKAGE_VERSION@)") endif() +set(CPACK_DEBIAN_PACKAGE_CONFLICTS ${HIP_PACKAGE_CONFLICTS}) +set(CPACK_DEBIAN_PACKAGE_REPLACES ${HIP_PACKAGE_CONFLICTS}) set(CPACK_BINARY_RPM "ON") set(CPACK_RPM_PACKAGE_ARCHITECTURE "x86_64") set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${PROJECT_BINARY_DIR}/postinst") set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${PROJECT_BINARY_DIR}/prerm") set(CPACK_RPM_PACKAGE_AUTOREQPROV " no") +set(CPACK_RPM_PACKAGE_REQUIRES_PREUN ${HIP_PACKAGE_CONFLICTS}) if(@COMPILE_HIP_ATP_MARKER@) - set(CPACK_RPM_PACKAGE_REQUIRES "hip_base = ${CPACK_PACKAGE_VERSION}, hcc_lc = @HCC_PACKAGE_VERSION@, rocm-profiler") + set(CPACK_RPM_PACKAGE_REQUIRES "hip_base = ${CPACK_PACKAGE_VERSION}, ${HCC_PACKAGE_NAME} = @HCC_PACKAGE_VERSION@, rocm-profiler") else() - set(CPACK_RPM_PACKAGE_REQUIRES "hip_base = ${CPACK_PACKAGE_VERSION}, hcc_lc = @HCC_PACKAGE_VERSION@") + set(CPACK_RPM_PACKAGE_REQUIRES "hip_base = ${CPACK_PACKAGE_VERSION}, ${HCC_PACKAGE_NAME} = @HCC_PACKAGE_VERSION@") endif() set(CPACK_SOURCE_GENERATOR "TGZ") include(CPack) From ec4f4a643d32df694ecb7ea85a5a536fb995da8c Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Thu, 22 Dec 2016 12:23:58 -0600 Subject: [PATCH 034/281] Support size_t in memset kernel. Add disable for HSA_AMD_AGENT_INFO_MAX_WAVES_PER_CU Remove one copy of completion_future in memset. [ROCm/hip commit: c325c988b11e65c031734b4ae8206ed666abb8bc] --- projects/hip/src/hip_hcc.cpp | 8 ++++++++ projects/hip/src/hip_memory.cpp | 20 ++++++++++---------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/projects/hip/src/hip_hcc.cpp b/projects/hip/src/hip_hcc.cpp index 14cfd61982..a4ef2b392b 100644 --- a/projects/hip/src/hip_hcc.cpp +++ b/projects/hip/src/hip_hcc.cpp @@ -52,6 +52,10 @@ THE SOFTWARE. #define USE_COPY_EXT_V2 1 #endif +#ifndef USE_ROCR_1_4 +#define USE_ROCR_1_4 1 +#endif + //================================================================================================= //Global variables: //================================================================================================= @@ -733,7 +737,11 @@ hipError_t ihipDevice_t::initProperties(hipDeviceProp_t* prop) // Get Max Threads Per Multiprocessor uint32_t max_waves_per_cu; +#if USE_ROCR_1_4 err = hsa_agent_get_info(_hsaAgent,(hsa_agent_info_t) HSA_AMD_AGENT_INFO_MAX_WAVES_PER_CU, &max_waves_per_cu); +#else + max_waves_per_cu = 10; +#endif DeviceErrorCheck(err); prop-> maxThreadsPerMultiProcessor = prop->warpSize*max_waves_per_cu; diff --git a/projects/hip/src/hip_memory.cpp b/projects/hip/src/hip_memory.cpp index 7aa6ef4942..7e1a1738a6 100644 --- a/projects/hip/src/hip_memory.cpp +++ b/projects/hip/src/hip_memory.cpp @@ -765,10 +765,11 @@ hipError_t hipMemcpyToArray(hipArray* dst, size_t wOffset, size_t hOffset, // TODO - make member function of stream? template -hc::completion_future +void ihipMemsetKernel(hipStream_t stream, LockedAccessor_StreamCrit_t &crit, - T * ptr, T val, size_t sizeBytes) + T * ptr, T val, size_t sizeBytes, + hc::completion_future *cf) { int wg = std::min((unsigned)8, stream->getDevice()->_computeUnits); const int threads_per_wg = 256; @@ -782,7 +783,7 @@ ihipMemsetKernel(hipStream_t stream, hc::extent<1> ext(threads); auto ext_tile = ext.tile(threads_per_wg); - hc::completion_future cf = + *cf = hc::parallel_for_each( crit->_av, ext_tile, @@ -798,7 +799,6 @@ ihipMemsetKernel(hipStream_t stream, } }); - return cf; } // TODO-sync: function is async unless target is pinned host memory - then these are fully sync. @@ -819,8 +819,8 @@ hipError_t hipMemsetAsync(void* dst, int value, size_t sizeBytes, hipStream_t s // use a faster dword-per-workitem copy: try { value = value & 0xff; - unsigned value32 = (value << 24) | (value << 16) | (value << 8) | (value) ; - cf = ihipMemsetKernel (stream, crit, static_cast (dst), value32, sizeBytes/sizeof(unsigned)); + uint32_t value32 = (value << 24) | (value << 16) | (value << 8) | (value) ; + ihipMemsetKernel (stream, crit, static_cast (dst), value32, sizeBytes/sizeof(uint32_t), &cf); } catch (std::exception &ex) { e = hipErrorInvalidValue; @@ -828,7 +828,7 @@ hipError_t hipMemsetAsync(void* dst, int value, size_t sizeBytes, hipStream_t s } else { // use a slow byte-per-workitem copy: try { - cf = ihipMemsetKernel (stream, crit, static_cast (dst), value, sizeBytes); + ihipMemsetKernel (stream, crit, static_cast (dst), value, sizeBytes, &cf); } catch (std::exception &ex) { e = hipErrorInvalidValue; @@ -870,8 +870,8 @@ hipError_t hipMemset(void* dst, int value, size_t sizeBytes ) // use a faster dword-per-workitem copy: try { value = value & 0xff; - unsigned value32 = (value << 24) | (value << 16) | (value << 8) | (value) ; - cf = ihipMemsetKernel (stream, crit, static_cast (dst), value32, sizeBytes/sizeof(unsigned)); + uint32_t value32 = (value << 24) | (value << 16) | (value << 8) | (value) ; + ihipMemsetKernel (stream, crit, static_cast (dst), value32, sizeBytes/sizeof(uint32_t), &cf); } catch (std::exception &ex) { e = hipErrorInvalidValue; @@ -879,7 +879,7 @@ hipError_t hipMemset(void* dst, int value, size_t sizeBytes ) } else { // use a slow byte-per-workitem copy: try { - cf = ihipMemsetKernel (stream, crit, static_cast (dst), value, sizeBytes); + ihipMemsetKernel (stream, crit, static_cast (dst), value, sizeBytes, &cf); } catch (std::exception &ex) { e = hipErrorInvalidValue; From 5d44da9e46c317dba21acd8c08decb59f20d7c37 Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Fri, 23 Dec 2016 11:49:00 +0530 Subject: [PATCH 035/281] hipcc: link to hip runtime using absolute path Change-Id: I714b3e9da0bc1d49665b079d9c4cec1c1a2efa80 [ROCm/hip commit: f6e9f6f0bfe0f13007bc7ac8e6b92b9130637e1e] --- projects/hip/bin/hipcc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/hip/bin/hipcc b/projects/hip/bin/hipcc index 7d2675d0ba..e85e803888 100755 --- a/projects/hip/bin/hipcc +++ b/projects/hip/bin/hipcc @@ -339,9 +339,9 @@ if ($setStdLib eq 0 and $HIP_PLATFORM eq 'hcc') if ($needHipHcc) { if ($linkType eq 0) { - substr($HIPLDFLAGS,0,0) = " -L$HIP_PATH/lib -lhip_hcc_static -lhip_device " ; + substr($HIPLDFLAGS,0,0) = " $HIP_PATH/lib/libhip_hcc_static.a $HIP_PATH/lib/libhip_device.a " ; } else { - substr($HIPLDFLAGS,0,0) = " -L$HIP_PATH/lib -Wl,--rpath=$HIP_PATH/lib -lhip_hcc -lhip_device "; + substr($HIPLDFLAGS,0,0) = " -Wl,--rpath=$HIP_PATH/lib $HIP_PATH/lib/libhip_hcc.so $HIP_PATH/lib/libhip_device.a "; } } From d152a89e796664bbd8dbc1b93ebfa0b75c570fba Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Fri, 23 Dec 2016 17:40:06 +0300 Subject: [PATCH 036/281] [HIPIFY] Stats: Calculation of changed code amount, based on actually replaced bytes. + REPLACED bytes, TOTAL bytes & CODE CHANGED are added to statistics. + -o-stats option for specifying the file with statistic. [ROCm/hip commit: 6882057fd28fe2cb84ea1361c33f6a7204eaeb12] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 108 +++++++++++++++------ 1 file changed, 76 insertions(+), 32 deletions(-) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index 39ae5ba47f..4825227b13 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -108,8 +108,7 @@ static cl::opt OutputFilename("o", cl::cat(ToolTemplateCategory)); static cl::opt Inplace("inplace", - cl::desc("Modify input file inplace, replacing input with hipified " - "output, save backup in .prehip file"), + cl::desc("Modify input file inplace, replacing input with hipified output, save backup in .prehip file"), cl::value_desc("inplace"), cl::cat(ToolTemplateCategory)); @@ -128,9 +127,14 @@ static cl::opt PrintStats("print-stats", cl::value_desc("print-stats"), cl::cat(ToolTemplateCategory)); +static cl::opt OutputStatsFilename("o-stats", + cl::desc("Output filename for statistics"), + cl::value_desc("filename"), + cl::cat(ToolTemplateCategory)); + static cl::opt Examine("examine", cl::desc("Combines -no-output and -print-stats options"), - cl::value_desc("n"), + cl::value_desc("examine"), cl::cat(ToolTemplateCategory)); static cl::extrahelp CommonHelp(CommonOptionsParser::HelpMessage); @@ -2238,8 +2242,8 @@ public: SourceManager *SM = Result.SourceManager; Replacement Rep(*SM, SM->getLocForStartOfFile(SM->getMainFileID()), 0, repName); Replace->insert(Rep); - hipCounter counter = {"", CONV_INCLUDE_CUDA_MAIN_H, API_RUNTIME}; - updateCounters(counter, ""); + hipCounter counter = { repName, CONV_INCLUDE_CUDA_MAIN_H, API_RUNTIME }; + updateCounters(counter, repName); } } @@ -2254,8 +2258,8 @@ void HipifyPPCallbacks::handleEndSource() { StringRef repName = "#include \n"; Replacement Rep(*_sm, _sm->getLocForStartOfFile(_sm->getMainFileID()), 0, repName); Replace->insert(Rep); - hipCounter counter = {"", CONV_INCLUDE_CUDA_MAIN_H, API_RUNTIME}; - updateCounters(counter, ""); + hipCounter counter = { repName, CONV_INCLUDE_CUDA_MAIN_H, API_RUNTIME }; + updateCounters(counter, repName); } } @@ -2323,7 +2327,9 @@ void addAllMatchers(ast_matchers::MatchFinder &Finder, Cuda2HipCallback *Callbac Callback); } -int64_t printStats(const std::string &csvFile, const std::string &srcFile, HipifyPPCallbacks &PPCallbacks, Cuda2HipCallback &Callback) { +int64_t printStats(const std::string &csvFile, const std::string &srcFile, + HipifyPPCallbacks &PPCallbacks, Cuda2HipCallback &Callback, + uint64_t replacedBytes, uint64_t totalBytes) { std::ofstream csv(csvFile, std::ios::app); int64_t sum = 0, sum_interm = 0; std::string str; @@ -2340,15 +2346,28 @@ int64_t printStats(const std::string &csvFile, const std::string &srcFile, Hipif llvm::outs() << "\n" << hipify_info << str; csv << "\n" << str; str = "CONVERTED refs count"; - llvm::outs() << hipify_info << str << ": " << sum << "\n"; + llvm::outs() << " " << str << ": " << sum << "\n"; csv << "\n" << str << separator << sum << "\n"; str = "UNCONVERTED refs count"; + llvm::outs() << " " << str << ": " << sum_unsupported << "\n"; csv << str << separator << sum_unsupported << "\n"; - str = "Conversion %"; + str = "CONVERSION %"; long conv = 100 - std::lround(double(sum_unsupported*100)/double(sum + sum_unsupported)); + llvm::outs() << " " << str << ": " << conv << "%\n"; + csv << str << separator << conv << "%\n"; + str = "REPLACED bytes"; + llvm::outs() << " " << str << ": " << replacedBytes << "\n"; + csv << str << separator << replacedBytes << "\n"; + str = "TOTAL bytes"; + llvm::outs() << " " << str << ": " << totalBytes << "\n"; + csv << str << separator << totalBytes << "\n"; + str = "CODE CHANGED %"; + conv = std::lround(double(replacedBytes * 100) / double(totalBytes)); + llvm::outs() << " " << str << ": " << conv << "%\n"; csv << str << separator << conv << "%\n"; } if (sum > 0) { + llvm::outs() << hipify_info << "CONVERTED refs by type:\n"; csv << "\nCUDA ref type" << separator << "Count\n"; for (int i = 0; i < CONV_LAST; i++) { sum_interm = Callback.countReps[i] + PPCallbacks.countReps[i]; @@ -2380,9 +2399,8 @@ int64_t printStats(const std::string &csvFile, const std::string &srcFile, Hipif } } if (sum_unsupported > 0) { - str = "UNCONVERTED refs count"; - llvm::outs() << hipify_info << str << ": " << sum_unsupported << "\n"; - csv << "\n" << str << separator << sum_unsupported << "\n"; + str = "UNCONVERTED refs by type:"; + llvm::outs() << hipify_info << str << "\n"; csv << "\nUNCONVERTED CUDA ref type" << separator << "Count\n"; for (int i = 0; i < CONV_LAST; i++) { sum_interm = Callback.countRepsUnsupported[i] + PPCallbacks.countRepsUnsupported[i]; @@ -2417,7 +2435,8 @@ int64_t printStats(const std::string &csvFile, const std::string &srcFile, Hipif return sum; } -void printAllStats(const std::string &csvFile, int64_t totalFiles, int64_t convertedFiles) { +void printAllStats(const std::string &csvFile, int64_t totalFiles, int64_t convertedFiles, + uint64_t replacedBytes, uint64_t totalBytes) { std::ofstream csv(csvFile, std::ios::app); int64_t sum = 0, sum_interm = 0; std::string str; @@ -2440,16 +2459,28 @@ void printAllStats(const std::string &csvFile, int64_t totalFiles, int64_t conve llvm::outs() << " " << str << ": " << totalFiles << "\n"; csv << str << separator << totalFiles << "\n"; str = "CONVERTED refs count"; - llvm::outs() << hipify_info << str << ": " << sum << "\n"; + llvm::outs() << " " << str << ": " << sum << "\n"; csv << str << separator << sum << "\n"; str = "UNCONVERTED refs count"; + llvm::outs() << " " << str << ": " << sum_unsupported << "\n"; csv << str << separator << sum_unsupported << "\n"; - str = "Conversion %"; + str = "CONVERSION %"; long conv = 100 - std::lround(double(sum_unsupported * 100) / double(sum + sum_unsupported)); + llvm::outs() << " " << str << ": " << conv << "%\n"; + csv << str << separator << conv << "%\n"; + str = "REPLACED bytes"; + llvm::outs() << " " << str << ": " << replacedBytes << "\n"; + csv << str << separator << replacedBytes << "\n"; + str = "TOTAL bytes"; + llvm::outs() << " " << str << ": " << totalBytes << "\n"; + csv << str << separator << totalBytes << "\n"; + str = "CODE CHANGED %"; + conv = std::lround(double(replacedBytes * 100) / double(totalBytes)); + llvm::outs() << " " << str << ": " << conv << "%\n"; csv << str << separator << conv << "%\n"; } - if (sum > 0) { + llvm::outs() << hipify_info << "CONVERTED refs by type:\n"; csv << "\nCUDA ref type" << separator << "Count\n"; for (int i = 0; i < CONV_LAST; i++) { sum_interm = countRepsTotal[i]; @@ -2473,9 +2504,8 @@ void printAllStats(const std::string &csvFile, int64_t totalFiles, int64_t conve } } if (sum_unsupported > 0) { - str = "UNCONVERTED refs count"; - llvm::outs() << hipify_info << str << ": " << sum_unsupported << "\n"; - csv << "\n" << str << separator << sum_unsupported << "\n"; + str = "UNCONVERTED refs by type:"; + llvm::outs() << hipify_info << str << "\n"; csv << "\nUNCONVERTED CUDA ref type" << separator << "Count\n"; for (int i = 0; i < CONV_LAST; i++) { sum_interm = countRepsTotalUnsupported[i]; @@ -2524,8 +2554,15 @@ int main(int argc, const char **argv) { NoOutput = PrintStats = true; } int Result = 0; - std::string csv = "hipify_stats.csv"; + std::string csv; + if (!OutputStatsFilename.empty()) { + csv = OutputStatsFilename; + } else { + csv = "hipify_stats.csv"; + } size_t filesTransleted = fileSources.size(); + uint64_t repBytesTotal = 0; + uint64_t bytesTotal = 0; if (PrintStats && filesTransleted > 1) { std::remove(csv.c_str()); } @@ -2555,7 +2592,6 @@ int main(int argc, const char **argv) { source.close(); dest.close(); } - RefactoringTool Tool(OptionsParser.getCompilations(), dst); ast_matchers::MatchFinder Finder; HipifyPPCallbacks PPCallbacks(&Tool.getReplacements()); @@ -2578,18 +2614,22 @@ int main(int argc, const char **argv) { LangOptions DefaultLangOptions; IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions(); TextDiagnosticPrinter DiagnosticPrinter(llvm::errs(), &*DiagOpts); - DiagnosticsEngine Diagnostics( - IntrusiveRefCntPtr(new DiagnosticIDs()), &*DiagOpts, + DiagnosticsEngine Diagnostics(IntrusiveRefCntPtr(new DiagnosticIDs()), &*DiagOpts, &DiagnosticPrinter, false); - DEBUG(dbgs() << "Replacements collected by the tool:\n"); - for (const auto &r : Tool.getReplacements()) { - DEBUG(dbgs() << r.toString() << "\n"); + uint64_t repBytes = 0; + uint64_t bytes = 0; + if (PrintStats) { + DEBUG(dbgs() << "Replacements collected by the tool:\n"); + for (const auto &r : Tool.getReplacements()) { + DEBUG(dbgs() << r.toString() << "\n"); + repBytes += r.getLength(); + } + std::ifstream src_file(dst, std::ios::binary | std::ios::ate); + bytes = src_file.tellg(); } - SourceManager Sources(Diagnostics, Tool.getFiles()); Rewriter Rewrite(Sources, DefaultLangOptions); - if (!Tool.applyAllReplacements(Rewrite)) { DEBUG(dbgs() << "Skipped some replacements.\n"); } @@ -2607,17 +2647,21 @@ int main(int argc, const char **argv) { } if (PrintStats) { if (fileSources.size() == 1) { - csv = dst + ".csv"; + if (OutputStatsFilename.empty()) { + csv = dst + ".csv"; + } std::remove(csv.c_str()); } - if (0 == printStats(csv, src, PPCallbacks, Callback)) { + if (0 == printStats(csv, src, PPCallbacks, Callback, repBytes, bytes)) { filesTransleted--; } + repBytesTotal += repBytes; + bytesTotal += bytes; } dst.clear(); } if (PrintStats && fileSources.size() > 1) { - printAllStats(csv, fileSources.size(), filesTransleted); + printAllStats(csv, fileSources.size(), filesTransleted, repBytesTotal, bytesTotal); } return Result; } From d2cf5ba147a491279daa6e364c89aa4b7af8e06e Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Fri, 23 Dec 2016 18:01:26 +0300 Subject: [PATCH 037/281] [HIPIFY] Fix line endings. [ROCm/hip commit: ab00e2a6270bf3a448ab228c0fbe563e964db7a6] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index 4825227b13..3e64ea1b1f 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -2602,6 +2602,7 @@ int main(int argc, const char **argv) { auto action = newFrontendActionFactory(&Finder, &PPCallbacks); std::vector compilationStages; compilationStages.push_back("--cuda-host-only"); + Tool.appendArgumentsAdjuster(getInsertArgumentAdjuster(compilationStages[0], ArgumentInsertPosition::BEGIN)); Tool.appendArgumentsAdjuster(getInsertArgumentAdjuster("-std=c++11")); #if defined(HIPIFY_CLANG_RES) From db5b0439dec4ba086f95ebd106fbd7acb6f8d02f Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Fri, 23 Dec 2016 22:06:20 +0300 Subject: [PATCH 038/281] [HIPIFY] Add hipconvertinplace2.sh and hipexamine2.sh scripts for hipify-clang. The differences from the similar scripts for hipify.pl: 1. CSV file with extended statistics is produced. 2. scripts' arguments are changed a bit: DIRNAME [hipify options] [--] [clang options] where -- is a delimiter; all the arguments are optional, except DIRNAME. Usage example: ./hipexamine2.sh ./tmp -o-stats ./tmp/stats.csv -- -I/usr/local/cuda-7.5/include -I/usr/local/hipify-clang/hipblas/include 2>&1 | tee log [ROCm/hip commit: bcbbc32fa63b39552f2adeb932cb554870c95cab] --- projects/hip/bin/hipconvertinplace2.sh | 24 ++++++++++++++++++++++++ projects/hip/bin/hipexamine2.sh | 22 ++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 projects/hip/bin/hipconvertinplace2.sh create mode 100644 projects/hip/bin/hipexamine2.sh diff --git a/projects/hip/bin/hipconvertinplace2.sh b/projects/hip/bin/hipconvertinplace2.sh new file mode 100644 index 0000000000..a765ab39fa --- /dev/null +++ b/projects/hip/bin/hipconvertinplace2.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +#usage : hipconvertinplace.sh DIRNAME [hipify options] [--] [clang options] + +#hipify "inplace" all code files in specified directory. +# This can be quite handy when dealing with an existing CUDA code base since the script +# preserves the existing directory structure. + +SCRIPT_DIR=`dirname $0` +SEARCH_DIR=$1 + +hipify_args='' +while (( "$#" )); do + shift + if [ "$1" != "--" ]; then + hipify_args="$hipify_args $1" + else + shift + break + fi +done +clang_args="$@" + +$SCRIPT_DIR/hipify-clang -inplace -print-stats $hipify_args `$SCRIPT_DIR/findcode.sh $SEARCH_DIR` -- -x cuda $clang_args diff --git a/projects/hip/bin/hipexamine2.sh b/projects/hip/bin/hipexamine2.sh new file mode 100644 index 0000000000..2a6fab7110 --- /dev/null +++ b/projects/hip/bin/hipexamine2.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +#usage : hipexamine2.sh DIRNAME [hipify options] [--] [clang options] + +# Generate CUDA->HIP conversion statistics for all the code files in the specified directory. + +SCRIPT_DIR=`dirname $0` +SEARCH_DIR=$1 + +hipify_args='' +while (( "$#" )); do + shift + if [ "$1" != "--" ]; then + hipify_args="$hipify_args $1" + else + shift + break + fi +done +clang_args="$@" + +$SCRIPT_DIR/hipify-clang -examine $hipify_args `$SCRIPT_DIR/findcode.sh $SEARCH_DIR` -- -x cuda $clang_args From 154576f772492fdf15b9c34c51534e4db1bb3cb7 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Mon, 26 Dec 2016 19:03:50 +0300 Subject: [PATCH 039/281] [HIPIFY] Pointer to typedef declaration is not hipified Fix for https://github.com/GPUOpen-ProfessionalCompute-Tools/HIP/issues/60 [ROCm/hip commit: 24703944dea397dc355c045c7582817f5576fe11] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 59 ++++++++++++++++++---- 1 file changed, 50 insertions(+), 9 deletions(-) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index 3e64ea1b1f..acba13b1e9 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -2018,6 +2018,34 @@ private: return false; } + bool cudaTypedefVarPtr(const MatchFinder::MatchResult &Result) { + if (const VarDecl *typedefVarPtr = Result.Nodes.getNodeAs("cudaTypedefVarPtr")) { + const Type *t = typedefVarPtr->getType().getTypePtrOrNull(); + if (t) { + QualType QT = t->getPointeeType(); + QT = QT.getUnqualifiedType(); + StringRef name = QT.getAsString(); + const auto found = N.cuda2hipRename.find(name); + if (found != N.cuda2hipRename.end()) { + updateCounters(found->second, name.str()); + if (!found->second.unsupported) { + StringRef repName = found->second.hipName; + TypeLoc TL = typedefVarPtr->getTypeSourceInfo()->getTypeLoc(); + SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); + SourceManager *SM = Result.SourceManager; + Replacement Rep(*SM, sl, name.size(), repName); + Replace->insert(Rep); + } + } + else { + llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [typedef var ptr].\n"; + } + } + return true; + } + return false; + } + bool cudaStructVar(const MatchFinder::MatchResult &Result) { if (const VarDecl *structVar = Result.Nodes.getNodeAs("cudaStructVar")) { StringRef name = structVar->getType() @@ -2221,17 +2249,18 @@ public: void run(const MatchFinder::MatchResult &Result) override { do { if (cudaCall(Result)) break; - if (cudaLaunchKernel(Result)) break; if (cudaBuiltin(Result)) break; if (cudaEnumConstantRef(Result)) break; if (cudaEnumConstantDecl(Result)) break; if (cudaTypedefVar(Result)) break; + if (cudaTypedefVarPtr(Result)) break; if (cudaStructVar(Result)) break; if (cudaStructVarPtr(Result)) break; if (cudaStructSizeOf(Result)) break; - if (cudaSharedIncompleteArrayVar(Result)) break; if (cudaParamDecl(Result)) break; if (cudaParamDeclPtr(Result)) break; + if (cudaLaunchKernel(Result)) break; + if (cudaSharedIncompleteArrayVar(Result)) break; if (stringLiteral(Result)) break; if (unresolvedTemplateName(Result)) break; break; @@ -2289,19 +2318,32 @@ void addAllMatchers(ast_matchers::MatchFinder &Finder, Cuda2HipCallback *Callbac hasType(typedefDecl(matchesName("cu.*|CU.*")))) .bind("cudaTypedefVar"), Callback); - // Array of elements of typedef type, Example: cudaStream_t streams[2]; + // Array of elements of typedef type. Example: + // cudaStream_t streams[2]; Finder.addMatcher(varDecl(isExpansionInMainFile(), hasType(arrayType(hasElementType(typedefType( hasDeclaration(typedefDecl(matchesName("cu.*|CU.*")))))))) .bind("cudaTypedefVar"), Callback); + // Pointer to typedef type. Examples: + // 1. + // cudaEvent_t *event = NULL; + // typedef __device_builtin__ struct CUevent_st *cudaEvent_t; + // 2. + // CUevent *event = NULL; + // typedef struct CUevent_st *CUevent; + Finder.addMatcher(varDecl(isExpansionInMainFile(), + hasType(pointsTo(typedefDecl( + matchesName("cu.*|CU.*"))))) + .bind("cudaTypedefVarPtr"), + Callback); Finder.addMatcher(varDecl(isExpansionInMainFile(), hasType(cxxRecordDecl(matchesName("cu.*|CU.*")))) .bind("cudaStructVar"), Callback); Finder.addMatcher(varDecl(isExpansionInMainFile(), hasType(pointsTo(cxxRecordDecl( - matchesName("cu.*|CU.*"))))) + matchesName("cu.*|CU.*"))))) .bind("cudaStructVarPtr"), Callback); Finder.addMatcher(parmVarDecl(isExpansionInMainFile(), @@ -2310,12 +2352,12 @@ void addAllMatchers(ast_matchers::MatchFinder &Finder, Cuda2HipCallback *Callbac Callback); Finder.addMatcher(parmVarDecl(isExpansionInMainFile(), hasType(pointsTo(namedDecl( - matchesName("cu.*|CU.*"))))) + matchesName("cu.*|CU.*"))))) .bind("cudaParamDeclPtr"), Callback); Finder.addMatcher(expr(isExpansionInMainFile(), - sizeOfExpr(hasArgumentOfType(recordType(hasDeclaration( - cxxRecordDecl(matchesName("cu.*|CU.*"))))))) + sizeOfExpr(hasArgumentOfType( + recordType(hasDeclaration(cxxRecordDecl(matchesName("cu.*|CU.*"))))))) .bind("cudaStructSizeOf"), Callback); Finder.addMatcher(stringLiteral(isExpansionInMainFile()).bind("stringLiteral"), @@ -2615,8 +2657,7 @@ int main(int argc, const char **argv) { LangOptions DefaultLangOptions; IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions(); TextDiagnosticPrinter DiagnosticPrinter(llvm::errs(), &*DiagOpts); - DiagnosticsEngine Diagnostics(IntrusiveRefCntPtr(new DiagnosticIDs()), &*DiagOpts, - &DiagnosticPrinter, false); + DiagnosticsEngine Diagnostics(IntrusiveRefCntPtr(new DiagnosticIDs()), &*DiagOpts, &DiagnosticPrinter, false); uint64_t repBytes = 0; uint64_t bytes = 0; From 12bf2e3f734e82264b6debed4a9de56abfc192de Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Tue, 27 Dec 2016 18:54:02 +0300 Subject: [PATCH 040/281] [HIPIFY] [Fix] An argument of a function used as macro argument is not hipified. https://github.com/GPUOpen-ProfessionalCompute-Tools/HIP/issues/35 [ROCm/hip commit: 5ec0488ce845a9cfb3c78c43a147c31159775533] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index acba13b1e9..790973f1ad 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -1671,8 +1671,6 @@ public: const MacroDefinition &MD, SourceRange Range, const MacroArgs *Args) override { if (_sm->isWrittenInMainFile(MacroNameTok.getLocation())) { - StringRef macroName = MacroNameTok.getIdentifierInfo()->getName(); - if (N.cudaExcludes.end() == N.cudaExcludes.find(macroName)) { for (unsigned int i = 0; Args && i < MD.getMacroInfo()->getNumArgs(); i++) { std::vector toks; // Code below is a kind of stolen from 'MacroArgs::getPreExpArgument' @@ -1684,16 +1682,13 @@ public: #else _pp->EnterTokenStream(start, len, false, false); #endif - int j = 0; do { toks.push_back(Token()); Token &tk = toks.back(); _pp->Lex(tk); - j++; } while (toks.back().isNot(tok::eof)); _pp->RemoveTopOfLexerStack(); // end of stolen code - j = 0; for (auto tok : toks) { if (tok.isAnyIdentifier()) { StringRef name = tok.getIdentifierInfo()->getName(); @@ -1750,10 +1745,8 @@ public: } } } - j++; } } - } } } From 2250218e10d19db2789625e6eaa608ba8b6cf728 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Tue, 27 Dec 2016 19:48:59 +0300 Subject: [PATCH 041/281] [HIPIFY] Formatting, no functional changes. [ROCm/hip commit: d7d3fcc77dcfe5c3f4f7d021d9ccebf7d80b3438] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 137 ++++++++++----------- 1 file changed, 66 insertions(+), 71 deletions(-) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index 790973f1ad..ed6f64fd0b 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -1591,8 +1591,7 @@ public: HipifyPPCallbacks(Replacements *R) : Cuda2Hip(R), SeenEnd(false), _sm(nullptr), _pp(nullptr) {} - virtual bool handleBeginSource(CompilerInstance &CI, - StringRef Filename) override { + virtual bool handleBeginSource(CompilerInstance &CI, StringRef Filename) override { Preprocessor &PP = CI.getPreprocessor(); SourceManager &SM = CI.getSourceManager(); setSourceManager(&SM); @@ -1619,7 +1618,7 @@ public: if (!found->second.unsupported) { StringRef repName = found->second.hipName; DEBUG(dbgs() << "Include file found: " << file_name << "\n" - << "SourceLocation:" + << "SourceLocation: " << filename_range.getBegin().printToString(*_sm) << "\n" << "Will be replaced with " << repName << "\n"); SourceLocation sl = filename_range.getBegin(); @@ -1650,12 +1649,10 @@ public: if (!found->second.unsupported) { StringRef repName = found->second.hipName; SourceLocation sl = T.getLocation(); - DEBUG(dbgs() << "Identifier " << name - << " found in definition of macro " + DEBUG(dbgs() << "Identifier " << name << " found in definition of macro " << MacroNameTok.getIdentifierInfo()->getName() << "\n" << "will be replaced with: " << repName << "\n" - << "SourceLocation: " << sl.printToString(*_sm) - << "\n"); + << "SourceLocation: " << sl.printToString(*_sm) << "\n"); Replacement Rep(*_sm, sl, name.size(), repName); Replace->insert(Rep); } @@ -1671,82 +1668,81 @@ public: const MacroDefinition &MD, SourceRange Range, const MacroArgs *Args) override { if (_sm->isWrittenInMainFile(MacroNameTok.getLocation())) { - for (unsigned int i = 0; Args && i < MD.getMacroInfo()->getNumArgs(); i++) { - std::vector toks; - // Code below is a kind of stolen from 'MacroArgs::getPreExpArgument' - // to workaround the 'const' MacroArgs passed into this hook. - const Token *start = Args->getUnexpArgument(i); - size_t len = Args->getArgLength(start) + 1; - #if (LLVM_VERSION_MAJOR >= 3) && (LLVM_VERSION_MINOR >= 9) - _pp->EnterTokenStream(ArrayRef(start, len), false); - #else - _pp->EnterTokenStream(start, len, false, false); - #endif - do { - toks.push_back(Token()); - Token &tk = toks.back(); - _pp->Lex(tk); - } while (toks.back().isNot(tok::eof)); - _pp->RemoveTopOfLexerStack(); - // end of stolen code - for (auto tok : toks) { - if (tok.isAnyIdentifier()) { - StringRef name = tok.getIdentifierInfo()->getName(); + for (unsigned int i = 0; Args && i < MD.getMacroInfo()->getNumArgs(); i++) { + std::vector toks; + // Code below is a kind of stolen from 'MacroArgs::getPreExpArgument' + // to workaround the 'const' MacroArgs passed into this hook. + const Token *start = Args->getUnexpArgument(i); + size_t len = Args->getArgLength(start) + 1; +#if (LLVM_VERSION_MAJOR >= 3) && (LLVM_VERSION_MINOR >= 9) + _pp->EnterTokenStream(ArrayRef(start, len), false); +#else + _pp->EnterTokenStream(start, len, false, false); +#endif + do { + toks.push_back(Token()); + Token &tk = toks.back(); + _pp->Lex(tk); + } while (toks.back().isNot(tok::eof)); + _pp->RemoveTopOfLexerStack(); + // end of stolen code + for (auto tok : toks) { + if (tok.isAnyIdentifier()) { + StringRef name = tok.getIdentifierInfo()->getName(); + const auto found = N.cuda2hipRename.find(name); + if (found != N.cuda2hipRename.end()) { + updateCounters(found->second, name.str()); + if (!found->second.unsupported) { + StringRef repName = found->second.hipName; + DEBUG(dbgs() << "Identifier " << name + << " found as an actual argument in expansion of macro " + << macroName << "\n" + << "will be replaced with: " << repName << "\n"); + size_t length = name.size(); + SourceLocation sl = tok.getLocation(); + if (_sm->isMacroBodyExpansion(sl)) { + LangOptions DefaultLangOptions; + SourceLocation sl_macro = _sm->getExpansionLoc(sl); + SourceLocation sl_end = Lexer::getLocForEndOfToken(sl_macro, 0, *_sm, DefaultLangOptions); + length = _sm->getCharacterData(sl_end) - _sm->getCharacterData(sl_macro); + name = StringRef(_sm->getCharacterData(sl_macro), length); + sl = sl_macro; + } + Replacement Rep(*_sm, sl, length, repName); + Replace->insert(Rep); + } + } else { + // llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [macro expansion].\n"; + } + } else if (tok.isLiteral()) { + SourceLocation sl = tok.getLocation(); + if (_sm->isMacroBodyExpansion(sl)) { + LangOptions DefaultLangOptions; + SourceLocation sl_macro = _sm->getExpansionLoc(sl); + SourceLocation sl_end = Lexer::getLocForEndOfToken(sl_macro, 0, *_sm, DefaultLangOptions); + size_t length = _sm->getCharacterData(sl_end) - _sm->getCharacterData(sl_macro); + StringRef name = StringRef(_sm->getCharacterData(sl_macro), length); const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { updateCounters(found->second, name.str()); if (!found->second.unsupported) { StringRef repName = found->second.hipName; - DEBUG(dbgs() - << "Identifier " << name - << " found as an actual argument in expansion of macro " - << macroName << "\n" - << "will be replaced with: " << repName << "\n"); - size_t length = name.size(); - SourceLocation sl = tok.getLocation(); - if (_sm->isMacroBodyExpansion(sl)) { - LangOptions DefaultLangOptions; - SourceLocation sl_macro = _sm->getExpansionLoc(sl); - SourceLocation sl_end = Lexer::getLocForEndOfToken(sl_macro, 0, *_sm, DefaultLangOptions); - length = _sm->getCharacterData(sl_end) - _sm->getCharacterData(sl_macro); - name = StringRef(_sm->getCharacterData(sl_macro), length); - sl = sl_macro; - } + sl = sl_macro; Replacement Rep(*_sm, sl, length, repName); Replace->insert(Rep); } } else { - // llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [macro expansion].\n"; + // llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [literal macro expansion].\n"; } - } else if (tok.isLiteral()) { - SourceLocation sl = tok.getLocation(); - if (_sm->isMacroBodyExpansion(sl)) { - LangOptions DefaultLangOptions; - SourceLocation sl_macro = _sm->getExpansionLoc(sl); - SourceLocation sl_end = Lexer::getLocForEndOfToken(sl_macro, 0, *_sm, DefaultLangOptions); - size_t length = _sm->getCharacterData(sl_end) - _sm->getCharacterData(sl_macro); - StringRef name = StringRef(_sm->getCharacterData(sl_macro), length); - const auto found = N.cuda2hipRename.find(name); - if (found != N.cuda2hipRename.end()) { - updateCounters(found->second, name.str()); - if (!found->second.unsupported) { - StringRef repName = found->second.hipName; - sl = sl_macro; - Replacement Rep(*_sm, sl, length, repName); - Replace->insert(Rep); - } - } else { - // llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [literal macro expansion].\n"; - } - } else { - if (tok.is(tok::string_literal)) { - StringRef s(tok.getLiteralData(), tok.getLength()); - processString(unquoteStr(s), *_sm, tok.getLocation()); - } + } else { + if (tok.is(tok::string_literal)) { + StringRef s(tok.getLiteralData(), tok.getLength()); + processString(unquoteStr(s), *_sm, tok.getLocation()); } } } } + } } } @@ -1774,8 +1770,7 @@ private: OS << "hipLaunchParm lp"; size_t repLength = OS.str().size(); SourceLocation sl = kernelDecl->getNameInfo().getEndLoc(); - SourceLocation kernelArgListStart = Lexer::findLocationAfterToken( - sl, tok::l_paren, *SM, DefaultLangOptions, true); + SourceLocation kernelArgListStart = Lexer::findLocationAfterToken(sl, tok::l_paren, *SM, DefaultLangOptions, true); DEBUG(dbgs() << kernelArgListStart.printToString(*SM)); if (kernelDecl->getNumParams() > 0) { const ParmVarDecl *pvdFirst = kernelDecl->getParamDecl(0); From 9d41561ab44875e060ffec4599f5c68abb0b561d Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Wed, 28 Dec 2016 18:08:10 +0300 Subject: [PATCH 042/281] [HIPIFY] Added the rest of cuBlas API. CUBLAS API 7.5 now is supported by hipify; API calls, which are not yet supported by hcblas/hipblas, are listed as HIP_UNSUPPORTED. [ROCm/hip commit: 6ceb85a03a4ba46fe38136e59e3e4a1b497d714c] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index ed6f64fd0b..0b2a8d8ec1 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -750,6 +750,17 @@ struct cuda2hipMap { cuda2hipRename["cublasHandle_t"] = {"hipblasHandle_t", CONV_TYPE, API_BLAS}; // TODO: dereferencing: typedef struct cublasContext *cublasHandle_t; cuda2hipRename["cublasContext"] = {"hipblasHandle_t", CONV_TYPE, API_BLAS}; + // Blas management functions + // unsupported yet by hipblas/hcblas + cuda2hipRename["cublasInit"] = {"hipblasInit", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasShutdown"] = {"hipblasShutdown", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasGetVersion"] = {"hipblasGetVersion", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasGetError"] = {"hipblasGetError", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasAlloc"] = {"hipblasAlloc", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasFree"] = {"hipblasFree", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasSetKernelStream"] = {"hipblasSetKernelStream", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasGetAtomicsMode"] = {"hipblasGetAtomicsMode", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; + cuda2hipRename["cublasSetAtomicsMode"] = {"hipblasSetAtomicsMode", CONV_MATH_FUNC, API_BLAS, HIP_UNSUPPORTED}; // Blas operations cuda2hipRename["cublasOperation_t"] = {"hipblasOperation_t", CONV_TYPE, API_BLAS}; cuda2hipRename["CUBLAS_OP_N"] = {"HIPBLAS_OP_N", CONV_NUMERIC_LITERAL, API_BLAS}; From 688d9f459e2615c7c3a234368d23252f8617fe15 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Wed, 28 Dec 2016 20:44:05 +0300 Subject: [PATCH 043/281] [HIPIFY] Elapsed time is added to statistics. [ROCm/hip commit: 14e9cf7e62a2811403193e73e65ae6951712b1de] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 30 +++++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index 0b2a8d8ec1..4ea34606db 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -48,6 +48,9 @@ THE SOFTWARE. #include #include #include +#include +#include +#include using namespace clang; using namespace clang::ast_matchers; @@ -2370,7 +2373,8 @@ void addAllMatchers(ast_matchers::MatchFinder &Finder, Cuda2HipCallback *Callbac int64_t printStats(const std::string &csvFile, const std::string &srcFile, HipifyPPCallbacks &PPCallbacks, Cuda2HipCallback &Callback, - uint64_t replacedBytes, uint64_t totalBytes) { + uint64_t replacedBytes, uint64_t totalBytes, + const std::chrono::steady_clock::time_point &start) { std::ofstream csv(csvFile, std::ios::app); int64_t sum = 0, sum_interm = 0; std::string str; @@ -2406,6 +2410,13 @@ int64_t printStats(const std::string &csvFile, const std::string &srcFile, conv = std::lround(double(replacedBytes * 100) / double(totalBytes)); llvm::outs() << " " << str << ": " << conv << "%\n"; csv << str << separator << conv << "%\n"; + typedef std::chrono::duration duration; + duration elapsed = std::chrono::steady_clock::now() - start; + str = "TIME ELAPSED s"; + std::stringstream stream; + stream << std::fixed << std::setprecision(2) << elapsed.count() / 1000; + llvm::outs() << " " << str << ": " << stream.str() << "\n"; + csv << str << separator << stream.str() << "\n"; } if (sum > 0) { llvm::outs() << hipify_info << "CONVERTED refs by type:\n"; @@ -2477,7 +2488,8 @@ int64_t printStats(const std::string &csvFile, const std::string &srcFile, } void printAllStats(const std::string &csvFile, int64_t totalFiles, int64_t convertedFiles, - uint64_t replacedBytes, uint64_t totalBytes) { + uint64_t replacedBytes, uint64_t totalBytes, + const std::chrono::steady_clock::time_point &start) { std::ofstream csv(csvFile, std::ios::app); int64_t sum = 0, sum_interm = 0; std::string str; @@ -2519,6 +2531,13 @@ void printAllStats(const std::string &csvFile, int64_t totalFiles, int64_t conve conv = std::lround(double(replacedBytes * 100) / double(totalBytes)); llvm::outs() << " " << str << ": " << conv << "%\n"; csv << str << separator << conv << "%\n"; + typedef std::chrono::duration duration; + duration elapsed = std::chrono::steady_clock::now() - start; + str = "TIME ELAPSED s"; + std::stringstream stream; + stream << std::fixed << std::setprecision(2) << elapsed.count() / 1000; + llvm::outs() << " " << str << ": " << stream.str() << "\n"; + csv << str << separator << stream.str() << "\n"; } if (sum > 0) { llvm::outs() << hipify_info << "CONVERTED refs by type:\n"; @@ -2573,6 +2592,8 @@ void printAllStats(const std::string &csvFile, int64_t totalFiles, int64_t conve } int main(int argc, const char **argv) { + auto start = std::chrono::steady_clock::now(); + auto begin = start; llvm::sys::PrintStackTraceOnErrorSignal(); CommonOptionsParser OptionsParser(argc, argv, ToolTemplateCategory, llvm::cl::OneOrMore); std::vector fileSources = OptionsParser.getSourcePathList(); @@ -2693,16 +2714,17 @@ int main(int argc, const char **argv) { } std::remove(csv.c_str()); } - if (0 == printStats(csv, src, PPCallbacks, Callback, repBytes, bytes)) { + if (0 == printStats(csv, src, PPCallbacks, Callback, repBytes, bytes, start)) { filesTransleted--; } + start = std::chrono::steady_clock::now(); repBytesTotal += repBytes; bytesTotal += bytes; } dst.clear(); } if (PrintStats && fileSources.size() > 1) { - printAllStats(csv, fileSources.size(), filesTransleted, repBytesTotal, bytesTotal); + printAllStats(csv, fileSources.size(), filesTransleted, repBytesTotal, bytesTotal, begin); } return Result; } From 977cd8fcb67c5963b54b676eb1c451277fa3e2da Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Wed, 4 Jan 2017 12:39:09 +0530 Subject: [PATCH 044/281] hipcc: Link to shared HIP runtime by default Change-Id: I5030e3245e4afb6863b401656ca5d1ad9ae84310 [ROCm/hip commit: a42da10c44c58cd48a34fd73fbdf657293f96be4] --- projects/hip/bin/hipcc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/hip/bin/hipcc b/projects/hip/bin/hipcc index e85e803888..3e88b77693 100755 --- a/projects/hip/bin/hipcc +++ b/projects/hip/bin/hipcc @@ -193,7 +193,7 @@ my $needHipHcc = ($HIP_PLATFORM eq 'hcc'); # set if we need to link hip_hcc my $printHipVersion = 0; # print HIP version my $runCmd = 1; my $buildDeps = 0; -my $linkType = 0; +my $linkType = 1; my $setLinkType = 0; my @options = (); From eb9be747f25b21638099a13acd1c283ce070c941 Mon Sep 17 00:00:00 2001 From: scchan Date: Thu, 5 Jan 2017 18:26:54 -0500 Subject: [PATCH 045/281] [cmake] add library dependencies to hip_hcc libraries [ROCm/hip commit: 4fd48084a6f7ea9d07c30ed3e8842e2cf4511df1] --- projects/hip/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/projects/hip/CMakeLists.txt b/projects/hip/CMakeLists.txt index 508880104d..1168b65be2 100644 --- a/projects/hip/CMakeLists.txt +++ b/projects/hip/CMakeLists.txt @@ -183,9 +183,11 @@ if(HIP_PLATFORM STREQUAL "hcc") src/hip_fp16.cpp src/device_functions.cpp) - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -L${HCC_HOME}/lib -lmcwamp -Wl,-Bsymbolic") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -L${HCC_HOME}/lib -lmcwamp -Wl,-Bsymbolic -Wl,-rpath ${HCC_HOME}/lib") add_library(hip_hcc SHARED ${SOURCE_FILES_RUNTIME}) + target_link_libraries(hip_hcc c++ c++abi hc_am) add_library(hip_hcc_static STATIC ${SOURCE_FILES_RUNTIME}) + target_link_libraries(hip_hcc_static c++ c++abi hc_am) add_dependencies(hip_hcc_static hip_hcc) add_library(hip_device STATIC ${SOURCE_FILES_DEVICE}) add_dependencies(hip_device hip_hcc) From 2e9defbef8c651f0934b1ca6baa330173d180efb Mon Sep 17 00:00:00 2001 From: Rahul Garg Date: Mon, 9 Jan 2017 23:54:01 +0530 Subject: [PATCH 046/281] Added state for hipDevice. Change-Id: Idbc3c04cd054a01b634856a1e0a23ff172e991aa [ROCm/hip commit: 5fb09879c7b2f8fe1b0353947769fb69e14cd6cf] --- projects/hip/include/hip/hip_runtime_api.h | 1 + projects/hip/src/hip_device.cpp | 64 +++++++++++++++------- projects/hip/src/hip_hcc.cpp | 5 +- projects/hip/src/hip_hcc.h | 6 +- projects/hip/src/hip_memory.cpp | 8 +-- 5 files changed, 58 insertions(+), 26 deletions(-) diff --git a/projects/hip/include/hip/hip_runtime_api.h b/projects/hip/include/hip/hip_runtime_api.h index a45a1ee27e..a2bfed5c69 100644 --- a/projects/hip/include/hip/hip_runtime_api.h +++ b/projects/hip/include/hip/hip_runtime_api.h @@ -181,6 +181,7 @@ typedef enum hipError_t { hipErrorSharedObjectSymbolNotFound = 302, hipErrorSharedObjectInitFailed = 303, hipErrorOperatingSystem = 304, + hipErrorSetOnActiveProcess = 305, hipErrorInvalidHandle = 400, hipErrorNotFound = 500, hipErrorIllegalAddress = 700, diff --git a/projects/hip/src/hip_device.cpp b/projects/hip/src/hip_device.cpp index 1cfdaa619d..0f2c2e2753 100644 --- a/projects/hip/src/hip_device.cpp +++ b/projects/hip/src/hip_device.cpp @@ -175,6 +175,24 @@ hipError_t hipDeviceReset(void) return ihipLogStatus(hipSuccess); } +hipError_t ihipDeviceSetState(void) +{ + hipError_t e = hipErrorInvalidContext; + auto *ctx = ihipGetTlsDefaultCtx(); + + if (ctx) { + ihipDevice_t *deviceHandle = ctx->getWriteableDevice(); + if(deviceHandle->_state == 0) + { + deviceHandle->_state = 1; + } + e = hipSuccess; + } + + return ihipLogStatus(e); +} + + hipError_t ihipDeviceGetAttribute(int* pi, hipDeviceAttribute_t attr, int device) { hipError_t e = hipSuccess; @@ -289,29 +307,35 @@ hipError_t hipSetDeviceFlags( unsigned int flags) // TODO : does this really OR in the flags or replaces previous flags: // TODO : Review error handling behavior for this function, it often returns ErrorSetOnActiveProcess if (ctx) { - ctx->_ctxFlags = ctx->_ctxFlags | flags; - if (flags & hipDeviceScheduleMask) { - switch (hipDeviceScheduleMask) { - case hipDeviceScheduleAuto: - case hipDeviceScheduleSpin: - case hipDeviceScheduleYield: - case hipDeviceScheduleBlockingSync: - e = hipSuccess; - break; - default: - e = hipSuccess; // TODO - should this be error? Map to Auto? - //e = hipErrorInvalidValue; - break; + auto *deviceHandle = ctx->getDevice(); + if(deviceHandle->_state == 0) + { + ctx->_ctxFlags = ctx->_ctxFlags | flags; + if (flags & hipDeviceScheduleMask) { + switch (hipDeviceScheduleMask) { + case hipDeviceScheduleAuto: + case hipDeviceScheduleSpin: + case hipDeviceScheduleYield: + case hipDeviceScheduleBlockingSync: + e = hipSuccess; + break; + default: + e = hipSuccess; // TODO - should this be error? Map to Auto? + //e = hipErrorInvalidValue; + break; + } } - } - unsigned supportedFlags = hipDeviceScheduleMask | hipDeviceMapHost | hipDeviceLmemResizeToMax; + unsigned supportedFlags = hipDeviceScheduleMask | hipDeviceMapHost | hipDeviceLmemResizeToMax; - if (flags & (~supportedFlags)) { - e = hipErrorInvalidValue; - } - } else { - e = hipErrorInvalidDevice; + if (flags & (~supportedFlags)) { + e = hipErrorInvalidValue; + } + } else { + e = hipErrorSetOnActiveProcess; + } + } else { + e = hipErrorInvalidDevice; } return ihipLogStatus(e); diff --git a/projects/hip/src/hip_hcc.cpp b/projects/hip/src/hip_hcc.cpp index a4ef2b392b..d760ade15d 100644 --- a/projects/hip/src/hip_hcc.cpp +++ b/projects/hip/src/hip_hcc.cpp @@ -482,7 +482,8 @@ void ihipCtxCriticalBase_t::addStream(ihipStream_t *stream) //================================================================================================= ihipDevice_t::ihipDevice_t(unsigned deviceId, unsigned deviceCnt, hc::accelerator &acc) : _deviceId(deviceId), - _acc(acc) + _acc(acc), + _state(0) { hsa_agent_t *agent = static_cast (acc.get_hsa_agent()); if (agent) { @@ -865,6 +866,7 @@ void ihipCtx_t::locked_reset() // Reset will remove peer mapping so don't need to do this explicitly. // FIXME - This is clearly a non-const action! Is this a context reset or a device reset - maybe should reference count? ihipDevice_t *device = getWriteableDevice(); + device->_state = 0; am_memtracker_reset(device->_acc); }; @@ -1553,6 +1555,7 @@ const char *ihipErrorString(hipError_t hip_error) case hipErrorSharedObjectSymbolNotFound : return "hipErrorSharedObjectSymbolNotFound"; case hipErrorSharedObjectInitFailed : return "hipErrorSharedObjectInitFailed"; case hipErrorOperatingSystem : return "hipErrorOperatingSystem"; + case hipErrorSetOnActiveProcess : return "hipErrorSetOnActiveProcess"; case hipErrorInvalidHandle : return "hipErrorInvalidHandle"; case hipErrorNotFound : return "hipErrorNotFound"; case hipErrorIllegalAddress : return "hipErrorIllegalAddress"; diff --git a/projects/hip/src/hip_hcc.h b/projects/hip/src/hip_hcc.h index ed85f1494c..8a4d457cb1 100644 --- a/projects/hip/src/hip_hcc.h +++ b/projects/hip/src/hip_hcc.h @@ -204,7 +204,8 @@ extern void recordApiTrace(std::string *fullStr, const std::string &apiStr); #define HIP_INIT()\ std::call_once(hip_initialized, ihipInit);\ ihipCtxStackUpdate(); - +#define HIP_SET_DEVICE()\ + ihipDeviceSetState(); // This macro should be called at the beginning of every HIP API. // It initialies the hip runtime (exactly once), and @@ -566,6 +567,8 @@ public: ihipCtx_t *_primaryCtx; + int _state; //1 if device is set otherwise 0 + private: hipError_t initProperties(hipDeviceProp_t* prop); }; @@ -703,6 +706,7 @@ extern ihipCtx_t *ihipGetTlsDefaultCtx(); extern void ihipSetTlsDefaultCtx(ihipCtx_t *ctx); extern hipError_t ihipSynchronize(void); extern void ihipCtxStackUpdate(); +extern hipError_t ihipDeviceSetState(); extern ihipDevice_t *ihipGetDevice(int); ihipCtx_t * ihipGetPrimaryCtx(unsigned deviceIndex); diff --git a/projects/hip/src/hip_memory.cpp b/projects/hip/src/hip_memory.cpp index 7e1a1738a6..74578e9b4b 100644 --- a/projects/hip/src/hip_memory.cpp +++ b/projects/hip/src/hip_memory.cpp @@ -105,7 +105,7 @@ hipError_t hipHostGetDevicePointer(void **devicePointer, void *hostPointer, unsi hipError_t hipMalloc(void** ptr, size_t sizeBytes) { HIP_INIT_API(ptr, sizeBytes); - + HIP_SET_DEVICE(); hipError_t hip_status = hipSuccess; // return NULL pointer when malloc size is 0 if (sizeBytes == 0) @@ -161,7 +161,7 @@ hipError_t hipMalloc(void** ptr, size_t sizeBytes) hipError_t hipHostMalloc(void** ptr, size_t sizeBytes, unsigned int flags) { HIP_INIT_API(ptr, sizeBytes, flags); - + HIP_SET_DEVICE(); hipError_t hip_status = hipSuccess; auto ctx = ihipGetTlsDefaultCtx(); @@ -233,7 +233,7 @@ hipError_t hipHostAlloc(void** ptr, size_t sizeBytes, unsigned int flags) hipError_t hipMallocPitch(void** ptr, size_t* pitch, size_t width, size_t height) { HIP_INIT_API(ptr, pitch, width, height); - + HIP_SET_DEVICE(); hipError_t hip_status = hipSuccess; if(width == 0 || height == 0) @@ -285,7 +285,7 @@ hipError_t hipMallocArray(hipArray** array, const hipChannelFormatDesc* desc, size_t width, size_t height, unsigned int flags) { HIP_INIT_API(array, desc, width, height, flags); - + HIP_SET_DEVICE(); hipError_t hip_status = hipSuccess; auto ctx = ihipGetTlsDefaultCtx(); From 72f6afab453e8ee278086ec725dd55d634d64b6d Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Tue, 3 Jan 2017 22:17:16 -0600 Subject: [PATCH 047/281] tolerate spaces in hip args [ROCm/hip commit: 3a42a7642a2325b9514e89616f7d70459db41fbb] --- projects/hip/bin/hipcc | 19 +++---- projects/hip/src/hip_hcc.cpp | 91 +++++++++++++++++++++++++-------- projects/hip/src/hip_hcc.h | 40 +++++++++++---- projects/hip/src/hip_stream.cpp | 10 ++-- 4 files changed, 116 insertions(+), 44 deletions(-) diff --git a/projects/hip/bin/hipcc b/projects/hip/bin/hipcc index 3e88b77693..ccea650776 100755 --- a/projects/hip/bin/hipcc +++ b/projects/hip/bin/hipcc @@ -244,6 +244,8 @@ my $toolArgs = ""; # arguments to pass to the hcc or nvcc tool foreach $arg (@ARGV) { + $trimarg = $arg; + $trimarg =~ s/^\s+|\s+$//g; # Remive whitespace my $swallowArg = 0; if ($arg eq '-c') { $compileOnly = 1; @@ -254,38 +256,37 @@ foreach $arg (@ARGV) $needLDFLAGS = 1; } - if(($arg eq '-stdlib=libc++') and ($setStdLib eq 0)) + if(($trimarg eq '-stdlib=libc++') and ($setStdLib eq 0)) { $HIPCXXFLAGS .= " -stdlib=libc++"; $setStdLib = 1; } - if(($arg eq '-stdlib=libstdc++') and ($setStdLib eq 0)) + if(($trimarg eq '-stdlib=libstdc++') and ($setStdLib eq 0)) { $HIPCXXFLAGS .= " -stdlib=libstdc++"; $HIPCXXFLAGS .= $HCC_WA_FLAGS; $setStdLib = 1; } - if($arg eq '--version') { + if($trimarg eq '--version') { $printHipVersion = 1; } - if($arg eq '--short-version') { + if($trimarg eq '--short-version') { $printHipVersion = 1; $runCmd = 0; } - if($arg eq '-M') { + if($trimarg eq '-M') { $compileOnly = 1; $buildDeps = 1; } - if($arg eq '-use_fast_math') { - print "In fast Math"; + if($trimarg eq '-use_fast_math') { $HIPCXXFLAGS .= " -DHIP_FAST_MATH "; } - if(($arg eq '-use-staticlib') and ($setLinkType eq 0)) + if(($trimarg eq '-use-staticlib') and ($setLinkType eq 0)) { $linkType = 0; $setLinkType = 1; } - if(($arg eq '-use-sharedlib') and ($setLinkType eq 0)) + if(($trimarg eq '-use-sharedlib') and ($setLinkType eq 0)) { $linkType = 1; $setLinkType = 1; diff --git a/projects/hip/src/hip_hcc.cpp b/projects/hip/src/hip_hcc.cpp index d760ade15d..c87e201c0c 100644 --- a/projects/hip/src/hip_hcc.cpp +++ b/projects/hip/src/hip_hcc.cpp @@ -69,6 +69,8 @@ std::string HIP_LAUNCH_BLOCKING_KERNELS; std::vector g_hipLaunchBlockingKernels; int HIP_API_BLOCKING = 0; +int HIP_MAX_QUEUES = 0; + int HIP_PRINT_ENV = 0; int HIP_TRACE_API= 0; std::string HIP_TRACE_API_COLOR("green"); @@ -254,7 +256,7 @@ ihipStream_t::ihipStream_t(ihipCtx_t *ctx, hc::accelerator_view av, unsigned int }; - tprintf(DB_SYNC, " streamCreate: stream=%p\n", this); + tprintf(DB_SYNC, " streamCreate: stream=%s\n", ToString(this).c_str()); }; @@ -269,7 +271,7 @@ ihipStream_t::~ihipStream_t() void ihipStream_t::wait(LockedAccessor_StreamCrit_t &crit, bool assertQueueEmpty) { if (! assertQueueEmpty) { - tprintf (DB_SYNC, "stream %p wait for queue-empty..\n", this); + tprintf (DB_SYNC, "stream %s wait for queue-empty..\n", ToString(this).c_str()); hc::hcWaitMode waitMode = hc::hcWaitModeActive; if (_scheduleMode == Auto) { @@ -353,6 +355,7 @@ ihipCtx_t * ihipStream_t::getCtx() const // Lock the stream to prevent other threads from intervening. LockedAccessor_StreamCrit_t ihipStream_t::lockopen_preKernelCommand() { + LockedAccessor_StreamCrit_t crit(_criticalData, false/*no unlock at destruction*/); if(crit->_kernelCnt > HIP_NUM_KERNELS_INFLIGHT){ @@ -361,6 +364,17 @@ LockedAccessor_StreamCrit_t ihipStream_t::lockopen_preKernelCommand() } crit->_kernelCnt++; + if (HIP_MAX_QUEUES && !crit->_hasQueue) { + // Obtain mutex access to the device critical data, release by destructor + LockedAccessor_CtxCrit_t ctxCrit(this->_ctx->criticalData()); + crit->_av = this->_ctx->stealActiveQueue(ctxCrit, this); + crit->_hasQueue = true; + } + + + + assert(crit->_hasQueue); + return crit; } @@ -391,21 +405,22 @@ void ihipStream_t::lockclose_postKernelCommand(const char * kernelName, hc::acce }; -//============================================================================= -// Recompute the peercnt and the packed _peerAgents whenever a peer is added or deleted. -// The packed _peerAgents can efficiently be used on each memory allocation. -template<> -void ihipCtxCriticalBase_t::recomputePeerAgents() -{ - _peerCnt = 0; - std::for_each (_peers.begin(), _peers.end(), [this](ihipCtx_t* ctx) { - _peerAgents[_peerCnt++] = ctx->getDevice()->_hsaAgent; - }); -} + + //============================================================================= + // Recompute the peercnt and the packed _peerAgents whenever a peer is added or deleted. + // The packed _peerAgents can efficiently be used on each memory allocation. + template<> + void ihipCtxCriticalBase_t::recomputePeerAgents() + { + _peerCnt = 0; + std::for_each (_peers.begin(), _peers.end(), [this](ihipCtx_t* ctx) { + _peerAgents[_peerCnt++] = ctx->getDevice()->_hsaAgent; + }); + } -template<> -bool ihipCtxCriticalBase_t::isPeerWatcher(const ihipCtx_t *peer) + template<> + bool ihipCtxCriticalBase_t::isPeerWatcher(const ihipCtx_t *peer) { auto match = std::find(_peers.begin(), _peers.end(), peer); return (match != std::end(_peers)); @@ -880,6 +895,44 @@ std::string ihipCtx_t::toString() const return ss.str(); }; + +hc::accelerator_view +ihipCtx_t::stealActiveQueue(LockedAccessor_CtxCrit_t &ctxCrit, ihipStream_t *needyStream ) +{ + + // TODO - review handling if queue can't be found. + while (1) { + for (auto iter=ctxCrit->streams().begin(); iter != ctxCrit->streams().end(); iter++) { + if (*iter != needyStream) { + auto victimCritPtr = (*iter)->_criticalData.mtry_lock(); + if (victimCritPtr && victimCritPtr->_hasQueue && (victimCritPtr->_kernelCnt == 0)) { + + + victimCritPtr->_hasQueue = false; + + tprintf(DB_SYNC, " stealActiveQueue move queue from victim:%s to needy:%s\n", + ToString(*iter).c_str(), ToString(needyStream).c_str()); + + return victimCritPtr->_av; + } + } + } + } +} + + +hc::accelerator_view +ihipCtx_t::createOrStealQueue(LockedAccessor_CtxCrit_t &ctxCrit) +{ + if (HIP_MAX_QUEUES && (ctxCrit->streams().size() >= HIP_MAX_QUEUES)) { + // Steal a queue from an existing stream: + return this->stealActiveQueue (ctxCrit, nullptr); + } else { + // Create a new view + return getWriteableDevice()->_acc.create_view(); + } +} + //---- @@ -921,13 +974,6 @@ void ihipCtx_t::locked_syncDefaultStream(bool waitOnSelf) } } -//--- -void ihipCtx_t::locked_addStream(ihipStream_t *s) -{ - LockedAccessor_CtxCrit_t crit(_criticalData); - - crit->addStream(s); -} //--- void ihipCtx_t::locked_removeStream(ihipStream_t *s) @@ -1217,6 +1263,7 @@ void ihipInit() READ_ENV_I(release, HIP_API_BLOCKING, 0, "Make HIP APIs 'host-synchronous', so they block until completed. Impacts hipMemcpyAsync, hipMemsetAsync." ); + READ_ENV_I(release, HIP_MAX_QUEUES, 0, "Maximum number of queues that this app will use per-device. Additional streams will share the specified number of queues. 0=no limit."); READ_ENV_C(release, HIP_DB, 0, "Print debug info. Bitmask (HIP_DB=0xff) or flags separated by '+' (HIP_DB=api+sync+mem+copy)", HIP_DB_callback); if ((HIP_DB & (1< public: ihipStreamCriticalBase_t(hc::accelerator_view av) : _kernelCnt(0), - _av(av) + _av(av), + _hasQueue(true) { }; @@ -410,11 +410,20 @@ public: } ihipStreamCriticalBase_t * mlock() { LockedBase::lock(); return this;}; + ihipStreamCriticalBase_t * mtry_lock() { + return LockedBase::try_lock() ? this: nullptr; + }; public: - // TODO - remove _kernelCnt mechanism: uint32_t _kernelCnt; // Count of inflight kernels in this stream. Reset at ::wait(). + hc::accelerator_view _av; + + // True if the stream has an allocated queue (accelerato_view) for its use: + // Always true at ihipStream creation but queue may later be stolen. + // This acts as a valid bit for the _av. + bool _hasQueue; +private: }; @@ -422,6 +431,7 @@ public: // for the ihipCtx_t and then for the individual streams. The locks should not be acquired in reverse order // or deadlock may occur. In some cases, it may be possible to reduce the range where the locks must be held. // HIP routines should avoid acquiring and releasing the same lock during the execution of a single HIP API. +// Another option is to use try_lock in the innermost lock query. typedef ihipStreamCriticalBase_t ihipStreamCritical_t; @@ -436,6 +446,7 @@ public: enum ScheduleMode {Auto, Spin, Yield}; typedef uint64_t SeqNum_t ; + // TODOD -make av a reference to avoid shared_ptr overhead? ihipStream_t(ihipCtx_t *ctx, hc::accelerator_view av, unsigned int flags); ~ihipStream_t(); @@ -499,11 +510,14 @@ private: bool canSeeMemory(const ihipCtx_t *thisCtx, const hc::AmPointerInfo *dstInfo, const hc::AmPointerInfo *srcInfo); - -private: // Data +public: // TODO - move private // Critical Data - MUST be accessed through LockedAccessor_StreamCrit_t ihipStreamCritical_t _criticalData; +private: // Data + + std::mutex _hasQueueLock; + ihipCtx_t *_ctx; // parent context that owns this stream. // Friends: @@ -602,6 +616,7 @@ public: const std::list &const_streams() const { return _streams; }; + // Peer Accessor classes: bool isPeerWatcher(const ihipCtx_t *peer); // returns True if peer has access to memory physically located on this device. bool addPeerWatcher(const ihipCtx_t *thisCtx, ihipCtx_t *peer); @@ -651,17 +666,22 @@ public: // Functions: ihipCtx_t(ihipDevice_t *device, unsigned deviceCnt, unsigned flags); // note: calls constructor for _criticalData ~ihipCtx_t(); - // Functions which read or write the critical data are named locked_. + // Functions which read or write the critical data are named locked_. + // (might be better called "locking_" // ihipCtx_t does not use recursive locks so the ihip implementation must avoid calling a locked_ function from within a locked_ function. // External functions which call several locked_ functions will acquire and release the lock for each function. if this occurs in // performance-sensitive code we may want to refactor by adding non-locked functions and creating a new locked_ member function to call them all. - void locked_addStream(ihipStream_t *s); void locked_removeStream(ihipStream_t *s); void locked_reset(); void locked_waitAllStreams(); void locked_syncDefaultStream(bool waitOnSelf); - ihipCtxCritical_t &criticalData() { return _criticalData; }; // TODO, move private. Fix P2P. + // Will allocate a queue and assign it to the needyStream: + hc::accelerator_view stealActiveQueue(LockedAccessor_CtxCrit_t &ctxCrit, + ihipStream_t *needyStream); + hc::accelerator_view createOrStealQueue(LockedAccessor_CtxCrit_t &ctxCrit); + + ihipCtxCritical_t &criticalData() { return _criticalData; }; const ihipDevice_t *getDevice() const { return _device; }; int getDeviceNum() const { return _device->_deviceId; }; diff --git a/projects/hip/src/hip_stream.cpp b/projects/hip/src/hip_stream.cpp index 8350035357..d754ffe5f6 100644 --- a/projects/hip/src/hip_stream.cpp +++ b/projects/hip/src/hip_stream.cpp @@ -45,11 +45,15 @@ hipError_t ihipStreamCreate(hipStream_t *stream, unsigned int flags) //Note this is an execute_in_order queue, so all kernels submitted will atuomatically wait for prev to complete: //This matches CUDA stream behavior: - auto istream = new ihipStream_t(ctx, acc.create_view(), flags); + { + // Obtain mutex access to the device critical data, release by destructor + LockedAccessor_CtxCrit_t ctxCrit(ctx->criticalData()); + auto istream = new ihipStream_t(ctx, ctx->createOrStealQueue(ctxCrit), flags); - ctx->locked_addStream(istream); + ctxCrit->addStream(istream); + *stream = istream; + } - *stream = istream; tprintf(DB_SYNC, "hipStreamCreate, stream=%p\n", *stream); } else { e = hipErrorInvalidDevice; From 653248458f45da3c10380c4fee82093692ad7155 Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Mon, 26 Dec 2016 20:26:56 -0600 Subject: [PATCH 048/281] Add more notes on debugging HIP apps. [ROCm/hip commit: fd209f37d97c71a2fedd63b7ffa54f1a1f77ab6f] --- projects/hip/docs/markdown/hip_profiling.md | 22 +++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/projects/hip/docs/markdown/hip_profiling.md b/projects/hip/docs/markdown/hip_profiling.md index 0c55acf85e..61f1bbcfbc 100644 --- a/projects/hip/docs/markdown/hip_profiling.md +++ b/projects/hip/docs/markdown/hip_profiling.md @@ -340,3 +340,25 @@ These options cause HCC to serialize. Useful if you have libraries or code whic - HSA_ENABLE_SDMA=0 : Causes host-to-device and device-to-host copies to use compute shader blit kernels rather than the dedicated DMA copy engines. Compute shader copies have low latency (typically < 5us) and can achieve approximately 80% of the bandwidth of the DMA copy engine. This flag is useful to isolate issues with the hardware copy engines. - HSA_ENABLE_INTERRUPT=0 : Causes completion signals to be detected with memory-based polling rather than interrupts. Can be useful to diagnose interrupt storm issues in the driver. - HSA_DISABLE_CACHE=1 : Disables the GPU L2 data cache. + +### Debugging HIP Applications + +- The variable "tls_tidInfo" contains the API sequence number (_apiSeqNum)- a monotonically increasing count of the HIP APIs called from this thread. This can be useful for setting conditional breakpoints. Also, each new HIP thread is mapped to monotically increasing shortTid ID. Both of these fields are displayed in the HIP debug info. +``` +(gdb) p tls_tidInfo +$32 = {_shortTid = 1, _apiSeqNum = 803} +``` + +- HCC tracks all of the application memory allocations, including those from HIP and HC's "am_alloc". These can be printed by calling the function 'hc::am_memtracker_print()'. +An optional argument specifies a void * targetPointer - the print routine will mark the allocation which contains the specified pointer with "-->" in the printed output. +This example shows a sample GDB session where we print the memory allocated by this process and mark a specified address by using the gdb "call" function.. +The gdb syntax also supports using the variable name (in this case 'dst'): +``` +(gdb) p dst +$33 = (void *) 0x5ec7e9000 +(gdb) call hc::am_memtracker_print(dst) +TargetAddress:0x5ec7e9000 + 0x504cfc000-0x504cfc00f:: allocSeqNum:1 hostPointer:0x504cfc000 devicePointer:0x504cfc000 sizeBytes:16 isInDeviceMem:0 isAmManaged:1 appId:0 appAllocFlags:0 appPtr:(nil) +... +-->0x5ec7e9000-0x5f7e28fff:: allocSeqNum:488 hostPointer:(nil) devicePointer:0x5ec7e9000 sizeBytes:191102976 isInDeviceMem:1 isAmManaged:1 appId:0 appAllocFlags:0 appPtr:(nil) +``` From bbb1485a8356e709f63553eaebac9e5fb6e6b868 Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Wed, 4 Jan 2017 14:38:18 -0600 Subject: [PATCH 049/281] First pass at virtualized queue support. Also updated stream debug messages to consistently use trace_helper. [ROCm/hip commit: 93fbc9cf7b32adc478d1965d83de3bd5e83ee4f7] --- projects/hip/src/hip_hcc.cpp | 59 +++++++++++++---------- projects/hip/src/hip_hcc.h | 84 ++++++++++++++++++++------------- projects/hip/src/hip_memory.cpp | 7 ++- projects/hip/src/hip_stream.cpp | 2 +- 4 files changed, 88 insertions(+), 64 deletions(-) diff --git a/projects/hip/src/hip_hcc.cpp b/projects/hip/src/hip_hcc.cpp index c87e201c0c..3bb3d6d128 100644 --- a/projects/hip/src/hip_hcc.cpp +++ b/projects/hip/src/hip_hcc.cpp @@ -243,7 +243,7 @@ ihipStream_t::ihipStream_t(ihipCtx_t *ctx, hc::accelerator_view av, unsigned int _id(0), // will be set by add function. _flags(flags), _ctx(ctx), - _criticalData(av) + _criticalData(this, av) { unsigned schedBits = ctx->_ctxFlags & hipDeviceScheduleMask; @@ -256,7 +256,6 @@ ihipStream_t::ihipStream_t(ihipCtx_t *ctx, hc::accelerator_view av, unsigned int }; - tprintf(DB_SYNC, " streamCreate: stream=%s\n", ToString(this).c_str()); }; @@ -271,7 +270,7 @@ ihipStream_t::~ihipStream_t() void ihipStream_t::wait(LockedAccessor_StreamCrit_t &crit, bool assertQueueEmpty) { if (! assertQueueEmpty) { - tprintf (DB_SYNC, "stream %s wait for queue-empty..\n", ToString(this).c_str()); + tprintf (DB_SYNC, "%s wait for queue-empty..\n", ToString(this).c_str()); hc::hcWaitMode waitMode = hc::hcWaitModeActive; if (_scheduleMode == Auto) { @@ -406,21 +405,21 @@ void ihipStream_t::lockclose_postKernelCommand(const char * kernelName, hc::acce - //============================================================================= - // Recompute the peercnt and the packed _peerAgents whenever a peer is added or deleted. - // The packed _peerAgents can efficiently be used on each memory allocation. - template<> - void ihipCtxCriticalBase_t::recomputePeerAgents() - { - _peerCnt = 0; - std::for_each (_peers.begin(), _peers.end(), [this](ihipCtx_t* ctx) { - _peerAgents[_peerCnt++] = ctx->getDevice()->_hsaAgent; - }); - } +//============================================================================= +// Recompute the peercnt and the packed _peerAgents whenever a peer is added or deleted. +// The packed _peerAgents can efficiently be used on each memory allocation. +template<> +void ihipCtxCriticalBase_t::recomputePeerAgents() +{ + _peerCnt = 0; + std::for_each (_peers.begin(), _peers.end(), [this](ihipCtx_t* ctx) { + _peerAgents[_peerCnt++] = ctx->getDevice()->_hsaAgent; + }); +} - template<> - bool ihipCtxCriticalBase_t::isPeerWatcher(const ihipCtx_t *peer) +template<> +bool ihipCtxCriticalBase_t::isPeerWatcher(const ihipCtx_t *peer) { auto match = std::find(_peers.begin(), _peers.end(), peer); return (match != std::end(_peers)); @@ -489,6 +488,7 @@ void ihipCtxCriticalBase_t::addStream(ihipStream_t *stream) { stream->_id = _streams.size(); _streams.push_back(stream); + tprintf(DB_SYNC, " addStream: %s\n", ToString(stream).c_str()); } //============================================================================= @@ -827,11 +827,11 @@ hipError_t ihipDevice_t::initProperties(hipDeviceProp_t* prop) ihipCtx_t::ihipCtx_t(ihipDevice_t *device, unsigned deviceCnt, unsigned flags) : _ctxFlags(flags), _device(device), - _criticalData(deviceCnt) + _criticalData(this, deviceCnt) { locked_reset(); - tprintf(DB_SYNC, "created ctx with defaultStream=%p\n", _defaultStream); + tprintf(DB_SYNC, "created ctx with defaultStream=%p (%s)\n", _defaultStream, ToString(_defaultStream).c_str()); }; @@ -861,7 +861,7 @@ void ihipCtx_t::locked_reset() for (auto streamI=crit->const_streams().begin(); streamI!=crit->const_streams().end(); streamI++) { ihipStream_t *stream = *streamI; (*streamI)->locked_wait(); - tprintf(DB_SYNC, " delete stream=%p\n", stream); + tprintf(DB_SYNC, " delete %s\n", ToString(stream).c_str()); delete stream; } @@ -905,15 +905,24 @@ ihipCtx_t::stealActiveQueue(LockedAccessor_CtxCrit_t &ctxCrit, ihipStream_t *nee for (auto iter=ctxCrit->streams().begin(); iter != ctxCrit->streams().end(); iter++) { if (*iter != needyStream) { auto victimCritPtr = (*iter)->_criticalData.mtry_lock(); - if (victimCritPtr && victimCritPtr->_hasQueue && (victimCritPtr->_kernelCnt == 0)) { + if (victimCritPtr) { + if (victimCritPtr->_hasQueue && (victimCritPtr->_kernelCnt == 0)) { + victimCritPtr->_hasQueue = false; - victimCritPtr->_hasQueue = false; + tprintf(DB_SYNC, " stealActiveQueue from victim:%s to needy:%s\n", + ToString(*iter).c_str(), ToString(needyStream).c_str()); - tprintf(DB_SYNC, " stealActiveQueue move queue from victim:%s to needy:%s\n", - ToString(*iter).c_str(), ToString(needyStream).c_str()); + // TODO - cleanup to remove forced setting to N + hc::accelerator_view av = victimCritPtr->_av; + uint64_t *p = (uint64_t*)(&victimCritPtr->_av); + *p = 0; // damage the victim av so attempt to use it will fault. - return victimCritPtr->_av; + (*iter)->_criticalData.munlock(); + return av; + } else { + (*iter)->_criticalData.munlock(); + } } } } @@ -1415,7 +1424,7 @@ hipStream_t ihipSyncAndResolveStream(hipStream_t stream) } else { // ALl streams have to wait for legacy default stream to be empty: if (!(stream->_flags & hipStreamNonBlocking)) { - tprintf(DB_SYNC, "stream %p wait default stream\n", stream); + tprintf(DB_SYNC, "%s wait default stream\n", ToString(stream).c_str()); stream->getCtx()->_defaultStream->locked_wait(); } diff --git a/projects/hip/src/hip_hcc.h b/projects/hip/src/hip_hcc.h index f2a2fb49fa..876e5df816 100644 --- a/projects/hip/src/hip_hcc.h +++ b/projects/hip/src/hip_hcc.h @@ -292,6 +292,34 @@ extern "C" { const hipStream_t hipStreamNull = 0x0; +/** + * HIP IPC Handle Size + */ +#define HIP_IPC_HANDLE_SIZE 64 +class ihipIpcMemHandle_t +{ +public: +#if USE_IPC + hsa_amd_ipc_memory_t ipc_handle; ///< ipc memory handle on ROCr +#endif + char reserved[HIP_IPC_HANDLE_SIZE]; + size_t psize; +}; + + +class ihipModule_t { +public: + hsa_executable_t executable; + hsa_code_object_t object; + std::string fileName; + void *ptr; + size_t size; + + ihipModule_t() : executable(), object(), fileName(), ptr(nullptr), size(0) {} +}; + + +//--- // Used to remove lock, for performance or stimulating bugs. class FakeMutex { @@ -330,21 +358,21 @@ public: _autoUnlock(autoUnlock) { - tprintf(DB_SYNC, "lock critical data %s.%p\n", typeid(T).name(), _criticalData); + tprintf(DB_SYNC, "lock criticalData=%p for %s\n", _criticalData, ToString(_criticalData->_parent).c_str()); _criticalData->_mutex.lock(); }; ~LockedAccessor() { if (_autoUnlock) { - tprintf(DB_SYNC, "auto-unlock critical data %s.%p\n",typeid(T).name(), _criticalData); + tprintf(DB_SYNC, "auto-unlock criticalData=%p for %s\n", _criticalData, ToString(_criticalData->_parent).c_str()); _criticalData->_mutex.unlock(); } } void unlock() { - tprintf(DB_SYNC, "unlock critical data %s.%p\n", typeid(T).name(), _criticalData); + tprintf(DB_SYNC, "unlock criticalData=%p for %s\n", _criticalData, ToString(_criticalData->_parent).c_str()); _criticalData->_mutex.unlock(); } @@ -369,40 +397,16 @@ struct LockedBase { MUTEX_TYPE _mutex; }; -/** - * HIP IPC Handle Size - */ -#define HIP_IPC_HANDLE_SIZE 64 -class ihipIpcMemHandle_t -{ -public: -#if USE_IPC - hsa_amd_ipc_memory_t ipc_handle; ///< ipc memory handle on ROCr -#endif - char reserved[HIP_IPC_HANDLE_SIZE]; - size_t psize; -}; - - -class ihipModule_t { -public: - hsa_executable_t executable; - hsa_code_object_t object; - std::string fileName; - void *ptr; - size_t size; - - ihipModule_t() : executable(), object(), fileName(), ptr(nullptr), size(0) {} -}; template class ihipStreamCriticalBase_t : public LockedBase { public: - ihipStreamCriticalBase_t(hc::accelerator_view av) : + ihipStreamCriticalBase_t(ihipStream_t *parentStream, hc::accelerator_view av) : _kernelCnt(0), _av(av), - _hasQueue(true) + _hasQueue(true), + _parent(parentStream) { }; @@ -410,11 +414,20 @@ public: } ihipStreamCriticalBase_t * mlock() { LockedBase::lock(); return this;}; + + void munlock() { + tprintf(DB_SYNC, "munlock criticalData=%p for %s\n", this, ToString(this->_parent).c_str()); + LockedBase::unlock(); + }; + ihipStreamCriticalBase_t * mtry_lock() { - return LockedBase::try_lock() ? this: nullptr; + bool gotLock = LockedBase::try_lock() ; + tprintf(DB_SYNC, "mtry_lock=%d criticalData=%p for %s\n", gotLock, this, ToString(this->_parent).c_str()); + return gotLock ? this: nullptr; }; public: + ihipStream_t * _parent; uint32_t _kernelCnt; // Count of inflight kernels in this stream. Reset at ::wait(). hc::accelerator_view _av; @@ -596,8 +609,9 @@ template class ihipCtxCriticalBase_t : LockedBase { public: - ihipCtxCriticalBase_t(unsigned deviceCnt) : - _peerCnt(0) + ihipCtxCriticalBase_t(ihipCtx_t *parentCtx, unsigned deviceCnt) : + _parent(parentCtx), + _peerCnt(0) { _peerAgents = new hsa_agent_t[deviceCnt]; }; @@ -633,6 +647,8 @@ public: friend class LockedAccessor; private: + ihipCtx_t * _parent; + //--- Stream Tracker: std::list< ihipStream_t* > _streams; // streams associated with this device. @@ -739,7 +755,7 @@ hipStream_t ihipSyncAndResolveStream(hipStream_t); // Stream printf functions: inline std::ostream& operator<<(std::ostream& os, const ihipStream_t& s) { - os << "stream#"; + os << "stream:"; os << s.getDevice()->_deviceId;; os << '.'; os << s._id; diff --git a/projects/hip/src/hip_memory.cpp b/projects/hip/src/hip_memory.cpp index 74578e9b4b..5bc77cf543 100644 --- a/projects/hip/src/hip_memory.cpp +++ b/projects/hip/src/hip_memory.cpp @@ -131,7 +131,7 @@ hipError_t hipMalloc(void** ptr, size_t sizeBytes) LockedAccessor_CtxCrit_t crit(ctx->criticalData()); // the peerCnt always stores self so make sure the trace actually peerCnt = crit->peerCnt(); - tprintf(DB_MEM, " allocated device_mem ptr:%p size:%zu on dev:%d and allowed %d other peer(s) access\n", + tprintf(DB_MEM, " allocated device_mem ptr:%p size:%zu on dev:%d and allow access to %d other peer(s)\n", *ptr, sizeBytes, device->_deviceId, peerCnt-1); if (peerCnt > 1) { @@ -841,7 +841,6 @@ hipError_t hipMemsetAsync(void* dst, int value, size_t sizeBytes, hipStream_t s if (HIP_API_BLOCKING) { tprintf (DB_SYNC, "%s LAUNCH_BLOCKING wait for hipMemsetAsync.\n", ToString(stream).c_str()); cf.wait(); - //tprintf (DB_SYNC, "'%s' LAUNCH_BLOCKING memset completed [stream:%p].\n", __func__, (void*)stream); } } else { e = hipErrorInvalidValue; @@ -892,9 +891,9 @@ hipError_t hipMemset(void* dst, int value, size_t sizeBytes ) if (HIP_LAUNCH_BLOCKING) { - tprintf (DB_SYNC, "'%s' LAUNCH_BLOCKING wait for memset [stream:%p].\n", __func__, (void*)stream); + tprintf (DB_SYNC, "'%s' LAUNCH_BLOCKING wait for memset in %s.\n", __func__, ToString(stream).c_str()); cf.wait(); - tprintf (DB_SYNC, "'%s' LAUNCH_BLOCKING memset completed [stream:%p].\n", __func__, (void*)stream); + tprintf (DB_SYNC, "'%s' LAUNCH_BLOCKING memset completed in %s.\n", __func__, ToString(stream).c_str()); } } else { e = hipErrorInvalidValue; diff --git a/projects/hip/src/hip_stream.cpp b/projects/hip/src/hip_stream.cpp index d754ffe5f6..8641f72265 100644 --- a/projects/hip/src/hip_stream.cpp +++ b/projects/hip/src/hip_stream.cpp @@ -54,7 +54,7 @@ hipError_t ihipStreamCreate(hipStream_t *stream, unsigned int flags) *stream = istream; } - tprintf(DB_SYNC, "hipStreamCreate, stream=%p\n", *stream); + tprintf(DB_SYNC, "hipStreamCreate, %s\n", ToString(*stream).c_str()); } else { e = hipErrorInvalidDevice; } From 1908d9504b36144ff27f110053683b6b3fba5015 Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Mon, 9 Jan 2017 17:19:40 -0600 Subject: [PATCH 050/281] Add HIP_MAX_QUEUES feature. Includes some tricky manipulation of the locks for contexts and streams. issue is that stealing a stream requires we lock the context to walk the streams to find a victim. To avoid deadlock, we can't have a stream locked when we lock the context. This implementation releases the stream lock, then acquires the context and selects the victim. A more stable implemenation might be to copy the stream list from a context so that a lock is not required to walk all streams. Smart shared_ptr could be used to prevent the streams from being deallocated during the walk. [ROCm/hip commit: a3e0012567697a78272ba2e509875bfeb410a367] --- projects/hip/src/hip_hcc.cpp | 78 +++++++++++++++++++++++---------- projects/hip/src/hip_hcc.h | 18 ++++---- projects/hip/src/hip_memory.cpp | 3 ++ projects/hip/src/hip_stream.cpp | 11 ++++- 4 files changed, 76 insertions(+), 34 deletions(-) diff --git a/projects/hip/src/hip_hcc.cpp b/projects/hip/src/hip_hcc.cpp index 3bb3d6d128..e5b7937e25 100644 --- a/projects/hip/src/hip_hcc.cpp +++ b/projects/hip/src/hip_hcc.cpp @@ -265,11 +265,37 @@ ihipStream_t::~ihipStream_t() } +inline void ihipStream_t::ensureHaveQueue(LockedAccessor_StreamCrit_t &streamCrit) +{ + if (HIP_MAX_QUEUES && !streamCrit->_hasQueue) { + + // To avoid deadlock, we have to release the stream lock before acquiring context lock. + // Else we can get hung if another thread has the context lock is trying to get lock for this stream. + // We lock it again below. + streamCrit->munlock(); + + // Obtain mutex access to the device critical data, release by destructor + LockedAccessor_CtxCrit_t ctxCrit(this->_ctx->criticalData()); + // TODO + auto needyCritPtr = this->_criticalData.mlock(); + + // Second test to ensure we still need to steal the queue - another thread may have + // snuck in here and already solved the issue. + if (!needyCritPtr->_hasQueue) { + needyCritPtr->_av = this->_ctx->stealActiveQueue(ctxCrit, this); + } + + streamCrit->_hasQueue = true; + } + assert(streamCrit->_hasQueue); +} + + //Wait for all kernel and data copy commands in this stream to complete. //This signature should be used in routines that already have locked the stream mutex -void ihipStream_t::wait(LockedAccessor_StreamCrit_t &crit, bool assertQueueEmpty) +void ihipStream_t::wait(LockedAccessor_StreamCrit_t &crit) { - if (! assertQueueEmpty) { + if (crit->_hasQueue) { tprintf (DB_SYNC, "%s wait for queue-empty..\n", ToString(this).c_str()); hc::hcWaitMode waitMode = hc::hcWaitModeActive; @@ -294,6 +320,8 @@ void ihipStream_t::wait(LockedAccessor_StreamCrit_t &crit, bool assertQueueEmpty } crit->_av.wait(waitMode); + } else { + tprintf (DB_SYNC, "%s wait for queue empty (done since stream has no physical queue).\n", ToString(this).c_str()); } crit->_kernelCnt = 0; @@ -301,11 +329,11 @@ void ihipStream_t::wait(LockedAccessor_StreamCrit_t &crit, bool assertQueueEmpty //--- //Wait for all kernel and data copy commands in this stream to complete. -void ihipStream_t::locked_wait(bool assertQueueEmpty) +void ihipStream_t::locked_wait() { LockedAccessor_StreamCrit_t crit(_criticalData); - wait(crit, assertQueueEmpty); + wait(crit); }; @@ -314,6 +342,8 @@ void ihipStream_t::locked_waitEvent(hipEvent_t event) { LockedAccessor_StreamCrit_t crit(_criticalData); + this->ensureHaveQueue(crit); + crit->_av.create_blocking_marker(event->_marker); } @@ -324,6 +354,7 @@ void ihipStream_t::locked_recordEvent(hipEvent_t event) // Lock the stream to prevent simultaneous access LockedAccessor_StreamCrit_t crit(_criticalData); + this->ensureHaveQueue(crit); event->_marker = crit->_av.create_marker(); } @@ -361,19 +392,11 @@ LockedAccessor_StreamCrit_t ihipStream_t::lockopen_preKernelCommand() this->wait(crit); crit->_kernelCnt = 0; } - crit->_kernelCnt++; - if (HIP_MAX_QUEUES && !crit->_hasQueue) { - // Obtain mutex access to the device critical data, release by destructor - LockedAccessor_CtxCrit_t ctxCrit(this->_ctx->criticalData()); - crit->_av = this->_ctx->stealActiveQueue(ctxCrit, this); - crit->_hasQueue = true; - } + this->ensureHaveQueue(crit); + - - assert(crit->_hasQueue); - return crit; } @@ -896,16 +919,18 @@ std::string ihipCtx_t::toString() const }; -hc::accelerator_view -ihipCtx_t::stealActiveQueue(LockedAccessor_CtxCrit_t &ctxCrit, ihipStream_t *needyStream ) +hc::accelerator_view +ihipCtx_t::stealActiveQueue(LockedAccessor_CtxCrit_t &ctxCrit, ihipStream_t *needyStream) { // TODO - review handling if queue can't be found. while (1) { + for (auto iter=ctxCrit->streams().begin(); iter != ctxCrit->streams().end(); iter++) { if (*iter != needyStream) { auto victimCritPtr = (*iter)->_criticalData.mtry_lock(); if (victimCritPtr) { + // try-lock succeeded: if (victimCritPtr->_hasQueue && (victimCritPtr->_kernelCnt == 0)) { victimCritPtr->_hasQueue = false; @@ -913,16 +938,16 @@ ihipCtx_t::stealActiveQueue(LockedAccessor_CtxCrit_t &ctxCrit, ihipStream_t *nee tprintf(DB_SYNC, " stealActiveQueue from victim:%s to needy:%s\n", ToString(*iter).c_str(), ToString(needyStream).c_str()); + hc::accelerator_view av = victimCritPtr->_av; + // TODO - cleanup to remove forced setting to N - hc::accelerator_view av = victimCritPtr->_av; uint64_t *p = (uint64_t*)(&victimCritPtr->_av); *p = 0; // damage the victim av so attempt to use it will fault. (*iter)->_criticalData.munlock(); - return av; - } else { - (*iter)->_criticalData.munlock(); - } + return av; + } + (*iter)->_criticalData.munlock(); } } } @@ -935,7 +960,8 @@ ihipCtx_t::createOrStealQueue(LockedAccessor_CtxCrit_t &ctxCrit) { if (HIP_MAX_QUEUES && (ctxCrit->streams().size() >= HIP_MAX_QUEUES)) { // Steal a queue from an existing stream: - return this->stealActiveQueue (ctxCrit, nullptr); + hc::accelerator_view av = this->stealActiveQueue (ctxCrit, nullptr); + return av; } else { // Create a new view return getWriteableDevice()->_acc.create_view(); @@ -1838,6 +1864,7 @@ void ihipStream_t::locked_copySync(void* dst, const void* src, size_t sizeBytes, src, srcPtrInfo._hostPointer, srcPtrInfo._devicePointer, srcPtrInfo._sizeBytes, srcPtrInfo._appId, srcTracked, srcPtrInfo._isInDeviceMem); + this->ensureHaveQueue(crit); #if USE_COPY_EXT_V2 crit->_av.copy_ext(src, dst, sizeBytes, hcCopyDir, srcPtrInfo, dstPtrInfo, copyDevice ? ©Device->getDevice()->_acc : nullptr, forceUnpinnedCopy); @@ -1902,6 +1929,8 @@ void ihipStream_t::locked_copyAsync(void* dst, const void* src, size_t sizeBytes // Perform fast asynchronous copy - we know copyDevice != NULL based on check above try { + this->ensureHaveQueue(crit); + if (HIP_FORCE_SYNC_COPY) { #if USE_COPY_EXT_V2 crit->_av.copy_ext (src, dst, sizeBytes, hcCopyDir, srcPtrInfo, dstPtrInfo, ©Device->getDevice()->_acc, forceUnpinnedCopy); @@ -1928,6 +1957,8 @@ void ihipStream_t::locked_copyAsync(void* dst, const void* src, size_t sizeBytes } else { LockedAccessor_StreamCrit_t crit(_criticalData); + + this->ensureHaveQueue(crit); #if USE_COPY_EXT_V2 crit->_av.copy_ext(src, dst, sizeBytes, hcCopyDir, srcPtrInfo, dstPtrInfo, copyDevice ? ©Device->getDevice()->_acc : nullptr, forceUnpinnedCopy); #else @@ -1985,6 +2016,7 @@ hipError_t hipHccGetAccelerator(int deviceId, hc::accelerator *acc) //--- +// Warning - with HIP_MAX_QUEUES!=0 there is no mechanism to prevent accelerator_view from being re-assigned... hipError_t hipHccGetAcceleratorView(hipStream_t stream, hc::accelerator_view **av) { HIP_INIT_API(stream, av); @@ -1994,7 +2026,7 @@ hipError_t hipHccGetAcceleratorView(hipStream_t stream, hc::accelerator_view **a stream = device->_defaultStream; } - *av = stream->locked_getAv(); + *av = stream->locked_getAv(); // TODO - review. hipError_t err = hipSuccess; return ihipLogStatus(err); diff --git a/projects/hip/src/hip_hcc.h b/projects/hip/src/hip_hcc.h index 876e5df816..e19ce63263 100644 --- a/projects/hip/src/hip_hcc.h +++ b/projects/hip/src/hip_hcc.h @@ -358,21 +358,21 @@ public: _autoUnlock(autoUnlock) { - tprintf(DB_SYNC, "lock criticalData=%p for %s\n", _criticalData, ToString(_criticalData->_parent).c_str()); + tprintf(DB_SYNC, "locking criticalData=%p for %s..\n", _criticalData, ToString(_criticalData->_parent).c_str()); _criticalData->_mutex.lock(); }; ~LockedAccessor() { if (_autoUnlock) { - tprintf(DB_SYNC, "auto-unlock criticalData=%p for %s\n", _criticalData, ToString(_criticalData->_parent).c_str()); + tprintf(DB_SYNC, "auto-unlocking criticalData=%p for %s...\n", _criticalData, ToString(_criticalData->_parent).c_str()); _criticalData->_mutex.unlock(); } } void unlock() { - tprintf(DB_SYNC, "unlock criticalData=%p for %s\n", _criticalData, ToString(_criticalData->_parent).c_str()); + tprintf(DB_SYNC, "unlocking criticalData=%p for %s...\n", _criticalData, ToString(_criticalData->_parent).c_str()); _criticalData->_mutex.unlock(); } @@ -416,13 +416,13 @@ public: ihipStreamCriticalBase_t * mlock() { LockedBase::lock(); return this;}; void munlock() { - tprintf(DB_SYNC, "munlock criticalData=%p for %s\n", this, ToString(this->_parent).c_str()); + tprintf(DB_SYNC, "munlocking criticalData=%p for %s...\n", this, ToString(this->_parent).c_str()); LockedBase::unlock(); }; ihipStreamCriticalBase_t * mtry_lock() { bool gotLock = LockedBase::try_lock() ; - tprintf(DB_SYNC, "mtry_lock=%d criticalData=%p for %s\n", gotLock, this, ToString(this->_parent).c_str()); + tprintf(DB_SYNC, "mtry_locking=%d criticalData=%p for %s...\n", gotLock, this, ToString(this->_parent).c_str()); return gotLock ? this: nullptr; }; @@ -476,7 +476,7 @@ public: void lockclose_postKernelCommand(const char *kernelName, hc::accelerator_view *av); - void locked_wait(bool assertQueueEmpty=false); + void locked_wait(); hc::accelerator_view* locked_getAv() { LockedAccessor_StreamCrit_t crit(_criticalData); return &(crit->_av); }; @@ -487,7 +487,7 @@ public: //--- // Use this if we already have the stream critical data mutex: - void wait(LockedAccessor_StreamCrit_t &crit, bool assertQueueEmpty=false); + void wait(LockedAccessor_StreamCrit_t &crit); void launchModuleKernel(hc::accelerator_view av, hsa_signal_t signal, uint32_t blockDimX, uint32_t blockDimY, uint32_t blockDimZ, @@ -502,6 +502,7 @@ public: const ihipDevice_t * getDevice() const; ihipCtx_t * getCtx() const; + void ensureHaveQueue(LockedAccessor_StreamCrit_t &streamCrit); public: //--- @@ -693,8 +694,7 @@ public: // Functions: void locked_syncDefaultStream(bool waitOnSelf); // Will allocate a queue and assign it to the needyStream: - hc::accelerator_view stealActiveQueue(LockedAccessor_CtxCrit_t &ctxCrit, - ihipStream_t *needyStream); + hc::accelerator_view stealActiveQueue(LockedAccessor_CtxCrit_t &ctxCrit, ihipStream_t *needyStream); hc::accelerator_view createOrStealQueue(LockedAccessor_CtxCrit_t &ctxCrit); ihipCtxCritical_t &criticalData() { return _criticalData; }; diff --git a/projects/hip/src/hip_memory.cpp b/projects/hip/src/hip_memory.cpp index 5bc77cf543..372d295b89 100644 --- a/projects/hip/src/hip_memory.cpp +++ b/projects/hip/src/hip_memory.cpp @@ -813,6 +813,8 @@ hipError_t hipMemsetAsync(void* dst, int value, size_t sizeBytes, hipStream_t s if (stream) { auto crit = stream->lockopen_preKernelCommand(); + stream->ensureHaveQueue(crit); + hc::completion_future cf ; if ((sizeBytes & 0x3) == 0) { @@ -863,6 +865,7 @@ hipError_t hipMemset(void* dst, int value, size_t sizeBytes ) if (stream) { auto crit = stream->lockopen_preKernelCommand(); + stream->ensureHaveQueue(crit); hc::completion_future cf ; if ((sizeBytes & 0x3) == 0) { diff --git a/projects/hip/src/hip_stream.cpp b/projects/hip/src/hip_stream.cpp index 8641f72265..aae412160f 100644 --- a/projects/hip/src/hip_stream.cpp +++ b/projects/hip/src/hip_stream.cpp @@ -48,6 +48,7 @@ hipError_t ihipStreamCreate(hipStream_t *stream, unsigned int flags) { // Obtain mutex access to the device critical data, release by destructor LockedAccessor_CtxCrit_t ctxCrit(ctx->criticalData()); + auto istream = new ihipStream_t(ctx, ctx->createOrStealQueue(ctxCrit), flags); ctxCrit->addStream(istream); @@ -124,8 +125,14 @@ hipError_t hipStreamQuery(hipStream_t stream) stream = device->_defaultStream; } - LockedAccessor_StreamCrit_t crit(stream->_criticalData); - int pendingOps = crit->_av.get_pending_async_ops(); + int pendingOps = 0; + + { + LockedAccessor_StreamCrit_t crit(stream->_criticalData); + if (crit->_hasQueue) { + pendingOps = crit->_av.get_pending_async_ops(); + } + } hipError_t e = (pendingOps > 0) ? hipErrorNotReady : hipSuccess; From 77bbf9c83214a7cd205affe69203f444443b966e Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Mon, 9 Jan 2017 20:22:43 -0600 Subject: [PATCH 051/281] Fix delete[] [ROCm/hip commit: a15d236de31dcc4f51b7cf582c6b8137cf28cd00] --- .../tests/src/runtimeApi/multiThread/hipMultiThreadDevice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/hip/tests/src/runtimeApi/multiThread/hipMultiThreadDevice.cpp b/projects/hip/tests/src/runtimeApi/multiThread/hipMultiThreadDevice.cpp index 7c83211f14..d5fc4cb20f 100644 --- a/projects/hip/tests/src/runtimeApi/multiThread/hipMultiThreadDevice.cpp +++ b/projects/hip/tests/src/runtimeApi/multiThread/hipMultiThreadDevice.cpp @@ -33,7 +33,7 @@ void createThenDestroyStreams(int iterations, int burstSize) } } - delete streams; + delete[] streams; } From 96640b45e28a7a8970a2f400ad8388e5834846e8 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Tue, 10 Jan 2017 17:54:22 +0300 Subject: [PATCH 052/281] [HIPIFY] CUdevice_attribute support up to CUDA 8.0.44 Attributes, which are not yet supported by HIP, are marked as HIP_UNSUPPORTED. [ROCm/hip commit: 7ed2b163de5a99f885cdc1a44f8bc5ac94d16f27] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 124 ++++++++++++++++----- 1 file changed, 99 insertions(+), 25 deletions(-) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index 4ea34606db..7995b3995f 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -319,31 +319,105 @@ struct cuda2hipMap { cuda2hipRename["CUdevice_attribute_enum"] = {"hipDeviceAttribute_t", CONV_TYPE, API_DRIVER}; cuda2hipRename["CUdevice_attribute"] = {"hipDeviceAttribute_t", CONV_TYPE, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_BLOCK"] = {"hipDeviceAttributeMaxThreadsPerBlock", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_X"] = {"hipDeviceAttributeMaxBlockDimX", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Y"] = {"hipDeviceAttributeMaxBlockDimY", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Z"] = {"hipDeviceAttributeMaxBlockDimZ", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_X"] = {"hipDeviceAttributeMaxGridDimX", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_Y"] = {"hipDeviceAttributeMaxGridDimY", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_Z"] = {"hipDeviceAttributeMaxGridDimZ", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK"] = {"hipDeviceAttributeMaxSharedMemoryPerBlock", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_TOTAL_CONSTANT_MEMORY"] = {"hipDeviceAttributeTotalConstantMemory", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_WARP_SIZE"] = {"hipDeviceAttributeWarpSize", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_BLOCK"] = {"hipDeviceAttributeMaxRegistersPerBlock", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_CLOCK_RATE"] = {"hipDeviceAttributeClockRate", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MEMORY_CLOCK_RATE"] = {"hipDeviceAttributeMemoryClockRate", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_GLOBAL_MEMORY_BUS_WIDTH"] = {"hipDeviceAttributeMemoryBusWidth", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_GLOBAL_MEMORY_BUS_WIDTH"] = {"hipDeviceAttributeMultiprocessorCount", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_COMPUTE_MODE"] = {"hipDeviceAttributeComputeMode", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_L2_CACHE_SIZE"] = {"hipDeviceAttributeL2CacheSize", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_MULTIPROCESSOR"] = {"hipDeviceAttributeMaxThreadsPerMultiProcessor", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR"] = {"hipDeviceAttributeComputeCapabilityMajor", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR"] = {"hipDeviceAttributeComputeCapabilityMinor", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_CONCURRENT_KERNELS"] = {"hipDeviceAttributeConcurrentKernels", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_PCI_BUS_ID"] = {"hipDeviceAttributePciBusId", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_PCI_DEVICE_ID"] = {"hipDeviceAttributePciDeviceId", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_MULTIPROCESSOR"] = {"hipDeviceAttributeMaxSharedMemoryPerMultiprocessor", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MULTI_GPU_BOARD"] = {"hipDeviceAttributeIsMultiGpuBoard", CONV_DEV, API_DRIVER}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_BLOCK"] = {"hipDeviceAttributeMaxThreadsPerBlock", CONV_DEV, API_DRIVER}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_X"] = {"hipDeviceAttributeMaxBlockDimX", CONV_DEV, API_DRIVER}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Y"] = {"hipDeviceAttributeMaxBlockDimY", CONV_DEV, API_DRIVER}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Z"] = {"hipDeviceAttributeMaxBlockDimZ", CONV_DEV, API_DRIVER}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_X"] = {"hipDeviceAttributeMaxGridDimX", CONV_DEV, API_DRIVER}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_Y"] = {"hipDeviceAttributeMaxGridDimY", CONV_DEV, API_DRIVER}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_Z"] = {"hipDeviceAttributeMaxGridDimZ", CONV_DEV, API_DRIVER}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK"] = {"hipDeviceAttributeMaxSharedMemoryPerBlock", CONV_DEV, API_DRIVER}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_SHARED_MEMORY_PER_BLOCK"] = {"hipDeviceAttributeMaxSharedMemoryPerBlock", CONV_DEV, API_DRIVER}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_TOTAL_CONSTANT_MEMORY"] = {"hipDeviceAttributeTotalConstantMemory", CONV_DEV, API_DRIVER}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_WARP_SIZE"] = {"hipDeviceAttributeWarpSize", CONV_DEV, API_DRIVER}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_BLOCK"] = {"hipDeviceAttributeMaxRegistersPerBlock", CONV_DEV, API_DRIVER}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_REGISTERS_PER_BLOCK"] = {"hipDeviceAttributeMaxRegistersPerBlock", CONV_DEV, API_DRIVER}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_CLOCK_RATE"] = {"hipDeviceAttributeClockRate", CONV_DEV, API_DRIVER}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MEMORY_CLOCK_RATE"] = {"hipDeviceAttributeMemoryClockRate", CONV_DEV, API_DRIVER}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_GLOBAL_MEMORY_BUS_WIDTH"] = {"hipDeviceAttributeMemoryBusWidth", CONV_DEV, API_DRIVER}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_COMPUTE_MODE"] = {"hipDeviceAttributeComputeMode", CONV_DEV, API_DRIVER}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_L2_CACHE_SIZE"] = {"hipDeviceAttributeL2CacheSize", CONV_DEV, API_DRIVER}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_MULTIPROCESSOR"] = {"hipDeviceAttributeMaxThreadsPerMultiProcessor", CONV_DEV, API_DRIVER}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR"] = {"hipDeviceAttributeComputeCapabilityMajor", CONV_DEV, API_DRIVER}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR"] = {"hipDeviceAttributeComputeCapabilityMinor", CONV_DEV, API_DRIVER}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_CONCURRENT_KERNELS"] = {"hipDeviceAttributeConcurrentKernels", CONV_DEV, API_DRIVER}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_PCI_BUS_ID"] = {"hipDeviceAttributePciBusId", CONV_DEV, API_DRIVER}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_PCI_DEVICE_ID"] = {"hipDeviceAttributePciDeviceId", CONV_DEV, API_DRIVER}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_MULTIPROCESSOR"] = {"hipDeviceAttributeMaxSharedMemoryPerMultiprocessor", CONV_DEV, API_DRIVER}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MULTI_GPU_BOARD"] = {"hipDeviceAttributeIsMultiGpuBoard", CONV_DEV, API_DRIVER}; + // unsupported yet by HIP + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_PITCH"] = {"hipDeviceAttributeMaxPitch", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_ASYNC_ENGINE_COUNT"] = {"hipDeviceAttributeAsyncEngineCount", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_GPU_OVERLAP"] = {"hipDeviceAttributeAsyncEngineCount", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT"] = {"hipDeviceAttributeMultiprocessorCount", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_KERNEL_EXEC_TIMEOUT"] = {"hipDeviceAttributeKernelExecTimeout", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_INTEGRATED"] = {"hipDeviceAttributeIntegrated", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_CAN_MAP_HOST_MEMORY"] = {"hipDeviceAttributeCanMapHostMemory", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_WIDTH"] = {"hipDeviceAttributeMaxTexture1DWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_WIDTH"] = {"hipDeviceAttributeMaxTexture2DWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_HEIGHT"] = {"hipDeviceAttributeMaxTexture2DHeight", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_WIDTH"] = {"hipDeviceAttributeMaxTexture3DWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_HEIGHT"] = {"hipDeviceAttributeMaxTexture3DHeight", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_DEPTH"] = {"hipDeviceAttributeMaxTexture3DDepth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_WIDTH"] = {"hipDeviceAttributeMaxTexture2DLayeredWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_HEIGHT"] = {"hipDeviceAttributeMaxTexture2DLayeredHeight", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_LAYERS"] = {"hipDeviceAttributeMaxTexture2DLayeredLayers", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_ARRAY_WIDTH"] = {"hipDeviceAttributeMaxTexture2DLayeredWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_ARRAY_HEIGHT"] = {"hipDeviceAttributeMaxTexture2DLayeredHeight", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_ARRAY_NUMSLICES"] = {"hipDeviceAttributeMaxTexture2DLayeredLayers", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_SURFACE_ALIGNMENT"] = {"hipDeviceAttributeSurfaceAlignment", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_ECC_ENABLED"] = {"hipDeviceAttributeEccEnabled", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_TCC_DRIVER"] = {"hipDeviceAttributeTccDriver", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_UNIFIED_ADDRESSING"] = {"hipDeviceAttributeUnifiedAddressing", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LAYERED_WIDTH"] = {"hipDeviceAttributeMaxTexture1DLayeredWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LAYERED_LAYERS"] = {"hipDeviceAttributeMaxTexture1DLayeredLayers", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_GATHER_WIDTH"] = {"hipDeviceAttributeMaxTexture2DGatherWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_GATHER_HEIGHT"] = {"hipDeviceAttributeMaxTexture2DGatherHeight", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_WIDTH_ALTERNATE"] = {"hipDeviceAttributeMaxTexture3DWidthAlternate", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_HEIGHT_ALTERNATE"] = {"hipDeviceAttributeMaxTexture3DHeightAlternate", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_DEPTH_ALTERNATE"] = {"hipDeviceAttributeMaxTexture3DDepthAlternate", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_PCI_DOMAIN_ID"] = {"hipDeviceAttributePciDomainId", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_TEXTURE_PITCH_ALIGNMENT"] = {"hipDeviceAttributeTexturePitchAlignment", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURECUBEMAP_WIDTH"] = {"hipDeviceAttributeMaxTextureCubemapWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURECUBEMAP_LAYERED_WIDTH"] = {"hipDeviceAttributeMaxTextureCubemapLayeredWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURECUBEMAP_LAYERED_LAYERS"] = {"hipDeviceAttributeMaxTextureCubemapLayeredLayers", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE1D_WIDTH"] = {"hipDeviceAttributeMaxSurface1DWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_WIDTH"] = {"hipDeviceAttributeMaxSurface2DWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_HEIGHT"] = {"hipDeviceAttributeMaxSurface2DHeight", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE3D_WIDTH"] = {"hipDeviceAttributeMaxSurface3DWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE3D_HEIGHT"] = {"hipDeviceAttributeMaxSurface3DHeight", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE3D_DEPTH"] = {"hipDeviceAttributeMaxSurface3DDepth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE1D_LAYERED_WIDTH"] = {"hipDeviceAttributeMaxSurface1DLayeredWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE1D_LAYERED_LAYERS"] = {"hipDeviceAttributeMaxSurface1DLayeredLayers", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_WIDTH"] = {"hipDeviceAttributeMaxSurface2DLayeredWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_HEIGHT"] = {"hipDeviceAttributeMaxSurface2DLayeredHeight", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_LAYERS"] = {"hipDeviceAttributeMaxSurface2DLayeredLayers", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_WIDTH"] = {"hipDeviceAttributeMaxSurfaceCudemapWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_LAYERED_WIDTH"] = {"hipDeviceAttributeMaxSurfaceCudemapLayeredWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_LAYERED_LAYERS"] = {"hipDeviceAttributeMaxSurfaceCudemapLayeredLayers", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LINEAR_WIDTH"] = {"hipDeviceAttributeMaxTexture1DLinearWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_WIDTH"] = {"hipDeviceAttributeMaxTexture2DLinearWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_HEIGHT"] = {"hipDeviceAttributeMaxTexture2DLinearHeight", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_PITCH"] = {"hipDeviceAttributeMaxTexture2DLinearPitch", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_MIPMAPPED_WIDTH"] = {"hipDeviceAttributeMaxTexture2DMipmappedWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_MIPMAPPED_HEIGHT"] = {"hipDeviceAttributeMaxTexture2DMipmappedHeight", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_MIPMAPPED_WIDTH"] = {"hipDeviceAttributeMaxTexture1DMipmappedWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_STREAM_PRIORITIES_SUPPORTED"] = {"hipDeviceAttributeStreamPrioritiesSupported", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_GLOBAL_L1_CACHE_SUPPORTED"] = {"hipDeviceAttributeGlobalL1CacheSupported", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_LOCAL_L1_CACHE_SUPPORTED"] = {"hipDeviceAttributeLocalL1CacheSupported", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_MULTIPROCESSOR"] = {"hipDeviceAttributeMaxRegistersPerMultiprocessor", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MANAGED_MEMORY"] = {"hipDeviceAttributeManagedMemory", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MULTI_GPU_BOARD_GROUP_ID"] = {"hipDeviceAttributeMultiGpuBoardGroupId", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX"] = {"hipDeviceAttributeMax", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + // deprecated, do not use + // cuda2hipRename["CU_DEVICE_ATTRIBUTE_CAN_TEX2D_GATHER"] = {"hipDeviceAttributeCanTex2DGather", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + // unsupported yet by HIP [CUDA 8.0.44] + cuda2hipRename["CU_DEVICE_ATTRIBUTE_HOST_NATIVE_ATOMIC_SUPPORTED"] = {"hipDeviceAttributeHostNativeAtomicSupported", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_SINGLE_TO_DOUBLE_PRECISION_PERF_RATIO"] = {"hipDeviceAttributeSingleToDoublePrecisionPerfRatio", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS"] = {"hipDeviceAttributePageableMemoryAccess", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS"] = {"hipDeviceAttributeConcurrentManagedAccess", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_COMPUTE_PREEMPTION_SUPPORTED"] = {"hipDeviceAttributeComputePreemptionSupported", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_CAN_USE_HOST_POINTER_FOR_REGISTERED_MEM"] = {"hipDeviceAttributeCanUseHostPointerForRegisteredMem", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; cuda2hipRename["CUdevprop_st"] = {"hipDeviceProp_t", CONV_TYPE, API_DRIVER}; cuda2hipRename["CUdevprop"] = {"hipDeviceProp_t", CONV_TYPE, API_DRIVER}; From 6c943240bee78d8d71ce08cdefb03142eafea57b Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Tue, 10 Jan 2017 19:29:33 +0300 Subject: [PATCH 053/281] [HIPIFY] cudaDeviceAttr (RT API) support up to CUDA 8.0.44 Attributes, which are not yet supported by HIP, are marked as HIP_UNSUPPORTED. [ROCm/hip commit: 3a99536ed510f43a0b1131ae5cca187fc3a84ea2] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 125 ++++++++++++++++----- 1 file changed, 97 insertions(+), 28 deletions(-) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index 7995b3995f..2f6d731c96 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -347,7 +347,9 @@ struct cuda2hipMap { cuda2hipRename["CU_DEVICE_ATTRIBUTE_MULTI_GPU_BOARD"] = {"hipDeviceAttributeIsMultiGpuBoard", CONV_DEV, API_DRIVER}; // unsupported yet by HIP cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_PITCH"] = {"hipDeviceAttributeMaxPitch", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_TEXTURE_ALIGNMENT"] = {"hipDeviceAttributeTextureAlignment", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; cuda2hipRename["CU_DEVICE_ATTRIBUTE_ASYNC_ENGINE_COUNT"] = {"hipDeviceAttributeAsyncEngineCount", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + // Deprecated. Use instead CU_DEVICE_ATTRIBUTE_ASYNC_ENGINE_COUNT cuda2hipRename["CU_DEVICE_ATTRIBUTE_GPU_OVERLAP"] = {"hipDeviceAttributeAsyncEngineCount", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; cuda2hipRename["CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT"] = {"hipDeviceAttributeMultiprocessorCount", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; cuda2hipRename["CU_DEVICE_ATTRIBUTE_KERNEL_EXEC_TIMEOUT"] = {"hipDeviceAttributeKernelExecTimeout", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; @@ -392,9 +394,9 @@ struct cuda2hipMap { cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_WIDTH"] = {"hipDeviceAttributeMaxSurface2DLayeredWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_HEIGHT"] = {"hipDeviceAttributeMaxSurface2DLayeredHeight", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_LAYERS"] = {"hipDeviceAttributeMaxSurface2DLayeredLayers", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_WIDTH"] = {"hipDeviceAttributeMaxSurfaceCudemapWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_LAYERED_WIDTH"] = {"hipDeviceAttributeMaxSurfaceCudemapLayeredWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_LAYERED_LAYERS"] = {"hipDeviceAttributeMaxSurfaceCudemapLayeredLayers", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_WIDTH"] = {"hipDeviceAttributeMaxSurfaceCubemapWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_LAYERED_WIDTH"] = {"hipDeviceAttributeMaxSurfaceCubemapLayeredWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_LAYERED_LAYERS"] = {"hipDeviceAttributeMaxSurfaceCubemapLayeredLayers", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LINEAR_WIDTH"] = {"hipDeviceAttributeMaxTexture1DLinearWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_WIDTH"] = {"hipDeviceAttributeMaxTexture2DLinearWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_HEIGHT"] = {"hipDeviceAttributeMaxTexture2DLinearHeight", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; @@ -703,31 +705,98 @@ struct cuda2hipMap { cuda2hipRename["cudaDeviceAttr"] = {"hipDeviceAttribute_t", CONV_TYPE, API_RUNTIME}; cuda2hipRename["cudaDeviceGetAttribute"] = {"hipDeviceGetAttribute", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrMaxThreadsPerBlock"] = {"hipDeviceAttributeMaxThreadsPerBlock", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrMaxBlockDimX"] = {"hipDeviceAttributeMaxBlockDimX", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrMaxBlockDimY"] = {"hipDeviceAttributeMaxBlockDimY", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrMaxBlockDimZ"] = {"hipDeviceAttributeMaxBlockDimZ", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrMaxGridDimX"] = {"hipDeviceAttributeMaxGridDimX", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrMaxGridDimY"] = {"hipDeviceAttributeMaxGridDimY", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrMaxGridDimZ"] = {"hipDeviceAttributeMaxGridDimZ", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrMaxSharedMemoryPerBlock"] = {"hipDeviceAttributeMaxSharedMemoryPerBlock", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrTotalConstantMemory"] = {"hipDeviceAttributeTotalConstantMemory", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrWarpSize"] = {"hipDeviceAttributeWarpSize", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrMaxRegistersPerBlock"] = {"hipDeviceAttributeMaxRegistersPerBlock", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrClockRate"] = {"hipDeviceAttributeClockRate", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrMemoryClockRate"] = {"hipDeviceAttributeMemoryClockRate", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrGlobalMemoryBusWidth"] = {"hipDeviceAttributeMemoryBusWidth", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrMultiProcessorCount"] = {"hipDeviceAttributeMultiprocessorCount", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrComputeMode"] = {"hipDeviceAttributeComputeMode", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrL2CacheSize"] = {"hipDeviceAttributeL2CacheSize", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrMaxThreadsPerMultiProcessor"] = {"hipDeviceAttributeMaxThreadsPerMultiProcessor", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrComputeCapabilityMajor"] = {"hipDeviceAttributeComputeCapabilityMajor", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrComputeCapabilityMinor"] = {"hipDeviceAttributeComputeCapabilityMinor", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrConcurrentKernels"] = {"hipDeviceAttributeConcurrentKernels", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrPciBusId"] = {"hipDeviceAttributePciBusId", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrPciDeviceId"] = {"hipDeviceAttributePciDeviceId", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrMaxSharedMemoryPerMultiprocessor"] = {"hipDeviceAttributeMaxSharedMemoryPerMultiprocessor", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrIsMultiGpuBoard"] = {"hipDeviceAttributeIsMultiGpuBoard", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDevAttrMaxThreadsPerBlock"] = {"hipDeviceAttributeMaxThreadsPerBlock", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDevAttrMaxBlockDimX"] = {"hipDeviceAttributeMaxBlockDimX", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDevAttrMaxBlockDimY"] = {"hipDeviceAttributeMaxBlockDimY", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDevAttrMaxBlockDimZ"] = {"hipDeviceAttributeMaxBlockDimZ", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDevAttrMaxGridDimX"] = {"hipDeviceAttributeMaxGridDimX", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDevAttrMaxGridDimY"] = {"hipDeviceAttributeMaxGridDimY", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDevAttrMaxGridDimZ"] = {"hipDeviceAttributeMaxGridDimZ", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDevAttrMaxSharedMemoryPerBlock"] = {"hipDeviceAttributeMaxSharedMemoryPerBlock", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDevAttrTotalConstantMemory"] = {"hipDeviceAttributeTotalConstantMemory", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDevAttrWarpSize"] = {"hipDeviceAttributeWarpSize", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDevAttrMaxRegistersPerBlock"] = {"hipDeviceAttributeMaxRegistersPerBlock", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDevAttrClockRate"] = {"hipDeviceAttributeClockRate", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDevAttrMemoryClockRate"] = {"hipDeviceAttributeMemoryClockRate", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDevAttrGlobalMemoryBusWidth"] = {"hipDeviceAttributeMemoryBusWidth", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDevAttrMultiProcessorCount"] = {"hipDeviceAttributeMultiprocessorCount", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDevAttrComputeMode"] = {"hipDeviceAttributeComputeMode", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDevAttrL2CacheSize"] = {"hipDeviceAttributeL2CacheSize", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDevAttrMaxThreadsPerMultiProcessor"] = {"hipDeviceAttributeMaxThreadsPerMultiProcessor", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDevAttrComputeCapabilityMajor"] = {"hipDeviceAttributeComputeCapabilityMajor", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDevAttrComputeCapabilityMinor"] = {"hipDeviceAttributeComputeCapabilityMinor", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDevAttrConcurrentKernels"] = {"hipDeviceAttributeConcurrentKernels", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDevAttrPciBusId"] = {"hipDeviceAttributePciBusId", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDevAttrPciDeviceId"] = {"hipDeviceAttributePciDeviceId", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDevAttrMaxSharedMemoryPerMultiprocessor"] = {"hipDeviceAttributeMaxSharedMemoryPerMultiprocessor", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDevAttrIsMultiGpuBoard"] = {"hipDeviceAttributeIsMultiGpuBoard", CONV_DEV, API_RUNTIME}; + // unsupported yet by HIP + cuda2hipRename["cudaDevAttrMaxPitch"] = {"hipDeviceAttributeMaxPitch", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrTextureAlignment"] = {"hipDeviceAttributeTextureAlignment", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + // Is not deprecated as CUDA Driver's API analogue CU_DEVICE_ATTRIBUTE_GPU_OVERLAP + cuda2hipRename["cudaDevAttrGpuOverlap"] = {"hipDeviceAttributeGpuOverlap", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrKernelExecTimeout"] = {"hipDeviceAttributeKernelExecTimeout", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrIntegrated"] = {"hipDeviceAttributeIntegrated", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrCanMapHostMemory"] = {"hipDeviceAttributeCanMapHostMemory", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrMaxTexture1DWidth"] = {"hipDeviceAttributeMaxTexture1DWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrMaxTexture2DWidth"] = {"hipDeviceAttributeMaxTexture2DWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrMaxTexture2DHeight"] = {"hipDeviceAttributeMaxTexture2DHeight", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrMaxTexture3DWidth"] = {"hipDeviceAttributeMaxTexture3DWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrMaxTexture3DHeight"] = {"hipDeviceAttributeMaxTexture3DHeight", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrMaxTexture3DDepth"] = {"hipDeviceAttributeMaxTexture3DDepth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrMaxTexture2DLayeredWidth"] = {"hipDeviceAttributeMaxTexture2DLayeredWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrMaxTexture2DLayeredHeight"] = {"hipDeviceAttributeMaxTexture2DLayeredHeight", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrMaxTexture2DLayeredLayers"] = {"hipDeviceAttributeMaxTexture2DLayeredLayers", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrSurfaceAlignment"] = {"hipDeviceAttributeSurfaceAlignment", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrEccEnabled"] = {"hipDeviceAttributeEccEnabled", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrTccDriver"] = {"hipDeviceAttributeTccDriver", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrUnifiedAddressing"] = {"hipDeviceAttributeUnifiedAddressing", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrMaxTexture1DLayeredWidth"] = {"hipDeviceAttributeMaxTexture1DLayeredWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrMaxTexture1DLayeredLayers"] = {"hipDeviceAttributeMaxTexture1DLayeredLayers", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrMaxTexture2DGatherWidth"] = {"hipDeviceAttributeMaxTexture2DGatherWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrMaxTexture2DGatherHeight"] = {"hipDeviceAttributeMaxTexture2DGatherHeight", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrMaxTexture3DWidthAlt"] = {"hipDeviceAttributeMaxTexture3DWidthAlternate", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrMaxTexture3DHeightAlt"] = {"hipDeviceAttributeMaxTexture3DHeightAlternate", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrMaxTexture3DDepthAlt"] = {"hipDeviceAttributeMaxTexture3DDepthAlternate", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrPciDomainId"] = {"hipDeviceAttributePciDomainId", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrTexturePitchAlignment"] = {"hipDeviceAttributeTexturePitchAlignment", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrMaxTextureCubemapWidth"] = {"hipDeviceAttributeMaxTextureCubemapWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrMaxTextureCubemapLayeredWidth"] = {"hipDeviceAttributeMaxTextureCubemapLayeredWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrMaxTextureCubemapLayeredLayers"] = {"hipDeviceAttributeMaxTextureCubemapLayeredLayers", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrMaxSurface1DWidth"] = {"hipDeviceAttributeMaxSurface1DWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrMaxSurface2DWidth"] = {"hipDeviceAttributeMaxSurface2DWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrMaxSurface2DHeight"] = {"hipDeviceAttributeMaxSurface2DHeight", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrMaxSurface3DWidth"] = {"hipDeviceAttributeMaxSurface3DWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrMaxSurface3DHeight"] = {"hipDeviceAttributeMaxSurface3DHeight", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrMaxSurface3DDepth"] = {"hipDeviceAttributeMaxSurface3DDepth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrMaxSurface1DLayeredWidth"] = {"hipDeviceAttributeMaxSurface1DLayeredWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrMaxSurface1DLayeredLayers"] = {"hipDeviceAttributeMaxSurface1DLayeredLayers", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrMaxSurface2DLayeredWidth"] = {"hipDeviceAttributeMaxSurface2DLayeredWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrMaxSurface2DLayeredHeight"] = {"hipDeviceAttributeMaxSurface2DLayeredHeight", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrMaxSurface2DLayeredLayers"] = {"hipDeviceAttributeMaxSurface2DLayeredLayers", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrMaxSurfaceCubemapWidth"] = {"hipDeviceAttributeMaxSurfaceCubemapWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrMaxSurfaceCubemapLayeredWidth"] = {"hipDeviceAttributeMaxSurfaceCubemapLayeredWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrMaxSurfaceCubemapLayeredLayers"] = {"hipDeviceAttributeMaxSurfaceCubemapLayeredLayers", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrMaxTexture1DLinearWidth"] = {"hipDeviceAttributeMaxTexture1DLinearWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrMaxTexture2DLinearWidth"] = {"hipDeviceAttributeMaxTexture2DLinearWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrMaxTexture2DLinearHeight"] = {"hipDeviceAttributeMaxTexture2DLinearHeight", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrMaxTexture2DLinearPitch"] = {"hipDeviceAttributeMaxTexture2DLinearPitch", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrMaxTexture2DMipmappedWidth"] = {"hipDeviceAttributeMaxTexture2DMipmappedWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrMaxTexture2DMipmappedHeight"] = {"hipDeviceAttributeMaxTexture2DMipmappedHeight", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrMaxTexture1DMipmappedWidth"] = {"hipDeviceAttributeMaxTexture1DMipmappedWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrStreamPrioritiesSupported"] = {"hipDeviceAttributeStreamPrioritiesSupported", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrGlobalL1CacheSupported"] = {"hipDeviceAttributeGlobalL1CacheSupported", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrLocalL1CacheSupported"] = {"hipDeviceAttributeLocalL1CacheSupported", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrMaxRegistersPerMultiprocessor"] = {"hipDeviceAttributeMaxRegistersPerMultiprocessor", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrManagedMemory"] = {"hipDeviceAttributeManagedMemory", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrMultiGpuBoardGroupID"] = {"hipDeviceAttributeMultiGpuBoardGroupID", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + // unsupported yet by HIP [CUDA 8.0.44] + cuda2hipRename["cudaDevAttrHostNativeAtomicSupported"] = {"hipDeviceAttributeHostNativeAtomicSupported", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrSingleToDoublePrecisionPerfRatio"] = {"hipDeviceAttributeSingleToDoublePrecisionPerfRatio", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrPageableMemoryAccess"] = {"hipDeviceAttributePageableMemoryAccess", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrConcurrentManagedAccess"] = {"hipDeviceAttributeConcurrentManagedAccess", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrComputePreemptionSupported"] = {"hipDeviceAttributeComputePreemptionSupported", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrCanUseHostPointerForRegisteredMem"] = {"hipDeviceAttributeCanUseHostPointerForRegisteredMem", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // Pointer Attributes cuda2hipRename["cudaPointerAttributes"] = {"hipPointerAttribute_t", CONV_TYPE, API_RUNTIME}; From 8e219d3624a5f48d8afb292b968fa633faa8f0a5 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Tue, 10 Jan 2017 20:24:27 +0300 Subject: [PATCH 054/281] [HIPIFY] cudaDataType_t and libraryPropertyType_t support (CUDA 8.0.44 only) All are marked as HIP_UNSUPPORTED. IMPORTANT: 1. libraryPropertyType_t has no cuda prefix. => TO_DO: new matcher is needed. 2. all libraries (cublas, cufft, cusolver, cusparse, nvgraph) have started to use these types (since 8.0). [ROCm/hip commit: 9a0780001bfee903ff91ba464c23188faccffde7] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index 2f6d731c96..938c980684 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -585,6 +585,35 @@ struct cuda2hipMap { cuda2hipRename["cuProfilerStop"] = {"hipProfilerStop", CONV_OTHER, API_DRIVER}; /////////////////////////////// CUDA RT API /////////////////////////////// + // Data types + // unsupported yet by HIP [CUDA 8.0.44] + cuda2hipRename["cudaDataType_t"] = {"hipDataType_t", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDataType"] = {"hipDataType_t", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["CUDA_R_16F"] = {"hipR16F", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["CUDA_C_16F"] = {"hipC16F", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["CUDA_R_32F"] = {"hipR32F", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["CUDA_C_32F"] = {"hipC32F", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["CUDA_R_64F"] = {"hipR64F", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["CUDA_C_64F"] = {"hipC64F", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["CUDA_R_8I"] = {"hipR8I", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["CUDA_C_8I"] = {"hipC8I", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["CUDA_R_8U"] = {"hipR8U", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["CUDA_C_8U"] = {"hipC8U", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["CUDA_R_32I"] = {"hipR32I", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["CUDA_C_32I"] = {"hipC32I", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["CUDA_R_32U"] = {"hipR32U", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["CUDA_C_32U"] = {"hipC32U", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; + + // Library property types + // IMPORTANT: no cuda prefix + // TO_DO: new matcher is needed + // unsupported yet by HIP [CUDA 8.0.44] + cuda2hipRename["libraryPropertyType_t"] = {"hipLibraryPropertyType_t", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["libraryPropertyType"] = {"hipLibraryPropertyType_t", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["MAJOR_VERSION"] = {"hipLibraryMajorVersion", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["MINOR_VERSION"] = {"hipLibraryMinorVersion", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["PATCH_LEVEL"] = {"hipLibraryPatchVersion", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; + // Error API cuda2hipRename["cudaGetLastError"] = {"hipGetLastError", CONV_ERR, API_RUNTIME}; cuda2hipRename["cudaPeekAtLastError"] = {"hipPeekAtLastError", CONV_ERR, API_RUNTIME}; From 418619469274ebb7e17bc25d70e8784dd7cdb3f1 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Wed, 11 Jan 2017 15:06:25 -0600 Subject: [PATCH 055/281] Added proper device data types Change-Id: I42029635ff68c3c13a764a3eda6447e6c77878c6 [ROCm/hip commit: 39910029a6c448b67e0cb1a4fc1a2d5c0878eddd] --- .../include/hip/hcc_detail/device_functions.h | 11 +- projects/hip/include/hip/hcc_detail/hip_ldg.h | 5 +- .../hip/include/hip/hcc_detail/hip_runtime.h | 4 +- .../include/hip/hcc_detail/hip_vector_types.h | 4295 +++++++++++++++-- projects/hip/src/device_util.cpp | 455 +- projects/hip/src/hip_ldg.cpp | 12 +- .../hip/tests/src/deviceLib/hip_test_ldg.cpp | 2 +- 7 files changed, 4010 insertions(+), 774 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/device_functions.h b/projects/hip/include/hip/hcc_detail/device_functions.h index 8fa870664f..e2b061c640 100644 --- a/projects/hip/include/hip/hcc_detail/device_functions.h +++ b/projects/hip/include/hip/hcc_detail/device_functions.h @@ -20,13 +20,18 @@ THE SOFTWARE. #ifndef HIP_HCC_DETAIL_DEVICE_FUNCTIONS_H #define HIP_HCC_DETAIL_DEVICE_FUNCTIONS_H -#include "hip_runtime.h" +#include +#include __device__ float __int_as_float (int x); __device__ double __hiloint2double (int hi, int lo); -extern __HIP_DEVICE__ double __longlong_as_double(long long int x); -extern __HIP_DEVICE__ long long int __double_as_longlong(double x); +__device__ char4 __hip_hc_add8pk(char4, char4); +__device__ char4 __hip_hc_sub8pk(char4, char4); +__device__ char4 __hip_hc_mul8pk(char4, char4); + +extern __device__ double __longlong_as_double(long long int x); +extern __device__ long long int __double_as_longlong(double x); #endif diff --git a/projects/hip/include/hip/hcc_detail/hip_ldg.h b/projects/hip/include/hip/hcc_detail/hip_ldg.h index 7dd6451749..65292951f0 100644 --- a/projects/hip/include/hip/hcc_detail/hip_ldg.h +++ b/projects/hip/include/hip/hcc_detail/hip_ldg.h @@ -25,8 +25,8 @@ THE SOFTWARE. #if __HCC__ #if __hcc_workweek__ >= 16164 -#include "hip/hip_vector_types.h" -#include "hip/hcc_detail/host_defines.h" +#include "hip_vector_types.h" +#include "host_defines.h" __device__ char __ldg(const char* ); @@ -75,4 +75,3 @@ __device__ double2 __ldg(const double2* ); #endif // __HCC__ #endif // HIP_LDG_H - diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime.h b/projects/hip/include/hip/hcc_detail/hip_runtime.h index 78accc0c5b..f747b446d7 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime.h @@ -46,6 +46,7 @@ THE SOFTWARE. #define CUDA_SUCCESS hipSuccess #include + //#include "hip/hcc_detail/hip_hcc.h" //--- // Remainder of this file only compiles with HCC @@ -815,9 +816,6 @@ extern "C" __device__ void* __hip_hc_free(void *ptr); //extern "C" __device__ void* malloc(size_t size); //extern "C" __device__ void* free(void *ptr); -extern "C" __device__ char4 __hip_hc_add8pk(char4, char4); -extern "C" __device__ char4 __hip_hc_sub8pk(char4, char4); -extern "C" __device__ char4 __hip_hc_mul8pk(char4, char4); #define __syncthreads() hc_barrier(CLK_LOCAL_MEM_FENCE) diff --git a/projects/hip/include/hip/hcc_detail/hip_vector_types.h b/projects/hip/include/hip/hcc_detail/hip_vector_types.h index 7c48985996..812bd272d0 100644 --- a/projects/hip/include/hip/hcc_detail/hip_vector_types.h +++ b/projects/hip/include/hip/hcc_detail/hip_vector_types.h @@ -32,402 +32,4051 @@ THE SOFTWARE. #error("This version of HIP requires a newer version of HCC."); #endif -#if 0 -#include +#include "host_defines.h" -using namespace hc::short_vector; +#define MAKE_DEFAULT_CONSTRUCTOR_ONE_COMPONENT(type) \ +__device__ __host__ type() {} \ +__device__ __host__ type(type& val) : x(val.x) { } \ +__device__ __host__ type(const type& val) : x(val.x) { } + +#define MAKE_DEFAULT_CONSTRUCTOR_TWO_COMPONENT(type) \ +__device__ __host__ type() {} \ +__device__ __host__ type(type& val) : x(val.x), y(val.y) { } \ +__device__ __host__ type(const type& val) : x(val.x), y(val.y) { } + +#define MAKE_DEFAULT_CONSTRUCTOR_THREE_COMPONENT(type) \ +__device__ __host__ type() {} \ +__device__ __host__ type(type& val) : x(val.x), y(val.y), z(val.z) { } \ +__device__ __host__ type(const type& val) : x(val.x), y(val.y), z(val.z) { } + +#define MAKE_DEFAULT_CONSTRUCTOR_FOUR_COMPONENT(type) \ +__device__ __host__ type() {} \ +__device__ __host__ type(type& val) : x(val.x), y(val.y), z(val.z), w(val.w) { } \ +__device__ __host__ type(const type& val) : x(val.x), y(val.y), z(val.z), w(val.w) { } -//-- Signed -// Define char vector types -typedef hc::short_vector::char1 char1; -typedef hc::short_vector::char2 char2; -typedef hc::short_vector::char3 char3; -typedef hc::short_vector::char4 char4; +#define MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(type, type1) \ +__device__ __host__ type(type1 val) : x(val) {} \ -// Define short vector types -typedef hc::short_vector::short1 short1; -typedef hc::short_vector::short2 short2; -typedef hc::short_vector::short3 short3; -typedef hc::short_vector::short4 short4; +#define MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(type, type1) \ +__device__ __host__ type(type1 val) : x(val), y(val) {} \ +__device__ __host__ type(type1 val1, type1 val2) : x(val1), y(val2) {} -// Define int vector types -typedef hc::short_vector::int1 int1; -typedef hc::short_vector::int2 int2; -typedef hc::short_vector::int3 int3; -typedef hc::short_vector::int4 int4; +#define MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(type, type1) \ +__device__ __host__ type(type1 val) : x(val), y(val), z(val) {} \ +__device__ __host__ type(type1 val1, type1 val2, type1 val3) : x(val1), y(val2), z(val3) {} -// Define long vector types -typedef hc::short_vector::long1 long1; -typedef hc::short_vector::long2 long2; -typedef hc::short_vector::long3 long3; -typedef hc::short_vector::long4 long4; +#define MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(type, type1) \ +__device__ __host__ type(type1 val) : x(val), y(val), z(val), w(val) {} \ +__device__ __host__ type(type1 val1, type1 val2, type1 val3, type1 val4) : x(val1), y(val2), z(val3), w(val4) {} -// Define longlong vector types -typedef hc::short_vector::longlong1 longlong1; -typedef hc::short_vector::longlong2 longlong2; -typedef hc::short_vector::longlong3 longlong3; -typedef hc::short_vector::longlong4 longlong4; +struct uchar1 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_ONE_COMPONENT(uchar1) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(uchar1, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(uchar1, signed char) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(uchar1, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(uchar1, signed short) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(uchar1, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(uchar1, signed int) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(uchar1, float) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(uchar1, double) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(uchar1, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(uchar1, signed long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(uchar1, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(uchar1, signed long long) + #endif + unsigned char x; -//-- Unsigned -// Define uchar vector types -typedef hc::short_vector::uchar1 uchar1; -typedef hc::short_vector::uchar2 uchar2; -typedef hc::short_vector::uchar3 uchar3; -typedef hc::short_vector::uchar4 uchar4; +} __attribute__((aligned(1))); -// Define ushort vector types -typedef hc::short_vector::ushort1 ushort1; -typedef hc::short_vector::ushort2 ushort2; -typedef hc::short_vector::ushort3 ushort3; -typedef hc::short_vector::ushort4 ushort4; +struct uchar2 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_TWO_COMPONENT(uchar2) -// Define uint vector types -typedef hc::short_vector::uint1 uint1; -typedef hc::short_vector::uint2 uint2; -typedef hc::short_vector::uint3 uint3; -typedef hc::short_vector::uint4 uint4; - -// Define ulong vector types -typedef hc::short_vector::ulong1 ulong1; -typedef hc::short_vector::ulong2 ulong2; -typedef hc::short_vector::ulong3 ulong3; -typedef hc::short_vector::ulong4 ulong4; - -// Define ulonglong vector types -typedef hc::short_vector::ulonglong1 ulonglong1; -typedef hc::short_vector::ulonglong2 ulonglong2; -typedef hc::short_vector::ulonglong3 ulonglong3; -typedef hc::short_vector::ulonglong4 ulonglong4; - - -//-- Floating point -// Define float vector types -typedef hc::short_vector::float1 float1; -typedef hc::short_vector::float2 float2; -typedef hc::short_vector::float3 float3; -typedef hc::short_vector::float4 float4; - -// Define double vector types -typedef hc::short_vector::double1 double1; -typedef hc::short_vector::double2 double2; -typedef hc::short_vector::double3 double3; -typedef hc::short_vector::double4 double4; - -#else - -#define __hip_align(name, val, data) \ - __attribute__((aligned(val))) name \ - { data } - -struct __hip_align(char1, 1, signed char x;); -struct __hip_align(uchar1, 1, unsigned char x;); - -struct __hip_align(char2, 2, signed char x; signed char y;); -struct __hip_align(uchar2, 2, unsigned char x; unsigned char y;); - -struct char3 -{ - signed char x, y, z; -}; - -struct uchar3 -{ - unsigned char x, y, z; -}; - -struct char4 -{ - union { - signed char x, y, z, w; - unsigned int val; + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(uchar2, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(uchar2, signed char) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(uchar2, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(uchar2, signed short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(uchar2, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(uchar2, signed int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(uchar2, float) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(uchar2, double) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(uchar2, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(uchar2, signed long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(uchar2, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(uchar2, signed long long) + #endif + union { + struct { + unsigned char x, y; }; + unsigned short a; + }; +} __attribute__((aligned(2))); + +struct uchar3 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_THREE_COMPONENT(uchar3) + + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(uchar3, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(uchar3, signed char) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(uchar3, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(uchar3, signed short) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(uchar3, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(uchar3, signed int) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(uchar3, float) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(uchar3, double) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(uchar3, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(uchar3, signed long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(uchar3, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(uchar3, signed long long) + #endif + unsigned char x, y, z; }; -struct uchar4 -{ - union { - unsigned char x, y, z, w; - unsigned int val; +struct uchar4 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_FOUR_COMPONENT(uchar4) + + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(uchar4, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(uchar4, signed char) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(uchar4, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(uchar4, signed short) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(uchar4, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(uchar4, signed int) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(uchar4, float) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(uchar4, double) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(uchar4, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(uchar4, signed long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(uchar4, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(uchar4, signed long long) + #endif + union { + struct { + unsigned char x, y, z, w; }; + unsigned int a; + }; +} __attribute__((aligned(4))); + + +struct char1 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_ONE_COMPONENT(char1) + + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(char1, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(char1, signed char) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(char1, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(char1, signed short) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(char1, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(char1, signed int) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(char1, float) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(char1, double) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(char1, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(char1, signed long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(char1, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(char1, signed long long) + #endif + signed char x; +} __attribute__((aligned(1))); + +struct char2 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_TWO_COMPONENT(char2) + + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(char2, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(char2, signed char) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(char2, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(char2, signed short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(char2, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(char2, signed int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(char2, float) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(char2, double) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(char2, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(char2, signed long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(char2, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(char2, signed long long) + #endif + union { + struct { + signed char x, y; + }; + unsigned short a; + }; +} __attribute__((aligned(2))); + +struct char3 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_THREE_COMPONENT(char3) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(char3, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(char3, signed char) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(char3, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(char3, signed short) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(char3, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(char3, signed int) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(char3, float) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(char3, double) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(char3, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(char3, signed long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(char3, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(char3, signed long long) + #endif + signed char x, y, z; }; -//struct __hip_align(char4, 4, signed char x; signed char y; signed char z; signed char w;); -//struct __hip_align(uchar4, 4, unsigned char x; unsigned char y; unsigned char z; unsigned char w;); +struct char4 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_FOUR_COMPONENT(char4) -struct __hip_align(short1, 2, signed short x;); -struct __hip_align(ushort1, 2, unsigned short x;); + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(char4, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(char4, signed char) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(char4, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(char4, signed short) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(char4, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(char4, signed int) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(char4, float) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(char4, double) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(char4, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(char4, signed long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(char4, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(char4, signed long long) + #endif + union { + struct { + signed char x, y, z, w; + }; + unsigned int a; + }; +} __attribute__((aligned(4))); -struct __hip_align(short2, 4, signed short x; signed short y;); -struct __hip_align(ushort2, 4, unsigned short x; unsigned short y;); -struct short3 -{ - signed short x, y, z; + +struct ushort1 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_ONE_COMPONENT(ushort1) + + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ushort1, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ushort1, signed char) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ushort1, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ushort1, signed short) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ushort1, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ushort1, signed int) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ushort1, float) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ushort1, double) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ushort1, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ushort1, signed long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ushort1, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ushort1, signed long long) + #endif + unsigned short x; +} __attribute__((aligned(2))); + +struct ushort2 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_TWO_COMPONENT(ushort2) + + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ushort2, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ushort2, signed char) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ushort2, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ushort2, signed short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ushort2, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ushort2, signed int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ushort2, float) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ushort2, double) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ushort2, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ushort2, signed long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ushort2, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ushort2, signed long long) + #endif + union { + struct { + unsigned short x, y; + }; + unsigned int a; + }; +} __attribute__((aligned(4))); + +struct ushort3 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_THREE_COMPONENT(ushort3) + + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ushort3, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ushort3, signed char) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ushort3, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ushort3, signed short) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ushort3, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ushort3, signed int) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ushort3, float) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ushort3, double) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ushort3, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ushort3, signed long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ushort3, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ushort3, signed long long) + #endif + unsigned short x, y, z; }; -struct ushort3 -{ - unsigned short x, y, z; +struct ushort4 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_FOUR_COMPONENT(ushort4) + + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ushort4, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ushort4, signed char) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ushort4, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ushort4, signed short) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ushort4, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ushort4, signed int) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ushort4, float) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ushort4, double) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ushort4, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ushort4, signed long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ushort4, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ushort4, signed long long) + #endif + union { + struct { + unsigned short x, y, z, w; + }; + unsigned int a, b; + }; +} __attribute__((aligned(8))); + +struct short1 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_ONE_COMPONENT(short1) + + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(short1, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(short1, signed char) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(short1, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(short1, signed short) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(short1, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(short1, signed int) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(short1, float) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(short1, double) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(short1, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(short1, signed long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(short1, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(short1, signed long long) + #endif + signed short x; +} __attribute__((aligned(2))); + +struct short2 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_TWO_COMPONENT(short2) + + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(short2, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(short2, signed char) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(short2, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(short2, signed short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(short2, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(short2, signed int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(short2, float) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(short2, double) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(short2, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(short2, signed long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(short2, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(short2, signed long long) + #endif + union { + struct { + signed short x, y; + }; + unsigned int a; + }; + +} __attribute__((aligned(4))); + +struct short3 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_THREE_COMPONENT(short3) + + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(short3, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(short3, signed char) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(short3, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(short3, signed short) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(short3, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(short3, signed int) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(short3, float) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(short3, double) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(short3, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(short3, signed long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(short3, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(short3, signed long long) + #endif + signed short x, y, z; }; -struct __hip_align(short4, 8, signed short x; signed short y; signed short z; signed short w;); -struct __hip_align(ushort4, 8, unsigned short x; unsigned short y; unsigned short z; unsigned short w;); +struct short4 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_FOUR_COMPONENT(short4) -struct __hip_align(int1, 4, signed int x;); -struct __hip_align(uint1, 4, unsigned int x;); + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(short4, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(short4, signed char) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(short4, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(short4, signed short) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(short4, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(short4, signed int) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(short4, float) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(short4, double) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(short4, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(short4, signed long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(short4, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(short4, signed long long) + #endif + union { + struct { + signed short x, y, z, w; + }; + unsigned int a, b; + }; +} __attribute__((aligned(8))); -struct __hip_align(int2, 8, signed int x; signed int y;); -struct __hip_align(uint2, 8, unsigned int x; unsigned int y;); -struct int3{ - signed int x, y, z; -}; -struct uint3{ - unsigned int x, y, z; +struct uint1 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_ONE_COMPONENT(uint1) + + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(uint1, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(uint1, signed char) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(uint1, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(uint1, signed short) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(uint1, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(uint1, signed int) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(uint1, float) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(uint1, double) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(uint1, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(uint1, signed long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(uint1, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(uint1, signed long long) + #endif + unsigned int x; +} __attribute__((aligned(4))); + +struct uint2 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_TWO_COMPONENT(uint2) + + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(uint2, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(uint2, signed char) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(uint2, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(uint2, signed short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(uint2, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(uint2, signed int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(uint2, float) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(uint2, double) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(uint2, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(uint2, signed long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(uint2, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(uint2, signed long long) + #endif + unsigned int x, y; +} __attribute__((aligned(8))); + +struct uint3 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_THREE_COMPONENT(uint3) + + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(uint3, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(uint3, signed char) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(uint3, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(uint3, signed short) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(uint3, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(uint3, signed int) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(uint3, float) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(uint3, double) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(uint3, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(uint3, signed long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(uint3, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(uint3, signed long long) + #endif + unsigned int x, y, z; }; -struct __hip_align(int4, 16, signed int x; signed int y; signed int z; signed int w;); -struct __hip_align(uint4, 16, unsigned int x; unsigned int y; unsigned int z; unsigned int w;); +struct uint4 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_FOUR_COMPONENT(uint4) -struct __hip_align(long1, 8, long int x;); -struct __hip_align(ulong1, 8, unsigned long x;); + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(uint4, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(uint4, signed char) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(uint4, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(uint4, signed short) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(uint4, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(uint4, signed int) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(uint4, float) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(uint4, double) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(uint4, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(uint4, signed long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(uint4, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(uint4, signed long long) + #endif + unsigned int x, y, z, w; +} __attribute__((aligned(16))); -struct __hip_align(long2, 16, long int x; long int y;); -struct __hip_align(ulong2, 16, unsigned long x; unsigned long y;); +struct int1 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_ONE_COMPONENT(int1) -struct long3{ - long int x, y, z; -}; -struct ulong3{ - unsigned long x, y, z; + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(int1, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(int1, signed char) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(int1, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(int1, signed short) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(int1, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(int1, signed int) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(int1, float) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(int1, double) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(int1, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(int1, signed long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(int1, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(int1, signed long long) + #endif + signed int x; +} __attribute__((aligned(4))); + +struct int2 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_TWO_COMPONENT(int2) + + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(int2, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(int2, signed char) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(int2, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(int2, signed short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(int2, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(int2, signed int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(int2, float) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(int2, double) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(int2, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(int2, signed long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(int2, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(int2, signed long long) + #endif + signed int x, y; +} __attribute__((aligned(8))); + +struct int3 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_THREE_COMPONENT(int3) + + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(int3, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(int3, signed char) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(int3, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(int3, signed short) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(int3, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(int3, signed int) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(int3, float) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(int3, double) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(int3, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(int3, signed long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(int3, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(int3, signed long long) + #endif + signed int x, y, z; }; -struct __hip_align(long4, 32, long int x; long int y; long int z; long int w;); -struct __hip_align(ulong4, 32, unsigned long x; unsigned long y; unsigned long z; unsigned long w;); +struct int4 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_FOUR_COMPONENT(int4) -struct float1 -{ - float x; + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(int4, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(int4, signed char) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(int4, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(int4, signed short) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(int4, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(int4, signed int) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(int4, float) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(int4, double) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(int4, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(int4, signed long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(int4, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(int4, signed long long) + #endif + signed int x, y, z, w; +} __attribute__((aligned(16))); + + +struct float1 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_ONE_COMPONENT(float1) + + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(float1, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(float1, signed char) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(float1, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(float1, signed short) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(float1, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(float1, signed int) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(float1, float) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(float1, double) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(float1, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(float1, signed long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(float1, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(float1, signed long long) + #endif + float x; +} __attribute__((aligned(4))); + +struct float2 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_TWO_COMPONENT(float2) + + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(float2, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(float2, signed char) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(float2, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(float2, signed short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(float2, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(float2, signed int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(float2, float) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(float2, double) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(float2, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(float2, signed long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(float2, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(float2, signed long long) + #endif + float x, y; +} __attribute__((aligned(8))); + +struct float3 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_THREE_COMPONENT(float3) + + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(float3, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(float3, signed char) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(float3, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(float3, signed short) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(float3, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(float3, signed int) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(float3, float) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(float3, double) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(float3, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(float3, signed long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(float3, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(float3, signed long long) + #endif + float x, y, z; }; -struct __hip_align(float2, 8, float x; float y;); +struct float4 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_FOUR_COMPONENT(float4) -struct float3 -{ - float x, y, z; + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(float4, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(float4, signed char) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(float4, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(float4, signed short) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(float4, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(float4, signed int) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(float4, float) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(float4, double) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(float4, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(float4, signed long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(float4, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(float4, signed long long) + #endif + float x, y, z, w; +} __attribute__((aligned(16))); + + + +struct double1 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_ONE_COMPONENT(double1) + + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(double1, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(double1, signed char) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(double1, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(double1, signed short) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(double1, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(double1, signed int) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(double1, float) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(double1, double) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(double1, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(double1, signed long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(double1, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(double1, signed long long) + #endif + double x; +} __attribute__((aligned(8))); + +struct double2 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_TWO_COMPONENT(double2) + + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(double2, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(double2, signed char) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(double2, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(double2, signed short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(double2, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(double2, signed int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(double2, float) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(double2, double) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(double2, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(double2, signed long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(double2, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(double2, signed long long) + #endif + double x, y; +} __attribute__((aligned(16))); + +struct double3 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_THREE_COMPONENT(double3) + + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(double3, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(double3, signed char) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(double3, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(double3, signed short) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(double3, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(double3, signed int) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(double3, float) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(double3, double) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(double3, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(double3, signed long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(double3, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(double3, signed long long) + #endif + double x, y, z; }; -struct __hip_align(float4, 16, float x; float y; float z; float w;); +struct double4 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_FOUR_COMPONENT(double4) -struct __hip_align(longlong1, 16, long long int x;); -struct __hip_align(ulonglong1, 16, unsigned long long int x;); + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(double4, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(double4, signed char) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(double4, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(double4, signed short) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(double4, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(double4, signed int) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(double4, float) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(double4, double) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(double4, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(double4, signed long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(double4, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(double4, signed long long) + #endif + double x, y, z, w; +} __attribute__((aligned(32))); -struct __attribute__((aligned(32))) longlong2 -{ - long long int x, y; + +struct ulong1 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_ONE_COMPONENT(ulong1) + + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ulong1, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ulong1, signed char) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ulong1, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ulong1, signed short) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ulong1, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ulong1, signed int) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ulong1, float) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ulong1, double) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ulong1, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ulong1, signed long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ulong1, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ulong1, signed long long) + #endif + unsigned long x; +} __attribute__((aligned(8))); + +struct ulong2 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_TWO_COMPONENT(ulong2) + + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ulong2, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ulong2, signed char) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ulong2, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ulong2, signed short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ulong2, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ulong2, signed int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ulong2, float) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ulong2, double) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ulong2, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ulong2, signed long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ulong2, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ulong2, signed long long) + #endif + unsigned long x, y; +} __attribute__((aligned(16))); + +struct ulong3 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_THREE_COMPONENT(ulong3) + + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ulong3, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ulong3, signed char) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ulong3, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ulong3, signed short) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ulong3, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ulong3, signed int) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ulong3, float) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ulong3, double) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ulong3, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ulong3, signed long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ulong3, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ulong3, signed long long) + #endif + unsigned long x, y, z; }; -struct __attribute__((aligned(32))) ulonglong2 -{ - unsigned long long int x, y; +struct ulong4 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_FOUR_COMPONENT(ulong4) + + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ulong4, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ulong4, signed char) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ulong4, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ulong4, signed short) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ulong4, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ulong4, signed int) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ulong4, float) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ulong4, double) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ulong4, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ulong4, signed long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ulong4, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ulong4, signed long long) + #endif + unsigned long x, y, z, w; +} __attribute__((aligned(32))); + + +struct long1 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_ONE_COMPONENT(long1) + + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(long1, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(long1, signed char) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(long1, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(long1, signed short) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(long1, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(long1, signed int) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(long1, float) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(long1, double) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(long1, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(long1, signed long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(long1, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(long1, signed long long) + #endif + signed long x; +} __attribute__((aligned(8))); + +struct long2 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_TWO_COMPONENT(long2) + + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(long2, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(long2, signed char) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(long2, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(long2, signed short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(long2, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(long2, signed int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(long2, float) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(long2, double) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(long2, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(long2, signed long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(long2, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(long2, signed long long) + #endif + signed long x, y; +} __attribute__((aligned(16))); + +struct long3 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_THREE_COMPONENT(long3) + + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(long3, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(long3, signed char) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(long3, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(long3, signed short) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(long3, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(long3, signed int) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(long3, float) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(long3, double) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(long3, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(long3, signed long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(long3, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(long3, signed long long) + #endif + signed long x, y, z; }; -struct longlong3 -{ - long long int x, y, z; +struct long4 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_FOUR_COMPONENT(long4) + + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(long4, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(long4, signed char) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(long4, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(long4, signed short) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(long4, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(long4, signed int) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(long4, float) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(long4, double) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(long4, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(long4, signed long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(long4, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(long4, signed long long) + #endif + signed long x, y, z, w; +} __attribute__((aligned(32))); + + +struct ulonglong1 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_ONE_COMPONENT(ulonglong1) + + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ulonglong1, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ulonglong1, signed char) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ulonglong1, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ulonglong1, signed short) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ulonglong1, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ulonglong1, signed int) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ulonglong1, float) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ulonglong1, double) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ulonglong1, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ulonglong1, signed long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ulonglong1, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(ulonglong1, signed long long) + #endif + unsigned long long x; +} __attribute__((aligned(8))); + +struct ulonglong2 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_TWO_COMPONENT(ulonglong2) + + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ulonglong2, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ulonglong2, signed char) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ulonglong2, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ulonglong2, signed short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ulonglong2, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ulonglong2, signed int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ulonglong2, float) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ulonglong2, double) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ulonglong2, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ulonglong2, signed long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ulonglong2, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ulonglong2, signed long long) + #endif + unsigned long long x, y; +} __attribute__((aligned(16))); + +struct ulonglong3 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_THREE_COMPONENT(ulonglong3) + + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ulonglong3, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ulonglong3, signed char) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ulonglong3, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ulonglong3, signed short) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ulonglong3, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ulonglong3, signed int) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ulonglong3, float) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ulonglong3, double) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ulonglong3, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ulonglong3, signed long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ulonglong3, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(ulonglong3, signed long long) + #endif + unsigned long long x, y, z; }; -struct ulonglong3 -{ - unsigned long long int x, y, z; +struct ulonglong4 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_FOUR_COMPONENT(ulonglong4) + + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ulonglong4, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ulonglong4, signed char) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ulonglong4, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ulonglong4, signed short) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ulonglong4, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ulonglong4, signed int) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ulonglong4, float) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ulonglong4, double) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ulonglong4, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ulonglong4, signed long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ulonglong4, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(ulonglong4, signed long long) + #endif + unsigned long long x, y, z, w; +} __attribute__((aligned(32))); + + +struct longlong1 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_ONE_COMPONENT(longlong1) + + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(longlong1, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(longlong1, signed char) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(longlong1, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(longlong1, signed short) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(longlong1, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(longlong1, signed int) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(longlong1, float) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(longlong1, double) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(longlong1, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(longlong1, signed long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(longlong1, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_ONE_COMPONENT(longlong1, signed long long) + #endif + signed long long x; +} __attribute__((aligned(8))); + +struct longlong2 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_TWO_COMPONENT(longlong2) + + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(longlong2, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(longlong2, signed char) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(longlong2, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(longlong2, signed short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(longlong2, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(longlong2, signed int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(longlong2, float) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(longlong2, double) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(longlong2, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(longlong2, signed long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(longlong2, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(longlong2, signed long long) + #endif + signed long long x, y; +} __attribute__((aligned(16))); + +struct longlong3 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_THREE_COMPONENT(longlong3) + + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(longlong3, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(longlong3, signed char) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(longlong3, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(longlong3, signed short) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(longlong3, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(longlong3, signed int) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(longlong3, float) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(longlong3, double) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(longlong3, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(longlong3, signed long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(longlong3, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_THREE_COMPONENT(longlong3, signed long long) + #endif + signed long long x, y, z; }; -struct __attribute__((aligned(64))) longlong4 -{ - long long int x, y, z, w; -}; +struct longlong4 { + #ifdef __cplusplus + public: + MAKE_DEFAULT_CONSTRUCTOR_FOUR_COMPONENT(longlong4) -struct __attribute__((aligned(64))) ulonglong4 -{ - unsigned long long int x, y, z, w; -}; + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(longlong4, unsigned char) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(longlong4, signed char) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(longlong4, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(longlong4, signed short) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(longlong4, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(longlong4, signed int) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(longlong4, float) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(longlong4, double) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(longlong4, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(longlong4, signed long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(longlong4, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_FOUR_COMPONENT(longlong4, signed long long) + #endif + signed long x, y, z, w; +} __attribute__((aligned(32))); -struct double1 -{ - double x; -}; +#define DECLOP_MAKE_ONE_COMPONENT(comp, type) \ +__device__ __host__ inline type make_##type(comp x) { \ + type ret; \ + ret.x = x; \ + return ret; \ +} -struct __attribute__((aligned(16))) double2 -{ - double x, y; -}; +#define DECLOP_MAKE_TWO_COMPONENT(comp, type) \ +__device__ __host__ inline type make_##type(comp x, comp y) { \ + type ret; \ + ret.x = x; \ + ret.y = y; \ + return ret; \ +} -struct double3 -{ - double x, y, z; -}; +#define DECLOP_MAKE_THREE_COMPONENT(comp, type) \ +__device__ __host__ inline type make_##type(comp x, comp y, comp z) { \ + type ret; \ + ret.x = x; \ + ret.y = y; \ + ret.z = z; \ + return ret; \ +} -struct __attribute__((aligned(32))) double4 -{ - double x, y, z, w; -}; +#define DECLOP_MAKE_FOUR_COMPONENT(comp, type) \ +__device__ __host__ inline type make_##type(comp x, comp y, comp z, comp w) { \ + type ret; \ + ret.x = x; \ + ret.y = y; \ + ret.z = z; \ + ret.w = w; \ + return ret; \ +} -#endif +DECLOP_MAKE_ONE_COMPONENT(unsigned char, uchar1); +DECLOP_MAKE_TWO_COMPONENT(unsigned char, uchar2); +DECLOP_MAKE_THREE_COMPONENT(unsigned char, uchar3); +DECLOP_MAKE_FOUR_COMPONENT(unsigned char, uchar4); -#if __HCC__ -#include"hip/hcc_detail/host_defines.h" -#define __HIP_DEVICE__ __device__ __host__ -#else -#define __HIP_DEVICE__ -#endif +DECLOP_MAKE_ONE_COMPONENT(signed char, char1); +DECLOP_MAKE_TWO_COMPONENT(signed char, char2); +DECLOP_MAKE_THREE_COMPONENT(signed char, char3); +DECLOP_MAKE_FOUR_COMPONENT(signed char, char4); -__HIP_DEVICE__ char1 make_char1(signed char ); -__HIP_DEVICE__ char2 make_char2(signed char, signed char ); -__HIP_DEVICE__ char3 make_char3(signed char, signed char, signed char ); -__HIP_DEVICE__ char4 make_char4(signed char, signed char, signed char, signed char ); +DECLOP_MAKE_ONE_COMPONENT(unsigned short, ushort1); +DECLOP_MAKE_TWO_COMPONENT(unsigned short, ushort2); +DECLOP_MAKE_THREE_COMPONENT(unsigned short, ushort3); +DECLOP_MAKE_FOUR_COMPONENT(unsigned short, ushort4); -__HIP_DEVICE__ short1 make_short1(short ); -__HIP_DEVICE__ short2 make_short2(short, short ); -__HIP_DEVICE__ short3 make_short3(short, short, short ); -__HIP_DEVICE__ short4 make_short4(short, short, short, short ); +DECLOP_MAKE_ONE_COMPONENT(signed short, short1); +DECLOP_MAKE_TWO_COMPONENT(signed short, short2); +DECLOP_MAKE_THREE_COMPONENT(signed short, short3); +DECLOP_MAKE_FOUR_COMPONENT(signed short, short4); -__HIP_DEVICE__ int1 make_int1(int ); -__HIP_DEVICE__ int2 make_int2(int, int ); -__HIP_DEVICE__ int3 make_int3(int, int, int ); -__HIP_DEVICE__ int4 make_int4(int, int, int, int ); +DECLOP_MAKE_ONE_COMPONENT(unsigned int, uint1); +DECLOP_MAKE_TWO_COMPONENT(unsigned int, uint2); +DECLOP_MAKE_THREE_COMPONENT(unsigned int, uint3); +DECLOP_MAKE_FOUR_COMPONENT(unsigned int, uint4); -__HIP_DEVICE__ long1 make_long1(long ); -__HIP_DEVICE__ long2 make_long2(long, long ); -__HIP_DEVICE__ long3 make_long3(long, long, long ); -__HIP_DEVICE__ long4 make_long4(long, long, long, long ); +DECLOP_MAKE_ONE_COMPONENT(signed int, int1); +DECLOP_MAKE_TWO_COMPONENT(signed int, int2); +DECLOP_MAKE_THREE_COMPONENT(signed int, int3); +DECLOP_MAKE_FOUR_COMPONENT(signed int, int4); -__HIP_DEVICE__ longlong1 make_longlong1(long long ); -__HIP_DEVICE__ longlong2 make_longlong2(long long, long long ); -__HIP_DEVICE__ longlong3 make_longlong3(long long, long long, long long ); -__HIP_DEVICE__ longlong4 make_longlong4(long long, long long, long long, long long ); +DECLOP_MAKE_ONE_COMPONENT(float, float1); +DECLOP_MAKE_TWO_COMPONENT(float, float2); +DECLOP_MAKE_THREE_COMPONENT(float, float3); +DECLOP_MAKE_FOUR_COMPONENT(float, float4); -__HIP_DEVICE__ uchar1 make_uchar1(unsigned char ); -__HIP_DEVICE__ uchar2 make_uchar2(unsigned char, unsigned char ); -__HIP_DEVICE__ uchar3 make_uchar3(unsigned char, unsigned char, unsigned char ); -__HIP_DEVICE__ uchar4 make_uchar4(unsigned char, unsigned char, unsigned char, unsigned char ); +DECLOP_MAKE_ONE_COMPONENT(double, double1); +DECLOP_MAKE_TWO_COMPONENT(double, double2); +DECLOP_MAKE_THREE_COMPONENT(double, double3); +DECLOP_MAKE_FOUR_COMPONENT(double, double4); -__HIP_DEVICE__ ushort1 make_ushort1(unsigned short ); -__HIP_DEVICE__ ushort2 make_ushort2(unsigned short, unsigned short ); -__HIP_DEVICE__ ushort3 make_ushort3(unsigned short, unsigned short, unsigned short ); -__HIP_DEVICE__ ushort4 make_ushort4(unsigned short, unsigned short, unsigned short, unsigned short ); +DECLOP_MAKE_ONE_COMPONENT(unsigned long, ulong1); +DECLOP_MAKE_TWO_COMPONENT(unsigned long, ulong2); +DECLOP_MAKE_THREE_COMPONENT(unsigned long, ulong3); +DECLOP_MAKE_FOUR_COMPONENT(unsigned long, ulong4); -__HIP_DEVICE__ uint1 make_uint1(unsigned int ); -__HIP_DEVICE__ uint2 make_uint2(unsigned int, unsigned int ); -__HIP_DEVICE__ uint3 make_uint3(unsigned int, unsigned int, unsigned int ); -__HIP_DEVICE__ uint4 make_uint4(unsigned int, unsigned int, unsigned int, unsigned int ); +DECLOP_MAKE_ONE_COMPONENT(signed long, long1); +DECLOP_MAKE_TWO_COMPONENT(signed long, long2); +DECLOP_MAKE_THREE_COMPONENT(signed long, long3); +DECLOP_MAKE_FOUR_COMPONENT(signed long, long4); -__HIP_DEVICE__ ulong1 make_ulong1(unsigned long ); -__HIP_DEVICE__ ulong2 make_ulong2(unsigned long, unsigned long ); -__HIP_DEVICE__ ulong3 make_ulong3(unsigned long, unsigned long, unsigned long ); -__HIP_DEVICE__ ulong4 make_ulong4(unsigned long, unsigned long, unsigned long, unsigned long ); +DECLOP_MAKE_ONE_COMPONENT(unsigned long, ulonglong1); +DECLOP_MAKE_TWO_COMPONENT(unsigned long, ulonglong2); +DECLOP_MAKE_THREE_COMPONENT(unsigned long, ulonglong3); +DECLOP_MAKE_FOUR_COMPONENT(unsigned long, ulonglong4); -__HIP_DEVICE__ ulonglong1 make_ulonglong1(unsigned long long ); -__HIP_DEVICE__ ulonglong2 make_ulonglong2(unsigned long long, unsigned long long); -__HIP_DEVICE__ ulonglong3 make_ulonglong3(unsigned long long, unsigned long long, unsigned long long); -__HIP_DEVICE__ ulonglong4 make_ulonglong4(unsigned long long, unsigned long long, unsigned long long, unsigned long long ); +DECLOP_MAKE_ONE_COMPONENT(signed long, longlong1); +DECLOP_MAKE_TWO_COMPONENT(signed long, longlong2); +DECLOP_MAKE_THREE_COMPONENT(signed long, longlong3); +DECLOP_MAKE_FOUR_COMPONENT(signed long, longlong4); -__HIP_DEVICE__ float1 make_float1(float ); -__HIP_DEVICE__ float2 make_float2(float, float ); -__HIP_DEVICE__ float3 make_float3(float, float, float ); -__HIP_DEVICE__ float4 make_float4(float, float, float, float ); -__HIP_DEVICE__ double1 make_double1(double ); -__HIP_DEVICE__ double2 make_double2(double, double ); -__HIP_DEVICE__ double3 make_double3(double, double, double ); -__HIP_DEVICE__ double4 make_double4(double, double, double, double ); +#if __cplusplus + +#define DECLOP_1VAR_2IN_1OUT(type, op) \ +__device__ __host__ type operator op (const type& lhs, const type& rhs) { \ + type ret; \ + ret.x = lhs.x op rhs.x; \ + return ret; \ +} + +#define DECLOP_1VAR_SCALE_PRODUCT(type, type1) \ +__device__ __host__ type operator * (const type& lhs, type1 rhs) { \ + type ret; \ + ret.x = lhs.x * rhs; \ + return ret; \ +} \ +\ +__device__ __host__ type operator * (type1 lhs, const type& rhs) { \ + type ret; \ + ret.x = lhs * rhs.x; \ + return ret; \ +} + +#define DECLOP_1VAR_ASSIGN(type, op) \ +__device__ __host__ inline type& operator op ( type& lhs, const type& rhs) { \ + lhs.x op rhs.x; \ + return lhs; \ +} + +#define DECLOP_1VAR_PREOP(type, op) \ +__device__ __host__ inline type& operator op (type& val) { \ + op val.x; \ + return val; \ +} + +#define DECLOP_1VAR_POSTOP(type, op) \ +__device__ __host__ type operator op (type& val, int i) { \ + type ret; \ + ret.x = val.x; \ + val.x op; \ + return ret; \ +} + +#define DECLOP_1VAR_COMP(type, op) \ +__device__ __host__ inline bool operator op (type& lhs, type& rhs) { \ + return lhs.x op rhs.x; \ +} + +#define DECLOP_1VAR_1IN_1OUT(type, op) \ +__device__ __host__ type operator op(type& rhs) { \ + type ret; \ + ret.x = op rhs.x; \ + return ret; \ +} + +#define DECLOP_1VAR_1IN_BOOLOUT(type, op) \ +__device__ __host__ inline bool operator op (type& rhs) { \ + return op rhs.x; \ +} + +/* + Two Element Access +*/ + +#define DECLOP_2VAR_2IN_1OUT(type, op) \ +__device__ __host__ type operator op (const type& lhs, const type& rhs) { \ + type ret; \ + ret.x = lhs.x op rhs.x; \ + ret.y = lhs.y op rhs.y; \ + return ret; \ +} + +#define DECLOP_2VAR_SCALE_PRODUCT(type, type1) \ +__device__ __host__ type operator * (const type& lhs, type1 rhs) { \ + type ret; \ + ret.x = lhs.x * rhs; \ + ret.y = lhs.y * rhs; \ + return ret; \ +} \ +\ +__device__ __host__ type operator * (type1 lhs, const type& rhs) { \ + type ret; \ + ret.x = lhs * rhs.x; \ + ret.y = lhs * rhs.y; \ + return ret; \ +} + +#define DECLOP_2VAR_ASSIGN(type, op) \ +__device__ __host__ inline type& operator op ( type& lhs, const type& rhs) { \ + lhs.x op rhs.x; \ + lhs.y op rhs.y; \ + return lhs; \ +} + +#define DECLOP_2VAR_PREOP(type, op) \ +__device__ __host__ inline type& operator op (type& val) { \ + op val.x; \ + op val.y; \ + return val; \ +} + +#define DECLOP_2VAR_POSTOP(type, op) \ +__device__ __host__ type operator op (type& val, int i) { \ + type ret; \ + ret.x = val.x; \ + ret.y = val.y; \ + val.x op; \ + val.y op; \ + return ret; \ +} + +#define DECLOP_2VAR_COMP(type, op) \ +__device__ __host__ inline bool operator op (type& lhs, type& rhs) { \ + return lhs.x op rhs.x && lhs.y op rhs.y; \ +} + +#define DECLOP_2VAR_1IN_1OUT(type, op) \ +__device__ __host__ type operator op(type &rhs) { \ + type ret; \ + ret.x = op rhs.x; \ + ret.y = op rhs.y; \ + return ret; \ +} + +#define DECLOP_2VAR_1IN_BOOLOUT(type, op) \ +__device__ __host__ inline bool operator op (type &rhs) { \ + return op rhs.x && op rhs.y; \ +} /* -///--- -// Inline functions for creating vector types from basic types -#define ONE_COMPONENT_ACCESS(T, VT) inline VT make_ ##VT [[hc]] [[cpu]] (T x) { VT t; t.x = x; return t; }; -#define TWO_COMPONENT_ACCESS(T, VT) inline VT make_ ##VT [[hc]] [[cpu]] (T x, T y) { VT t; t.x=x; t.y=y; return t; }; -#define THREE_COMPONENT_ACCESS(T, VT) inline VT make_ ##VT [[hc]] [[cpu]] (T x, T y, T z) { VT t; t.x=x; t.y=y; t.z=z; return t; }; -#define FOUR_COMPONENT_ACCESS(T, VT) inline VT make_ ##VT [[hc]] [[cpu]] (T x, T y, T z, T w) { VT t; t.x=x; t.y=y; t.z=z; t.w=w; return t; }; - - -//signed: -ONE_COMPONENT_ACCESS (signed char, char1); -TWO_COMPONENT_ACCESS (signed char, char2); -THREE_COMPONENT_ACCESS(signed char, char3); -FOUR_COMPONENT_ACCESS (signed char, char4); - -ONE_COMPONENT_ACCESS (short, short1); -TWO_COMPONENT_ACCESS (short, short2); -THREE_COMPONENT_ACCESS(short, short3); -FOUR_COMPONENT_ACCESS (short, short4); - -ONE_COMPONENT_ACCESS (int, int1); -TWO_COMPONENT_ACCESS (int, int2); -THREE_COMPONENT_ACCESS(int, int3); -FOUR_COMPONENT_ACCESS (int, int4); - -ONE_COMPONENT_ACCESS (long int, long1); -TWO_COMPONENT_ACCESS (long int, long2); -THREE_COMPONENT_ACCESS(long int, long3); -FOUR_COMPONENT_ACCESS (long int, long4); - -ONE_COMPONENT_ACCESS (long long int, ulong1); -TWO_COMPONENT_ACCESS (long long int, ulong2); -THREE_COMPONENT_ACCESS(long long int, ulong3); -FOUR_COMPONENT_ACCESS (long long int, ulong4); - -ONE_COMPONENT_ACCESS (long long int, longlong1); -TWO_COMPONENT_ACCESS (long long int, longlong2); -THREE_COMPONENT_ACCESS(long long int, longlong3); -FOUR_COMPONENT_ACCESS (long long int, longlong4); - - -// unsigned: -ONE_COMPONENT_ACCESS (unsigned char, uchar1); -TWO_COMPONENT_ACCESS (unsigned char, uchar2); -THREE_COMPONENT_ACCESS(unsigned char, uchar3); -FOUR_COMPONENT_ACCESS (unsigned char, uchar4); - -ONE_COMPONENT_ACCESS (unsigned short, ushort1); -TWO_COMPONENT_ACCESS (unsigned short, ushort2); -THREE_COMPONENT_ACCESS(unsigned short, ushort3); -FOUR_COMPONENT_ACCESS (unsigned short, ushort4); - -ONE_COMPONENT_ACCESS (unsigned int, uint1); -TWO_COMPONENT_ACCESS (unsigned int, uint2); -THREE_COMPONENT_ACCESS(unsigned int, uint3); -FOUR_COMPONENT_ACCESS (unsigned int, uint4); - -ONE_COMPONENT_ACCESS (unsigned long int, ulong1); -TWO_COMPONENT_ACCESS (unsigned long int, ulong2); -THREE_COMPONENT_ACCESS(unsigned long int, ulong3); -FOUR_COMPONENT_ACCESS (unsigned long int, ulong4); - -ONE_COMPONENT_ACCESS (unsigned long long int, ulong1); -TWO_COMPONENT_ACCESS (unsigned long long int, ulong2); -THREE_COMPONENT_ACCESS(unsigned long long int, ulong3); -FOUR_COMPONENT_ACCESS (unsigned long long int, ulong4); - -ONE_COMPONENT_ACCESS (unsigned long long int, ulonglong1); -TWO_COMPONENT_ACCESS (unsigned long long int, ulonglong2); -THREE_COMPONENT_ACCESS(unsigned long long int, ulonglong3); -FOUR_COMPONENT_ACCESS (unsigned long long int, ulonglong4); - - -//Floating point -ONE_COMPONENT_ACCESS (float, float1); -TWO_COMPONENT_ACCESS (float, float2); -THREE_COMPONENT_ACCESS(float, float3); -FOUR_COMPONENT_ACCESS (float, float4); - -ONE_COMPONENT_ACCESS (double, double1); -TWO_COMPONENT_ACCESS (double, double2); -THREE_COMPONENT_ACCESS(double, double3); -FOUR_COMPONENT_ACCESS (double, double4); + Three Element Access */ +#define DECLOP_3VAR_2IN_1OUT(type, op) \ +__device__ __host__ type operator op (const type& lhs, const type& rhs) { \ + type ret; \ + ret.x = lhs.x op rhs.x; \ + ret.y = lhs.y op rhs.y; \ + ret.z = lhs.z op rhs.z; \ + return ret; \ +} + +#define DECLOP_3VAR_SCALE_PRODUCT(type, type1) \ +__device__ __host__ type operator * (const type& lhs, type1 rhs) { \ + type ret; \ + ret.x = lhs.x * rhs; \ + ret.y = lhs.y * rhs; \ + ret.z = lhs.z * rhs; \ + return ret; \ +} \ +\ +__device__ __host__ type operator * (type1 lhs, const type& rhs) { \ + type ret; \ + ret.x = lhs * rhs.x; \ + ret.y = lhs * rhs.y; \ + ret.z = lhs * rhs.z; \ + return ret; \ +} + +#define DECLOP_3VAR_ASSIGN(type, op) \ +__device__ __host__ inline type& operator op ( type& lhs, const type& rhs) { \ + lhs.x op rhs.x; \ + lhs.y op rhs.y; \ + lhs.z op rhs.z; \ + return lhs; \ +} + +#define DECLOP_3VAR_PREOP(type, op) \ +__device__ __host__ inline type& operator op (type& val) { \ + op val.x; \ + op val.y; \ + op val.z; \ + return val; \ +} + +#define DECLOP_3VAR_POSTOP(type, op) \ +__device__ __host__ type operator op (type& val, int i) { \ + type ret; \ + ret.x = val.x; \ + ret.y = val.y; \ + ret.z = val.z; \ + val.x op; \ + val.y op; \ + val.z op; \ + return ret; \ +} + +#define DECLOP_3VAR_COMP(type, op) \ +__device__ __host__ inline bool operator op (type& lhs, type& rhs) { \ + return lhs.x op rhs.x && lhs.y op rhs.y && lhs.z op rhs.z; \ +} + +#define DECLOP_3VAR_1IN_1OUT(type, op) \ +__device__ __host__ type operator op(type &rhs) { \ + type ret; \ + ret.x = op rhs.x; \ + ret.y = op rhs.y; \ + ret.z = op rhs.z; \ + return ret; \ +} + +#define DECLOP_3VAR_1IN_BOOLOUT(type, op) \ +__device__ __host__ inline bool operator op (type &rhs) { \ + return op rhs.x && op rhs.y && op rhs.z; \ +} + + +/* + Four Element Access +*/ + +#define DECLOP_4VAR_2IN_1OUT(type, op) \ +__device__ __host__ type operator op ( const type& lhs, const type& rhs) { \ + type ret; \ + ret.x = lhs.x op rhs.x; \ + ret.y = lhs.y op rhs.y; \ + ret.z = lhs.z op rhs.z; \ + ret.w = lhs.w op rhs.w; \ + return ret; \ +} + +#define DECLOP_4VAR_SCALE_PRODUCT(type, type1) \ +__device__ __host__ type operator * (const type& lhs, type1 rhs) { \ + type ret; \ + ret.x = lhs.x * rhs; \ + ret.y = lhs.y * rhs; \ + ret.z = lhs.z * rhs; \ + ret.w = lhs.w * rhs; \ + return ret; \ +} \ +\ +__device__ __host__ type operator * (type1 lhs, const type& rhs) { \ + type ret; \ + ret.x = lhs * rhs.x; \ + ret.y = lhs * rhs.y; \ + ret.z = lhs * rhs.z; \ + ret.w = lhs * rhs.w; \ + return ret; \ +} + +#define DECLOP_4VAR_ASSIGN(type, op) \ +__device__ __host__ inline type& operator op ( type& lhs, const type& rhs) { \ + lhs.x op rhs.x; \ + lhs.y op rhs.y; \ + lhs.z op rhs.z; \ + lhs.w op rhs.w; \ + return lhs; \ +} + +#define DECLOP_4VAR_PREOP(type, op) \ +__device__ __host__ inline type& operator op (type& val) { \ + op val.x; \ + op val.y; \ + op val.z; \ + op val.w; \ + return val; \ +} + +#define DECLOP_4VAR_POSTOP(type, op) \ +__device__ __host__ type operator op (type& val, int i) { \ + type ret; \ + ret.x = val.x; \ + ret.y = val.y; \ + ret.z = val.z; \ + ret.w = val.w; \ + val.x op; \ + val.y op; \ + val.z op; \ + val.w op; \ + return ret; \ +} + +#define DECLOP_4VAR_COMP(type, op) \ +__device__ __host__ inline bool operator op (type& lhs, type& rhs) { \ + return lhs.x op rhs.x && lhs.y op rhs.y && lhs.z op rhs.z && lhs.w op rhs.w; \ +} + +#define DECLOP_4VAR_1IN_1OUT(type, op) \ +__device__ __host__ type operator op(type &rhs) { \ + type ret; \ + ret.x = op rhs.x; \ + ret.y = op rhs.y; \ + ret.z = op rhs.z; \ + ret.w = op rhs.w; \ + return ret; \ +} + +#define DECLOP_4VAR_1IN_BOOLOUT(type, op) \ +__device__ __host__ inline bool operator op (type &rhs) { \ + return op rhs.x && op rhs.y && op rhs.z && op rhs.w; \ +} + + +/* +Overloading operators +*/ + +// UNSIGNED CHAR1 + +DECLOP_1VAR_2IN_1OUT(uchar1, +) +DECLOP_1VAR_2IN_1OUT(uchar1, -) +DECLOP_1VAR_2IN_1OUT(uchar1, *) +DECLOP_1VAR_2IN_1OUT(uchar1, /) +DECLOP_1VAR_2IN_1OUT(uchar1, %) +DECLOP_1VAR_2IN_1OUT(uchar1, &) +DECLOP_1VAR_2IN_1OUT(uchar1, |) +DECLOP_1VAR_2IN_1OUT(uchar1, ^) +DECLOP_1VAR_2IN_1OUT(uchar1, <<) +DECLOP_1VAR_2IN_1OUT(uchar1, >>) + + +DECLOP_1VAR_ASSIGN(uchar1, +=) +DECLOP_1VAR_ASSIGN(uchar1, -=) +DECLOP_1VAR_ASSIGN(uchar1, *=) +DECLOP_1VAR_ASSIGN(uchar1, /=) +DECLOP_1VAR_ASSIGN(uchar1, %=) +DECLOP_1VAR_ASSIGN(uchar1, &=) +DECLOP_1VAR_ASSIGN(uchar1, |=) +DECLOP_1VAR_ASSIGN(uchar1, ^=) +DECLOP_1VAR_ASSIGN(uchar1, <<=) +DECLOP_1VAR_ASSIGN(uchar1, >>=) + +DECLOP_1VAR_PREOP(uchar1, ++) +DECLOP_1VAR_PREOP(uchar1, --) + +DECLOP_1VAR_POSTOP(uchar1, ++) +DECLOP_1VAR_POSTOP(uchar1, --) + +DECLOP_1VAR_COMP(uchar1, ==) +DECLOP_1VAR_COMP(uchar1, !=) +DECLOP_1VAR_COMP(uchar1, <) +DECLOP_1VAR_COMP(uchar1, >) +DECLOP_1VAR_COMP(uchar1, <=) +DECLOP_1VAR_COMP(uchar1, >=) + +DECLOP_1VAR_COMP(uchar1, &&) +DECLOP_1VAR_COMP(uchar1, ||) + +DECLOP_1VAR_1IN_1OUT(uchar1, ~) +DECLOP_1VAR_1IN_BOOLOUT(uchar1, !) + +DECLOP_1VAR_SCALE_PRODUCT(uchar1, unsigned char) +DECLOP_1VAR_SCALE_PRODUCT(uchar1, signed char) +DECLOP_1VAR_SCALE_PRODUCT(uchar1, unsigned short) +DECLOP_1VAR_SCALE_PRODUCT(uchar1, signed short) +DECLOP_1VAR_SCALE_PRODUCT(uchar1, unsigned int) +DECLOP_1VAR_SCALE_PRODUCT(uchar1, signed int) +DECLOP_1VAR_SCALE_PRODUCT(uchar1, float) +DECLOP_1VAR_SCALE_PRODUCT(uchar1, unsigned long) +DECLOP_1VAR_SCALE_PRODUCT(uchar1, signed long) +DECLOP_1VAR_SCALE_PRODUCT(uchar1, double) +DECLOP_1VAR_SCALE_PRODUCT(uchar1, unsigned long long) +DECLOP_1VAR_SCALE_PRODUCT(uchar1, signed long long) + +// UNSIGNED CHAR2 + +DECLOP_2VAR_2IN_1OUT(uchar2, +) +DECLOP_2VAR_2IN_1OUT(uchar2, -) +DECLOP_2VAR_2IN_1OUT(uchar2, *) +DECLOP_2VAR_2IN_1OUT(uchar2, /) +DECLOP_2VAR_2IN_1OUT(uchar2, %) +DECLOP_2VAR_2IN_1OUT(uchar2, &) +DECLOP_2VAR_2IN_1OUT(uchar2, |) +DECLOP_2VAR_2IN_1OUT(uchar2, ^) +DECLOP_2VAR_2IN_1OUT(uchar2, <<) +DECLOP_2VAR_2IN_1OUT(uchar2, >>) + +DECLOP_2VAR_ASSIGN(uchar2, +=) +DECLOP_2VAR_ASSIGN(uchar2, -=) +DECLOP_2VAR_ASSIGN(uchar2, *=) +DECLOP_2VAR_ASSIGN(uchar2, /=) +DECLOP_2VAR_ASSIGN(uchar2, %=) +DECLOP_2VAR_ASSIGN(uchar2, &=) +DECLOP_2VAR_ASSIGN(uchar2, |=) +DECLOP_2VAR_ASSIGN(uchar2, ^=) +DECLOP_2VAR_ASSIGN(uchar2, <<=) +DECLOP_2VAR_ASSIGN(uchar2, >>=) + +DECLOP_2VAR_PREOP(uchar2, ++) +DECLOP_2VAR_PREOP(uchar2, --) + +DECLOP_2VAR_POSTOP(uchar2, ++) +DECLOP_2VAR_POSTOP(uchar2, --) + +DECLOP_2VAR_COMP(uchar2, ==) +DECLOP_2VAR_COMP(uchar2, !=) +DECLOP_2VAR_COMP(uchar2, <) +DECLOP_2VAR_COMP(uchar2, >) +DECLOP_2VAR_COMP(uchar2, <=) +DECLOP_2VAR_COMP(uchar2, >=) + +DECLOP_2VAR_COMP(uchar2, &&) +DECLOP_2VAR_COMP(uchar2, ||) + +DECLOP_2VAR_1IN_1OUT(uchar2, ~) +DECLOP_2VAR_1IN_BOOLOUT(uchar2, !) + +DECLOP_2VAR_SCALE_PRODUCT(uchar2, unsigned char) +DECLOP_2VAR_SCALE_PRODUCT(uchar2, signed char) +DECLOP_2VAR_SCALE_PRODUCT(uchar2, unsigned short) +DECLOP_2VAR_SCALE_PRODUCT(uchar2, signed short) +DECLOP_2VAR_SCALE_PRODUCT(uchar2, unsigned int) +DECLOP_2VAR_SCALE_PRODUCT(uchar2, signed int) +DECLOP_2VAR_SCALE_PRODUCT(uchar2, float) +DECLOP_2VAR_SCALE_PRODUCT(uchar2, unsigned long) +DECLOP_2VAR_SCALE_PRODUCT(uchar2, signed long) +DECLOP_2VAR_SCALE_PRODUCT(uchar2, double) +DECLOP_2VAR_SCALE_PRODUCT(uchar2, unsigned long long) +DECLOP_2VAR_SCALE_PRODUCT(uchar2, signed long long) + +// UNSIGNED CHAR3 + +DECLOP_3VAR_2IN_1OUT(uchar3, +) +DECLOP_3VAR_2IN_1OUT(uchar3, -) +DECLOP_3VAR_2IN_1OUT(uchar3, *) +DECLOP_3VAR_2IN_1OUT(uchar3, /) +DECLOP_3VAR_2IN_1OUT(uchar3, %) +DECLOP_3VAR_2IN_1OUT(uchar3, &) +DECLOP_3VAR_2IN_1OUT(uchar3, |) +DECLOP_3VAR_2IN_1OUT(uchar3, ^) +DECLOP_3VAR_2IN_1OUT(uchar3, <<) +DECLOP_3VAR_2IN_1OUT(uchar3, >>) + +DECLOP_3VAR_ASSIGN(uchar3, +=) +DECLOP_3VAR_ASSIGN(uchar3, -=) +DECLOP_3VAR_ASSIGN(uchar3, *=) +DECLOP_3VAR_ASSIGN(uchar3, /=) +DECLOP_3VAR_ASSIGN(uchar3, %=) +DECLOP_3VAR_ASSIGN(uchar3, &=) +DECLOP_3VAR_ASSIGN(uchar3, |=) +DECLOP_3VAR_ASSIGN(uchar3, ^=) +DECLOP_3VAR_ASSIGN(uchar3, <<=) +DECLOP_3VAR_ASSIGN(uchar3, >>=) + +DECLOP_3VAR_PREOP(uchar3, ++) +DECLOP_3VAR_PREOP(uchar3, --) + +DECLOP_3VAR_POSTOP(uchar3, ++) +DECLOP_3VAR_POSTOP(uchar3, --) + +DECLOP_3VAR_COMP(uchar3, ==) +DECLOP_3VAR_COMP(uchar3, !=) +DECLOP_3VAR_COMP(uchar3, <) +DECLOP_3VAR_COMP(uchar3, >) +DECLOP_3VAR_COMP(uchar3, <=) +DECLOP_3VAR_COMP(uchar3, >=) + +DECLOP_3VAR_COMP(uchar3, &&) +DECLOP_3VAR_COMP(uchar3, ||) + +DECLOP_3VAR_1IN_1OUT(uchar3, ~) +DECLOP_3VAR_1IN_BOOLOUT(uchar3, !) + +DECLOP_3VAR_SCALE_PRODUCT(uchar3, unsigned char) +DECLOP_3VAR_SCALE_PRODUCT(uchar3, signed char) +DECLOP_3VAR_SCALE_PRODUCT(uchar3, unsigned short) +DECLOP_3VAR_SCALE_PRODUCT(uchar3, signed short) +DECLOP_3VAR_SCALE_PRODUCT(uchar3, unsigned int) +DECLOP_3VAR_SCALE_PRODUCT(uchar3, signed int) +DECLOP_3VAR_SCALE_PRODUCT(uchar3, float) +DECLOP_3VAR_SCALE_PRODUCT(uchar3, unsigned long) +DECLOP_3VAR_SCALE_PRODUCT(uchar3, signed long) +DECLOP_3VAR_SCALE_PRODUCT(uchar3, double) +DECLOP_3VAR_SCALE_PRODUCT(uchar3, unsigned long long) +DECLOP_3VAR_SCALE_PRODUCT(uchar3, signed long long) + +// UNSIGNED CHAR4 + +DECLOP_4VAR_2IN_1OUT(uchar4, +) +DECLOP_4VAR_2IN_1OUT(uchar4, -) +DECLOP_4VAR_2IN_1OUT(uchar4, *) +DECLOP_4VAR_2IN_1OUT(uchar4, /) +DECLOP_4VAR_2IN_1OUT(uchar4, %) +DECLOP_4VAR_2IN_1OUT(uchar4, &) +DECLOP_4VAR_2IN_1OUT(uchar4, |) +DECLOP_4VAR_2IN_1OUT(uchar4, ^) +DECLOP_4VAR_2IN_1OUT(uchar4, <<) +DECLOP_4VAR_2IN_1OUT(uchar4, >>) + +DECLOP_4VAR_ASSIGN(uchar4, +=) +DECLOP_4VAR_ASSIGN(uchar4, -=) +DECLOP_4VAR_ASSIGN(uchar4, *=) +DECLOP_4VAR_ASSIGN(uchar4, /=) +DECLOP_4VAR_ASSIGN(uchar4, %=) +DECLOP_4VAR_ASSIGN(uchar4, &=) +DECLOP_4VAR_ASSIGN(uchar4, |=) +DECLOP_4VAR_ASSIGN(uchar4, ^=) +DECLOP_4VAR_ASSIGN(uchar4, <<=) +DECLOP_4VAR_ASSIGN(uchar4, >>=) + +DECLOP_4VAR_PREOP(uchar4, ++) +DECLOP_4VAR_PREOP(uchar4, --) + +DECLOP_4VAR_POSTOP(uchar4, ++) +DECLOP_4VAR_POSTOP(uchar4, --) + +DECLOP_4VAR_COMP(uchar4, ==) +DECLOP_4VAR_COMP(uchar4, !=) +DECLOP_4VAR_COMP(uchar4, <) +DECLOP_4VAR_COMP(uchar4, >) +DECLOP_4VAR_COMP(uchar4, <=) +DECLOP_4VAR_COMP(uchar4, >=) + +DECLOP_4VAR_COMP(uchar4, &&) +DECLOP_4VAR_COMP(uchar4, ||) + +DECLOP_4VAR_1IN_1OUT(uchar4, ~) +DECLOP_4VAR_1IN_BOOLOUT(uchar4, !) + +DECLOP_4VAR_SCALE_PRODUCT(uchar4, unsigned char) +DECLOP_4VAR_SCALE_PRODUCT(uchar4, signed char) +DECLOP_4VAR_SCALE_PRODUCT(uchar4, unsigned short) +DECLOP_4VAR_SCALE_PRODUCT(uchar4, signed short) +DECLOP_4VAR_SCALE_PRODUCT(uchar4, unsigned int) +DECLOP_4VAR_SCALE_PRODUCT(uchar4, signed int) +DECLOP_4VAR_SCALE_PRODUCT(uchar4, float) +DECLOP_4VAR_SCALE_PRODUCT(uchar4, unsigned long) +DECLOP_4VAR_SCALE_PRODUCT(uchar4, signed long) +DECLOP_4VAR_SCALE_PRODUCT(uchar4, double) +DECLOP_4VAR_SCALE_PRODUCT(uchar4, unsigned long long) +DECLOP_4VAR_SCALE_PRODUCT(uchar4, signed long long) + +// SIGNED CHAR1 + +DECLOP_1VAR_2IN_1OUT(char1, +) +DECLOP_1VAR_2IN_1OUT(char1, -) +DECLOP_1VAR_2IN_1OUT(char1, *) +DECLOP_1VAR_2IN_1OUT(char1, /) +DECLOP_1VAR_2IN_1OUT(char1, %) +DECLOP_1VAR_2IN_1OUT(char1, &) +DECLOP_1VAR_2IN_1OUT(char1, |) +DECLOP_1VAR_2IN_1OUT(char1, ^) +DECLOP_1VAR_2IN_1OUT(char1, <<) +DECLOP_1VAR_2IN_1OUT(char1, >>) + + +DECLOP_1VAR_ASSIGN(char1, +=) +DECLOP_1VAR_ASSIGN(char1, -=) +DECLOP_1VAR_ASSIGN(char1, *=) +DECLOP_1VAR_ASSIGN(char1, /=) +DECLOP_1VAR_ASSIGN(char1, %=) +DECLOP_1VAR_ASSIGN(char1, &=) +DECLOP_1VAR_ASSIGN(char1, |=) +DECLOP_1VAR_ASSIGN(char1, ^=) +DECLOP_1VAR_ASSIGN(char1, <<=) +DECLOP_1VAR_ASSIGN(char1, >>=) + +DECLOP_1VAR_PREOP(char1, ++) +DECLOP_1VAR_PREOP(char1, --) + +DECLOP_1VAR_POSTOP(char1, ++) +DECLOP_1VAR_POSTOP(char1, --) + +DECLOP_1VAR_COMP(char1, ==) +DECLOP_1VAR_COMP(char1, !=) +DECLOP_1VAR_COMP(char1, <) +DECLOP_1VAR_COMP(char1, >) +DECLOP_1VAR_COMP(char1, <=) +DECLOP_1VAR_COMP(char1, >=) + +DECLOP_1VAR_COMP(char1, &&) +DECLOP_1VAR_COMP(char1, ||) + +DECLOP_1VAR_1IN_1OUT(char1, ~) +DECLOP_1VAR_1IN_BOOLOUT(char1, !) + +DECLOP_1VAR_SCALE_PRODUCT(char1, unsigned char) +DECLOP_1VAR_SCALE_PRODUCT(char1, signed char) +DECLOP_1VAR_SCALE_PRODUCT(char1, unsigned short) +DECLOP_1VAR_SCALE_PRODUCT(char1, signed short) +DECLOP_1VAR_SCALE_PRODUCT(char1, unsigned int) +DECLOP_1VAR_SCALE_PRODUCT(char1, signed int) +DECLOP_1VAR_SCALE_PRODUCT(char1, float) +DECLOP_1VAR_SCALE_PRODUCT(char1, unsigned long) +DECLOP_1VAR_SCALE_PRODUCT(char1, signed long) +DECLOP_1VAR_SCALE_PRODUCT(char1, double) +DECLOP_1VAR_SCALE_PRODUCT(char1, unsigned long long) +DECLOP_1VAR_SCALE_PRODUCT(char1, signed long long) + +// SIGNED CHAR2 + +DECLOP_2VAR_2IN_1OUT(char2, +) +DECLOP_2VAR_2IN_1OUT(char2, -) +DECLOP_2VAR_2IN_1OUT(char2, *) +DECLOP_2VAR_2IN_1OUT(char2, /) +DECLOP_2VAR_2IN_1OUT(char2, %) +DECLOP_2VAR_2IN_1OUT(char2, &) +DECLOP_2VAR_2IN_1OUT(char2, |) +DECLOP_2VAR_2IN_1OUT(char2, ^) +DECLOP_2VAR_2IN_1OUT(char2, <<) +DECLOP_2VAR_2IN_1OUT(char2, >>) + +DECLOP_2VAR_ASSIGN(char2, +=) +DECLOP_2VAR_ASSIGN(char2, -=) +DECLOP_2VAR_ASSIGN(char2, *=) +DECLOP_2VAR_ASSIGN(char2, /=) +DECLOP_2VAR_ASSIGN(char2, %=) +DECLOP_2VAR_ASSIGN(char2, &=) +DECLOP_2VAR_ASSIGN(char2, |=) +DECLOP_2VAR_ASSIGN(char2, ^=) +DECLOP_2VAR_ASSIGN(char2, <<=) +DECLOP_2VAR_ASSIGN(char2, >>=) + +DECLOP_2VAR_PREOP(char2, ++) +DECLOP_2VAR_PREOP(char2, --) + +DECLOP_2VAR_POSTOP(char2, ++) +DECLOP_2VAR_POSTOP(char2, --) + +DECLOP_2VAR_COMP(char2, ==) +DECLOP_2VAR_COMP(char2, !=) +DECLOP_2VAR_COMP(char2, <) +DECLOP_2VAR_COMP(char2, >) +DECLOP_2VAR_COMP(char2, <=) +DECLOP_2VAR_COMP(char2, >=) + +DECLOP_2VAR_COMP(char2, &&) +DECLOP_2VAR_COMP(char2, ||) + +DECLOP_2VAR_1IN_1OUT(char2, ~) +DECLOP_2VAR_1IN_BOOLOUT(char2, !) + +DECLOP_2VAR_SCALE_PRODUCT(char2, unsigned char) +DECLOP_2VAR_SCALE_PRODUCT(char2, signed char) +DECLOP_2VAR_SCALE_PRODUCT(char2, unsigned short) +DECLOP_2VAR_SCALE_PRODUCT(char2, signed short) +DECLOP_2VAR_SCALE_PRODUCT(char2, unsigned int) +DECLOP_2VAR_SCALE_PRODUCT(char2, signed int) +DECLOP_2VAR_SCALE_PRODUCT(char2, float) +DECLOP_2VAR_SCALE_PRODUCT(char2, unsigned long) +DECLOP_2VAR_SCALE_PRODUCT(char2, signed long) +DECLOP_2VAR_SCALE_PRODUCT(char2, double) +DECLOP_2VAR_SCALE_PRODUCT(char2, unsigned long long) +DECLOP_2VAR_SCALE_PRODUCT(char2, signed long long) + +// SIGNED CHAR3 + +DECLOP_3VAR_2IN_1OUT(char3, +) +DECLOP_3VAR_2IN_1OUT(char3, -) +DECLOP_3VAR_2IN_1OUT(char3, *) +DECLOP_3VAR_2IN_1OUT(char3, /) +DECLOP_3VAR_2IN_1OUT(char3, %) +DECLOP_3VAR_2IN_1OUT(char3, &) +DECLOP_3VAR_2IN_1OUT(char3, |) +DECLOP_3VAR_2IN_1OUT(char3, ^) +DECLOP_3VAR_2IN_1OUT(char3, <<) +DECLOP_3VAR_2IN_1OUT(char3, >>) + +DECLOP_3VAR_ASSIGN(char3, +=) +DECLOP_3VAR_ASSIGN(char3, -=) +DECLOP_3VAR_ASSIGN(char3, *=) +DECLOP_3VAR_ASSIGN(char3, /=) +DECLOP_3VAR_ASSIGN(char3, %=) +DECLOP_3VAR_ASSIGN(char3, &=) +DECLOP_3VAR_ASSIGN(char3, |=) +DECLOP_3VAR_ASSIGN(char3, ^=) +DECLOP_3VAR_ASSIGN(char3, <<=) +DECLOP_3VAR_ASSIGN(char3, >>=) + +DECLOP_3VAR_PREOP(char3, ++) +DECLOP_3VAR_PREOP(char3, --) + +DECLOP_3VAR_POSTOP(char3, ++) +DECLOP_3VAR_POSTOP(char3, --) + +DECLOP_3VAR_COMP(char3, ==) +DECLOP_3VAR_COMP(char3, !=) +DECLOP_3VAR_COMP(char3, <) +DECLOP_3VAR_COMP(char3, >) +DECLOP_3VAR_COMP(char3, <=) +DECLOP_3VAR_COMP(char3, >=) + +DECLOP_3VAR_COMP(char3, &&) +DECLOP_3VAR_COMP(char3, ||) + +DECLOP_3VAR_1IN_1OUT(char3, ~) +DECLOP_3VAR_1IN_BOOLOUT(char3, !) + +DECLOP_3VAR_SCALE_PRODUCT(char3, unsigned char) +DECLOP_3VAR_SCALE_PRODUCT(char3, signed char) +DECLOP_3VAR_SCALE_PRODUCT(char3, unsigned short) +DECLOP_3VAR_SCALE_PRODUCT(char3, signed short) +DECLOP_3VAR_SCALE_PRODUCT(char3, unsigned int) +DECLOP_3VAR_SCALE_PRODUCT(char3, signed int) +DECLOP_3VAR_SCALE_PRODUCT(char3, float) +DECLOP_3VAR_SCALE_PRODUCT(char3, unsigned long) +DECLOP_3VAR_SCALE_PRODUCT(char3, signed long) +DECLOP_3VAR_SCALE_PRODUCT(char3, double) +DECLOP_3VAR_SCALE_PRODUCT(char3, unsigned long long) +DECLOP_3VAR_SCALE_PRODUCT(char3, signed long long) + +// SIGNED CHAR4 + +DECLOP_4VAR_2IN_1OUT(char4, +) +DECLOP_4VAR_2IN_1OUT(char4, -) +DECLOP_4VAR_2IN_1OUT(char4, *) +DECLOP_4VAR_2IN_1OUT(char4, /) +DECLOP_4VAR_2IN_1OUT(char4, %) +DECLOP_4VAR_2IN_1OUT(char4, &) +DECLOP_4VAR_2IN_1OUT(char4, |) +DECLOP_4VAR_2IN_1OUT(char4, ^) +DECLOP_4VAR_2IN_1OUT(char4, <<) +DECLOP_4VAR_2IN_1OUT(char4, >>) + +DECLOP_4VAR_ASSIGN(char4, +=) +DECLOP_4VAR_ASSIGN(char4, -=) +DECLOP_4VAR_ASSIGN(char4, *=) +DECLOP_4VAR_ASSIGN(char4, /=) +DECLOP_4VAR_ASSIGN(char4, %=) +DECLOP_4VAR_ASSIGN(char4, &=) +DECLOP_4VAR_ASSIGN(char4, |=) +DECLOP_4VAR_ASSIGN(char4, ^=) +DECLOP_4VAR_ASSIGN(char4, <<=) +DECLOP_4VAR_ASSIGN(char4, >>=) + +DECLOP_4VAR_PREOP(char4, ++) +DECLOP_4VAR_PREOP(char4, --) + +DECLOP_4VAR_POSTOP(char4, ++) +DECLOP_4VAR_POSTOP(char4, --) + +DECLOP_4VAR_COMP(char4, ==) +DECLOP_4VAR_COMP(char4, !=) +DECLOP_4VAR_COMP(char4, <) +DECLOP_4VAR_COMP(char4, >) +DECLOP_4VAR_COMP(char4, <=) +DECLOP_4VAR_COMP(char4, >=) + +DECLOP_4VAR_COMP(char4, &&) +DECLOP_4VAR_COMP(char4, ||) + +DECLOP_4VAR_1IN_1OUT(char4, ~) +DECLOP_4VAR_1IN_BOOLOUT(char4, !) + +DECLOP_4VAR_SCALE_PRODUCT(char4, unsigned char) +DECLOP_4VAR_SCALE_PRODUCT(char4, signed char) +DECLOP_4VAR_SCALE_PRODUCT(char4, unsigned short) +DECLOP_4VAR_SCALE_PRODUCT(char4, signed short) +DECLOP_4VAR_SCALE_PRODUCT(char4, unsigned int) +DECLOP_4VAR_SCALE_PRODUCT(char4, signed int) +DECLOP_4VAR_SCALE_PRODUCT(char4, float) +DECLOP_4VAR_SCALE_PRODUCT(char4, unsigned long) +DECLOP_4VAR_SCALE_PRODUCT(char4, signed long) +DECLOP_4VAR_SCALE_PRODUCT(char4, double) +DECLOP_4VAR_SCALE_PRODUCT(char4, unsigned long long) +DECLOP_4VAR_SCALE_PRODUCT(char4, signed long long) + +// UNSIGNED SHORT1 + +DECLOP_1VAR_2IN_1OUT(ushort1, +) +DECLOP_1VAR_2IN_1OUT(ushort1, -) +DECLOP_1VAR_2IN_1OUT(ushort1, *) +DECLOP_1VAR_2IN_1OUT(ushort1, /) +DECLOP_1VAR_2IN_1OUT(ushort1, %) +DECLOP_1VAR_2IN_1OUT(ushort1, &) +DECLOP_1VAR_2IN_1OUT(ushort1, |) +DECLOP_1VAR_2IN_1OUT(ushort1, ^) +DECLOP_1VAR_2IN_1OUT(ushort1, <<) +DECLOP_1VAR_2IN_1OUT(ushort1, >>) + + +DECLOP_1VAR_ASSIGN(ushort1, +=) +DECLOP_1VAR_ASSIGN(ushort1, -=) +DECLOP_1VAR_ASSIGN(ushort1, *=) +DECLOP_1VAR_ASSIGN(ushort1, /=) +DECLOP_1VAR_ASSIGN(ushort1, %=) +DECLOP_1VAR_ASSIGN(ushort1, &=) +DECLOP_1VAR_ASSIGN(ushort1, |=) +DECLOP_1VAR_ASSIGN(ushort1, ^=) +DECLOP_1VAR_ASSIGN(ushort1, <<=) +DECLOP_1VAR_ASSIGN(ushort1, >>=) + +DECLOP_1VAR_PREOP(ushort1, ++) +DECLOP_1VAR_PREOP(ushort1, --) + +DECLOP_1VAR_POSTOP(ushort1, ++) +DECLOP_1VAR_POSTOP(ushort1, --) + +DECLOP_1VAR_COMP(ushort1, ==) +DECLOP_1VAR_COMP(ushort1, !=) +DECLOP_1VAR_COMP(ushort1, <) +DECLOP_1VAR_COMP(ushort1, >) +DECLOP_1VAR_COMP(ushort1, <=) +DECLOP_1VAR_COMP(ushort1, >=) + +DECLOP_1VAR_COMP(ushort1, &&) +DECLOP_1VAR_COMP(ushort1, ||) + +DECLOP_1VAR_1IN_1OUT(ushort1, ~) +DECLOP_1VAR_1IN_BOOLOUT(ushort1, !) + +DECLOP_1VAR_SCALE_PRODUCT(ushort1, unsigned char) +DECLOP_1VAR_SCALE_PRODUCT(ushort1, signed char) +DECLOP_1VAR_SCALE_PRODUCT(ushort1, unsigned short) +DECLOP_1VAR_SCALE_PRODUCT(ushort1, signed short) +DECLOP_1VAR_SCALE_PRODUCT(ushort1, unsigned int) +DECLOP_1VAR_SCALE_PRODUCT(ushort1, signed int) +DECLOP_1VAR_SCALE_PRODUCT(ushort1, float) +DECLOP_1VAR_SCALE_PRODUCT(ushort1, unsigned long) +DECLOP_1VAR_SCALE_PRODUCT(ushort1, signed long) +DECLOP_1VAR_SCALE_PRODUCT(ushort1, double) +DECLOP_1VAR_SCALE_PRODUCT(ushort1, unsigned long long) +DECLOP_1VAR_SCALE_PRODUCT(ushort1, signed long long) + +// UNSIGNED SHORT2 + +DECLOP_2VAR_2IN_1OUT(ushort2, +) +DECLOP_2VAR_2IN_1OUT(ushort2, -) +DECLOP_2VAR_2IN_1OUT(ushort2, *) +DECLOP_2VAR_2IN_1OUT(ushort2, /) +DECLOP_2VAR_2IN_1OUT(ushort2, %) +DECLOP_2VAR_2IN_1OUT(ushort2, &) +DECLOP_2VAR_2IN_1OUT(ushort2, |) +DECLOP_2VAR_2IN_1OUT(ushort2, ^) +DECLOP_2VAR_2IN_1OUT(ushort2, <<) +DECLOP_2VAR_2IN_1OUT(ushort2, >>) + +DECLOP_2VAR_ASSIGN(ushort2, +=) +DECLOP_2VAR_ASSIGN(ushort2, -=) +DECLOP_2VAR_ASSIGN(ushort2, *=) +DECLOP_2VAR_ASSIGN(ushort2, /=) +DECLOP_2VAR_ASSIGN(ushort2, %=) +DECLOP_2VAR_ASSIGN(ushort2, &=) +DECLOP_2VAR_ASSIGN(ushort2, |=) +DECLOP_2VAR_ASSIGN(ushort2, ^=) +DECLOP_2VAR_ASSIGN(ushort2, <<=) +DECLOP_2VAR_ASSIGN(ushort2, >>=) + +DECLOP_2VAR_PREOP(ushort2, ++) +DECLOP_2VAR_PREOP(ushort2, --) + +DECLOP_2VAR_POSTOP(ushort2, ++) +DECLOP_2VAR_POSTOP(ushort2, --) + +DECLOP_2VAR_COMP(ushort2, ==) +DECLOP_2VAR_COMP(ushort2, !=) +DECLOP_2VAR_COMP(ushort2, <) +DECLOP_2VAR_COMP(ushort2, >) +DECLOP_2VAR_COMP(ushort2, <=) +DECLOP_2VAR_COMP(ushort2, >=) + +DECLOP_2VAR_COMP(ushort2, &&) +DECLOP_2VAR_COMP(ushort2, ||) + +DECLOP_2VAR_1IN_1OUT(ushort2, ~) +DECLOP_2VAR_1IN_BOOLOUT(ushort2, !) + +DECLOP_2VAR_SCALE_PRODUCT(ushort2, unsigned char) +DECLOP_2VAR_SCALE_PRODUCT(ushort2, signed char) +DECLOP_2VAR_SCALE_PRODUCT(ushort2, unsigned short) +DECLOP_2VAR_SCALE_PRODUCT(ushort2, signed short) +DECLOP_2VAR_SCALE_PRODUCT(ushort2, unsigned int) +DECLOP_2VAR_SCALE_PRODUCT(ushort2, signed int) +DECLOP_2VAR_SCALE_PRODUCT(ushort2, float) +DECLOP_2VAR_SCALE_PRODUCT(ushort2, unsigned long) +DECLOP_2VAR_SCALE_PRODUCT(ushort2, signed long) +DECLOP_2VAR_SCALE_PRODUCT(ushort2, double) +DECLOP_2VAR_SCALE_PRODUCT(ushort2, unsigned long long) +DECLOP_2VAR_SCALE_PRODUCT(ushort2, signed long long) + +// UNSIGNED SHORT3 + +DECLOP_3VAR_2IN_1OUT(ushort3, +) +DECLOP_3VAR_2IN_1OUT(ushort3, -) +DECLOP_3VAR_2IN_1OUT(ushort3, *) +DECLOP_3VAR_2IN_1OUT(ushort3, /) +DECLOP_3VAR_2IN_1OUT(ushort3, %) +DECLOP_3VAR_2IN_1OUT(ushort3, &) +DECLOP_3VAR_2IN_1OUT(ushort3, |) +DECLOP_3VAR_2IN_1OUT(ushort3, ^) +DECLOP_3VAR_2IN_1OUT(ushort3, <<) +DECLOP_3VAR_2IN_1OUT(ushort3, >>) + +DECLOP_3VAR_ASSIGN(ushort3, +=) +DECLOP_3VAR_ASSIGN(ushort3, -=) +DECLOP_3VAR_ASSIGN(ushort3, *=) +DECLOP_3VAR_ASSIGN(ushort3, /=) +DECLOP_3VAR_ASSIGN(ushort3, %=) +DECLOP_3VAR_ASSIGN(ushort3, &=) +DECLOP_3VAR_ASSIGN(ushort3, |=) +DECLOP_3VAR_ASSIGN(ushort3, ^=) +DECLOP_3VAR_ASSIGN(ushort3, <<=) +DECLOP_3VAR_ASSIGN(ushort3, >>=) + +DECLOP_3VAR_PREOP(ushort3, ++) +DECLOP_3VAR_PREOP(ushort3, --) + +DECLOP_3VAR_POSTOP(ushort3, ++) +DECLOP_3VAR_POSTOP(ushort3, --) + +DECLOP_3VAR_COMP(ushort3, ==) +DECLOP_3VAR_COMP(ushort3, !=) +DECLOP_3VAR_COMP(ushort3, <) +DECLOP_3VAR_COMP(ushort3, >) +DECLOP_3VAR_COMP(ushort3, <=) +DECLOP_3VAR_COMP(ushort3, >=) + +DECLOP_3VAR_COMP(ushort3, &&) +DECLOP_3VAR_COMP(ushort3, ||) + +DECLOP_3VAR_1IN_1OUT(ushort3, ~) +DECLOP_3VAR_1IN_BOOLOUT(ushort3, !) + +DECLOP_3VAR_SCALE_PRODUCT(ushort3, unsigned char) +DECLOP_3VAR_SCALE_PRODUCT(ushort3, signed char) +DECLOP_3VAR_SCALE_PRODUCT(ushort3, unsigned short) +DECLOP_3VAR_SCALE_PRODUCT(ushort3, signed short) +DECLOP_3VAR_SCALE_PRODUCT(ushort3, unsigned int) +DECLOP_3VAR_SCALE_PRODUCT(ushort3, signed int) +DECLOP_3VAR_SCALE_PRODUCT(ushort3, float) +DECLOP_3VAR_SCALE_PRODUCT(ushort3, unsigned long) +DECLOP_3VAR_SCALE_PRODUCT(ushort3, signed long) +DECLOP_3VAR_SCALE_PRODUCT(ushort3, double) +DECLOP_3VAR_SCALE_PRODUCT(ushort3, unsigned long long) +DECLOP_3VAR_SCALE_PRODUCT(ushort3, signed long long) + +// UNSIGNED SHORT4 + +DECLOP_4VAR_2IN_1OUT(ushort4, +) +DECLOP_4VAR_2IN_1OUT(ushort4, -) +DECLOP_4VAR_2IN_1OUT(ushort4, *) +DECLOP_4VAR_2IN_1OUT(ushort4, /) +DECLOP_4VAR_2IN_1OUT(ushort4, %) +DECLOP_4VAR_2IN_1OUT(ushort4, &) +DECLOP_4VAR_2IN_1OUT(ushort4, |) +DECLOP_4VAR_2IN_1OUT(ushort4, ^) +DECLOP_4VAR_2IN_1OUT(ushort4, <<) +DECLOP_4VAR_2IN_1OUT(ushort4, >>) + +DECLOP_4VAR_ASSIGN(ushort4, +=) +DECLOP_4VAR_ASSIGN(ushort4, -=) +DECLOP_4VAR_ASSIGN(ushort4, *=) +DECLOP_4VAR_ASSIGN(ushort4, /=) +DECLOP_4VAR_ASSIGN(ushort4, %=) +DECLOP_4VAR_ASSIGN(ushort4, &=) +DECLOP_4VAR_ASSIGN(ushort4, |=) +DECLOP_4VAR_ASSIGN(ushort4, ^=) +DECLOP_4VAR_ASSIGN(ushort4, <<=) +DECLOP_4VAR_ASSIGN(ushort4, >>=) + +DECLOP_4VAR_PREOP(ushort4, ++) +DECLOP_4VAR_PREOP(ushort4, --) + +DECLOP_4VAR_POSTOP(ushort4, ++) +DECLOP_4VAR_POSTOP(ushort4, --) + +DECLOP_4VAR_COMP(ushort4, ==) +DECLOP_4VAR_COMP(ushort4, !=) +DECLOP_4VAR_COMP(ushort4, <) +DECLOP_4VAR_COMP(ushort4, >) +DECLOP_4VAR_COMP(ushort4, <=) +DECLOP_4VAR_COMP(ushort4, >=) + +DECLOP_4VAR_COMP(ushort4, &&) +DECLOP_4VAR_COMP(ushort4, ||) + +DECLOP_4VAR_1IN_1OUT(ushort4, ~) +DECLOP_4VAR_1IN_BOOLOUT(ushort4, !) + +DECLOP_4VAR_SCALE_PRODUCT(ushort4, unsigned char) +DECLOP_4VAR_SCALE_PRODUCT(ushort4, signed char) +DECLOP_4VAR_SCALE_PRODUCT(ushort4, unsigned short) +DECLOP_4VAR_SCALE_PRODUCT(ushort4, signed short) +DECLOP_4VAR_SCALE_PRODUCT(ushort4, unsigned int) +DECLOP_4VAR_SCALE_PRODUCT(ushort4, signed int) +DECLOP_4VAR_SCALE_PRODUCT(ushort4, float) +DECLOP_4VAR_SCALE_PRODUCT(ushort4, unsigned long) +DECLOP_4VAR_SCALE_PRODUCT(ushort4, signed long) +DECLOP_4VAR_SCALE_PRODUCT(ushort4, double) +DECLOP_4VAR_SCALE_PRODUCT(ushort4, unsigned long long) +DECLOP_4VAR_SCALE_PRODUCT(ushort4, signed long long) + +// SIGNED SHORT1 + +DECLOP_1VAR_2IN_1OUT(short1, +) +DECLOP_1VAR_2IN_1OUT(short1, -) +DECLOP_1VAR_2IN_1OUT(short1, *) +DECLOP_1VAR_2IN_1OUT(short1, /) +DECLOP_1VAR_2IN_1OUT(short1, %) +DECLOP_1VAR_2IN_1OUT(short1, &) +DECLOP_1VAR_2IN_1OUT(short1, |) +DECLOP_1VAR_2IN_1OUT(short1, ^) +DECLOP_1VAR_2IN_1OUT(short1, <<) +DECLOP_1VAR_2IN_1OUT(short1, >>) + + +DECLOP_1VAR_ASSIGN(short1, +=) +DECLOP_1VAR_ASSIGN(short1, -=) +DECLOP_1VAR_ASSIGN(short1, *=) +DECLOP_1VAR_ASSIGN(short1, /=) +DECLOP_1VAR_ASSIGN(short1, %=) +DECLOP_1VAR_ASSIGN(short1, &=) +DECLOP_1VAR_ASSIGN(short1, |=) +DECLOP_1VAR_ASSIGN(short1, ^=) +DECLOP_1VAR_ASSIGN(short1, <<=) +DECLOP_1VAR_ASSIGN(short1, >>=) + +DECLOP_1VAR_PREOP(short1, ++) +DECLOP_1VAR_PREOP(short1, --) + +DECLOP_1VAR_POSTOP(short1, ++) +DECLOP_1VAR_POSTOP(short1, --) + +DECLOP_1VAR_COMP(short1, ==) +DECLOP_1VAR_COMP(short1, !=) +DECLOP_1VAR_COMP(short1, <) +DECLOP_1VAR_COMP(short1, >) +DECLOP_1VAR_COMP(short1, <=) +DECLOP_1VAR_COMP(short1, >=) + +DECLOP_1VAR_COMP(short1, &&) +DECLOP_1VAR_COMP(short1, ||) + +DECLOP_1VAR_1IN_1OUT(short1, ~) +DECLOP_1VAR_1IN_BOOLOUT(short1, !) + +DECLOP_1VAR_SCALE_PRODUCT(short1, unsigned char) +DECLOP_1VAR_SCALE_PRODUCT(short1, signed char) +DECLOP_1VAR_SCALE_PRODUCT(short1, unsigned short) +DECLOP_1VAR_SCALE_PRODUCT(short1, signed short) +DECLOP_1VAR_SCALE_PRODUCT(short1, unsigned int) +DECLOP_1VAR_SCALE_PRODUCT(short1, signed int) +DECLOP_1VAR_SCALE_PRODUCT(short1, float) +DECLOP_1VAR_SCALE_PRODUCT(short1, unsigned long) +DECLOP_1VAR_SCALE_PRODUCT(short1, signed long) +DECLOP_1VAR_SCALE_PRODUCT(short1, double) +DECLOP_1VAR_SCALE_PRODUCT(short1, unsigned long long) +DECLOP_1VAR_SCALE_PRODUCT(short1, signed long long) + +// SIGNED SHORT2 + +DECLOP_2VAR_2IN_1OUT(short2, +) +DECLOP_2VAR_2IN_1OUT(short2, -) +DECLOP_2VAR_2IN_1OUT(short2, *) +DECLOP_2VAR_2IN_1OUT(short2, /) +DECLOP_2VAR_2IN_1OUT(short2, %) +DECLOP_2VAR_2IN_1OUT(short2, &) +DECLOP_2VAR_2IN_1OUT(short2, |) +DECLOP_2VAR_2IN_1OUT(short2, ^) +DECLOP_2VAR_2IN_1OUT(short2, <<) +DECLOP_2VAR_2IN_1OUT(short2, >>) + +DECLOP_2VAR_ASSIGN(short2, +=) +DECLOP_2VAR_ASSIGN(short2, -=) +DECLOP_2VAR_ASSIGN(short2, *=) +DECLOP_2VAR_ASSIGN(short2, /=) +DECLOP_2VAR_ASSIGN(short2, %=) +DECLOP_2VAR_ASSIGN(short2, &=) +DECLOP_2VAR_ASSIGN(short2, |=) +DECLOP_2VAR_ASSIGN(short2, ^=) +DECLOP_2VAR_ASSIGN(short2, <<=) +DECLOP_2VAR_ASSIGN(short2, >>=) + +DECLOP_2VAR_PREOP(short2, ++) +DECLOP_2VAR_PREOP(short2, --) + +DECLOP_2VAR_POSTOP(short2, ++) +DECLOP_2VAR_POSTOP(short2, --) + +DECLOP_2VAR_COMP(short2, ==) +DECLOP_2VAR_COMP(short2, !=) +DECLOP_2VAR_COMP(short2, <) +DECLOP_2VAR_COMP(short2, >) +DECLOP_2VAR_COMP(short2, <=) +DECLOP_2VAR_COMP(short2, >=) + +DECLOP_2VAR_COMP(short2, &&) +DECLOP_2VAR_COMP(short2, ||) + +DECLOP_2VAR_1IN_1OUT(short2, ~) +DECLOP_2VAR_1IN_BOOLOUT(short2, !) + +DECLOP_2VAR_SCALE_PRODUCT(short2, unsigned char) +DECLOP_2VAR_SCALE_PRODUCT(short2, signed char) +DECLOP_2VAR_SCALE_PRODUCT(short2, unsigned short) +DECLOP_2VAR_SCALE_PRODUCT(short2, signed short) +DECLOP_2VAR_SCALE_PRODUCT(short2, unsigned int) +DECLOP_2VAR_SCALE_PRODUCT(short2, signed int) +DECLOP_2VAR_SCALE_PRODUCT(short2, float) +DECLOP_2VAR_SCALE_PRODUCT(short2, unsigned long) +DECLOP_2VAR_SCALE_PRODUCT(short2, signed long) +DECLOP_2VAR_SCALE_PRODUCT(short2, double) +DECLOP_2VAR_SCALE_PRODUCT(short2, unsigned long long) +DECLOP_2VAR_SCALE_PRODUCT(short2, signed long long) + +// SIGNED SHORT3 + +DECLOP_3VAR_2IN_1OUT(short3, +) +DECLOP_3VAR_2IN_1OUT(short3, -) +DECLOP_3VAR_2IN_1OUT(short3, *) +DECLOP_3VAR_2IN_1OUT(short3, /) +DECLOP_3VAR_2IN_1OUT(short3, %) +DECLOP_3VAR_2IN_1OUT(short3, &) +DECLOP_3VAR_2IN_1OUT(short3, |) +DECLOP_3VAR_2IN_1OUT(short3, ^) +DECLOP_3VAR_2IN_1OUT(short3, <<) +DECLOP_3VAR_2IN_1OUT(short3, >>) + +DECLOP_3VAR_ASSIGN(short3, +=) +DECLOP_3VAR_ASSIGN(short3, -=) +DECLOP_3VAR_ASSIGN(short3, *=) +DECLOP_3VAR_ASSIGN(short3, /=) +DECLOP_3VAR_ASSIGN(short3, %=) +DECLOP_3VAR_ASSIGN(short3, &=) +DECLOP_3VAR_ASSIGN(short3, |=) +DECLOP_3VAR_ASSIGN(short3, ^=) +DECLOP_3VAR_ASSIGN(short3, <<=) +DECLOP_3VAR_ASSIGN(short3, >>=) + +DECLOP_3VAR_PREOP(short3, ++) +DECLOP_3VAR_PREOP(short3, --) + +DECLOP_3VAR_POSTOP(short3, ++) +DECLOP_3VAR_POSTOP(short3, --) + +DECLOP_3VAR_COMP(short3, ==) +DECLOP_3VAR_COMP(short3, !=) +DECLOP_3VAR_COMP(short3, <) +DECLOP_3VAR_COMP(short3, >) +DECLOP_3VAR_COMP(short3, <=) +DECLOP_3VAR_COMP(short3, >=) + +DECLOP_3VAR_COMP(short3, &&) +DECLOP_3VAR_COMP(short3, ||) + +DECLOP_3VAR_1IN_1OUT(short3, ~) +DECLOP_3VAR_1IN_BOOLOUT(short3, !) + +DECLOP_3VAR_SCALE_PRODUCT(short3, unsigned char) +DECLOP_3VAR_SCALE_PRODUCT(short3, signed char) +DECLOP_3VAR_SCALE_PRODUCT(short3, unsigned short) +DECLOP_3VAR_SCALE_PRODUCT(short3, signed short) +DECLOP_3VAR_SCALE_PRODUCT(short3, unsigned int) +DECLOP_3VAR_SCALE_PRODUCT(short3, signed int) +DECLOP_3VAR_SCALE_PRODUCT(short3, float) +DECLOP_3VAR_SCALE_PRODUCT(short3, unsigned long) +DECLOP_3VAR_SCALE_PRODUCT(short3, signed long) +DECLOP_3VAR_SCALE_PRODUCT(short3, double) +DECLOP_3VAR_SCALE_PRODUCT(short3, unsigned long long) +DECLOP_3VAR_SCALE_PRODUCT(short3, signed long long) + +// SIGNED SHORT4 + +DECLOP_4VAR_2IN_1OUT(short4, +) +DECLOP_4VAR_2IN_1OUT(short4, -) +DECLOP_4VAR_2IN_1OUT(short4, *) +DECLOP_4VAR_2IN_1OUT(short4, /) +DECLOP_4VAR_2IN_1OUT(short4, %) +DECLOP_4VAR_2IN_1OUT(short4, &) +DECLOP_4VAR_2IN_1OUT(short4, |) +DECLOP_4VAR_2IN_1OUT(short4, ^) +DECLOP_4VAR_2IN_1OUT(short4, <<) +DECLOP_4VAR_2IN_1OUT(short4, >>) + +DECLOP_4VAR_ASSIGN(short4, +=) +DECLOP_4VAR_ASSIGN(short4, -=) +DECLOP_4VAR_ASSIGN(short4, *=) +DECLOP_4VAR_ASSIGN(short4, /=) +DECLOP_4VAR_ASSIGN(short4, %=) +DECLOP_4VAR_ASSIGN(short4, &=) +DECLOP_4VAR_ASSIGN(short4, |=) +DECLOP_4VAR_ASSIGN(short4, ^=) +DECLOP_4VAR_ASSIGN(short4, <<=) +DECLOP_4VAR_ASSIGN(short4, >>=) + +DECLOP_4VAR_PREOP(short4, ++) +DECLOP_4VAR_PREOP(short4, --) + +DECLOP_4VAR_POSTOP(short4, ++) +DECLOP_4VAR_POSTOP(short4, --) + +DECLOP_4VAR_COMP(short4, ==) +DECLOP_4VAR_COMP(short4, !=) +DECLOP_4VAR_COMP(short4, <) +DECLOP_4VAR_COMP(short4, >) +DECLOP_4VAR_COMP(short4, <=) +DECLOP_4VAR_COMP(short4, >=) + +DECLOP_4VAR_COMP(short4, &&) +DECLOP_4VAR_COMP(short4, ||) + +DECLOP_4VAR_1IN_1OUT(short4, ~) +DECLOP_4VAR_1IN_BOOLOUT(short4, !) + +DECLOP_4VAR_SCALE_PRODUCT(short4, unsigned char) +DECLOP_4VAR_SCALE_PRODUCT(short4, signed char) +DECLOP_4VAR_SCALE_PRODUCT(short4, unsigned short) +DECLOP_4VAR_SCALE_PRODUCT(short4, signed short) +DECLOP_4VAR_SCALE_PRODUCT(short4, unsigned int) +DECLOP_4VAR_SCALE_PRODUCT(short4, signed int) +DECLOP_4VAR_SCALE_PRODUCT(short4, float) +DECLOP_4VAR_SCALE_PRODUCT(short4, unsigned long) +DECLOP_4VAR_SCALE_PRODUCT(short4, signed long) +DECLOP_4VAR_SCALE_PRODUCT(short4, double) +DECLOP_4VAR_SCALE_PRODUCT(short4, unsigned long long) +DECLOP_4VAR_SCALE_PRODUCT(short4, signed long long) + +// UNSIGNED INT1 + +DECLOP_1VAR_2IN_1OUT(uint1, +) +DECLOP_1VAR_2IN_1OUT(uint1, -) +DECLOP_1VAR_2IN_1OUT(uint1, *) +DECLOP_1VAR_2IN_1OUT(uint1, /) +DECLOP_1VAR_2IN_1OUT(uint1, %) +DECLOP_1VAR_2IN_1OUT(uint1, &) +DECLOP_1VAR_2IN_1OUT(uint1, |) +DECLOP_1VAR_2IN_1OUT(uint1, ^) +DECLOP_1VAR_2IN_1OUT(uint1, <<) +DECLOP_1VAR_2IN_1OUT(uint1, >>) + + +DECLOP_1VAR_ASSIGN(uint1, +=) +DECLOP_1VAR_ASSIGN(uint1, -=) +DECLOP_1VAR_ASSIGN(uint1, *=) +DECLOP_1VAR_ASSIGN(uint1, /=) +DECLOP_1VAR_ASSIGN(uint1, %=) +DECLOP_1VAR_ASSIGN(uint1, &=) +DECLOP_1VAR_ASSIGN(uint1, |=) +DECLOP_1VAR_ASSIGN(uint1, ^=) +DECLOP_1VAR_ASSIGN(uint1, <<=) +DECLOP_1VAR_ASSIGN(uint1, >>=) + +DECLOP_1VAR_PREOP(uint1, ++) +DECLOP_1VAR_PREOP(uint1, --) + +DECLOP_1VAR_POSTOP(uint1, ++) +DECLOP_1VAR_POSTOP(uint1, --) + +DECLOP_1VAR_COMP(uint1, ==) +DECLOP_1VAR_COMP(uint1, !=) +DECLOP_1VAR_COMP(uint1, <) +DECLOP_1VAR_COMP(uint1, >) +DECLOP_1VAR_COMP(uint1, <=) +DECLOP_1VAR_COMP(uint1, >=) + +DECLOP_1VAR_COMP(uint1, &&) +DECLOP_1VAR_COMP(uint1, ||) + +DECLOP_1VAR_1IN_1OUT(uint1, ~) +DECLOP_1VAR_1IN_BOOLOUT(uint1, !) + +DECLOP_1VAR_SCALE_PRODUCT(uint1, unsigned char) +DECLOP_1VAR_SCALE_PRODUCT(uint1, signed char) +DECLOP_1VAR_SCALE_PRODUCT(uint1, unsigned short) +DECLOP_1VAR_SCALE_PRODUCT(uint1, signed short) +DECLOP_1VAR_SCALE_PRODUCT(uint1, unsigned int) +DECLOP_1VAR_SCALE_PRODUCT(uint1, signed int) +DECLOP_1VAR_SCALE_PRODUCT(uint1, float) +DECLOP_1VAR_SCALE_PRODUCT(uint1, unsigned long) +DECLOP_1VAR_SCALE_PRODUCT(uint1, signed long) +DECLOP_1VAR_SCALE_PRODUCT(uint1, double) +DECLOP_1VAR_SCALE_PRODUCT(uint1, unsigned long long) +DECLOP_1VAR_SCALE_PRODUCT(uint1, signed long long) + +// UNSIGNED INT2 + +DECLOP_2VAR_2IN_1OUT(uint2, +) +DECLOP_2VAR_2IN_1OUT(uint2, -) +DECLOP_2VAR_2IN_1OUT(uint2, *) +DECLOP_2VAR_2IN_1OUT(uint2, /) +DECLOP_2VAR_2IN_1OUT(uint2, %) +DECLOP_2VAR_2IN_1OUT(uint2, &) +DECLOP_2VAR_2IN_1OUT(uint2, |) +DECLOP_2VAR_2IN_1OUT(uint2, ^) +DECLOP_2VAR_2IN_1OUT(uint2, <<) +DECLOP_2VAR_2IN_1OUT(uint2, >>) + +DECLOP_2VAR_ASSIGN(uint2, +=) +DECLOP_2VAR_ASSIGN(uint2, -=) +DECLOP_2VAR_ASSIGN(uint2, *=) +DECLOP_2VAR_ASSIGN(uint2, /=) +DECLOP_2VAR_ASSIGN(uint2, %=) +DECLOP_2VAR_ASSIGN(uint2, &=) +DECLOP_2VAR_ASSIGN(uint2, |=) +DECLOP_2VAR_ASSIGN(uint2, ^=) +DECLOP_2VAR_ASSIGN(uint2, <<=) +DECLOP_2VAR_ASSIGN(uint2, >>=) + +DECLOP_2VAR_PREOP(uint2, ++) +DECLOP_2VAR_PREOP(uint2, --) + +DECLOP_2VAR_POSTOP(uint2, ++) +DECLOP_2VAR_POSTOP(uint2, --) + +DECLOP_2VAR_COMP(uint2, ==) +DECLOP_2VAR_COMP(uint2, !=) +DECLOP_2VAR_COMP(uint2, <) +DECLOP_2VAR_COMP(uint2, >) +DECLOP_2VAR_COMP(uint2, <=) +DECLOP_2VAR_COMP(uint2, >=) + +DECLOP_2VAR_COMP(uint2, &&) +DECLOP_2VAR_COMP(uint2, ||) + +DECLOP_2VAR_1IN_1OUT(uint2, ~) +DECLOP_2VAR_1IN_BOOLOUT(uint2, !) + +DECLOP_2VAR_SCALE_PRODUCT(uint2, unsigned char) +DECLOP_2VAR_SCALE_PRODUCT(uint2, signed char) +DECLOP_2VAR_SCALE_PRODUCT(uint2, unsigned short) +DECLOP_2VAR_SCALE_PRODUCT(uint2, signed short) +DECLOP_2VAR_SCALE_PRODUCT(uint2, unsigned int) +DECLOP_2VAR_SCALE_PRODUCT(uint2, signed int) +DECLOP_2VAR_SCALE_PRODUCT(uint2, float) +DECLOP_2VAR_SCALE_PRODUCT(uint2, unsigned long) +DECLOP_2VAR_SCALE_PRODUCT(uint2, signed long) +DECLOP_2VAR_SCALE_PRODUCT(uint2, double) +DECLOP_2VAR_SCALE_PRODUCT(uint2, unsigned long long) +DECLOP_2VAR_SCALE_PRODUCT(uint2, signed long long) + +// UNSIGNED INT3 + +DECLOP_3VAR_2IN_1OUT(uint3, +) +DECLOP_3VAR_2IN_1OUT(uint3, -) +DECLOP_3VAR_2IN_1OUT(uint3, *) +DECLOP_3VAR_2IN_1OUT(uint3, /) +DECLOP_3VAR_2IN_1OUT(uint3, %) +DECLOP_3VAR_2IN_1OUT(uint3, &) +DECLOP_3VAR_2IN_1OUT(uint3, |) +DECLOP_3VAR_2IN_1OUT(uint3, ^) +DECLOP_3VAR_2IN_1OUT(uint3, <<) +DECLOP_3VAR_2IN_1OUT(uint3, >>) + +DECLOP_3VAR_ASSIGN(uint3, +=) +DECLOP_3VAR_ASSIGN(uint3, -=) +DECLOP_3VAR_ASSIGN(uint3, *=) +DECLOP_3VAR_ASSIGN(uint3, /=) +DECLOP_3VAR_ASSIGN(uint3, %=) +DECLOP_3VAR_ASSIGN(uint3, &=) +DECLOP_3VAR_ASSIGN(uint3, |=) +DECLOP_3VAR_ASSIGN(uint3, ^=) +DECLOP_3VAR_ASSIGN(uint3, <<=) +DECLOP_3VAR_ASSIGN(uint3, >>=) + +DECLOP_3VAR_PREOP(uint3, ++) +DECLOP_3VAR_PREOP(uint3, --) + +DECLOP_3VAR_POSTOP(uint3, ++) +DECLOP_3VAR_POSTOP(uint3, --) + +DECLOP_3VAR_COMP(uint3, ==) +DECLOP_3VAR_COMP(uint3, !=) +DECLOP_3VAR_COMP(uint3, <) +DECLOP_3VAR_COMP(uint3, >) +DECLOP_3VAR_COMP(uint3, <=) +DECLOP_3VAR_COMP(uint3, >=) + +DECLOP_3VAR_COMP(uint3, &&) +DECLOP_3VAR_COMP(uint3, ||) + +DECLOP_3VAR_1IN_1OUT(uint3, ~) +DECLOP_3VAR_1IN_BOOLOUT(uint3, !) + +DECLOP_3VAR_SCALE_PRODUCT(uint3, unsigned char) +DECLOP_3VAR_SCALE_PRODUCT(uint3, signed char) +DECLOP_3VAR_SCALE_PRODUCT(uint3, unsigned short) +DECLOP_3VAR_SCALE_PRODUCT(uint3, signed short) +DECLOP_3VAR_SCALE_PRODUCT(uint3, unsigned int) +DECLOP_3VAR_SCALE_PRODUCT(uint3, signed int) +DECLOP_3VAR_SCALE_PRODUCT(uint3, float) +DECLOP_3VAR_SCALE_PRODUCT(uint3, unsigned long) +DECLOP_3VAR_SCALE_PRODUCT(uint3, signed long) +DECLOP_3VAR_SCALE_PRODUCT(uint3, double) +DECLOP_3VAR_SCALE_PRODUCT(uint3, unsigned long long) +DECLOP_3VAR_SCALE_PRODUCT(uint3, signed long long) + +// UNSIGNED INT4 + +DECLOP_4VAR_2IN_1OUT(uint4, +) +DECLOP_4VAR_2IN_1OUT(uint4, -) +DECLOP_4VAR_2IN_1OUT(uint4, *) +DECLOP_4VAR_2IN_1OUT(uint4, /) +DECLOP_4VAR_2IN_1OUT(uint4, %) +DECLOP_4VAR_2IN_1OUT(uint4, &) +DECLOP_4VAR_2IN_1OUT(uint4, |) +DECLOP_4VAR_2IN_1OUT(uint4, ^) +DECLOP_4VAR_2IN_1OUT(uint4, <<) +DECLOP_4VAR_2IN_1OUT(uint4, >>) + +DECLOP_4VAR_ASSIGN(uint4, +=) +DECLOP_4VAR_ASSIGN(uint4, -=) +DECLOP_4VAR_ASSIGN(uint4, *=) +DECLOP_4VAR_ASSIGN(uint4, /=) +DECLOP_4VAR_ASSIGN(uint4, %=) +DECLOP_4VAR_ASSIGN(uint4, &=) +DECLOP_4VAR_ASSIGN(uint4, |=) +DECLOP_4VAR_ASSIGN(uint4, ^=) +DECLOP_4VAR_ASSIGN(uint4, <<=) +DECLOP_4VAR_ASSIGN(uint4, >>=) + +DECLOP_4VAR_PREOP(uint4, ++) +DECLOP_4VAR_PREOP(uint4, --) + +DECLOP_4VAR_POSTOP(uint4, ++) +DECLOP_4VAR_POSTOP(uint4, --) + +DECLOP_4VAR_COMP(uint4, ==) +DECLOP_4VAR_COMP(uint4, !=) +DECLOP_4VAR_COMP(uint4, <) +DECLOP_4VAR_COMP(uint4, >) +DECLOP_4VAR_COMP(uint4, <=) +DECLOP_4VAR_COMP(uint4, >=) + +DECLOP_4VAR_COMP(uint4, &&) +DECLOP_4VAR_COMP(uint4, ||) + +DECLOP_4VAR_1IN_1OUT(uint4, ~) +DECLOP_4VAR_1IN_BOOLOUT(uint4, !) + +DECLOP_4VAR_SCALE_PRODUCT(uint4, unsigned char) +DECLOP_4VAR_SCALE_PRODUCT(uint4, signed char) +DECLOP_4VAR_SCALE_PRODUCT(uint4, unsigned short) +DECLOP_4VAR_SCALE_PRODUCT(uint4, signed short) +DECLOP_4VAR_SCALE_PRODUCT(uint4, unsigned int) +DECLOP_4VAR_SCALE_PRODUCT(uint4, signed int) +DECLOP_4VAR_SCALE_PRODUCT(uint4, float) +DECLOP_4VAR_SCALE_PRODUCT(uint4, unsigned long) +DECLOP_4VAR_SCALE_PRODUCT(uint4, signed long) +DECLOP_4VAR_SCALE_PRODUCT(uint4, double) +DECLOP_4VAR_SCALE_PRODUCT(uint4, unsigned long long) +DECLOP_4VAR_SCALE_PRODUCT(uint4, signed long long) + +// SIGNED INT1 + +DECLOP_1VAR_2IN_1OUT(int1, +) +DECLOP_1VAR_2IN_1OUT(int1, -) +DECLOP_1VAR_2IN_1OUT(int1, *) +DECLOP_1VAR_2IN_1OUT(int1, /) +DECLOP_1VAR_2IN_1OUT(int1, %) +DECLOP_1VAR_2IN_1OUT(int1, &) +DECLOP_1VAR_2IN_1OUT(int1, |) +DECLOP_1VAR_2IN_1OUT(int1, ^) +DECLOP_1VAR_2IN_1OUT(int1, <<) +DECLOP_1VAR_2IN_1OUT(int1, >>) + + +DECLOP_1VAR_ASSIGN(int1, +=) +DECLOP_1VAR_ASSIGN(int1, -=) +DECLOP_1VAR_ASSIGN(int1, *=) +DECLOP_1VAR_ASSIGN(int1, /=) +DECLOP_1VAR_ASSIGN(int1, %=) +DECLOP_1VAR_ASSIGN(int1, &=) +DECLOP_1VAR_ASSIGN(int1, |=) +DECLOP_1VAR_ASSIGN(int1, ^=) +DECLOP_1VAR_ASSIGN(int1, <<=) +DECLOP_1VAR_ASSIGN(int1, >>=) + +DECLOP_1VAR_PREOP(int1, ++) +DECLOP_1VAR_PREOP(int1, --) + +DECLOP_1VAR_POSTOP(int1, ++) +DECLOP_1VAR_POSTOP(int1, --) + +DECLOP_1VAR_COMP(int1, ==) +DECLOP_1VAR_COMP(int1, !=) +DECLOP_1VAR_COMP(int1, <) +DECLOP_1VAR_COMP(int1, >) +DECLOP_1VAR_COMP(int1, <=) +DECLOP_1VAR_COMP(int1, >=) + +DECLOP_1VAR_COMP(int1, &&) +DECLOP_1VAR_COMP(int1, ||) + +DECLOP_1VAR_1IN_1OUT(int1, ~) +DECLOP_1VAR_1IN_BOOLOUT(int1, !) + +DECLOP_1VAR_SCALE_PRODUCT(int1, unsigned char) +DECLOP_1VAR_SCALE_PRODUCT(int1, signed char) +DECLOP_1VAR_SCALE_PRODUCT(int1, unsigned short) +DECLOP_1VAR_SCALE_PRODUCT(int1, signed short) +DECLOP_1VAR_SCALE_PRODUCT(int1, unsigned int) +DECLOP_1VAR_SCALE_PRODUCT(int1, signed int) +DECLOP_1VAR_SCALE_PRODUCT(int1, float) +DECLOP_1VAR_SCALE_PRODUCT(int1, unsigned long) +DECLOP_1VAR_SCALE_PRODUCT(int1, signed long) +DECLOP_1VAR_SCALE_PRODUCT(int1, double) +DECLOP_1VAR_SCALE_PRODUCT(int1, unsigned long long) +DECLOP_1VAR_SCALE_PRODUCT(int1, signed long long) + +// SIGNED INT2 + +DECLOP_2VAR_2IN_1OUT(int2, +) +DECLOP_2VAR_2IN_1OUT(int2, -) +DECLOP_2VAR_2IN_1OUT(int2, *) +DECLOP_2VAR_2IN_1OUT(int2, /) +DECLOP_2VAR_2IN_1OUT(int2, %) +DECLOP_2VAR_2IN_1OUT(int2, &) +DECLOP_2VAR_2IN_1OUT(int2, |) +DECLOP_2VAR_2IN_1OUT(int2, ^) +DECLOP_2VAR_2IN_1OUT(int2, <<) +DECLOP_2VAR_2IN_1OUT(int2, >>) + +DECLOP_2VAR_ASSIGN(int2, +=) +DECLOP_2VAR_ASSIGN(int2, -=) +DECLOP_2VAR_ASSIGN(int2, *=) +DECLOP_2VAR_ASSIGN(int2, /=) +DECLOP_2VAR_ASSIGN(int2, %=) +DECLOP_2VAR_ASSIGN(int2, &=) +DECLOP_2VAR_ASSIGN(int2, |=) +DECLOP_2VAR_ASSIGN(int2, ^=) +DECLOP_2VAR_ASSIGN(int2, <<=) +DECLOP_2VAR_ASSIGN(int2, >>=) + +DECLOP_2VAR_PREOP(int2, ++) +DECLOP_2VAR_PREOP(int2, --) + +DECLOP_2VAR_POSTOP(int2, ++) +DECLOP_2VAR_POSTOP(int2, --) + +DECLOP_2VAR_COMP(int2, ==) +DECLOP_2VAR_COMP(int2, !=) +DECLOP_2VAR_COMP(int2, <) +DECLOP_2VAR_COMP(int2, >) +DECLOP_2VAR_COMP(int2, <=) +DECLOP_2VAR_COMP(int2, >=) + +DECLOP_2VAR_COMP(int2, &&) +DECLOP_2VAR_COMP(int2, ||) + +DECLOP_2VAR_1IN_1OUT(int2, ~) +DECLOP_2VAR_1IN_BOOLOUT(int2, !) + +DECLOP_2VAR_SCALE_PRODUCT(int2, unsigned char) +DECLOP_2VAR_SCALE_PRODUCT(int2, signed char) +DECLOP_2VAR_SCALE_PRODUCT(int2, unsigned short) +DECLOP_2VAR_SCALE_PRODUCT(int2, signed short) +DECLOP_2VAR_SCALE_PRODUCT(int2, unsigned int) +DECLOP_2VAR_SCALE_PRODUCT(int2, signed int) +DECLOP_2VAR_SCALE_PRODUCT(int2, float) +DECLOP_2VAR_SCALE_PRODUCT(int2, unsigned long) +DECLOP_2VAR_SCALE_PRODUCT(int2, signed long) +DECLOP_2VAR_SCALE_PRODUCT(int2, double) +DECLOP_2VAR_SCALE_PRODUCT(int2, unsigned long long) +DECLOP_2VAR_SCALE_PRODUCT(int2, signed long long) + +// SIGNED INT3 + +DECLOP_3VAR_2IN_1OUT(int3, +) +DECLOP_3VAR_2IN_1OUT(int3, -) +DECLOP_3VAR_2IN_1OUT(int3, *) +DECLOP_3VAR_2IN_1OUT(int3, /) +DECLOP_3VAR_2IN_1OUT(int3, %) +DECLOP_3VAR_2IN_1OUT(int3, &) +DECLOP_3VAR_2IN_1OUT(int3, |) +DECLOP_3VAR_2IN_1OUT(int3, ^) +DECLOP_3VAR_2IN_1OUT(int3, <<) +DECLOP_3VAR_2IN_1OUT(int3, >>) + +DECLOP_3VAR_ASSIGN(int3, +=) +DECLOP_3VAR_ASSIGN(int3, -=) +DECLOP_3VAR_ASSIGN(int3, *=) +DECLOP_3VAR_ASSIGN(int3, /=) +DECLOP_3VAR_ASSIGN(int3, %=) +DECLOP_3VAR_ASSIGN(int3, &=) +DECLOP_3VAR_ASSIGN(int3, |=) +DECLOP_3VAR_ASSIGN(int3, ^=) +DECLOP_3VAR_ASSIGN(int3, <<=) +DECLOP_3VAR_ASSIGN(int3, >>=) + +DECLOP_3VAR_PREOP(int3, ++) +DECLOP_3VAR_PREOP(int3, --) + +DECLOP_3VAR_POSTOP(int3, ++) +DECLOP_3VAR_POSTOP(int3, --) + +DECLOP_3VAR_COMP(int3, ==) +DECLOP_3VAR_COMP(int3, !=) +DECLOP_3VAR_COMP(int3, <) +DECLOP_3VAR_COMP(int3, >) +DECLOP_3VAR_COMP(int3, <=) +DECLOP_3VAR_COMP(int3, >=) + +DECLOP_3VAR_COMP(int3, &&) +DECLOP_3VAR_COMP(int3, ||) + +DECLOP_3VAR_1IN_1OUT(int3, ~) +DECLOP_3VAR_1IN_BOOLOUT(int3, !) + +DECLOP_3VAR_SCALE_PRODUCT(int3, unsigned char) +DECLOP_3VAR_SCALE_PRODUCT(int3, signed char) +DECLOP_3VAR_SCALE_PRODUCT(int3, unsigned short) +DECLOP_3VAR_SCALE_PRODUCT(int3, signed short) +DECLOP_3VAR_SCALE_PRODUCT(int3, unsigned int) +DECLOP_3VAR_SCALE_PRODUCT(int3, signed int) +DECLOP_3VAR_SCALE_PRODUCT(int3, float) +DECLOP_3VAR_SCALE_PRODUCT(int3, unsigned long) +DECLOP_3VAR_SCALE_PRODUCT(int3, signed long) +DECLOP_3VAR_SCALE_PRODUCT(int3, double) +DECLOP_3VAR_SCALE_PRODUCT(int3, unsigned long long) +DECLOP_3VAR_SCALE_PRODUCT(int3, signed long long) + +// SIGNED INT4 + +DECLOP_4VAR_2IN_1OUT(int4, +) +DECLOP_4VAR_2IN_1OUT(int4, -) +DECLOP_4VAR_2IN_1OUT(int4, *) +DECLOP_4VAR_2IN_1OUT(int4, /) +DECLOP_4VAR_2IN_1OUT(int4, %) +DECLOP_4VAR_2IN_1OUT(int4, &) +DECLOP_4VAR_2IN_1OUT(int4, |) +DECLOP_4VAR_2IN_1OUT(int4, ^) +DECLOP_4VAR_2IN_1OUT(int4, <<) +DECLOP_4VAR_2IN_1OUT(int4, >>) + +DECLOP_4VAR_ASSIGN(int4, +=) +DECLOP_4VAR_ASSIGN(int4, -=) +DECLOP_4VAR_ASSIGN(int4, *=) +DECLOP_4VAR_ASSIGN(int4, /=) +DECLOP_4VAR_ASSIGN(int4, %=) +DECLOP_4VAR_ASSIGN(int4, &=) +DECLOP_4VAR_ASSIGN(int4, |=) +DECLOP_4VAR_ASSIGN(int4, ^=) +DECLOP_4VAR_ASSIGN(int4, <<=) +DECLOP_4VAR_ASSIGN(int4, >>=) + +DECLOP_4VAR_PREOP(int4, ++) +DECLOP_4VAR_PREOP(int4, --) + +DECLOP_4VAR_POSTOP(int4, ++) +DECLOP_4VAR_POSTOP(int4, --) + +DECLOP_4VAR_COMP(int4, ==) +DECLOP_4VAR_COMP(int4, !=) +DECLOP_4VAR_COMP(int4, <) +DECLOP_4VAR_COMP(int4, >) +DECLOP_4VAR_COMP(int4, <=) +DECLOP_4VAR_COMP(int4, >=) + +DECLOP_4VAR_COMP(int4, &&) +DECLOP_4VAR_COMP(int4, ||) + +DECLOP_4VAR_1IN_1OUT(int4, ~) +DECLOP_4VAR_1IN_BOOLOUT(int4, !) + +DECLOP_4VAR_SCALE_PRODUCT(int4, unsigned char) +DECLOP_4VAR_SCALE_PRODUCT(int4, signed char) +DECLOP_4VAR_SCALE_PRODUCT(int4, unsigned short) +DECLOP_4VAR_SCALE_PRODUCT(int4, signed short) +DECLOP_4VAR_SCALE_PRODUCT(int4, unsigned int) +DECLOP_4VAR_SCALE_PRODUCT(int4, signed int) +DECLOP_4VAR_SCALE_PRODUCT(int4, float) +DECLOP_4VAR_SCALE_PRODUCT(int4, unsigned long) +DECLOP_4VAR_SCALE_PRODUCT(int4, signed long) +DECLOP_4VAR_SCALE_PRODUCT(int4, double) +DECLOP_4VAR_SCALE_PRODUCT(int4, unsigned long long) +DECLOP_4VAR_SCALE_PRODUCT(int4, signed long long) + +// FLOAT1 + +DECLOP_1VAR_2IN_1OUT(float1, +) +DECLOP_1VAR_2IN_1OUT(float1, -) +DECLOP_1VAR_2IN_1OUT(float1, *) +DECLOP_1VAR_2IN_1OUT(float1, /) + +DECLOP_1VAR_ASSIGN(float1, +=) +DECLOP_1VAR_ASSIGN(float1, -=) +DECLOP_1VAR_ASSIGN(float1, *=) +DECLOP_1VAR_ASSIGN(float1, /=) + +DECLOP_1VAR_PREOP(float1, ++) +DECLOP_1VAR_PREOP(float1, --) + +DECLOP_1VAR_POSTOP(float1, ++) +DECLOP_1VAR_POSTOP(float1, --) + +DECLOP_1VAR_COMP(float1, ==) +DECLOP_1VAR_COMP(float1, !=) +DECLOP_1VAR_COMP(float1, <) +DECLOP_1VAR_COMP(float1, >) +DECLOP_1VAR_COMP(float1, <=) +DECLOP_1VAR_COMP(float1, >=) + +DECLOP_1VAR_SCALE_PRODUCT(float1, unsigned char) +DECLOP_1VAR_SCALE_PRODUCT(float1, signed char) +DECLOP_1VAR_SCALE_PRODUCT(float1, unsigned short) +DECLOP_1VAR_SCALE_PRODUCT(float1, signed short) +DECLOP_1VAR_SCALE_PRODUCT(float1, unsigned int) +DECLOP_1VAR_SCALE_PRODUCT(float1, signed int) +DECLOP_1VAR_SCALE_PRODUCT(float1, float) +DECLOP_1VAR_SCALE_PRODUCT(float1, unsigned long) +DECLOP_1VAR_SCALE_PRODUCT(float1, signed long) +DECLOP_1VAR_SCALE_PRODUCT(float1, double) +DECLOP_1VAR_SCALE_PRODUCT(float1, unsigned long long) +DECLOP_1VAR_SCALE_PRODUCT(float1, signed long long) + +// FLOAT2 + +DECLOP_2VAR_2IN_1OUT(float2, +) +DECLOP_2VAR_2IN_1OUT(float2, -) +DECLOP_2VAR_2IN_1OUT(float2, *) +DECLOP_2VAR_2IN_1OUT(float2, /) + +DECLOP_2VAR_ASSIGN(float2, +=) +DECLOP_2VAR_ASSIGN(float2, -=) +DECLOP_2VAR_ASSIGN(float2, *=) +DECLOP_2VAR_ASSIGN(float2, /=) + +DECLOP_2VAR_PREOP(float2, ++) +DECLOP_2VAR_PREOP(float2, --) + +DECLOP_2VAR_POSTOP(float2, ++) +DECLOP_2VAR_POSTOP(float2, --) + +DECLOP_2VAR_COMP(float2, ==) +DECLOP_2VAR_COMP(float2, !=) +DECLOP_2VAR_COMP(float2, <) +DECLOP_2VAR_COMP(float2, >) +DECLOP_2VAR_COMP(float2, <=) +DECLOP_2VAR_COMP(float2, >=) + +DECLOP_2VAR_SCALE_PRODUCT(float2, unsigned char) +DECLOP_2VAR_SCALE_PRODUCT(float2, signed char) +DECLOP_2VAR_SCALE_PRODUCT(float2, unsigned short) +DECLOP_2VAR_SCALE_PRODUCT(float2, signed short) +DECLOP_2VAR_SCALE_PRODUCT(float2, unsigned int) +DECLOP_2VAR_SCALE_PRODUCT(float2, signed int) +DECLOP_2VAR_SCALE_PRODUCT(float2, float) +DECLOP_2VAR_SCALE_PRODUCT(float2, unsigned long) +DECLOP_2VAR_SCALE_PRODUCT(float2, signed long) +DECLOP_2VAR_SCALE_PRODUCT(float2, double) +DECLOP_2VAR_SCALE_PRODUCT(float2, unsigned long long) +DECLOP_2VAR_SCALE_PRODUCT(float2, signed long long) + +// FLOAT3 + +DECLOP_3VAR_2IN_1OUT(float3, +) +DECLOP_3VAR_2IN_1OUT(float3, -) +DECLOP_3VAR_2IN_1OUT(float3, *) +DECLOP_3VAR_2IN_1OUT(float3, /) + +DECLOP_3VAR_ASSIGN(float3, +=) +DECLOP_3VAR_ASSIGN(float3, -=) +DECLOP_3VAR_ASSIGN(float3, *=) +DECLOP_3VAR_ASSIGN(float3, /=) + +DECLOP_3VAR_PREOP(float3, ++) +DECLOP_3VAR_PREOP(float3, --) + +DECLOP_3VAR_POSTOP(float3, ++) +DECLOP_3VAR_POSTOP(float3, --) + +DECLOP_3VAR_COMP(float3, ==) +DECLOP_3VAR_COMP(float3, !=) +DECLOP_3VAR_COMP(float3, <) +DECLOP_3VAR_COMP(float3, >) +DECLOP_3VAR_COMP(float3, <=) +DECLOP_3VAR_COMP(float3, >=) + +DECLOP_3VAR_SCALE_PRODUCT(float3, unsigned char) +DECLOP_3VAR_SCALE_PRODUCT(float3, signed char) +DECLOP_3VAR_SCALE_PRODUCT(float3, unsigned short) +DECLOP_3VAR_SCALE_PRODUCT(float3, signed short) +DECLOP_3VAR_SCALE_PRODUCT(float3, unsigned int) +DECLOP_3VAR_SCALE_PRODUCT(float3, signed int) +DECLOP_3VAR_SCALE_PRODUCT(float3, float) +DECLOP_3VAR_SCALE_PRODUCT(float3, unsigned long) +DECLOP_3VAR_SCALE_PRODUCT(float3, signed long) +DECLOP_3VAR_SCALE_PRODUCT(float3, double) +DECLOP_3VAR_SCALE_PRODUCT(float3, unsigned long long) +DECLOP_3VAR_SCALE_PRODUCT(float3, signed long long) + +// FLOAT4 + +DECLOP_4VAR_2IN_1OUT(float4, +) +DECLOP_4VAR_2IN_1OUT(float4, -) +DECLOP_4VAR_2IN_1OUT(float4, *) +DECLOP_4VAR_2IN_1OUT(float4, /) + +DECLOP_4VAR_ASSIGN(float4, +=) +DECLOP_4VAR_ASSIGN(float4, -=) +DECLOP_4VAR_ASSIGN(float4, *=) +DECLOP_4VAR_ASSIGN(float4, /=) + +DECLOP_4VAR_PREOP(float4, ++) +DECLOP_4VAR_PREOP(float4, --) + +DECLOP_4VAR_POSTOP(float4, ++) +DECLOP_4VAR_POSTOP(float4, --) + +DECLOP_4VAR_COMP(float4, ==) +DECLOP_4VAR_COMP(float4, !=) +DECLOP_4VAR_COMP(float4, <) +DECLOP_4VAR_COMP(float4, >) +DECLOP_4VAR_COMP(float4, <=) +DECLOP_4VAR_COMP(float4, >=) + +DECLOP_4VAR_SCALE_PRODUCT(float4, unsigned char) +DECLOP_4VAR_SCALE_PRODUCT(float4, signed char) +DECLOP_4VAR_SCALE_PRODUCT(float4, unsigned short) +DECLOP_4VAR_SCALE_PRODUCT(float4, signed short) +DECLOP_4VAR_SCALE_PRODUCT(float4, unsigned int) +DECLOP_4VAR_SCALE_PRODUCT(float4, signed int) +DECLOP_4VAR_SCALE_PRODUCT(float4, float) +DECLOP_4VAR_SCALE_PRODUCT(float4, unsigned long) +DECLOP_4VAR_SCALE_PRODUCT(float4, signed long) +DECLOP_4VAR_SCALE_PRODUCT(float4, double) +DECLOP_4VAR_SCALE_PRODUCT(float4, unsigned long long) +DECLOP_4VAR_SCALE_PRODUCT(float4, signed long long) + +// DOUBLE1 + +DECLOP_1VAR_2IN_1OUT(double1, +) +DECLOP_1VAR_2IN_1OUT(double1, -) +DECLOP_1VAR_2IN_1OUT(double1, *) +DECLOP_1VAR_2IN_1OUT(double1, /) + +DECLOP_1VAR_ASSIGN(double1, +=) +DECLOP_1VAR_ASSIGN(double1, -=) +DECLOP_1VAR_ASSIGN(double1, *=) +DECLOP_1VAR_ASSIGN(double1, /=) + +DECLOP_1VAR_PREOP(double1, ++) +DECLOP_1VAR_PREOP(double1, --) + +DECLOP_1VAR_POSTOP(double1, ++) +DECLOP_1VAR_POSTOP(double1, --) + +DECLOP_1VAR_COMP(double1, ==) +DECLOP_1VAR_COMP(double1, !=) +DECLOP_1VAR_COMP(double1, <) +DECLOP_1VAR_COMP(double1, >) +DECLOP_1VAR_COMP(double1, <=) +DECLOP_1VAR_COMP(double1, >=) + +DECLOP_1VAR_SCALE_PRODUCT(double1, unsigned char) +DECLOP_1VAR_SCALE_PRODUCT(double1, signed char) +DECLOP_1VAR_SCALE_PRODUCT(double1, unsigned short) +DECLOP_1VAR_SCALE_PRODUCT(double1, signed short) +DECLOP_1VAR_SCALE_PRODUCT(double1, unsigned int) +DECLOP_1VAR_SCALE_PRODUCT(double1, signed int) +DECLOP_1VAR_SCALE_PRODUCT(double1, float) +DECLOP_1VAR_SCALE_PRODUCT(double1, unsigned long) +DECLOP_1VAR_SCALE_PRODUCT(double1, signed long) +DECLOP_1VAR_SCALE_PRODUCT(double1, double) +DECLOP_1VAR_SCALE_PRODUCT(double1, unsigned long long) +DECLOP_1VAR_SCALE_PRODUCT(double1, signed long long) + +// DOUBLE2 + +DECLOP_2VAR_2IN_1OUT(double2, +) +DECLOP_2VAR_2IN_1OUT(double2, -) +DECLOP_2VAR_2IN_1OUT(double2, *) +DECLOP_2VAR_2IN_1OUT(double2, /) + +DECLOP_2VAR_ASSIGN(double2, +=) +DECLOP_2VAR_ASSIGN(double2, -=) +DECLOP_2VAR_ASSIGN(double2, *=) +DECLOP_2VAR_ASSIGN(double2, /=) + +DECLOP_2VAR_PREOP(double2, ++) +DECLOP_2VAR_PREOP(double2, --) + +DECLOP_2VAR_POSTOP(double2, ++) +DECLOP_2VAR_POSTOP(double2, --) + +DECLOP_2VAR_COMP(double2, ==) +DECLOP_2VAR_COMP(double2, !=) +DECLOP_2VAR_COMP(double2, <) +DECLOP_2VAR_COMP(double2, >) +DECLOP_2VAR_COMP(double2, <=) +DECLOP_2VAR_COMP(double2, >=) + +DECLOP_2VAR_SCALE_PRODUCT(double2, unsigned char) +DECLOP_2VAR_SCALE_PRODUCT(double2, signed char) +DECLOP_2VAR_SCALE_PRODUCT(double2, unsigned short) +DECLOP_2VAR_SCALE_PRODUCT(double2, signed short) +DECLOP_2VAR_SCALE_PRODUCT(double2, unsigned int) +DECLOP_2VAR_SCALE_PRODUCT(double2, signed int) +DECLOP_2VAR_SCALE_PRODUCT(double2, float) +DECLOP_2VAR_SCALE_PRODUCT(double2, unsigned long) +DECLOP_2VAR_SCALE_PRODUCT(double2, signed long) +DECLOP_2VAR_SCALE_PRODUCT(double2, double) +DECLOP_2VAR_SCALE_PRODUCT(double2, unsigned long long) +DECLOP_2VAR_SCALE_PRODUCT(double2, signed long long) + +// DOUBLE3 + +DECLOP_3VAR_2IN_1OUT(double3, +) +DECLOP_3VAR_2IN_1OUT(double3, -) +DECLOP_3VAR_2IN_1OUT(double3, *) +DECLOP_3VAR_2IN_1OUT(double3, /) + +DECLOP_3VAR_ASSIGN(double3, +=) +DECLOP_3VAR_ASSIGN(double3, -=) +DECLOP_3VAR_ASSIGN(double3, *=) +DECLOP_3VAR_ASSIGN(double3, /=) + +DECLOP_3VAR_PREOP(double3, ++) +DECLOP_3VAR_PREOP(double3, --) + +DECLOP_3VAR_POSTOP(double3, ++) +DECLOP_3VAR_POSTOP(double3, --) + +DECLOP_3VAR_COMP(double3, ==) +DECLOP_3VAR_COMP(double3, !=) +DECLOP_3VAR_COMP(double3, <) +DECLOP_3VAR_COMP(double3, >) +DECLOP_3VAR_COMP(double3, <=) +DECLOP_3VAR_COMP(double3, >=) + +DECLOP_3VAR_SCALE_PRODUCT(double3, unsigned char) +DECLOP_3VAR_SCALE_PRODUCT(double3, signed char) +DECLOP_3VAR_SCALE_PRODUCT(double3, unsigned short) +DECLOP_3VAR_SCALE_PRODUCT(double3, signed short) +DECLOP_3VAR_SCALE_PRODUCT(double3, unsigned int) +DECLOP_3VAR_SCALE_PRODUCT(double3, signed int) +DECLOP_3VAR_SCALE_PRODUCT(double3, float) +DECLOP_3VAR_SCALE_PRODUCT(double3, unsigned long) +DECLOP_3VAR_SCALE_PRODUCT(double3, signed long) +DECLOP_3VAR_SCALE_PRODUCT(double3, double) +DECLOP_3VAR_SCALE_PRODUCT(double3, unsigned long long) +DECLOP_3VAR_SCALE_PRODUCT(double3, signed long long) + +// DOUBLE4 + +DECLOP_4VAR_2IN_1OUT(double4, +) +DECLOP_4VAR_2IN_1OUT(double4, -) +DECLOP_4VAR_2IN_1OUT(double4, *) +DECLOP_4VAR_2IN_1OUT(double4, /) + +DECLOP_4VAR_ASSIGN(double4, +=) +DECLOP_4VAR_ASSIGN(double4, -=) +DECLOP_4VAR_ASSIGN(double4, *=) +DECLOP_4VAR_ASSIGN(double4, /=) + +DECLOP_4VAR_PREOP(double4, ++) +DECLOP_4VAR_PREOP(double4, --) + +DECLOP_4VAR_POSTOP(double4, ++) +DECLOP_4VAR_POSTOP(double4, --) + +DECLOP_4VAR_COMP(double4, ==) +DECLOP_4VAR_COMP(double4, !=) +DECLOP_4VAR_COMP(double4, <) +DECLOP_4VAR_COMP(double4, >) +DECLOP_4VAR_COMP(double4, <=) +DECLOP_4VAR_COMP(double4, >=) + +DECLOP_4VAR_SCALE_PRODUCT(double4, unsigned char) +DECLOP_4VAR_SCALE_PRODUCT(double4, signed char) +DECLOP_4VAR_SCALE_PRODUCT(double4, unsigned short) +DECLOP_4VAR_SCALE_PRODUCT(double4, signed short) +DECLOP_4VAR_SCALE_PRODUCT(double4, unsigned int) +DECLOP_4VAR_SCALE_PRODUCT(double4, signed int) +DECLOP_4VAR_SCALE_PRODUCT(double4, float) +DECLOP_4VAR_SCALE_PRODUCT(double4, unsigned long) +DECLOP_4VAR_SCALE_PRODUCT(double4, signed long) +DECLOP_4VAR_SCALE_PRODUCT(double4, double) +DECLOP_4VAR_SCALE_PRODUCT(double4, unsigned long long) +DECLOP_4VAR_SCALE_PRODUCT(double4, signed long long) + +// UNSIGNED LONG1 + +DECLOP_1VAR_2IN_1OUT(ulong1, +) +DECLOP_1VAR_2IN_1OUT(ulong1, -) +DECLOP_1VAR_2IN_1OUT(ulong1, *) +DECLOP_1VAR_2IN_1OUT(ulong1, /) +DECLOP_1VAR_2IN_1OUT(ulong1, %) +DECLOP_1VAR_2IN_1OUT(ulong1, &) +DECLOP_1VAR_2IN_1OUT(ulong1, |) +DECLOP_1VAR_2IN_1OUT(ulong1, ^) +DECLOP_1VAR_2IN_1OUT(ulong1, <<) +DECLOP_1VAR_2IN_1OUT(ulong1, >>) + + +DECLOP_1VAR_ASSIGN(ulong1, +=) +DECLOP_1VAR_ASSIGN(ulong1, -=) +DECLOP_1VAR_ASSIGN(ulong1, *=) +DECLOP_1VAR_ASSIGN(ulong1, /=) +DECLOP_1VAR_ASSIGN(ulong1, %=) +DECLOP_1VAR_ASSIGN(ulong1, &=) +DECLOP_1VAR_ASSIGN(ulong1, |=) +DECLOP_1VAR_ASSIGN(ulong1, ^=) +DECLOP_1VAR_ASSIGN(ulong1, <<=) +DECLOP_1VAR_ASSIGN(ulong1, >>=) + +DECLOP_1VAR_PREOP(ulong1, ++) +DECLOP_1VAR_PREOP(ulong1, --) + +DECLOP_1VAR_POSTOP(ulong1, ++) +DECLOP_1VAR_POSTOP(ulong1, --) + +DECLOP_1VAR_COMP(ulong1, ==) +DECLOP_1VAR_COMP(ulong1, !=) +DECLOP_1VAR_COMP(ulong1, <) +DECLOP_1VAR_COMP(ulong1, >) +DECLOP_1VAR_COMP(ulong1, <=) +DECLOP_1VAR_COMP(ulong1, >=) + +DECLOP_1VAR_COMP(ulong1, &&) +DECLOP_1VAR_COMP(ulong1, ||) + +DECLOP_1VAR_1IN_1OUT(ulong1, ~) +DECLOP_1VAR_1IN_BOOLOUT(ulong1, !) + +DECLOP_1VAR_SCALE_PRODUCT(ulong1, unsigned char) +DECLOP_1VAR_SCALE_PRODUCT(ulong1, signed char) +DECLOP_1VAR_SCALE_PRODUCT(ulong1, unsigned short) +DECLOP_1VAR_SCALE_PRODUCT(ulong1, signed short) +DECLOP_1VAR_SCALE_PRODUCT(ulong1, unsigned int) +DECLOP_1VAR_SCALE_PRODUCT(ulong1, signed int) +DECLOP_1VAR_SCALE_PRODUCT(ulong1, float) +DECLOP_1VAR_SCALE_PRODUCT(ulong1, unsigned long) +DECLOP_1VAR_SCALE_PRODUCT(ulong1, signed long) +DECLOP_1VAR_SCALE_PRODUCT(ulong1, double) +DECLOP_1VAR_SCALE_PRODUCT(ulong1, unsigned long long) +DECLOP_1VAR_SCALE_PRODUCT(ulong1, signed long long) + +// UNSIGNED LONG2 + +DECLOP_2VAR_2IN_1OUT(ulong2, +) +DECLOP_2VAR_2IN_1OUT(ulong2, -) +DECLOP_2VAR_2IN_1OUT(ulong2, *) +DECLOP_2VAR_2IN_1OUT(ulong2, /) +DECLOP_2VAR_2IN_1OUT(ulong2, %) +DECLOP_2VAR_2IN_1OUT(ulong2, &) +DECLOP_2VAR_2IN_1OUT(ulong2, |) +DECLOP_2VAR_2IN_1OUT(ulong2, ^) +DECLOP_2VAR_2IN_1OUT(ulong2, <<) +DECLOP_2VAR_2IN_1OUT(ulong2, >>) + +DECLOP_2VAR_ASSIGN(ulong2, +=) +DECLOP_2VAR_ASSIGN(ulong2, -=) +DECLOP_2VAR_ASSIGN(ulong2, *=) +DECLOP_2VAR_ASSIGN(ulong2, /=) +DECLOP_2VAR_ASSIGN(ulong2, %=) +DECLOP_2VAR_ASSIGN(ulong2, &=) +DECLOP_2VAR_ASSIGN(ulong2, |=) +DECLOP_2VAR_ASSIGN(ulong2, ^=) +DECLOP_2VAR_ASSIGN(ulong2, <<=) +DECLOP_2VAR_ASSIGN(ulong2, >>=) + +DECLOP_2VAR_PREOP(ulong2, ++) +DECLOP_2VAR_PREOP(ulong2, --) + +DECLOP_2VAR_POSTOP(ulong2, ++) +DECLOP_2VAR_POSTOP(ulong2, --) + +DECLOP_2VAR_COMP(ulong2, ==) +DECLOP_2VAR_COMP(ulong2, !=) +DECLOP_2VAR_COMP(ulong2, <) +DECLOP_2VAR_COMP(ulong2, >) +DECLOP_2VAR_COMP(ulong2, <=) +DECLOP_2VAR_COMP(ulong2, >=) + +DECLOP_2VAR_COMP(ulong2, &&) +DECLOP_2VAR_COMP(ulong2, ||) + +DECLOP_2VAR_1IN_1OUT(ulong2, ~) +DECLOP_2VAR_1IN_BOOLOUT(ulong2, !) + +DECLOP_2VAR_SCALE_PRODUCT(ulong2, unsigned char) +DECLOP_2VAR_SCALE_PRODUCT(ulong2, signed char) +DECLOP_2VAR_SCALE_PRODUCT(ulong2, unsigned short) +DECLOP_2VAR_SCALE_PRODUCT(ulong2, signed short) +DECLOP_2VAR_SCALE_PRODUCT(ulong2, unsigned int) +DECLOP_2VAR_SCALE_PRODUCT(ulong2, signed int) +DECLOP_2VAR_SCALE_PRODUCT(ulong2, float) +DECLOP_2VAR_SCALE_PRODUCT(ulong2, unsigned long) +DECLOP_2VAR_SCALE_PRODUCT(ulong2, signed long) +DECLOP_2VAR_SCALE_PRODUCT(ulong2, double) +DECLOP_2VAR_SCALE_PRODUCT(ulong2, unsigned long long) +DECLOP_2VAR_SCALE_PRODUCT(ulong2, signed long long) + +// UNSIGNED LONG3 + +DECLOP_3VAR_2IN_1OUT(ulong3, +) +DECLOP_3VAR_2IN_1OUT(ulong3, -) +DECLOP_3VAR_2IN_1OUT(ulong3, *) +DECLOP_3VAR_2IN_1OUT(ulong3, /) +DECLOP_3VAR_2IN_1OUT(ulong3, %) +DECLOP_3VAR_2IN_1OUT(ulong3, &) +DECLOP_3VAR_2IN_1OUT(ulong3, |) +DECLOP_3VAR_2IN_1OUT(ulong3, ^) +DECLOP_3VAR_2IN_1OUT(ulong3, <<) +DECLOP_3VAR_2IN_1OUT(ulong3, >>) + +DECLOP_3VAR_ASSIGN(ulong3, +=) +DECLOP_3VAR_ASSIGN(ulong3, -=) +DECLOP_3VAR_ASSIGN(ulong3, *=) +DECLOP_3VAR_ASSIGN(ulong3, /=) +DECLOP_3VAR_ASSIGN(ulong3, %=) +DECLOP_3VAR_ASSIGN(ulong3, &=) +DECLOP_3VAR_ASSIGN(ulong3, |=) +DECLOP_3VAR_ASSIGN(ulong3, ^=) +DECLOP_3VAR_ASSIGN(ulong3, <<=) +DECLOP_3VAR_ASSIGN(ulong3, >>=) + +DECLOP_3VAR_PREOP(ulong3, ++) +DECLOP_3VAR_PREOP(ulong3, --) + +DECLOP_3VAR_POSTOP(ulong3, ++) +DECLOP_3VAR_POSTOP(ulong3, --) + +DECLOP_3VAR_COMP(ulong3, ==) +DECLOP_3VAR_COMP(ulong3, !=) +DECLOP_3VAR_COMP(ulong3, <) +DECLOP_3VAR_COMP(ulong3, >) +DECLOP_3VAR_COMP(ulong3, <=) +DECLOP_3VAR_COMP(ulong3, >=) + +DECLOP_3VAR_COMP(ulong3, &&) +DECLOP_3VAR_COMP(ulong3, ||) + +DECLOP_3VAR_1IN_1OUT(ulong3, ~) +DECLOP_3VAR_1IN_BOOLOUT(ulong3, !) + +DECLOP_3VAR_SCALE_PRODUCT(ulong3, unsigned char) +DECLOP_3VAR_SCALE_PRODUCT(ulong3, signed char) +DECLOP_3VAR_SCALE_PRODUCT(ulong3, unsigned short) +DECLOP_3VAR_SCALE_PRODUCT(ulong3, signed short) +DECLOP_3VAR_SCALE_PRODUCT(ulong3, unsigned int) +DECLOP_3VAR_SCALE_PRODUCT(ulong3, signed int) +DECLOP_3VAR_SCALE_PRODUCT(ulong3, float) +DECLOP_3VAR_SCALE_PRODUCT(ulong3, unsigned long) +DECLOP_3VAR_SCALE_PRODUCT(ulong3, signed long) +DECLOP_3VAR_SCALE_PRODUCT(ulong3, double) +DECLOP_3VAR_SCALE_PRODUCT(ulong3, unsigned long long) +DECLOP_3VAR_SCALE_PRODUCT(ulong3, signed long long) + +// UNSIGNED LONG4 + +DECLOP_4VAR_2IN_1OUT(ulong4, +) +DECLOP_4VAR_2IN_1OUT(ulong4, -) +DECLOP_4VAR_2IN_1OUT(ulong4, *) +DECLOP_4VAR_2IN_1OUT(ulong4, /) +DECLOP_4VAR_2IN_1OUT(ulong4, %) +DECLOP_4VAR_2IN_1OUT(ulong4, &) +DECLOP_4VAR_2IN_1OUT(ulong4, |) +DECLOP_4VAR_2IN_1OUT(ulong4, ^) +DECLOP_4VAR_2IN_1OUT(ulong4, <<) +DECLOP_4VAR_2IN_1OUT(ulong4, >>) + +DECLOP_4VAR_ASSIGN(ulong4, +=) +DECLOP_4VAR_ASSIGN(ulong4, -=) +DECLOP_4VAR_ASSIGN(ulong4, *=) +DECLOP_4VAR_ASSIGN(ulong4, /=) +DECLOP_4VAR_ASSIGN(ulong4, %=) +DECLOP_4VAR_ASSIGN(ulong4, &=) +DECLOP_4VAR_ASSIGN(ulong4, |=) +DECLOP_4VAR_ASSIGN(ulong4, ^=) +DECLOP_4VAR_ASSIGN(ulong4, <<=) +DECLOP_4VAR_ASSIGN(ulong4, >>=) + +DECLOP_4VAR_PREOP(ulong4, ++) +DECLOP_4VAR_PREOP(ulong4, --) + +DECLOP_4VAR_POSTOP(ulong4, ++) +DECLOP_4VAR_POSTOP(ulong4, --) + +DECLOP_4VAR_COMP(ulong4, ==) +DECLOP_4VAR_COMP(ulong4, !=) +DECLOP_4VAR_COMP(ulong4, <) +DECLOP_4VAR_COMP(ulong4, >) +DECLOP_4VAR_COMP(ulong4, <=) +DECLOP_4VAR_COMP(ulong4, >=) + +DECLOP_4VAR_COMP(ulong4, &&) +DECLOP_4VAR_COMP(ulong4, ||) + +DECLOP_4VAR_1IN_1OUT(ulong4, ~) +DECLOP_4VAR_1IN_BOOLOUT(ulong4, !) + +DECLOP_4VAR_SCALE_PRODUCT(ulong4, unsigned char) +DECLOP_4VAR_SCALE_PRODUCT(ulong4, signed char) +DECLOP_4VAR_SCALE_PRODUCT(ulong4, unsigned short) +DECLOP_4VAR_SCALE_PRODUCT(ulong4, signed short) +DECLOP_4VAR_SCALE_PRODUCT(ulong4, unsigned int) +DECLOP_4VAR_SCALE_PRODUCT(ulong4, signed int) +DECLOP_4VAR_SCALE_PRODUCT(ulong4, float) +DECLOP_4VAR_SCALE_PRODUCT(ulong4, unsigned long) +DECLOP_4VAR_SCALE_PRODUCT(ulong4, signed long) +DECLOP_4VAR_SCALE_PRODUCT(ulong4, double) +DECLOP_4VAR_SCALE_PRODUCT(ulong4, unsigned long long) +DECLOP_4VAR_SCALE_PRODUCT(ulong4, signed long long) + +// SIGNED LONG1 + +DECLOP_1VAR_2IN_1OUT(long1, +) +DECLOP_1VAR_2IN_1OUT(long1, -) +DECLOP_1VAR_2IN_1OUT(long1, *) +DECLOP_1VAR_2IN_1OUT(long1, /) +DECLOP_1VAR_2IN_1OUT(long1, %) +DECLOP_1VAR_2IN_1OUT(long1, &) +DECLOP_1VAR_2IN_1OUT(long1, |) +DECLOP_1VAR_2IN_1OUT(long1, ^) +DECLOP_1VAR_2IN_1OUT(long1, <<) +DECLOP_1VAR_2IN_1OUT(long1, >>) + + +DECLOP_1VAR_ASSIGN(long1, +=) +DECLOP_1VAR_ASSIGN(long1, -=) +DECLOP_1VAR_ASSIGN(long1, *=) +DECLOP_1VAR_ASSIGN(long1, /=) +DECLOP_1VAR_ASSIGN(long1, %=) +DECLOP_1VAR_ASSIGN(long1, &=) +DECLOP_1VAR_ASSIGN(long1, |=) +DECLOP_1VAR_ASSIGN(long1, ^=) +DECLOP_1VAR_ASSIGN(long1, <<=) +DECLOP_1VAR_ASSIGN(long1, >>=) + +DECLOP_1VAR_PREOP(long1, ++) +DECLOP_1VAR_PREOP(long1, --) + +DECLOP_1VAR_POSTOP(long1, ++) +DECLOP_1VAR_POSTOP(long1, --) + +DECLOP_1VAR_COMP(long1, ==) +DECLOP_1VAR_COMP(long1, !=) +DECLOP_1VAR_COMP(long1, <) +DECLOP_1VAR_COMP(long1, >) +DECLOP_1VAR_COMP(long1, <=) +DECLOP_1VAR_COMP(long1, >=) + +DECLOP_1VAR_COMP(long1, &&) +DECLOP_1VAR_COMP(long1, ||) + +DECLOP_1VAR_1IN_1OUT(long1, ~) +DECLOP_1VAR_1IN_BOOLOUT(long1, !) + +DECLOP_1VAR_SCALE_PRODUCT(long1, unsigned char) +DECLOP_1VAR_SCALE_PRODUCT(long1, signed char) +DECLOP_1VAR_SCALE_PRODUCT(long1, unsigned short) +DECLOP_1VAR_SCALE_PRODUCT(long1, signed short) +DECLOP_1VAR_SCALE_PRODUCT(long1, unsigned int) +DECLOP_1VAR_SCALE_PRODUCT(long1, signed int) +DECLOP_1VAR_SCALE_PRODUCT(long1, float) +DECLOP_1VAR_SCALE_PRODUCT(long1, unsigned long) +DECLOP_1VAR_SCALE_PRODUCT(long1, signed long) +DECLOP_1VAR_SCALE_PRODUCT(long1, double) +DECLOP_1VAR_SCALE_PRODUCT(long1, unsigned long long) +DECLOP_1VAR_SCALE_PRODUCT(long1, signed long long) + +// SIGNED LONG2 + +DECLOP_2VAR_2IN_1OUT(long2, +) +DECLOP_2VAR_2IN_1OUT(long2, -) +DECLOP_2VAR_2IN_1OUT(long2, *) +DECLOP_2VAR_2IN_1OUT(long2, /) +DECLOP_2VAR_2IN_1OUT(long2, %) +DECLOP_2VAR_2IN_1OUT(long2, &) +DECLOP_2VAR_2IN_1OUT(long2, |) +DECLOP_2VAR_2IN_1OUT(long2, ^) +DECLOP_2VAR_2IN_1OUT(long2, <<) +DECLOP_2VAR_2IN_1OUT(long2, >>) + +DECLOP_2VAR_ASSIGN(long2, +=) +DECLOP_2VAR_ASSIGN(long2, -=) +DECLOP_2VAR_ASSIGN(long2, *=) +DECLOP_2VAR_ASSIGN(long2, /=) +DECLOP_2VAR_ASSIGN(long2, %=) +DECLOP_2VAR_ASSIGN(long2, &=) +DECLOP_2VAR_ASSIGN(long2, |=) +DECLOP_2VAR_ASSIGN(long2, ^=) +DECLOP_2VAR_ASSIGN(long2, <<=) +DECLOP_2VAR_ASSIGN(long2, >>=) + +DECLOP_2VAR_PREOP(long2, ++) +DECLOP_2VAR_PREOP(long2, --) + +DECLOP_2VAR_POSTOP(long2, ++) +DECLOP_2VAR_POSTOP(long2, --) + +DECLOP_2VAR_COMP(long2, ==) +DECLOP_2VAR_COMP(long2, !=) +DECLOP_2VAR_COMP(long2, <) +DECLOP_2VAR_COMP(long2, >) +DECLOP_2VAR_COMP(long2, <=) +DECLOP_2VAR_COMP(long2, >=) + +DECLOP_2VAR_COMP(long2, &&) +DECLOP_2VAR_COMP(long2, ||) + +DECLOP_2VAR_1IN_1OUT(long2, ~) +DECLOP_2VAR_1IN_BOOLOUT(long2, !) + +DECLOP_2VAR_SCALE_PRODUCT(long2, unsigned char) +DECLOP_2VAR_SCALE_PRODUCT(long2, signed char) +DECLOP_2VAR_SCALE_PRODUCT(long2, unsigned short) +DECLOP_2VAR_SCALE_PRODUCT(long2, signed short) +DECLOP_2VAR_SCALE_PRODUCT(long2, unsigned int) +DECLOP_2VAR_SCALE_PRODUCT(long2, signed int) +DECLOP_2VAR_SCALE_PRODUCT(long2, float) +DECLOP_2VAR_SCALE_PRODUCT(long2, unsigned long) +DECLOP_2VAR_SCALE_PRODUCT(long2, signed long) +DECLOP_2VAR_SCALE_PRODUCT(long2, double) +DECLOP_2VAR_SCALE_PRODUCT(long2, unsigned long long) +DECLOP_2VAR_SCALE_PRODUCT(long2, signed long long) + +// SIGNED LONG3 + +DECLOP_3VAR_2IN_1OUT(long3, +) +DECLOP_3VAR_2IN_1OUT(long3, -) +DECLOP_3VAR_2IN_1OUT(long3, *) +DECLOP_3VAR_2IN_1OUT(long3, /) +DECLOP_3VAR_2IN_1OUT(long3, %) +DECLOP_3VAR_2IN_1OUT(long3, &) +DECLOP_3VAR_2IN_1OUT(long3, |) +DECLOP_3VAR_2IN_1OUT(long3, ^) +DECLOP_3VAR_2IN_1OUT(long3, <<) +DECLOP_3VAR_2IN_1OUT(long3, >>) + +DECLOP_3VAR_ASSIGN(long3, +=) +DECLOP_3VAR_ASSIGN(long3, -=) +DECLOP_3VAR_ASSIGN(long3, *=) +DECLOP_3VAR_ASSIGN(long3, /=) +DECLOP_3VAR_ASSIGN(long3, %=) +DECLOP_3VAR_ASSIGN(long3, &=) +DECLOP_3VAR_ASSIGN(long3, |=) +DECLOP_3VAR_ASSIGN(long3, ^=) +DECLOP_3VAR_ASSIGN(long3, <<=) +DECLOP_3VAR_ASSIGN(long3, >>=) + +DECLOP_3VAR_PREOP(long3, ++) +DECLOP_3VAR_PREOP(long3, --) + +DECLOP_3VAR_POSTOP(long3, ++) +DECLOP_3VAR_POSTOP(long3, --) + +DECLOP_3VAR_COMP(long3, ==) +DECLOP_3VAR_COMP(long3, !=) +DECLOP_3VAR_COMP(long3, <) +DECLOP_3VAR_COMP(long3, >) +DECLOP_3VAR_COMP(long3, <=) +DECLOP_3VAR_COMP(long3, >=) + +DECLOP_3VAR_COMP(long3, &&) +DECLOP_3VAR_COMP(long3, ||) + +DECLOP_3VAR_1IN_1OUT(long3, ~) +DECLOP_3VAR_1IN_BOOLOUT(long3, !) + +DECLOP_3VAR_SCALE_PRODUCT(long3, unsigned char) +DECLOP_3VAR_SCALE_PRODUCT(long3, signed char) +DECLOP_3VAR_SCALE_PRODUCT(long3, unsigned short) +DECLOP_3VAR_SCALE_PRODUCT(long3, signed short) +DECLOP_3VAR_SCALE_PRODUCT(long3, unsigned int) +DECLOP_3VAR_SCALE_PRODUCT(long3, signed int) +DECLOP_3VAR_SCALE_PRODUCT(long3, float) +DECLOP_3VAR_SCALE_PRODUCT(long3, unsigned long) +DECLOP_3VAR_SCALE_PRODUCT(long3, signed long) +DECLOP_3VAR_SCALE_PRODUCT(long3, double) +DECLOP_3VAR_SCALE_PRODUCT(long3, unsigned long long) +DECLOP_3VAR_SCALE_PRODUCT(long3, signed long long) + +// SIGNED LONG4 + +DECLOP_4VAR_2IN_1OUT(long4, +) +DECLOP_4VAR_2IN_1OUT(long4, -) +DECLOP_4VAR_2IN_1OUT(long4, *) +DECLOP_4VAR_2IN_1OUT(long4, /) +DECLOP_4VAR_2IN_1OUT(long4, %) +DECLOP_4VAR_2IN_1OUT(long4, &) +DECLOP_4VAR_2IN_1OUT(long4, |) +DECLOP_4VAR_2IN_1OUT(long4, ^) +DECLOP_4VAR_2IN_1OUT(long4, <<) +DECLOP_4VAR_2IN_1OUT(long4, >>) + +DECLOP_4VAR_ASSIGN(long4, +=) +DECLOP_4VAR_ASSIGN(long4, -=) +DECLOP_4VAR_ASSIGN(long4, *=) +DECLOP_4VAR_ASSIGN(long4, /=) +DECLOP_4VAR_ASSIGN(long4, %=) +DECLOP_4VAR_ASSIGN(long4, &=) +DECLOP_4VAR_ASSIGN(long4, |=) +DECLOP_4VAR_ASSIGN(long4, ^=) +DECLOP_4VAR_ASSIGN(long4, <<=) +DECLOP_4VAR_ASSIGN(long4, >>=) + +DECLOP_4VAR_PREOP(long4, ++) +DECLOP_4VAR_PREOP(long4, --) + +DECLOP_4VAR_POSTOP(long4, ++) +DECLOP_4VAR_POSTOP(long4, --) + +DECLOP_4VAR_COMP(long4, ==) +DECLOP_4VAR_COMP(long4, !=) +DECLOP_4VAR_COMP(long4, <) +DECLOP_4VAR_COMP(long4, >) +DECLOP_4VAR_COMP(long4, <=) +DECLOP_4VAR_COMP(long4, >=) + +DECLOP_4VAR_COMP(long4, &&) +DECLOP_4VAR_COMP(long4, ||) + +DECLOP_4VAR_1IN_1OUT(long4, ~) +DECLOP_4VAR_1IN_BOOLOUT(long4, !) + +DECLOP_4VAR_SCALE_PRODUCT(long4, unsigned char) +DECLOP_4VAR_SCALE_PRODUCT(long4, signed char) +DECLOP_4VAR_SCALE_PRODUCT(long4, unsigned short) +DECLOP_4VAR_SCALE_PRODUCT(long4, signed short) +DECLOP_4VAR_SCALE_PRODUCT(long4, unsigned int) +DECLOP_4VAR_SCALE_PRODUCT(long4, signed int) +DECLOP_4VAR_SCALE_PRODUCT(long4, float) +DECLOP_4VAR_SCALE_PRODUCT(long4, unsigned long) +DECLOP_4VAR_SCALE_PRODUCT(long4, signed long) +DECLOP_4VAR_SCALE_PRODUCT(long4, double) +DECLOP_4VAR_SCALE_PRODUCT(long4, unsigned long long) +DECLOP_4VAR_SCALE_PRODUCT(long4, signed long long) + +// UNSIGNED LONGLONG1 + +DECLOP_1VAR_2IN_1OUT(ulonglong1, +) +DECLOP_1VAR_2IN_1OUT(ulonglong1, -) +DECLOP_1VAR_2IN_1OUT(ulonglong1, *) +DECLOP_1VAR_2IN_1OUT(ulonglong1, /) +DECLOP_1VAR_2IN_1OUT(ulonglong1, %) +DECLOP_1VAR_2IN_1OUT(ulonglong1, &) +DECLOP_1VAR_2IN_1OUT(ulonglong1, |) +DECLOP_1VAR_2IN_1OUT(ulonglong1, ^) +DECLOP_1VAR_2IN_1OUT(ulonglong1, <<) +DECLOP_1VAR_2IN_1OUT(ulonglong1, >>) + + +DECLOP_1VAR_ASSIGN(ulonglong1, +=) +DECLOP_1VAR_ASSIGN(ulonglong1, -=) +DECLOP_1VAR_ASSIGN(ulonglong1, *=) +DECLOP_1VAR_ASSIGN(ulonglong1, /=) +DECLOP_1VAR_ASSIGN(ulonglong1, %=) +DECLOP_1VAR_ASSIGN(ulonglong1, &=) +DECLOP_1VAR_ASSIGN(ulonglong1, |=) +DECLOP_1VAR_ASSIGN(ulonglong1, ^=) +DECLOP_1VAR_ASSIGN(ulonglong1, <<=) +DECLOP_1VAR_ASSIGN(ulonglong1, >>=) + +DECLOP_1VAR_PREOP(ulonglong1, ++) +DECLOP_1VAR_PREOP(ulonglong1, --) + +DECLOP_1VAR_POSTOP(ulonglong1, ++) +DECLOP_1VAR_POSTOP(ulonglong1, --) + +DECLOP_1VAR_COMP(ulonglong1, ==) +DECLOP_1VAR_COMP(ulonglong1, !=) +DECLOP_1VAR_COMP(ulonglong1, <) +DECLOP_1VAR_COMP(ulonglong1, >) +DECLOP_1VAR_COMP(ulonglong1, <=) +DECLOP_1VAR_COMP(ulonglong1, >=) + +DECLOP_1VAR_COMP(ulonglong1, &&) +DECLOP_1VAR_COMP(ulonglong1, ||) + +DECLOP_1VAR_1IN_1OUT(ulonglong1, ~) +DECLOP_1VAR_1IN_BOOLOUT(ulonglong1, !) + +DECLOP_1VAR_SCALE_PRODUCT(ulonglong1, unsigned char) +DECLOP_1VAR_SCALE_PRODUCT(ulonglong1, signed char) +DECLOP_1VAR_SCALE_PRODUCT(ulonglong1, unsigned short) +DECLOP_1VAR_SCALE_PRODUCT(ulonglong1, signed short) +DECLOP_1VAR_SCALE_PRODUCT(ulonglong1, unsigned int) +DECLOP_1VAR_SCALE_PRODUCT(ulonglong1, signed int) +DECLOP_1VAR_SCALE_PRODUCT(ulonglong1, float) +DECLOP_1VAR_SCALE_PRODUCT(ulonglong1, unsigned long) +DECLOP_1VAR_SCALE_PRODUCT(ulonglong1, signed long) +DECLOP_1VAR_SCALE_PRODUCT(ulonglong1, double) +DECLOP_1VAR_SCALE_PRODUCT(ulonglong1, unsigned long long) +DECLOP_1VAR_SCALE_PRODUCT(ulonglong1, signed long long) + +// UNSIGNED LONGLONG2 + +DECLOP_2VAR_2IN_1OUT(ulonglong2, +) +DECLOP_2VAR_2IN_1OUT(ulonglong2, -) +DECLOP_2VAR_2IN_1OUT(ulonglong2, *) +DECLOP_2VAR_2IN_1OUT(ulonglong2, /) +DECLOP_2VAR_2IN_1OUT(ulonglong2, %) +DECLOP_2VAR_2IN_1OUT(ulonglong2, &) +DECLOP_2VAR_2IN_1OUT(ulonglong2, |) +DECLOP_2VAR_2IN_1OUT(ulonglong2, ^) +DECLOP_2VAR_2IN_1OUT(ulonglong2, <<) +DECLOP_2VAR_2IN_1OUT(ulonglong2, >>) + +DECLOP_2VAR_ASSIGN(ulonglong2, +=) +DECLOP_2VAR_ASSIGN(ulonglong2, -=) +DECLOP_2VAR_ASSIGN(ulonglong2, *=) +DECLOP_2VAR_ASSIGN(ulonglong2, /=) +DECLOP_2VAR_ASSIGN(ulonglong2, %=) +DECLOP_2VAR_ASSIGN(ulonglong2, &=) +DECLOP_2VAR_ASSIGN(ulonglong2, |=) +DECLOP_2VAR_ASSIGN(ulonglong2, ^=) +DECLOP_2VAR_ASSIGN(ulonglong2, <<=) +DECLOP_2VAR_ASSIGN(ulonglong2, >>=) + +DECLOP_2VAR_PREOP(ulonglong2, ++) +DECLOP_2VAR_PREOP(ulonglong2, --) + +DECLOP_2VAR_POSTOP(ulonglong2, ++) +DECLOP_2VAR_POSTOP(ulonglong2, --) + +DECLOP_2VAR_COMP(ulonglong2, ==) +DECLOP_2VAR_COMP(ulonglong2, !=) +DECLOP_2VAR_COMP(ulonglong2, <) +DECLOP_2VAR_COMP(ulonglong2, >) +DECLOP_2VAR_COMP(ulonglong2, <=) +DECLOP_2VAR_COMP(ulonglong2, >=) + +DECLOP_2VAR_COMP(ulonglong2, &&) +DECLOP_2VAR_COMP(ulonglong2, ||) + +DECLOP_2VAR_1IN_1OUT(ulonglong2, ~) +DECLOP_2VAR_1IN_BOOLOUT(ulonglong2, !) + +DECLOP_2VAR_SCALE_PRODUCT(ulonglong2, unsigned char) +DECLOP_2VAR_SCALE_PRODUCT(ulonglong2, signed char) +DECLOP_2VAR_SCALE_PRODUCT(ulonglong2, unsigned short) +DECLOP_2VAR_SCALE_PRODUCT(ulonglong2, signed short) +DECLOP_2VAR_SCALE_PRODUCT(ulonglong2, unsigned int) +DECLOP_2VAR_SCALE_PRODUCT(ulonglong2, signed int) +DECLOP_2VAR_SCALE_PRODUCT(ulonglong2, float) +DECLOP_2VAR_SCALE_PRODUCT(ulonglong2, unsigned long) +DECLOP_2VAR_SCALE_PRODUCT(ulonglong2, signed long) +DECLOP_2VAR_SCALE_PRODUCT(ulonglong2, double) +DECLOP_2VAR_SCALE_PRODUCT(ulonglong2, unsigned long long) +DECLOP_2VAR_SCALE_PRODUCT(ulonglong2, signed long long) + +// UNSIGNED LONGLONG3 + +DECLOP_3VAR_2IN_1OUT(ulonglong3, +) +DECLOP_3VAR_2IN_1OUT(ulonglong3, -) +DECLOP_3VAR_2IN_1OUT(ulonglong3, *) +DECLOP_3VAR_2IN_1OUT(ulonglong3, /) +DECLOP_3VAR_2IN_1OUT(ulonglong3, %) +DECLOP_3VAR_2IN_1OUT(ulonglong3, &) +DECLOP_3VAR_2IN_1OUT(ulonglong3, |) +DECLOP_3VAR_2IN_1OUT(ulonglong3, ^) +DECLOP_3VAR_2IN_1OUT(ulonglong3, <<) +DECLOP_3VAR_2IN_1OUT(ulonglong3, >>) + +DECLOP_3VAR_ASSIGN(ulonglong3, +=) +DECLOP_3VAR_ASSIGN(ulonglong3, -=) +DECLOP_3VAR_ASSIGN(ulonglong3, *=) +DECLOP_3VAR_ASSIGN(ulonglong3, /=) +DECLOP_3VAR_ASSIGN(ulonglong3, %=) +DECLOP_3VAR_ASSIGN(ulonglong3, &=) +DECLOP_3VAR_ASSIGN(ulonglong3, |=) +DECLOP_3VAR_ASSIGN(ulonglong3, ^=) +DECLOP_3VAR_ASSIGN(ulonglong3, <<=) +DECLOP_3VAR_ASSIGN(ulonglong3, >>=) + +DECLOP_3VAR_PREOP(ulonglong3, ++) +DECLOP_3VAR_PREOP(ulonglong3, --) + +DECLOP_3VAR_POSTOP(ulonglong3, ++) +DECLOP_3VAR_POSTOP(ulonglong3, --) + +DECLOP_3VAR_COMP(ulonglong3, ==) +DECLOP_3VAR_COMP(ulonglong3, !=) +DECLOP_3VAR_COMP(ulonglong3, <) +DECLOP_3VAR_COMP(ulonglong3, >) +DECLOP_3VAR_COMP(ulonglong3, <=) +DECLOP_3VAR_COMP(ulonglong3, >=) + +DECLOP_3VAR_COMP(ulonglong3, &&) +DECLOP_3VAR_COMP(ulonglong3, ||) + +DECLOP_3VAR_1IN_1OUT(ulonglong3, ~) +DECLOP_3VAR_1IN_BOOLOUT(ulonglong3, !) + +DECLOP_3VAR_SCALE_PRODUCT(ulonglong3, unsigned char) +DECLOP_3VAR_SCALE_PRODUCT(ulonglong3, signed char) +DECLOP_3VAR_SCALE_PRODUCT(ulonglong3, unsigned short) +DECLOP_3VAR_SCALE_PRODUCT(ulonglong3, signed short) +DECLOP_3VAR_SCALE_PRODUCT(ulonglong3, unsigned int) +DECLOP_3VAR_SCALE_PRODUCT(ulonglong3, signed int) +DECLOP_3VAR_SCALE_PRODUCT(ulonglong3, float) +DECLOP_3VAR_SCALE_PRODUCT(ulonglong3, unsigned long) +DECLOP_3VAR_SCALE_PRODUCT(ulonglong3, signed long) +DECLOP_3VAR_SCALE_PRODUCT(ulonglong3, double) +DECLOP_3VAR_SCALE_PRODUCT(ulonglong3, unsigned long long) +DECLOP_3VAR_SCALE_PRODUCT(ulonglong3, signed long long) + +// UNSIGNED LONGLONG4 + +DECLOP_4VAR_2IN_1OUT(ulonglong4, +) +DECLOP_4VAR_2IN_1OUT(ulonglong4, -) +DECLOP_4VAR_2IN_1OUT(ulonglong4, *) +DECLOP_4VAR_2IN_1OUT(ulonglong4, /) +DECLOP_4VAR_2IN_1OUT(ulonglong4, %) +DECLOP_4VAR_2IN_1OUT(ulonglong4, &) +DECLOP_4VAR_2IN_1OUT(ulonglong4, |) +DECLOP_4VAR_2IN_1OUT(ulonglong4, ^) +DECLOP_4VAR_2IN_1OUT(ulonglong4, <<) +DECLOP_4VAR_2IN_1OUT(ulonglong4, >>) + +DECLOP_4VAR_ASSIGN(ulonglong4, +=) +DECLOP_4VAR_ASSIGN(ulonglong4, -=) +DECLOP_4VAR_ASSIGN(ulonglong4, *=) +DECLOP_4VAR_ASSIGN(ulonglong4, /=) +DECLOP_4VAR_ASSIGN(ulonglong4, %=) +DECLOP_4VAR_ASSIGN(ulonglong4, &=) +DECLOP_4VAR_ASSIGN(ulonglong4, |=) +DECLOP_4VAR_ASSIGN(ulonglong4, ^=) +DECLOP_4VAR_ASSIGN(ulonglong4, <<=) +DECLOP_4VAR_ASSIGN(ulonglong4, >>=) + +DECLOP_4VAR_PREOP(ulonglong4, ++) +DECLOP_4VAR_PREOP(ulonglong4, --) + +DECLOP_4VAR_POSTOP(ulonglong4, ++) +DECLOP_4VAR_POSTOP(ulonglong4, --) + +DECLOP_4VAR_COMP(ulonglong4, ==) +DECLOP_4VAR_COMP(ulonglong4, !=) +DECLOP_4VAR_COMP(ulonglong4, <) +DECLOP_4VAR_COMP(ulonglong4, >) +DECLOP_4VAR_COMP(ulonglong4, <=) +DECLOP_4VAR_COMP(ulonglong4, >=) + +DECLOP_4VAR_COMP(ulonglong4, &&) +DECLOP_4VAR_COMP(ulonglong4, ||) + +DECLOP_4VAR_1IN_1OUT(ulonglong4, ~) +DECLOP_4VAR_1IN_BOOLOUT(ulonglong4, !) + +DECLOP_4VAR_SCALE_PRODUCT(ulonglong4, unsigned char) +DECLOP_4VAR_SCALE_PRODUCT(ulonglong4, signed char) +DECLOP_4VAR_SCALE_PRODUCT(ulonglong4, unsigned short) +DECLOP_4VAR_SCALE_PRODUCT(ulonglong4, signed short) +DECLOP_4VAR_SCALE_PRODUCT(ulonglong4, unsigned int) +DECLOP_4VAR_SCALE_PRODUCT(ulonglong4, signed int) +DECLOP_4VAR_SCALE_PRODUCT(ulonglong4, float) +DECLOP_4VAR_SCALE_PRODUCT(ulonglong4, unsigned long) +DECLOP_4VAR_SCALE_PRODUCT(ulonglong4, signed long) +DECLOP_4VAR_SCALE_PRODUCT(ulonglong4, double) +DECLOP_4VAR_SCALE_PRODUCT(ulonglong4, unsigned long long) +DECLOP_4VAR_SCALE_PRODUCT(ulonglong4, signed long long) + +// SIGNED LONGLONG1 + +DECLOP_1VAR_2IN_1OUT(longlong1, +) +DECLOP_1VAR_2IN_1OUT(longlong1, -) +DECLOP_1VAR_2IN_1OUT(longlong1, *) +DECLOP_1VAR_2IN_1OUT(longlong1, /) +DECLOP_1VAR_2IN_1OUT(longlong1, %) +DECLOP_1VAR_2IN_1OUT(longlong1, &) +DECLOP_1VAR_2IN_1OUT(longlong1, |) +DECLOP_1VAR_2IN_1OUT(longlong1, ^) +DECLOP_1VAR_2IN_1OUT(longlong1, <<) +DECLOP_1VAR_2IN_1OUT(longlong1, >>) + + +DECLOP_1VAR_ASSIGN(longlong1, +=) +DECLOP_1VAR_ASSIGN(longlong1, -=) +DECLOP_1VAR_ASSIGN(longlong1, *=) +DECLOP_1VAR_ASSIGN(longlong1, /=) +DECLOP_1VAR_ASSIGN(longlong1, %=) +DECLOP_1VAR_ASSIGN(longlong1, &=) +DECLOP_1VAR_ASSIGN(longlong1, |=) +DECLOP_1VAR_ASSIGN(longlong1, ^=) +DECLOP_1VAR_ASSIGN(longlong1, <<=) +DECLOP_1VAR_ASSIGN(longlong1, >>=) + +DECLOP_1VAR_PREOP(longlong1, ++) +DECLOP_1VAR_PREOP(longlong1, --) + +DECLOP_1VAR_POSTOP(longlong1, ++) +DECLOP_1VAR_POSTOP(longlong1, --) + +DECLOP_1VAR_COMP(longlong1, ==) +DECLOP_1VAR_COMP(longlong1, !=) +DECLOP_1VAR_COMP(longlong1, <) +DECLOP_1VAR_COMP(longlong1, >) +DECLOP_1VAR_COMP(longlong1, <=) +DECLOP_1VAR_COMP(longlong1, >=) + +DECLOP_1VAR_COMP(longlong1, &&) +DECLOP_1VAR_COMP(longlong1, ||) + +DECLOP_1VAR_1IN_1OUT(longlong1, ~) +DECLOP_1VAR_1IN_BOOLOUT(longlong1, !) + +DECLOP_1VAR_SCALE_PRODUCT(longlong1, unsigned char) +DECLOP_1VAR_SCALE_PRODUCT(longlong1, signed char) +DECLOP_1VAR_SCALE_PRODUCT(longlong1, unsigned short) +DECLOP_1VAR_SCALE_PRODUCT(longlong1, signed short) +DECLOP_1VAR_SCALE_PRODUCT(longlong1, unsigned int) +DECLOP_1VAR_SCALE_PRODUCT(longlong1, signed int) +DECLOP_1VAR_SCALE_PRODUCT(longlong1, float) +DECLOP_1VAR_SCALE_PRODUCT(longlong1, unsigned long) +DECLOP_1VAR_SCALE_PRODUCT(longlong1, signed long) +DECLOP_1VAR_SCALE_PRODUCT(longlong1, double) +DECLOP_1VAR_SCALE_PRODUCT(longlong1, unsigned long long) +DECLOP_1VAR_SCALE_PRODUCT(longlong1, signed long long) + +// SIGNED LONGLONG2 + +DECLOP_2VAR_2IN_1OUT(longlong2, +) +DECLOP_2VAR_2IN_1OUT(longlong2, -) +DECLOP_2VAR_2IN_1OUT(longlong2, *) +DECLOP_2VAR_2IN_1OUT(longlong2, /) +DECLOP_2VAR_2IN_1OUT(longlong2, %) +DECLOP_2VAR_2IN_1OUT(longlong2, &) +DECLOP_2VAR_2IN_1OUT(longlong2, |) +DECLOP_2VAR_2IN_1OUT(longlong2, ^) +DECLOP_2VAR_2IN_1OUT(longlong2, <<) +DECLOP_2VAR_2IN_1OUT(longlong2, >>) + +DECLOP_2VAR_ASSIGN(longlong2, +=) +DECLOP_2VAR_ASSIGN(longlong2, -=) +DECLOP_2VAR_ASSIGN(longlong2, *=) +DECLOP_2VAR_ASSIGN(longlong2, /=) +DECLOP_2VAR_ASSIGN(longlong2, %=) +DECLOP_2VAR_ASSIGN(longlong2, &=) +DECLOP_2VAR_ASSIGN(longlong2, |=) +DECLOP_2VAR_ASSIGN(longlong2, ^=) +DECLOP_2VAR_ASSIGN(longlong2, <<=) +DECLOP_2VAR_ASSIGN(longlong2, >>=) + +DECLOP_2VAR_PREOP(longlong2, ++) +DECLOP_2VAR_PREOP(longlong2, --) + +DECLOP_2VAR_POSTOP(longlong2, ++) +DECLOP_2VAR_POSTOP(longlong2, --) + +DECLOP_2VAR_COMP(longlong2, ==) +DECLOP_2VAR_COMP(longlong2, !=) +DECLOP_2VAR_COMP(longlong2, <) +DECLOP_2VAR_COMP(longlong2, >) +DECLOP_2VAR_COMP(longlong2, <=) +DECLOP_2VAR_COMP(longlong2, >=) + +DECLOP_2VAR_COMP(longlong2, &&) +DECLOP_2VAR_COMP(longlong2, ||) + +DECLOP_2VAR_1IN_1OUT(longlong2, ~) +DECLOP_2VAR_1IN_BOOLOUT(longlong2, !) + +DECLOP_2VAR_SCALE_PRODUCT(longlong2, unsigned char) +DECLOP_2VAR_SCALE_PRODUCT(longlong2, signed char) +DECLOP_2VAR_SCALE_PRODUCT(longlong2, unsigned short) +DECLOP_2VAR_SCALE_PRODUCT(longlong2, signed short) +DECLOP_2VAR_SCALE_PRODUCT(longlong2, unsigned int) +DECLOP_2VAR_SCALE_PRODUCT(longlong2, signed int) +DECLOP_2VAR_SCALE_PRODUCT(longlong2, float) +DECLOP_2VAR_SCALE_PRODUCT(longlong2, unsigned long) +DECLOP_2VAR_SCALE_PRODUCT(longlong2, signed long) +DECLOP_2VAR_SCALE_PRODUCT(longlong2, double) +DECLOP_2VAR_SCALE_PRODUCT(longlong2, unsigned long long) +DECLOP_2VAR_SCALE_PRODUCT(longlong2, signed long long) + +// SIGNED LONGLONG3 + +DECLOP_3VAR_2IN_1OUT(longlong3, +) +DECLOP_3VAR_2IN_1OUT(longlong3, -) +DECLOP_3VAR_2IN_1OUT(longlong3, *) +DECLOP_3VAR_2IN_1OUT(longlong3, /) +DECLOP_3VAR_2IN_1OUT(longlong3, %) +DECLOP_3VAR_2IN_1OUT(longlong3, &) +DECLOP_3VAR_2IN_1OUT(longlong3, |) +DECLOP_3VAR_2IN_1OUT(longlong3, ^) +DECLOP_3VAR_2IN_1OUT(longlong3, <<) +DECLOP_3VAR_2IN_1OUT(longlong3, >>) + +DECLOP_3VAR_ASSIGN(longlong3, +=) +DECLOP_3VAR_ASSIGN(longlong3, -=) +DECLOP_3VAR_ASSIGN(longlong3, *=) +DECLOP_3VAR_ASSIGN(longlong3, /=) +DECLOP_3VAR_ASSIGN(longlong3, %=) +DECLOP_3VAR_ASSIGN(longlong3, &=) +DECLOP_3VAR_ASSIGN(longlong3, |=) +DECLOP_3VAR_ASSIGN(longlong3, ^=) +DECLOP_3VAR_ASSIGN(longlong3, <<=) +DECLOP_3VAR_ASSIGN(longlong3, >>=) + +DECLOP_3VAR_PREOP(longlong3, ++) +DECLOP_3VAR_PREOP(longlong3, --) + +DECLOP_3VAR_POSTOP(longlong3, ++) +DECLOP_3VAR_POSTOP(longlong3, --) + +DECLOP_3VAR_COMP(longlong3, ==) +DECLOP_3VAR_COMP(longlong3, !=) +DECLOP_3VAR_COMP(longlong3, <) +DECLOP_3VAR_COMP(longlong3, >) +DECLOP_3VAR_COMP(longlong3, <=) +DECLOP_3VAR_COMP(longlong3, >=) + +DECLOP_3VAR_COMP(longlong3, &&) +DECLOP_3VAR_COMP(longlong3, ||) + +DECLOP_3VAR_1IN_1OUT(longlong3, ~) +DECLOP_3VAR_1IN_BOOLOUT(longlong3, !) + +DECLOP_3VAR_SCALE_PRODUCT(longlong3, unsigned char) +DECLOP_3VAR_SCALE_PRODUCT(longlong3, signed char) +DECLOP_3VAR_SCALE_PRODUCT(longlong3, unsigned short) +DECLOP_3VAR_SCALE_PRODUCT(longlong3, signed short) +DECLOP_3VAR_SCALE_PRODUCT(longlong3, unsigned int) +DECLOP_3VAR_SCALE_PRODUCT(longlong3, signed int) +DECLOP_3VAR_SCALE_PRODUCT(longlong3, float) +DECLOP_3VAR_SCALE_PRODUCT(longlong3, unsigned long) +DECLOP_3VAR_SCALE_PRODUCT(longlong3, signed long) +DECLOP_3VAR_SCALE_PRODUCT(longlong3, double) +DECLOP_3VAR_SCALE_PRODUCT(longlong3, unsigned long long) +DECLOP_3VAR_SCALE_PRODUCT(longlong3, signed long long) + +// SIGNED LONGLONG4 + +DECLOP_4VAR_2IN_1OUT(longlong4, +) +DECLOP_4VAR_2IN_1OUT(longlong4, -) +DECLOP_4VAR_2IN_1OUT(longlong4, *) +DECLOP_4VAR_2IN_1OUT(longlong4, /) +DECLOP_4VAR_2IN_1OUT(longlong4, %) +DECLOP_4VAR_2IN_1OUT(longlong4, &) +DECLOP_4VAR_2IN_1OUT(longlong4, |) +DECLOP_4VAR_2IN_1OUT(longlong4, ^) +DECLOP_4VAR_2IN_1OUT(longlong4, <<) +DECLOP_4VAR_2IN_1OUT(longlong4, >>) + +DECLOP_4VAR_ASSIGN(longlong4, +=) +DECLOP_4VAR_ASSIGN(longlong4, -=) +DECLOP_4VAR_ASSIGN(longlong4, *=) +DECLOP_4VAR_ASSIGN(longlong4, /=) +DECLOP_4VAR_ASSIGN(longlong4, %=) +DECLOP_4VAR_ASSIGN(longlong4, &=) +DECLOP_4VAR_ASSIGN(longlong4, |=) +DECLOP_4VAR_ASSIGN(longlong4, ^=) +DECLOP_4VAR_ASSIGN(longlong4, <<=) +DECLOP_4VAR_ASSIGN(longlong4, >>=) + +DECLOP_4VAR_PREOP(longlong4, ++) +DECLOP_4VAR_PREOP(longlong4, --) + +DECLOP_4VAR_POSTOP(longlong4, ++) +DECLOP_4VAR_POSTOP(longlong4, --) + +DECLOP_4VAR_COMP(longlong4, ==) +DECLOP_4VAR_COMP(longlong4, !=) +DECLOP_4VAR_COMP(longlong4, <) +DECLOP_4VAR_COMP(longlong4, >) +DECLOP_4VAR_COMP(longlong4, <=) +DECLOP_4VAR_COMP(longlong4, >=) + +DECLOP_4VAR_COMP(longlong4, &&) +DECLOP_4VAR_COMP(longlong4, ||) + +DECLOP_4VAR_1IN_1OUT(longlong4, ~) +DECLOP_4VAR_1IN_BOOLOUT(longlong4, !) + +DECLOP_4VAR_SCALE_PRODUCT(longlong4, unsigned char) +DECLOP_4VAR_SCALE_PRODUCT(longlong4, signed char) +DECLOP_4VAR_SCALE_PRODUCT(longlong4, unsigned short) +DECLOP_4VAR_SCALE_PRODUCT(longlong4, signed short) +DECLOP_4VAR_SCALE_PRODUCT(longlong4, unsigned int) +DECLOP_4VAR_SCALE_PRODUCT(longlong4, signed int) +DECLOP_4VAR_SCALE_PRODUCT(longlong4, float) +DECLOP_4VAR_SCALE_PRODUCT(longlong4, unsigned long) +DECLOP_4VAR_SCALE_PRODUCT(longlong4, signed long) +DECLOP_4VAR_SCALE_PRODUCT(longlong4, double) +DECLOP_4VAR_SCALE_PRODUCT(longlong4, unsigned long long) +DECLOP_4VAR_SCALE_PRODUCT(longlong4, signed long long) + + #endif +#endif diff --git a/projects/hip/src/device_util.cpp b/projects/hip/src/device_util.cpp index 5452e1c905..669fcb7570 100644 --- a/projects/hip/src/device_util.cpp +++ b/projects/hip/src/device_util.cpp @@ -14,7 +14,7 @@ all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -129,34 +129,34 @@ __device__ int __hip_move_dpp(int src, int dpp_ctrl, int row_mask, int bank_mask __device__ char4 __hip_hc_add8pk(char4 in1, char4 in2) { char4 out; - unsigned one1 = in1.val & MASK1; - unsigned one2 = in2.val & MASK1; - out.val = (one1 + one2) & MASK1; - one1 = in1.val & MASK2; - one2 = in2.val & MASK2; - out.val = out.val | ((one1 + one2) & MASK2); + unsigned one1 = in1.a & MASK1; + unsigned one2 = in2.a & MASK1; + out.a = (one1 + one2) & MASK1; + one1 = in1.a & MASK2; + one2 = in2.a & MASK2; + out.a = out.a | ((one1 + one2) & MASK2); return out; } __device__ char4 __hip_hc_sub8pk(char4 in1, char4 in2) { char4 out; - unsigned one1 = in1.val & MASK1; - unsigned one2 = in2.val & MASK1; - out.val = (one1 - one2) & MASK1; - one1 = in1.val & MASK2; - one2 = in2.val & MASK2; - out.val = out.val | ((one1 - one2) & MASK2); + unsigned one1 = in1.a & MASK1; + unsigned one2 = in2.a & MASK1; + out.a = (one1 - one2) & MASK1; + one1 = in1.a & MASK2; + one2 = in2.a & MASK2; + out.a = out.a | ((one1 - one2) & MASK2); return out; } __device__ char4 __hip_hc_mul8pk(char4 in1, char4 in2) { char4 out; - unsigned one1 = in1.val & MASK1; - unsigned one2 = in2.val & MASK1; - out.val = (one1 * one2) & MASK1; - one1 = in1.val & MASK2; - one2 = in2.val & MASK2; - out.val = out.val | ((one1 * one2) & MASK2); + unsigned one1 = in1.a & MASK1; + unsigned one2 = in2.a & MASK1; + out.a = (one1 * one2) & MASK1; + one1 = in1.a & MASK2; + one2 = in2.a & MASK2; + out.a = out.a | ((one1 * one2) & MASK2); return out; } @@ -2179,426 +2179,17 @@ __device__ double __hip_fast_dsqrt_rz(double x) { return hc::fast_math::sqrt(x); } -__HIP_DEVICE__ char1 make_char1(signed char x) -{ - char1 c1; - c1.x = x; - return c1; -} - -__HIP_DEVICE__ char2 make_char2(signed char x, signed char y) -{ - char2 c2; - c2.x = x; - c2.y = y; - return c2; -} - -__HIP_DEVICE__ char3 make_char3(signed char x, signed char y, signed char z) -{ - char3 c3; - c3.x = x; - c3.y = y; - c3.z = z; - return c3; -} - -__HIP_DEVICE__ char4 make_char4(signed char x, signed char y, signed char z, signed char w) -{ - char4 c4; - c4.x = x; - c4.y = y; - c4.z = z; - c4.w = w; - return c4; -} - -__HIP_DEVICE__ short1 make_short1(short x) -{ - short1 s1; - s1.x = x; - return s1; -} - -__HIP_DEVICE__ short2 make_short2(short x, short y) -{ - short2 s2; - s2.x = x; - s2.y = y; - return s2; -} - -__HIP_DEVICE__ short3 make_short3(short x, short y, short z) -{ - short3 s3; - s3.x = x; - s3.y = y; - s3.z = z; - return s3; -} - -__HIP_DEVICE__ short4 make_short4(short x, short y, short z, short w) -{ - short4 s4; - s4.x = x; - s4.y = y; - s4.z = z; - s4.w = w; - return s4; -} - -__HIP_DEVICE__ int1 make_int1(int x) -{ - int1 i1; - i1.x = x; - return i1; -} - -__HIP_DEVICE__ int2 make_int2(int x, int y) -{ - int2 i2; - i2.x = x; - i2.y = y; - return i2; -} - -__HIP_DEVICE__ int3 make_int3(int x, int y, int z) -{ - int3 i3; - i3.x = x; - i3.y = y; - i3.z = z; - return i3; -} - -__HIP_DEVICE__ int4 make_int4(int x, int y, int z, int w) -{ - int4 i4; - i4.x = x; - i4.y = y; - i4.z = z; - i4.w = w; - return i4; -} - -__HIP_DEVICE__ long1 make_long1(long x) -{ - long1 l1; - l1.x = x; - return l1; -} - -__HIP_DEVICE__ long2 make_long2(long x, long y) -{ - long2 l2; - l2.x = x; - l2.y = y; - return l2; -} - -__HIP_DEVICE__ long3 make_long3(long x, long y, long z) -{ - long3 l3; - l3.x = x; - l3.y = y; - l3.z = z; - return l3; -} - -__HIP_DEVICE__ long4 make_long4(long x, long y, long z, long w) -{ - long4 l4; - l4.x = x; - l4.y = y; - l4.z = z; - l4.w = w; - return l4; -} - -__HIP_DEVICE__ longlong1 make_longlong1(long long x) -{ - longlong1 l1; - l1.x = x; - return l1; -} - -__HIP_DEVICE__ longlong2 make_longlong2(long long x, long long y) -{ - longlong2 l2; - l2.x = x; - l2.y = y; - return l2; -} - -__HIP_DEVICE__ longlong3 make_longlong3(long long x, long long y, long long z) -{ - longlong3 l3; - l3.x = x; - l3.y = y; - l3.z = z; - return l3; -} - -__HIP_DEVICE__ longlong4 make_longlong4(long long x, long long y, long long z, long long w) -{ - longlong4 l4; - l4.x = x; - l4.y = y; - l4.z = z; - l4.w = w; - return l4; -} - -__HIP_DEVICE__ uchar1 make_uchar1(unsigned char x) -{ - uchar1 c1; - c1.x = x; - return c1; -} - -__HIP_DEVICE__ uchar2 make_uchar2(unsigned char x, unsigned char y) -{ - uchar2 c2; - c2.x = x; - c2.y = y; - return c2; -} - -__HIP_DEVICE__ uchar3 make_uchar3(unsigned char x, unsigned char y, unsigned char z) -{ - uchar3 c3; - c3.x = x; - c3.y = y; - c3.z = z; - return c3; -} - -__HIP_DEVICE__ uchar4 make_uchar4(unsigned char x, unsigned char y, unsigned char z, unsigned char w) -{ - uchar4 c4; - c4.x = x; - c4.y = y; - c4.z = z; - c4.w = w; - return c4; -} - -__HIP_DEVICE__ ushort1 make_ushort1(unsigned short x) -{ - ushort1 s1; - s1.x = x; - return s1; -} - -__HIP_DEVICE__ ushort2 make_ushort2(unsigned short x, unsigned short y) -{ - ushort2 s2; - s2.x = x; - s2.y = y; - return s2; -} - -__HIP_DEVICE__ ushort3 make_ushort3(unsigned short x, unsigned short y, unsigned short z) -{ - ushort3 s3; - s3.x = x; - s3.y = y; - s3.z = z; - return s3; -} - -__HIP_DEVICE__ ushort4 make_ushort4(unsigned short x, unsigned short y, unsigned short z, unsigned short w) -{ - ushort4 s4; - s4.x = x; - s4.y = y; - s4.z = z; - s4.w = w; - return s4; -} - -__HIP_DEVICE__ uint1 make_uint1(unsigned int x) -{ - uint1 i1; - i1.x = x; - return i1; -} - -__HIP_DEVICE__ uint2 make_uint2(unsigned int x, unsigned int y) -{ - uint2 i2; - i2.x = x; - i2.y = y; - return i2; -} - -__HIP_DEVICE__ uint3 make_uint3(unsigned int x, unsigned int y, unsigned int z) -{ - uint3 i3; - i3.x = x; - i3.y = y; - i3.z = z; - return i3; -} - -__HIP_DEVICE__ uint4 make_uint4(unsigned int x, unsigned int y, unsigned int z, unsigned int w) -{ - uint4 i4; - i4.x = x; - i4.y = y; - i4.z = z; - i4.w = w; - return i4; -} - -__HIP_DEVICE__ ulong1 make_ulong1(unsigned long x) -{ - ulong1 l1; - l1.x = x; - return l1; -} - -__HIP_DEVICE__ ulong2 make_ulong2(unsigned long x, unsigned long y) -{ - ulong2 l2; - l2.x = x; - l2.y = y; - return l2; -} - -__HIP_DEVICE__ ulong3 make_ulong3(unsigned long x, unsigned long y, unsigned long z) -{ - ulong3 l3; - l3.x = x; - l3.y = y; - l3.z = z; - return l3; -} - -__HIP_DEVICE__ ulong4 make_ulong4(unsigned long x, unsigned long y, unsigned long z, unsigned long w) -{ - ulong4 l4; - l4.x = x; - l4.y = y; - l4.z = z; - l4.w = w; - return l4; -} - -__HIP_DEVICE__ ulonglong1 make_ulonglong1(unsigned long long x) -{ - ulonglong1 l1; - l1.x = x; - return l1; -} - -__HIP_DEVICE__ ulonglong2 make_ulonglong2(unsigned long long x, unsigned long long y) -{ - ulonglong2 l2; - l2.x = x; - l2.y = y; - return l2; -} - -__HIP_DEVICE__ ulonglong3 make_ulonglong3(unsigned long long x, unsigned long long y, unsigned long long z) -{ - ulonglong3 l3; - l3.x = x; - l3.y = y; - l3.z = z; - return l3; -} - -__HIP_DEVICE__ ulonglong4 make_ulonglong4(unsigned long long x, unsigned long long y, unsigned long long z, unsigned long long w) -{ - ulonglong4 l4; - l4.x = x; - l4.y = y; - l4.z = z; - l4.w = w; - return l4; -} - -__HIP_DEVICE__ float1 make_float1(float x) -{ - float1 f1; - f1.x = x; - return f1; -} - -__HIP_DEVICE__ float2 make_float2(float x, float y) -{ - float2 f2; - f2.x = x; - f2.y = y; - return f2; -} - -__HIP_DEVICE__ float3 make_float3(float x, float y, float z) -{ - float3 f3; - f3.x = x; - f3.y = y; - f3.z = z; - return f3; -} - -__HIP_DEVICE__ float4 make_float4(float x, float y, float z, float w) -{ - float4 f4; - f4.x = x; - f4.y = y; - f4.z = z; - f4.w = w; - return f4; -} - -__HIP_DEVICE__ double1 make_double1(double x) -{ - double1 d1; - d1.x = x; - return d1; -} - -__HIP_DEVICE__ double2 make_double2(double x, double y) -{ - double2 d2; - d2.x = x; - d2.y = y; - return d2; -} - -__HIP_DEVICE__ double3 make_double3(double x, double y, double z) -{ - double3 d3; - d3.x = x; - d3.y = y; - d3.z = z; - return d3; -} - -__HIP_DEVICE__ double4 make_double4(double x, double y, double z, double w) -{ - double4 d4; - d4.x = x; - d4.y = y; - d4.z = z; - d4.w = w; - return d4; -} - - -__HIP_DEVICE__ double __longlong_as_double(long long int x) +__device__ double __longlong_as_double(long long int x) { return static_cast(x); } -__HIP_DEVICE__ long long __double_as_longlong(double x) +__device__ long long __double_as_longlong(double x) { return static_cast(x); } -__HIP_DEVICE__ void __threadfence_system(void){ +__device__ void __threadfence_system(void){ // no-op } @@ -3391,5 +2982,3 @@ __host__ double norm4d(double a, double b, double c, double d) { return std::sqrt(a*a + b*b + c*c + d*d); } - - diff --git a/projects/hip/src/hip_ldg.cpp b/projects/hip/src/hip_ldg.cpp index f3e593355a..075e1926f1 100644 --- a/projects/hip/src/hip_ldg.cpp +++ b/projects/hip/src/hip_ldg.cpp @@ -20,23 +20,22 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include - #include "hip/hcc_detail/hip_ldg.h" +#include "hip/hcc_detail/hip_vector_types.h" __device__ char __ldg(const char* ptr) { - return ptr[0]; + return *ptr; } __device__ char2 __ldg(const char2* ptr) { - return ptr[0]; + return *ptr; } __device__ char4 __ldg(const char4* ptr) { - return ptr[0]; + return *ptr; } __device__ signed char __ldg(const signed char* ptr) @@ -169,6 +168,3 @@ __device__ double2 __ldg(const double2* ptr) { return ptr[0]; } - - - diff --git a/projects/hip/tests/src/deviceLib/hip_test_ldg.cpp b/projects/hip/tests/src/deviceLib/hip_test_ldg.cpp index 0737533175..171ff1afd0 100644 --- a/projects/hip/tests/src/deviceLib/hip_test_ldg.cpp +++ b/projects/hip/tests/src/deviceLib/hip_test_ldg.cpp @@ -32,6 +32,7 @@ THE SOFTWARE. #include #include #include "hip/hip_runtime.h" +#include "hip/hip_vector_types.h" #include "test_common.h" #if (__hcc_workweek__ >= 16164) || defined (__HIP_PLATFORM_NVCC__) @@ -389,4 +390,3 @@ int main() { } #endif - From ea788070530f31eb6e8be3a90b1ac658e590bec9 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Wed, 11 Jan 2017 17:53:32 -0600 Subject: [PATCH 056/281] fixed compilation issues with operator overloading device data types Change-Id: I6a60282f0c04a3c0d382cdf2d67ad8d9156880ad [ROCm/hip commit: e30887dc694d130e434c8800daad8f6216def8ab] --- .../include/hip/hcc_detail/hip_vector_types.h | 80 +++++++++---------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/hip_vector_types.h b/projects/hip/include/hip/hcc_detail/hip_vector_types.h index 812bd272d0..e15da69b3f 100644 --- a/projects/hip/include/hip/hcc_detail/hip_vector_types.h +++ b/projects/hip/include/hip/hcc_detail/hip_vector_types.h @@ -1131,14 +1131,14 @@ struct longlong4 { } __attribute__((aligned(32))); #define DECLOP_MAKE_ONE_COMPONENT(comp, type) \ -__device__ __host__ inline type make_##type(comp x) { \ +__device__ __host__ static inline type make_##type(comp x) { \ type ret; \ ret.x = x; \ return ret; \ } #define DECLOP_MAKE_TWO_COMPONENT(comp, type) \ -__device__ __host__ inline type make_##type(comp x, comp y) { \ +__device__ __host__ static inline type make_##type(comp x, comp y) { \ type ret; \ ret.x = x; \ ret.y = y; \ @@ -1146,7 +1146,7 @@ __device__ __host__ inline type make_##type(comp x, comp y) { \ } #define DECLOP_MAKE_THREE_COMPONENT(comp, type) \ -__device__ __host__ inline type make_##type(comp x, comp y, comp z) { \ +__device__ __host__ static inline type make_##type(comp x, comp y, comp z) { \ type ret; \ ret.x = x; \ ret.y = y; \ @@ -1155,7 +1155,7 @@ __device__ __host__ inline type make_##type(comp x, comp y, comp z) { \ } #define DECLOP_MAKE_FOUR_COMPONENT(comp, type) \ -__device__ __host__ inline type make_##type(comp x, comp y, comp z, comp w) { \ +__device__ __host__ static inline type make_##type(comp x, comp y, comp z, comp w) { \ type ret; \ ret.x = x; \ ret.y = y; \ @@ -1228,39 +1228,39 @@ DECLOP_MAKE_FOUR_COMPONENT(signed long, longlong4); #if __cplusplus #define DECLOP_1VAR_2IN_1OUT(type, op) \ -__device__ __host__ type operator op (const type& lhs, const type& rhs) { \ +__device__ __host__ static type operator op (const type& lhs, const type& rhs) { \ type ret; \ ret.x = lhs.x op rhs.x; \ return ret; \ } #define DECLOP_1VAR_SCALE_PRODUCT(type, type1) \ -__device__ __host__ type operator * (const type& lhs, type1 rhs) { \ +__device__ __host__ static type operator * (const type& lhs, type1 rhs) { \ type ret; \ ret.x = lhs.x * rhs; \ return ret; \ } \ \ -__device__ __host__ type operator * (type1 lhs, const type& rhs) { \ +__device__ __host__ static type operator * (type1 lhs, const type& rhs) { \ type ret; \ ret.x = lhs * rhs.x; \ return ret; \ } #define DECLOP_1VAR_ASSIGN(type, op) \ -__device__ __host__ inline type& operator op ( type& lhs, const type& rhs) { \ +__device__ __host__ static inline type& operator op ( type& lhs, const type& rhs) { \ lhs.x op rhs.x; \ return lhs; \ } #define DECLOP_1VAR_PREOP(type, op) \ -__device__ __host__ inline type& operator op (type& val) { \ +__device__ __host__ static inline type& operator op (type& val) { \ op val.x; \ return val; \ } #define DECLOP_1VAR_POSTOP(type, op) \ -__device__ __host__ type operator op (type& val, int i) { \ +__device__ __host__ static type operator op (type& val, int i) { \ type ret; \ ret.x = val.x; \ val.x op; \ @@ -1268,19 +1268,19 @@ __device__ __host__ type operator op (type& val, int i) { \ } #define DECLOP_1VAR_COMP(type, op) \ -__device__ __host__ inline bool operator op (type& lhs, type& rhs) { \ +__device__ __host__ static inline bool operator op (type& lhs, type& rhs) { \ return lhs.x op rhs.x; \ } #define DECLOP_1VAR_1IN_1OUT(type, op) \ -__device__ __host__ type operator op(type& rhs) { \ +__device__ __host__ static type operator op(type& rhs) { \ type ret; \ ret.x = op rhs.x; \ return ret; \ } #define DECLOP_1VAR_1IN_BOOLOUT(type, op) \ -__device__ __host__ inline bool operator op (type& rhs) { \ +__device__ __host__ static inline bool operator op (type& rhs) { \ return op rhs.x; \ } @@ -1289,7 +1289,7 @@ __device__ __host__ inline bool operator op (type& rhs) { \ */ #define DECLOP_2VAR_2IN_1OUT(type, op) \ -__device__ __host__ type operator op (const type& lhs, const type& rhs) { \ +__device__ __host__ static type operator op (const type& lhs, const type& rhs) { \ type ret; \ ret.x = lhs.x op rhs.x; \ ret.y = lhs.y op rhs.y; \ @@ -1297,14 +1297,14 @@ __device__ __host__ type operator op (const type& lhs, const type& rhs) { \ } #define DECLOP_2VAR_SCALE_PRODUCT(type, type1) \ -__device__ __host__ type operator * (const type& lhs, type1 rhs) { \ +__device__ __host__ static type operator * (const type& lhs, type1 rhs) { \ type ret; \ ret.x = lhs.x * rhs; \ ret.y = lhs.y * rhs; \ return ret; \ } \ \ -__device__ __host__ type operator * (type1 lhs, const type& rhs) { \ +__device__ __host__ static type operator * (type1 lhs, const type& rhs) { \ type ret; \ ret.x = lhs * rhs.x; \ ret.y = lhs * rhs.y; \ @@ -1312,21 +1312,21 @@ __device__ __host__ type operator * (type1 lhs, const type& rhs) { \ } #define DECLOP_2VAR_ASSIGN(type, op) \ -__device__ __host__ inline type& operator op ( type& lhs, const type& rhs) { \ +__device__ __host__ static inline type& operator op ( type& lhs, const type& rhs) { \ lhs.x op rhs.x; \ lhs.y op rhs.y; \ return lhs; \ } #define DECLOP_2VAR_PREOP(type, op) \ -__device__ __host__ inline type& operator op (type& val) { \ +__device__ __host__ static inline type& operator op (type& val) { \ op val.x; \ op val.y; \ return val; \ } #define DECLOP_2VAR_POSTOP(type, op) \ -__device__ __host__ type operator op (type& val, int i) { \ +__device__ __host__ static type operator op (type& val, int i) { \ type ret; \ ret.x = val.x; \ ret.y = val.y; \ @@ -1336,12 +1336,12 @@ __device__ __host__ type operator op (type& val, int i) { \ } #define DECLOP_2VAR_COMP(type, op) \ -__device__ __host__ inline bool operator op (type& lhs, type& rhs) { \ +__device__ __host__ static inline bool operator op (type& lhs, type& rhs) { \ return lhs.x op rhs.x && lhs.y op rhs.y; \ } #define DECLOP_2VAR_1IN_1OUT(type, op) \ -__device__ __host__ type operator op(type &rhs) { \ +__device__ __host__ static type operator op(type &rhs) { \ type ret; \ ret.x = op rhs.x; \ ret.y = op rhs.y; \ @@ -1349,7 +1349,7 @@ __device__ __host__ type operator op(type &rhs) { \ } #define DECLOP_2VAR_1IN_BOOLOUT(type, op) \ -__device__ __host__ inline bool operator op (type &rhs) { \ +__device__ __host__ static inline bool operator op (type &rhs) { \ return op rhs.x && op rhs.y; \ } @@ -1359,7 +1359,7 @@ __device__ __host__ inline bool operator op (type &rhs) { \ */ #define DECLOP_3VAR_2IN_1OUT(type, op) \ -__device__ __host__ type operator op (const type& lhs, const type& rhs) { \ +__device__ __host__ static type operator op (const type& lhs, const type& rhs) { \ type ret; \ ret.x = lhs.x op rhs.x; \ ret.y = lhs.y op rhs.y; \ @@ -1368,7 +1368,7 @@ __device__ __host__ type operator op (const type& lhs, const type& rhs) { \ } #define DECLOP_3VAR_SCALE_PRODUCT(type, type1) \ -__device__ __host__ type operator * (const type& lhs, type1 rhs) { \ +__device__ __host__ static type operator * (const type& lhs, type1 rhs) { \ type ret; \ ret.x = lhs.x * rhs; \ ret.y = lhs.y * rhs; \ @@ -1376,7 +1376,7 @@ __device__ __host__ type operator * (const type& lhs, type1 rhs) { \ return ret; \ } \ \ -__device__ __host__ type operator * (type1 lhs, const type& rhs) { \ +__device__ __host__ static type operator * (type1 lhs, const type& rhs) { \ type ret; \ ret.x = lhs * rhs.x; \ ret.y = lhs * rhs.y; \ @@ -1385,7 +1385,7 @@ __device__ __host__ type operator * (type1 lhs, const type& rhs) { \ } #define DECLOP_3VAR_ASSIGN(type, op) \ -__device__ __host__ inline type& operator op ( type& lhs, const type& rhs) { \ +__device__ __host__ static inline type& operator op ( type& lhs, const type& rhs) { \ lhs.x op rhs.x; \ lhs.y op rhs.y; \ lhs.z op rhs.z; \ @@ -1393,7 +1393,7 @@ __device__ __host__ inline type& operator op ( type& lhs, const type& rhs) { \ } #define DECLOP_3VAR_PREOP(type, op) \ -__device__ __host__ inline type& operator op (type& val) { \ +__device__ __host__ static inline type& operator op (type& val) { \ op val.x; \ op val.y; \ op val.z; \ @@ -1401,7 +1401,7 @@ __device__ __host__ inline type& operator op (type& val) { \ } #define DECLOP_3VAR_POSTOP(type, op) \ -__device__ __host__ type operator op (type& val, int i) { \ +__device__ __host__ static type operator op (type& val, int i) { \ type ret; \ ret.x = val.x; \ ret.y = val.y; \ @@ -1413,12 +1413,12 @@ __device__ __host__ type operator op (type& val, int i) { \ } #define DECLOP_3VAR_COMP(type, op) \ -__device__ __host__ inline bool operator op (type& lhs, type& rhs) { \ +__device__ __host__ static inline bool operator op (type& lhs, type& rhs) { \ return lhs.x op rhs.x && lhs.y op rhs.y && lhs.z op rhs.z; \ } #define DECLOP_3VAR_1IN_1OUT(type, op) \ -__device__ __host__ type operator op(type &rhs) { \ +__device__ __host__ static type operator op(type &rhs) { \ type ret; \ ret.x = op rhs.x; \ ret.y = op rhs.y; \ @@ -1427,7 +1427,7 @@ __device__ __host__ type operator op(type &rhs) { \ } #define DECLOP_3VAR_1IN_BOOLOUT(type, op) \ -__device__ __host__ inline bool operator op (type &rhs) { \ +__device__ __host__ static inline bool operator op (type &rhs) { \ return op rhs.x && op rhs.y && op rhs.z; \ } @@ -1437,7 +1437,7 @@ __device__ __host__ inline bool operator op (type &rhs) { \ */ #define DECLOP_4VAR_2IN_1OUT(type, op) \ -__device__ __host__ type operator op ( const type& lhs, const type& rhs) { \ +__device__ __host__ static type operator op ( const type& lhs, const type& rhs) { \ type ret; \ ret.x = lhs.x op rhs.x; \ ret.y = lhs.y op rhs.y; \ @@ -1447,7 +1447,7 @@ __device__ __host__ type operator op ( const type& lhs, const type& rhs) { \ } #define DECLOP_4VAR_SCALE_PRODUCT(type, type1) \ -__device__ __host__ type operator * (const type& lhs, type1 rhs) { \ +__device__ __host__ static type operator * (const type& lhs, type1 rhs) { \ type ret; \ ret.x = lhs.x * rhs; \ ret.y = lhs.y * rhs; \ @@ -1456,7 +1456,7 @@ __device__ __host__ type operator * (const type& lhs, type1 rhs) { \ return ret; \ } \ \ -__device__ __host__ type operator * (type1 lhs, const type& rhs) { \ +__device__ __host__ static type operator * (type1 lhs, const type& rhs) { \ type ret; \ ret.x = lhs * rhs.x; \ ret.y = lhs * rhs.y; \ @@ -1466,7 +1466,7 @@ __device__ __host__ type operator * (type1 lhs, const type& rhs) { \ } #define DECLOP_4VAR_ASSIGN(type, op) \ -__device__ __host__ inline type& operator op ( type& lhs, const type& rhs) { \ +__device__ __host__ static inline type& operator op ( type& lhs, const type& rhs) { \ lhs.x op rhs.x; \ lhs.y op rhs.y; \ lhs.z op rhs.z; \ @@ -1475,7 +1475,7 @@ __device__ __host__ inline type& operator op ( type& lhs, const type& rhs) { \ } #define DECLOP_4VAR_PREOP(type, op) \ -__device__ __host__ inline type& operator op (type& val) { \ +__device__ __host__ static inline type& operator op (type& val) { \ op val.x; \ op val.y; \ op val.z; \ @@ -1484,7 +1484,7 @@ __device__ __host__ inline type& operator op (type& val) { \ } #define DECLOP_4VAR_POSTOP(type, op) \ -__device__ __host__ type operator op (type& val, int i) { \ +__device__ __host__ static type operator op (type& val, int i) { \ type ret; \ ret.x = val.x; \ ret.y = val.y; \ @@ -1498,12 +1498,12 @@ __device__ __host__ type operator op (type& val, int i) { \ } #define DECLOP_4VAR_COMP(type, op) \ -__device__ __host__ inline bool operator op (type& lhs, type& rhs) { \ +__device__ __host__ static inline bool operator op (type& lhs, type& rhs) { \ return lhs.x op rhs.x && lhs.y op rhs.y && lhs.z op rhs.z && lhs.w op rhs.w; \ } #define DECLOP_4VAR_1IN_1OUT(type, op) \ -__device__ __host__ type operator op(type &rhs) { \ +__device__ __host__ static type operator op(type &rhs) { \ type ret; \ ret.x = op rhs.x; \ ret.y = op rhs.y; \ @@ -1513,7 +1513,7 @@ __device__ __host__ type operator op(type &rhs) { \ } #define DECLOP_4VAR_1IN_BOOLOUT(type, op) \ -__device__ __host__ inline bool operator op (type &rhs) { \ +__device__ __host__ static inline bool operator op (type &rhs) { \ return op rhs.x && op rhs.y && op rhs.z && op rhs.w; \ } From 19c9e073dc557e3c86040ca4af5aca8c7c8e007c Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Wed, 11 Jan 2017 18:02:30 -0600 Subject: [PATCH 057/281] added test for vector data types Change-Id: I0b6624886e474601cb1ef003c5f10adf399a21c9 [ROCm/hip commit: 57294ce46149f831ad97f5c7ccf36b5aba7bb73c] --- .../tests/src/deviceLib/hipVectorTypes.cpp | 3443 +++++++++++++++++ 1 file changed, 3443 insertions(+) create mode 100644 projects/hip/tests/src/deviceLib/hipVectorTypes.cpp diff --git a/projects/hip/tests/src/deviceLib/hipVectorTypes.cpp b/projects/hip/tests/src/deviceLib/hipVectorTypes.cpp new file mode 100644 index 0000000000..0e5757b30d --- /dev/null +++ b/projects/hip/tests/src/deviceLib/hipVectorTypes.cpp @@ -0,0 +1,3443 @@ +/* +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#include +#include +#include + +#define cmpFloat1(in, exp) \ + if(in.x != exp) { \ + std::cout<<"Failed at: "<<__LINE__<<" in func: "<<__func__<<" expected output: "<> f1; + cmpFloat1(f2, 2); + + f1.x = 2; + f2.x = 1; + f1 += f2; + cmpFloat1(f1, 3); + f1 -= f2; + cmpFloat1(f1, 2); + f1 *= f2; + cmpFloat1(f1, 2); + f1 /= f2; + cmpFloat1(f1, 2); + f1 %= f2; + cmpFloat1(f1, 0); + f1 &= f2; + cmpFloat1(f1, 0); + f1 |= f2; + cmpFloat1(f1, 1); + f1 ^= f2; + cmpFloat1(f1, 0); + f1.x = 1; + f1 <<= f2; + cmpFloat1(f1, 2); + f1 >>= f2; + cmpFloat1(f1, 1); + + f1.x = 2; + f2 = f1++; + cmpFloat1(f1, 3); + cmpFloat1(f2, 2); + f2 = f1--; + cmpFloat1(f2, 3); + cmpFloat1(f1, 2); + f2 = ++f1; + cmpFloat1(f1, 3); + cmpFloat1(f2, 3); + f2 = --f1; + cmpFloat1(f1, 2); + cmpFloat1(f2, 2); + + f2 = ~f1; + cmpFloat1(f2, 253); + assert(!f1 == false); + + f1.x = 3; + f2.x = 4; + f3.x = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestUChar2() { + uchar2 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f2.x = 1; + f2.y = 1; + f3 = f1 + f2; + cmpFloat2(f3, 2); + f2 = f3 - f1; + cmpFloat2(f2, 1); + f1 = f2 * f3; + cmpFloat2(f1, 2); + f2 = f1 / f3; + cmpFloat2(f2, 2/2); + f3 = f1 % f2; + cmpFloat2(f3, 0); + f1 = f3 & f2; + cmpFloat2(f1, 0); + f2 = f1 ^ f3; + cmpFloat2(f2, 0); + f1.x = 1; + f1.y = 1; + f2.x = 2; + f2.y = 2; + f3 = f1 << f2; + cmpFloat2(f3, 4); + f2 = f3 >> f1; + cmpFloat2(f2, 2); + + f1.x = 2; + f1.y = 2; + f2.x = 1; + f2.y = 1; + f1 += f2; + cmpFloat2(f1, 3); + f1 -= f2; + cmpFloat2(f1, 2); + f1 *= f2; + cmpFloat2(f1, 2); + f1 /= f2; + cmpFloat2(f1, 2); + f1 %= f2; + cmpFloat2(f1, 0); + f1 &= f2; + cmpFloat2(f1, 0); + f1 |= f2; + cmpFloat2(f1, 1); + f1 ^= f2; + cmpFloat2(f1, 0); + f1.x = 1; + f1.y = 1; + f1 <<= f2; + cmpFloat2(f1, 2); + f1 >>= f2; + cmpFloat2(f1, 1); + + f1.x = 2; + f1.y = 2; + f2 = f1++; + cmpFloat2(f1, 3); + cmpFloat2(f2, 2); + f2 = f1--; + cmpFloat2(f2, 3); + cmpFloat2(f1, 2); + f2 = ++f1; + cmpFloat2(f1, 3); + cmpFloat2(f2, 3); + f2 = --f1; + cmpFloat2(f1, 2); + cmpFloat2(f2, 2); + + f2 = ~f1; + cmpFloat2(f2, 253); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f2.x = 4; + f2.y = 4; + f3.x = 3; + f3.y = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestUChar3() { + uchar3 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f3 = f1 + f2; + cmpFloat3(f3, 2); + f2 = f3 - f1; + cmpFloat3(f2, 1); + f1 = f2 * f3; + cmpFloat3(f1, 2); + f2 = f1 / f3; + cmpFloat3(f2, 2/2); + f3 = f1 % f2; + cmpFloat3(f3, 0); + f1 = f3 & f2; + cmpFloat3(f1, 0); + f2 = f1 ^ f3; + cmpFloat3(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f3 = f1 << f2; + cmpFloat3(f3, 4); + f2 = f3 >> f1; + cmpFloat3(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f1 += f2; + cmpFloat3(f1, 3); + f1 -= f2; + cmpFloat3(f1, 2); + f1 *= f2; + cmpFloat3(f1, 2); + f1 /= f2; + cmpFloat3(f1, 2); + f1 %= f2; + cmpFloat3(f1, 0); + f1 &= f2; + cmpFloat3(f1, 0); + f1 |= f2; + cmpFloat3(f1, 1); + f1 ^= f2; + cmpFloat3(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1 <<= f2; + cmpFloat3(f1, 2); + f1 >>= f2; + cmpFloat3(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2 = f1++; + cmpFloat3(f1, 3); + cmpFloat3(f2, 2); + f2 = f1--; + cmpFloat3(f2, 3); + cmpFloat3(f1, 2); + f2 = ++f1; + cmpFloat3(f1, 3); + cmpFloat3(f2, 3); + f2 = --f1; + cmpFloat3(f1, 2); + cmpFloat3(f2, 2); + + f2 = ~f1; + cmpFloat3(f2, 253); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestUChar4() { + uchar4 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f3 = f1 + f2; + cmpFloat4(f3, 2); + f2 = f3 - f1; + cmpFloat4(f2, 1); + f1 = f2 * f3; + cmpFloat4(f1, 2); + f2 = f1 / f3; + cmpFloat4(f2, 2/2); + f3 = f1 % f2; + cmpFloat4(f3, 0); + f1 = f3 & f2; + cmpFloat4(f1, 0); + f2 = f1 ^ f3; + cmpFloat4(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f2.w = 2; + f3 = f1 << f2; + cmpFloat4(f3, 4); + f2 = f3 >> f1; + cmpFloat4(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f1 += f2; + cmpFloat4(f1, 3); + f1 -= f2; + cmpFloat4(f1, 2); + f1 *= f2; + cmpFloat4(f1, 2); + f1 /= f2; + cmpFloat4(f1, 2); + f1 %= f2; + cmpFloat4(f1, 0); + f1 &= f2; + cmpFloat4(f1, 0); + f1 |= f2; + cmpFloat4(f1, 1); + f1 ^= f2; + cmpFloat4(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f1 <<= f2; + cmpFloat4(f1, 2); + f1 >>= f2; + cmpFloat4(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2 = f1++; + cmpFloat4(f1, 3); + cmpFloat4(f2, 2); + f2 = f1--; + cmpFloat4(f2, 3); + cmpFloat4(f1, 2); + f2 = ++f1; + cmpFloat4(f1, 3); + cmpFloat4(f2, 3); + f2 = --f1; + cmpFloat4(f1, 2); + cmpFloat4(f2, 2); + + f2 = ~f1; + cmpFloat4(f2, 253); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f2.w = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + f3.w = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestChar1() { + char1 f1, f2, f3; + f1.x = 1; + f2.x = 1; + f3 = f1 + f2; + cmpFloat1(f3, 2); + f2 = f3 - f1; + cmpFloat1(f2, 1); + f1 = f2 * f3; + cmpFloat1(f1, 2); + f2 = f1 / f3; + cmpFloat1(f2, 2/2); + f3 = f1 % f2; + cmpFloat1(f3, 0); + f1 = f3 & f2; + cmpFloat1(f1, 0); + f2 = f1 ^ f3; + cmpFloat1(f2, 0); + f1.x = 1; + f2.x = 2; + f3 = f1 << f2; + cmpFloat1(f3, 4); + f2 = f3 >> f1; + cmpFloat1(f2, 2); + + f1.x = 2; + f2.x = 1; + f1 += f2; + cmpFloat1(f1, 3); + f1 -= f2; + cmpFloat1(f1, 2); + f1 *= f2; + cmpFloat1(f1, 2); + f1 /= f2; + cmpFloat1(f1, 2); + f1 %= f2; + cmpFloat1(f1, 0); + f1 &= f2; + cmpFloat1(f1, 0); + f1 |= f2; + cmpFloat1(f1, 1); + f1 ^= f2; + cmpFloat1(f1, 0); + f1.x = 1; + f1 <<= f2; + cmpFloat1(f1, 2); + f1 >>= f2; + cmpFloat1(f1, 1); + + f1.x = 2; + f2 = f1++; + cmpFloat1(f1, 3); + cmpFloat1(f2, 2); + f2 = f1--; + cmpFloat1(f2, 3); + cmpFloat1(f1, 2); + f2 = ++f1; + cmpFloat1(f1, 3); + cmpFloat1(f2, 3); + f2 = --f1; + cmpFloat1(f1, 2); + cmpFloat1(f2, 2); + + f2 = ~f1; + cmpFloat1(f2, (char)253); + assert(!f1 == false); + + f1.x = 3; + f2.x = 4; + f3.x = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestChar2() { + char2 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f2.x = 1; + f2.y = 1; + f3 = f1 + f2; + cmpFloat2(f3, 2); + f2 = f3 - f1; + cmpFloat2(f2, 1); + f1 = f2 * f3; + cmpFloat2(f1, 2); + f2 = f1 / f3; + cmpFloat2(f2, 2/2); + f3 = f1 % f2; + cmpFloat2(f3, 0); + f1 = f3 & f2; + cmpFloat2(f1, 0); + f2 = f1 ^ f3; + cmpFloat2(f2, 0); + f1.x = 1; + f1.y = 1; + f2.x = 2; + f2.y = 2; + f3 = f1 << f2; + cmpFloat2(f3, 4); + f2 = f3 >> f1; + cmpFloat2(f2, 2); + + f1.x = 2; + f1.y = 2; + f2.x = 1; + f2.y = 1; + f1 += f2; + cmpFloat2(f1, 3); + f1 -= f2; + cmpFloat2(f1, 2); + f1 *= f2; + cmpFloat2(f1, 2); + f1 /= f2; + cmpFloat2(f1, 2); + f1 %= f2; + cmpFloat2(f1, 0); + f1 &= f2; + cmpFloat2(f1, 0); + f1 |= f2; + cmpFloat2(f1, 1); + f1 ^= f2; + cmpFloat2(f1, 0); + f1.x = 1; + f1.y = 1; + f1 <<= f2; + cmpFloat2(f1, 2); + f1 >>= f2; + cmpFloat2(f1, 1); + + f1.x = 2; + f1.y = 2; + f2 = f1++; + cmpFloat2(f1, 3); + cmpFloat2(f2, 2); + f2 = f1--; + cmpFloat2(f2, 3); + cmpFloat2(f1, 2); + f2 = ++f1; + cmpFloat2(f1, 3); + cmpFloat2(f2, 3); + f2 = --f1; + cmpFloat2(f1, 2); + cmpFloat2(f2, 2); + + f2 = ~f1; + cmpFloat2(f2, (char)253); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f2.x = 4; + f2.y = 4; + f3.x = 3; + f3.y = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestChar3() { + char3 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f3 = f1 + f2; + cmpFloat3(f3, 2); + f2 = f3 - f1; + cmpFloat3(f2, 1); + f1 = f2 * f3; + cmpFloat3(f1, 2); + f2 = f1 / f3; + cmpFloat3(f2, 2/2); + f3 = f1 % f2; + cmpFloat3(f3, 0); + f1 = f3 & f2; + cmpFloat3(f1, 0); + f2 = f1 ^ f3; + cmpFloat3(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f3 = f1 << f2; + cmpFloat3(f3, 4); + f2 = f3 >> f1; + cmpFloat3(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f1 += f2; + cmpFloat3(f1, 3); + f1 -= f2; + cmpFloat3(f1, 2); + f1 *= f2; + cmpFloat3(f1, 2); + f1 /= f2; + cmpFloat3(f1, 2); + f1 %= f2; + cmpFloat3(f1, 0); + f1 &= f2; + cmpFloat3(f1, 0); + f1 |= f2; + cmpFloat3(f1, 1); + f1 ^= f2; + cmpFloat3(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1 <<= f2; + cmpFloat3(f1, 2); + f1 >>= f2; + cmpFloat3(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2 = f1++; + cmpFloat3(f1, 3); + cmpFloat3(f2, 2); + f2 = f1--; + cmpFloat3(f2, 3); + cmpFloat3(f1, 2); + f2 = ++f1; + cmpFloat3(f1, 3); + cmpFloat3(f2, 3); + f2 = --f1; + cmpFloat3(f1, 2); + cmpFloat3(f2, 2); + + f2 = ~f1; + cmpFloat3(f2, (char)253); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestChar4() { + char4 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f3 = f1 + f2; + cmpFloat4(f3, 2); + f2 = f3 - f1; + cmpFloat4(f2, 1); + f1 = f2 * f3; + cmpFloat4(f1, 2); + f2 = f1 / f3; + cmpFloat4(f2, 2/2); + f3 = f1 % f2; + cmpFloat4(f3, 0); + f1 = f3 & f2; + cmpFloat4(f1, 0); + f2 = f1 ^ f3; + cmpFloat4(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f2.w = 2; + f3 = f1 << f2; + cmpFloat4(f3, 4); + f2 = f3 >> f1; + cmpFloat4(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f1 += f2; + cmpFloat4(f1, 3); + f1 -= f2; + cmpFloat4(f1, 2); + f1 *= f2; + cmpFloat4(f1, 2); + f1 /= f2; + cmpFloat4(f1, 2); + f1 %= f2; + cmpFloat4(f1, 0); + f1 &= f2; + cmpFloat4(f1, 0); + f1 |= f2; + cmpFloat4(f1, 1); + f1 ^= f2; + cmpFloat4(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f1 <<= f2; + cmpFloat4(f1, 2); + f1 >>= f2; + cmpFloat4(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2 = f1++; + cmpFloat4(f1, 3); + cmpFloat4(f2, 2); + f2 = f1--; + cmpFloat4(f2, 3); + cmpFloat4(f1, 2); + f2 = ++f1; + cmpFloat4(f1, 3); + cmpFloat4(f2, 3); + f2 = --f1; + cmpFloat4(f1, 2); + cmpFloat4(f2, 2); + + f2 = ~f1; + cmpFloat4(f2, (char)253); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f2.w = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + f3.w = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestUShort1() { + ushort1 f1, f2, f3; + f1.x = 1; + f2.x = 1; + f3 = f1 + f2; + cmpFloat1(f3, 2); + f2 = f3 - f1; + cmpFloat1(f2, 1); + f1 = f2 * f3; + cmpFloat1(f1, 2); + f2 = f1 / f3; + cmpFloat1(f2, 2/2); + f3 = f1 % f2; + cmpFloat1(f3, 0); + f1 = f3 & f2; + cmpFloat1(f1, 0); + f2 = f1 ^ f3; + cmpFloat1(f2, 0); + f1.x = 1; + f2.x = 2; + f3 = f1 << f2; + cmpFloat1(f3, 4); + f2 = f3 >> f1; + cmpFloat1(f2, 2); + + f1.x = 2; + f2.x = 1; + f1 += f2; + cmpFloat1(f1, 3); + f1 -= f2; + cmpFloat1(f1, 2); + f1 *= f2; + cmpFloat1(f1, 2); + f1 /= f2; + cmpFloat1(f1, 2); + f1 %= f2; + cmpFloat1(f1, 0); + f1 &= f2; + cmpFloat1(f1, 0); + f1 |= f2; + cmpFloat1(f1, 1); + f1 ^= f2; + cmpFloat1(f1, 0); + f1.x = 1; + f1 <<= f2; + cmpFloat1(f1, 2); + f1 >>= f2; + cmpFloat1(f1, 1); + + f1.x = 2; + f2 = f1++; + cmpFloat1(f1, 3); + cmpFloat1(f2, 2); + f2 = f1--; + cmpFloat1(f2, 3); + cmpFloat1(f1, 2); + f2 = ++f1; + cmpFloat1(f1, 3); + cmpFloat1(f2, 3); + f2 = --f1; + cmpFloat1(f1, 2); + cmpFloat1(f2, 2); + + f2 = ~f1; + cmpFloat1(f2, (unsigned short)65533); + assert(!f1 == false); + + f1.x = 3; + f2.x = 4; + f3.x = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestUShort2() { + ushort2 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f2.x = 1; + f2.y = 1; + f3 = f1 + f2; + cmpFloat2(f3, 2); + f2 = f3 - f1; + cmpFloat2(f2, 1); + f1 = f2 * f3; + cmpFloat2(f1, 2); + f2 = f1 / f3; + cmpFloat2(f2, 2/2); + f3 = f1 % f2; + cmpFloat2(f3, 0); + f1 = f3 & f2; + cmpFloat2(f1, 0); + f2 = f1 ^ f3; + cmpFloat2(f2, 0); + f1.x = 1; + f1.y = 1; + f2.x = 2; + f2.y = 2; + f3 = f1 << f2; + cmpFloat2(f3, 4); + f2 = f3 >> f1; + cmpFloat2(f2, 2); + + f1.x = 2; + f1.y = 2; + f2.x = 1; + f2.y = 1; + f1 += f2; + cmpFloat2(f1, 3); + f1 -= f2; + cmpFloat2(f1, 2); + f1 *= f2; + cmpFloat2(f1, 2); + f1 /= f2; + cmpFloat2(f1, 2); + f1 %= f2; + cmpFloat2(f1, 0); + f1 &= f2; + cmpFloat2(f1, 0); + f1 |= f2; + cmpFloat2(f1, 1); + f1 ^= f2; + cmpFloat2(f1, 0); + f1.x = 1; + f1.y = 1; + f1 <<= f2; + cmpFloat2(f1, 2); + f1 >>= f2; + cmpFloat2(f1, 1); + + f1.x = 2; + f1.y = 2; + f2 = f1++; + cmpFloat2(f1, 3); + cmpFloat2(f2, 2); + f2 = f1--; + cmpFloat2(f2, 3); + cmpFloat2(f1, 2); + f2 = ++f1; + cmpFloat2(f1, 3); + cmpFloat2(f2, 3); + f2 = --f1; + cmpFloat2(f1, 2); + cmpFloat2(f2, 2); + + f2 = ~f1; + cmpFloat2(f2, (unsigned short)65533); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f2.x = 4; + f2.y = 4; + f3.x = 3; + f3.y = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestUShort3() { + ushort3 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f3 = f1 + f2; + cmpFloat3(f3, 2); + f2 = f3 - f1; + cmpFloat3(f2, 1); + f1 = f2 * f3; + cmpFloat3(f1, 2); + f2 = f1 / f3; + cmpFloat3(f2, 2/2); + f3 = f1 % f2; + cmpFloat3(f3, 0); + f1 = f3 & f2; + cmpFloat3(f1, 0); + f2 = f1 ^ f3; + cmpFloat3(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f3 = f1 << f2; + cmpFloat3(f3, 4); + f2 = f3 >> f1; + cmpFloat3(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f1 += f2; + cmpFloat3(f1, 3); + f1 -= f2; + cmpFloat3(f1, 2); + f1 *= f2; + cmpFloat3(f1, 2); + f1 /= f2; + cmpFloat3(f1, 2); + f1 %= f2; + cmpFloat3(f1, 0); + f1 &= f2; + cmpFloat3(f1, 0); + f1 |= f2; + cmpFloat3(f1, 1); + f1 ^= f2; + cmpFloat3(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1 <<= f2; + cmpFloat3(f1, 2); + f1 >>= f2; + cmpFloat3(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2 = f1++; + cmpFloat3(f1, 3); + cmpFloat3(f2, 2); + f2 = f1--; + cmpFloat3(f2, 3); + cmpFloat3(f1, 2); + f2 = ++f1; + cmpFloat3(f1, 3); + cmpFloat3(f2, 3); + f2 = --f1; + cmpFloat3(f1, 2); + cmpFloat3(f2, 2); + + f2 = ~f1; + cmpFloat3(f2, (unsigned short)65533); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestUShort4() { + ushort4 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f3 = f1 + f2; + cmpFloat4(f3, 2); + f2 = f3 - f1; + cmpFloat4(f2, 1); + f1 = f2 * f3; + cmpFloat4(f1, 2); + f2 = f1 / f3; + cmpFloat4(f2, 2/2); + f3 = f1 % f2; + cmpFloat4(f3, 0); + f1 = f3 & f2; + cmpFloat4(f1, 0); + f2 = f1 ^ f3; + cmpFloat4(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f2.w = 2; + f3 = f1 << f2; + cmpFloat4(f3, 4); + f2 = f3 >> f1; + cmpFloat4(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f1 += f2; + cmpFloat4(f1, 3); + f1 -= f2; + cmpFloat4(f1, 2); + f1 *= f2; + cmpFloat4(f1, 2); + f1 /= f2; + cmpFloat4(f1, 2); + f1 %= f2; + cmpFloat4(f1, 0); + f1 &= f2; + cmpFloat4(f1, 0); + f1 |= f2; + cmpFloat4(f1, 1); + f1 ^= f2; + cmpFloat4(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f1 <<= f2; + cmpFloat4(f1, 2); + f1 >>= f2; + cmpFloat4(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2 = f1++; + cmpFloat4(f1, 3); + cmpFloat4(f2, 2); + f2 = f1--; + cmpFloat4(f2, 3); + cmpFloat4(f1, 2); + f2 = ++f1; + cmpFloat4(f1, 3); + cmpFloat4(f2, 3); + f2 = --f1; + cmpFloat4(f1, 2); + cmpFloat4(f2, 2); + + f2 = ~f1; + cmpFloat4(f2, (unsigned short)65533); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f2.w = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + f3.w = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestShort1() { + short1 f1, f2, f3; + f1.x = 1; + f2.x = 1; + f3 = f1 + f2; + cmpFloat1(f3, 2); + f2 = f3 - f1; + cmpFloat1(f2, 1); + f1 = f2 * f3; + cmpFloat1(f1, 2); + f2 = f1 / f3; + cmpFloat1(f2, 2/2); + f3 = f1 % f2; + cmpFloat1(f3, 0); + f1 = f3 & f2; + cmpFloat1(f1, 0); + f2 = f1 ^ f3; + cmpFloat1(f2, 0); + f1.x = 1; + f2.x = 2; + f3 = f1 << f2; + cmpFloat1(f3, 4); + f2 = f3 >> f1; + cmpFloat1(f2, 2); + + f1.x = 2; + f2.x = 1; + f1 += f2; + cmpFloat1(f1, 3); + f1 -= f2; + cmpFloat1(f1, 2); + f1 *= f2; + cmpFloat1(f1, 2); + f1 /= f2; + cmpFloat1(f1, 2); + f1 %= f2; + cmpFloat1(f1, 0); + f1 &= f2; + cmpFloat1(f1, 0); + f1 |= f2; + cmpFloat1(f1, 1); + f1 ^= f2; + cmpFloat1(f1, 0); + f1.x = 1; + f1 <<= f2; + cmpFloat1(f1, 2); + f1 >>= f2; + cmpFloat1(f1, 1); + + f1.x = 2; + f2 = f1++; + cmpFloat1(f1, 3); + cmpFloat1(f2, 2); + f2 = f1--; + cmpFloat1(f2, 3); + cmpFloat1(f1, 2); + f2 = ++f1; + cmpFloat1(f1, 3); + cmpFloat1(f2, 3); + f2 = --f1; + cmpFloat1(f1, 2); + cmpFloat1(f2, 2); + + f2 = ~f1; + cmpFloat1(f2, (signed short)65533); + assert(!f1 == false); + + f1.x = 3; + f2.x = 4; + f3.x = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestShort2() { + short2 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f2.x = 1; + f2.y = 1; + f3 = f1 + f2; + cmpFloat2(f3, 2); + f2 = f3 - f1; + cmpFloat2(f2, 1); + f1 = f2 * f3; + cmpFloat2(f1, 2); + f2 = f1 / f3; + cmpFloat2(f2, 2/2); + f3 = f1 % f2; + cmpFloat2(f3, 0); + f1 = f3 & f2; + cmpFloat2(f1, 0); + f2 = f1 ^ f3; + cmpFloat2(f2, 0); + f1.x = 1; + f1.y = 1; + f2.x = 2; + f2.y = 2; + f3 = f1 << f2; + cmpFloat2(f3, 4); + f2 = f3 >> f1; + cmpFloat2(f2, 2); + + f1.x = 2; + f1.y = 2; + f2.x = 1; + f2.y = 1; + f1 += f2; + cmpFloat2(f1, 3); + f1 -= f2; + cmpFloat2(f1, 2); + f1 *= f2; + cmpFloat2(f1, 2); + f1 /= f2; + cmpFloat2(f1, 2); + f1 %= f2; + cmpFloat2(f1, 0); + f1 &= f2; + cmpFloat2(f1, 0); + f1 |= f2; + cmpFloat2(f1, 1); + f1 ^= f2; + cmpFloat2(f1, 0); + f1.x = 1; + f1.y = 1; + f1 <<= f2; + cmpFloat2(f1, 2); + f1 >>= f2; + cmpFloat2(f1, 1); + + f1.x = 2; + f1.y = 2; + f2 = f1++; + cmpFloat2(f1, 3); + cmpFloat2(f2, 2); + f2 = f1--; + cmpFloat2(f2, 3); + cmpFloat2(f1, 2); + f2 = ++f1; + cmpFloat2(f1, 3); + cmpFloat2(f2, 3); + f2 = --f1; + cmpFloat2(f1, 2); + cmpFloat2(f2, 2); + + f2 = ~f1; + cmpFloat2(f2, (signed short)65533); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f2.x = 4; + f2.y = 4; + f3.x = 3; + f3.y = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestShort3() { + short3 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f3 = f1 + f2; + cmpFloat3(f3, 2); + f2 = f3 - f1; + cmpFloat3(f2, 1); + f1 = f2 * f3; + cmpFloat3(f1, 2); + f2 = f1 / f3; + cmpFloat3(f2, 2/2); + f3 = f1 % f2; + cmpFloat3(f3, 0); + f1 = f3 & f2; + cmpFloat3(f1, 0); + f2 = f1 ^ f3; + cmpFloat3(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f3 = f1 << f2; + cmpFloat3(f3, 4); + f2 = f3 >> f1; + cmpFloat3(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f1 += f2; + cmpFloat3(f1, 3); + f1 -= f2; + cmpFloat3(f1, 2); + f1 *= f2; + cmpFloat3(f1, 2); + f1 /= f2; + cmpFloat3(f1, 2); + f1 %= f2; + cmpFloat3(f1, 0); + f1 &= f2; + cmpFloat3(f1, 0); + f1 |= f2; + cmpFloat3(f1, 1); + f1 ^= f2; + cmpFloat3(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1 <<= f2; + cmpFloat3(f1, 2); + f1 >>= f2; + cmpFloat3(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2 = f1++; + cmpFloat3(f1, 3); + cmpFloat3(f2, 2); + f2 = f1--; + cmpFloat3(f2, 3); + cmpFloat3(f1, 2); + f2 = ++f1; + cmpFloat3(f1, 3); + cmpFloat3(f2, 3); + f2 = --f1; + cmpFloat3(f1, 2); + cmpFloat3(f2, 2); + + f2 = ~f1; + cmpFloat3(f2, (signed short)65533); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestShort4() { + short4 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f3 = f1 + f2; + cmpFloat4(f3, 2); + f2 = f3 - f1; + cmpFloat4(f2, 1); + f1 = f2 * f3; + cmpFloat4(f1, 2); + f2 = f1 / f3; + cmpFloat4(f2, 2/2); + f3 = f1 % f2; + cmpFloat4(f3, 0); + f1 = f3 & f2; + cmpFloat4(f1, 0); + f2 = f1 ^ f3; + cmpFloat4(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f2.w = 2; + f3 = f1 << f2; + cmpFloat4(f3, 4); + f2 = f3 >> f1; + cmpFloat4(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f1 += f2; + cmpFloat4(f1, 3); + f1 -= f2; + cmpFloat4(f1, 2); + f1 *= f2; + cmpFloat4(f1, 2); + f1 /= f2; + cmpFloat4(f1, 2); + f1 %= f2; + cmpFloat4(f1, 0); + f1 &= f2; + cmpFloat4(f1, 0); + f1 |= f2; + cmpFloat4(f1, 1); + f1 ^= f2; + cmpFloat4(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f1 <<= f2; + cmpFloat4(f1, 2); + f1 >>= f2; + cmpFloat4(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2 = f1++; + cmpFloat4(f1, 3); + cmpFloat4(f2, 2); + f2 = f1--; + cmpFloat4(f2, 3); + cmpFloat4(f1, 2); + f2 = ++f1; + cmpFloat4(f1, 3); + cmpFloat4(f2, 3); + f2 = --f1; + cmpFloat4(f1, 2); + cmpFloat4(f2, 2); + + f2 = ~f1; + cmpFloat4(f2, (signed short)65533); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f2.w = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + f3.w = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + + +bool TestUInt1() { + uint1 f1, f2, f3; + f1.x = 1; + f2.x = 1; + f3 = f1 + f2; + cmpFloat1(f3, 2); + f2 = f3 - f1; + cmpFloat1(f2, 1); + f1 = f2 * f3; + cmpFloat1(f1, 2); + f2 = f1 / f3; + cmpFloat1(f2, 2/2); + f3 = f1 % f2; + cmpFloat1(f3, 0); + f1 = f3 & f2; + cmpFloat1(f1, 0); + f2 = f1 ^ f3; + cmpFloat1(f2, 0); + f1.x = 1; + f2.x = 2; + f3 = f1 << f2; + cmpFloat1(f3, 4); + f2 = f3 >> f1; + cmpFloat1(f2, 2); + + f1.x = 2; + f2.x = 1; + f1 += f2; + cmpFloat1(f1, 3); + f1 -= f2; + cmpFloat1(f1, 2); + f1 *= f2; + cmpFloat1(f1, 2); + f1 /= f2; + cmpFloat1(f1, 2); + f1 %= f2; + cmpFloat1(f1, 0); + f1 &= f2; + cmpFloat1(f1, 0); + f1 |= f2; + cmpFloat1(f1, 1); + f1 ^= f2; + cmpFloat1(f1, 0); + f1.x = 1; + f1 <<= f2; + cmpFloat1(f1, 2); + f1 >>= f2; + cmpFloat1(f1, 1); + + f1.x = 2; + f2 = f1++; + cmpFloat1(f1, 3); + cmpFloat1(f2, 2); + f2 = f1--; + cmpFloat1(f2, 3); + cmpFloat1(f1, 2); + f2 = ++f1; + cmpFloat1(f1, 3); + cmpFloat1(f2, 3); + f2 = --f1; + cmpFloat1(f1, 2); + cmpFloat1(f2, 2); + + f2 = ~f1; + cmpFloat1(f2, (unsigned int)4294967293); + assert(!f1 == false); + + f1.x = 3; + f2.x = 4; + f3.x = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestUInt2() { + uint2 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f2.x = 1; + f2.y = 1; + f3 = f1 + f2; + cmpFloat2(f3, 2); + f2 = f3 - f1; + cmpFloat2(f2, 1); + f1 = f2 * f3; + cmpFloat2(f1, 2); + f2 = f1 / f3; + cmpFloat2(f2, 2/2); + f3 = f1 % f2; + cmpFloat2(f3, 0); + f1 = f3 & f2; + cmpFloat2(f1, 0); + f2 = f1 ^ f3; + cmpFloat2(f2, 0); + f1.x = 1; + f1.y = 1; + f2.x = 2; + f2.y = 2; + f3 = f1 << f2; + cmpFloat2(f3, 4); + f2 = f3 >> f1; + cmpFloat2(f2, 2); + + f1.x = 2; + f1.y = 2; + f2.x = 1; + f2.y = 1; + f1 += f2; + cmpFloat2(f1, 3); + f1 -= f2; + cmpFloat2(f1, 2); + f1 *= f2; + cmpFloat2(f1, 2); + f1 /= f2; + cmpFloat2(f1, 2); + f1 %= f2; + cmpFloat2(f1, 0); + f1 &= f2; + cmpFloat2(f1, 0); + f1 |= f2; + cmpFloat2(f1, 1); + f1 ^= f2; + cmpFloat2(f1, 0); + f1.x = 1; + f1.y = 1; + f1 <<= f2; + cmpFloat2(f1, 2); + f1 >>= f2; + cmpFloat2(f1, 1); + + f1.x = 2; + f1.y = 2; + f2 = f1++; + cmpFloat2(f1, 3); + cmpFloat2(f2, 2); + f2 = f1--; + cmpFloat2(f2, 3); + cmpFloat2(f1, 2); + f2 = ++f1; + cmpFloat2(f1, 3); + cmpFloat2(f2, 3); + f2 = --f1; + cmpFloat2(f1, 2); + cmpFloat2(f2, 2); + + f2 = ~f1; + cmpFloat2(f2, (unsigned int)4294967293); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f2.x = 4; + f2.y = 4; + f3.x = 3; + f3.y = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestUInt3() { + uint3 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f3 = f1 + f2; + cmpFloat3(f3, 2); + f2 = f3 - f1; + cmpFloat3(f2, 1); + f1 = f2 * f3; + cmpFloat3(f1, 2); + f2 = f1 / f3; + cmpFloat3(f2, 2/2); + f3 = f1 % f2; + cmpFloat3(f3, 0); + f1 = f3 & f2; + cmpFloat3(f1, 0); + f2 = f1 ^ f3; + cmpFloat3(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f3 = f1 << f2; + cmpFloat3(f3, 4); + f2 = f3 >> f1; + cmpFloat3(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f1 += f2; + cmpFloat3(f1, 3); + f1 -= f2; + cmpFloat3(f1, 2); + f1 *= f2; + cmpFloat3(f1, 2); + f1 /= f2; + cmpFloat3(f1, 2); + f1 %= f2; + cmpFloat3(f1, 0); + f1 &= f2; + cmpFloat3(f1, 0); + f1 |= f2; + cmpFloat3(f1, 1); + f1 ^= f2; + cmpFloat3(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1 <<= f2; + cmpFloat3(f1, 2); + f1 >>= f2; + cmpFloat3(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2 = f1++; + cmpFloat3(f1, 3); + cmpFloat3(f2, 2); + f2 = f1--; + cmpFloat3(f2, 3); + cmpFloat3(f1, 2); + f2 = ++f1; + cmpFloat3(f1, 3); + cmpFloat3(f2, 3); + f2 = --f1; + cmpFloat3(f1, 2); + cmpFloat3(f2, 2); + + f2 = ~f1; + cmpFloat3(f2, (unsigned int)4294967293); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestUInt4() { + uint4 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f3 = f1 + f2; + cmpFloat4(f3, 2); + f2 = f3 - f1; + cmpFloat4(f2, 1); + f1 = f2 * f3; + cmpFloat4(f1, 2); + f2 = f1 / f3; + cmpFloat4(f2, 2/2); + f3 = f1 % f2; + cmpFloat4(f3, 0); + f1 = f3 & f2; + cmpFloat4(f1, 0); + f2 = f1 ^ f3; + cmpFloat4(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f2.w = 2; + f3 = f1 << f2; + cmpFloat4(f3, 4); + f2 = f3 >> f1; + cmpFloat4(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f1 += f2; + cmpFloat4(f1, 3); + f1 -= f2; + cmpFloat4(f1, 2); + f1 *= f2; + cmpFloat4(f1, 2); + f1 /= f2; + cmpFloat4(f1, 2); + f1 %= f2; + cmpFloat4(f1, 0); + f1 &= f2; + cmpFloat4(f1, 0); + f1 |= f2; + cmpFloat4(f1, 1); + f1 ^= f2; + cmpFloat4(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f1 <<= f2; + cmpFloat4(f1, 2); + f1 >>= f2; + cmpFloat4(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2 = f1++; + cmpFloat4(f1, 3); + cmpFloat4(f2, 2); + f2 = f1--; + cmpFloat4(f2, 3); + cmpFloat4(f1, 2); + f2 = ++f1; + cmpFloat4(f1, 3); + cmpFloat4(f2, 3); + f2 = --f1; + cmpFloat4(f1, 2); + cmpFloat4(f2, 2); + + f2 = ~f1; + cmpFloat4(f2, (unsigned int)4294967293); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f2.w = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + f3.w = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestInt1() { + int1 f1, f2, f3; + f1.x = 1; + f2.x = 1; + f3 = f1 + f2; + cmpFloat1(f3, 2); + f2 = f3 - f1; + cmpFloat1(f2, 1); + f1 = f2 * f3; + cmpFloat1(f1, 2); + f2 = f1 / f3; + cmpFloat1(f2, 2/2); + f3 = f1 % f2; + cmpFloat1(f3, 0); + f1 = f3 & f2; + cmpFloat1(f1, 0); + f2 = f1 ^ f3; + cmpFloat1(f2, 0); + f1.x = 1; + f2.x = 2; + f3 = f1 << f2; + cmpFloat1(f3, 4); + f2 = f3 >> f1; + cmpFloat1(f2, 2); + + f1.x = 2; + f2.x = 1; + f1 += f2; + cmpFloat1(f1, 3); + f1 -= f2; + cmpFloat1(f1, 2); + f1 *= f2; + cmpFloat1(f1, 2); + f1 /= f2; + cmpFloat1(f1, 2); + f1 %= f2; + cmpFloat1(f1, 0); + f1 &= f2; + cmpFloat1(f1, 0); + f1 |= f2; + cmpFloat1(f1, 1); + f1 ^= f2; + cmpFloat1(f1, 0); + f1.x = 1; + f1 <<= f2; + cmpFloat1(f1, 2); + f1 >>= f2; + cmpFloat1(f1, 1); + + f1.x = 2; + f2 = f1++; + cmpFloat1(f1, 3); + cmpFloat1(f2, 2); + f2 = f1--; + cmpFloat1(f2, 3); + cmpFloat1(f1, 2); + f2 = ++f1; + cmpFloat1(f1, 3); + cmpFloat1(f2, 3); + f2 = --f1; + cmpFloat1(f1, 2); + cmpFloat1(f2, 2); + + f2 = ~f1; + cmpFloat1(f2, (signed int)4294967293); + assert(!f1 == false); + + f1.x = 3; + f2.x = 4; + f3.x = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestInt2() { + int2 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f2.x = 1; + f2.y = 1; + f3 = f1 + f2; + cmpFloat2(f3, 2); + f2 = f3 - f1; + cmpFloat2(f2, 1); + f1 = f2 * f3; + cmpFloat2(f1, 2); + f2 = f1 / f3; + cmpFloat2(f2, 2/2); + f3 = f1 % f2; + cmpFloat2(f3, 0); + f1 = f3 & f2; + cmpFloat2(f1, 0); + f2 = f1 ^ f3; + cmpFloat2(f2, 0); + f1.x = 1; + f1.y = 1; + f2.x = 2; + f2.y = 2; + f3 = f1 << f2; + cmpFloat2(f3, 4); + f2 = f3 >> f1; + cmpFloat2(f2, 2); + + f1.x = 2; + f1.y = 2; + f2.x = 1; + f2.y = 1; + f1 += f2; + cmpFloat2(f1, 3); + f1 -= f2; + cmpFloat2(f1, 2); + f1 *= f2; + cmpFloat2(f1, 2); + f1 /= f2; + cmpFloat2(f1, 2); + f1 %= f2; + cmpFloat2(f1, 0); + f1 &= f2; + cmpFloat2(f1, 0); + f1 |= f2; + cmpFloat2(f1, 1); + f1 ^= f2; + cmpFloat2(f1, 0); + f1.x = 1; + f1.y = 1; + f1 <<= f2; + cmpFloat2(f1, 2); + f1 >>= f2; + cmpFloat2(f1, 1); + + f1.x = 2; + f1.y = 2; + f2 = f1++; + cmpFloat2(f1, 3); + cmpFloat2(f2, 2); + f2 = f1--; + cmpFloat2(f2, 3); + cmpFloat2(f1, 2); + f2 = ++f1; + cmpFloat2(f1, 3); + cmpFloat2(f2, 3); + f2 = --f1; + cmpFloat2(f1, 2); + cmpFloat2(f2, 2); + + f2 = ~f1; + cmpFloat2(f2, (signed int)4294967293); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f2.x = 4; + f2.y = 4; + f3.x = 3; + f3.y = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestInt3() { + int3 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f3 = f1 + f2; + cmpFloat3(f3, 2); + f2 = f3 - f1; + cmpFloat3(f2, 1); + f1 = f2 * f3; + cmpFloat3(f1, 2); + f2 = f1 / f3; + cmpFloat3(f2, 2/2); + f3 = f1 % f2; + cmpFloat3(f3, 0); + f1 = f3 & f2; + cmpFloat3(f1, 0); + f2 = f1 ^ f3; + cmpFloat3(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f3 = f1 << f2; + cmpFloat3(f3, 4); + f2 = f3 >> f1; + cmpFloat3(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f1 += f2; + cmpFloat3(f1, 3); + f1 -= f2; + cmpFloat3(f1, 2); + f1 *= f2; + cmpFloat3(f1, 2); + f1 /= f2; + cmpFloat3(f1, 2); + f1 %= f2; + cmpFloat3(f1, 0); + f1 &= f2; + cmpFloat3(f1, 0); + f1 |= f2; + cmpFloat3(f1, 1); + f1 ^= f2; + cmpFloat3(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1 <<= f2; + cmpFloat3(f1, 2); + f1 >>= f2; + cmpFloat3(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2 = f1++; + cmpFloat3(f1, 3); + cmpFloat3(f2, 2); + f2 = f1--; + cmpFloat3(f2, 3); + cmpFloat3(f1, 2); + f2 = ++f1; + cmpFloat3(f1, 3); + cmpFloat3(f2, 3); + f2 = --f1; + cmpFloat3(f1, 2); + cmpFloat3(f2, 2); + + f2 = ~f1; + cmpFloat3(f2, (signed int)4294967293); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestInt4() { + int4 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f3 = f1 + f2; + cmpFloat4(f3, 2); + f2 = f3 - f1; + cmpFloat4(f2, 1); + f1 = f2 * f3; + cmpFloat4(f1, 2); + f2 = f1 / f3; + cmpFloat4(f2, 2/2); + f3 = f1 % f2; + cmpFloat4(f3, 0); + f1 = f3 & f2; + cmpFloat4(f1, 0); + f2 = f1 ^ f3; + cmpFloat4(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f2.w = 2; + f3 = f1 << f2; + cmpFloat4(f3, 4); + f2 = f3 >> f1; + cmpFloat4(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f1 += f2; + cmpFloat4(f1, 3); + f1 -= f2; + cmpFloat4(f1, 2); + f1 *= f2; + cmpFloat4(f1, 2); + f1 /= f2; + cmpFloat4(f1, 2); + f1 %= f2; + cmpFloat4(f1, 0); + f1 &= f2; + cmpFloat4(f1, 0); + f1 |= f2; + cmpFloat4(f1, 1); + f1 ^= f2; + cmpFloat4(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f1 <<= f2; + cmpFloat4(f1, 2); + f1 >>= f2; + cmpFloat4(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2 = f1++; + cmpFloat4(f1, 3); + cmpFloat4(f2, 2); + f2 = f1--; + cmpFloat4(f2, 3); + cmpFloat4(f1, 2); + f2 = ++f1; + cmpFloat4(f1, 3); + cmpFloat4(f2, 3); + f2 = --f1; + cmpFloat4(f1, 2); + cmpFloat4(f2, 2); + + f2 = ~f1; + cmpFloat4(f2, (signed int)4294967293); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f2.w = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + f3.w = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestULong1() { + ulong1 f1, f2, f3; + f1.x = 1; + f2.x = 1; + f3 = f1 + f2; + cmpFloat1(f3, 2); + f2 = f3 - f1; + cmpFloat1(f2, 1); + f1 = f2 * f3; + cmpFloat1(f1, 2); + f2 = f1 / f3; + cmpFloat1(f2, 2/2); + f3 = f1 % f2; + cmpFloat1(f3, 0); + f1 = f3 & f2; + cmpFloat1(f1, 0); + f2 = f1 ^ f3; + cmpFloat1(f2, 0); + f1.x = 1; + f2.x = 2; + f3 = f1 << f2; + cmpFloat1(f3, 4); + f2 = f3 >> f1; + cmpFloat1(f2, 2); + + f1.x = 2; + f2.x = 1; + f1 += f2; + cmpFloat1(f1, 3); + f1 -= f2; + cmpFloat1(f1, 2); + f1 *= f2; + cmpFloat1(f1, 2); + f1 /= f2; + cmpFloat1(f1, 2); + f1 %= f2; + cmpFloat1(f1, 0); + f1 &= f2; + cmpFloat1(f1, 0); + f1 |= f2; + cmpFloat1(f1, 1); + f1 ^= f2; + cmpFloat1(f1, 0); + f1.x = 1; + f1 <<= f2; + cmpFloat1(f1, 2); + f1 >>= f2; + cmpFloat1(f1, 1); + + f1.x = 2; + f2 = f1++; + cmpFloat1(f1, 3); + cmpFloat1(f2, 2); + f2 = f1--; + cmpFloat1(f2, 3); + cmpFloat1(f1, 2); + f2 = ++f1; + cmpFloat1(f1, 3); + cmpFloat1(f2, 3); + f2 = --f1; + cmpFloat1(f1, 2); + cmpFloat1(f2, 2); + + f2 = ~f1; + cmpFloat1(f2, 18446744073709551613UL); + assert(!f1 == false); + + f1.x = 3; + f2.x = 4; + f3.x = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestULong2() { + ulong2 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f2.x = 1; + f2.y = 1; + f3 = f1 + f2; + cmpFloat2(f3, 2); + f2 = f3 - f1; + cmpFloat2(f2, 1); + f1 = f2 * f3; + cmpFloat2(f1, 2); + f2 = f1 / f3; + cmpFloat2(f2, 2/2); + f3 = f1 % f2; + cmpFloat2(f3, 0); + f1 = f3 & f2; + cmpFloat2(f1, 0); + f2 = f1 ^ f3; + cmpFloat2(f2, 0); + f1.x = 1; + f1.y = 1; + f2.x = 2; + f2.y = 2; + f3 = f1 << f2; + cmpFloat2(f3, 4); + f2 = f3 >> f1; + cmpFloat2(f2, 2); + + f1.x = 2; + f1.y = 2; + f2.x = 1; + f2.y = 1; + f1 += f2; + cmpFloat2(f1, 3); + f1 -= f2; + cmpFloat2(f1, 2); + f1 *= f2; + cmpFloat2(f1, 2); + f1 /= f2; + cmpFloat2(f1, 2); + f1 %= f2; + cmpFloat2(f1, 0); + f1 &= f2; + cmpFloat2(f1, 0); + f1 |= f2; + cmpFloat2(f1, 1); + f1 ^= f2; + cmpFloat2(f1, 0); + f1.x = 1; + f1.y = 1; + f1 <<= f2; + cmpFloat2(f1, 2); + f1 >>= f2; + cmpFloat2(f1, 1); + + f1.x = 2; + f1.y = 2; + f2 = f1++; + cmpFloat2(f1, 3); + cmpFloat2(f2, 2); + f2 = f1--; + cmpFloat2(f2, 3); + cmpFloat2(f1, 2); + f2 = ++f1; + cmpFloat2(f1, 3); + cmpFloat2(f2, 3); + f2 = --f1; + cmpFloat2(f1, 2); + cmpFloat2(f2, 2); + + f2 = ~f1; + cmpFloat2(f2, 18446744073709551613UL); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f2.x = 4; + f2.y = 4; + f3.x = 3; + f3.y = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestULong3() { + ulong3 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f3 = f1 + f2; + cmpFloat3(f3, 2); + f2 = f3 - f1; + cmpFloat3(f2, 1); + f1 = f2 * f3; + cmpFloat3(f1, 2); + f2 = f1 / f3; + cmpFloat3(f2, 2/2); + f3 = f1 % f2; + cmpFloat3(f3, 0); + f1 = f3 & f2; + cmpFloat3(f1, 0); + f2 = f1 ^ f3; + cmpFloat3(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f3 = f1 << f2; + cmpFloat3(f3, 4); + f2 = f3 >> f1; + cmpFloat3(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f1 += f2; + cmpFloat3(f1, 3); + f1 -= f2; + cmpFloat3(f1, 2); + f1 *= f2; + cmpFloat3(f1, 2); + f1 /= f2; + cmpFloat3(f1, 2); + f1 %= f2; + cmpFloat3(f1, 0); + f1 &= f2; + cmpFloat3(f1, 0); + f1 |= f2; + cmpFloat3(f1, 1); + f1 ^= f2; + cmpFloat3(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1 <<= f2; + cmpFloat3(f1, 2); + f1 >>= f2; + cmpFloat3(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2 = f1++; + cmpFloat3(f1, 3); + cmpFloat3(f2, 2); + f2 = f1--; + cmpFloat3(f2, 3); + cmpFloat3(f1, 2); + f2 = ++f1; + cmpFloat3(f1, 3); + cmpFloat3(f2, 3); + f2 = --f1; + cmpFloat3(f1, 2); + cmpFloat3(f2, 2); + + f2 = ~f1; + cmpFloat3(f2, 18446744073709551613UL); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestULong4() { + ulong4 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f3 = f1 + f2; + cmpFloat4(f3, 2); + f2 = f3 - f1; + cmpFloat4(f2, 1); + f1 = f2 * f3; + cmpFloat4(f1, 2); + f2 = f1 / f3; + cmpFloat4(f2, 2/2); + f3 = f1 % f2; + cmpFloat4(f3, 0); + f1 = f3 & f2; + cmpFloat4(f1, 0); + f2 = f1 ^ f3; + cmpFloat4(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f2.w = 2; + f3 = f1 << f2; + cmpFloat4(f3, 4); + f2 = f3 >> f1; + cmpFloat4(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f1 += f2; + cmpFloat4(f1, 3); + f1 -= f2; + cmpFloat4(f1, 2); + f1 *= f2; + cmpFloat4(f1, 2); + f1 /= f2; + cmpFloat4(f1, 2); + f1 %= f2; + cmpFloat4(f1, 0); + f1 &= f2; + cmpFloat4(f1, 0); + f1 |= f2; + cmpFloat4(f1, 1); + f1 ^= f2; + cmpFloat4(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f1 <<= f2; + cmpFloat4(f1, 2); + f1 >>= f2; + cmpFloat4(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2 = f1++; + cmpFloat4(f1, 3); + cmpFloat4(f2, 2); + f2 = f1--; + cmpFloat4(f2, 3); + cmpFloat4(f1, 2); + f2 = ++f1; + cmpFloat4(f1, 3); + cmpFloat4(f2, 3); + f2 = --f1; + cmpFloat4(f1, 2); + cmpFloat4(f2, 2); + + f2 = ~f1; + cmpFloat4(f2, 18446744073709551613UL); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f2.w = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + f3.w = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestLong1() { + long1 f1, f2, f3; + f1.x = 1; + f2.x = 1; + f3 = f1 + f2; + cmpFloat1(f3, 2); + f2 = f3 - f1; + cmpFloat1(f2, 1); + f1 = f2 * f3; + cmpFloat1(f1, 2); + f2 = f1 / f3; + cmpFloat1(f2, 2/2); + f3 = f1 % f2; + cmpFloat1(f3, 0); + f1 = f3 & f2; + cmpFloat1(f1, 0); + f2 = f1 ^ f3; + cmpFloat1(f2, 0); + f1.x = 1; + f2.x = 2; + f3 = f1 << f2; + cmpFloat1(f3, 4); + f2 = f3 >> f1; + cmpFloat1(f2, 2); + + f1.x = 2; + f2.x = 1; + f1 += f2; + cmpFloat1(f1, 3); + f1 -= f2; + cmpFloat1(f1, 2); + f1 *= f2; + cmpFloat1(f1, 2); + f1 /= f2; + cmpFloat1(f1, 2); + f1 %= f2; + cmpFloat1(f1, 0); + f1 &= f2; + cmpFloat1(f1, 0); + f1 |= f2; + cmpFloat1(f1, 1); + f1 ^= f2; + cmpFloat1(f1, 0); + f1.x = 1; + f1 <<= f2; + cmpFloat1(f1, 2); + f1 >>= f2; + cmpFloat1(f1, 1); + + f1.x = 2; + f2 = f1++; + cmpFloat1(f1, 3); + cmpFloat1(f2, 2); + f2 = f1--; + cmpFloat1(f2, 3); + cmpFloat1(f1, 2); + f2 = ++f1; + cmpFloat1(f1, 3); + cmpFloat1(f2, 3); + f2 = --f1; + cmpFloat1(f1, 2); + cmpFloat1(f2, 2); + + f2 = ~f1; + cmpFloat1(f2, -3); + assert(!f1 == false); + + f1.x = 3; + f2.x = 4; + f3.x = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestLong2() { + long2 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f2.x = 1; + f2.y = 1; + f3 = f1 + f2; + cmpFloat2(f3, 2); + f2 = f3 - f1; + cmpFloat2(f2, 1); + f1 = f2 * f3; + cmpFloat2(f1, 2); + f2 = f1 / f3; + cmpFloat2(f2, 2/2); + f3 = f1 % f2; + cmpFloat2(f3, 0); + f1 = f3 & f2; + cmpFloat2(f1, 0); + f2 = f1 ^ f3; + cmpFloat2(f2, 0); + f1.x = 1; + f1.y = 1; + f2.x = 2; + f2.y = 2; + f3 = f1 << f2; + cmpFloat2(f3, 4); + f2 = f3 >> f1; + cmpFloat2(f2, 2); + + f1.x = 2; + f1.y = 2; + f2.x = 1; + f2.y = 1; + f1 += f2; + cmpFloat2(f1, 3); + f1 -= f2; + cmpFloat2(f1, 2); + f1 *= f2; + cmpFloat2(f1, 2); + f1 /= f2; + cmpFloat2(f1, 2); + f1 %= f2; + cmpFloat2(f1, 0); + f1 &= f2; + cmpFloat2(f1, 0); + f1 |= f2; + cmpFloat2(f1, 1); + f1 ^= f2; + cmpFloat2(f1, 0); + f1.x = 1; + f1.y = 1; + f1 <<= f2; + cmpFloat2(f1, 2); + f1 >>= f2; + cmpFloat2(f1, 1); + + f1.x = 2; + f1.y = 2; + f2 = f1++; + cmpFloat2(f1, 3); + cmpFloat2(f2, 2); + f2 = f1--; + cmpFloat2(f2, 3); + cmpFloat2(f1, 2); + f2 = ++f1; + cmpFloat2(f1, 3); + cmpFloat2(f2, 3); + f2 = --f1; + cmpFloat2(f1, 2); + cmpFloat2(f2, 2); + + f2 = ~f1; + cmpFloat2(f2, -3); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f2.x = 4; + f2.y = 4; + f3.x = 3; + f3.y = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestLong3() { + long3 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f3 = f1 + f2; + cmpFloat3(f3, 2); + f2 = f3 - f1; + cmpFloat3(f2, 1); + f1 = f2 * f3; + cmpFloat3(f1, 2); + f2 = f1 / f3; + cmpFloat3(f2, 2/2); + f3 = f1 % f2; + cmpFloat3(f3, 0); + f1 = f3 & f2; + cmpFloat3(f1, 0); + f2 = f1 ^ f3; + cmpFloat3(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f3 = f1 << f2; + cmpFloat3(f3, 4); + f2 = f3 >> f1; + cmpFloat3(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f1 += f2; + cmpFloat3(f1, 3); + f1 -= f2; + cmpFloat3(f1, 2); + f1 *= f2; + cmpFloat3(f1, 2); + f1 /= f2; + cmpFloat3(f1, 2); + f1 %= f2; + cmpFloat3(f1, 0); + f1 &= f2; + cmpFloat3(f1, 0); + f1 |= f2; + cmpFloat3(f1, 1); + f1 ^= f2; + cmpFloat3(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1 <<= f2; + cmpFloat3(f1, 2); + f1 >>= f2; + cmpFloat3(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2 = f1++; + cmpFloat3(f1, 3); + cmpFloat3(f2, 2); + f2 = f1--; + cmpFloat3(f2, 3); + cmpFloat3(f1, 2); + f2 = ++f1; + cmpFloat3(f1, 3); + cmpFloat3(f2, 3); + f2 = --f1; + cmpFloat3(f1, 2); + cmpFloat3(f2, 2); + + f2 = ~f1; + cmpFloat3(f2, -3); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestLong4() { + long4 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f3 = f1 + f2; + cmpFloat4(f3, 2); + f2 = f3 - f1; + cmpFloat4(f2, 1); + f1 = f2 * f3; + cmpFloat4(f1, 2); + f2 = f1 / f3; + cmpFloat4(f2, 2/2); + f3 = f1 % f2; + cmpFloat4(f3, 0); + f1 = f3 & f2; + cmpFloat4(f1, 0); + f2 = f1 ^ f3; + cmpFloat4(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f2.w = 2; + f3 = f1 << f2; + cmpFloat4(f3, 4); + f2 = f3 >> f1; + cmpFloat4(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f1 += f2; + cmpFloat4(f1, 3); + f1 -= f2; + cmpFloat4(f1, 2); + f1 *= f2; + cmpFloat4(f1, 2); + f1 /= f2; + cmpFloat4(f1, 2); + f1 %= f2; + cmpFloat4(f1, 0); + f1 &= f2; + cmpFloat4(f1, 0); + f1 |= f2; + cmpFloat4(f1, 1); + f1 ^= f2; + cmpFloat4(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f1 <<= f2; + cmpFloat4(f1, 2); + f1 >>= f2; + cmpFloat4(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2 = f1++; + cmpFloat4(f1, 3); + cmpFloat4(f2, 2); + f2 = f1--; + cmpFloat4(f2, 3); + cmpFloat4(f1, 2); + f2 = ++f1; + cmpFloat4(f1, 3); + cmpFloat4(f2, 3); + f2 = --f1; + cmpFloat4(f1, 2); + cmpFloat4(f2, 2); + + f2 = ~f1; + cmpFloat4(f2, -3); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f2.w = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + f3.w = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + + +bool TestFloat1() { + float1 f1, f2, f3; +// float1 f4(1); +// cmpFloat1(f4, 1.0f); +// float1 f5(2.0f); +// cmpFloat1(f5, 2.0f); + f1.x = 1.0f; + f2.x = 1.0f; + f3 = f1 + f2; + cmpFloat1(f3, 2.0f); + f2 = f3 - f1; + cmpFloat1(f2, 1.0f); + f1 = f2 * f3; + cmpFloat1(f1, 2.0f); + f2 = f1 / f3; + cmpFloat1(f2, 2.0f/2.0f); + f1 += f2; + cmpFloat1(f1, 3.0f); + f1 -= f2; + cmpFloat1(f1, 2.0f); + f1 *= f2; + cmpFloat1(f1, 2.0f); + f1 /= f2; + cmpFloat1(f1, 2.0f); + f2 = f1++; + cmpFloat1(f1, 3.0f); + cmpFloat1(f2, 2.0f); + f2 = f1--; + cmpFloat1(f2, 3.0f); + cmpFloat1(f1, 2.0f); + f2 = ++f1; + cmpFloat1(f1, 3.0f); + cmpFloat1(f2, 3.0f); + f2 = --f1; + cmpFloat1(f1, 2.0f); + cmpFloat1(f1, 2.0f); + + f1.x = 3.0f; + f2.x = 4.0f; + f3.x = 3.0f; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + return true; +} + +bool TestFloat2() { + float2 f1, f2, f3; + f1.x = 1.0f; + f1.y = 1.0f; + f2.x = 1.0f; + f2.y = 1.0f; + f3 = f1 + f2; + cmpFloat2(f3, 2.0f); + f2 = f3 - f1; + cmpFloat2(f2, 1.0f); + f1 = f2 * f3; + cmpFloat2(f1, 2.0f); + f2 = f1 / f3; + cmpFloat2(f2, 2.0f/2.0f); + f1 += f2; + cmpFloat2(f1, 3.0f); + f1 -= f2; + cmpFloat2(f1, 2.0f); + f1 *= f2; + cmpFloat2(f1, 2.0f); + f1 /= f2; + cmpFloat2(f1, 2.0f); + + f2 = f1++; + cmpFloat2(f1, 3.0f); + cmpFloat2(f2, 2.0f); + f2 = f1--; + cmpFloat2(f2, 3.0f); + cmpFloat2(f1, 2.0f); + f2 = ++f1; + cmpFloat2(f1, 3.0f); + cmpFloat2(f2, 3.0f); + f2 = --f1; + cmpFloat2(f1, 2.0f); + cmpFloat2(f1, 2.0f); + + f1.x = 3.0f; + f1.y = 3.0f; + f2.x = 4.0f; + f2.y = 4.0f; + f3.x = 3.0f; + f3.y = 3.0f; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + + return true; +} + +bool TestFloat3() { + float3 f1, f2, f3; + f1.x = 1.0f; + f1.y = 1.0f; + f1.z = 1.0f; + f2.x = 1.0f; + f2.y = 1.0f; + f2.z = 1.0f; + f3 = f1 + f2; + cmpFloat3(f3, 2.0f); + f2 = f3 - f1; + cmpFloat3(f2, 1.0f); + f1 = f2 * f3; + cmpFloat3(f1, 2.0f); + f2 = f1 / f3; + cmpFloat3(f2, 2.0f/2.0f); + f1 += f2; + cmpFloat3(f1, 3.0f); + f1 -= f2; + cmpFloat3(f1, 2.0f); + f1 *= f2; + cmpFloat3(f1, 2.0f); + f1 /= f2; + f2 = f1++; + cmpFloat3(f1, 3.0f); + cmpFloat3(f2, 2.0f); + f2 = f1--; + cmpFloat3(f2, 3.0f); + cmpFloat3(f1, 2.0f); + f2 = ++f1; + cmpFloat3(f1, 3.0f); + cmpFloat3(f2, 3.0f); + f2 = --f1; + cmpFloat3(f1, 2.0f); + cmpFloat3(f1, 2.0f); + + f1.x = 3.0f; + f1.y = 3.0f; + f1.z = 3.0f; + f2.x = 4.0f; + f2.y = 4.0f; + f2.z = 4.0f; + f3.x = 3.0f; + f3.y = 3.0f; + f3.z = 3.0f; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + + return true; +} + + +bool TestFloat4() { + float4 f1, f2, f3; + f1.x = 1.0f; + f1.y = 1.0f; + f1.z = 1.0f; + f1.w = 1.0f; + f2.x = 1.0f; + f2.y = 1.0f; + f2.z = 1.0f; + f2.w = 1.0f; + f3 = f1 + f2; + cmpFloat4(f3, 2.0f); + f2 = f3 - f1; + cmpFloat4(f2, 1.0f); + f1 = f2 * f3; + cmpFloat4(f1, 2.0f); + f2 = f1 / f3; + cmpFloat4(f2, 2.0f/2.0f); + f1 += f2; + cmpFloat4(f1, 3.0f); + f1 -= f2; + cmpFloat4(f1, 2.0f); + f1 *= f2; + cmpFloat4(f1, 2.0f); + f1 /= f2; + f2 = f1++; + cmpFloat4(f1, 3.0f); + cmpFloat4(f2, 2.0f); + f2 = f1--; + cmpFloat4(f2, 3.0f); + cmpFloat4(f1, 2.0f); + f2 = ++f1; + cmpFloat4(f1, 3.0f); + cmpFloat4(f2, 3.0f); + f2 = --f1; + cmpFloat4(f1, 2.0f); + cmpFloat4(f1, 2.0f); + + f1.x = 3.0f; + f1.y = 3.0f; + f1.z = 3.0f; + f1.w = 3.0f; + f2.x = 4.0f; + f2.y = 4.0f; + f2.z = 4.0f; + f2.w = 4.0f; + f3.x = 3.0f; + f3.y = 3.0f; + f3.z = 3.0f; + f3.w = 3.0f; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + return true; +} + + + +int main() { + assert(sizeof(float1) == 4); + assert(sizeof(float2) == 8); + assert(sizeof(float3) == 12); + assert(sizeof(float4) == 16); + assert(TestFloat1() && TestFloat2() && TestFloat3() && TestFloat4() + && TestUChar1() && TestUChar2() && TestUChar3() && TestUChar4() + && TestChar1() && TestChar2() && TestChar3() && TestChar4() + && TestUShort1() && TestUShort2() && TestUShort3() && TestUShort4() + && TestShort1() && TestShort2() && TestShort3() && TestShort4() + && TestUInt1() && TestUInt2() && TestUInt3() && TestUInt4() + && TestInt1() && TestInt2() && TestInt3() && TestInt4() + && TestULong1() && TestULong2() && TestULong3() && TestULong4() + && TestLong1() && TestLong2() && TestLong3() && TestLong4() == true); + + float1 f1 = make_float1(1.0f); +} From 5de29029cd643d5b05811921dc3905f66e0760a8 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Wed, 11 Jan 2017 18:05:41 -0600 Subject: [PATCH 058/281] changed copyright year from 2016 to 2017 in src directory Change-Id: Idb97db509b2b4b1656b2df7a14a62ade38c9d574 [ROCm/hip commit: 73fcce26f980367df57b28906f27e065365786ff] --- projects/hip/src/device_functions.cpp | 4 +--- projects/hip/src/device_util.cpp | 2 +- projects/hip/src/device_util.h | 2 +- projects/hip/src/hip_context.cpp | 2 +- projects/hip/src/hip_device.cpp | 3 +-- projects/hip/src/hip_error.cpp | 2 +- projects/hip/src/hip_event.cpp | 6 ++---- projects/hip/src/hip_fp16.cpp | 2 +- projects/hip/src/hip_hcc.cpp | 22 +++++++++++----------- projects/hip/src/hip_hcc.h | 14 +++++++------- projects/hip/src/hip_ldg.cpp | 2 +- projects/hip/src/hip_memory.cpp | 4 ++-- projects/hip/src/hip_module.cpp | 4 +--- projects/hip/src/hip_peer.cpp | 26 +++++++++++++------------- projects/hip/src/hip_stream.cpp | 4 ++-- projects/hip/src/hip_util.h | 2 +- projects/hip/src/trace_helper.h | 20 ++++++++++---------- 17 files changed, 57 insertions(+), 64 deletions(-) diff --git a/projects/hip/src/device_functions.cpp b/projects/hip/src/device_functions.cpp index 30a09e6e02..0de0cf7f6b 100644 --- a/projects/hip/src/device_functions.cpp +++ b/projects/hip/src/device_functions.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights @@ -54,5 +54,3 @@ __device__ double __hiloint2double (int hi, int lo) { s.s2.lo = lo; return s.d; } - - diff --git a/projects/hip/src/device_util.cpp b/projects/hip/src/device_util.cpp index 669fcb7570..db0f494af4 100644 --- a/projects/hip/src/device_util.cpp +++ b/projects/hip/src/device_util.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/projects/hip/src/device_util.h b/projects/hip/src/device_util.h index 8ccf5a540e..18811321d9 100644 --- a/projects/hip/src/device_util.h +++ b/projects/hip/src/device_util.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/projects/hip/src/hip_context.cpp b/projects/hip/src/hip_context.cpp index b38a6c3b74..6c862b114b 100644 --- a/projects/hip/src/hip_context.cpp +++ b/projects/hip/src/hip_context.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/projects/hip/src/hip_device.cpp b/projects/hip/src/hip_device.cpp index 0f2c2e2753..131526b6e2 100644 --- a/projects/hip/src/hip_device.cpp +++ b/projects/hip/src/hip_device.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -479,4 +479,3 @@ hipError_t hipChooseDevice( int* device, const hipDeviceProp_t* prop ) } return ihipLogStatus(e); } - diff --git a/projects/hip/src/hip_error.cpp b/projects/hip/src/hip_error.cpp index 60c45cc1f7..4c14ba4156 100644 --- a/projects/hip/src/hip_error.cpp +++ b/projects/hip/src/hip_error.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/projects/hip/src/hip_event.cpp b/projects/hip/src/hip_event.cpp index 74fe487968..5a0ed9d8f8 100644 --- a/projects/hip/src/hip_event.cpp +++ b/projects/hip/src/hip_event.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -43,7 +43,7 @@ hipError_t ihipEventCreate(hipEvent_t* event, unsigned flags) eh->_stream = NULL; eh->_flags = flags; eh->_timestamp = 0; - *event = eh; + *event = eh; } else { e = hipErrorInvalidValue; } @@ -186,5 +186,3 @@ hipError_t hipEventQuery(hipEvent_t event) return ihipLogStatus(hipSuccess); } } - - diff --git a/projects/hip/src/hip_fp16.cpp b/projects/hip/src/hip_fp16.cpp index 1a9d04474f..0ecac0a6fb 100644 --- a/projects/hip/src/hip_fp16.cpp +++ b/projects/hip/src/hip_fp16.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/projects/hip/src/hip_hcc.cpp b/projects/hip/src/hip_hcc.cpp index e5b7937e25..a2383245fc 100644 --- a/projects/hip/src/hip_hcc.cpp +++ b/projects/hip/src/hip_hcc.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -279,12 +279,12 @@ inline void ihipStream_t::ensureHaveQueue(LockedAccessor_StreamCrit_t &streamCri // TODO auto needyCritPtr = this->_criticalData.mlock(); - // Second test to ensure we still need to steal the queue - another thread may have + // Second test to ensure we still need to steal the queue - another thread may have // snuck in here and already solved the issue. if (!needyCritPtr->_hasQueue) { needyCritPtr->_av = this->_ctx->stealActiveQueue(ctxCrit, this); } - + streamCrit->_hasQueue = true; } assert(streamCrit->_hasQueue); @@ -394,7 +394,7 @@ LockedAccessor_StreamCrit_t ihipStream_t::lockopen_preKernelCommand() } this->ensureHaveQueue(crit); - + return crit; @@ -944,10 +944,10 @@ ihipCtx_t::stealActiveQueue(LockedAccessor_CtxCrit_t &ctxCrit, ihipStream_t *nee uint64_t *p = (uint64_t*)(&victimCritPtr->_av); *p = 0; // damage the victim av so attempt to use it will fault. - (*iter)->_criticalData.munlock(); + (*iter)->_criticalData.munlock(); return av; - } - (*iter)->_criticalData.munlock(); + } + (*iter)->_criticalData.munlock(); } } } @@ -1296,7 +1296,7 @@ void ihipInit() tokenize(HIP_LAUNCH_BLOCKING_KERNELS, ',', &g_hipLaunchBlockingKernels); } READ_ENV_I(release, HIP_API_BLOCKING, 0, "Make HIP APIs 'host-synchronous', so they block until completed. Impacts hipMemcpyAsync, hipMemsetAsync." ); - + READ_ENV_I(release, HIP_MAX_QUEUES, 0, "Maximum number of queues that this app will use per-device. Additional streams will share the specified number of queues. 0=no limit."); @@ -1320,8 +1320,8 @@ void ihipInit() READ_ENV_I(release, HIP_WAIT_MODE, 0, "Force synchronization mode. 1= force yield, 2=force spin, 0=defaults specified in application"); - READ_ENV_I(release, HIP_FORCE_P2P_HOST, 0, "Force use of host/staging copy for peer-to-peer copies.1=always use copies, 2=always return false for hipDeviceCanAccessPeer"); - READ_ENV_I(release, HIP_FORCE_SYNC_COPY, 0, "Force all copies (even hipMemcpyAsync) to use sync copies"); + READ_ENV_I(release, HIP_FORCE_P2P_HOST, 0, "Force use of host/staging copy for peer-to-peer copies.1=always use copies, 2=always return false for hipDeviceCanAccessPeer"); + READ_ENV_I(release, HIP_FORCE_SYNC_COPY, 0, "Force all copies (even hipMemcpyAsync) to use sync copies"); // TODO - review, can we remove this? READ_ENV_I(release, HIP_NUM_KERNELS_INFLIGHT, 128, "Max number of inflight kernels per stream before active synchronization is forced."); @@ -2026,7 +2026,7 @@ hipError_t hipHccGetAcceleratorView(hipStream_t stream, hc::accelerator_view **a stream = device->_defaultStream; } - *av = stream->locked_getAv(); // TODO - review. + *av = stream->locked_getAv(); // TODO - review. hipError_t err = hipSuccess; return ihipLogStatus(err); diff --git a/projects/hip/src/hip_hcc.h b/projects/hip/src/hip_hcc.h index e19ce63263..031c92fca7 100644 --- a/projects/hip/src/hip_hcc.h +++ b/projects/hip/src/hip_hcc.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -415,15 +415,15 @@ public: ihipStreamCriticalBase_t * mlock() { LockedBase::lock(); return this;}; - void munlock() { + void munlock() { tprintf(DB_SYNC, "munlocking criticalData=%p for %s...\n", this, ToString(this->_parent).c_str()); - LockedBase::unlock(); + LockedBase::unlock(); }; - ihipStreamCriticalBase_t * mtry_lock() { + ihipStreamCriticalBase_t * mtry_lock() { bool gotLock = LockedBase::try_lock() ; tprintf(DB_SYNC, "mtry_locking=%d criticalData=%p for %s...\n", gotLock, this, ToString(this->_parent).c_str()); - return gotLock ? this: nullptr; + return gotLock ? this: nullptr; }; public: @@ -683,7 +683,7 @@ public: // Functions: ihipCtx_t(ihipDevice_t *device, unsigned deviceCnt, unsigned flags); // note: calls constructor for _criticalData ~ihipCtx_t(); - // Functions which read or write the critical data are named locked_. + // Functions which read or write the critical data are named locked_. // (might be better called "locking_" // ihipCtx_t does not use recursive locks so the ihip implementation must avoid calling a locked_ function from within a locked_ function. // External functions which call several locked_ functions will acquire and release the lock for each function. if this occurs in @@ -697,7 +697,7 @@ public: // Functions: hc::accelerator_view stealActiveQueue(LockedAccessor_CtxCrit_t &ctxCrit, ihipStream_t *needyStream); hc::accelerator_view createOrStealQueue(LockedAccessor_CtxCrit_t &ctxCrit); - ihipCtxCritical_t &criticalData() { return _criticalData; }; + ihipCtxCritical_t &criticalData() { return _criticalData; }; const ihipDevice_t *getDevice() const { return _device; }; int getDeviceNum() const { return _device->_deviceId; }; diff --git a/projects/hip/src/hip_ldg.cpp b/projects/hip/src/hip_ldg.cpp index 075e1926f1..d91f54a807 100644 --- a/projects/hip/src/hip_ldg.cpp +++ b/projects/hip/src/hip_ldg.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/projects/hip/src/hip_memory.cpp b/projects/hip/src/hip_memory.cpp index 372d295b89..c43b6991c6 100644 --- a/projects/hip/src/hip_memory.cpp +++ b/projects/hip/src/hip_memory.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -1087,7 +1087,7 @@ hipError_t hipIpcOpenMemHandle(void** devPtr, hipIpcMemHandle_t handle, unsigned hsa_amd_ipc_memory_attach(&handle->ipc_handle, handle->psize, 1, agent, devPtr); if(hsa_status != HSA_STATUS_SUCCESS) hipStatus = hipErrorMapBufferObjectFailed; -#else +#else hipStatus = hipErrorRuntimeOther; #endif return hipStatus; diff --git a/projects/hip/src/hip_module.cpp b/projects/hip/src/hip_module.cpp index 74cdd8a4ae..7d77dbe8dd 100644 --- a/projects/hip/src/hip_module.cpp +++ b/projects/hip/src/hip_module.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -403,5 +403,3 @@ hipError_t hipModuleLoadData(hipModule_t *module, const void *image) } return ihipLogStatus(ret); } - - diff --git a/projects/hip/src/hip_peer.cpp b/projects/hip/src/hip_peer.cpp index b7dca06e5f..e57665be0c 100644 --- a/projects/hip/src/hip_peer.cpp +++ b/projects/hip/src/hip_peer.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -31,7 +31,7 @@ THE SOFTWARE. // There are two flavors: // - one where contexts are specified with hipCtx_t type. // - one where contexts are specified with integer deviceIds, that are mapped to the primary context for that device. -// The implementation contains a set of internal ihip* functions which operate on contexts. Then the +// The implementation contains a set of internal ihip* functions which operate on contexts. Then the // public APIs are thin wrappers which call into this internal implementations. // TODO - actually not yet - currently the integer deviceId flavors just call the context APIs. need to fix. @@ -46,16 +46,16 @@ hipError_t ihipDeviceCanAccessPeer (int* canAccessPeer, hipCtx_t thisCtx, hipCtx if (thisCtx == peerCtx) { *canAccessPeer = 0; - tprintf(DB_MEM, "Can't be peer to self. (this=%s, peer=%s)\n", - thisCtx->toString().c_str(), peerCtx->toString().c_str()); + tprintf(DB_MEM, "Can't be peer to self. (this=%s, peer=%s)\n", + thisCtx->toString().c_str(), peerCtx->toString().c_str()); } else if (HIP_FORCE_P2P_HOST & 0x2) { *canAccessPeer = false; - tprintf(DB_MEM, "HIP_FORCE_P2P_HOST denies peer access this=%s peer=%s canAccessPeer=%d\n", - thisCtx->toString().c_str(), peerCtx->toString().c_str(), *canAccessPeer); + tprintf(DB_MEM, "HIP_FORCE_P2P_HOST denies peer access this=%s peer=%s canAccessPeer=%d\n", + thisCtx->toString().c_str(), peerCtx->toString().c_str(), *canAccessPeer); } else { *canAccessPeer = peerCtx->getDevice()->_acc.get_is_peer(thisCtx->getDevice()->_acc); - tprintf(DB_MEM, "deviceCanAccessPeer this=%s peer=%s canAccessPeer=%d\n", - thisCtx->toString().c_str(), peerCtx->toString().c_str(), *canAccessPeer); + tprintf(DB_MEM, "deviceCanAccessPeer this=%s peer=%s canAccessPeer=%d\n", + thisCtx->toString().c_str(), peerCtx->toString().c_str(), *canAccessPeer); } } else { @@ -99,14 +99,14 @@ hipError_t ihipDisablePeerAccess (hipCtx_t peerCtx) LockedAccessor_CtxCrit_t peerCrit(peerCtx->criticalData()); bool changed = peerCrit->removePeerWatcher(peerCtx, thisCtx); if (changed) { - tprintf(DB_MEM, "device %s disable access to memory allocated on peer:%s\n", - thisCtx->toString().c_str(), peerCtx->toString().c_str()); + tprintf(DB_MEM, "device %s disable access to memory allocated on peer:%s\n", + thisCtx->toString().c_str(), peerCtx->toString().c_str()); // Update the peers for all memory already saved in the tracker: am_memtracker_update_peers(peerCtx->getDevice()->_acc, peerCrit->peerCnt(), peerCrit->peerAgents()); } else { err = hipErrorPeerAccessNotEnabled; // never enabled P2P access. } - } + } } else { err = hipErrorInvalidDevice; } @@ -133,8 +133,8 @@ hipError_t ihipEnablePeerAccess (hipCtx_t peerCtx, unsigned int flags) // Add thisCtx to peerCtx's access list so that new allocations on peer will be made visible to this device: bool isNewPeer = peerCrit->addPeerWatcher(peerCtx, thisCtx); if (isNewPeer) { - tprintf(DB_MEM, "device=%s can now see all memory allocated on peer=%s\n", - thisCtx->toString().c_str(), peerCtx->toString().c_str()); + tprintf(DB_MEM, "device=%s can now see all memory allocated on peer=%s\n", + thisCtx->toString().c_str(), peerCtx->toString().c_str()); am_memtracker_update_peers(peerCtx->getDevice()->_acc, peerCrit->peerCnt(), peerCrit->peerAgents()); } else { err = hipErrorPeerAccessAlreadyEnabled; diff --git a/projects/hip/src/hip_stream.cpp b/projects/hip/src/hip_stream.cpp index aae412160f..594fb6e860 100644 --- a/projects/hip/src/hip_stream.cpp +++ b/projects/hip/src/hip_stream.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -214,7 +214,7 @@ hipError_t hipStreamAddCallback(hipStream_t stream, hipStreamCallback_t callback { HIP_INIT_API(stream, callback, userData, flags); hipError_t e = hipSuccess; - //--- explicitly synchronize stream to add callback routines + //--- explicitly synchronize stream to add callback routines hipStreamSynchronize(stream); callback(stream, e, userData); return ihipLogStatus(e); diff --git a/projects/hip/src/hip_util.h b/projects/hip/src/hip_util.h index 34a80ed205..f6817ffccb 100644 --- a/projects/hip/src/hip_util.h +++ b/projects/hip/src/hip_util.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/projects/hip/src/trace_helper.h b/projects/hip/src/trace_helper.h index bde40d0690..f58f81fbff 100644 --- a/projects/hip/src/trace_helper.h +++ b/projects/hip/src/trace_helper.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -55,7 +55,7 @@ inline std::string ToHexString(T v) // This is the default which works for most types: template -inline std::string ToString(T v) +inline std::string ToString(T v) { std::ostringstream ss; ss << v; @@ -65,7 +65,7 @@ inline std::string ToString(T v) // hipEvent_t specialization. TODO - maybe add an event ID for debug? template <> -inline std::string ToString(hipEvent_t v) +inline std::string ToString(hipEvent_t v) { std::ostringstream ss; ss << v; @@ -74,7 +74,7 @@ inline std::string ToString(hipEvent_t v) // hipEvent_t specialization. TODO - maybe add an event ID for debug? template <> -inline std::string ToString(hipFunction_t v) +inline std::string ToString(hipFunction_t v) { std::ostringstream ss; ss << "0x" << std::hex << v._object; @@ -85,7 +85,7 @@ inline std::string ToString(hipFunction_t v) // hipStream_t template <> -inline std::string ToString(hipStream_t v) +inline std::string ToString(hipStream_t v) { std::ostringstream ss; if (v == NULL) { @@ -99,7 +99,7 @@ inline std::string ToString(hipStream_t v) // hipMemcpyKind specialization template <> -inline std::string ToString(hipMemcpyKind v) +inline std::string ToString(hipMemcpyKind v) { switch(v) { CASE_STR(hipMemcpyHostToHost); @@ -113,14 +113,14 @@ inline std::string ToString(hipMemcpyKind v) template <> -inline std::string ToString(hipError_t v) +inline std::string ToString(hipError_t v) { return ihipErrorString(v); }; // Catch empty arguments case -inline std::string ToString() +inline std::string ToString() { return (""); } @@ -129,8 +129,8 @@ inline std::string ToString() //--- // C++11 variadic template - peels off first argument, converts to string, and calls itself again to peel the next arg. // Strings are automatically separated by comma+space. -template -inline std::string ToString(T first, Args... args) +template +inline std::string ToString(T first, Args... args) { return ToString(first) + ", " + ToString(args...) ; } From 82e5cfa56405e8a4cafcd2311d649c70270e0524 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Wed, 11 Jan 2017 18:09:33 -0600 Subject: [PATCH 059/281] changed copyright year from 2016 to 2017 in include directory Change-Id: Ib5935a84fb51a04b3446df31cc2287101f791b83 [ROCm/hip commit: 98c4221dc2949882ac3bc6f729ab855c50662a55] --- projects/hip/include/hip/device_functions.h | 6 +++--- projects/hip/include/hip/hcc.h | 2 +- projects/hip/include/hip/hip_common.h | 6 +++--- projects/hip/include/hip/hip_complex.h | 3 +-- projects/hip/include/hip/hip_fp16.h | 2 +- projects/hip/include/hip/hip_profile.h | 6 +++--- projects/hip/include/hip/hip_runtime.h | 9 ++++----- projects/hip/include/hip/hip_runtime_api.h | 2 +- projects/hip/include/hip/hip_texture.h | 6 +++--- projects/hip/include/hip/hip_vector_types.h | 6 +++--- 10 files changed, 23 insertions(+), 25 deletions(-) diff --git a/projects/hip/include/hip/device_functions.h b/projects/hip/include/hip/device_functions.h index 838bad8f0c..24211b7d2d 100644 --- a/projects/hip/include/hip/device_functions.h +++ b/projects/hip/include/hip/device_functions.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights @@ -26,8 +26,8 @@ THE SOFTWARE. #include #elif defined(__HIP_PLATFORM_NVCC__) && !defined (__HIP_PLATFORM_HCC__) #include -#else +#else #error("Must define exactly one of __HIP_PLATFORM_HCC__ or __HIP_PLATFORM_NVCC__"); -#endif +#endif #endif diff --git a/projects/hip/include/hip/hcc.h b/projects/hip/include/hip/hcc.h index dba26aeab3..9b8a649412 100644 --- a/projects/hip/include/hip/hcc.h +++ b/projects/hip/include/hip/hcc.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/projects/hip/include/hip/hip_common.h b/projects/hip/include/hip/hip_common.h index 4c75568f4d..f0e58f1f76 100644 --- a/projects/hip/include/hip/hip_common.h +++ b/projects/hip/include/hip/hip_common.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -25,7 +25,7 @@ THE SOFTWARE. // Common code included at start of every hip file. // Auto enable __HIP_PLATFORM_HCC__ if compiling with HCC // Other compiler (GCC,ICC,etc) need to set one of these macros explicitly -#if defined(__HCC__) +#if defined(__HCC__) #define __HIP_PLATFORM_HCC__ #define __HIPCC__ @@ -37,7 +37,7 @@ THE SOFTWARE. #endif // Auto enable __HIP_PLATFORM_NVCC__ if compiling with NVCC -#if defined(__NVCC__) +#if defined(__NVCC__) #define __HIP_PLATFORM_NVCC__ # ifdef __CUDACC__ # define __HIPCC__ diff --git a/projects/hip/include/hip/hip_complex.h b/projects/hip/include/hip/hip_complex.h index 0f4fb0b3d8..ea15137894 100644 --- a/projects/hip/include/hip/hip_complex.h +++ b/projects/hip/include/hip/hip_complex.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -31,4 +31,3 @@ THE SOFTWARE. #else #error("Must define exactly one of __HIP_PLATFORM_HCC__ or __HIP_PLATFORM_NVCC__"); #endif - diff --git a/projects/hip/include/hip/hip_fp16.h b/projects/hip/include/hip/hip_fp16.h index b91063998a..2f64c1a143 100644 --- a/projects/hip/include/hip/hip_fp16.h +++ b/projects/hip/include/hip/hip_fp16.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/projects/hip/include/hip/hip_profile.h b/projects/hip/include/hip/hip_profile.h index 489143adfd..e621ae8c79 100644 --- a/projects/hip/include/hip/hip_profile.h +++ b/projects/hip/include/hip/hip_profile.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -32,7 +32,7 @@ THE SOFTWARE. #define HIP_BEGIN_MARKER(markerName, group) amdtBeginMarker(markerName, group, nullptr); #define HIP_END_MARKER() amdtEndMarker(); #else -#define HIP_SCOPED_MARKER(markerName, group) +#define HIP_SCOPED_MARKER(markerName, group) #define HIP_BEGIN_MARKER(markerName, group) -#define HIP_END_MARKER() +#define HIP_END_MARKER() #endif diff --git a/projects/hip/include/hip/hip_runtime.h b/projects/hip/include/hip/hip_runtime.h index dff1e19252..9bc45f300d 100644 --- a/projects/hip/include/hip/hip_runtime.h +++ b/projects/hip/include/hip/hip_runtime.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -22,7 +22,7 @@ THE SOFTWARE. //! HIP = Heterogeneous-compute Interface for Portability //! -//! Define a extremely thin runtime layer that allows source code to be compiled unmodified +//! Define a extremely thin runtime layer that allows source code to be compiled unmodified //! through either AMD HCC or NVCC. Key features tend to be in the spirit //! and terminology of CUDA, but with a portable path to other accelerators as well: // @@ -54,11 +54,10 @@ THE SOFTWARE. #include #elif defined(__HIP_PLATFORM_NVCC__) && !defined (__HIP_PLATFORM_HCC__) #include -#else +#else #error("Must define exactly one of __HIP_PLATFORM_HCC__ or __HIP_PLATFORM_NVCC__"); -#endif +#endif #include #include - diff --git a/projects/hip/include/hip/hip_runtime_api.h b/projects/hip/include/hip/hip_runtime_api.h index a2bfed5c69..28d67fc01a 100644 --- a/projects/hip/include/hip/hip_runtime_api.h +++ b/projects/hip/include/hip/hip_runtime_api.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/projects/hip/include/hip/hip_texture.h b/projects/hip/include/hip/hip_texture.h index 3e7802b457..66ec4a6ca1 100644 --- a/projects/hip/include/hip/hip_texture.h +++ b/projects/hip/include/hip/hip_texture.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -29,9 +29,9 @@ THE SOFTWARE. #include #elif defined(__HIP_PLATFORM_NVCC__) && !defined (__HIP_PLATFORM_HCC__) #include -#else +#else #error("Must define exactly one of __HIP_PLATFORM_HCC__ or __HIP_PLATFORM_NVCC__"); -#endif +#endif #endif diff --git a/projects/hip/include/hip/hip_vector_types.h b/projects/hip/include/hip/hip_vector_types.h index 7733d92bda..33827e4d96 100644 --- a/projects/hip/include/hip/hip_vector_types.h +++ b/projects/hip/include/hip/hip_vector_types.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -33,6 +33,6 @@ THE SOFTWARE. #endif #elif defined(__HIP_PLATFORM_NVCC__) && !defined (__HIP_PLATFORM_HCC__) #include -#else +#else #error("Must define exactly one of __HIP_PLATFORM_HCC__ or __HIP_PLATFORM_NVCC__"); -#endif +#endif From ea8ad522893de0b893cb003c8a6a1a3d10588fe2 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Wed, 11 Jan 2017 18:23:37 -0600 Subject: [PATCH 060/281] changed data type used for complex Change-Id: I0a3bb281af3d5ac1290207821c7c45aea40f513f [ROCm/hip commit: e2318cda74077d0424497a6a00ff590285d8c135] --- projects/hip/include/hip/hcc_detail/hip_complex.h | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/hip_complex.h b/projects/hip/include/hip/hcc_detail/hip_complex.h index 21995de096..f4af5839ad 100644 --- a/projects/hip/include/hip/hcc_detail/hip_complex.h +++ b/projects/hip/include/hip/hcc_detail/hip_complex.h @@ -23,10 +23,8 @@ THE SOFTWARE. #ifndef HIPCOMPLEX_H #define HIPCOMPLEX_H -typedef struct{ - float x; - float y; -}hipFloatComplex; +typedef float2 hipFloatComplex; +typedef double2 hipDoubleComplex; __device__ static inline float hipCrealf(hipFloatComplex z){ return z.x; @@ -79,10 +77,6 @@ __device__ static inline float hipCabsf(hipFloatComplex z){ } -typedef struct{ - double x; - double y; -}hipDoubleComplex; __device__ static inline double hipCreal(hipDoubleComplex z){ return z.x; From 7f00c120a757cc018eafb78768dcce4115960d7f Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Thu, 12 Jan 2017 11:30:20 -0600 Subject: [PATCH 061/281] Started adding native half math library support 1. Removed HIP_EXPERIMENTAL env variable so that device code will be accessed from LLVM IR 2. Removed soft support from headers and moved to hip_fp16.cpp 3. Added LLVM IR + inline asm to hip_ir.ll 4. Added test for fp16 5. Added barriers for hcc 3.5 and hcc 4.0 for half support a. Which means, hcc 4.0 can parse __fp16 but hcc 3.5 cant b. HCC 4.0 code is implemented now, hcc 3.5 will be added later Change-Id: Ic37859b2688ebb02e168bab643d1882bf4727952 [ROCm/hip commit: d180fdaae07223e345a630f8f33f5dbb15b9144f] --- projects/hip/bin/hipcc | 2 +- .../hip/include/hip/hcc_detail/hip_fp16.h | 214 ++++------------- projects/hip/src/hip_fp16.cpp | 220 +++++++++--------- projects/hip/src/hip_ir.ll | 49 ++++ .../hip/tests/src/deviceLib/hipTestHalf.cpp | 75 ++++++ 5 files changed, 278 insertions(+), 282 deletions(-) create mode 100644 projects/hip/tests/src/deviceLib/hipTestHalf.cpp diff --git a/projects/hip/bin/hipcc b/projects/hip/bin/hipcc index ccea650776..de8f0cb9a3 100755 --- a/projects/hip/bin/hipcc +++ b/projects/hip/bin/hipcc @@ -220,7 +220,7 @@ if($HIP_PLATFORM eq "hcc"){ } } -if(($HIP_PLATFORM eq "hcc") and defined $ENV{HIP_EXPERIMENTAL}){ +if(($HIP_PLATFORM eq "hcc")){ $EXPORT_LL=" "; $ENV{HCC_EXTRA_LIBRARIES}="$HIP_PATH/lib/hip_ir.ll\n"; } diff --git a/projects/hip/include/hip/hcc_detail/hip_fp16.h b/projects/hip/include/hip/hcc_detail/hip_fp16.h index d51a5d1fcd..c779bcfba2 100644 --- a/projects/hip/include/hip/hcc_detail/hip_fp16.h +++ b/projects/hip/include/hip/hcc_detail/hip_fp16.h @@ -25,213 +25,81 @@ THE SOFTWARE. #include "hip/hip_runtime.h" -#if 0 +#if __clang_major__ == 4 typedef __fp16 __half; typedef struct __attribute__((aligned(4))){ - int a; + union { + __half p[2]; + unsigned int q; + }; } __half2; -extern "C" __half __hip_hadd_gfx803(__half a, __half b); -extern "C" __half __hip_hfma_gfx803(__half a, __half b); -extern "C" __half __hip_hmul_gfx803(__half a, __half b); -extern "C" __half __hip_hsub_gfx803(__half a, __half b); +extern "C" __half __hip_hc_ir_hadd_half(__half, __half); +extern "C" __half __hip_hc_ir_hfma_half(__half, __half, __half); +extern "C" __half __hip_hc_ir_hmul_half(__half, __half); +extern "C" __half __hip_hc_ir_hsub_half(__half, __half); -extern "C" int __hip_hadd2_gfx803(int a, int b); -extern "C" int __hip_hfma2_gfx803(int a, int b); -extern "C" int __hip_hmul2_gfx803(int a, int b); -extern "C" int __hip_hsub2_gfx803(int a, int b); - -__device__ inline __half __hadd(__half a, __half b) { - return __hip_hadd_gfx803(a, b); +__device__ static inline __half __hadd(const __half a, const __half b) { + return __hip_hc_ir_hadd_half(a, b); } -__device__ inline __half __hadd_sat(__half a, __half b) { - return __hip_hadd_gfx803(a, b); +__device__ static inline __half __hadd_sat(__half a, __half b) { + return __hip_hc_ir_hadd_half(a, b); } -__device__ inline __half __hfma(__half a, __half b) { - return __hip_hfma_gfx803(a, b); +__device__ static inline __half __hfma(__half a, __half b, __half c) { + return __hip_hc_ir_hfma_half(a, b, c); } -__device__ inline __half __hfma_sat(__half a, __half b) { - return __hip_hfma_gfx803(a, b); +__device__ static inline __half __hfma_sat(__half a, __half b, __half c) { + return __hip_hc_ir_hfma_half(a, b, c); } -__device__ inline __half __hmul(__half a, __half b) { - return __hip_hmul_gfx803(a, b); +__device__ static inline __half __hmul(__half a, __half b) { + return __hip_hc_ir_hmul_half(a, b); } -__device__ inline __half __hmul_sat(__half a, __half b) { - return __hip_hmul_gfx803(a, b); +__device__ static inline __half __hmul_sat(__half a, __half b) { + return __hip_hc_ir_hmul_half(a, b); } -__device__ inline __half __hsub(__half a, __half b) { - return __hip_hsub_gfx803(a, b); +__device__ static inline __half __hneg(__half a) { + return -a; } -__device__ inline __half __hsub_sat(__half a, __half b) { - return __hip_hsub_gfx803(a, b); +__device__ static inline __half __hsub(__half a, __half b) { + return __hip_hc_ir_hsub_half(a, b); } - -__device__ inline __half2 __hadd2(__half2 a, __half2 b) { - __half2 ret; - ret.a = __hip_hadd2_gfx803(a.a, b.a); - return ret; +__device__ static inline __half __hsub_sat(__half a, __half b) { + return __hip_hc_ir_hsub_half(a, b); } -#else +__device__ static inline __half hdiv(__half a, __half b) { + return a/b; +} -typedef struct{ +#endif + +#if __clang_major__ == 3 + +typedef struct { unsigned x: 16; } __half; - typedef struct __attribute__((aligned(4))){ - __half p,q; + union { + __half p[2]; + unsigned int q; + }; } __half2; -typedef __half half; -typedef __half2 half2; -/* -Arithmetic functions -*/ -__device__ __half __hadd(const __half a, const __half b); - -__device__ __half __hadd_sat(const __half a, const __half b); - -__device__ __half __hfma(const __half a, const __half b, const __half c); - -__device__ __half __hfma_sat(const __half a, const __half b, const __half c); - -__device__ __half __hmul(const __half a, const __half b); - -__device__ __half __hmul_sat(const __half a, const __half b); - -__device__ __half __hneq(const __half a); - -__device__ __half __hsub(const __half a, const __half b); - -__device__ __half __hsub_sat(const __half a, const __half b); - - - -/* -Half2 Arithmetic Instructions -*/ - -__device__ __half2 __hadd2(const __half2 a, const __half2 b); - -__device__ __half2 __hadd2_sat(const __half2 a, const __half2 b); - -__device__ __half2 __hfma2(const __half2 a, const __half2 b, const __half2 c); - -__device__ __half2 __hfma2_sat(const __half2 a, const __half2 b, const __half2 c); - -__device__ __half2 __hmul2(const __half2 a, const __half2 b); - -__device__ __half2 __hmul2_sat(const __half2 a, const __half2 b); - -__device__ __half2 __hneq2(const __half2 a); - -__device__ __half2 __hsub2(const __half2 a, const __half2 b); - -__device__ __half2 __hsub2_sat(const __half2 a, const __half2 b); - -/* -Half Cmps -*/ - -__device__ bool __heq(const __half a, const __half b); - -__device__ bool __hge(const __half a, const __half b); - -__device__ bool __hgt(const __half a, const __half b); - -__device__ bool __hisinf(const __half a); - -__device__ bool __hisnan(const __half a); - -__device__ bool __hle(const __half a, const __half b); - -__device__ bool __hlt(const __half a, const __half b); - -__device__ bool __hne(const __half a, const __half b); - -/* -Half2 Cmps -*/ - -__device__ bool __hbeq2(const __half2 a, const __half2 b); - -__device__ bool __hbge2(const __half2 a, const __half2 b); - -__device__ bool __hbgt2(const __half2 a, const __half2 b); - -__device__ bool __hble2(const __half2 a, const __half2 b); - -__device__ bool __hblt2(const __half2 a, const __half2 b); - -__device__ bool __hbne2(const __half2 a, const __half2 b); - -__device__ __half2 __heq2(const __half2 a, const __half2 b); - -__device__ __half2 __hge2(const __half2 a, const __half2 b); - -__device__ __half2 __hgt2(const __half2 a, const __half2 b); - -__device__ __half2 __hisnan2(const __half2 a); - -__device__ __half2 __hle2(const __half2 a, const __half2 b); - -__device__ __half2 __hlt2(const __half2 a, const __half2 b); - -__device__ __half2 __hne2(const __half2 a, const __half2 b); - - -/* -Half Cnvs and Data Mvmnt -*/ - -__device__ __half2 __float22half2_rn(const float2 a); - -__device__ __half __float2half(const float a); - -__device__ __half2 __float2half2_rn(const float a); - -__device__ __half2 __floats2half2_rn(const float a, const float b); - -__device__ float2 __half22float2(const __half2 a); - -__device__ float __half2float(const __half a); - -__device__ __half2 __half2half2(const __half a); - -__device__ __half2 __halves2half2(const __half a, const __half b); - -__device__ float __high2float(const __half2 a); - -__device__ __half __high2half(const __half2 a); - -__device__ __half2 __high2half2(const __half2 a); - -__device__ __half2 __highs2half2(const __half2 a, const __half2 b); - -__device__ float __low2float(const __half2 a); - -__device__ __half __low2half(const __half2 a); - -__device__ __half2 __low2half2(const __half2 a); - -__device__ __half2 __lows2half2(const __half2 a, const __half2 b); - -__device__ __half2 __lowhigh2highlow(const __half2 a); - -__device__ __half2 __low2half2(const __half2 a, const __half2 b); #endif + + #endif diff --git a/projects/hip/src/hip_fp16.cpp b/projects/hip/src/hip_fp16.cpp index 0ecac0a6fb..83e0a161c7 100644 --- a/projects/hip/src/hip_fp16.cpp +++ b/projects/hip/src/hip_fp16.cpp @@ -35,6 +35,8 @@ typedef struct{ }; } struct_float; +#if __clang_major__ == 3 + static __device__ float cvt_half_to_float(__half a){ struct_float ret = {0}; if(a.x == 0){ @@ -64,44 +66,44 @@ static __device__ __half cvt_float_to_half(float b){ } -__device__ __half __hadd(const __half a, const __half b){ +__device__ __half __soft_hadd(const __half a, const __half b){ return cvt_float_to_half(cvt_half_to_float(a)+cvt_half_to_float(b)); } -__device__ __half __hadd_sat(const __half a, const __half b){ +__device__ __half __soft_hadd_sat(const __half a, const __half b){ float f = cvt_half_to_float(a) + cvt_half_to_float(b); return (f < 0.0f ? __half_value_zero_float : (f > 1.0f ? __half_value_one_float: cvt_float_to_half(f))); } -__device__ __half __hfma(const __half a, const __half b, const __half c){ +__device__ __half __soft_hfma(const __half a, const __half b, const __half c){ return cvt_float_to_half(fmaf(cvt_half_to_float(a), cvt_half_to_float(b), cvt_half_to_float(c))); } -__device__ __half __hfma_sat(const __half a, const __half b, const __half c){ +__device__ __half __soft_hfma_sat(const __half a, const __half b, const __half c){ float f = fmaf(cvt_half_to_float(a), cvt_half_to_float(b), cvt_half_to_float(c)); return (f < 0.0f ? __half_value_zero_float : (f > 1.0f ? __half_value_one_float: cvt_float_to_half(f))); } -__device__ __half __hmul(const __half a, const __half b){ +__device__ __half __soft_hmul(const __half a, const __half b){ return cvt_float_to_half(cvt_half_to_float(a)*cvt_half_to_float(b)); } -__device__ __half __hmul_sat(const __half a, const __half b){ +__device__ __half __soft_hmul_sat(const __half a, const __half b){ float f = cvt_half_to_float(a) * cvt_half_to_float(b); return (f < 0.0f ? __half_value_zero_float : (f > 1.0f ? __half_value_one_float: cvt_float_to_half(f))); } -__device__ __half __hneq(const __half a){ +__device__ __half __soft_hneq(const __half a){ __half ret = {a.x}; ret.x ^= 1 << 15; return ret; } -__device__ __half __hsub(const __half a, const __half b){ +__device__ __half __soft_hsub(const __half a, const __half b){ return cvt_float_to_half(cvt_half_to_float(a)-cvt_half_to_float(b)); } -__device__ __half __hsub_sat(const __half a, const __half b){ +__device__ __half __soft_hsub_sat(const __half a, const __half b){ float f = cvt_half_to_float(a) - cvt_half_to_float(b); return (f < 0.0f ? __half_value_zero_float : (f > 1.0f ? __half_value_one_float: cvt_float_to_half(f))); } @@ -111,66 +113,66 @@ __device__ __half __hsub_sat(const __half a, const __half b){ Half2 Arithmetic Instructions */ -__device__ __half2 __hadd2(const __half2 a, const __half2 b){ +__device__ __half2 __soft_hadd2(const __half2 a, const __half2 b){ __half2 ret; - ret.p = __hadd(a.p, b.p); - ret.q = __hadd(a.q, b.q); + ret.p[1] = __soft_hadd(a.p[1], b.p[1]); + ret.p[0] = __soft_hadd(a.p[0], b.p[0]); return ret; } -__device__ __half2 __hadd2_sat(const __half2 a, const __half2 b){ +__device__ __half2 __soft_hadd2_sat(const __half2 a, const __half2 b){ __half2 ret; - ret.p = __hadd_sat(a.p, b.p); - ret.q = __hadd_sat(a.q, b.q); + ret.p[1] = __soft_hadd_sat(a.p[1], b.p[1]); + ret.p[0] = __soft_hadd_sat(a.p[0], b.p[0]); return ret; } -__device__ __half2 __hfma2(const __half2 a, const __half2 b, const __half2 c){ +__device__ __half2 __soft_hfma2(const __half2 a, const __half2 b, const __half2 c){ __half2 ret; - ret.p = __hfma(a.p, b.p, c.p); - ret.q = __hfma(a.q, b.q, c.q); + ret.p[1] = __soft_hfma(a.p[1], b.p[1], c.p[1]); + ret.p[0] = __soft_hfma(a.p[0], b.p[0], c.p[0]); return ret; } -__device__ __half2 __hfma2_sat(const __half2 a, const __half2 b, const __half2 c){ +__device__ __half2 __soft_hfma2_sat(const __half2 a, const __half2 b, const __half2 c){ __half2 ret; - ret.p = __hfma_sat(a.p, b.p, c.p); - ret.q = __hfma_sat(a.q, b.q, c.q); + ret.p[1] = __soft_hfma_sat(a.p[1], b.p[1], c.p[1]); + ret.p[0] = __soft_hfma_sat(a.p[0], b.p[0], c.p[0]); return ret; } -__device__ __half2 __hmul2(const __half2 a, const __half2 b){ +__device__ __half2 __soft_hmul2(const __half2 a, const __half2 b){ __half2 ret; - ret.p = __hmul(a.p, b.p); - ret.q = __hmul(a.q, b.q); + ret.p[1] = __soft_hmul(a.p[1], b.p[1]); + ret.p[0] = __soft_hmul(a.p[0], b.p[0]); return ret; } -__device__ __half2 __hmul2_sat(const __half2 a, const __half2 b){ +__device__ __half2 __soft_hmul2_sat(const __half2 a, const __half2 b){ __half2 ret; - ret.p = __hmul_sat(a.p, b.p); - ret.q = __hmul_sat(a.q, b.q); + ret.p[1] = __soft_hmul_sat(a.p[1], b.p[1]); + ret.p[0] = __soft_hmul_sat(a.p[0], b.p[0]); return ret; } -__device__ __half2 __hneq2(const __half2 a){ +__device__ __half2 __soft_hneq2(const __half2 a){ __half2 ret; - ret.p = __hneq(a.p); - ret.q = __hneq(a.q); + ret.p[1] = __soft_hneq(a.p[1]); + ret.p[0] = __soft_hneq(a.p[0]); return ret; } -__device__ __half2 __hsub2(const __half2 a, const __half2 b){ +__device__ __half2 __soft_hsub2(const __half2 a, const __half2 b){ __half2 ret; - ret.p = __hsub(a.p, b.p); - ret.q = __hsub(a.q, b.q); + ret.p[1] = __soft_hsub(a.p[1], b.p[1]); + ret.p[0] = __soft_hsub(a.p[0], b.p[0]); return ret; } -__device__ __half2 __hsub2_sat(const __half2 a, const __half2 b){ +__device__ __half2 __soft_hsub2_sat(const __half2 a, const __half2 b){ __half2 ret; - ret.p = __hsub_sat(a.p, b.p); - ret.q = __hsub_sat(a.q, b.q); + ret.p[1] = __soft_hsub_sat(a.p[1], b.p[1]); + ret.p[0] = __soft_hsub_sat(a.p[0], b.p[0]); return ret; } @@ -178,23 +180,23 @@ __device__ __half2 __hsub2_sat(const __half2 a, const __half2 b){ Half Cmps */ -__device__ bool __heq(const __half a, const __half b){ +__device__ bool __soft_heq(const __half a, const __half b){ return (a.x == b.x ? true:false); } -__device__ bool __hge(const __half a, const __half b){ +__device__ bool __soft_hge(const __half a, const __half b){ return (cvt_half_to_float(a) >= cvt_half_to_float(b)); } -__device__ bool __hgt(const __half a, const __half b){ +__device__ bool __soft_hgt(const __half a, const __half b){ return (cvt_half_to_float(a) > cvt_half_to_float(b)); } -__device__ bool __hisinf(const __half a){ +__device__ bool __soft_hisinf(const __half a){ return ((a.x == __half_neg_inf) ? -1 : (a.x == __half_pos_inf) ? 1 : 0); } -__device__ bool __hisnan(const __half a){ +__device__ bool __soft_hisnan(const __half a){ if(((a.x & __half_pos_inf) == a.x) || ((a.x & __half_neg_inf) == a.x)){ return true; }else{ @@ -202,15 +204,15 @@ __device__ bool __hisnan(const __half a){ } } -__device__ bool __hle(const __half a, const __half b){ +__device__ bool __soft_hle(const __half a, const __half b){ return (cvt_half_to_float(a) <= cvt_half_to_float(b)); } -__device__ bool __hlt(const __half a, const __half b){ +__device__ bool __soft_hlt(const __half a, const __half b){ return (cvt_half_to_float(a) < cvt_half_to_float(b)); } -__device__ bool __hne(const __half a, const __half b){ +__device__ bool __soft_hne(const __half a, const __half b){ return a.x == b.x ? false : true; } @@ -218,78 +220,78 @@ __device__ bool __hne(const __half a, const __half b){ Half2 Cmps */ -__device__ bool __hbeq2(const __half2 a, const __half2 b){ - return __heq(a.p, b.p) && __heq(a.q, b.q); +__device__ bool __soft_hbeq2(const __half2 a, const __half2 b){ + return __soft_heq(a.p[1], b.p[1]) && __soft_heq(a.p[0], b.p[0]); } -__device__ bool __hbge2(const __half2 a, const __half2 b){ - return __hge(a.p, b.p) && __hge(a.q, b.q); +__device__ bool __soft_hbge2(const __half2 a, const __half2 b){ + return __soft_hge(a.p[1], b.p[1]) && __soft_hge(a.p[0], b.p[0]); } -__device__ bool __hbgt2(const __half2 a, const __half2 b){ - return __hgt(a.p, b.p) && __hgt(a.q, b.q); +__device__ bool __soft_hbgt2(const __half2 a, const __half2 b){ + return __soft_hgt(a.p[1], b.p[1]) && __soft_hgt(a.p[0], b.p[0]); } -__device__ bool __hble2(const __half2 a, const __half2 b){ - return __hle(a.p, b.p) && __hle(a.q, b.q); +__device__ bool __soft_hble2(const __half2 a, const __half2 b){ + return __soft_hle(a.p[1], b.p[1]) && __soft_hle(a.p[0], b.p[0]); } -__device__ bool __hblt2(const __half2 a, const __half2 b){ - return __hlt(a.p, b.p) && __hlt(a.q, b.q); +__device__ bool __soft_hblt2(const __half2 a, const __half2 b){ + return __soft_hlt(a.p[1], b.p[1]) && __soft_hlt(a.p[0], b.p[0]); } -__device__ bool __hbne2(const __half2 a, const __half2 b){ - return __hne(a.p, b.p) && __hne(a.q, b.q); +__device__ bool __soft_hbne2(const __half2 a, const __half2 b){ + return __soft_hne(a.p[1], b.p[1]) && __soft_hne(a.p[0], b.p[0]); } -__device__ __half2 __heq2(const __half2 a, const __half2 b){ +__device__ __half2 __soft_heq2(const __half2 a, const __half2 b){ __half2 ret = {0}; - ret.p = (__heq(a.p, b.p)) ? __half_value_one_float : __half_value_zero_float; - ret.q = (__heq(a.q, b.q)) ? __half_value_one_float : __half_value_zero_float; + ret.p[1] = (__soft_heq(a.p[1], b.p[1])) ? __half_value_one_float : __half_value_zero_float; + ret.p[0] = (__soft_heq(a.p[0], b.p[0])) ? __half_value_one_float : __half_value_zero_float; return ret; } -__device__ __half2 __hge2(const __half2 a, const __half2 b){ +__device__ __half2 __soft_hge2(const __half2 a, const __half2 b){ __half2 ret = {0}; - ret.p = (__hge(a.p, b.p)) ? __half_value_one_float : __half_value_zero_float; - ret.q = (__hge(a.q, b.q)) ? __half_value_one_float : __half_value_zero_float; + ret.p[1] = (__soft_hge(a.p[1], b.p[1])) ? __half_value_one_float : __half_value_zero_float; + ret.p[0] = (__soft_hge(a.p[0], b.p[0])) ? __half_value_one_float : __half_value_zero_float; return ret; } -__device__ __half2 __hgt2(const __half2 a, const __half2 b){ +__device__ __half2 __soft_hgt2(const __half2 a, const __half2 b){ __half2 ret = {0}; - ret.p = (__hgt(a.p, b.p)) ? __half_value_one_float : __half_value_zero_float; - ret.q = (__hgt(a.q, b.q)) ? __half_value_one_float : __half_value_zero_float; + ret.p[1] = (__soft_hgt(a.p[1], b.p[1])) ? __half_value_one_float : __half_value_zero_float; + ret.p[0] = (__soft_hgt(a.p[0], b.p[0])) ? __half_value_one_float : __half_value_zero_float; return ret; } -__device__ __half2 __hisnan2(const __half2 a){ +__device__ __half2 __soft_hisnan2(const __half2 a){ __half2 ret = {0}; - ret.p = __hisnan(a.p) ? __half_value_one_float : __half_value_zero_float; - ret.q = __hisnan(a.q) ? __half_value_one_float : __half_value_zero_float; + ret.p[1] = __soft_hisnan(a.p[1]) ? __half_value_one_float : __half_value_zero_float; + ret.p[0] = __soft_hisnan(a.p[0]) ? __half_value_one_float : __half_value_zero_float; return ret; } -__device__ __half2 __hle2(const __half2 a, const __half2 b){ +__device__ __half2 __soft_hle2(const __half2 a, const __half2 b){ __half2 ret = {0}; - ret.p = (__hle(a.p, b.p)) ? __half_value_one_float : __half_value_zero_float; - ret.q = (__hle(a.q, b.q)) ? __half_value_one_float : __half_value_zero_float; + ret.p[1] = (__soft_hle(a.p[1], b.p[1])) ? __half_value_one_float : __half_value_zero_float; + ret.p[0] = (__soft_hle(a.p[0], b.p[0])) ? __half_value_one_float : __half_value_zero_float; return ret; } -__device__ __half2 __hlt2(const __half2 a, const __half2 b){ +__device__ __half2 __soft_hlt2(const __half2 a, const __half2 b){ __half2 ret = {0}; - ret.p = (__hlt(a.p, b.p)) ? __half_value_one_float : __half_value_zero_float; - ret.q = (__hlt(a.q, b.q)) ? __half_value_one_float : __half_value_zero_float; + ret.p[1] = (__soft_hlt(a.p[1], b.p[1])) ? __half_value_one_float : __half_value_zero_float; + ret.p[0] = (__soft_hlt(a.p[0], b.p[0])) ? __half_value_one_float : __half_value_zero_float; return ret; } -__device__ __half2 __hne2(const __half2 a, const __half2 b){ +__device__ __half2 __soft_hne2(const __half2 a, const __half2 b){ __half2 ret = {0}; - ret.p = (__hne(a.p, b.p)) ? __half_value_one_float : __half_value_zero_float; - ret.q = (__hne(a.q, b.q)) ? __half_value_one_float : __half_value_zero_float; + ret.p[1] = (__soft_hne(a.p[1], b.p[1])) ? __half_value_one_float : __half_value_zero_float; + ret.p[0] = (__soft_hne(a.p[0], b.p[0])) ? __half_value_one_float : __half_value_zero_float; return ret; } @@ -297,78 +299,80 @@ __device__ __half2 __hne2(const __half2 a, const __half2 b){ Half Cnvs and Data Mvmnt */ -__device__ __half2 __float22half2_rn(const float2 a){ +__device__ __half2 __soft_float22half2_rn(const float2 a){ __half2 ret = {0}; - ret.p = cvt_float_to_half(a.x); - ret.q = cvt_float_to_half(a.y); + ret.p[1] = cvt_float_to_half(a.x); + ret.p[0] = cvt_float_to_half(a.y); return ret; } -__device__ __half __float2half(const float a){ +__device__ __half __soft_float2half(const float a){ return cvt_float_to_half(a); } -__device__ __half2 __float2half2_rn(const float a){ +__device__ __half2 __soft_float2half2_rn(const float a){ __half ret = cvt_float_to_half(a); return {ret, ret}; } -__device__ __half2 __floats2half2_rn(const float a, const float b){ +__device__ __half2 __soft_floats2half2_rn(const float a, const float b){ return {cvt_float_to_half(a), cvt_float_to_half(b)}; } -__device__ float2 __half22float2(const __half2 a){ - return {cvt_half_to_float(a.p), cvt_half_to_float(a.q)}; +__device__ float2 __soft_half22float2(const __half2 a){ + return {cvt_half_to_float(a.p[1]), cvt_half_to_float(a.p[0])}; } -__device__ float __half2float(const __half a){ +__device__ float __soft_half2float(const __half a){ return cvt_half_to_float(a); } -__device__ __half2 __half2half2(const __half a){ +__device__ __half2 __soft_half2half2(const __half a){ return {a,a}; } -__device__ __half2 __halves2half2(const __half a, const __half b){ +__device__ __half2 __soft_halves2half2(const __half a, const __half b){ return {a,b}; } -__device__ float __high2float(const __half2 a){ - return cvt_half_to_float(a.p); +__device__ float __soft_high2float(const __half2 a){ + return cvt_half_to_float(a.p[1]); } -__device__ __half __high2half(const __half2 a){ - return a.p; +__device__ __half __soft_high2half(const __half2 a){ + return a.p[1]; } -__device__ __half2 __high2half2(const __half2 a){ - return {a.p, a.p}; +__device__ __half2 __soft_high2half2(const __half2 a){ + return {a.p[1], a.p[1]}; } -__device__ __half2 __highs2half2(const __half2 a, const __half2 b){ - return {a.p, b.p}; +__device__ __half2 __soft_highs2half2(const __half2 a, const __half2 b){ + return {a.p[1], b.p[1]}; } -__device__ float __low2float(const __half2 a){ - return cvt_half_to_float(a.q); +__device__ float __soft_low2float(const __half2 a){ + return cvt_half_to_float(a.p[0]); } -__device__ __half __low2half(const __half2 a){ - return a.q; +__device__ __half __soft_low2half(const __half2 a){ + return a.p[0]; } -__device__ __half2 __low2half2(const __half2 a){ - return {a.q, a.q}; +__device__ __half2 __soft_low2half2(const __half2 a){ + return {a.p[0], a.p[0]}; } -__device__ __half2 __lows2half2(const __half2 a, const __half2 b){ - return {a.q, b.q}; +__device__ __half2 __soft_lows2half2(const __half2 a, const __half2 b){ + return {a.p[0], b.p[0]}; } -__device__ __half2 __lowhigh2highlow(const __half2 a){ - return {a.q, a.p}; +__device__ __half2 __soft_lowhigh2highlow(const __half2 a){ + return {a.p[0], a.p[1]}; } -__device__ __half2 __low2half2(const __half2 a, const __half2 b){ - return {a.q, b.q}; +__device__ __half2 __soft_low2half2(const __half2 a, const __half2 b){ + return {a.p[0], b.p[0]}; } + +#endif diff --git a/projects/hip/src/hip_ir.ll b/projects/hip/src/hip_ir.ll index 472038df6a..202bf9f215 100644 --- a/projects/hip/src/hip_ir.ll +++ b/projects/hip/src/hip_ir.ll @@ -12,6 +12,55 @@ define linkonce_odr spir_func void @__threadfence_block() #1 { ret void } +; Lightning does not support inline asm for 16-bit data types +; So, bitcast half to short and then extend to 32bit i32 +; After inline asm, convert back to half +define half @__hip_hc_ir_hadd_half(half %a, half %b) #1 { + %1 = bitcast half %a to i16 + %2 = bitcast half %b to i16 + %3 = zext i16 %1 to i32 + %4 = zext i16 %2 to i32 + %5 = tail call i32 asm "v_add_f16 $0, $1, $2","=v,v,v"(i32 %3, i32 %4) + %6 = trunc i32 %5 to i16 + %7 = bitcast i16 %6 to half + ret half %7 +} + +define half @__hip_hc_ir_hsub_half(half %a, half %b) #1 { + %1 = bitcast half %a to i16 + %2 = bitcast half %b to i16 + %3 = zext i16 %1 to i32 + %4 = zext i16 %2 to i32 + %5 = tail call i32 asm "v_sub_f16 $0, $1, $2","=v,v,v"(i32 %3, i32 %4) + %6 = trunc i32 %5 to i16 + %7 = bitcast i16 %6 to half + ret half %7 +} + +define half @__hip_hc_ir_hmul_half(half %a, half %b) #1 { + %1 = bitcast half %a to i16 + %2 = bitcast half %b to i16 + %3 = zext i16 %1 to i32 + %4 = zext i16 %2 to i32 + %5 = tail call i32 asm "v_mul_f16 $0, $1, $2","=v,v,v"(i32 %3, i32 %4) + %6 = trunc i32 %5 to i16 + %7 = bitcast i16 %6 to half + ret half %7 +} + +define half @__hip_hc_ir_hfma_half(half %a, half %b, half %c) #1 { + %1 = bitcast half %a to i16 + %2 = bitcast half %b to i16 + %3 = bitcast half %c to i16 + %4 = zext i16 %1 to i32 + %5 = zext i16 %2 to i32 + %6 = zext i16 %3 to i32 + %7 = tail call i32 asm "v_mad_f16 $0, $1, $2, $3","=v,v,v,v"(i32 %4, i32 %5, i32 %6) + %8 = trunc i32 %7 to i16 + %9 = bitcast i16 %8 to half + ret half %9 +} + attributes #1 = { alwaysinline nounwind } diff --git a/projects/hip/tests/src/deviceLib/hipTestHalf.cpp b/projects/hip/tests/src/deviceLib/hipTestHalf.cpp new file mode 100644 index 0000000000..9533bf34ca --- /dev/null +++ b/projects/hip/tests/src/deviceLib/hipTestHalf.cpp @@ -0,0 +1,75 @@ +/* +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +/* HIT_START + * BUILD: %t %s ../test_common.cpp + * RUN: %t + * HIT_END + */ + +#include "test_common.h" +#include "hip/hip_runtime.h" +#include "hip/hip_runtime_api.h" +#include "hip/hip_fp16.h" + +#define hInf 0x7C00 +#define hInfPK 0x7C007C00 +#define h65504 0xF7FF +#define h65504PK 0xF7FFF7FF +#define h27 0x4EC0 +#define h27PK 0x4EC04EC0 +#define h7 0x4700 +#define h7PK 0x47004700 +#define h3 0x4200 +#define h3PK 0x42004200 +#define h1 0x3C00 +#define h1PK 0x3C003C00 +#define hPoint5 0x3800 +#define hPoint5PK 0x38003800 +#define hZero 0x0000 +#define hNeg1 0xBC00 +#define hNeg1PK 0xBC00BC00 + +struct holder{ +union{ + __half a; + unsigned short b; +}; +}; + +__global__ void CheckHalf(hipLaunchParm lp, __half* In1, __half* In2, __half* In3, __half* Out){ + Out[0] = __hadd(In1[0], In2[0]); + Out[1] = __hadd_sat(In1[1], In2[1]); + Out[2] = __hfma(In1[2], In2[2],In3[2]); + Out[3] = __hfma_sat(In1[3], In2[3], In3[3]); + Out[4] = __hmul(In1[4], In2[4]); + Out[5] = __hmul_sat(In1[5], In2[5]); + Out[6] = __hneg(In1[6]); + Out[7] = __hsub(In1[7], In2[7]); + Out[8] = __hsub_sat(In1[8], In2[8]); + Out[9] = hdiv(In1[9], In2[9]); +} + + +int main(){ + +} From 0180125a290568cd438a7aef06e217d002e15632 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Thu, 12 Jan 2017 14:10:51 -0600 Subject: [PATCH 062/281] added packed math fp16 native device functions 1. Added SDWA implementation inside IR file 2. Added device functions to header + used them in test Change-Id: Ib4e059a58eee201cc82438689e3e9bc5f9d26653 [ROCm/hip commit: 5ef8ef3bd7b95cba058dbce318e8b98c677bbf29] --- .../hip/include/hip/hcc_detail/hip_fp16.h | 71 +++++++++++++++++++ projects/hip/src/hip_ir.ll | 23 ++++++ .../hip/tests/src/deviceLib/hipTestHalf.cpp | 12 ++++ 3 files changed, 106 insertions(+) diff --git a/projects/hip/include/hip/hcc_detail/hip_fp16.h b/projects/hip/include/hip/hcc_detail/hip_fp16.h index c779bcfba2..2ef8d330e7 100644 --- a/projects/hip/include/hip/hcc_detail/hip_fp16.h +++ b/projects/hip/include/hip/hcc_detail/hip_fp16.h @@ -41,6 +41,11 @@ extern "C" __half __hip_hc_ir_hfma_half(__half, __half, __half); extern "C" __half __hip_hc_ir_hmul_half(__half, __half); extern "C" __half __hip_hc_ir_hsub_half(__half, __half); +extern "C" int __hip_hc_ir_hadd2_int(int, int); +extern "C" int __hip_hc_ir_hfma2_int(int, int, int); +extern "C" int __hip_hc_ir_hmul2_int(int, int); +extern "C" int __hip_hc_ir_hsub2_int(int, int); + __device__ static inline __half __hadd(const __half a, const __half b) { return __hip_hc_ir_hadd_half(a, b); } @@ -81,6 +86,72 @@ __device__ static inline __half hdiv(__half a, __half b) { return a/b; } +/* + Half2 Arithmetic Functions +*/ + +__device__ static inline __half2 __hadd2(__half2 a, __half2 b) { + __half2 c; + c.q = __hip_hc_ir_hadd2_int(a.q, b.q); + return c; +} + +__device__ static inline __half2 __hadd2_sat(__half2 a, __half2 b) { + __half2 c; + c.q = __hip_hc_ir_hadd2_int(a.q, b.q); + return c; +} + +__device__ static inline __half2 __hfma2(__half2 a, __half2 b, __half2 c) { + __half2 d; + d.q = __hip_hc_ir_hfma2_int(a.q, b.q, c.q); + return d; +} + +__device__ static inline __half2 __hfma2_sat(__half2 a, __half2 b, __half2 c) { + __half2 d; + d.q = __hip_hc_ir_hfma2_int(a.q, b.q, c.q); + return d; +} + +__device__ static inline __half2 __hmul2(__half2 a, __half2 b) { + __half2 c; + c.q = __hip_hc_ir_hmul2_int(a.q, b.q); + return c; +} + +__device__ static inline __half2 __hmul2_sat(__half2 a, __half2 b) { + __half2 c; + c.q = __hip_hc_ir_hmul2_int(a.q, b.q); + return c; +} + +__device__ static inline __half2 __hsub2(__half2 a, __half2 b) { + __half2 c; + c.q = __hip_hc_ir_hsub2_int(a.q, b.q); + return c; +} + +__device__ static inline __half2 __hneg2(__half2 a) { + __half2 c; + c.p[0] = - a.p[0]; + c.p[1] = - a.p[1]; + return c; +} + +__device__ static inline __half2 __hsub2_sat(__half2 a, __half2 b) { + __half2 c; + c.q = __hip_hc_ir_hsub2_int(a.q, b.q); + return c; +} + +__device__ static inline __half2 h2div(__half2 a, __half2 b) { + __half2 c; + c.p[0] = a.p[0] / b.p[0]; + c.p[1] = a.p[1] / b.p[1]; + return c; +} + #endif #if __clang_major__ == 3 diff --git a/projects/hip/src/hip_ir.ll b/projects/hip/src/hip_ir.ll index 202bf9f215..52460a38bb 100644 --- a/projects/hip/src/hip_ir.ll +++ b/projects/hip/src/hip_ir.ll @@ -61,6 +61,29 @@ define half @__hip_hc_ir_hfma_half(half %a, half %b, half %c) #1 { ret half %9 } +define i32 @__hip_hc_ir_hadd2_int(i32 %a, i32 %b) #1 { + %1 = tail call i32 asm sideeffect "v_add_f16 $0, $1, $2","=v,v,v"(i32 %a, i32 %b) + tail call void asm sideeffect "v_add_f16_sdwa $0, $1, $2 dst_sel:WORD_1 dst_unused:UNUSED_PRESERVE src0_sel:WORD_1 src1_sel:WORD_1","v,v,v"(i32 %1, i32 %a, i32 %b) + ret i32 %1 +} +define i32 @__hip_hc_ir_hfma2_int(i32 %a, i32 %b, i32 %c) #1 { + %1 = tail call i32 asm sideeffect "v_mad_f16 $0, $1, $2, $3","=v,v,v,v"(i32 %a, i32 %b, i32 %c) + tail call void asm sideeffect "v_mul_f16_sdwa $0, $1, $2 dst_sel:WORD_1 dst_unused:UNUSED_PRESERVE src0_sel:WORD_1 src1_sel:WORD_1","v,v,v"(i32 %1, i32 %a, i32 %b) + tail call void asm sideeffect "v_add_f16_sdwa $0, $1, $2 dst_sel:WORD_1 dst_unused:UNUSED_PRESERVE src0_sel:WORD_1 src1_sel:WORD_1","v,v,v"(i32 %1, i32 %1, i32 %c) + ret i32 %1 +} + +define i32 @__hip_hc_ir_hmul2_int(i32 %a, i32 %b) #1 { + %1 = tail call i32 asm sideeffect "v_mul_f16 $0, $1, $2","=v,v,v"(i32 %a, i32 %b) + tail call void asm sideeffect "v_mul_f16_sdwa $0, $1, $2 dst_sel:WORD_1 dst_unused:UNUSED_PRESERVE src0_sel:WORD_1 src1_sel:WORD_1","v,v,v"(i32 %1, i32 %a, i32 %b) + ret i32 %1 +} + +define i32 @__hip_hc_ir_hsub2_int(i32 %a, i32 %b) #1 { + %1 = tail call i32 asm sideeffect "v_sub_f16 $0, $1, $2","=v,v,v"(i32 %a, i32 %b) + tail call void asm sideeffect "v_sub_f16_sdwa $0, $1, $2 dst_sel:WORD_1 dst_unused:UNUSED_PRESERVE src0_sel:WORD_1 src1_sel:WORD_1","v,v,v"(i32 %1, i32 %a, i32 %b) + ret i32 %1 +} attributes #1 = { alwaysinline nounwind } diff --git a/projects/hip/tests/src/deviceLib/hipTestHalf.cpp b/projects/hip/tests/src/deviceLib/hipTestHalf.cpp index 9533bf34ca..2c01c5cb72 100644 --- a/projects/hip/tests/src/deviceLib/hipTestHalf.cpp +++ b/projects/hip/tests/src/deviceLib/hipTestHalf.cpp @@ -69,6 +69,18 @@ __global__ void CheckHalf(hipLaunchParm lp, __half* In1, __half* In2, __half* In Out[9] = hdiv(In1[9], In2[9]); } +__global__ void CheckHalf2(hipLaunchParm lp, __half2* In1, __half2* In2, __half2* In3, __half2* Out){ + Out[0] = __hadd2(In1[0], In2[0]); + Out[1] = __hadd2_sat(In1[1], In2[1]); + Out[2] = __hfma2(In1[2], In2[2],In3[2]); + Out[3] = __hfma2_sat(In1[3], In2[3], In3[3]); + Out[4] = __hmul2(In1[4], In2[4]); + Out[5] = __hmul2_sat(In1[5], In2[5]); + Out[6] = __hneg2(In1[6]); + Out[7] = __hsub2(In1[7], In2[7]); + Out[8] = __hsub2_sat(In1[8], In2[8]); + Out[9] = h2div(In1[9], In2[9]); +} int main(){ From d30f6a1d1b29a0805e69134d29c16ea2f4ac1016 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Thu, 12 Jan 2017 14:52:14 -0600 Subject: [PATCH 063/281] added comparision device functions for fp16 1. Added comparision device functions 2. Added test to check correct isa getting generated Change-Id: I16732f5a1438bdce145f7bfcecd28198e3cc4b79 [ROCm/hip commit: 2dcd7600dc6c413e47d3be5ac109f9a875e16c69] --- .../hip/include/hip/hcc_detail/hip_fp16.h | 75 +++++++++++++++++++ .../hip/tests/src/deviceLib/hipTestHalf.cpp | 18 +++-- 2 files changed, 86 insertions(+), 7 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/hip_fp16.h b/projects/hip/include/hip/hcc_detail/hip_fp16.h index 2ef8d330e7..e4408556f1 100644 --- a/projects/hip/include/hip/hcc_detail/hip_fp16.h +++ b/projects/hip/include/hip/hcc_detail/hip_fp16.h @@ -36,6 +36,17 @@ typedef struct __attribute__((aligned(4))){ }; } __half2; +struct holder{ + union { + __half h; + unsigned short s; + }; +}; + +#define HINF 65504 + +static struct holder hInf = {HINF}; + extern "C" __half __hip_hc_ir_hadd_half(__half, __half); extern "C" __half __hip_hc_ir_hfma_half(__half, __half, __half); extern "C" __half __hip_hc_ir_hmul_half(__half, __half); @@ -152,6 +163,70 @@ __device__ static inline __half2 h2div(__half2 a, __half2 b) { return c; } +/* +Half comparision Functions +*/ + +__device__ static inline bool __heq(__half a, __half b) { + return a == b ? true : false; +} + +__device__ static inline bool __hge(__half a, __half b) { + return a >= b ? true : false; +} + +__device__ static inline bool __hgt(__half a, __half b) { + return a > b ? true : false; +} + +__device__ static inline bool __hisinf(__half a) { + return a == hInf.s ? true : false; +} + +__device__ static inline bool __hisnan(__half a) { + return a > hInf.s ? true : false; +} + +__device__ static inline bool __hle(__half a, __half b) { + return a <= b ? true : false; +} + +__device__ static inline bool __hlt(__half a, __half b) { + return a < b ? true : false; +} + +__device__ static inline bool __hne(__half a, __half b) { + return a != b ? true : false; +} + +/* +Half2 Comparision Functions +*/ + +__device__ static inline bool __hbeq2(__half2 a, __half2 b) { + return (a.p[0] == b.p[0] ? true : false) && (a.p[1] == b.p[1] ? true : false); +} + +__device__ static inline bool __hbge2(__half2 a, __half2 b) { + return (a.p[0] >= b.p[0] ? true : false) && (a.p[1] >= b.p[1] ? true : false); +} + +__device__ static inline bool __hbgt2(__half2 a, __half2 b) { + return (a.p[0] > b.p[0] ? true : false) && (a.p[1] > b.p[1] ? true : false); +} + +__device__ static inline bool __hble2(__half2 a, __half2 b) { + return (a.p[0] <= b.p[0] ? true : false) && (a.p[1] <= b.p[1] ? true : false); +} + +__device__ static inline bool __hblt2(__half2 a, __half2 b) { + return (a.p[0] < b.p[0] ? true : false) && (a.p[1] < b.p[1] ? true : false); +} + +__device__ static inline bool __hbne2(__half2 a, __half2 b) { + return (a.p[0] != b.p[0] ? true : false) && (a.p[1] != b.p[1] ? true : false); +} + #endif #if __clang_major__ == 3 diff --git a/projects/hip/tests/src/deviceLib/hipTestHalf.cpp b/projects/hip/tests/src/deviceLib/hipTestHalf.cpp index 2c01c5cb72..46927c3902 100644 --- a/projects/hip/tests/src/deviceLib/hipTestHalf.cpp +++ b/projects/hip/tests/src/deviceLib/hipTestHalf.cpp @@ -49,13 +49,6 @@ THE SOFTWARE. #define hNeg1 0xBC00 #define hNeg1PK 0xBC00BC00 -struct holder{ -union{ - __half a; - unsigned short b; -}; -}; - __global__ void CheckHalf(hipLaunchParm lp, __half* In1, __half* In2, __half* In3, __half* Out){ Out[0] = __hadd(In1[0], In2[0]); Out[1] = __hadd_sat(In1[1], In2[1]); @@ -82,6 +75,17 @@ __global__ void CheckHalf2(hipLaunchParm lp, __half2* In1, __half2* In2, __half2 Out[9] = h2div(In1[9], In2[9]); } +__global__ void CheckCmpHalf(hipLaunchParm lp, __half* In1, __half* In2, bool* Out) { + Out[0] = __heq(In1[0], In2[0]); + Out[1] = __hge(In1[1], In2[1]); + Out[2] = __hgt(In1[2], In2[2]); + Out[3] = __hisinf(In1[3]); + Out[4] = __hisnan(In1[4]); + Out[5] = __hle(In1[5], In2[5]); + Out[6] = __hlt(In1[6], In2[6]); + Out[7] = __hne(In1[7], In2[7]); +} + int main(){ } From a0cb435ab96d9569b62c844bfb1e6b4aed856b59 Mon Sep 17 00:00:00 2001 From: Robert Date: Mon, 19 Dec 2016 17:36:07 -0800 Subject: [PATCH 064/281] fix spelling errors Conflicts: README.md docs/markdown/hip_faq.md Change-Id: I8ca025e01276939ed3d7be24200ecaa8cf5e1e2c [ROCm/hip commit: 65ad9d80d79d9eac96e2244e67c4726f36826aa0] --- projects/hip/CONTRIBUTING.md | 2 +- projects/hip/INSTALL.md | 6 +-- projects/hip/docs/markdown/hip_faq.md | 50 +++++++++---------- projects/hip/docs/markdown/hip_performance.md | 6 +-- .../docs/markdown/hip_porting_driver_api.md | 6 +-- .../hip/docs/markdown/hip_porting_guide.md | 2 +- projects/hip/docs/markdown/hip_profiling.md | 10 ++-- 7 files changed, 41 insertions(+), 41 deletions(-) diff --git a/projects/hip/CONTRIBUTING.md b/projects/hip/CONTRIBUTING.md index 81c4bc8c32..d9d353681d 100644 --- a/projects/hip/CONTRIBUTING.md +++ b/projects/hip/CONTRIBUTING.md @@ -126,7 +126,7 @@ Differences or limitations of HIP APIs as compared to CUDA APIs should be clearl - All HIP environment variables should begin with the keyword HIP_ Environment variables should be long enough to describe their purpose but short enough so they can be remembered - perhaps 10-20 characters, with 3-4 parts separated by underscores. - To see the list of current environment variables, along with their values, set HIP_PRINT_ENV and run any hip applications on ROCM platform . + To see the list of current environment variables, along with their values, set HIP_PRINT_ENV and run any hip applications on ROCm platform . HIPCC or other tools may support additional environment variables which should follow the above convention. diff --git a/projects/hip/INSTALL.md b/projects/hip/INSTALL.md index 4139cb2010..ef584dafa0 100644 --- a/projects/hip/INSTALL.md +++ b/projects/hip/INSTALL.md @@ -22,14 +22,14 @@ HIP code can be developed either on AMD ROCm platform using hcc compiler, or a C ## AMD-hcc -* Install the [rocm](http://gpuopen.com/getting-started-with-boltzmann-components-platforms-installation/) packages. Rocm will install all of the necessary components, including the kernel driver, runtime software, HCC compiler, and HIP. +* Install the [rocm](http://gpuopen.com/getting-started-with-boltzmann-components-platforms-installation/) packages. ROCm will install all of the necessary components, including the kernel driver, runtime software, HCC compiler, and HIP. * Default paths and environment variables: * By default HIP looks for hcc in /opt/rocm/hcc (can be overridden by setting HCC_HOME environment variable) * By default HIP looks for HSA in /opt/rocm/hsa (can be overridden by setting HSA_PATH environment variable) * By default HIP is installed into /opt/rocm/hip (can be overridden by setting HIP_PATH environment variable). - * Optionally, consider adding /opt/rocm/bin to your path to make it easier to use the tools. + * Optionally, consider adding /opt/rocm/bin to your PATH to make it easier to use the tools. ## NVIDIA-nvcc @@ -96,7 +96,7 @@ The native GCN target is included with upstream LLVM, and has also been integrat Binary packages for the direct-to-isa package are included with the [rocm](http://gpuopen.com/getting-started-with-boltzmann-components-platforms-installation/) package. Alternatively, this sections describes how to build it from source: -1. Install the rocm packages as described above. +1. Install the ROCm packages as described above. 2. Follow the instructions [here](https://github.com/RadeonOpenCompute/HCC-Native-GCN-ISA/wiki) * In the make step for HCC, we recommend setting -DCMAKE_INSTALL_PREFIX. * Set HCC_HOME environment variable before compiling HIP program to point to the native compiler: diff --git a/projects/hip/docs/markdown/hip_faq.md b/projects/hip/docs/markdown/hip_faq.md index 0b79976988..d7235c4ebc 100644 --- a/projects/hip/docs/markdown/hip_faq.md +++ b/projects/hip/docs/markdown/hip_faq.md @@ -50,7 +50,7 @@ At a high-level, the following features are not supported: - Textures - Dynamic parallelism (CUDA 5.0) - Managed memory (CUDA 6.5) -- Graphics interoperation with OpenGL or Direct3D +- Graphics interoperability with OpenGL or Direct3D - CUDA Driver API (Under Development) - CUDA IPC Functions (Under Development) - CUDA array, mipmappedArray and pitched memory @@ -75,13 +75,13 @@ See the [API Support Table](CUDA_Runtime_API_functions_supported_by_HIP.md) for ### Is HIP a drop-in replacement for CUDA? -No. HIP provides porting tools which do most of the work do convert CUDA code into portable C++ code that uses the HIP APIs. +No. HIP provides porting tools which do most of the work to convert CUDA code into portable C++ code that uses the HIP APIs. Most developers will port their code from CUDA to HIP and then maintain the HIP version. HIP code provides the same performance as native CUDA code, plus the benefits of running on AMD platforms. ### What specific version of CUDA does HIP support? -HIP APIs and features do not map to a specific CUDA version. HIP provides a strong subset of functionality provided in CUDA, and the hipify tools can -scan code to identify any unsupported CUDA functions - this is very useful for identifying the specific features required by a given application. +HIP APIs and features do not map to a specific CUDA version. HIP provides a strong subset of functionality provided in CUDA, and the hipify tools can +scan code to identify any unsupported CUDA functions - this is useful for identifying the specific features required by a given application. However, we can provide a rough summary of the features included in each CUDA SDK and the support level in HIP: @@ -105,8 +105,8 @@ However, we can provide a rough summary of the features included in each CUDA SD - TBD. ### What libraries does HIP support? -HIP includes growing support for the 4 key math libraries using hcBlas, hcFft, hcrng, and hcsparse). -These offer pointer-based memory interfaces (as opposed to opaque buffers) and can be easily interfaces with other HCC code. Developers should use conditional compilation if portability to nvcc systems is desired - using calls to cu* routines on one path and hc* routines on the other. +HIP includes growing support for the 4 key math libraries using hcBlas, hcFft, hcrng and hcsparse. +These offer pointer-based memory interfaces (as opposed to opaque buffers) and can be easily interfaced with other HCC applications. Developers should use conditional compilation if portability to nvcc systems is desired - using calls to cu* routines on one path and hc* routines on the other. - [hcblas](https://bitbucket.org/multicoreware/hcblas) - [hcfft](https://bitbucket.org/multicoreware/hcfft) @@ -130,47 +130,47 @@ HIP offers several benefits over OpenCL: ### How does porting CUDA to HIP compare to porting CUDA to OpenCL? Both HIP and CUDA are dialects of C++, and thus porting between them is relatively straightforward. Both dialects support templates, classes, lambdas, and other C++ constructs. -As one example, the hipify tool was originally a perl script that used simple text conversions from CUDA to HIP. +As one example, the hipify tool was originally a Perl script that used simple text conversions from CUDA to HIP. HIP and CUDA provide similar math library calls as well. In summary, the HIP philosophy was to make the HIP language close enough to CUDA that the porting effort is relatively simple. This reduces the potential for error, and also makes it easy to automate the translation. HIP's goal is to quickly get the ported program running on both platforms with little manual intervention, so that the programmer can focus on performance optimizations. There have been several tools that have attempted to convert CUDA into OpenCL, such as CU2CL. OpenCL is a C99-based kernel language (rather than C++) and also does not support single-source compilation. -As a result, the OpenCL syntax is quite different than CUDA, and the porting tools have to perform some heroic transformations to bridge this gap. +As a result, the OpenCL syntax is different from CUDA, and the porting tools have to perform some heroic transformations to bridge this gap. The tools also struggle with more complex CUDA applications, in particular those that use templates, classes, or other C++ features inside the kernel. ### What hardware does HIP support? -- For AMD platforms, HIP runs on the same hardware that the HCC "hc" mode supports. See the ROCM documentation for the list of supported platforms. -- For Nvidia platforms, HIP requires Unified Memory and should run on a device which runs the CUDA SDK 6.0 or newer. We have tested the Nvidia Titan and K40. +- For AMD platforms, HIP runs on the same hardware that the HCC "hc" mode supports. See the ROCm documentation for the list of supported platforms. +- For Nvidia platforms, HIP requires Unified Memory and should run on any device supporting CUDA SDK 6.0 or newer. We have tested the Nvidia Titan and Tesla K40. ### Does Hipify automatically convert all source code? -Typically, Hipify can automatically convert almost all run-time code, and the coordinate indexing device code (i.e. threadIdx.x -> hipThreadIdx_x). +Typically, hipify can automatically convert almost all run-time code, and the coordinate indexing device code ( threadIdx.x -> hipThreadIdx_x ). Most device code needs no additional conversion, since HIP and CUDA have similar names for math and built-in functions. The hipify-clang tool will automatically modify the kernel signature as needed (automating a step that used to be done manually) Additional porting may be required to deal with architecture feature queries or with CUDA capabilities that HIP doesn't support. In general, developers should always expect to perform some platform-specific tuning and optimization. ### What is NVCC? -NVCC is Nvidia's compiler driver for compiling "CUDA C++" code into PTX or device code for Nvidia GPUs. It's a closed-source binary product that comes with CUDA SDKs. +NVCC is Nvidia's compiler driver for compiling "CUDA C++" code into PTX or device code for Nvidia GPUs. It's a closed-source binary compiler that is provided by the CUDA SDK. ### What is HCC? -HCC is AMD's compiler driver which compiles "heterogenous C++" code into HSAIL or GCN device code for AMD GPUs. It's an open-source compiler based on recent versions of CLANG/LLVM. +HCC is AMD's compiler driver which compiles "heterogeneous C++" code into HSAIL or GCN device code for AMD GPUs. It's an open-source compiler based on recent versions of CLANG/LLVM. ### Why use HIP rather than supporting CUDA directly? While HIP is a strong subset of the CUDA, it is a subset. The HIP layer allows that subset to be clearly defined and documented. -Developers who code to the HIP API can be assured there code will remain portable across Nvidia and AMD platforms. +Developers who code to the HIP API can be assured their code will remain portable across Nvidia and AMD platforms. In addition, HIP defines portable mechanisms to query architectural features, and supports a larger 64-bit wavesize which expands the return type for cross-lane functions like ballot and shuffle from 32-bit ints to 64-bit ints. ### Can I develop HIP code on an Nvidia CUDA platform? -Yes! HIP's CUDA path only exposes the APIs and functionality that work on both NVCC and HCC back-ends. -"Extra" APIs, parameters, and features which exist in CUDA but not in HCC will typically result in compile-time or run-time errors. -Developers need to use the HIP API for most accelerator code, and bracket any CUDA-specific code with appropriate ifdefs. +Yes. HIP's CUDA path only exposes the APIs and functionality that work on both NVCC and HCC back-ends. +"Extra" APIs, parameters, and features which exist in CUDA but not in HCC will typically result in compile- or run-time errors. +Developers need to use the HIP API for most accelerator code, and bracket any CUDA-specific code with preprocessor conditionals. Developers concerned about portability should of course run on both platforms, and should expect to tune for performance. In some cases CUDA has a richer set of modes for some APIs, and some C++ capabilities such as virtual functions - see the HIP @API documentation for more details. ### Can I develop HIP code on an AMD HCC platform? -Yes! HIP's HCC path only exposes the APIs and functions that work on both NVCC and HCC back ends. "Extra" APIs, parameters and features that appear in HCC but not CUDA will typically cause compile- or run-time errors. Developers must use the HIP API for most accelerator code and bracket any HCC-specific code with appropriate ifdefs. Those concerned about portability should, of course, test their code on both platforms and should tune it for performance. Typically, HCC supports a more modern set of C++11/C++14/C++17 features, so HIP developers who want portability should be careful when using advanced C++ features on the hc path. +Yes. HIP's HCC path only exposes the APIs and functions that work on both NVCC and HCC back ends. "Extra" APIs, parameters and features that appear in HCC but not CUDA will typically cause compile- or run-time errors. Developers must use the HIP API for most accelerator code and bracket any HCC-specific code with preprocessor conditionals. Those concerned about portability should, of course, test their code on both platforms and should tune it for performance. Typically, HCC supports a more modern set of C++11/C++14/C++17 features, so HIP developers who want portability should be careful when using advanced C++ features on the hc path. ### Can a HIP binary run on both AMD and Nvidia platforms? HIP is a source-portable language that can be compiled to run on either the HCC or NVCC platform. HIP tools don't create a "fat binary" that can run on either platform, however. @@ -183,9 +183,9 @@ A C++ dialect, hc is supported by the AMD HCC compiler. It provides C++ run time ### On HCC, can I link HIP code with host code compiled with another compiler such as gcc, icc, or clang ? -Yes! HIP/HCC generates the object code which conforms to the GCC ABI, and also links with libstdc++. This means you can compile host code with the compiler of your choice and link this -with GPU code compiler with HIP. Larger projects often contain a mixture of accelerator code (initially written in CUDA with nvcc) plus host code (compiled with gcc, icc, or clang). These projects -can convert the accelerator code to HIP, compile that code with hipcc, and link with object code from the preferred compiler.S +Yes. HIP/HCC generates the object code which conforms to the GCC ABI, and also links with libstdc++. This means you can compile host code with the compiler of your choice and link the generated object code +with GPU code compiled with HIP. Larger projects often contain a mixture of accelerator code (initially written in CUDA with nvcc) and host code (compiled with gcc, icc, or clang). These projects +can convert the accelerator code to HIP, compile that code with hipcc, and link with object code from their preferred compiler. @@ -197,7 +197,7 @@ Sometimes this isn't what you want - you can force HIP to recognize the platform export HIP_PLATFORM=hcc ``` -One symptom of this problem is the message "error: 'unknown error'(11) at square.hipref.cpp:56". This can occur if you have a CUDA installation on an AMD platform, and HIP incorrectly detects the platform as nvcc. HIP may be able to compile the application using the nvcc tool-chain, but will generate this error at runtime since the platform does not have a CUDA device. The fix is to set HIP_PLATFORM=hcc and rebuild the issue. +One symptom of this problem is the message "error: 'unknown error'(11) at square.hipref.cpp:56". This can occur if you have a CUDA installation on an AMD platform, and HIP incorrectly detects the platform as nvcc. HIP may be able to compile the application using the nvcc tool-chain, but will generate this error at runtime since the platform does not have a CUDA device. The fix is to set HIP_PLATFORM=hcc and rebuild. If you see issues related to incorrect platform detection, please file an issue with the GitHub issue tracker so we can improve HIP's platform detection logic. @@ -206,7 +206,7 @@ Yes. You can use HIP_PLATFORM to choose which path hipcc targets. This configur ### On CUDA, can I mix CUDA code with HIP code? -Yes. Most HIP data structures (hipStream_t, hipEvent_t) are typedefs to CUDA equivalents and can be intermixed. Both CUDA and HIP use integer device ids . +Yes. Most HIP data structures (hipStream_t, hipEvent_t) are typedefs to CUDA equivalents and can be intermixed. Both CUDA and HIP use integer device ids. One notable exception is that hipError_t is a new type, and cannot be used where a cudaError_t is expected. In these cases, refactor the code to remove the expectation. Alternatively, hip_runtime_api.h defines functions which convert between the error code spaces: hipErrorToCudaError @@ -217,10 +217,10 @@ If platform portability is important, use #ifdef __HIP_PLATFORM_NVCC__ to guard ### On HCC, can I use HC functionality with HIP? Yes. -The code can include hc.hpp and use HC functions inside the kernel. A typical use case is to use AMD-specific hardware features such as the permute, swizzle, or DPP operations. +The code can include hc.hpp and use HC functions inside the kernel. A typical use-case is to use AMD-specific hardware features such as the permute, swizzle, or DPP operations. The "-stdlib=libc++" must be passed to hipcc in order to compile hc.hpp. See the 'bit_extract' sample for an example. -Also these functions can be used to extract HCC acclerator and accelerator_view structures from the HIP deviceId and hipStream_t: +Also these functions can be used to extract HCC accelerator and accelerator_view structures from the HIP deviceId and hipStream_t: hipHccGetAccelerator(int deviceId, hc::accelerator *acc); hipError_t hipHccGetAcceleratorView(hipStream_t stream, hc::accelerator_view **av); diff --git a/projects/hip/docs/markdown/hip_performance.md b/projects/hip/docs/markdown/hip_performance.md index bd550c9255..67a2f88b58 100644 --- a/projects/hip/docs/markdown/hip_performance.md +++ b/projects/hip/docs/markdown/hip_performance.md @@ -6,18 +6,18 @@ Please note that this document lists possible ways for experimenting with HIP st #### On Small BAR Setup -There are two possible ways to transfer data from Host to Device (H2D) and Device to Host(D2H) +There are two possible ways to transfer data from host-to-device (H2D) and device-to-host(D2H) * Using Staging Buffers * Using PinInPlace #### On Large BAR Setup -There are three possible ways to transfer data from Host to Device (H2D) +There are three possible ways to transfer data from host-to-device (H2D) * Using Staging Buffers * Using PinInPlace * Direct Memcpy - And there are two possible ways to transfer data from Device to Host (D2H) + And there are two possible ways to transfer data from device-to-host (D2H) * Using Staging Buffers * Using PinInPlace diff --git a/projects/hip/docs/markdown/hip_porting_driver_api.md b/projects/hip/docs/markdown/hip_porting_driver_api.md index 5093291baa..f51f53a092 100644 --- a/projects/hip/docs/markdown/hip_porting_driver_api.md +++ b/projects/hip/docs/markdown/hip_porting_driver_api.md @@ -1,7 +1,7 @@ # Porting CUDA Driver API ## Introduction to the CUDA Driver and Runtime APIs -CUDA provides a separate CUDA Driver and Runtime APIs. The two APis have significant overlap in functionality: +CUDA provides a separate CUDA Driver and Runtime APIs. The two APIs have significant overlap in functionality: - Both APIs support events, streams, memory management, memory copy, and error handling. - Both APIs deliver similar performance. - Driver APIs calls begin with the prefix `cu` while Runtime APIs begin with the prefix `cuda`. For example, the Driver API API contains `cuEventCreate` while the Runtime API contains `cudaEventCreate`, with similar functionality. @@ -90,14 +90,14 @@ the context. The current context is implicitly used by other APIs such as `hipS The hipify tool will convert CUDA Driver APIs for streams, events, memory management to the equivalent HIP driver calls. For example, `cuEventCreate` will be translated to `hipEventCreate`. Hipify also converts error code from the Driver namespace and coding -convention to the equivalent HIP error code. Thus, HIP unifies the APis for these common functions. +convention to the equivalent HIP error code. Thus, HIP unifies the APIs for these common functions. [hipify support for translating driver API is Under Development] The memory copy APIs require additional explanation. The CUDA driver includes the memory direction in the name of the API (ie `cuMemcpyH2D`) while the CUDA driver API provides a single memory copy API with a parameter that specifies the direction and additionally supports a "default" direction where the runtime determines the direction automatically. -HIP provides APis with both styles: for example, `hipMemcpyH2D` as well as `hipMemcpy`. +HIP provides APIs with both styles: for example, `hipMemcpyH2D` as well as `hipMemcpy`. The first flavor may be faster in some cases since they avoid host overhead to detect the different memory directions. diff --git a/projects/hip/docs/markdown/hip_porting_guide.md b/projects/hip/docs/markdown/hip_porting_guide.md index e0e74c0f89..e34bed0cbc 100644 --- a/projects/hip/docs/markdown/hip_porting_guide.md +++ b/projects/hip/docs/markdown/hip_porting_guide.md @@ -553,7 +553,7 @@ If you pass a ".cu" file, hcc will attempt to compile it as a Cuda language file ### HIP Environment Variables -On the HCC path, HIP provides a number of environment variables that control the behavior of HIP. Some of these are useful for appliction development (for example HIP_VISIBLE_DEVICES, HIP_LAUNCH_BLOCKING), +On the HCC path, HIP provides a number of environment variables that control the behavior of HIP. Some of these are useful for application development (for example HIP_VISIBLE_DEVICES, HIP_LAUNCH_BLOCKING), some are useful for performance tuning or experimentation (for example HIP_STAGING*), and some are useful for debugging (HIP_DB). You can see the environment variables supported by HIP as well as their current values and usage with the environment var "HIP_PRINT_ENV" - set this and then run any HIP application. For example: diff --git a/projects/hip/docs/markdown/hip_profiling.md b/projects/hip/docs/markdown/hip_profiling.md index 61f1bbcfbc..c198c4dc4b 100644 --- a/projects/hip/docs/markdown/hip_profiling.md +++ b/projects/hip/docs/markdown/hip_profiling.md @@ -92,11 +92,11 @@ HIP_PROFILE_API supports two levels of information. #### Adding markers to applications -Markers can be used to define application-specific events that will be recorded in the ATP file and displayed in the CodeXL gui. +Markers can be used to define application-specific events that will be recorded in the ATP file and displayed in the CodeXL GUI. This can be particularly useful for visualizing how the higher-level phases of application behavior relate to the lower level HIP APIs, kernel launches, and data transfers. For example, an instrumented machine learning framework could show the beginning and ending of each layer in the network. -Markers have a specific begin and end time, and can be nested. Nested calls are displayed hierarchically in the CodeXL gui, with each level of the hierarchy occupying a different row. +Markers have a specific begin and end time, and can be nested. Nested calls are displayed hierarchically in the CodeXL GUI, with each level of the hierarchy occupying a different row. The HIP APis are defined in "hip_profile.h": ``` @@ -131,7 +131,7 @@ The HIP marker API is only supported on ROCm platform. The marker macros are de This [HIP sample](samples/2_Cookbook/2_Profiler/) shows the profiler marker API used in a small application. -More information on the marker API can be found in the profiler header file and PDF in a ROCM installation: +More information on the marker API can be found in the profiler header file and PDF in a ROCm installation: - /opt/rocm/profiler/CXLActivityLogger/include/CXLActivityLogger.h - /opt/rocm/profiler/CXLActivityLogger/doc/CXLActivityLogger.pdf @@ -185,7 +185,7 @@ $ nvprof --profile-from-start-off ... This feature is under development. #### Reducing timeline trace output file size -If the application is already recording the HIP APIs, the HSA APIs are somewhat redundant and the ATP file size can be substantially reduced by not recording these APIs. HIP includes a text file that lists all of the HSA APis and can assist in this filtering: +If the application is already recording the HIP APIs, the HSA APIs are somewhat redundant and the ATP file size can be substantially reduced by not recording these APIs. HIP includes a text file that lists all of the HSA APIs and can assist in this filtering: ``` $ rocm-profiler -F hip/bin/hsa-api-filter-cxl.txt @@ -273,7 +273,7 @@ None will disable use of color control codes for both the opening and closing an This flag is primarily targeted to assist HIP development team in the development of the HIP runtime, but in some situations may be useful to HIP application developers as well. The HIP debug information is designed to print important information during the execution of a HIP API. HIP provides -different color-coded levels of debug informaton: +different color-coded levels of debug information: - api : Print the beginning and end of each HIP API, including the arguments and return codes. This is equivalent to setting HIP_TRACE_API=1. - sync : Print multi-thread and other synchronization debug information. - copy : Print which engine is doing the copy, which copy flavor is selected, information on source and destination memory. From a3cd9893d32d424ab9bd8455485a24319fd3e59e Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Fri, 13 Jan 2017 14:59:15 +0300 Subject: [PATCH 065/281] [HIPIFY] Formatting, no functional changes. [ROCm/hip commit: b7992fa252f414d5569dc10d0c943fd38a2d8700] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 241 ++++++++++----------- 1 file changed, 119 insertions(+), 122 deletions(-) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index 938c980684..543d527d58 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -184,138 +184,137 @@ struct cuda2hipMap { cuda2hipRename["cublas_v2.h"] = {"hipblas.h", CONV_INCLUDE, API_BLAS}; // Error codes and return types - cuda2hipRename["CUresult"] = {"hipError_t", CONV_TYPE, API_DRIVER}; - cuda2hipRename["cudaError_t"] = {"hipError_t", CONV_TYPE, API_RUNTIME}; - cuda2hipRename["cudaError"] = {"hipError", CONV_TYPE, API_RUNTIME}; + cuda2hipRename["CUresult"] = {"hipError_t", CONV_TYPE, API_DRIVER}; + cuda2hipRename["cudaError_t"] = {"hipError_t", CONV_TYPE, API_RUNTIME}; + cuda2hipRename["cudaError"] = {"hipError", CONV_TYPE, API_RUNTIME}; // CUDA Driver API error code only - cuda2hipRename["CUDA_ERROR_INVALID_CONTEXT"] = {"hipErrorInvalidContext", CONV_ERR, API_DRIVER}; - cuda2hipRename["CUDA_ERROR_CONTEXT_ALREADY_CURRENT"] = {"hipErrorContextAlreadyCurrent", CONV_ERR, API_DRIVER}; - cuda2hipRename["CUDA_ERROR_MAP_FAILED"] = {"hipErrorMapFailed", CONV_ERR, API_DRIVER}; - cuda2hipRename["CUDA_ERROR_UNMAP_FAILED"] = {"hipErrorUnmapFailed", CONV_ERR, API_DRIVER}; - cuda2hipRename["CUDA_ERROR_ARRAY_IS_MAPPED"] = {"hipErrorArrayIsMapped", CONV_ERR, API_DRIVER}; - cuda2hipRename["CUDA_ERROR_ALREADY_MAPPED"] = {"hipErrorAlreadyMapped", CONV_ERR, API_DRIVER}; - cuda2hipRename["CUDA_ERROR_ALREADY_ACQUIRED"] = {"hipErrorAlreadyAcquired", CONV_ERR, API_DRIVER}; - cuda2hipRename["CUDA_ERROR_NOT_MAPPED"] = {"hipErrorNotMapped", CONV_ERR, API_DRIVER}; - cuda2hipRename["CUDA_ERROR_NOT_MAPPED_AS_ARRAY"] = {"hipErrorNotMappedAsArray", CONV_ERR, API_DRIVER}; - cuda2hipRename["CUDA_ERROR_NOT_MAPPED_AS_POINTER"] = {"hipErrorNotMappedAsPointer", CONV_ERR, API_DRIVER}; - cuda2hipRename["CUDA_ERROR_CONTEXT_ALREADY_IN_USE"] = {"hipErrorContextAlreadyInUse", CONV_ERR, API_DRIVER}; - cuda2hipRename["CUDA_ERROR_INVALID_SOURCE"] = {"hipErrorInvalidSource", CONV_ERR, API_DRIVER}; - cuda2hipRename["CUDA_ERROR_FILE_NOT_FOUND"] = {"hipErrorFileNotFound", CONV_ERR, API_DRIVER}; - cuda2hipRename["CUDA_ERROR_NOT_FOUND"] = {"hipErrorNotFound", CONV_ERR, API_DRIVER}; + cuda2hipRename["CUDA_ERROR_INVALID_CONTEXT"] = {"hipErrorInvalidContext", CONV_ERR, API_DRIVER}; + cuda2hipRename["CUDA_ERROR_CONTEXT_ALREADY_CURRENT"] = {"hipErrorContextAlreadyCurrent", CONV_ERR, API_DRIVER}; + cuda2hipRename["CUDA_ERROR_MAP_FAILED"] = {"hipErrorMapFailed", CONV_ERR, API_DRIVER}; + cuda2hipRename["CUDA_ERROR_UNMAP_FAILED"] = {"hipErrorUnmapFailed", CONV_ERR, API_DRIVER}; + cuda2hipRename["CUDA_ERROR_ARRAY_IS_MAPPED"] = {"hipErrorArrayIsMapped", CONV_ERR, API_DRIVER}; + cuda2hipRename["CUDA_ERROR_ALREADY_MAPPED"] = {"hipErrorAlreadyMapped", CONV_ERR, API_DRIVER}; + cuda2hipRename["CUDA_ERROR_ALREADY_ACQUIRED"] = {"hipErrorAlreadyAcquired", CONV_ERR, API_DRIVER}; + cuda2hipRename["CUDA_ERROR_NOT_MAPPED"] = {"hipErrorNotMapped", CONV_ERR, API_DRIVER}; + cuda2hipRename["CUDA_ERROR_NOT_MAPPED_AS_ARRAY"] = {"hipErrorNotMappedAsArray", CONV_ERR, API_DRIVER}; + cuda2hipRename["CUDA_ERROR_NOT_MAPPED_AS_POINTER"] = {"hipErrorNotMappedAsPointer", CONV_ERR, API_DRIVER}; + cuda2hipRename["CUDA_ERROR_CONTEXT_ALREADY_IN_USE"] = {"hipErrorContextAlreadyInUse", CONV_ERR, API_DRIVER}; + cuda2hipRename["CUDA_ERROR_INVALID_SOURCE"] = {"hipErrorInvalidSource", CONV_ERR, API_DRIVER}; + cuda2hipRename["CUDA_ERROR_FILE_NOT_FOUND"] = {"hipErrorFileNotFound", CONV_ERR, API_DRIVER}; + cuda2hipRename["CUDA_ERROR_NOT_FOUND"] = {"hipErrorNotFound", CONV_ERR, API_DRIVER}; // CUDA RT API error code only - cuda2hipRename["cudaErrorInvalidDeviceFunction"] = {"hipErrorInvalidDeviceFunction", CONV_ERR, API_RUNTIME}; - cuda2hipRename["cudaErrorInvalidConfiguration"] = {"hipErrorInvalidConfiguration", CONV_ERR, API_RUNTIME}; - cuda2hipRename["cudaErrorPriorLaunchFailure"] = {"hipErrorPriorLaunchFailure", CONV_ERR, API_RUNTIME}; - cuda2hipRename["cudaErrorInvalidMemcpyDirection"] = {"hipErrorInvalidMemcpyDirection", CONV_ERR, API_RUNTIME}; - cuda2hipRename["cudaErrorInvalidDevicePointer"] = {"hipErrorInvalidDevicePointer", CONV_ERR, API_RUNTIME}; - cuda2hipRename["cudaErrorMissingConfiguration"] = {"hipErrorMissingConfiguration", CONV_ERR, API_RUNTIME}; + cuda2hipRename["cudaErrorInvalidDeviceFunction"] = {"hipErrorInvalidDeviceFunction", CONV_ERR, API_RUNTIME}; + cuda2hipRename["cudaErrorInvalidConfiguration"] = {"hipErrorInvalidConfiguration", CONV_ERR, API_RUNTIME}; + cuda2hipRename["cudaErrorPriorLaunchFailure"] = {"hipErrorPriorLaunchFailure", CONV_ERR, API_RUNTIME}; + cuda2hipRename["cudaErrorInvalidMemcpyDirection"] = {"hipErrorInvalidMemcpyDirection", CONV_ERR, API_RUNTIME}; + cuda2hipRename["cudaErrorInvalidDevicePointer"] = {"hipErrorInvalidDevicePointer", CONV_ERR, API_RUNTIME}; + cuda2hipRename["cudaErrorMissingConfiguration"] = {"hipErrorMissingConfiguration", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_SUCCESS"] = {"hipSuccess", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaSuccess"] = {"hipSuccess", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_SUCCESS"] = {"hipSuccess", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaSuccess"] = {"hipSuccess", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_UNKNOWN"] = {"hipErrorUnknown", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorUnknown"] = {"hipErrorUnknown", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_UNKNOWN"] = {"hipErrorUnknown", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorUnknown"] = {"hipErrorUnknown", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_NOT_INITIALIZED"] = {"hipErrorNotInitialized", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorInitializationError"] = {"hipErrorNotInitialized", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_NOT_INITIALIZED"] = {"hipErrorNotInitialized", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorInitializationError"] = {"hipErrorNotInitialized", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_DEINITIALIZED"] = {"hipErrorDeinitialized", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorCudartUnloading"] = {"hipErrorDeinitialized", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_DEINITIALIZED"] = {"hipErrorDeinitialized", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorCudartUnloading"] = {"hipErrorDeinitialized", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_OUT_OF_MEMORY"] = {"hipErrorMemoryAllocation", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorMemoryAllocation"] = {"hipErrorMemoryAllocation", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_OUT_OF_MEMORY"] = {"hipErrorMemoryAllocation", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorMemoryAllocation"] = {"hipErrorMemoryAllocation", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_INVALID_HANDLE"] = {"hipErrorInvalidResourceHandle", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorInvalidResourceHandle"] = {"hipErrorInvalidResourceHandle", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_INVALID_HANDLE"] = {"hipErrorInvalidResourceHandle", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorInvalidResourceHandle"] = {"hipErrorInvalidResourceHandle", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_INVALID_VALUE"] = {"hipErrorInvalidValue", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorInvalidValue"] = {"hipErrorInvalidValue", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_INVALID_VALUE"] = {"hipErrorInvalidValue", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorInvalidValue"] = {"hipErrorInvalidValue", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_INVALID_DEVICE"] = {"hipErrorInvalidDevice", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorInvalidDevice"] = {"hipErrorInvalidDevice", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_INVALID_DEVICE"] = {"hipErrorInvalidDevice", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorInvalidDevice"] = {"hipErrorInvalidDevice", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_NOT_INITIALIZED"] = {"hipErrorInitializationError", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorInitializationError"] = {"hipErrorInitializationError", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_NOT_INITIALIZED"] = {"hipErrorInitializationError", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorInitializationError"] = {"hipErrorInitializationError", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_NO_DEVICE"] = {"hipErrorNoDevice", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorNoDevice"] = {"hipErrorNoDevice", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_NO_DEVICE"] = {"hipErrorNoDevice", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorNoDevice"] = {"hipErrorNoDevice", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_NOT_READY"] = {"hipErrorNotReady", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorNotReady"] = {"hipErrorNotReady", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_NOT_READY"] = {"hipErrorNotReady", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorNotReady"] = {"hipErrorNotReady", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_PEER_ACCESS_NOT_ENABLED"] = {"hipErrorPeerAccessNotEnabled", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorPeerAccessNotEnabled"] = {"hipErrorPeerAccessNotEnabled", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_PEER_ACCESS_NOT_ENABLED"] = {"hipErrorPeerAccessNotEnabled", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorPeerAccessNotEnabled"] = {"hipErrorPeerAccessNotEnabled", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_PEER_ACCESS_ALREADY_ENABLED"] = {"hipErrorPeerAccessAlreadyEnabled", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorPeerAccessAlreadyEnabled"] = {"hipErrorPeerAccessAlreadyEnabled", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_PEER_ACCESS_ALREADY_ENABLED"] = {"hipErrorPeerAccessAlreadyEnabled", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorPeerAccessAlreadyEnabled"] = {"hipErrorPeerAccessAlreadyEnabled", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_PEER_ACCESS_UNSUPPORTED"] = {"hipErrorPeerAccessUnsupported", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorPeerAccessUnsupported"] = {"hipErrorPeerAccessUnsupported", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_PEER_ACCESS_UNSUPPORTED"] = {"hipErrorPeerAccessUnsupported", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorPeerAccessUnsupported"] = {"hipErrorPeerAccessUnsupported", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_INVALID_PTX"] = {"hipErrorInvalidKernelFile", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorInvalidPtx"] = {"hipErrorInvalidKernelFile", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_INVALID_PTX"] = {"hipErrorInvalidKernelFile", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorInvalidPtx"] = {"hipErrorInvalidKernelFile", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_INVALID_GRAPHICS_CONTEXT"] = {"hipErrorInvalidGraphicsContext", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorInvalidGraphicsContext"] = {"hipErrorInvalidGraphicsContext", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_INVALID_GRAPHICS_CONTEXT"] = {"hipErrorInvalidGraphicsContext", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorInvalidGraphicsContext"] = {"hipErrorInvalidGraphicsContext", CONV_ERR, API_RUNTIME}; cuda2hipRename["CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND"] = {"hipErrorSharedObjectSymbolNotFound", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorSharedObjectSymbolNotFound"] = {"hipErrorSharedObjectSymbolNotFound", CONV_ERR, API_RUNTIME}; + cuda2hipRename["cudaErrorSharedObjectSymbolNotFound"] = {"hipErrorSharedObjectSymbolNotFound", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_SHARED_OBJECT_INIT_FAILED"] = {"hipErrorSharedObjectInitFailed", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorSharedObjectInitFailed"] = {"hipErrorSharedObjectInitFailed", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_SHARED_OBJECT_INIT_FAILED"] = {"hipErrorSharedObjectInitFailed", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorSharedObjectInitFailed"] = {"hipErrorSharedObjectInitFailed", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_OPERATING_SYSTEM"] = {"hipErrorOperatingSystem", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorOperatingSystem"] = {"hipErrorOperatingSystem", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_OPERATING_SYSTEM"] = {"hipErrorOperatingSystem", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorOperatingSystem"] = {"hipErrorOperatingSystem", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_ILLEGAL_ADDRESS"] = {"hipErrorIllegalAddress", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorIllegalAddress"] = {"hipErrorIllegalAddress", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_ILLEGAL_ADDRESS"] = {"hipErrorIllegalAddress", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorIllegalAddress"] = {"hipErrorIllegalAddress", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_LAUNCH_FAILED"] = {"hipErrorLaunchFailure", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorLaunchFailure"] = {"hipErrorLaunchFailure", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_LAUNCH_FAILED"] = {"hipErrorLaunchFailure", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorLaunchFailure"] = {"hipErrorLaunchFailure", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_LAUNCH_TIMEOUT"] = {"hipErrorLaunchTimeOut", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorLaunchTimeout"] = {"hipErrorLaunchTimeOut", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_LAUNCH_TIMEOUT"] = {"hipErrorLaunchTimeOut", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorLaunchTimeout"] = {"hipErrorLaunchTimeOut", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES"] = {"hipErrorLaunchOutOfResources", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorLaunchOutOfResources"] = {"hipErrorLaunchOutOfResources", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES"] = {"hipErrorLaunchOutOfResources", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorLaunchOutOfResources"] = {"hipErrorLaunchOutOfResources", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_ECC_UNCORRECTABLE"] = {"hipErrorECCNotCorrectable", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorECCUncorrectable"] = {"hipErrorECCNotCorrectable", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_ECC_UNCORRECTABLE"] = {"hipErrorECCNotCorrectable", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorECCUncorrectable"] = {"hipErrorECCNotCorrectable", CONV_ERR, API_RUNTIME}; cuda2hipRename["CUDA_ERROR_HOST_MEMORY_ALREADY_REGISTERED"] = {"hipErrorHostMemoryAlreadyRegistered", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorHostMemoryAlreadyRegistered"] = {"hipErrorHostMemoryAlreadyRegistered", CONV_ERR, API_RUNTIME}; + cuda2hipRename["cudaErrorHostMemoryAlreadyRegistered"] = {"hipErrorHostMemoryAlreadyRegistered", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_HOST_MEMORY_NOT_REGISTERED"] = {"hipErrorHostMemoryNotRegistered", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorHostMemoryNotRegistered"] = {"hipErrorHostMemoryNotRegistered", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_HOST_MEMORY_NOT_REGISTERED"] = {"hipErrorHostMemoryNotRegistered", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorHostMemoryNotRegistered"] = {"hipErrorHostMemoryNotRegistered", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_NO_BINARY_FOR_GPU"] = {"hipErrorNoBinaryForGpu", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorNoKernelImageForDevice"] = {"hipErrorNoBinaryForGpu", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_NO_BINARY_FOR_GPU"] = {"hipErrorNoBinaryForGpu", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorNoKernelImageForDevice"] = {"hipErrorNoBinaryForGpu", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_UNSUPPORTED_LIMIT"] = {"hipErrorUnsupportedLimit", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorUnsupportedLimit"] = {"hipErrorUnsupportedLimit", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_UNSUPPORTED_LIMIT"] = {"hipErrorUnsupportedLimit", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorUnsupportedLimit"] = {"hipErrorUnsupportedLimit", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_INVALID_IMAGE"] = {"hipErrorInvalidImage", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorInvalidKernelImage"] = {"hipErrorInvalidImage", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_INVALID_IMAGE"] = {"hipErrorInvalidImage", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorInvalidKernelImage"] = {"hipErrorInvalidImage", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_PROFILER_DISABLED"] = {"hipErrorProfilerDisabled", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorProfilerDisabled"] = {"hipErrorProfilerDisabled", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_PROFILER_DISABLED"] = {"hipErrorProfilerDisabled", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorProfilerDisabled"] = {"hipErrorProfilerDisabled", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_PROFILER_NOT_INITIALIZED"] = {"hipErrorProfilerNotInitialized", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorProfilerNotInitialized"] = {"hipErrorProfilerNotInitialized", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_PROFILER_NOT_INITIALIZED"] = {"hipErrorProfilerNotInitialized", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorProfilerNotInitialized"] = {"hipErrorProfilerNotInitialized", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_PROFILER_ALREADY_STARTED"] = {"hipErrorProfilerAlreadyStarted", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorProfilerAlreadyStarted"] = {"hipErrorProfilerAlreadyStarted", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_PROFILER_ALREADY_STARTED"] = {"hipErrorProfilerAlreadyStarted", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorProfilerAlreadyStarted"] = {"hipErrorProfilerAlreadyStarted", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_PROFILER_ALREADY_STOPPED"] = {"hipErrorProfilerAlreadyStopped", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorProfilerAlreadyStopped"] = {"hipErrorProfilerAlreadyStopped", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_PROFILER_ALREADY_STOPPED"] = {"hipErrorProfilerAlreadyStopped", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorProfilerAlreadyStopped"] = {"hipErrorProfilerAlreadyStopped", CONV_ERR, API_RUNTIME}; ///////////////////////////// CUDA DRIVER API ///////////////////////////// // Types // NOTE: CUdevice might be changed to typedef int in the future. cuda2hipRename["CUdevice"] = {"hipDevice_t", CONV_TYPE, API_DRIVER}; - cuda2hipRename["CUdevice_attribute_enum"] = {"hipDeviceAttribute_t", CONV_TYPE, API_DRIVER}; cuda2hipRename["CUdevice_attribute"] = {"hipDeviceAttribute_t", CONV_TYPE, API_DRIVER}; @@ -450,14 +449,6 @@ struct cuda2hipMap { cuda2hipRename["CUcontext"] = {"hipCtx_t", CONV_TYPE, API_DRIVER}; cuda2hipRename["CUmodule"] = {"hipModule_t", CONV_TYPE, API_DRIVER}; - cuda2hipRename["CUevent"] = {"hipEvent_t", CONV_TYPE, API_DRIVER}; - cuda2hipRename["CUevent_st"] = {"hipEvent_t", CONV_TYPE, API_DRIVER}; - // Event Flags - cuda2hipRename["CU_EVENT_DEFAULT"] = {"hipEventDefault", CONV_EVENT, API_DRIVER}; - cuda2hipRename["CU_EVENT_BLOCKING_SYNC"] = {"hipEventBlockingSync", CONV_EVENT, API_DRIVER}; - cuda2hipRename["CU_EVENT_DISABLE_TIMING"] = {"hipEventDisableTiming", CONV_EVENT, API_DRIVER}; - cuda2hipRename["CU_EVENT_INTERPROCESS"] = {"hipEventInterprocess", CONV_EVENT, API_DRIVER}; - cuda2hipRename["CUstream"] = {"hipStream_t", CONV_TYPE, API_DRIVER}; // Stream Flags cuda2hipRename["CU_STREAM_DEFAULT"] = {"hipStreamDefault", CONV_STREAM, API_DRIVER}; @@ -469,15 +460,6 @@ struct cuda2hipMap { // Driver cuda2hipRename["cuDriverGetVersion"] = {"hipDriverGetVersion", CONV_DRIVER, API_DRIVER}; - // Occupancy - // unsupported yet by HIP - cuda2hipRename["cudaOccupancyMaxPotentialBlockSize"] = {"hipOccupancyMaxPotentialBlockSize", CONV_OCCUPANCY, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["cudaOccupancyMaxPotentialBlockSizeWithFlags"] = {"hipOccupancyMaxPotentialBlockSizeWithFlags", CONV_OCCUPANCY, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["cudaOccupancyMaxActiveBlocksPerMultiprocessor"] = {"hipOccupancyMaxActiveBlocksPerMultiprocessor", CONV_OCCUPANCY, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags"] = {"hipOccupancyMaxActiveBlocksPerMultiprocessorWithFlags", CONV_OCCUPANCY, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["cudaOccupancyMaxPotentialBlockSizeVariableSMem"] = {"hipOccupancyMaxPotentialBlockSizeVariableSMem", CONV_OCCUPANCY, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["cudaOccupancyMaxPotentialBlockSizeVariableSMemWithFlags"] = {"hipOccupancyMaxPotentialBlockSizeVariableSMemWithFlags", CONV_OCCUPANCY, API_DRIVER, HIP_UNSUPPORTED}; - // Context cuda2hipRename["cuCtxCreate_v2"] = {"hipCtxCreate", CONV_CONTEXT, API_DRIVER}; cuda2hipRename["cuCtxDestroy_v2"] = {"hipCtxDestroy", CONV_CONTEXT, API_DRIVER}; @@ -514,6 +496,14 @@ struct cuda2hipMap { cuda2hipRename["cuDeviceCanAccessPeer"] = {"hipDeviceCanAccessPeer", CONV_DEV, API_DRIVER}; // Events + cuda2hipRename["CUevent"] = {"hipEvent_t", CONV_TYPE, API_DRIVER}; + cuda2hipRename["CUevent_st"] = {"hipEvent_t", CONV_TYPE, API_DRIVER}; + // Event Flags + cuda2hipRename["CU_EVENT_DEFAULT"] = {"hipEventDefault", CONV_EVENT, API_DRIVER}; + cuda2hipRename["CU_EVENT_BLOCKING_SYNC"] = {"hipEventBlockingSync", CONV_EVENT, API_DRIVER}; + cuda2hipRename["CU_EVENT_DISABLE_TIMING"] = {"hipEventDisableTiming", CONV_EVENT, API_DRIVER}; + cuda2hipRename["CU_EVENT_INTERPROCESS"] = {"hipEventInterprocess", CONV_EVENT, API_DRIVER}; + cuda2hipRename["cuEventCreate"] = {"hipEventCreate", CONV_EVENT, API_DRIVER}; cuda2hipRename["cuEventDestroy_v2"] = {"hipEventDestroy", CONV_EVENT, API_DRIVER}; cuda2hipRename["cuEventElapsedTime"] = {"hipEventElapsedTime", CONV_EVENT, API_DRIVER}; @@ -720,19 +710,19 @@ struct cuda2hipMap { cuda2hipRename["cudaStreamNonBlocking"] = {"hipStreamNonBlocking", CONV_STREAM, API_RUNTIME}; // Other synchronization - cuda2hipRename["cudaDeviceSynchronize"] = {"hipDeviceSynchronize", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDeviceSynchronize"] = {"hipDeviceSynchronize", CONV_DEV, API_RUNTIME}; // translate deprecated cudaThreadSynchronize - cuda2hipRename["cudaThreadSynchronize"] = {"hipDeviceSynchronize", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDeviceReset"] = {"hipDeviceReset", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaThreadSynchronize"] = {"hipDeviceSynchronize", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDeviceReset"] = {"hipDeviceReset", CONV_DEV, API_RUNTIME}; // translate deprecated cudaThreadExit - cuda2hipRename["cudaThreadExit"] = {"hipDeviceReset", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaSetDevice"] = {"hipSetDevice", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaGetDevice"] = {"hipGetDevice", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaGetDeviceCount"] = {"hipGetDeviceCount", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaThreadExit"] = {"hipDeviceReset", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaSetDevice"] = {"hipSetDevice", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaGetDevice"] = {"hipGetDevice", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaGetDeviceCount"] = {"hipGetDeviceCount", CONV_DEV, API_RUNTIME}; // Attributes - cuda2hipRename["cudaDeviceAttr"] = {"hipDeviceAttribute_t", CONV_TYPE, API_RUNTIME}; - cuda2hipRename["cudaDeviceGetAttribute"] = {"hipDeviceGetAttribute", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDeviceAttr"] = {"hipDeviceAttribute_t", CONV_TYPE, API_RUNTIME}; + cuda2hipRename["cudaDeviceGetAttribute"] = {"hipDeviceGetAttribute", CONV_DEV, API_RUNTIME}; cuda2hipRename["cudaDevAttrMaxThreadsPerBlock"] = {"hipDeviceAttributeMaxThreadsPerBlock", CONV_DEV, API_RUNTIME}; cuda2hipRename["cudaDevAttrMaxBlockDimX"] = {"hipDeviceAttributeMaxBlockDimX", CONV_DEV, API_RUNTIME}; @@ -872,12 +862,21 @@ struct cuda2hipMap { // unsupported yet by HIP cuda2hipRename["cudaRuntimeGetVersion"] = {"hipRuntimeGetVersion", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + // Occupancy + // unsupported yet by HIP + cuda2hipRename["cudaOccupancyMaxPotentialBlockSize"] = {"hipOccupancyMaxPotentialBlockSize", CONV_OCCUPANCY, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["cudaOccupancyMaxPotentialBlockSizeWithFlags"] = {"hipOccupancyMaxPotentialBlockSizeWithFlags", CONV_OCCUPANCY, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["cudaOccupancyMaxActiveBlocksPerMultiprocessor"] = {"hipOccupancyMaxActiveBlocksPerMultiprocessor", CONV_OCCUPANCY, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags"] = {"hipOccupancyMaxActiveBlocksPerMultiprocessorWithFlags", CONV_OCCUPANCY, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["cudaOccupancyMaxPotentialBlockSizeVariableSMem"] = {"hipOccupancyMaxPotentialBlockSizeVariableSMem", CONV_OCCUPANCY, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["cudaOccupancyMaxPotentialBlockSizeVariableSMemWithFlags"] = {"hipOccupancyMaxPotentialBlockSizeVariableSMemWithFlags", CONV_OCCUPANCY, API_DRIVER, HIP_UNSUPPORTED}; + // Peer2Peer - cuda2hipRename["cudaDeviceCanAccessPeer"] = {"hipDeviceCanAccessPeer", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDeviceDisablePeerAccess"] = {"hipDeviceDisablePeerAccess", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDeviceEnablePeerAccess"] = {"hipDeviceEnablePeerAccess", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaMemcpyPeerAsync"] = {"hipMemcpyPeerAsync", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaMemcpyPeer"] = {"hipMemcpyPeer", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaDeviceCanAccessPeer"] = {"hipDeviceCanAccessPeer", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDeviceDisablePeerAccess"] = {"hipDeviceDisablePeerAccess", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDeviceEnablePeerAccess"] = {"hipDeviceEnablePeerAccess", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaMemcpyPeerAsync"] = {"hipMemcpyPeerAsync", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaMemcpyPeer"] = {"hipMemcpyPeer", CONV_MEM, API_RUNTIME}; // Shared memory cuda2hipRename["cudaDeviceSetSharedMemConfig"] = {"hipDeviceSetSharedMemConfig", CONV_DEV, API_RUNTIME}; @@ -1693,7 +1692,6 @@ StringRef unquoteStr(StringRef s) { class Cuda2Hip { public: Cuda2Hip(Replacements *R): Replace(R) {} - uint64_t countReps[CONV_LAST] = { 0 }; uint64_t countApiReps[API_LAST] = { 0 }; uint64_t countRepsUnsupported[CONV_LAST] = { 0 }; @@ -2031,8 +2029,7 @@ private: dyn_cast(e)) { calleeName = ule->getName().getAsIdentifierInfo()->getName(); owner->addMatcher(functionTemplateDecl(hasName(calleeName)) - .bind("unresolvedTemplateName"), - this); + .bind("unresolvedTemplateName"), this); } } XStr.clear(); From b00361b981d8225c8922bef3eee8b6112d017701 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Fri, 13 Jan 2017 10:56:07 -0600 Subject: [PATCH 066/281] added half2 cmp and conv, data movement device functions 1. Added half2 comparision functions 2. Added conversion and data movement half apis Change-Id: Ia33c0e957d9deb1f2b7a8fde8e22168f4d41b88b [ROCm/hip commit: 3f52f76194cfd4c8e55a095711e71e946c908a94] --- .../hip/include/hip/hcc_detail/hip_fp16.h | 391 +++++++++++++++++- .../hip/tests/src/deviceLib/hipTestHalf.cpp | 10 + 2 files changed, 397 insertions(+), 4 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/hip_fp16.h b/projects/hip/include/hip/hcc_detail/hip_fp16.h index e4408556f1..638cecefb4 100644 --- a/projects/hip/include/hip/hcc_detail/hip_fp16.h +++ b/projects/hip/include/hip/hcc_detail/hip_fp16.h @@ -36,7 +36,7 @@ typedef struct __attribute__((aligned(4))){ }; } __half2; -struct holder{ +struct hipHalfHolder{ union { __half h; unsigned short s; @@ -45,7 +45,7 @@ struct holder{ #define HINF 65504 -static struct holder hInf = {HINF}; +static struct hipHalfHolder __hInfValue = {HINF}; extern "C" __half __hip_hc_ir_hadd_half(__half, __half); extern "C" __half __hip_hc_ir_hfma_half(__half, __half, __half); @@ -180,11 +180,11 @@ __device__ static inline bool __hgt(__half a, __half b) { } __device__ static inline bool __hisinf(__half a) { - return a == hInf.s ? true : false; + return a == __hInfValue.h ? true : false; } __device__ static inline bool __hisnan(__half a) { - return a > hInf.s ? true : false; + return a > __hInfValue.h ? true : false; } __device__ static inline bool __hle(__half a, __half b) { @@ -227,6 +227,389 @@ __device__ static inline bool __hbne2(__half2 a, __half2 b) { return (a.p[0] != b.p[0] ? true : false) && (a.p[1] != b.p[1] ? true : false); } +__device__ static inline __half2 __heq2(__half2 a, __half2 b) { + __half2 c; + c.p[0] = (a.p[0] == b.p[0]) ? (__half)1 : (__half)0; + c.p[1] = (a.p[1] == b.p[1]) ? (__half)1 : (__half)0; + return c; +} + +__device__ static inline __half2 __hge2(__half2 a, __half2 b) { + __half2 c; + c.p[0] = (a.p[0] >= b.p[0]) ? (__half)1 : (__half)0; + c.p[1] = (a.p[1] >= b.p[1]) ? (__half)1 : (__half)0; + return c; +} + +__device__ static inline __half2 __hgt2(__half2 a, __half2 b) { + __half2 c; + c.p[0] = (a.p[0] > b.p[0]) ? (__half)1 : (__half)0; + c.p[1] = (a.p[1] > b.p[1]) ? (__half)1 : (__half)0; + return c; +} + +__device__ static inline __half2 __hisnan2(__half2 a) { + __half2 c; + c.p[0] = (a.p[0] > __hInfValue.h) ? (__half)1 : (__half)0; + c.p[1] = (a.p[1] > __hInfValue.h) ? (__half)1 : (__half)0; + return c; +} + +__device__ static inline __half2 __hle2(__half2 a, __half2 b) { + __half2 c; + c.p[0] = (a.p[0] <= b.p[0]) ? (__half)1 : (__half)0; + c.p[1] = (a.p[1] <= b.p[1]) ? (__half)1 : (__half)0; + return c; +} + +__device__ static inline __half2 __hlt2(__half2 a, __half2 b) { + __half2 c; + c.p[0] = (a.p[0] < b.p[0]) ? (__half)1 : (__half)0; + c.p[1] = (a.p[1] < b.p[1]) ? (__half)1 : (__half)0; + return c; +} + +__device__ static inline __half2 __hne2(__half2 a, __half2 b) { + __half2 c; + c.p[0] = (a.p[0] != b.p[0]) ? (__half)1 : (__half)0; + c.p[1] = (a.p[1] != b.p[1]) ? (__half)1 : (__half)0; + return c; +} + +/* +Conversion instructions +*/ + +__device__ static inline __half2 __float22half2_rn(const float2 a) { + __half2 b; + b.p[0] = (__half)a.x; + b.p[1] = (__half)a.y; + return b; +} + +__device__ static inline __half __float2half(const float a) { + return (__half)a; +} + +__device__ static inline __half2 __float2half2_rn(const float a) { + __half2 b; + b.p[0] = (__half)a; + b.p[1] = (__half)a; + return b; +} + +__device__ static inline __half __float2half_rd(const float a) { + return (__half)a; +} + +__device__ static inline __half __float2half_ru(const float a) { + return (__half)a; +} + +__device__ static inline __half __float2half_rz(const float a) { + return (__half)a; +} + +__device__ static inline __half2 __floats2half2_rn(const float a, const float b) { + __half2 c; + c.p[0] = (__half)a; + c.p[1] = (__half)b; + return c; +} + +__device__ static inline float2 __half22float2(const __half2 a) { + float2 b; + b.x = (float)a.p[0]; + b.y = (float)a.p[1]; + return b; +} + +__device__ static inline float __half2float(const __half a) { + return (float)a; +} + +__device__ static inline __half2 half2half2(const __half a) { + __half2 b; + b.p[0] = a; + b.p[1] = a; + return b; +} + +__device__ static inline int __half2int_rd(__half h) { + return (int)h; +} + +__device__ static inline int __half2int_rn(__half h) { + return (int)h; +} + +__device__ static inline int __half2int_ru(__half h) { + return (int)h; +} + +__device__ static inline int __half2int_rz(__half h) { + return (int)h; +} + +__device__ static inline long long int __half2ll_rd(__half h) { + return (long long int)h; +} + +__device__ static inline long long int __half2ll_rn(__half h) { + return (long long int)h; +} + +__device__ static inline long long int __half2ll_ru(__half h) { + return (long long int)h; +} + +__device__ static inline long long int __half2ll_rz(__half h) { + return (long long int)h; +} + +__device__ static inline short __half2short_rd(__half h) { + return (short)h; +} + +__device__ static inline short __half2short_rn(__half h) { + return (short)h; +} + +__device__ static inline short __half2short_ru(__half h) { + return (short)h; +} + +__device__ static inline short __half2short_rz(__half h) { + return (short)h; +} + +__device__ static inline unsigned int __half2uint_rd(__half h) { + return (unsigned int)h; +} + +__device__ static inline unsigned int __half2uint_rn(__half h) { + return (unsigned int)h; +} + +__device__ static inline unsigned int __half2uint_ru(__half h) { + return (unsigned int)h; +} + +__device__ static inline unsigned int __half2uint_rz(__half h) { + return (unsigned int)h; +} + +__device__ static inline unsigned long long int __half2ull_rd(__half h) { + return (unsigned long long)h; +} + +__device__ static inline unsigned long long int __half2ull_rn(__half h) { + return (unsigned long long)h; +} + +__device__ static inline unsigned long long int __half2ull_ru(__half h) { + return (unsigned long long)h; +} + +__device__ static inline unsigned long long int __half2ull_rz(__half h) { + return (unsigned long long)h; +} + +__device__ static inline unsigned short int __half2ushort_rd(__half h) { + return (unsigned short int)h; +} + +__device__ static inline unsigned short int __half2ushort_rn(__half h) { + return (unsigned short int)h; +} + +__device__ static inline unsigned short int __half2ushort_ru(__half h) { + return (unsigned short int)h; +} + +__device__ static inline unsigned short int __half2ushort_rz(__half h) { + return (unsigned short int)h; +} + +__device__ static inline short int __half_as_short(const __half h) { + hipHalfHolder hH; + hH.h = h; + return (short)hH.s; +} + +__device__ static inline unsigned short int __half_as_ushort(const __half h) { + hipHalfHolder hH; + hH.h = h; + return hH.s; +} + +__device__ static inline __half2 __halves2half2(const __half a, const __half b) { + __half2 c; + c.p[0] = a; + c.p[1] = b; + return c; +} + +__device__ static inline float __high2float(const __half2 a) { + return (float)a.p[1]; +} + +__device__ static inline __half __high2half(const __half2 a) { + return a.p[1]; +} + +__device__ static inline __half2 __high2half2(const __half2 a) { + __half2 b; + b.p[0] = a.p[1]; + b.p[1] = a.p[1]; + return b; +} + +__device__ static inline __half2 __highs2half2(const __half2 a, const __half2 b) { + __half2 c; + c.p[0] = a.p[1]; + c.p[1] = b.p[1]; + return c; +} + +__device__ static inline __half __int2half_rd(int i) { + return (__half)i; +} + +__device__ static inline __half __int2half_rn(int i) { + return (__half)i; +} + +__device__ static inline __half __int2half_ru(int i) { + return (__half)i; +} + +__device__ static inline __half __int2half_rz(int i) { + return (__half)i; +} + +__device__ static inline __half __ll2half_rd(long long int i){ + return (__half)i; +} + +__device__ static inline __half __ll2half_rn(long long int i){ + return (__half)i; +} + +__device__ static inline __half __ll2half_ru(long long int i){ + return (__half)i; +} + +__device__ static inline __half __ll2half_rz(long long int i){ + return (__half)i; +} + +__device__ static inline float __low2float(const __half2 a) { + return (float)a.p[0]; +} + +__device__ static inline __half __low2half(const __half2 a) { + return a.p[0]; +} + +__device__ static inline __half2 __low2half2(const __half2 a, const __half2 b) { + __half2 c; + c.p[0] = a.p[0]; + c.p[1] = b.p[0]; + return c; +} + +__device__ static inline __half2 __low2half2(const __half2 a) { + __half2 b; + b.p[0] = a.p[0]; + b.p[1] = a.p[0]; + return b; +} + +__device__ static inline __half2 __lowhigh2highlow(const __half2 a) { + __half2 b; + b.p[0] = a.p[1]; + b.p[1] = a.p[0]; + return b; +} + +__device__ static inline __half2 __lows2half2(const __half2 a, const __half2 b) { + __half2 c; + c.p[0] = a.p[0]; + c.p[1] = b.p[0]; + return c; +} + +__device__ static inline __half __short2half_rd(short int i) { + return (__half)i; +} + +__device__ static inline __half __short2half_rn(short int i) { + return (__half)i; +} + +__device__ static inline __half __short2half_ru(short int i) { + return (__half)i; +} + +__device__ static inline __half __short2half_rz(short int i) { + return (__half)i; +} + +__device__ static inline __half __uint2half_rd(unsigned int i) { + return (__half)i; +} + +__device__ static inline __half __uint2half_rn(unsigned int i) { + return (__half)i; +} + +__device__ static inline __half __uint2half_ru(unsigned int i) { + return (__half)i; +} + +__device__ static inline __half __uint2half_rz(unsigned int i) { + return (__half)i; +} + +__device__ static inline __half __ull2half_rd(unsigned long long int i) { + return (__half)i; +} + +__device__ static inline __half __ull2half_rn(unsigned long long int i) { + return (__half)i; +} + +__device__ static inline __half __ull2half_ru(unsigned long long int i) { + return (__half)i; +} + +__device__ static inline __half __ull2half_rz(unsigned long long int i) { + return (__half)i; +} + +__device__ static inline __half __ushort2half_rd(unsigned short int i) { + return (__half)i; +} + +__device__ static inline __half __ushort2half_rn(unsigned short int i) { + return (__half)i; +} + +__device__ static inline __half __ushort2half_ru(unsigned short int i) { + return (__half)i; +} + +__device__ static inline __half __ushort2half_rz(unsigned short int i) { + return (__half)i; +} + +__device__ static inline __half __ushort_as_half(const unsigned short int i) { + hipHalfHolder hH; + hH.s = i; + return hH.h; +} + #endif #if __clang_major__ == 3 diff --git a/projects/hip/tests/src/deviceLib/hipTestHalf.cpp b/projects/hip/tests/src/deviceLib/hipTestHalf.cpp index 46927c3902..05900259f1 100644 --- a/projects/hip/tests/src/deviceLib/hipTestHalf.cpp +++ b/projects/hip/tests/src/deviceLib/hipTestHalf.cpp @@ -86,6 +86,16 @@ __global__ void CheckCmpHalf(hipLaunchParm lp, __half* In1, __half* In2, bool* O Out[7] = __hne(In1[7], In2[7]); } +__global__ void CheckCmpHalf2(hipLaunchParm lp, __half2* In1, __half2* In2, __half2* Out) { + Out[0] = __heq2(In1[0], In2[0]); + Out[1] = __hge2(In1[1], In2[1]); + Out[2] = __hgt2(In1[2], In2[2]); + Out[4] = __hisnan2(In1[4]); + Out[5] = __hle2(In1[5], In2[5]); + Out[6] = __hlt2(In1[6], In2[6]); + Out[7] = __hne2(In1[7], In2[7]); +} + int main(){ } From 0d5b2539d35fbbe38b0e7999a0499eb3c51424a5 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Fri, 13 Jan 2017 12:05:29 -0600 Subject: [PATCH 067/281] added math functions for half 1. Added math functions for half precision 2. HRCP is not available due to device code linking errors, will be enabled once it is fixed 3. Added math functions to half test file Change-Id: Ie317ce70ef518a4fc3f27142143d01e0327f5df3 [ROCm/hip commit: 8c978c210ced06926a4fa38ec08401157e0806d7] --- .../hip/include/hip/hcc_detail/hip_fp16.h | 72 +++++++++++++++++++ .../hip/tests/src/deviceLib/hipTestHalf.cpp | 15 ++++ 2 files changed, 87 insertions(+) diff --git a/projects/hip/include/hip/hcc_detail/hip_fp16.h b/projects/hip/include/hip/hcc_detail/hip_fp16.h index 638cecefb4..002fbdd3ce 100644 --- a/projects/hip/include/hip/hcc_detail/hip_fp16.h +++ b/projects/hip/include/hip/hcc_detail/hip_fp16.h @@ -57,6 +57,18 @@ extern "C" int __hip_hc_ir_hfma2_int(int, int, int); extern "C" int __hip_hc_ir_hmul2_int(int, int); extern "C" int __hip_hc_ir_hsub2_int(int, int); +extern "C" __half __hip_hc_ir_hceil_half(__half) __asm("llvm.ceil.f16"); +extern "C" __half __hip_hc_ir_hcos_half(__half) __asm("llvm.cos.f16"); +extern "C" __half __hip_hc_ir_hexp2_half(__half) __asm("llvm.exp2.f16"); +extern "C" __half __hip_hc_ir_hfloor_half(__half) __asm("llvm.floor.f16"); +extern "C" __half __hip_hc_ir_hlog2_half(__half) __asm("llvm.log2.f16"); +extern "C" __half __hip_hc_ir_hrcp_half(__half) __asm("llvm.amdgcn.rcp.f16"); +extern "C" __half __hip_hc_ir_hrint_half(__half) __asm("llvm.rint.f16"); +extern "C" __half __hip_hc_ir_hrsqrt_half(__half) __asm("llvm.sqrt.f16"); +extern "C" __half __hip_hc_ir_hsin_half(__half) __asm("llvm.sin.f16"); +extern "C" __half __hip_hc_ir_hsqrt_half(__half) __asm("llvm.sqrt.f16"); +extern "C" __half __hip_hc_ir_htrunc_half(__half) __asm("llvm.trunc.f16"); + __device__ static inline __half __hadd(const __half a, const __half b) { return __hip_hc_ir_hadd_half(a, b); } @@ -610,6 +622,66 @@ __device__ static inline __half __ushort_as_half(const unsigned short int i) { return hH.h; } +__device__ static inline __half hceil(const __half h) { + return __hip_hc_ir_hceil_half(h); +} + +__device__ static inline __half hcos(const __half h) { + return __hip_hc_ir_hcos_half(h); +} + +__device__ static inline __half hexp(const __half h) { + return __hip_hc_ir_hexp2_half(__hip_hc_ir_hmul_half(h, 1.442694)); +} + +__device__ static inline __half hexp10(const __half h) { + return __hip_hc_ir_hexp2_half(__hip_hc_ir_hmul_half(h, 3.3219281)); +} + +__device__ static inline __half hexp2(const __half h) { + return __hip_hc_ir_hexp2_half(h); +} + +__device__ static inline __half hfloor(const __half h) { + return __hip_hc_ir_hfloor_half(h); +} + +__device__ static inline __half hlog(const __half h) { + return __hip_hc_ir_hmul_half(__hip_hc_ir_hlog2_half(h), 0.693147); +} + +__device__ static inline __half hlog10(const __half h) { + return __hip_hc_ir_hmul_half(__hip_hc_ir_hlog2_half(h), 0.301029); +} + +__device__ static inline __half hlog2(const __half h) { + return __hip_hc_ir_hlog2_half(h); +} +/* +__device__ static inline __half hrcp(const __half h) { + return __hip_hc_ir_hrcp_half(h); +} +*/ +__device__ static inline __half hrint(const __half h) { + return __hip_hc_ir_hrint_half(h); +} + +__device__ static inline __half hrsqrt(const __half h) { + return __hip_hc_ir_hrsqrt_half(h); +} + +__device__ static inline __half hsin(const __half h) { + return __hip_hc_ir_hsin_half(h); +} + +__device__ static inline __half hsqrt(const __half a) { + return __hip_hc_ir_hsqrt_half(a); +} + +__device__ static inline __half htrunc(const __half a) { + return __hip_hc_ir_htrunc_half(a); +} + #endif #if __clang_major__ == 3 diff --git a/projects/hip/tests/src/deviceLib/hipTestHalf.cpp b/projects/hip/tests/src/deviceLib/hipTestHalf.cpp index 05900259f1..55fb48cb91 100644 --- a/projects/hip/tests/src/deviceLib/hipTestHalf.cpp +++ b/projects/hip/tests/src/deviceLib/hipTestHalf.cpp @@ -60,6 +60,21 @@ __global__ void CheckHalf(hipLaunchParm lp, __half* In1, __half* In2, __half* In Out[7] = __hsub(In1[7], In2[7]); Out[8] = __hsub_sat(In1[8], In2[8]); Out[9] = hdiv(In1[9], In2[9]); + Out[10] = hceil(In1[10]); + Out[11] = hcos(In1[11]); + Out[12] = hexp(In1[12]); + Out[13] = hexp10(In1[13]); + Out[14] = hexp2(In1[14]); + Out[15] = hfloor(In1[15]); + Out[16] = hlog(In1[16]); + Out[17] = hlog10(In1[17]); + Out[18] = hlog2(In1[18]); +// Out[19] = hrcp(In1[19]); + Out[20] = hrint(In1[20]); + Out[21] = hrsqrt(In1[21]); + Out[22] = hsin(In1[22]); + Out[23] = hsqrt(In1[23]); + Out[24] = htrunc(In1[24]); } __global__ void CheckHalf2(hipLaunchParm lp, __half2* In1, __half2* In2, __half2* In3, __half2* Out){ From 1f5fe6714b4ba7d292f357573b8ccbb3debe937f Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Fri, 13 Jan 2017 12:27:11 -0600 Subject: [PATCH 068/281] added half2 math operations 1. They use SDWA + LLVM IR 2. Added these functions to test 3. Need to do exp, exp10, log, log10, rint Change-Id: I06176acc6cb8bb054495310531777406a41b54e4 [ROCm/hip commit: 0e576295b411a4e0ce0fd29edf5222d41f22a42d] --- .../hip/include/hip/hcc_detail/hip_fp16.h | 76 +++++++++++++++++++ projects/hip/src/hip_ir.ll | 60 +++++++++++++++ .../hip/tests/src/deviceLib/hipTestHalf.cpp | 16 ++++ 3 files changed, 152 insertions(+) diff --git a/projects/hip/include/hip/hcc_detail/hip_fp16.h b/projects/hip/include/hip/hcc_detail/hip_fp16.h index 002fbdd3ce..c54aef319b 100644 --- a/projects/hip/include/hip/hcc_detail/hip_fp16.h +++ b/projects/hip/include/hip/hcc_detail/hip_fp16.h @@ -69,6 +69,17 @@ extern "C" __half __hip_hc_ir_hsin_half(__half) __asm("llvm.sin.f16"); extern "C" __half __hip_hc_ir_hsqrt_half(__half) __asm("llvm.sqrt.f16"); extern "C" __half __hip_hc_ir_htrunc_half(__half) __asm("llvm.trunc.f16"); +extern "C" int __hip_hc_ir_h2ceil_int(int); +extern "C" int __hip_hc_ir_h2cos_int(int); +extern "C" int __hip_hc_ir_h2exp2_int(int); +extern "C" int __hip_hc_ir_h2floor_int(int); +extern "C" int __hip_hc_ir_h2log2_int(int); +extern "C" int __hip_hc_ir_h2rcp_int(int); +extern "C" int __hip_hc_ir_h2rsqrt_int(int); +extern "C" int __hip_hc_ir_h2sin_int(int); +extern "C" int __hip_hc_ir_h2sqrt_int(int); +extern "C" int __hip_hc_ir_h2trunc_int(int); + __device__ static inline __half __hadd(const __half a, const __half b) { return __hip_hc_ir_hadd_half(a, b); } @@ -682,6 +693,71 @@ __device__ static inline __half htrunc(const __half a) { return __hip_hc_ir_htrunc_half(a); } +/* +Half2 Math Operations +*/ + +__device__ static inline __half2 h2ceil(const __half2 h) { + __half2 a; + a.q = __hip_hc_ir_h2ceil_int(h.q); + return a; +} + +__device__ static inline __half2 h2cos(const __half2 h) { + __half2 a; + a.q = __hip_hc_ir_h2cos_int(h.q); + return a; +} + +__device__ static inline __half2 h2exp2(const __half2 h) { + __half2 a; + a.q = __hip_hc_ir_h2exp2_int(h.q); + return a; +} + +__device__ static inline __half2 h2floor(const __half2 h) { + __half2 a; + a.q = __hip_hc_ir_h2floor_int(h.q); + return a; +} + +__device__ static inline __half2 h2log2(const __half2 h) { + __half2 a; + a.q = __hip_hc_ir_h2log2_int(h.q); + return a; +} + +__device__ static inline __half2 h2rcp(const __half2 h) { + __half2 a; + a.q = __hip_hc_ir_h2rcp_int(h.q); + return a; +} + +__device__ static inline __half2 h2rsqrt(const __half2 h) { + __half2 a; + a.q = __hip_hc_ir_h2rsqrt_int(h.q); + return a; +} + +__device__ static inline __half2 h2sin(const __half2 h) { + __half2 a; + a.q = __hip_hc_ir_h2sin_int(h.q); + return a; +} + +__device__ static inline __half2 h2sqrt(const __half2 h) { + __half2 a; + a.q = __hip_hc_ir_h2sqrt_int(h.q); + return a; +} + +__device__ static inline __half2 h2trunc(const __half2 h) { + __half2 a; + a.q = __hip_hc_ir_h2trunc_int(h.q); + return a; +} + + #endif #if __clang_major__ == 3 diff --git a/projects/hip/src/hip_ir.ll b/projects/hip/src/hip_ir.ll index 52460a38bb..739717c740 100644 --- a/projects/hip/src/hip_ir.ll +++ b/projects/hip/src/hip_ir.ll @@ -86,4 +86,64 @@ define i32 @__hip_hc_ir_hsub2_int(i32 %a, i32 %b) #1 { ret i32 %1 } +define i32 @__hip_hc_ir_h2ceil_int(i32 %a) #1 { + %1 = tail call i32 asm sideeffect "v_ceil_f16 $0, $1","=v,v"(i32 %a) + tail call void asm sideeffect "v_ceil_f16_sdwa $0, $1 dst_sel:WORD_1 dst_unused:UNUSED_PRESERVE src0_sel:WORD_1","v,v"(i32 %1, i32 %a) + ret i32 %1 +} + +define i32 @__hip_hc_ir_h2cos_int(i32 %a) #1 { + %1 = tail call i32 asm sideeffect "v_cos_f16 $0, $1","=v,v"(i32 %a) + tail call void asm sideeffect "v_cos_f16_sdwa $0, $1 dst_sel:WORD_1 dst_unused:UNUSED_PRESERVE src0_sel:WORD_1","v,v"(i32 %1, i32 %a) + ret i32 %1 +} + +define i32 @__hip_hc_ir_h2exp2_int(i32 %a) #1 { + %1 = tail call i32 asm sideeffect "v_exp_f16 $0, $1","=v,v"(i32 %a) + tail call void asm sideeffect "v_exp_f16_sdwa $0, $1 dst_sel:WORD_1 dst_unused:UNUSED_PRESERVE src0_sel:WORD_1","v,v"(i32 %1, i32 %a) + ret i32 %1 +} + +define i32 @__hip_hc_ir_h2floor_int(i32 %a) #1 { + %1 = tail call i32 asm sideeffect "v_floor_f16 $0, $1","=v,v"(i32 %a) + tail call void asm sideeffect "v_floor_f16_sdwa $0, $1 dst_sel:WORD_1 dst_unused:UNUSED_PRESERVE src0_sel:WORD_1","v,v"(i32 %1, i32 %a) + ret i32 %1 +} + +define i32 @__hip_hc_ir_h2log2_int(i32 %a) #1 { + %1 = tail call i32 asm sideeffect "v_log_f16 $0, $1","=v,v"(i32 %a) + tail call void asm sideeffect "v_log_f16_sdwa $0, $1 dst_sel:WORD_1 dst_unused:UNUSED_PRESERVE src0_sel:WORD_1","v,v"(i32 %1, i32 %a) + ret i32 %1 +} + +define i32 @__hip_hc_ir_h2rcp_int(i32 %a) #1 { + %1 = tail call i32 asm sideeffect "v_rcp_f16 $0, $1","=v,v"(i32 %a) + tail call void asm sideeffect "v_rcp_f16_sdwa $0, $1 dst_sel:WORD_1 dst_unused:UNUSED_PRESERVE src0_sel:WORD_1","v,v"(i32 %1, i32 %a) + ret i32 %1 +} + +define i32 @__hip_hc_ir_h2rsqrt_int(i32 %a) #1 { + %1 = tail call i32 asm sideeffect "v_rsq_f16 $0, $1","=v,v"(i32 %a) + tail call void asm sideeffect "v_rsq_f16_sdwa $0, $1 dst_sel:WORD_1 dst_unused:UNUSED_PRESERVE src0_sel:WORD_1","v,v"(i32 %1, i32 %a) + ret i32 %1 +} + +define i32 @__hip_hc_ir_h2sin_int(i32 %a) #1 { + %1 = tail call i32 asm sideeffect "v_sin_f16 $0, $1","=v,v"(i32 %a) + tail call void asm sideeffect "v_sin_f16_sdwa $0, $1 dst_sel:WORD_1 dst_unused:UNUSED_PRESERVE src0_sel:WORD_1","v,v"(i32 %1, i32 %a) + ret i32 %1 +} + +define i32 @__hip_hc_ir_h2sqrt_int(i32 %a) #1 { + %1 = tail call i32 asm sideeffect "v_sqrt_f16 $0, $1","=v,v"(i32 %a) + tail call void asm sideeffect "v_sqrt_f16_sdwa $0, $1 dst_sel:WORD_1 dst_unused:UNUSED_PRESERVE src0_sel:WORD_1","v,v"(i32 %1, i32 %a) + ret i32 %1 +} + +define i32 @__hip_hc_ir_h2trunc_int(i32 %a) #1 { + %1 = tail call i32 asm sideeffect "v_trunc_f16 $0, $1","=v,v"(i32 %a) + tail call void asm sideeffect "v_trunc_f16_sdwa $0, $1 dst_sel:WORD_1 dst_unused:UNUSED_PRESERVE src0_sel:WORD_1","v,v"(i32 %1, i32 %a) + ret i32 %1 +} + attributes #1 = { alwaysinline nounwind } diff --git a/projects/hip/tests/src/deviceLib/hipTestHalf.cpp b/projects/hip/tests/src/deviceLib/hipTestHalf.cpp index 55fb48cb91..c194a42ca2 100644 --- a/projects/hip/tests/src/deviceLib/hipTestHalf.cpp +++ b/projects/hip/tests/src/deviceLib/hipTestHalf.cpp @@ -88,6 +88,21 @@ __global__ void CheckHalf2(hipLaunchParm lp, __half2* In1, __half2* In2, __half2 Out[7] = __hsub2(In1[7], In2[7]); Out[8] = __hsub2_sat(In1[8], In2[8]); Out[9] = h2div(In1[9], In2[9]); + Out[10] = h2ceil(In1[10]); + Out[11] = h2cos(In1[11]); +// Out[12] = h2exp(In1[12]); +// Out[13] = h2exp10(In1[13]); + Out[14] = h2exp2(In1[14]); + Out[15] = h2floor(In1[15]); +// Out[16] = h2log(In1[16]); +// Out[17] = h2log10(In1[17]); + Out[18] = h2log2(In1[18]); + Out[19] = h2rcp(In1[19]); +// Out[20] = h2rint(In1[20]); + Out[21] = h2rsqrt(In1[21]); + Out[22] = h2sin(In1[22]); + Out[23] = h2sqrt(In1[23]); + Out[24] = h2trunc(In1[24]); } __global__ void CheckCmpHalf(hipLaunchParm lp, __half* In1, __half* In2, bool* Out) { @@ -109,6 +124,7 @@ __global__ void CheckCmpHalf2(hipLaunchParm lp, __half2* In1, __half2* In2, __ha Out[5] = __hle2(In1[5], In2[5]); Out[6] = __hlt2(In1[6], In2[6]); Out[7] = __hne2(In1[7], In2[7]); + } int main(){ From fa376d6d7164d3c763f250bd09a8ab0ee1aaa295 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Fri, 13 Jan 2017 13:26:10 -0600 Subject: [PATCH 069/281] added half2 log, log10, exp, exp10 math functions 1. Enabled tests for log, log10, exp, exp10 half2 2. h2rint is still disabled. Change-Id: I01f6002f6992259919893c524c526db5ee09473a [ROCm/hip commit: bf45105c7c2b44e38c57f2185254fd18c23f3e01] --- .../hip/include/hip/hcc_detail/hip_fp16.h | 31 +++++++++++++++++++ .../hip/tests/src/deviceLib/hipTestHalf.cpp | 8 ++--- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/hip_fp16.h b/projects/hip/include/hip/hcc_detail/hip_fp16.h index c54aef319b..eb63c7cd60 100644 --- a/projects/hip/include/hip/hcc_detail/hip_fp16.h +++ b/projects/hip/include/hip/hcc_detail/hip_fp16.h @@ -709,6 +709,22 @@ __device__ static inline __half2 h2cos(const __half2 h) { return a; } +__device__ static inline __half2 h2exp(const __half2 h) { + __half2 factor; + factor.p[0] = 1.442694; + factor.p[1] = 1.442694; + factor.q = __hip_hc_ir_h2exp2_int(__hip_hc_ir_hmul2_int(h.q, factor.q)); + return factor; +} + +__device__ static inline __half2 h2exp10(const __half2 h) { + __half2 factor; + factor.p[0] = 3.3219281; + factor.p[1] = 3.3219281; + factor.q = __hip_hc_ir_h2exp2_int(__hip_hc_ir_hmul2_int(h.q, factor.q)); + return factor; +} + __device__ static inline __half2 h2exp2(const __half2 h) { __half2 a; a.q = __hip_hc_ir_h2exp2_int(h.q); @@ -721,6 +737,21 @@ __device__ static inline __half2 h2floor(const __half2 h) { return a; } +__device__ static inline __half2 h2log(const __half2 h) { + __half2 factor; + factor.p[0] = 0.693147; + factor.p[1] = 0.693147; + factor. q = __hip_hc_ir_hmul2_int(__hip_hc_ir_h2log2_int(h.q), factor.q); + return factor; +} + +__device__ static inline __half2 h2log10(const __half2 h) { + __half2 factor; + factor.p[0] = 0.301029; + factor.p[1] = 0.301029; + factor.q = __hip_hc_ir_hmul2_int(__hip_hc_ir_h2log2_int(h.q), factor.q); + return factor; +} __device__ static inline __half2 h2log2(const __half2 h) { __half2 a; a.q = __hip_hc_ir_h2log2_int(h.q); diff --git a/projects/hip/tests/src/deviceLib/hipTestHalf.cpp b/projects/hip/tests/src/deviceLib/hipTestHalf.cpp index c194a42ca2..975a494b2a 100644 --- a/projects/hip/tests/src/deviceLib/hipTestHalf.cpp +++ b/projects/hip/tests/src/deviceLib/hipTestHalf.cpp @@ -90,12 +90,12 @@ __global__ void CheckHalf2(hipLaunchParm lp, __half2* In1, __half2* In2, __half2 Out[9] = h2div(In1[9], In2[9]); Out[10] = h2ceil(In1[10]); Out[11] = h2cos(In1[11]); -// Out[12] = h2exp(In1[12]); -// Out[13] = h2exp10(In1[13]); + Out[12] = h2exp(In1[12]); + Out[13] = h2exp10(In1[13]); Out[14] = h2exp2(In1[14]); Out[15] = h2floor(In1[15]); -// Out[16] = h2log(In1[16]); -// Out[17] = h2log10(In1[17]); + Out[16] = h2log(In1[16]); + Out[17] = h2log10(In1[17]); Out[18] = h2log2(In1[18]); Out[19] = h2rcp(In1[19]); // Out[20] = h2rint(In1[20]); From 8e411f0beb632cb644c6584ce2084b99da44d021 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Mon, 16 Jan 2017 12:10:05 -0600 Subject: [PATCH 070/281] Added type conversion intrinsics 1. Added all type conversion intrinsics 2. NO TESTS have been added. (Will add in next commit) 3. Sanatized code in hip_runtime.h 4. Added passed() to hipTestHalf to make it pass on HIT Change-Id: I0987963c802fc7ff4d7e07d7b88d86da35da53c9 [ROCm/hip commit: 6f2cfddc670835a3965afe252352c488680b846d] --- .../include/hip/hcc_detail/device_functions.h | 112 +++++- .../hip/include/hip/hcc_detail/hip_fp16.h | 4 + .../hip/include/hip/hcc_detail/hip_runtime.h | 30 +- projects/hip/src/device_functions.cpp | 362 ++++++++++++++++-- projects/hip/src/device_util.cpp | 10 - .../hip/tests/src/deviceLib/hipTestHalf.cpp | 2 +- 6 files changed, 462 insertions(+), 58 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/device_functions.h b/projects/hip/include/hip/hcc_detail/device_functions.h index e2b061c640..e6771650a2 100644 --- a/projects/hip/include/hip/hcc_detail/device_functions.h +++ b/projects/hip/include/hip/hcc_detail/device_functions.h @@ -23,15 +23,119 @@ THE SOFTWARE. #include #include -__device__ float __int_as_float (int x); +/* +Rounding modes are not yet supported in HIP +*/ -__device__ double __hiloint2double (int hi, int lo); +__device__ float __double2float_rd(double x); +__device__ float __double2float_rn(double x); +__device__ float __double2float_ru(double x); +__device__ float __double2float_rz(double x); + +__device__ int __double2hiint(double x); +__device__ int __double2loint(double x); + +__device__ int __double2int_rd(double x); +__device__ int __double2int_rn(double x); +__device__ int __double2int_ru(double x); +__device__ int __double2int_rz(double x); + +__device__ long long int __double2ll_rd(double x); +__device__ long long int __double2ll_rn(double x); +__device__ long long int __double2ll_ru(double x); +__device__ long long int __double2ll_rz(double x); + +__device__ unsigned int __double2uint_rd(double x); +__device__ unsigned int __double2uint_rn(double x); +__device__ unsigned int __double2uint_ru(double x); +__device__ unsigned int __double2uint_rz(double x); + +__device__ unsigned long long int __double2ull_rd(double x); +__device__ unsigned long long int __double2ull_rn(double x); +__device__ unsigned long long int __double2ull_ru(double x); +__device__ unsigned long long int __double2ull_rz(double x); + +__device__ long long int __double_as_longlong(double x); +/* +__device__ unsigned short __float2half_rn(float x); +__device__ float __half2float(unsigned short); + +The above device function are not a valid . +Use +__device__ __half __float2half_rn(float x); +__device__ float __half2float(__half); +from hip_fp16.h + +CUDA implements half as unsigned short whereas, HIP doesn't. + +*/ + +__device__ int float2int_rd(float x); +__device__ int float2int_rn(float x); +__device__ int float2int_ru(float x); +__device__ int float2int_rz(float x); + +__device__ long long int __float2ll_rd(float x); +__device__ long long int __float2ll_rn(float x); +__device__ long long int __float2ll_ru(float x); +__device__ long long int __float2ll_rz(float x); + +__device__ unsigned int __float2uint_rd(float x); +__device__ unsigned int __float2uint_rn(float x); +__device__ unsigned int __float2uint_ru(float x); +__device__ unsigned int __float2uint_rz(float x); + +__device__ unsigned long long int __float2ull_rd(float x); +__device__ unsigned long long int __float2ull_rn(float x); +__device__ unsigned long long int __float2ull_ru(float x); +__device__ unsigned long long int __float2ull_rz(float x); + +__device__ int __float_as_int(float x); +__device__ unsigned int __float_as_uint(float x); +__device__ double __hiloint2double(int hi, int lo); +__device__ double __int2double_rn(int x); + +__device__ float __int2float_rd(int x); +__device__ float __int2float_rn(int x); +__device__ float __int2float_ru(int x); +__device__ float __int2float_rz(int x); + +__device__ float __int_as_float(int x); + +__device__ double __ll2double_rd(long long int x); +__device__ double __ll2double_rn(long long int x); +__device__ double __ll2double_ru(long long int x); +__device__ double __ll2double_rz(long long int x); + +__device__ float __ll2float_rd(long long int x); +__device__ float __ll2float_rn(long long int x); +__device__ float __ll2float_ru(long long int x); +__device__ float __ll2float_rz(long long int x); + +__device__ double __longlong_as_double(long long int x); + +__device__ double __uint2double_rn(int x); + +__device__ float __uint2float_rd(unsigned int x); +__device__ float __uint2float_rn(unsigned int x); +__device__ float __uint2float_ru(unsigned int x); +__device__ float __uint2float_rz(unsigned int x); + +__device__ float __uint_as_float(unsigned int x); + +__device__ double __ull2double_rd(unsigned long long int x); +__device__ double __ull2double_rn(unsigned long long int x); +__device__ double __ull2double_ru(unsigned long long int x); +__device__ double __ull2double_rz(unsigned long long int x); + +__device__ float __ull2float_rd(unsigned long long int x); +__device__ float __ull2float_rn(unsigned long long int x); +__device__ float __ull2float_ru(unsigned long long int x); +__device__ float __ull2float_rz(unsigned long long int x); __device__ char4 __hip_hc_add8pk(char4, char4); __device__ char4 __hip_hc_sub8pk(char4, char4); __device__ char4 __hip_hc_mul8pk(char4, char4); -extern __device__ double __longlong_as_double(long long int x); -extern __device__ long long int __double_as_longlong(double x); #endif diff --git a/projects/hip/include/hip/hcc_detail/hip_fp16.h b/projects/hip/include/hip/hcc_detail/hip_fp16.h index eb63c7cd60..8ae6d0d85b 100644 --- a/projects/hip/include/hip/hcc_detail/hip_fp16.h +++ b/projects/hip/include/hip/hcc_detail/hip_fp16.h @@ -325,6 +325,10 @@ __device__ static inline __half __float2half_rd(const float a) { return (__half)a; } +__device__ static inline __half __float2half_rn(const float a) { + return (__half)a; +} + __device__ static inline __half __float2half_ru(const float a) { return (__half)a; } diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime.h b/projects/hip/include/hip/hcc_detail/hip_runtime.h index f747b446d7..f595ff1c05 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime.h @@ -136,12 +136,10 @@ __device__ float cyl_bessel_i0f(float x); __device__ float cyl_bessel_i1f(float x); __device__ float erfcf(float x); __device__ float erfcinvf(float y); -__host__ float erfcinvf(float y); + __device__ float erfcxf(float x); -__host__ float erfcxf(float x); __device__ float erff(float x); __device__ float erfinvf(float y); -__host__ float erfinvf(float y); __device__ float exp2f(float x); __device__ float expm1f(float x); __device__ float fabsf(float x); @@ -174,34 +172,24 @@ __device__ float nanf(const char* tagp); __device__ float nearbyintf(float x); __device__ float nextafterf(float x, float y); __device__ float norm3df(float a, float b, float c); -__host__ float norm3df(float a, float b, float c); __device__ float norm4df(float a, float b, float c, float d); -__host__ float norm4df(float a, float b, float c, float d); __device__ float normcdff(float y); -__host__ float normcdff(float y); __device__ float normcdfinvf(float y); -__host__ float normcdfinvf(float y); __device__ float normf(int dim, const float *a); __device__ float rcbrtf(float x); -__host__ float rcbrtf(float x); __device__ float remainderf(float x, float y); __device__ float remquof(float x, float y, int *quo); __device__ float rhypotf(float x, float y); -__host__ float rhypotf(float x, float y); __device__ float rintf(float x); __device__ float rnorm3df(float a, float b, float c); -__host__ float rnorm3df(float a, float b, float c); __device__ float rnorm4df(float a, float b, float c, float d); -__host__ float rnorm4df(float a, float b, float c, float d); __device__ float rnormf(int dim, const float* a); -__host__ float rnormf(int dim, const float* a); __device__ float roundf(float x); __device__ float rsqrtf(float x); __device__ float scalblnf(float x, long int n); __device__ float scalbnf(float x, int n); __host__ __device__ unsigned signbit(float a); __device__ void sincospif(float x, float *sptr, float *cptr); -__host__ void sincospif(float x, float *sptr, float *cptr); __device__ float sinhf(float x); __device__ float sinpif(float x); __device__ float sqrtf(float x); @@ -214,8 +202,22 @@ __device__ float ynf(int n, float x); __host__ __device__ float cospif(float x); __host__ __device__ float sinpif(float x); -__device__ float sqrtf(float x); +// /__device__ float sqrtf(float x); __host__ __device__ float rsqrtf(float x); +__host__ float normcdff(float y); + +__host__ float erfcinvf(float y); +__host__ float erfcxf(float x); +__host__ float erfinvf(float y); +__host__ float norm3df(float a, float b, float c); +__host__ float normcdfinvf(float y); +__host__ float norm4df(float a, float b, float c, float d); +__host__ float rcbrtf(float x); +__host__ float rhypotf(float x, float y); +__host__ float rnorm3df(float a, float b, float c); +__host__ float rnormf(int dim, const float* a); +__host__ float rnorm4df(float a, float b, float c, float d); +__host__ void sincospif(float x, float *sptr, float *cptr); __device__ double acos(double x); __device__ double acosh(double x); diff --git a/projects/hip/src/device_functions.cpp b/projects/hip/src/device_functions.cpp index 0de0cf7f6b..01d18d8d28 100644 --- a/projects/hip/src/device_functions.cpp +++ b/projects/hip/src/device_functions.cpp @@ -19,38 +19,342 @@ THE SOFTWARE. #include -extern "C" float __hip_int_as_float(int); +struct holder64Bit{ + union{ + double d; + unsigned long int uli; + signed long int sli; + signed int si[2]; + unsigned int ui[2]; + }; +} __attribute__((aligned(8))); -typedef struct { - signed int hi; - signed int lo; -} __hip_signed_2; +struct holder32Bit { + union { + float f; + unsigned int ui; + signed int si; + }; +} __attribute__((aligned(4))); -typedef struct { -union { - double d; - long long int lli; - __hip_signed_2 s2; -} ; -} __hip_64bit_struct; +struct holder64Bit hold64; +struct holder32Bit hold32; -typedef struct { -union { - float f; - unsigned int ui; - signed int si; -}; -} __hip_32bit_struct; - -__device__ float __int_as_float (int x) { - __hip_32bit_struct s; - s.si = x; - return s.f; +__device__ float __double2float_rd(double x) +{ + return (double)x; +} +__device__ float __double2float_rn(double x) +{ + return (double)x; +} +__device__ float __double2float_ru(double x) +{ + return (double)x; +} +__device__ float __double2float_rz(double x) +{ + return (double)x; } -__device__ double __hiloint2double (int hi, int lo) { - __hip_64bit_struct s; - s.s2.hi = hi; - s.s2.lo = lo; - return s.d; + +__device__ int __double2hiint(double x) +{ + hold64.d = x; + return hold64.si[1]; +} +__device__ int __double2loint(double x) +{ + hold64.d = x; + return hold64.si[0]; +} + + +__device__ int __double2int_rd(double x) +{ + return (int)x; +} +__device__ int __double2int_rn(double x) +{ + return (int)x; +} +__device__ int __double2int_ru(double x) +{ + return (int)x; +} +__device__ int __double2int_rz(double x) +{ + return (int)x; +} + +__device__ long long int __double2ll_rd(double x) +{ + return (long long int)x; +} +__device__ long long int __double2ll_rn(double x) +{ + return (long long int)x; +} +__device__ long long int __double2ll_ru(double x) +{ + return (long long int)x; +} +__device__ long long int __double2ll_rz(double x) +{ + return (long long int)x; +} + + +__device__ unsigned int __double2uint_rd(double x) +{ + return (unsigned int)x; +} +__device__ unsigned int __double2uint_rn(double x) +{ + return (unsigned int)x; +} +__device__ unsigned int __double2uint_ru(double x) +{ + return (unsigned int)x; +} +__device__ unsigned int __double2uint_rz(double x) +{ + return (unsigned int)x; +} + +__device__ unsigned long long int __double2ull_rd(double x) +{ + return (unsigned long long int)x; +} +__device__ unsigned long long int __double2ull_rn(double x) +{ + return (unsigned long long int)x; +} +__device__ unsigned long long int __double2ull_ru(double x) +{ + return (unsigned long long int)x; +} +__device__ unsigned long long int __double2ull_rz(double x) +{ + return (unsigned long long int)x; +} + +__device__ long long int __double_as_longlong(double x) +{ + hold64.d = x; + return hold64.sli; +} + +__device__ int float2int_rd(float x) +{ + return (int)x; +} +__device__ int float2int_rn(float x) +{ + return (int)x; +} +__device__ int float2int_ru(float x) +{ + return (int)x; +} +__device__ int float2int_rz(float x) +{ + return (int)x; +} + +__device__ long long int __float2ll_rd(float x) +{ + return (long long int)x; +} +__device__ long long int __float2ll_rn(float x) +{ + return (long long int)x; +} +__device__ long long int __float2ll_ru(float x) +{ + return (long long int)x; +} +__device__ long long int __float2ll_rz(float x) +{ + return (long long int)x; +} + +__device__ unsigned int __float2uint_rd(float x) +{ + return (unsigned int)x; +} +__device__ unsigned int __float2uint_rn(float x) +{ + return (unsigned int)x; +} +__device__ unsigned int __float2uint_ru(float x) +{ + return (unsigned int)x; +} +__device__ unsigned int __float2uint_rz(float x) +{ + return (unsigned int)x; +} + +__device__ unsigned long long int __float2ull_rd(float x) +{ + return (unsigned long long int)x; +} +__device__ unsigned long long int __float2ull_rn(float x) +{ + return (unsigned long long int)x; +} +__device__ unsigned long long int __float2ull_ru(float x) +{ + return (unsigned long long int)x; +} +__device__ unsigned long long int __float2ull_rz(float x) +{ + return (unsigned long long int)x; +} + +__device__ int __float_as_int(float x) +{ + hold32.f = x; + return hold32.si; +} +__device__ unsigned int __float_as_uint(float x) +{ + hold32.f = x; + return hold32.ui; +} +__device__ double __hiloint2double(int hi, int lo) +{ + hold64.si[1] = hi; + hold64.si[0] = lo; + return hold64.d; +} +__device__ double __int2double_rn(int x) +{ + return (double)x; +} + +__device__ float __int2float_rd(int x) +{ + return (float)x; +} +__device__ float __int2float_rn(int x) +{ + return (float)x; +} +__device__ float __int2float_ru(int x) +{ + return (float)x; +} +__device__ float __int2float_rz(int x) +{ + return (float)x; +} + +__device__ float __int_as_float(int x) +{ + hold32.si = x; + return hold32.f; +} + +__device__ double __ll2double_rd(long long int x) +{ + return (double)x; +} +__device__ double __ll2double_rn(long long int x) +{ + return (double)x; +} +__device__ double __ll2double_ru(long long int x) +{ + return (double)x; +} +__device__ double __ll2double_rz(long long int x) +{ + return (double)x; +} + +__device__ float __ll2float_rd(long long int x) +{ + return (float)x; +} +__device__ float __ll2float_rn(long long int x) +{ + return (float)x; +} +__device__ float __ll2float_ru(long long int x) +{ + return (float)x; +} +__device__ float __ll2float_rz(long long int x) +{ + return (float)x; +} + +__device__ double __longlong_as_double(long long int x) +{ + hold64.sli = x; + return hold64.d; +} + +__device__ double __uint2double_rn(int x) +{ + return (double)x; +} + +__device__ float __uint2float_rd(unsigned int x) +{ + return (float)x; +} +__device__ float __uint2float_rn(unsigned int x) +{ + return (float)x; +} +__device__ float __uint2float_ru(unsigned int x) +{ + return (float)x; +} +__device__ float __uint2float_rz(unsigned int x) +{ + return (float)x; +} + +__device__ float __uint_as_float(unsigned int x) +{ + hold32.ui = x; + return hold32.f; +} + +__device__ double __ull2double_rd(unsigned long long int x) +{ + return (double)x; +} +__device__ double __ull2double_rn(unsigned long long int x) +{ + return (double)x; +} +__device__ double __ull2double_ru(unsigned long long int x) +{ + return (double)x; +} +__device__ double __ull2double_rz(unsigned long long int x) +{ + return (double)x; +} + +__device__ float __ull2float_rd(unsigned long long int x) +{ + return (float)x; +} +__device__ float __ull2float_rn(unsigned long long int x) +{ + return (float)x; +} +__device__ float __ull2float_ru(unsigned long long int x) +{ + return (float)x; +} +__device__ float __ull2float_rz(unsigned long long int x) +{ + return (float)x; } diff --git a/projects/hip/src/device_util.cpp b/projects/hip/src/device_util.cpp index db0f494af4..cf5d6ff5af 100644 --- a/projects/hip/src/device_util.cpp +++ b/projects/hip/src/device_util.cpp @@ -2179,16 +2179,6 @@ __device__ double __hip_fast_dsqrt_rz(double x) { return hc::fast_math::sqrt(x); } -__device__ double __longlong_as_double(long long int x) -{ - return static_cast(x); -} - -__device__ long long __double_as_longlong(double x) -{ - return static_cast(x); -} - __device__ void __threadfence_system(void){ // no-op } diff --git a/projects/hip/tests/src/deviceLib/hipTestHalf.cpp b/projects/hip/tests/src/deviceLib/hipTestHalf.cpp index 975a494b2a..12b7e2e270 100644 --- a/projects/hip/tests/src/deviceLib/hipTestHalf.cpp +++ b/projects/hip/tests/src/deviceLib/hipTestHalf.cpp @@ -128,5 +128,5 @@ __global__ void CheckCmpHalf2(hipLaunchParm lp, __half2* In1, __half2* In2, __ha } int main(){ - + passed(); } From 38edad98a68af66250e41c7c988301d81e3497ee Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Mon, 16 Jan 2017 12:32:35 -0600 Subject: [PATCH 071/281] moved most of the fp16 code inside hip_fp16.cpp 1. As we use holder data structure, we move all the cmp, math, cvt apis to cpp file 2. All the tests passed 3. Add more extensive testing for half Change-Id: I92c6399dace602a0a24432728e3f2a07124e6fb1 [ROCm/hip commit: 18631efbc0bf9f23751689dd33359cfc4c112344] --- .../hip/include/hip/hcc_detail/hip_fp16.h | 565 ++++-------------- projects/hip/src/hip_fp16.cpp | 468 +++++++++++++++ 2 files changed, 572 insertions(+), 461 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/hip_fp16.h b/projects/hip/include/hip/hcc_detail/hip_fp16.h index 8ae6d0d85b..755cb19f6d 100644 --- a/projects/hip/include/hip/hcc_detail/hip_fp16.h +++ b/projects/hip/include/hip/hcc_detail/hip_fp16.h @@ -36,17 +36,6 @@ typedef struct __attribute__((aligned(4))){ }; } __half2; -struct hipHalfHolder{ - union { - __half h; - unsigned short s; - }; -}; - -#define HINF 65504 - -static struct hipHalfHolder __hInfValue = {HINF}; - extern "C" __half __hip_hc_ir_hadd_half(__half, __half); extern "C" __half __hip_hc_ir_hfma_half(__half, __half, __half); extern "C" __half __hip_hc_ir_hmul_half(__half, __half); @@ -186,456 +175,6 @@ __device__ static inline __half2 h2div(__half2 a, __half2 b) { return c; } -/* -Half comparision Functions -*/ - -__device__ static inline bool __heq(__half a, __half b) { - return a == b ? true : false; -} - -__device__ static inline bool __hge(__half a, __half b) { - return a >= b ? true : false; -} - -__device__ static inline bool __hgt(__half a, __half b) { - return a > b ? true : false; -} - -__device__ static inline bool __hisinf(__half a) { - return a == __hInfValue.h ? true : false; -} - -__device__ static inline bool __hisnan(__half a) { - return a > __hInfValue.h ? true : false; -} - -__device__ static inline bool __hle(__half a, __half b) { - return a <= b ? true : false; -} - -__device__ static inline bool __hlt(__half a, __half b) { - return a < b ? true : false; -} - -__device__ static inline bool __hne(__half a, __half b) { - return a != b ? true : false; -} - -/* -Half2 Comparision Functions -*/ - -__device__ static inline bool __hbeq2(__half2 a, __half2 b) { - return (a.p[0] == b.p[0] ? true : false) && (a.p[1] == b.p[1] ? true : false); -} - -__device__ static inline bool __hbge2(__half2 a, __half2 b) { - return (a.p[0] >= b.p[0] ? true : false) && (a.p[1] >= b.p[1] ? true : false); -} - -__device__ static inline bool __hbgt2(__half2 a, __half2 b) { - return (a.p[0] > b.p[0] ? true : false) && (a.p[1] > b.p[1] ? true : false); -} - -__device__ static inline bool __hble2(__half2 a, __half2 b) { - return (a.p[0] <= b.p[0] ? true : false) && (a.p[1] <= b.p[1] ? true : false); -} - -__device__ static inline bool __hblt2(__half2 a, __half2 b) { - return (a.p[0] < b.p[0] ? true : false) && (a.p[1] < b.p[1] ? true : false); -} - -__device__ static inline bool __hbne2(__half2 a, __half2 b) { - return (a.p[0] != b.p[0] ? true : false) && (a.p[1] != b.p[1] ? true : false); -} - -__device__ static inline __half2 __heq2(__half2 a, __half2 b) { - __half2 c; - c.p[0] = (a.p[0] == b.p[0]) ? (__half)1 : (__half)0; - c.p[1] = (a.p[1] == b.p[1]) ? (__half)1 : (__half)0; - return c; -} - -__device__ static inline __half2 __hge2(__half2 a, __half2 b) { - __half2 c; - c.p[0] = (a.p[0] >= b.p[0]) ? (__half)1 : (__half)0; - c.p[1] = (a.p[1] >= b.p[1]) ? (__half)1 : (__half)0; - return c; -} - -__device__ static inline __half2 __hgt2(__half2 a, __half2 b) { - __half2 c; - c.p[0] = (a.p[0] > b.p[0]) ? (__half)1 : (__half)0; - c.p[1] = (a.p[1] > b.p[1]) ? (__half)1 : (__half)0; - return c; -} - -__device__ static inline __half2 __hisnan2(__half2 a) { - __half2 c; - c.p[0] = (a.p[0] > __hInfValue.h) ? (__half)1 : (__half)0; - c.p[1] = (a.p[1] > __hInfValue.h) ? (__half)1 : (__half)0; - return c; -} - -__device__ static inline __half2 __hle2(__half2 a, __half2 b) { - __half2 c; - c.p[0] = (a.p[0] <= b.p[0]) ? (__half)1 : (__half)0; - c.p[1] = (a.p[1] <= b.p[1]) ? (__half)1 : (__half)0; - return c; -} - -__device__ static inline __half2 __hlt2(__half2 a, __half2 b) { - __half2 c; - c.p[0] = (a.p[0] < b.p[0]) ? (__half)1 : (__half)0; - c.p[1] = (a.p[1] < b.p[1]) ? (__half)1 : (__half)0; - return c; -} - -__device__ static inline __half2 __hne2(__half2 a, __half2 b) { - __half2 c; - c.p[0] = (a.p[0] != b.p[0]) ? (__half)1 : (__half)0; - c.p[1] = (a.p[1] != b.p[1]) ? (__half)1 : (__half)0; - return c; -} - -/* -Conversion instructions -*/ - -__device__ static inline __half2 __float22half2_rn(const float2 a) { - __half2 b; - b.p[0] = (__half)a.x; - b.p[1] = (__half)a.y; - return b; -} - -__device__ static inline __half __float2half(const float a) { - return (__half)a; -} - -__device__ static inline __half2 __float2half2_rn(const float a) { - __half2 b; - b.p[0] = (__half)a; - b.p[1] = (__half)a; - return b; -} - -__device__ static inline __half __float2half_rd(const float a) { - return (__half)a; -} - -__device__ static inline __half __float2half_rn(const float a) { - return (__half)a; -} - -__device__ static inline __half __float2half_ru(const float a) { - return (__half)a; -} - -__device__ static inline __half __float2half_rz(const float a) { - return (__half)a; -} - -__device__ static inline __half2 __floats2half2_rn(const float a, const float b) { - __half2 c; - c.p[0] = (__half)a; - c.p[1] = (__half)b; - return c; -} - -__device__ static inline float2 __half22float2(const __half2 a) { - float2 b; - b.x = (float)a.p[0]; - b.y = (float)a.p[1]; - return b; -} - -__device__ static inline float __half2float(const __half a) { - return (float)a; -} - -__device__ static inline __half2 half2half2(const __half a) { - __half2 b; - b.p[0] = a; - b.p[1] = a; - return b; -} - -__device__ static inline int __half2int_rd(__half h) { - return (int)h; -} - -__device__ static inline int __half2int_rn(__half h) { - return (int)h; -} - -__device__ static inline int __half2int_ru(__half h) { - return (int)h; -} - -__device__ static inline int __half2int_rz(__half h) { - return (int)h; -} - -__device__ static inline long long int __half2ll_rd(__half h) { - return (long long int)h; -} - -__device__ static inline long long int __half2ll_rn(__half h) { - return (long long int)h; -} - -__device__ static inline long long int __half2ll_ru(__half h) { - return (long long int)h; -} - -__device__ static inline long long int __half2ll_rz(__half h) { - return (long long int)h; -} - -__device__ static inline short __half2short_rd(__half h) { - return (short)h; -} - -__device__ static inline short __half2short_rn(__half h) { - return (short)h; -} - -__device__ static inline short __half2short_ru(__half h) { - return (short)h; -} - -__device__ static inline short __half2short_rz(__half h) { - return (short)h; -} - -__device__ static inline unsigned int __half2uint_rd(__half h) { - return (unsigned int)h; -} - -__device__ static inline unsigned int __half2uint_rn(__half h) { - return (unsigned int)h; -} - -__device__ static inline unsigned int __half2uint_ru(__half h) { - return (unsigned int)h; -} - -__device__ static inline unsigned int __half2uint_rz(__half h) { - return (unsigned int)h; -} - -__device__ static inline unsigned long long int __half2ull_rd(__half h) { - return (unsigned long long)h; -} - -__device__ static inline unsigned long long int __half2ull_rn(__half h) { - return (unsigned long long)h; -} - -__device__ static inline unsigned long long int __half2ull_ru(__half h) { - return (unsigned long long)h; -} - -__device__ static inline unsigned long long int __half2ull_rz(__half h) { - return (unsigned long long)h; -} - -__device__ static inline unsigned short int __half2ushort_rd(__half h) { - return (unsigned short int)h; -} - -__device__ static inline unsigned short int __half2ushort_rn(__half h) { - return (unsigned short int)h; -} - -__device__ static inline unsigned short int __half2ushort_ru(__half h) { - return (unsigned short int)h; -} - -__device__ static inline unsigned short int __half2ushort_rz(__half h) { - return (unsigned short int)h; -} - -__device__ static inline short int __half_as_short(const __half h) { - hipHalfHolder hH; - hH.h = h; - return (short)hH.s; -} - -__device__ static inline unsigned short int __half_as_ushort(const __half h) { - hipHalfHolder hH; - hH.h = h; - return hH.s; -} - -__device__ static inline __half2 __halves2half2(const __half a, const __half b) { - __half2 c; - c.p[0] = a; - c.p[1] = b; - return c; -} - -__device__ static inline float __high2float(const __half2 a) { - return (float)a.p[1]; -} - -__device__ static inline __half __high2half(const __half2 a) { - return a.p[1]; -} - -__device__ static inline __half2 __high2half2(const __half2 a) { - __half2 b; - b.p[0] = a.p[1]; - b.p[1] = a.p[1]; - return b; -} - -__device__ static inline __half2 __highs2half2(const __half2 a, const __half2 b) { - __half2 c; - c.p[0] = a.p[1]; - c.p[1] = b.p[1]; - return c; -} - -__device__ static inline __half __int2half_rd(int i) { - return (__half)i; -} - -__device__ static inline __half __int2half_rn(int i) { - return (__half)i; -} - -__device__ static inline __half __int2half_ru(int i) { - return (__half)i; -} - -__device__ static inline __half __int2half_rz(int i) { - return (__half)i; -} - -__device__ static inline __half __ll2half_rd(long long int i){ - return (__half)i; -} - -__device__ static inline __half __ll2half_rn(long long int i){ - return (__half)i; -} - -__device__ static inline __half __ll2half_ru(long long int i){ - return (__half)i; -} - -__device__ static inline __half __ll2half_rz(long long int i){ - return (__half)i; -} - -__device__ static inline float __low2float(const __half2 a) { - return (float)a.p[0]; -} - -__device__ static inline __half __low2half(const __half2 a) { - return a.p[0]; -} - -__device__ static inline __half2 __low2half2(const __half2 a, const __half2 b) { - __half2 c; - c.p[0] = a.p[0]; - c.p[1] = b.p[0]; - return c; -} - -__device__ static inline __half2 __low2half2(const __half2 a) { - __half2 b; - b.p[0] = a.p[0]; - b.p[1] = a.p[0]; - return b; -} - -__device__ static inline __half2 __lowhigh2highlow(const __half2 a) { - __half2 b; - b.p[0] = a.p[1]; - b.p[1] = a.p[0]; - return b; -} - -__device__ static inline __half2 __lows2half2(const __half2 a, const __half2 b) { - __half2 c; - c.p[0] = a.p[0]; - c.p[1] = b.p[0]; - return c; -} - -__device__ static inline __half __short2half_rd(short int i) { - return (__half)i; -} - -__device__ static inline __half __short2half_rn(short int i) { - return (__half)i; -} - -__device__ static inline __half __short2half_ru(short int i) { - return (__half)i; -} - -__device__ static inline __half __short2half_rz(short int i) { - return (__half)i; -} - -__device__ static inline __half __uint2half_rd(unsigned int i) { - return (__half)i; -} - -__device__ static inline __half __uint2half_rn(unsigned int i) { - return (__half)i; -} - -__device__ static inline __half __uint2half_ru(unsigned int i) { - return (__half)i; -} - -__device__ static inline __half __uint2half_rz(unsigned int i) { - return (__half)i; -} - -__device__ static inline __half __ull2half_rd(unsigned long long int i) { - return (__half)i; -} - -__device__ static inline __half __ull2half_rn(unsigned long long int i) { - return (__half)i; -} - -__device__ static inline __half __ull2half_ru(unsigned long long int i) { - return (__half)i; -} - -__device__ static inline __half __ull2half_rz(unsigned long long int i) { - return (__half)i; -} - -__device__ static inline __half __ushort2half_rd(unsigned short int i) { - return (__half)i; -} - -__device__ static inline __half __ushort2half_rn(unsigned short int i) { - return (__half)i; -} - -__device__ static inline __half __ushort2half_ru(unsigned short int i) { - return (__half)i; -} - -__device__ static inline __half __ushort2half_rz(unsigned short int i) { - return (__half)i; -} - -__device__ static inline __half __ushort_as_half(const unsigned short int i) { - hipHalfHolder hH; - hH.s = i; - return hH.h; -} __device__ static inline __half hceil(const __half h) { return __hip_hc_ir_hceil_half(h); @@ -792,6 +331,110 @@ __device__ static inline __half2 h2trunc(const __half2 h) { return a; } +__device__ bool __heq(__half a, __half b); +__device__ bool __hge(__half a, __half b); +__device__ bool __hgt(__half a, __half b); +__device__ bool __hisinf(__half a); +__device__ bool __hisnan(__half a); +__device__ bool __hle(__half a, __half b); +__device__ bool __hlt(__half a, __half b); +__device__ bool __hne(__half a, __half b); +/* +Half2 Comparision Functions +*/ + +__device__ bool __hbeq2(__half2 a, __half2 b); +__device__ bool __hbge2(__half2 a, __half2 b); +__device__ bool __hbgt2(__half2 a, __half2 b); +__device__ bool __hble2(__half2 a, __half2 b); +__device__ bool __hblt2(__half2 a, __half2 b); +__device__ bool __hbne2(__half2 a, __half2 b); +__device__ __half2 __heq2(__half2 a, __half2 b); +__device__ __half2 __hge2(__half2 a, __half2 b); +__device__ __half2 __hgt2(__half2 a, __half2 b); +__device__ __half2 __hisnan2(__half2 a); +__device__ __half2 __hle2(__half2 a, __half2 b); +__device__ __half2 __hlt2(__half2 a, __half2 b); +__device__ __half2 __hne2(__half2 a, __half2 b); + +/* +Conversion instructions +*/ +__device__ __half2 __float22half2_rn(const float2 a); +__device__ __half __float2half(const float a); +__device__ __half2 __float2half2_rn(const float a); +__device__ __half __float2half_rd(const float a); +__device__ __half __float2half_rn(const float a); +__device__ __half __float2half_ru(const float a); +__device__ __half __float2half_rz(const float a); +__device__ __half2 __floats2half2_rn(const float a, const float b); +__device__ float2 __half22float2(const __half2 a); +__device__ float __half2float(const __half a); +__device__ __half2 half2half2(const __half a); +__device__ int __half2int_rd(__half h); +__device__ int __half2int_rn(__half h); +__device__ int __half2int_ru(__half h); +__device__ int __half2int_rz(__half h); +__device__ long long int __half2ll_rd(__half h); +__device__ long long int __half2ll_rn(__half h); +__device__ long long int __half2ll_ru(__half h); +__device__ long long int __half2ll_rz(__half h); +__device__ short __half2short_rd(__half h); +__device__ short __half2short_rn(__half h); +__device__ short __half2short_ru(__half h); +__device__ short __half2short_rz(__half h); +__device__ unsigned int __half2uint_rd(__half h); +__device__ unsigned int __half2uint_rn(__half h); +__device__ unsigned int __half2uint_ru(__half h); +__device__ unsigned int __half2uint_rz(__half h); +__device__ unsigned long long int __half2ull_rd(__half h); +__device__ unsigned long long int __half2ull_rn(__half h); +__device__ unsigned long long int __half2ull_ru(__half h); +__device__ unsigned long long int __half2ull_rz(__half h); +__device__ unsigned short int __half2ushort_rd(__half h); +__device__ unsigned short int __half2ushort_rn(__half h); +__device__ unsigned short int __half2ushort_ru(__half h); +__device__ unsigned short int __half2ushort_rz(__half h); +__device__ short int __half_as_short(const __half h); +__device__ unsigned short int __half_as_ushort(const __half h); +__device__ __half2 __halves2half2(const __half a, const __half b); +__device__ float __high2float(const __half2 a); +__device__ __half __high2half(const __half2 a); +__device__ __half2 __high2half2(const __half2 a); +__device__ __half2 __highs2half2(const __half2 a, const __half2 b); +__device__ __half __int2half_rd(int i); +__device__ __half __int2half_rn(int i); +__device__ __half __int2half_ru(int i); +__device__ __half __int2half_rz(int i); +__device__ __half __ll2half_rd(long long int i); +__device__ __half __ll2half_rn(long long int i); +__device__ __half __ll2half_ru(long long int i); +__device__ __half __ll2half_rz(long long int i); +__device__ float __low2float(const __half2 a); + +__device__ __half __low2half(const __half2 a); +__device__ __half2 __low2half2(const __half2 a, const __half2 b); +__device__ __half2 __low2half2(const __half2 a); +__device__ __half2 __lowhigh2highlow(const __half2 a); +__device__ __half2 __lows2half2(const __half2 a, const __half2 b); +__device__ __half __short2half_rd(short int i); +__device__ __half __short2half_rn(short int i); +__device__ __half __short2half_ru(short int i); +__device__ __half __short2half_rz(short int i); +__device__ __half __uint2half_rd(unsigned int i); +__device__ __half __uint2half_rn(unsigned int i); +__device__ __half __uint2half_ru(unsigned int i); +__device__ __half __uint2half_rz(unsigned int i); +__device__ __half __ull2half_rd(unsigned long long int i); +__device__ __half __ull2half_rn(unsigned long long int i); +__device__ __half __ull2half_ru(unsigned long long int i); +__device__ __half __ull2half_rz(unsigned long long int i); +__device__ __half __ushort2half_rd(unsigned short int i); +__device__ __half __ushort2half_rn(unsigned short int i); +__device__ __half __ushort2half_ru(unsigned short int i); +__device__ __half __ushort2half_rz(unsigned short int i); +__device__ __half __ushort_as_half(const unsigned short int i); + #endif diff --git a/projects/hip/src/hip_fp16.cpp b/projects/hip/src/hip_fp16.cpp index 83e0a161c7..ac79ddba08 100644 --- a/projects/hip/src/hip_fp16.cpp +++ b/projects/hip/src/hip_fp16.cpp @@ -22,6 +22,472 @@ THE SOFTWARE. #include"hip/hip_fp16.h" +struct hipHalfHolder{ + union { + __half h; + unsigned short s; + }; +}; + +#define HINF 65504 + +static struct hipHalfHolder __hInfValue = {HINF}; +/* +Half comparision Functions +*/ + +__device__ bool __heq(__half a, __half b) { + return a == b ? true : false; +} + +__device__ bool __hge(__half a, __half b) { + return a >= b ? true : false; +} + +__device__ bool __hgt(__half a, __half b) { + return a > b ? true : false; +} + +__device__ bool __hisinf(__half a) { + return a == __hInfValue.h ? true : false; +} + +__device__ bool __hisnan(__half a) { + return a > __hInfValue.h ? true : false; +} + +__device__ bool __hle(__half a, __half b) { + return a <= b ? true : false; +} + +__device__ bool __hlt(__half a, __half b) { + return a < b ? true : false; +} + +__device__ bool __hne(__half a, __half b) { + return a != b ? true : false; +} + +/* +Half2 Comparision Functions +*/ + +__device__ bool __hbeq2(__half2 a, __half2 b) { + return (a.p[0] == b.p[0] ? true : false) && (a.p[1] == b.p[1] ? true : false); +} + +__device__ bool __hbge2(__half2 a, __half2 b) { + return (a.p[0] >= b.p[0] ? true : false) && (a.p[1] >= b.p[1] ? true : false); +} + +__device__ bool __hbgt2(__half2 a, __half2 b) { + return (a.p[0] > b.p[0] ? true : false) && (a.p[1] > b.p[1] ? true : false); +} + +__device__ bool __hble2(__half2 a, __half2 b) { + return (a.p[0] <= b.p[0] ? true : false) && (a.p[1] <= b.p[1] ? true : false); +} + +__device__ bool __hblt2(__half2 a, __half2 b) { + return (a.p[0] < b.p[0] ? true : false) && (a.p[1] < b.p[1] ? true : false); +} + +__device__ bool __hbne2(__half2 a, __half2 b) { + return (a.p[0] != b.p[0] ? true : false) && (a.p[1] != b.p[1] ? true : false); +} + +__device__ __half2 __heq2(__half2 a, __half2 b) { + __half2 c; + c.p[0] = (a.p[0] == b.p[0]) ? (__half)1 : (__half)0; + c.p[1] = (a.p[1] == b.p[1]) ? (__half)1 : (__half)0; + return c; +} + +__device__ __half2 __hge2(__half2 a, __half2 b) { + __half2 c; + c.p[0] = (a.p[0] >= b.p[0]) ? (__half)1 : (__half)0; + c.p[1] = (a.p[1] >= b.p[1]) ? (__half)1 : (__half)0; + return c; +} + +__device__ __half2 __hgt2(__half2 a, __half2 b) { + __half2 c; + c.p[0] = (a.p[0] > b.p[0]) ? (__half)1 : (__half)0; + c.p[1] = (a.p[1] > b.p[1]) ? (__half)1 : (__half)0; + return c; +} + +__device__ __half2 __hisnan2(__half2 a) { + __half2 c; + c.p[0] = (a.p[0] > __hInfValue.h) ? (__half)1 : (__half)0; + c.p[1] = (a.p[1] > __hInfValue.h) ? (__half)1 : (__half)0; + return c; +} + +__device__ __half2 __hle2(__half2 a, __half2 b) { + __half2 c; + c.p[0] = (a.p[0] <= b.p[0]) ? (__half)1 : (__half)0; + c.p[1] = (a.p[1] <= b.p[1]) ? (__half)1 : (__half)0; + return c; +} + +__device__ __half2 __hlt2(__half2 a, __half2 b) { + __half2 c; + c.p[0] = (a.p[0] < b.p[0]) ? (__half)1 : (__half)0; + c.p[1] = (a.p[1] < b.p[1]) ? (__half)1 : (__half)0; + return c; +} + +__device__ __half2 __hne2(__half2 a, __half2 b) { + __half2 c; + c.p[0] = (a.p[0] != b.p[0]) ? (__half)1 : (__half)0; + c.p[1] = (a.p[1] != b.p[1]) ? (__half)1 : (__half)0; + return c; +} + +/* +Conversion instructions +*/ +__device__ __half2 __float22half2_rn(const float2 a) { + __half2 b; + b.p[0] = (__half)a.x; + b.p[1] = (__half)a.y; + return b; +} + +__device__ __half __float2half(const float a) { + return (__half)a; +} + +__device__ __half2 __float2half2_rn(const float a) { + __half2 b; + b.p[0] = (__half)a; + b.p[1] = (__half)a; + return b; +} + +__device__ __half __float2half_rd(const float a) { + return (__half)a; +} + +__device__ __half __float2half_rn(const float a) { + return (__half)a; +} + +__device__ __half __float2half_ru(const float a) { + return (__half)a; +} + +__device__ __half __float2half_rz(const float a) { + return (__half)a; +} + +__device__ __half2 __floats2half2_rn(const float a, const float b) { + __half2 c; + c.p[0] = (__half)a; + c.p[1] = (__half)b; + return c; +} + +__device__ float2 __half22float2(const __half2 a) { + float2 b; + b.x = (float)a.p[0]; + b.y = (float)a.p[1]; + return b; +} + +__device__ float __half2float(const __half a) { + return (float)a; +} + +__device__ __half2 half2half2(const __half a) { + __half2 b; + b.p[0] = a; + b.p[1] = a; + return b; +} + +__device__ int __half2int_rd(__half h) { + return (int)h; +} + +__device__ int __half2int_rn(__half h) { + return (int)h; +} + +__device__ int __half2int_ru(__half h) { + return (int)h; +} + +__device__ int __half2int_rz(__half h) { + return (int)h; +} + +__device__ long long int __half2ll_rd(__half h) { + return (long long int)h; +} + +__device__ long long int __half2ll_rn(__half h) { + return (long long int)h; +} + +__device__ long long int __half2ll_ru(__half h) { + return (long long int)h; +} + +__device__ long long int __half2ll_rz(__half h) { + return (long long int)h; +} + +__device__ short __half2short_rd(__half h) { + return (short)h; +} + +__device__ short __half2short_rn(__half h) { + return (short)h; +} + +__device__ short __half2short_ru(__half h) { + return (short)h; +} + +__device__ short __half2short_rz(__half h) { + return (short)h; +} + +__device__ unsigned int __half2uint_rd(__half h) { + return (unsigned int)h; +} + +__device__ unsigned int __half2uint_rn(__half h) { + return (unsigned int)h; +} + +__device__ unsigned int __half2uint_ru(__half h) { + return (unsigned int)h; +} + +__device__ unsigned int __half2uint_rz(__half h) { + return (unsigned int)h; +} + +__device__ unsigned long long int __half2ull_rd(__half h) { + return (unsigned long long)h; +} + +__device__ unsigned long long int __half2ull_rn(__half h) { + return (unsigned long long)h; +} + +__device__ unsigned long long int __half2ull_ru(__half h) { + return (unsigned long long)h; +} + +__device__ unsigned long long int __half2ull_rz(__half h) { + return (unsigned long long)h; +} + +__device__ unsigned short int __half2ushort_rd(__half h) { + return (unsigned short int)h; +} + +__device__ unsigned short int __half2ushort_rn(__half h) { + return (unsigned short int)h; +} + +__device__ unsigned short int __half2ushort_ru(__half h) { + return (unsigned short int)h; +} + +__device__ unsigned short int __half2ushort_rz(__half h) { + return (unsigned short int)h; +} + +__device__ short int __half_as_short(const __half h) { + hipHalfHolder hH; + hH.h = h; + return (short)hH.s; +} + +__device__ unsigned short int __half_as_ushort(const __half h) { + hipHalfHolder hH; + hH.h = h; + return hH.s; +} + +__device__ __half2 __halves2half2(const __half a, const __half b) { + __half2 c; + c.p[0] = a; + c.p[1] = b; + return c; +} + +__device__ float __high2float(const __half2 a) { + return (float)a.p[1]; +} + +__device__ __half __high2half(const __half2 a) { + return a.p[1]; +} + +__device__ __half2 __high2half2(const __half2 a) { + __half2 b; + b.p[0] = a.p[1]; + b.p[1] = a.p[1]; + return b; +} + +__device__ __half2 __highs2half2(const __half2 a, const __half2 b) { + __half2 c; + c.p[0] = a.p[1]; + c.p[1] = b.p[1]; + return c; +} + +__device__ __half __int2half_rd(int i) { + return (__half)i; +} + +__device__ __half __int2half_rn(int i) { + return (__half)i; +} + +__device__ __half __int2half_ru(int i) { + return (__half)i; +} + +__device__ __half __int2half_rz(int i) { + return (__half)i; +} + +__device__ __half __ll2half_rd(long long int i){ + return (__half)i; +} + +__device__ __half __ll2half_rn(long long int i){ + return (__half)i; +} + +__device__ __half __ll2half_ru(long long int i){ + return (__half)i; +} + +__device__ __half __ll2half_rz(long long int i){ + return (__half)i; +} + +__device__ float __low2float(const __half2 a) { + return (float)a.p[0]; +} + +__device__ __half __low2half(const __half2 a) { + return a.p[0]; +} + +__device__ __half2 __low2half2(const __half2 a, const __half2 b) { + __half2 c; + c.p[0] = a.p[0]; + c.p[1] = b.p[0]; + return c; +} + +__device__ __half2 __low2half2(const __half2 a) { + __half2 b; + b.p[0] = a.p[0]; + b.p[1] = a.p[0]; + return b; +} + +__device__ __half2 __lowhigh2highlow(const __half2 a) { + __half2 b; + b.p[0] = a.p[1]; + b.p[1] = a.p[0]; + return b; +} + +__device__ __half2 __lows2half2(const __half2 a, const __half2 b) { + __half2 c; + c.p[0] = a.p[0]; + c.p[1] = b.p[0]; + return c; +} + +__device__ __half __short2half_rd(short int i) { + return (__half)i; +} + +__device__ __half __short2half_rn(short int i) { + return (__half)i; +} + +__device__ __half __short2half_ru(short int i) { + return (__half)i; +} + +__device__ __half __short2half_rz(short int i) { + return (__half)i; +} + +__device__ __half __uint2half_rd(unsigned int i) { + return (__half)i; +} + +__device__ __half __uint2half_rn(unsigned int i) { + return (__half)i; +} + +__device__ __half __uint2half_ru(unsigned int i) { + return (__half)i; +} + +__device__ __half __uint2half_rz(unsigned int i) { + return (__half)i; +} + +__device__ __half __ull2half_rd(unsigned long long int i) { + return (__half)i; +} + +__device__ __half __ull2half_rn(unsigned long long int i) { + return (__half)i; +} + +__device__ __half __ull2half_ru(unsigned long long int i) { + return (__half)i; +} + +__device__ __half __ull2half_rz(unsigned long long int i) { + return (__half)i; +} + +__device__ __half __ushort2half_rd(unsigned short int i) { + return (__half)i; +} + +__device__ __half __ushort2half_rn(unsigned short int i) { + return (__half)i; +} + +__device__ __half __ushort2half_ru(unsigned short int i) { + return (__half)i; +} + +__device__ __half __ushort2half_rz(unsigned short int i) { + return (__half)i; +} + +__device__ __half __ushort_as_half(const unsigned short int i) { + hipHalfHolder hH; + hH.s = i; + return hH.h; +} + + +/* +Soft Implementation. Use it for backup. +*/ + + static const unsigned sign_val = 0x8000; static const __half __half_value_one_float = {0x3C00}; static const __half __half_value_zero_float = {0x0}; @@ -375,4 +841,6 @@ __device__ __half2 __soft_low2half2(const __half2 a, const __half2 b){ return {a.p[0], b.p[0]}; } + + #endif From 72202cccbd5262dc29ee7e6b384824ae4d5cd1c6 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Mon, 16 Jan 2017 14:55:29 -0600 Subject: [PATCH 072/281] v1: Working on Integer Intrinsics 1. Half way through 2. May not work 3. No test written Change-Id: I705b743a78b142ff068e2521870e73fca7ad2b1c [ROCm/hip commit: b09ad764a1d37595aafa8fbbee0765bc797d454a] --- .../include/hip/hcc_detail/device_functions.h | 53 ++++++ .../hip/include/hip/hcc_detail/hip_runtime.h | 24 --- projects/hip/src/device_functions.cpp | 164 ++++++++++++++++++ projects/hip/src/device_util.cpp | 110 ------------ projects/hip/src/hip_ir.ll | 25 +++ 5 files changed, 242 insertions(+), 134 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/device_functions.h b/projects/hip/include/hip/hcc_detail/device_functions.h index e6771650a2..8eb9d6a46c 100644 --- a/projects/hip/include/hip/hcc_detail/device_functions.h +++ b/projects/hip/include/hip/hcc_detail/device_functions.h @@ -23,6 +23,59 @@ THE SOFTWARE. #include #include +extern "C" unsigned int __hip_hc_ir_umul24_int(unsigned int, unsigned int); +extern "C" signed int __hip_hc_ir_mul24_int(signed int, signed int); +extern "C" signed int __hip_hc_ir_mulhi_int(signed int, signed int); +extern "C" unsigned int __hip_hc_ir_umulhi_int(unsigned int, unsigned int); +// integer intrinsic function __poc __clz __ffs __brev +__device__ unsigned int __brev( unsigned int x); +__device__ unsigned long long int __brevll( unsigned long long int x); +__device__ unsigned int __byte_perm(unsigned int x, unsigned int y, unsigned int s); +__device__ unsigned int __clz(int x); +__device__ unsigned int __clzll(long long int x); +__device__ unsigned int __ffs(int x); +__device__ unsigned int __ffsll(long long int x); +__device__ static inline unsigned int __hadd(int x, int y) +{ + return (x + y) >> 1; +} +__device__ static inline int __mul24(int x, int y) +{ + return __hip_hc_ir_mul24_int(x, y); +} +__device__ long long int __mul64hi(long long int x, long long int y); +__device__ int __mulhi(int x, int y) +{ + return __hip_hc_ir_mulhi_int(x, y); +} +__device__ unsigned int __popc( unsigned int x); +__device__ unsigned int __popcll( unsigned long long int x); +__device__ int __rhadd(int x, int y) +{ + return (x + y + 1) >> 1; +} +//__device__ unsigned int __sad(int x, int y, int z); +/* +Implemented signed version of sad +*/ +__device__ unsigned int __uhadd(unsigned int x, unsigned int y) +{ + return (x + y) >> 1; +} +__device__ static inline int __umul24(unsigned int x, unsigned int y) +{ + return __hip_hc_ir_umul24_int(x, y); +} +__device__ unsigned long long int __umul64hi(unsigned long long int x, unsigned long long int y); +__device__ unsigned int __umulhi(unsigned int x, unsigned int y); +__device__ unsigned int __urhadd(unsigned int x, unsigned int y); +__device__ unsigned int __usad(unsigned int x, unsigned int y, unsigned int z); + +// warp vote function __all __any __ballot +__device__ int __all( int input); +__device__ int __any( int input); +__device__ unsigned long long int __ballot( int input); + /* Rounding modes are not yet supported in HIP */ diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime.h b/projects/hip/include/hip/hcc_detail/hip_runtime.h index f595ff1c05..f6967c3445 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime.h @@ -420,30 +420,6 @@ __device__ unsigned int atomicInc(unsigned int* address, __device__ unsigned int atomicDec(unsigned int* address, unsigned int val); -//__mul24 __umul24 -__device__ int __mul24(int arg1, int arg2); -__device__ unsigned int __umul24(unsigned int arg1, unsigned int arg2); - -// integer intrinsic function __poc __clz __ffs __brev -__device__ unsigned int __popc( unsigned int input); -__device__ unsigned int __popcll( unsigned long long int input); -__device__ unsigned int __clz(unsigned int input); -__device__ unsigned int __clzll(unsigned long long int input); -__device__ unsigned int __clz(int input); -__device__ unsigned int __clzll(long long int input); -__device__ unsigned int __ffs(unsigned int input); -__device__ unsigned int __ffsll(unsigned long long int input); -__device__ unsigned int __ffs(int input); -__device__ unsigned int __ffsll(long long int input); -__device__ unsigned int __brev( unsigned int input); -__device__ unsigned long long int __brevll( unsigned long long int input); - - -// warp vote function __all __any __ballot -__device__ int __all( int input); -__device__ int __any( int input); -__device__ unsigned long long int __ballot( int input); - // warp shuffle functions #ifdef __cplusplus __device__ int __shfl(int input, int lane, int width=warpSize); diff --git a/projects/hip/src/device_functions.cpp b/projects/hip/src/device_functions.cpp index 01d18d8d28..7fb67b787a 100644 --- a/projects/hip/src/device_functions.cpp +++ b/projects/hip/src/device_functions.cpp @@ -18,6 +18,10 @@ THE SOFTWARE. */ #include +#include +#include +#include +#include "device_util.h" struct holder64Bit{ union{ @@ -358,3 +362,163 @@ __device__ float __ull2float_rz(unsigned long long int x) { return (float)x; } + + + +// integer intrinsic function __poc __clz __ffs __brev +__device__ unsigned int __popc( unsigned int input) +{ + return hc::__popcount_u32_b32(input); +} + +__device__ unsigned int __popcll( unsigned long long int input) +{ + return hc::__popcount_u32_b64(input); +} + +__device__ unsigned int __clz(unsigned int input) +{ +#ifdef NVCC_COMPAT + return input == 0 ? 32 : hc::__firstbit_u32_u32( input); +#else + return hc::__firstbit_u32_u32( input); +#endif +} + +__device__ unsigned int __clzll(unsigned long long int input) +{ +#ifdef NVCC_COMPAT + return input == 0 ? 64 : hc::__firstbit_u32_u64( input); +#else + return hc::__firstbit_u32_u64( input); +#endif +} + +__device__ unsigned int __clz( int input) +{ +#ifdef NVCC_COMPAT + return input == 0 ? 32 : hc::__firstbit_u32_s32( input); +#else + return hc::__firstbit_u32_s32( input); +#endif +} + +__device__ unsigned int __clzll( long long int input) +{ +#ifdef NVCC_COMPAT + return input == 0 ? 64 : hc::__firstbit_u32_s64( input); +#else + return hc::__firstbit_u32_s64( input); +#endif +} + +__device__ unsigned int __ffs(unsigned int input) +{ +#ifdef NVCC_COMPAT + return hc::__lastbit_u32_u32( input)+1; +#else + return hc::__lastbit_u32_u32( input); +#endif +} + +__device__ unsigned int __ffsll(unsigned long long int input) +{ +#ifdef NVCC_COMPAT + return hc::__lastbit_u32_u64( input)+1; +#else + return hc::__lastbit_u32_u64( input); +#endif +} + +__device__ unsigned int __ffs( int input) +{ +#ifdef NVCC_COMPAT + return hc::__lastbit_u32_s32( input)+1; +#else + return hc::__lastbit_u32_s32( input); +#endif +} + +__device__ unsigned int __ffsll( long long int input) +{ +#ifdef NVCC_COMPAT + return hc::__lastbit_u32_s64( input)+1; +#else + return hc::__lastbit_u32_s64( input); +#endif +} + +__device__ unsigned int __brev( unsigned int input) +{ + return hc::__bitrev_b32( input); +} + +__device__ unsigned long long int __brevll( unsigned long long int input) +{ + return hc::__bitrev_b64( input); +} + +struct ucharHolder { + union { + unsigned char c[4]; + unsigned int ui; + }; +}__attribute__((aligned(4))); + +struct uchar2Holder { + union { + unsigned int ui[2]; + unsigned char c[8]; + }; +}__attribute__((aligned(8))); + +struct intHolder { + union { + signed int si[2]; + signed int long sl; + }; +}__attribute__((aligned(8))); + +struct uintHolder { + union { + signed int ui[2]; + signed int long ul; + }; +}__attribute__((aligned(8))); + +struct uchar2Holder cHoldVal; +struct ucharHolder cHoldKey; +struct ucharHolder cHoldOut; + +struct intHolder iHold1; +struct intHolder iHold2; +struct uintHolder uHold1; +struct uintHolder uHold2; + +__device__ unsigned int __byte_perm(unsigned int x, unsigned int y, unsigned int s) +{ + cHoldKey.ui = s; + cHoldVal.ui[0] = x; + cHoldVal.ui[1] = y; + cHoldOut.c[0] = cHoldVal.c[cHoldKey.c[0]]; + cHoldOut.c[1] = cHoldVal.c[cHoldKey.c[1]]; + cHoldOut.c[2] = cHoldVal.c[cHoldKey.c[2]]; + cHoldOut.c[3] = cHoldVal.c[cHoldKey.c[3]]; + return cHoldOut.ui; +} + +__device__ long long __mul64hi(long long int x, long long int y) +{ + iHold1.sl = x; + iHold2.sl = y; + iHold1.sl = iHold1.si[1] * iHold2.si[1]; + return iHold1.sl; +} + +__device__ unsigned long long __umul64hi(unsigned long long int x, unsigned long long int y) +{ + uHold1.ul = x; + uHold2.ul = y; + uHold1.ul = uHold1.ui[1] * uHold2.ui[1]; + return uHold1.ul; +} diff --git a/projects/hip/src/device_util.cpp b/projects/hip/src/device_util.cpp index cf5d6ff5af..e875db1cf9 100644 --- a/projects/hip/src/device_util.cpp +++ b/projects/hip/src/device_util.cpp @@ -1843,117 +1843,7 @@ __device__ unsigned int atomicDec(unsigned int* address, return hc::__atomic_wrapdec(address,val); } -//__mul24 __umul24 -__device__ int __mul24(int arg1, - int arg2) -{ - return hc::__mul24(arg1, arg2); -} -__device__ unsigned int __umul24(unsigned int arg1, - unsigned int arg2) -{ - return hc::__mul24(arg1, arg2); -} -__device__ unsigned int test__popc(unsigned int input) -{ - return hc::__popcount_u32_b32(input); -} - -// integer intrinsic function __poc __clz __ffs __brev -__device__ unsigned int __popc( unsigned int input) -{ - return hc::__popcount_u32_b32(input); -} - -__device__ unsigned int test__popc(unsigned int input); - -__device__ unsigned int __popcll( unsigned long long int input) -{ - return hc::__popcount_u32_b64(input); -} - -__device__ unsigned int __clz(unsigned int input) -{ -#ifdef NVCC_COMPAT - return input == 0 ? 32 : hc::__firstbit_u32_u32( input); -#else - return hc::__firstbit_u32_u32( input); -#endif -} - -__device__ unsigned int __clzll(unsigned long long int input) -{ -#ifdef NVCC_COMPAT - return input == 0 ? 64 : hc::__firstbit_u32_u64( input); -#else - return hc::__firstbit_u32_u64( input); -#endif -} - -__device__ unsigned int __clz( int input) -{ -#ifdef NVCC_COMPAT - return input == 0 ? 32 : hc::__firstbit_u32_s32( input); -#else - return hc::__firstbit_u32_s32( input); -#endif -} - -__device__ unsigned int __clzll( long long int input) -{ -#ifdef NVCC_COMPAT - return input == 0 ? 64 : hc::__firstbit_u32_s64( input); -#else - return hc::__firstbit_u32_s64( input); -#endif -} - -__device__ unsigned int __ffs(unsigned int input) -{ -#ifdef NVCC_COMPAT - return hc::__lastbit_u32_u32( input)+1; -#else - return hc::__lastbit_u32_u32( input); -#endif -} - -__device__ unsigned int __ffsll(unsigned long long int input) -{ -#ifdef NVCC_COMPAT - return hc::__lastbit_u32_u64( input)+1; -#else - return hc::__lastbit_u32_u64( input); -#endif -} - -__device__ unsigned int __ffs( int input) -{ -#ifdef NVCC_COMPAT - return hc::__lastbit_u32_s32( input)+1; -#else - return hc::__lastbit_u32_s32( input); -#endif -} - -__device__ unsigned int __ffsll( long long int input) -{ -#ifdef NVCC_COMPAT - return hc::__lastbit_u32_s64( input)+1; -#else - return hc::__lastbit_u32_s64( input); -#endif -} - -__device__ unsigned int __brev( unsigned int input) -{ - return hc::__bitrev_b32( input); -} - -__device__ unsigned long long int __brevll( unsigned long long int input) -{ - return hc::__bitrev_b64( input); -} // warp vote function __all __any __ballot __device__ int __all( int input) diff --git a/projects/hip/src/hip_ir.ll b/projects/hip/src/hip_ir.ll index 739717c740..a20b57016e 100644 --- a/projects/hip/src/hip_ir.ll +++ b/projects/hip/src/hip_ir.ll @@ -146,4 +146,29 @@ define i32 @__hip_hc_ir_h2trunc_int(i32 %a) #1 { ret i32 %1 } +define i32 @__hip_hc_ir_mul24_int(i32 %a, i32 %b) #1 { + %1 = tail call i32 asm sideeffect "v_mul_i32_i24 $0, $1, $2","=v,v,v"(i32 %a, i32 %b) + ret i32 %1 +} + +define i32 @__hip_hc_ir_umul24_int(i32 %a, i32 %b) #1 { + %1 = tail call i32 asm sideeffect "v_mul_u32_u24 $0, $1, $2","=v,v,v"(i32 %a, i32 %b) + ret i32 %1 +} + +define i32 @__hip_hc_ir_mulhi_int(i32 %a, i32 %b) #1 { + %1 = tail call i32 asm sideeffect "v_mul_hi_i32 $0, $1, $2","=v,v,v"(i32 %a, i32 %b) + ret i32 %1 +} + +define i32 @__hip_hc_ir_umulhi_int(i32 %a, i32 %b) #1 { + %1 = tail call i32 asm sideeffect "v_mul_hi_u32 $0, $1, $2","=v,v,v"(i32 %a, i32 %b) + ret i32 %1 +} + +define i32 @__hip_hc_ir_usad_int(i32 %a, i32 %b, i32 %c) #1 { + %1 = tail call i32 asm sideeffect "v_sad_u32 $0, $1, $2, $3","=v,v,v,v"(i32 %a, i32 %b, i32 %c) + ret i32 %1 +} + attributes #1 = { alwaysinline nounwind } From b2ec4294321da0ef5d26c38976474dfc9c9ee30a Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Tue, 17 Jan 2017 09:00:09 -0600 Subject: [PATCH 073/281] fixed broken tests and device code for integer intrinsics 1. Fixed build issues with new Integer intrinsics 2. Changed tests to work exactly as CUDA code 3. Still some integer intrinsics need to be supported Change-Id: Ie6f4171259cf4da517436895d4f6f01e01f59b11 [ROCm/hip commit: c0fd0921cbb1c25553c258ea65d44c2f7721b4cb] --- .../include/hip/hcc_detail/device_functions.h | 13 ++++--------- .../hip/include/hip/hcc_detail/hip_runtime.h | 5 +++++ .../tests/src/deviceLib/hipIntegerIntrinsics.cpp | 1 + projects/hip/tests/src/deviceLib/hip_ballot.cpp | 16 +++++++++------- projects/hip/tests/src/deviceLib/hip_brev.cpp | 3 +-- projects/hip/tests/src/deviceLib/hip_clz.cpp | 2 +- projects/hip/tests/src/deviceLib/hip_ffs.cpp | 3 +-- projects/hip/tests/src/deviceLib/hip_popc.cpp | 3 +-- 8 files changed, 23 insertions(+), 23 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/device_functions.h b/projects/hip/include/hip/hcc_detail/device_functions.h index 8eb9d6a46c..bed206c0ed 100644 --- a/projects/hip/include/hip/hcc_detail/device_functions.h +++ b/projects/hip/include/hip/hcc_detail/device_functions.h @@ -44,21 +44,21 @@ __device__ static inline int __mul24(int x, int y) return __hip_hc_ir_mul24_int(x, y); } __device__ long long int __mul64hi(long long int x, long long int y); -__device__ int __mulhi(int x, int y) +__device__ static inline int __mulhi(int x, int y) { return __hip_hc_ir_mulhi_int(x, y); } __device__ unsigned int __popc( unsigned int x); __device__ unsigned int __popcll( unsigned long long int x); -__device__ int __rhadd(int x, int y) +__device__ static inline int __rhadd(int x, int y) { return (x + y + 1) >> 1; } //__device__ unsigned int __sad(int x, int y, int z); /* -Implemented signed version of sad +Implement signed version of sad */ -__device__ unsigned int __uhadd(unsigned int x, unsigned int y) +__device__ static inline unsigned int __uhadd(unsigned int x, unsigned int y) { return (x + y) >> 1; } @@ -71,11 +71,6 @@ __device__ unsigned int __umulhi(unsigned int x, unsigned int y); __device__ unsigned int __urhadd(unsigned int x, unsigned int y); __device__ unsigned int __usad(unsigned int x, unsigned int y, unsigned int z); -// warp vote function __all __any __ballot -__device__ int __all( int input); -__device__ int __any( int input); -__device__ unsigned long long int __ballot( int input); - /* Rounding modes are not yet supported in HIP */ diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime.h b/projects/hip/include/hip/hcc_detail/hip_runtime.h index f6967c3445..e911d17ebb 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime.h @@ -420,6 +420,11 @@ __device__ unsigned int atomicInc(unsigned int* address, __device__ unsigned int atomicDec(unsigned int* address, unsigned int val); + // warp vote function __all __any __ballot +__device__ int __all( int input); +__device__ int __any( int input); +__device__ unsigned long long int __ballot( int input); + // warp shuffle functions #ifdef __cplusplus __device__ int __shfl(int input, int lane, int width=warpSize); diff --git a/projects/hip/tests/src/deviceLib/hipIntegerIntrinsics.cpp b/projects/hip/tests/src/deviceLib/hipIntegerIntrinsics.cpp index abe0b66e90..f9328e7a2c 100644 --- a/projects/hip/tests/src/deviceLib/hipIntegerIntrinsics.cpp +++ b/projects/hip/tests/src/deviceLib/hipIntegerIntrinsics.cpp @@ -20,6 +20,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "hip/hip_runtime.h" +#include "hip/device_functions.h" #include "test_common.h" #pragma GCC diagnostic ignored "-Wall" diff --git a/projects/hip/tests/src/deviceLib/hip_ballot.cpp b/projects/hip/tests/src/deviceLib/hip_ballot.cpp index 236ceb57fe..629e676bc7 100644 --- a/projects/hip/tests/src/deviceLib/hip_ballot.cpp +++ b/projects/hip/tests/src/deviceLib/hip_ballot.cpp @@ -26,9 +26,11 @@ THE SOFTWARE. #include #include "hip/hip_runtime.h" +#include "hip/device_functions.h" + #define HIP_ASSERT(x) (assert((x)==hipSuccess)) -__global__ void +__global__ void gpu_ballot(hipLaunchParm lp, unsigned int* device_ballot, int Num_Warps_per_Block,int pshift) { @@ -39,7 +41,7 @@ __global__ void #else atomicAdd(&device_ballot[warp_num+hipBlockIdx_x*Num_Warps_per_Block],__popc(__ballot(tid - 245))); #endif - + } @@ -47,24 +49,24 @@ int main(int argc, char *argv[]) { int warpSize, pshift; hipDeviceProp_t devProp; hipGetDeviceProperties(&devProp, 0); - + warpSize = devProp.warpSize; int w = warpSize; - pshift = 0; + pshift = 0; while (w >>= 1) ++pshift; - + unsigned int Num_Threads_per_Block = 512; unsigned int Num_Blocks_per_Grid = 1; unsigned int Num_Warps_per_Block = Num_Threads_per_Block/warpSize; unsigned int Num_Warps_per_Grid = (Num_Threads_per_Block*Num_Blocks_per_Grid)/warpSize; unsigned int* host_ballot = (unsigned int*)malloc(Num_Warps_per_Grid*sizeof(unsigned int)); - unsigned int* device_ballot; + unsigned int* device_ballot; HIP_ASSERT(hipMalloc((void**)&device_ballot, Num_Warps_per_Grid*sizeof(unsigned int))); int divergent_count =0; for (int i=0; i #include #include "hip/hip_runtime.h" - +#include "hip/device_functions.h" #define HIP_ASSERT(x) (assert((x)==hipSuccess)) @@ -181,4 +181,3 @@ int main() { return errors; } - diff --git a/projects/hip/tests/src/deviceLib/hip_clz.cpp b/projects/hip/tests/src/deviceLib/hip_clz.cpp index 5c60b29a2d..869f4406f5 100644 --- a/projects/hip/tests/src/deviceLib/hip_clz.cpp +++ b/projects/hip/tests/src/deviceLib/hip_clz.cpp @@ -32,6 +32,7 @@ THE SOFTWARE. #include #include #include "hip/hip_runtime.h" +#include "hip/device_functions.h" #define HIP_ASSERT(x) (assert((x)==hipSuccess)) #define WIDTH 8 @@ -188,4 +189,3 @@ int main() { return errors; } - diff --git a/projects/hip/tests/src/deviceLib/hip_ffs.cpp b/projects/hip/tests/src/deviceLib/hip_ffs.cpp index dfdc439a21..ba9bd7b9a0 100644 --- a/projects/hip/tests/src/deviceLib/hip_ffs.cpp +++ b/projects/hip/tests/src/deviceLib/hip_ffs.cpp @@ -32,7 +32,7 @@ THE SOFTWARE. #include #include #include "hip/hip_runtime.h" - +#include "hip/device_functions.h" #define HIP_ASSERT(x) (assert((x)==hipSuccess)) @@ -184,4 +184,3 @@ int main() { return errors; } - diff --git a/projects/hip/tests/src/deviceLib/hip_popc.cpp b/projects/hip/tests/src/deviceLib/hip_popc.cpp index b40bbd2000..6fe214c7fa 100644 --- a/projects/hip/tests/src/deviceLib/hip_popc.cpp +++ b/projects/hip/tests/src/deviceLib/hip_popc.cpp @@ -32,7 +32,7 @@ THE SOFTWARE. #include #include #include "hip/hip_runtime.h" - +#include "hip/device_functions.h" #define HIP_ASSERT(x) (assert((x)==hipSuccess)) @@ -172,4 +172,3 @@ int main() { return errors; } - From 675ecdd54c3156d3562587c0b7bf06d194cc029e Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Tue, 17 Jan 2017 09:27:51 -0600 Subject: [PATCH 074/281] added last few integer intrinsic support 1. Added usad, umulhi, urhadd 2. Corrected implementation of __hadd, __hradd 3. TODO: __sad(). It gets tricky as ISA sees them as unsigned Change-Id: Ibd2c2133b462f9393f3990355706386c79256bba [ROCm/hip commit: 02c7f3a70fff8df3bf482e014ad74ea2279cd7a2] --- .../include/hip/hcc_detail/device_functions.h | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/device_functions.h b/projects/hip/include/hip/hcc_detail/device_functions.h index bed206c0ed..fb5a1a6c18 100644 --- a/projects/hip/include/hip/hcc_detail/device_functions.h +++ b/projects/hip/include/hip/hcc_detail/device_functions.h @@ -27,6 +27,7 @@ extern "C" unsigned int __hip_hc_ir_umul24_int(unsigned int, unsigned int); extern "C" signed int __hip_hc_ir_mul24_int(signed int, signed int); extern "C" signed int __hip_hc_ir_mulhi_int(signed int, signed int); extern "C" unsigned int __hip_hc_ir_umulhi_int(unsigned int, unsigned int); +extern "C" unsigned int __hip_hc_ir_usad_int(unsigned int, unsigned int, unsigned int); // integer intrinsic function __poc __clz __ffs __brev __device__ unsigned int __brev( unsigned int x); __device__ unsigned long long int __brevll( unsigned long long int x); @@ -37,7 +38,10 @@ __device__ unsigned int __ffs(int x); __device__ unsigned int __ffsll(long long int x); __device__ static inline unsigned int __hadd(int x, int y) { - return (x + y) >> 1; + int z = x + y; + int sign = z & 0x8000000; + int value = z & 0x7FFFFFFF; + return ((value) >> 1 || sign); } __device__ static inline int __mul24(int x, int y) { @@ -52,7 +56,10 @@ __device__ unsigned int __popc( unsigned int x); __device__ unsigned int __popcll( unsigned long long int x); __device__ static inline int __rhadd(int x, int y) { - return (x + y + 1) >> 1; + int z = x + y + 1; + int sign = z & 0x8000000; + int value = z & 0x7FFFFFFF; + return ((value) >> 1 || sign); } //__device__ unsigned int __sad(int x, int y, int z); /* @@ -67,9 +74,18 @@ __device__ static inline int __umul24(unsigned int x, unsigned int y) return __hip_hc_ir_umul24_int(x, y); } __device__ unsigned long long int __umul64hi(unsigned long long int x, unsigned long long int y); -__device__ unsigned int __umulhi(unsigned int x, unsigned int y); -__device__ unsigned int __urhadd(unsigned int x, unsigned int y); -__device__ unsigned int __usad(unsigned int x, unsigned int y, unsigned int z); +__device__ static inline unsigned int __umulhi(unsigned int x, unsigned int y) +{ + return __hip_hc_ir_umulhi_int(x, y); +} +__device__ static inline unsigned int __urhadd(unsigned int x, unsigned int y) +{ + return (x + y + 1) >> 1; +} +__device__ static inline unsigned int __usad(unsigned int x, unsigned int y, unsigned int z) +{ + return __hip_hc_ir_usad_int(x, y, z); +} /* Rounding modes are not yet supported in HIP From ea01905ceec821ce5eec4706fd7617d667798121 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Tue, 17 Jan 2017 09:59:08 -0600 Subject: [PATCH 075/281] enabled integer intrinsics tests Change-Id: I5d28d556f228240eda2fc0098121ed3b29b041e7 [ROCm/hip commit: 13ce9ece77f6109efc09dd7fdc1ba9181dc56894] --- .../include/hip/hcc_detail/device_functions.h | 12 ++++++---- projects/hip/src/device_functions.cpp | 19 ++++++++------- .../src/deviceLib/hipIntegerIntrinsics.cpp | 24 +++++++++---------- 3 files changed, 29 insertions(+), 26 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/device_functions.h b/projects/hip/include/hip/hcc_detail/device_functions.h index fb5a1a6c18..06beeb23f8 100644 --- a/projects/hip/include/hip/hcc_detail/device_functions.h +++ b/projects/hip/include/hip/hcc_detail/device_functions.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights @@ -28,6 +28,7 @@ extern "C" signed int __hip_hc_ir_mul24_int(signed int, signed int); extern "C" signed int __hip_hc_ir_mulhi_int(signed int, signed int); extern "C" unsigned int __hip_hc_ir_umulhi_int(unsigned int, unsigned int); extern "C" unsigned int __hip_hc_ir_usad_int(unsigned int, unsigned int, unsigned int); + // integer intrinsic function __poc __clz __ffs __brev __device__ unsigned int __brev( unsigned int x); __device__ unsigned long long int __brevll( unsigned long long int x); @@ -61,10 +62,11 @@ __device__ static inline int __rhadd(int x, int y) int value = z & 0x7FFFFFFF; return ((value) >> 1 || sign); } -//__device__ unsigned int __sad(int x, int y, int z); -/* -Implement signed version of sad -*/ +__device__ static inline unsigned int __sad(int x, int y, int z) +{ + return x > y ? x - y + z : y - x + z; +} + __device__ static inline unsigned int __uhadd(unsigned int x, unsigned int y) { return (x + y) >> 1; diff --git a/projects/hip/src/device_functions.cpp b/projects/hip/src/device_functions.cpp index 7fb67b787a..4b0eb9a5ff 100644 --- a/projects/hip/src/device_functions.cpp +++ b/projects/hip/src/device_functions.cpp @@ -363,7 +363,9 @@ __device__ float __ull2float_rz(unsigned long long int x) return (float)x; } - +/* +Integer Intrinsics +*/ // integer intrinsic function __poc __clz __ffs __brev __device__ unsigned int __popc( unsigned int input) @@ -486,17 +488,12 @@ struct uintHolder { }; }__attribute__((aligned(8))); -struct uchar2Holder cHoldVal; -struct ucharHolder cHoldKey; -struct ucharHolder cHoldOut; - -struct intHolder iHold1; -struct intHolder iHold2; -struct uintHolder uHold1; -struct uintHolder uHold2; __device__ unsigned int __byte_perm(unsigned int x, unsigned int y, unsigned int s) { + struct uchar2Holder cHoldVal; + struct ucharHolder cHoldKey; + struct ucharHolder cHoldOut; cHoldKey.ui = s; cHoldVal.ui[0] = x; cHoldVal.ui[1] = y; @@ -509,6 +506,8 @@ __device__ unsigned int __byte_perm(unsigned int x, unsigned int y, unsigned int __device__ long long __mul64hi(long long int x, long long int y) { + struct intHolder iHold1; + struct intHolder iHold2; iHold1.sl = x; iHold2.sl = y; iHold1.sl = iHold1.si[1] * iHold2.si[1]; @@ -517,6 +516,8 @@ __device__ long long __mul64hi(long long int x, long long int y) __device__ unsigned long long __umul64hi(unsigned long long int x, unsigned long long int y) { + struct uintHolder uHold1; + struct uintHolder uHold2; uHold1.ul = x; uHold2.ul = y; uHold1.ul = uHold1.ui[1] * uHold2.ui[1]; diff --git a/projects/hip/tests/src/deviceLib/hipIntegerIntrinsics.cpp b/projects/hip/tests/src/deviceLib/hipIntegerIntrinsics.cpp index f9328e7a2c..63530574d8 100644 --- a/projects/hip/tests/src/deviceLib/hipIntegerIntrinsics.cpp +++ b/projects/hip/tests/src/deviceLib/hipIntegerIntrinsics.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -30,27 +30,27 @@ __device__ void integer_intrinsics() { __brev((unsigned int)10); __brevll((unsigned long long)10); - //__byte_perm((unsigned int)0, (unsigned int)0, 0); + __byte_perm((unsigned int)0, (unsigned int)0, 0); __clz((int)10); __clzll((long long)10); __ffs((int)10); __ffsll((long long)10); - //__hadd((int)1, (int)3); + __hadd((int)1, (int)3); __mul24((int)1, (int)2); - //__mul64hi((long long)1, (long long)2); - //__mulhi((int)1, (int)2); + __mul64hi((long long)1, (long long)2); + __mulhi((int)1, (int)2); __popc((unsigned int)4); __popcll((unsigned long long)4); int a = min((int)4, (int)5); int b = max((int)4, (int)5); - //__rhadd((int)1, (int)2); - //__sad((int)1, (int)2, 0); - //__uhadd((unsigned int)1, (unsigned int)3); + __rhadd((int)1, (int)2); + __sad((int)1, (int)2, 0); + __uhadd((unsigned int)1, (unsigned int)3); __umul24((unsigned int)1, (unsigned int)2); - //__umul64hi((unsigned long long)1, (unsigned long long)2); - //__umulhi((unsigned int)1, (unsigned int)2); - //__urhadd((unsigned int)1, (unsigned int)2); - //__usad((unsigned int)1, (unsigned int)2, 0); + __umul64hi((unsigned long long)1, (unsigned long long)2); + __umulhi((unsigned int)1, (unsigned int)2); + __urhadd((unsigned int)1, (unsigned int)2); + __usad((unsigned int)1, (unsigned int)2, 0); } __global__ void compileIntegerIntrinsics(hipLaunchParm lp, int ignored) From 77401c9b642d7d628210586f1c2beca9458f1224 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Tue, 17 Jan 2017 14:57:51 -0600 Subject: [PATCH 076/281] Moved device code to mimic cuda header behavior 1. All fp32, fp64 math device/host functions should be in math_functions.h/.cpp 2. All fp32, fp64 fast math intrinsics for device/host functions should be in device_functions.h/.cpp 3. All the device code implementations should be in device_util.h/.cpp 4. Hence, made changes appropriately by moving code and creating new header files 5. Added math_functions.cpp/.h 6. Changed #ifndef signature to make sure no conflicts between headers with same names in hip/hip_runtime.h and hip/hcc_detail/hip_runtime.h 7. Changed tests to fit the code changes, making them to include appropriate headers 8. Added math_functions.cpp to CMakeLists.txt 9. Some of the tests are still broken, mostly host math functions will fix them in next commit 10. TODO: FIX compilation issues for host math functions Change-Id: I7a17637d7e294a7d224ffba932c1a08668febd26 [ROCm/hip commit: b723169ee9517cf36ae1ca38dec821233a37767e] --- projects/hip/CMakeLists.txt | 3 +- .../include/hip/hcc_detail/device_functions.h | 167 +++ .../hip/include/hip/hcc_detail/hip_fp16.h | 8 +- .../hip/include/hip/hcc_detail/hip_runtime.h | 448 -------- .../include/hip/hcc_detail/math_functions.h | 288 +++++ projects/hip/include/hip/math_functions.h | 49 + projects/hip/src/device_functions.cpp | 68 ++ projects/hip/src/device_util.cpp | 1008 +---------------- projects/hip/src/device_util.h | 117 ++ projects/hip/src/math_functions.cpp | 971 ++++++++++++++++ .../hipDoublePrecisionIntrinsics.cpp | 35 +- .../hipDoublePrecisionMathDevice.cpp | 21 +- .../deviceLib/hipDoublePrecisionMathHost.cpp | 5 +- .../hip/tests/src/deviceLib/hipFloatMath.cpp | 1 + .../src/deviceLib/hipFloatMathPrecise.cpp | 3 +- .../src/deviceLib/hipIntegerIntrinsics.cpp | 4 +- .../hipSinglePrecisionIntrinsics.cpp | 59 +- .../hipSinglePrecisionMathDevice.cpp | 3 +- .../deviceLib/hipSinglePrecisionMathHost.cpp | 3 +- .../hip/tests/src/deviceLib/hipTestDevice.cpp | 5 +- .../src/deviceLib/hipTestDeviceDouble.cpp | 5 +- .../hip/tests/src/deviceLib/hip_anyall.cpp | 3 +- .../hip/tests/src/deviceLib/hip_ballot.cpp | 4 +- projects/hip/tests/src/deviceLib/hip_brev.cpp | 2 +- projects/hip/tests/src/deviceLib/hip_clz.cpp | 2 +- projects/hip/tests/src/deviceLib/hip_ffs.cpp | 4 +- projects/hip/tests/src/deviceLib/hip_popc.cpp | 4 +- projects/hip/tests/src/deviceLib/hip_trig.cpp | 3 +- .../runtimeApi/stream/hipAPIStreamDisable.cpp | 3 +- .../runtimeApi/stream/hipAPIStreamEnable.cpp | 3 +- 30 files changed, 1759 insertions(+), 1540 deletions(-) create mode 100644 projects/hip/include/hip/hcc_detail/math_functions.h create mode 100644 projects/hip/include/hip/math_functions.h create mode 100644 projects/hip/src/math_functions.cpp diff --git a/projects/hip/CMakeLists.txt b/projects/hip/CMakeLists.txt index 1168b65be2..cbd2050025 100644 --- a/projects/hip/CMakeLists.txt +++ b/projects/hip/CMakeLists.txt @@ -181,7 +181,8 @@ if(HIP_PLATFORM STREQUAL "hcc") src/device_util.cpp src/hip_ldg.cpp src/hip_fp16.cpp - src/device_functions.cpp) + src/device_functions.cpp + src/math_functions.cpp) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -L${HCC_HOME}/lib -lmcwamp -Wl,-Bsymbolic -Wl,-rpath ${HCC_HOME}/lib") add_library(hip_hcc SHARED ${SOURCE_FILES_RUNTIME}) diff --git a/projects/hip/include/hip/hcc_detail/device_functions.h b/projects/hip/include/hip/hcc_detail/device_functions.h index 06beeb23f8..0489a72c8b 100644 --- a/projects/hip/include/hip/hcc_detail/device_functions.h +++ b/projects/hip/include/hip/hcc_detail/device_functions.h @@ -23,6 +23,173 @@ THE SOFTWARE. #include #include +// Single Precision Fast Math +extern __attribute__((const)) float __hip_fast_cosf(float) __asm("llvm.cos.f32"); +extern __attribute__((const)) float __hip_fast_exp2f(float) __asm("llvm.exp2.f32"); +__device__ float __hip_fast_exp10f(float); +__device__ float __hip_fast_expf(float); +__device__ float __hip_fast_frsqrt_rn(float); +extern __attribute__((const)) float __hip_fast_fsqrt_rd(float) __asm("llvm.sqrt.f32"); +__device__ float __hip_fast_fsqrt_rn(float); +__device__ float __hip_fast_fsqrt_ru(float); +__device__ float __hip_fast_fsqrt_rz(float); +__device__ float __hip_fast_log10f(float); +extern __attribute__((const)) float __hip_fast_log2f(float) __asm("llvm.log2.f32"); +__device__ float __hip_fast_logf(float); +__device__ float __hip_fast_powf(float, float); +__device__ void __hip_fast_sincosf(float,float*,float*); +extern __attribute__((const)) float __hip_fast_sinf(float) __asm("llvm.sin.f32"); +__device__ float __hip_fast_tanf(float); +extern __attribute__((const)) float __hip_fast_fmaf(float,float,float) __asm("llvm.fma.f32"); +extern __attribute__((const)) float __hip_fast_frcp(float) __asm("llvm.amdgcn.rcp.f32"); + +extern __attribute__((const)) double __hip_fast_dsqrt(double) __asm("llvm.sqrt.f64"); +extern __attribute__((const)) double __hip_fast_fma(double,double,double) __asm("llvm.fma.f64"); +extern __attribute__((const)) double __hip_fast_drcp(double) __asm("llvm.amdgcn.rcp.f64"); + + +// Single Precision Fast Math +__device__ inline float __cosf(float x) { + return __hip_fast_cosf(x); +} + +__device__ inline float __exp10f(float x) { + return __hip_fast_exp10f(x); +} + +__device__ inline float __expf(float x) { + return __hip_fast_expf(x); +} + +__device__ inline float __frsqrt_rn(float x) { + return __hip_fast_frsqrt_rn(x); +} + +__device__ inline float __fsqrt_rd(float x) { + return __hip_fast_fsqrt_rd(x); +} + +__device__ inline float __fsqrt_rn(float x) { + return __hip_fast_fsqrt_rn(x); +} + +__device__ inline float __fsqrt_ru(float x) { + return __hip_fast_fsqrt_ru(x); +} + +__device__ inline float __fsqrt_rz(float x) { + return __hip_fast_fsqrt_rz(x); +} + +__device__ inline float __log10f(float x) { + return __hip_fast_log10f(x); +} + +__device__ inline float __log2f(float x) { + return __hip_fast_log2f(x); +} + +__device__ inline float __logf(float x) { + return __hip_fast_logf(x); +} + +__device__ inline float __powf(float base, float exponent) { + return __hip_fast_powf(base, exponent); +} + +__device__ inline void __sincosf(float x, float *s, float *c) { + return __hip_fast_sincosf(x, s, c); +} + +__device__ inline float __sinf(float x) { + return __hip_fast_sinf(x); +} + +__device__ inline float __tanf(float x) { + return __hip_fast_tanf(x); +} + +__device__ inline float __fmaf_rd(float x, float y, float z) { + return __hip_fast_fmaf(x, y, z); +} + +__device__ inline float __fmaf_rn(float x, float y, float z) { + return __hip_fast_fmaf(x, y, z); +} + +__device__ inline float __fmaf_ru(float x, float y, float z) { + return __hip_fast_fmaf(x, y, z); +} + +__device__ inline float __fmaf_rz(float x, float y, float z) { + return __hip_fast_fmaf(x, y, z); +} + +__device__ inline float __frcp_rd(float x) { + return __hip_fast_frcp(x); +} + +__device__ inline float __frcp_rn(float x) { + return __hip_fast_frcp(x); +} + +__device__ inline float __frcp_ru(float x) { + return __hip_fast_frcp(x); +} + +__device__ inline float __frcp_rz(float x) { + return __hip_fast_frcp(x); +} + +__device__ inline double __dsqrt_rd(double x) { + return __hip_fast_dsqrt(x); +} + +__device__ inline double __dsqrt_rn(double x) { + return __hip_fast_dsqrt(x); +} + +__device__ inline double __dsqrt_ru(double x) { + return __hip_fast_dsqrt(x); +} + +__device__ inline double __dsqrt_rz(double x) { + return __hip_fast_dsqrt(x); +} + +__device__ inline double __fma_rd(double x, double y, double z) { + return __hip_fast_fma(x, y, z); +} + +__device__ inline double __fma_rn(double x, double y, double z) { + return __hip_fast_fma(x, y, z); +} + +__device__ inline double __fma_ru(double x, double y, double z) { + return __hip_fast_fma(x, y, z); +} + +__device__ inline double __fma_rz(double x, double y, double z) { + return __hip_fast_fma(x, y, z); +} + +__device__ inline double __drcp_rd(double x) { + return __hip_fast_drcp(x); +} + +__device__ inline double __drcp_rn(double x) { + return __hip_fast_drcp(x); +} + +__device__ inline double __drcp_ru(double x) { + return __hip_fast_drcp(x); +} + +__device__ inline double __drcp_rz(double x) { + return __hip_fast_drcp(x); +} + + extern "C" unsigned int __hip_hc_ir_umul24_int(unsigned int, unsigned int); extern "C" signed int __hip_hc_ir_mul24_int(signed int, signed int); extern "C" signed int __hip_hc_ir_mulhi_int(signed int, signed int); diff --git a/projects/hip/include/hip/hcc_detail/hip_fp16.h b/projects/hip/include/hip/hcc_detail/hip_fp16.h index 755cb19f6d..73049eb5fb 100644 --- a/projects/hip/include/hip/hcc_detail/hip_fp16.h +++ b/projects/hip/include/hip/hcc_detail/hip_fp16.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef HIP_FP16_H -#define HIP_FP16_H +#ifndef HIP_HCC_DETAIL_FP16_H +#define HIP_HCC_DETAIL_FP16_H #include "hip/hip_runtime.h" @@ -452,8 +452,6 @@ typedef struct __attribute__((aligned(4))){ } __half2; - - #endif diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime.h b/projects/hip/include/hip/hcc_detail/hip_runtime.h index e911d17ebb..f11846a0da 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime.h @@ -121,208 +121,6 @@ extern int HIP_TRACE_API; #define __HCC_C__ #endif -__device__ float acosf(float x); -__device__ float acoshf(float x); -__device__ float asinf(float x); -__device__ float asinhf(float x); -__device__ float atan2f(float y, float x); -__device__ float atanf(float x); -__device__ float atanhf(float x); -__device__ float cbrtf(float x); -__device__ float ceilf(float x); -__device__ float copysignf(float x, float y); -__device__ float coshf(float x); -__device__ float cyl_bessel_i0f(float x); -__device__ float cyl_bessel_i1f(float x); -__device__ float erfcf(float x); -__device__ float erfcinvf(float y); - -__device__ float erfcxf(float x); -__device__ float erff(float x); -__device__ float erfinvf(float y); -__device__ float exp2f(float x); -__device__ float expm1f(float x); -__device__ float fabsf(float x); -__device__ float fdimf(float x, float y); -__device__ __host__ float fdividef(float x, float y); -__device__ float floorf(float x); -__device__ float fmaf(float x, float y, float z); -__device__ float fmaxf(float x, float y); -__device__ float fminf(float x, float y); -__device__ float fmodf(float x, float y); -__device__ float frexpf(float x, float y); -__device__ float hypotf(float x, float y); -__device__ float ilogbf(float x); -__host__ __device__ unsigned isfinite(float a); -__device__ unsigned isinf(float a); -__device__ unsigned isnan(float a); -__device__ float j0f(float x); -__device__ float j1f(float x); -__device__ float jnf(int n, float x); -__device__ float ldexpf(float x, int exp); -__device__ float lgammaf(float x); -__device__ long long int llrintf(float x); -__device__ long long int llroundf(float x); -__device__ float log1pf(float x); -__device__ float logbf(float x); -__device__ long int lrintf(float x); -__device__ long int lroundf(float x); -__device__ float modff(float x, float *iptr); -__device__ float nanf(const char* tagp); -__device__ float nearbyintf(float x); -__device__ float nextafterf(float x, float y); -__device__ float norm3df(float a, float b, float c); -__device__ float norm4df(float a, float b, float c, float d); -__device__ float normcdff(float y); -__device__ float normcdfinvf(float y); -__device__ float normf(int dim, const float *a); -__device__ float rcbrtf(float x); -__device__ float remainderf(float x, float y); -__device__ float remquof(float x, float y, int *quo); -__device__ float rhypotf(float x, float y); -__device__ float rintf(float x); -__device__ float rnorm3df(float a, float b, float c); -__device__ float rnorm4df(float a, float b, float c, float d); -__device__ float rnormf(int dim, const float* a); -__device__ float roundf(float x); -__device__ float rsqrtf(float x); -__device__ float scalblnf(float x, long int n); -__device__ float scalbnf(float x, int n); -__host__ __device__ unsigned signbit(float a); -__device__ void sincospif(float x, float *sptr, float *cptr); -__device__ float sinhf(float x); -__device__ float sinpif(float x); -__device__ float sqrtf(float x); -__device__ float tanhf(float x); -__device__ float tgammaf(float x); -__device__ float truncf(float x); -__device__ float y0f(float x); -__device__ float y1f(float x); -__device__ float ynf(int n, float x); - -__host__ __device__ float cospif(float x); -__host__ __device__ float sinpif(float x); -// /__device__ float sqrtf(float x); -__host__ __device__ float rsqrtf(float x); -__host__ float normcdff(float y); - -__host__ float erfcinvf(float y); -__host__ float erfcxf(float x); -__host__ float erfinvf(float y); -__host__ float norm3df(float a, float b, float c); -__host__ float normcdfinvf(float y); -__host__ float norm4df(float a, float b, float c, float d); -__host__ float rcbrtf(float x); -__host__ float rhypotf(float x, float y); -__host__ float rnorm3df(float a, float b, float c); -__host__ float rnormf(int dim, const float* a); -__host__ float rnorm4df(float a, float b, float c, float d); -__host__ void sincospif(float x, float *sptr, float *cptr); - -__device__ double acos(double x); -__device__ double acosh(double x); -__device__ double asin(double x); -__device__ double asinh(double x); -__device__ double atan(double x); -__device__ double atan2(double y, double x); -__device__ double atanh(double x); -__device__ double cbrt(double x); -__device__ double ceil(double x); -__device__ double copysign(double x, double y); -__device__ double cos(double x); -__device__ double cosh(double x); -__host__ __device__ double cospi(double x); -__device__ double cyl_bessel_i0(double x); -__device__ double cyl_bessel_i1(double x); -__device__ double erf(double x); -__device__ double erfc(double x); -__device__ double erfcinv(double y); -__device__ double erfcx(double x); -__device__ double erfinv(double x); -__device__ double exp(double x); -__device__ double exp10(double x); -__device__ double exp2(double x); -__device__ double expm1(double x); -__device__ double fabs(double x); -__device__ double fdim(double x, double y); -__device__ double fdivide(double x, double y); -__device__ double floor(double x); -__device__ double fma(double x, double y, double z); -__device__ double fmax(double x, double y); -__device__ double fmin(double x, double y); -__device__ double fmod(double x, double y); -__device__ double frexp(double x, int *nptr); -__device__ double hypot(double x, double y); -__device__ double ilogb(double x); -__host__ __device__ unsigned isfinite(double x); -__device__ unsigned isinf(double x); -__device__ unsigned isnan(double x); -__device__ double j0(double x); -__device__ double j1(double x); -__device__ double jn(int n, double x); -__device__ double ldexp(double x, int exp); -__device__ double lgamma(double x); -__device__ long long llrint(double x); -__device__ long long llround(double x); -__device__ double log(double x); -__device__ double log10(double x); -__device__ double log1p(double x); -__device__ double log2(double x); -__device__ double logb(double x); -__device__ long int lrint(double x); -__device__ long int lround(double x); -__device__ double modf(double x, double *iptr); -__device__ double nan(const char* tagp); -__device__ double nearbyint(double x); -__device__ double nextafter(double x, double y); -__device__ double norm(int dim, const double* t); -__device__ double norm3d(double a, double b, double c); -__host__ double norm3d(double a, double b, double c); -__device__ double norm4d(double a, double b, double c, double d); -__host__ double norm4d(double a, double b, double c, double d); -__device__ double normcdf(double y); -__host__ double normcdf(double y); -__device__ double normcdfinv(double y); -__host__ double normcdfinv(double y); -__device__ double pow(double x, double y); -__device__ double rcbrt(double x); -__host__ double rcbrt(double x); -__device__ double remainder(double x, double y); -__device__ double remquo(double x, double y, int *quo); -__device__ double rhypot(double x, double y); -__host__ double rhypot(double x, double y); -__device__ double rint(double x); -__device__ double rnorm(int dim, const double* t); -__host__ double rnorm(int dim, const double* t); -__device__ double rnorm3d(double a, double b, double c); -__host__ double rnorm3d(double a, double b, double c); -__device__ double rnorm4d(double a, double b, double c, double d); -__host__ double rnorm4d(double a, double b, double c, double d); -__device__ double round(double x); -__host__ __device__ double rsqrt(double x); -__device__ double scalbln(double x, long int n); -__device__ double scalbn(double x, int n); -__host__ __device__ unsigned signbit(double a); -__device__ double sin(double a); -__device__ void sincos(double x, double *sptr, double *cptr); -__device__ void sincospi(double x, double *sptr, double *cptr); -__host__ void sincospi(double x, double *sptr, double *cptr); -__device__ double sinh(double x); -__host__ __device__ double sinpi(double x); -__device__ double sqrt(double x); -__device__ double tan(double x); -__device__ double tanh(double x); -__device__ double tgamma(double x); -__device__ double trunc(double x); -__device__ double y0(double x); -__device__ double y1(double y); -__device__ double yn(int n, double x); - -__host__ double erfcinv(double y); -__host__ double erfcx(double x); -__host__ double erfinv(double y); -__host__ double fdivide(double x, double y); - // TODO - hipify-clang - change to use the function call. //#define warpSize hc::__wavesize() extern const int warpSize; @@ -451,252 +249,6 @@ __host__ __device__ int max(int arg1, int arg2); __device__ __attribute__((address_space(3))) void* __get_dynamicgroupbaseptr(); -//TODO - add a couple fast math operations here, the set here will grow : - -// Single Precision Precise Math -__device__ float __hip_precise_cosf(float); -__device__ float __hip_precise_exp10f(float); -__device__ float __hip_precise_expf(float); -__device__ float __hip_precise_frsqrt_rn(float); -__device__ float __hip_precise_fsqrt_rd(float); -__device__ float __hip_precise_fsqrt_rn(float); -__device__ float __hip_precise_fsqrt_ru(float); -__device__ float __hip_precise_fsqrt_rz(float); -__device__ float __hip_precise_log10f(float); -__device__ float __hip_precise_log2f(float); -__device__ float __hip_precise_logf(float); -__device__ float __hip_precise_powf(float, float); -__device__ void __hip_precise_sincosf(float,float*,float*); -__device__ float __hip_precise_sinf(float); -__device__ float __hip_precise_tanf(float); - -// Double Precision Precise Math -__device__ double __hip_precise_dsqrt_rd(double); -__device__ double __hip_precise_dsqrt_rn(double); -__device__ double __hip_precise_dsqrt_ru(double); -__device__ double __hip_precise_dsqrt_rz(double); - -// Single Precision Fast Math -extern __attribute__((const)) float __hip_fast_cosf(float) __asm("llvm.cos.f32"); -extern __attribute__((const)) float __hip_fast_exp2f(float) __asm("llvm.exp2.f32"); -__device__ float __hip_fast_exp10f(float); -__device__ float __hip_fast_expf(float); -__device__ float __hip_fast_frsqrt_rn(float); -extern __attribute__((const)) float __hip_fast_fsqrt_rd(float) __asm("llvm.sqrt.f32"); -__device__ float __hip_fast_fsqrt_rn(float); -__device__ float __hip_fast_fsqrt_ru(float); -__device__ float __hip_fast_fsqrt_rz(float); -__device__ float __hip_fast_log10f(float); -extern __attribute__((const)) float __hip_fast_log2f(float) __asm("llvm.log2.f32"); -__device__ float __hip_fast_logf(float); -__device__ float __hip_fast_powf(float, float); -__device__ void __hip_fast_sincosf(float,float*,float*); -extern __attribute__((const)) float __hip_fast_sinf(float) __asm("llvm.sin.f32"); -__device__ float __hip_fast_tanf(float); -extern __attribute__((const)) float __hip_fast_fmaf(float,float,float) __asm("llvm.fma.f32"); -extern __attribute__((const)) float __hip_fast_frcp(float) __asm("llvm.amdgcn.rcp.f32"); - -extern __attribute__((const)) double __hip_fast_dsqrt(double) __asm("llvm.sqrt.f64"); -extern __attribute__((const)) double __hip_fast_fma(double,double,double) __asm("llvm.fma.f64"); -extern __attribute__((const)) double __hip_fast_drcp(double) __asm("llvm.amdgcn.rcp.f64"); - -#ifdef HIP_FAST_MATH -// Single Precision Precise Math when enabled - -__device__ inline float cosf(float x) { - return __hip_fast_cosf(x); -} - -__device__ inline float exp10f(float x) { - return __hip_fast_exp10f(x); -} - -__device__ inline float expf(float x) { - return __hip_fast_expf(x); -} - -__device__ inline float log10f(float x) { - return __hip_fast_log10f(x); -} - -__device__ inline float log2f(float x) { - return __hip_fast_log2f(x); -} - -__device__ inline float logf(float x) { - return __hip_fast_logf(x); -} - -__device__ inline float powf(float base, float exponent) { - return __hip_fast_powf(base, exponent); -} - -__device__ inline void sincosf(float x, float *s, float *c) { - return __hip_fast_sincosf(x, s, c); -} - -__device__ inline float sinf(float x) { - return __hip_fast_sinf(x); -} - -__device__ inline float tanf(float x) { - return __hip_fast_tanf(x); -} - -#else - -__device__ float sinf(float); -__device__ float cosf(float); -__device__ float tanf(float); -__device__ void sincosf(float, float*, float*); -__device__ float logf(float); -__device__ float log2f(float); -__device__ float log10f(float); -__device__ float expf(float); -__device__ float exp10f(float); -__device__ float powf(float, float); - -#endif -// Single Precision Fast Math -__device__ inline float __cosf(float x) { - return __hip_fast_cosf(x); -} - -__device__ inline float __exp10f(float x) { - return __hip_fast_exp10f(x); -} - -__device__ inline float __expf(float x) { - return __hip_fast_expf(x); -} - -__device__ inline float __frsqrt_rn(float x) { - return __hip_fast_frsqrt_rn(x); -} - -__device__ inline float __fsqrt_rd(float x) { - return __hip_fast_fsqrt_rd(x); -} - -__device__ inline float __fsqrt_rn(float x) { - return __hip_fast_fsqrt_rn(x); -} - -__device__ inline float __fsqrt_ru(float x) { - return __hip_fast_fsqrt_ru(x); -} - -__device__ inline float __fsqrt_rz(float x) { - return __hip_fast_fsqrt_rz(x); -} - -__device__ inline float __log10f(float x) { - return __hip_fast_log10f(x); -} - -__device__ inline float __log2f(float x) { - return __hip_fast_log2f(x); -} - -__device__ inline float __logf(float x) { - return __hip_fast_logf(x); -} - -__device__ inline float __powf(float base, float exponent) { - return __hip_fast_powf(base, exponent); -} - -__device__ inline void __sincosf(float x, float *s, float *c) { - return __hip_fast_sincosf(x, s, c); -} - -__device__ inline float __sinf(float x) { - return __hip_fast_sinf(x); -} - -__device__ inline float __tanf(float x) { - return __hip_fast_tanf(x); -} - -__device__ inline float __fmaf_rd(float x, float y, float z) { - return __hip_fast_fmaf(x, y, z); -} - -__device__ inline float __fmaf_rn(float x, float y, float z) { - return __hip_fast_fmaf(x, y, z); -} - -__device__ inline float __fmaf_ru(float x, float y, float z) { - return __hip_fast_fmaf(x, y, z); -} - -__device__ inline float __fmaf_rz(float x, float y, float z) { - return __hip_fast_fmaf(x, y, z); -} - -__device__ inline float __frcp_rd(float x) { - return __hip_fast_frcp(x); -} - -__device__ inline float __frcp_rn(float x) { - return __hip_fast_frcp(x); -} - -__device__ inline float __frcp_ru(float x) { - return __hip_fast_frcp(x); -} - -__device__ inline float __frcp_rz(float x) { - return __hip_fast_frcp(x); -} - -__device__ inline double __dsqrt_rd(double x) { - return __hip_fast_dsqrt(x); -} - -__device__ inline double __dsqrt_rn(double x) { - return __hip_fast_dsqrt(x); -} - -__device__ inline double __dsqrt_ru(double x) { - return __hip_fast_dsqrt(x); -} - -__device__ inline double __dsqrt_rz(double x) { - return __hip_fast_dsqrt(x); -} - -__device__ inline double __fma_rd(double x, double y, double z) { - return __hip_fast_fma(x, y, z); -} - -__device__ inline double __fma_rn(double x, double y, double z) { - return __hip_fast_fma(x, y, z); -} - -__device__ inline double __fma_ru(double x, double y, double z) { - return __hip_fast_fma(x, y, z); -} - -__device__ inline double __fma_rz(double x, double y, double z) { - return __hip_fast_fma(x, y, z); -} - -__device__ inline double __drcp_rd(double x) { - return __hip_fast_drcp(x); -} - -__device__ inline double __drcp_rn(double x) { - return __hip_fast_drcp(x); -} - -__device__ inline double __drcp_ru(double x) { - return __hip_fast_drcp(x); -} - -__device__ inline double __drcp_rz(double x) { - return __hip_fast_drcp(x); -} /** * CUDA 8 device function features diff --git a/projects/hip/include/hip/hcc_detail/math_functions.h b/projects/hip/include/hip/hcc_detail/math_functions.h new file mode 100644 index 0000000000..5a0e21f83c --- /dev/null +++ b/projects/hip/include/hip/hcc_detail/math_functions.h @@ -0,0 +1,288 @@ +/* +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#ifndef HIP_HCC_DETAIL_MATH_FUNCTIONS_H +#define HIP_HCC_DETAIL_MATH_FUNCTIONS_H + +#include +#include +#include + +__device__ float acosf(float x); +__device__ float acoshf(float x); +__device__ float asinf(float x); +__device__ float asinhf(float x); +__device__ float atan2f(float y, float x); +__device__ float atanf(float x); +__device__ float atanhf(float x); +__device__ float cbrtf(float x); +__device__ float ceilf(float x); +__device__ float copysignf(float x, float y); +__device__ float coshf(float x); +__device__ float cyl_bessel_i0f(float x); +__device__ float cyl_bessel_i1f(float x); +__device__ float erfcf(float x); +__device__ float erfcinvf(float y); + +__device__ float erfcxf(float x); +__device__ float erff(float x); +__device__ float erfinvf(float y); +__device__ float exp2f(float x); +__device__ float expm1f(float x); +__device__ float fabsf(float x); +__device__ float fdimf(float x, float y); +__device__ __host__ float fdividef(float x, float y); +__device__ float floorf(float x); +__device__ float fmaf(float x, float y, float z); +__device__ float fmaxf(float x, float y); +__device__ float fminf(float x, float y); +__device__ float fmodf(float x, float y); +__device__ float frexpf(float x, float y); +__device__ float hypotf(float x, float y); +__device__ float ilogbf(float x); +__host__ __device__ int isfinite(float a); +__device__ unsigned isinf(float a); +__device__ unsigned isnan(float a); +__device__ float j0f(float x); +__device__ float j1f(float x); +__device__ float jnf(int n, float x); +__device__ float ldexpf(float x, int exp); +__device__ float lgammaf(float x); +__device__ long long int llrintf(float x); +__device__ long long int llroundf(float x); +__device__ float log1pf(float x); +__device__ float logbf(float x); +__device__ long int lrintf(float x); +__device__ long int lroundf(float x); +__device__ float modff(float x, float *iptr); +__device__ float nanf(const char* tagp); +__device__ float nearbyintf(float x); +__device__ float nextafterf(float x, float y); +__device__ float norm3df(float a, float b, float c); +__device__ float norm4df(float a, float b, float c, float d); +__device__ float normcdff(float y); +__device__ float normcdfinvf(float y); +__device__ float normf(int dim, const float *a); +__device__ float rcbrtf(float x); +__device__ float remainderf(float x, float y); +__device__ float remquof(float x, float y, int *quo); +__device__ float rhypotf(float x, float y); +__device__ float rintf(float x); +__device__ float rnorm3df(float a, float b, float c); +__device__ float rnorm4df(float a, float b, float c, float d); +__device__ float rnormf(int dim, const float* a); +__device__ float roundf(float x); +__device__ float rsqrtf(float x); +__device__ float scalblnf(float x, long int n); +__device__ float scalbnf(float x, int n); +__host__ __device__ unsigned signbit(float a); +__device__ void sincospif(float x, float *sptr, float *cptr); +__device__ float sinhf(float x); +__device__ float sinpif(float x); +__device__ float sqrtf(float x); +__device__ float tanhf(float x); +__device__ float tgammaf(float x); +__device__ float truncf(float x); +__device__ float y0f(float x); +__device__ float y1f(float x); +__device__ float ynf(int n, float x); + +__host__ __device__ float cospif(float x); +__host__ __device__ float sinpif(float x); +// /__device__ float sqrtf(float x); +__host__ __device__ float rsqrtf(float x); +__host__ float normcdff(float y); + +__host__ float erfcinvf(float y); +__host__ float erfcxf(float x); +__host__ float erfinvf(float y); +__host__ float norm3df(float a, float b, float c); +__host__ float normcdfinvf(float y); +__host__ float norm4df(float a, float b, float c, float d); +__host__ float rcbrtf(float x); +__host__ float rhypotf(float x, float y); +__host__ float rnorm3df(float a, float b, float c); +__host__ float rnormf(int dim, const float* a); +__host__ float rnorm4df(float a, float b, float c, float d); +__host__ void sincospif(float x, float *sptr, float *cptr); + +__device__ double acos(double x); +__device__ double acosh(double x); +__device__ double asin(double x); +__device__ double asinh(double x); +__device__ double atan(double x); +__device__ double atan2(double y, double x); +__device__ double atanh(double x); +__device__ double cbrt(double x); +__device__ double ceil(double x); +__device__ double copysign(double x, double y); +__device__ double cos(double x); +__device__ double cosh(double x); +__host__ __device__ double cospi(double x); +__device__ double cyl_bessel_i0(double x); +__device__ double cyl_bessel_i1(double x); +__device__ double erf(double x); +__device__ double erfc(double x); +__device__ double erfcinv(double y); +__device__ double erfcx(double x); +__device__ double erfinv(double x); +__device__ double exp(double x); +__device__ double exp10(double x); +__device__ double exp2(double x); +__device__ double expm1(double x); +__device__ double fabs(double x); +__device__ double fdim(double x, double y); +__device__ double floor(double x); +__device__ double fma(double x, double y, double z); +__device__ double fmax(double x, double y); +__device__ double fmin(double x, double y); +__device__ double fmod(double x, double y); +__device__ double frexp(double x, int *nptr); +__device__ double hypot(double x, double y); +__device__ double ilogb(double x); +__host__ __device__ unsigned isfinite(double x); +__device__ unsigned isinf(double x); +__device__ unsigned isnan(double x); +__device__ double j0(double x); +__device__ double j1(double x); +__device__ double jn(int n, double x); +__device__ double ldexp(double x, int exp); +__device__ double lgamma(double x); +__device__ long long llrint(double x); +__device__ long long llround(double x); +__device__ double log(double x); +__device__ double log10(double x); +__device__ double log1p(double x); +__device__ double log2(double x); +__device__ double logb(double x); +__device__ long int lrint(double x); +__device__ long int lround(double x); +__device__ double modf(double x, double *iptr); +__device__ double nan(const char* tagp); +__device__ double nearbyint(double x); +__device__ double nextafter(double x, double y); +__device__ double norm(int dim, const double* t); +__device__ double norm3d(double a, double b, double c); +__host__ double norm3d(double a, double b, double c); +__device__ double norm4d(double a, double b, double c, double d); +__host__ double norm4d(double a, double b, double c, double d); +__device__ double normcdf(double y); +__host__ double normcdf(double y); +__device__ double normcdfinv(double y); +__host__ double normcdfinv(double y); +__device__ double pow(double x, double y); +__device__ double rcbrt(double x); +__host__ double rcbrt(double x); +__device__ double remainder(double x, double y); +__device__ double remquo(double x, double y, int *quo); +__device__ double rhypot(double x, double y); +__host__ double rhypot(double x, double y); +__device__ double rint(double x); +__device__ double rnorm(int dim, const double* t); +__host__ double rnorm(int dim, const double* t); +__device__ double rnorm3d(double a, double b, double c); +__host__ double rnorm3d(double a, double b, double c); +__device__ double rnorm4d(double a, double b, double c, double d); +__host__ double rnorm4d(double a, double b, double c, double d); +__device__ double round(double x); +__host__ __device__ double rsqrt(double x); +__device__ double scalbln(double x, long int n); +__device__ double scalbn(double x, int n); +__host__ __device__ unsigned signbit(double a); +__device__ double sin(double a); +__device__ void sincos(double x, double *sptr, double *cptr); +__device__ void sincospi(double x, double *sptr, double *cptr); +__host__ void sincospi(double x, double *sptr, double *cptr); +__device__ double sinh(double x); +__host__ __device__ double sinpi(double x); +__device__ double sqrt(double x); +__device__ double tan(double x); +__device__ double tanh(double x); +__device__ double tgamma(double x); +__device__ double trunc(double x); +__device__ double y0(double x); +__device__ double y1(double y); +__device__ double yn(int n, double x); + +__host__ double erfcinv(double y); +__host__ double erfcx(double x); +__host__ double erfinv(double y); +__host__ double fdivide(double x, double y); +__host__ double norm(double x, const double *t); + +#ifdef HIP_FAST_MATH +// Single Precision Precise Math when enabled + +__device__ inline float cosf(float x) { + return __hip_fast_cosf(x); +} + +__device__ inline float exp10f(float x) { + return __hip_fast_exp10f(x); +} + +__device__ inline float expf(float x) { + return __hip_fast_expf(x); +} + +__device__ inline float log10f(float x) { + return __hip_fast_log10f(x); +} + +__device__ inline float log2f(float x) { + return __hip_fast_log2f(x); +} + +__device__ inline float logf(float x) { + return __hip_fast_logf(x); +} + +__device__ inline float powf(float base, float exponent) { + return __hip_fast_powf(base, exponent); +} + +__device__ inline void sincosf(float x, float *s, float *c) { + return __hip_fast_sincosf(x, s, c); +} + +__device__ inline float sinf(float x) { + return __hip_fast_sinf(x); +} + +__device__ inline float tanf(float x) { + return __hip_fast_tanf(x); +} + +#else + +__device__ float sinf(float); +__device__ float cosf(float); +__device__ float tanf(float); +__device__ void sincosf(float, float*, float*); +__device__ float logf(float); +__device__ float log2f(float); +__device__ float log10f(float); +__device__ float expf(float); +__device__ float exp10f(float); +__device__ float powf(float, float); + +#endif + + +#endif diff --git a/projects/hip/include/hip/math_functions.h b/projects/hip/include/hip/math_functions.h new file mode 100644 index 0000000000..d33f7a2e90 --- /dev/null +++ b/projects/hip/include/hip/math_functions.h @@ -0,0 +1,49 @@ +/* +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +//! HIP = Heterogeneous-compute Interface for Portability +//! +//! Define a extremely thin runtime layer that allows source code to be compiled unmodified +//! through either AMD HCC or NVCC. Key features tend to be in the spirit +//! and terminology of CUDA, but with a portable path to other accelerators as well: +// +//! Both paths support rich C++ features including classes, templates, lambdas, etc. +//! Runtime API is C +//! Memory management is based on pure pointers and resembles malloc/free/copy. +// +//! hip_runtime.h : includes everything in hip_api.h, plus math builtins and kernel launch macros. +//! hip_runtime_api.h : Defines HIP API. This is a C header file and does not use any C++ features. + +#pragma once + +// Some standard header files, these are included by hc.hpp and so want to make them avail on both +// paths to provide a consistent include env and avoid "missing symbol" errors that only appears +// on NVCC path: + + +#if defined(__HIP_PLATFORM_HCC__) && !defined (__HIP_PLATFORM_NVCC__) +#include +#elif defined(__HIP_PLATFORM_NVCC__) && !defined (__HIP_PLATFORM_HCC__) +#include +#else +#error("Must define exactly one of __HIP_PLATFORM_HCC__ or __HIP_PLATFORM_NVCC__"); +#endif diff --git a/projects/hip/src/device_functions.cpp b/projects/hip/src/device_functions.cpp index 4b0eb9a5ff..abc9db570e 100644 --- a/projects/hip/src/device_functions.cpp +++ b/projects/hip/src/device_functions.cpp @@ -523,3 +523,71 @@ __device__ unsigned long long __umul64hi(unsigned long long int x, unsigned long uHold1.ul = uHold1.ui[1] * uHold2.ui[1]; return uHold1.ul; } + +/* +HIP specific device functions +*/ + +__device__ unsigned __hip_ds_bpermute(int index, unsigned src) { + return hc::__amdgcn_ds_bpermute(index, src); +} + +__device__ float __hip_ds_bpermutef(int index, float src) { + return hc::__amdgcn_ds_bpermute(index, src); +} + +__device__ unsigned __hip_ds_permute(int index, unsigned src) { + return hc::__amdgcn_ds_permute(index, src); +} + +__device__ float __hip_ds_permutef(int index, float src) { + return hc::__amdgcn_ds_permute(index, src); +} + +__device__ unsigned __hip_ds_swizzle(unsigned int src, int pattern) { + return hc::__amdgcn_ds_swizzle(src, pattern); +} + +__device__ float __hip_ds_swizzlef(float src, int pattern) { + return hc::__amdgcn_ds_swizzle(src, pattern); +} + +__device__ int __hip_move_dpp(int src, int dpp_ctrl, int row_mask, int bank_mask, bool bound_ctrl) { + return hc::__amdgcn_move_dpp(src, dpp_ctrl, row_mask, bank_mask, bound_ctrl); +} + +#define MASK1 0x00ff00ff +#define MASK2 0xff00ff00 + +__device__ char4 __hip_hc_add8pk(char4 in1, char4 in2) { + char4 out; + unsigned one1 = in1.a & MASK1; + unsigned one2 = in2.a & MASK1; + out.a = (one1 + one2) & MASK1; + one1 = in1.a & MASK2; + one2 = in2.a & MASK2; + out.a = out.a | ((one1 + one2) & MASK2); + return out; +} + +__device__ char4 __hip_hc_sub8pk(char4 in1, char4 in2) { + char4 out; + unsigned one1 = in1.a & MASK1; + unsigned one2 = in2.a & MASK1; + out.a = (one1 - one2) & MASK1; + one1 = in1.a & MASK2; + one2 = in2.a & MASK2; + out.a = out.a | ((one1 - one2) & MASK2); + return out; +} + +__device__ char4 __hip_hc_mul8pk(char4 in1, char4 in2) { + char4 out; + unsigned one1 = in1.a & MASK1; + unsigned one2 = in2.a & MASK1; + out.a = (one1 * one2) & MASK1; + one1 = in1.a & MASK2; + one2 = in2.a & MASK2; + out.a = out.a | ((one1 * one2) & MASK2); + return out; +} diff --git a/projects/hip/src/device_util.cpp b/projects/hip/src/device_util.cpp index e875db1cf9..d80d9e7ef5 100644 --- a/projects/hip/src/device_util.cpp +++ b/projects/hip/src/device_util.cpp @@ -24,7 +24,7 @@ THE SOFTWARE. #include #include #include "device_util.h" - +#include "hip/hcc_detail/device_functions.h" #include "hip/hip_runtime.h" //================================================================================================= @@ -96,69 +96,7 @@ __device__ void* __hip_hc_free(void *ptr) return nullptr; } -__device__ unsigned __hip_ds_bpermute(int index, unsigned src) { - return hc::__amdgcn_ds_bpermute(index, src); -} -__device__ float __hip_ds_bpermutef(int index, float src) { - return hc::__amdgcn_ds_bpermute(index, src); -} - -__device__ unsigned __hip_ds_permute(int index, unsigned src) { - return hc::__amdgcn_ds_permute(index, src); -} - -__device__ float __hip_ds_permutef(int index, float src) { - return hc::__amdgcn_ds_permute(index, src); -} - -__device__ unsigned __hip_ds_swizzle(unsigned int src, int pattern) { - return hc::__amdgcn_ds_swizzle(src, pattern); -} - -__device__ float __hip_ds_swizzlef(float src, int pattern) { - return hc::__amdgcn_ds_swizzle(src, pattern); -} - -__device__ int __hip_move_dpp(int src, int dpp_ctrl, int row_mask, int bank_mask, bool bound_ctrl) { - return hc::__amdgcn_move_dpp(src, dpp_ctrl, row_mask, bank_mask, bound_ctrl); -} - -#define MASK1 0x00ff00ff -#define MASK2 0xff00ff00 - -__device__ char4 __hip_hc_add8pk(char4 in1, char4 in2) { - char4 out; - unsigned one1 = in1.a & MASK1; - unsigned one2 = in2.a & MASK1; - out.a = (one1 + one2) & MASK1; - one1 = in1.a & MASK2; - one2 = in2.a & MASK2; - out.a = out.a | ((one1 + one2) & MASK2); - return out; -} - -__device__ char4 __hip_hc_sub8pk(char4 in1, char4 in2) { - char4 out; - unsigned one1 = in1.a & MASK1; - unsigned one2 = in2.a & MASK1; - out.a = (one1 - one2) & MASK1; - one1 = in1.a & MASK2; - one2 = in2.a & MASK2; - out.a = out.a | ((one1 - one2) & MASK2); - return out; -} - -__device__ char4 __hip_hc_mul8pk(char4 in1, char4 in2) { - char4 out; - unsigned one1 = in1.a & MASK1; - unsigned one2 = in2.a & MASK1; - out.a = (one1 * one2) & MASK1; - one1 = in1.a & MASK2; - one2 = in2.a & MASK2; - out.a = out.a | ((one1 * one2) & MASK2); - return out; -} // loop unrolling __device__ void* memcpy(void* dst, void* src, size_t size) @@ -192,39 +130,6 @@ __device__ void* free(void *ptr) return __hip_hc_free(ptr); } -//================================================================================================= - -// TODO: Choose whether default is precise math or fast math based on compilation flag. -#ifdef __HCC_ACCELERATOR__ -using namespace hc::precise_math; -#endif - - -#define HIP_SQRT_2 1.41421356237 -#define HIP_SQRT_PI 1.77245385091 - -#define __hip_erfinva3 -0.140543331 -#define __hip_erfinva2 0.914624893 -#define __hip_erfinva1 -1.645349621 -#define __hip_erfinva0 0.886226899 - -#define __hip_erfinvb4 0.012229801 -#define __hip_erfinvb3 -0.329097515 -#define __hip_erfinvb2 1.442710462 -#define __hip_erfinvb1 -2.118377725 -#define __hip_erfinvb0 1 - -#define __hip_erfinvc3 1.641345311 -#define __hip_erfinvc2 3.429567803 -#define __hip_erfinvc1 -1.62490649 -#define __hip_erfinvc0 -1.970840454 - -#define __hip_erfinvd2 1.637067800 -#define __hip_erfinvd1 3.543889200 -#define __hip_erfinvd0 1 - -#define HIP_PI 3.14159265358979323846 - __device__ float __hip_erfinvf(float x){ float ret; int sign; @@ -942,735 +847,6 @@ __device__ float __hip_ynf(int n, float x) -__device__ float acosf(float x) -{ - return hc::precise_math::acosf(x); -} -__device__ float acoshf(float x) -{ - return hc::precise_math::acoshf(x); -} -__device__ float asinf(float x) -{ - return hc::precise_math::asinf(x); -} -__device__ float asinhf(float x) -{ - return hc::precise_math::asinhf(x); -} -__device__ float atan2f(float y, float x) -{ - return hc::precise_math::atan2f(x, y); -} -__device__ float atanf(float x) -{ - return hc::precise_math::atanf(x); -} -__device__ float atanhf(float x) -{ - return hc::precise_math::atanhf(x); -} -__device__ float cbrtf(float x) -{ - return hc::precise_math::cbrtf(x); -} -__device__ float ceilf(float x) -{ - return hc::precise_math::ceilf(x); -} -__device__ float copysignf(float x, float y) -{ - return hc::precise_math::copysignf(x, y); -} -__device__ float cosf(float x) -{ - return hc::precise_math::cosf(x); -} -__device__ float coshf(float x) -{ - return hc::precise_math::coshf(x); -} -__device__ float cyl_bessel_i0f(float x); -__device__ float cyl_bessel_i1f(float x); -__device__ float erfcf(float x) -{ - return hc::precise_math::erfcf(x); -} -__device__ float erfcinvf(float y) -{ - return __hip_erfinvf(1 - y); -} -__device__ float erfcxf(float x) -{ - return hc::precise_math::expf(x*x)*hc::precise_math::erfcf(x); -} -__device__ float erff(float x) -{ - return hc::precise_math::erff(x); -} -__device__ float erfinvf(float y) -{ - return __hip_erfinvf(y); -} -__device__ float exp10f(float x) -{ - return hc::precise_math::exp10f(x); -} -__device__ float exp2f(float x) -{ - return hc::precise_math::exp2f(x); -} -__device__ float expf(float x) -{ - return hc::precise_math::expf(x); -} -__device__ float expm1f(float x) -{ - return hc::precise_math::expm1f(x); -} -__device__ float fabsf(float x) -{ - return hc::precise_math::fabsf(x); -} -__device__ float fdimf(float x, float y) -{ - return hc::precise_math::fdimf(x, y); -} -__device__ float fdividef(float x, float y) -{ - return x/y; -} -__device__ float floorf(float x) -{ - return hc::precise_math::floorf(x); -} -__device__ float fmaf(float x, float y, float z) -{ - return hc::precise_math::fmaf(x, y, z); -} -__device__ float fmaxf(float x, float y) -{ - return hc::precise_math::fmaxf(x, y); -} -__device__ float fminf(float x, float y) -{ - return hc::precise_math::fminf(x, y); -} -__device__ float fmodf(float x, float y) -{ - return hc::precise_math::fmodf(x, y); -} -__device__ float frexpf(float x, int *nptr) -{ - return hc::precise_math::frexpf(x, nptr); -} -__device__ float hypotf(float x, float y) -{ - return hc::precise_math::hypotf(x, y); -} -__device__ float ilogbf(float x) -{ - return hc::precise_math::ilogbf(x); -} -__device__ unsigned isfinite(float a) -{ - return hc::precise_math::isfinite(a); -} -__device__ unsigned isinf(float a) -{ - return hc::precise_math::isinf(a); -} -__device__ unsigned isnan(float a) -{ - return hc::precise_math::isnan(a); -} -__device__ float j0f(float x) -{ - return __hip_j0f(x); -} -__device__ float j1f(float x) -{ - return __hip_j1f(x); -} -__device__ float jnf(int n, float x) -{ - return __hip_jnf(n, x); -} -__device__ float ldexpf(float x, int exp) -{ - return hc::precise_math::ldexpf(x, exp); -} -__device__ float lgammaf(float x, int *sign) -{ - return hc::precise_math::lgammaf(x, sign); -} -__device__ long long int llrintf(float x) -{ - int y = hc::precise_math::roundf(x); - long long int z = y; - return z; -} -__device__ long long int llroundf(float x) -{ - int y = hc::precise_math::roundf(x); - long long int z = y; - return z; -}__device__ float log10f(float x) -{ - return hc::precise_math::log10f(x); -} -__device__ float log1pf(float x) -{ - return hc::precise_math::log1pf(x); -} -__device__ float log2f(float x) -{ - return hc::precise_math::log2f(x); -} -__device__ float logbf(float x) -{ - return hc::precise_math::logbf(x); -} -__device__ float logf(float x) -{ - return hc::precise_math::logf(x); -} -__device__ long int lrintf(float x) -{ - int y = hc::precise_math::roundf(x); - long int z = y; - return z; -} -__device__ long int lroundf(float x) -{ - long int y = hc::precise_math::roundf(x); - return y; -} -__device__ float modff(float x, float *iptr) -{ - return hc::precise_math::modff(x, iptr); -} -__device__ float nanf(const char* tagp) -{ - return hc::precise_math::nanf((int)*tagp); -} -__device__ float nearbyintf(float x) -{ - return hc::precise_math::nearbyintf(x); -} -__device__ float nextafterf(float x, float y) -{ - return hc::precise_math::nextafter(x, y); -} -__device__ float norm3df(float a, float b, float c) -{ - float x = a*a + b*b + c*c; - return hc::precise_math::sqrtf(x); -} -__device__ float norm4df(float a, float b, float c, float d) -{ - float x = a*a + b*b; - float y = c*c + d*d; - return hc::precise_math::sqrtf(x+y); -} - -__device__ float normcdff(float y) -{ - return ((hc::precise_math::erff(y)/1.41421356237) + 1)/2; -} -__device__ float normcdfinvf(float y) -{ - return HIP_SQRT_2 * __hip_erfinvf(2*y-1); -} -__device__ float normf(int dim, const float *a) -{ - float x = 0.0f; - for(int i=0;i + /* Heap size computation for malloc and free device functions. */ @@ -35,4 +37,119 @@ THE SOFTWARE. #define SIZE_MALLOC NUM_PAGES * SIZE_OF_PAGE #define SIZE_OF_HEAP SIZE_MALLOC +#define HIP_SQRT_2 1.41421356237 +#define HIP_SQRT_PI 1.77245385091 + +#define __hip_erfinva3 -0.140543331 +#define __hip_erfinva2 0.914624893 +#define __hip_erfinva1 -1.645349621 +#define __hip_erfinva0 0.886226899 + +#define __hip_erfinvb4 0.012229801 +#define __hip_erfinvb3 -0.329097515 +#define __hip_erfinvb2 1.442710462 +#define __hip_erfinvb1 -2.118377725 +#define __hip_erfinvb0 1 + +#define __hip_erfinvc3 1.641345311 +#define __hip_erfinvc2 3.429567803 +#define __hip_erfinvc1 -1.62490649 +#define __hip_erfinvc0 -1.970840454 + +#define __hip_erfinvd2 1.637067800 +#define __hip_erfinvd1 3.543889200 +#define __hip_erfinvd0 1 + +#define HIP_PI 3.14159265358979323846 + +__device__ void* __hip_hc_malloc(size_t size); +__device__ void* __hip_hc_free(void* ptr); + +__device__ float __hip_erfinvf(float x); +__device__ double __hip_erfinv(double x); + +__device__ float __hip_j0f(float x); +__device__ double __hip_j0(double x); + +__device__ float __hip_j1f(float x); +__device__ double __hip_j1(double x); + +__device__ float __hip_y0f(float x); +__device__ double __hip_y0(double x); + +__device__ float __hip_y1f(float x); +__device__ double __hip_y1(double x); + +__device__ float __hip_jnf(int n, float x); +__device__ double __hip_jn(int n, double x); + +__device__ float __hip_ynf(int n, float x); +__device__ double __hip_yn(int n, double x); + +__device__ float __hip_precise_cosf(float x); +__device__ float __hip_precise_exp10f(float x); +__device__ float __hip_precise_expf(float x); +__device__ float __hip_precise_frsqrt_rn(float x); +__device__ float __hip_precise_fsqrt_rd(float x); +__device__ float __hip_precise_fsqrt_rn(float x); +__device__ float __hip_precise_fsqrt_ru(float x); +__device__ float __hip_precise_fsqrt_rz(float x); +__device__ float __hip_precise_log10f(float x); +__device__ float __hip_precise_log2f(float x); +__device__ float __hip_precise_logf(float x); +__device__ float __hip_precise_powf(float base, float exponent); +__device__ void __hip_precise_sincosf(float x, float *s, float *c); +__device__ float __hip_precise_sinf(float x); +__device__ float __hip_precise_tanf(float x); +// Double Precision Math +__device__ double __hip_precise_dsqrt_rd(double x); +__device__ double __hip_precise_dsqrt_rn(double x); +__device__ double __hip_precise_dsqrt_ru(double x); +__device__ double __hip_precise_dsqrt_rz(double x); + + + +// Float Fast Math +__device__ float __hip_fast_exp10f(float x); +__device__ float __hip_fast_expf(float x); +__device__ float __hip_fast_frsqrt_rn(float x); +__device__ float __hip_fast_fsqrt_rn(float x); +__device__ float __hip_fast_fsqrt_ru(float x); +__device__ float __hip_fast_fsqrt_rz(float x); +__device__ float __hip_fast_log10f(float x); +__device__ float __hip_fast_logf(float x); +__device__ float __hip_fast_powf(float base, float exponent); +__device__ void __hip_fast_sincosf(float x, float *s, float *c); +__device__ float __hip_fast_tanf(float x); +// Double Precision Math +__device__ double __hip_fast_dsqrt_rd(double x); +__device__ double __hip_fast_dsqrt_rn(double x); +__device__ double __hip_fast_dsqrt_ru(double x); +__device__ double __hip_fast_dsqrt_rz(double x); +__device__ void __threadfence_system(void); + +float __hip_host_erfinvf(float x); +double __hip_host_erfinv(double x); + +float __hip_host_erfcinvf(float y); +double __hip_host_erfcinv(double y); + +float __hip_host_j0f(float x); +double __hip_host_j0(double x); + +float __hip_host_j1f(float x); +double __hip_host_j1(double x); + +float __hip_host_y0f(float x); +double __hip_host_y1(double x); + +float __hip_host_y1f(float x); +double __hip_host_y1(double x); + +float __hip_host_jnf(int n, float x); +double __hip_host_jn(int n, double x); + +float __hip_host_ynf(int n, float x); +double __hip_host_yn(int n, double x); + #endif diff --git a/projects/hip/src/math_functions.cpp b/projects/hip/src/math_functions.cpp new file mode 100644 index 0000000000..34a80448db --- /dev/null +++ b/projects/hip/src/math_functions.cpp @@ -0,0 +1,971 @@ + +/* +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#include +#include +#include +#include "device_util.h" +#include "hip/hcc_detail/device_functions.h" +#include "hip/hip_runtime.h" + +__device__ float acosf(float x) +{ + return hc::precise_math::acosf(x); +} +__device__ float acoshf(float x) +{ + return hc::precise_math::acoshf(x); +} +__device__ float asinf(float x) +{ + return hc::precise_math::asinf(x); +} +__device__ float asinhf(float x) +{ + return hc::precise_math::asinhf(x); +} +__device__ float atan2f(float y, float x) +{ + return hc::precise_math::atan2f(x, y); +} +__device__ float atanf(float x) +{ + return hc::precise_math::atanf(x); +} +__device__ float atanhf(float x) +{ + return hc::precise_math::atanhf(x); +} +__device__ float cbrtf(float x) +{ + return hc::precise_math::cbrtf(x); +} +__device__ float ceilf(float x) +{ + return hc::precise_math::ceilf(x); +} +__device__ float copysignf(float x, float y) +{ + return hc::precise_math::copysignf(x, y); +} +__device__ float cosf(float x) +{ + return hc::precise_math::cosf(x); +} +__device__ float coshf(float x) +{ + return hc::precise_math::coshf(x); +} +__device__ float cyl_bessel_i0f(float x); +__device__ float cyl_bessel_i1f(float x); +__device__ float erfcf(float x) +{ + return hc::precise_math::erfcf(x); +} +__device__ float erfcinvf(float y) +{ + return __hip_erfinvf(1 - y); +} +__device__ float erfcxf(float x) +{ + return hc::precise_math::expf(x*x)*hc::precise_math::erfcf(x); +} +__device__ float erff(float x) +{ + return hc::precise_math::erff(x); +} +__device__ float erfinvf(float y) +{ + return __hip_erfinvf(y); +} +__device__ float exp10f(float x) +{ + return hc::precise_math::exp10f(x); +} +__device__ float exp2f(float x) +{ + return hc::precise_math::exp2f(x); +} +__device__ float expf(float x) +{ + return hc::precise_math::expf(x); +} +__device__ float expm1f(float x) +{ + return hc::precise_math::expm1f(x); +} +__device__ float fabsf(float x) +{ + return hc::precise_math::fabsf(x); +} +__device__ float fdimf(float x, float y) +{ + return hc::precise_math::fdimf(x, y); +} +__device__ float fdividef(float x, float y) +{ + return x/y; +} +__device__ float floorf(float x) +{ + return hc::precise_math::floorf(x); +} +__device__ float fmaf(float x, float y, float z) +{ + return hc::precise_math::fmaf(x, y, z); +} +__device__ float fmaxf(float x, float y) +{ + return hc::precise_math::fmaxf(x, y); +} +__device__ float fminf(float x, float y) +{ + return hc::precise_math::fminf(x, y); +} +__device__ float fmodf(float x, float y) +{ + return hc::precise_math::fmodf(x, y); +} +__device__ float frexpf(float x, int *nptr) +{ + return hc::precise_math::frexpf(x, nptr); +} +__device__ float hypotf(float x, float y) +{ + return hc::precise_math::hypotf(x, y); +} +__device__ float ilogbf(float x) +{ + return hc::precise_math::ilogbf(x); +} +__device__ unsigned isfinite(float a) +{ + return hc::precise_math::isfinite(a); +} +__device__ unsigned isinf(float a) +{ + return hc::precise_math::isinf(a); +} +__device__ unsigned isnan(float a) +{ + return hc::precise_math::isnan(a); +} +__device__ float j0f(float x) +{ + return __hip_j0f(x); +} +__device__ float j1f(float x) +{ + return __hip_j1f(x); +} +__device__ float jnf(int n, float x) +{ + return __hip_jnf(n, x); +} +__device__ float ldexpf(float x, int exp) +{ + return hc::precise_math::ldexpf(x, exp); +} +__device__ float lgammaf(float x, int *sign) +{ + return hc::precise_math::lgammaf(x, sign); +} +__device__ long long int llrintf(float x) +{ + int y = hc::precise_math::roundf(x); + long long int z = y; + return z; +} +__device__ long long int llroundf(float x) +{ + int y = hc::precise_math::roundf(x); + long long int z = y; + return z; +}__device__ float log10f(float x) +{ + return hc::precise_math::log10f(x); +} +__device__ float log1pf(float x) +{ + return hc::precise_math::log1pf(x); +} +__device__ float log2f(float x) +{ + return hc::precise_math::log2f(x); +} +__device__ float logbf(float x) +{ + return hc::precise_math::logbf(x); +} +__device__ float logf(float x) +{ + return hc::precise_math::logf(x); +} +__device__ long int lrintf(float x) +{ + int y = hc::precise_math::roundf(x); + long int z = y; + return z; +} +__device__ long int lroundf(float x) +{ + long int y = hc::precise_math::roundf(x); + return y; +} +__device__ float modff(float x, float *iptr) +{ + return hc::precise_math::modff(x, iptr); +} +__device__ float nanf(const char* tagp) +{ + return hc::precise_math::nanf((int)*tagp); +} +__device__ float nearbyintf(float x) +{ + return hc::precise_math::nearbyintf(x); +} +__device__ float nextafterf(float x, float y) +{ + return hc::precise_math::nextafter(x, y); +} +__device__ float norm3df(float a, float b, float c) +{ + float x = a*a + b*b + c*c; + return hc::precise_math::sqrtf(x); +} +__device__ float norm4df(float a, float b, float c, float d) +{ + float x = a*a + b*b; + float y = c*c + d*d; + return hc::precise_math::sqrtf(x+y); +} + +__device__ float normcdff(float y) +{ + return ((hc::precise_math::erff(y)/1.41421356237) + 1)/2; +} +__device__ float normcdfinvf(float y) +{ + return HIP_SQRT_2 * __hip_erfinvf(2*y-1); +} +__device__ float normf(int dim, const float *a) +{ + float x = 0.0f; + for(int i=0;i +#include #include "test_common.h" #pragma GCC diagnostic ignored "-Wall" @@ -27,18 +28,18 @@ THE SOFTWARE. __device__ void double_precision_intrinsics() { - //__dadd_rd(0.0, 1.0); - //__dadd_rn(0.0, 1.0); - //__dadd_ru(0.0, 1.0); - //__dadd_rz(0.0, 1.0); - //__ddiv_rd(0.0, 1.0); - //__ddiv_rn(0.0, 1.0); - //__ddiv_ru(0.0, 1.0); - //__ddiv_rz(0.0, 1.0); - //__dmul_rd(1.0, 2.0); - //__dmul_rn(1.0, 2.0); - //__dmul_ru(1.0, 2.0); - //__dmul_rz(1.0, 2.0); + __dadd_rd(0.0, 1.0); + __dadd_rn(0.0, 1.0); + __dadd_ru(0.0, 1.0); + __dadd_rz(0.0, 1.0); + __ddiv_rd(0.0, 1.0); + __ddiv_rn(0.0, 1.0); + __ddiv_ru(0.0, 1.0); + __ddiv_rz(0.0, 1.0); + __dmul_rd(1.0, 2.0); + __dmul_rn(1.0, 2.0); + __dmul_ru(1.0, 2.0); + __dmul_rz(1.0, 2.0); __drcp_rd(2.0); __drcp_rn(2.0); __drcp_ru(2.0); @@ -47,10 +48,10 @@ __device__ void double_precision_intrinsics() __dsqrt_rn(4.0); __dsqrt_ru(4.0); __dsqrt_rz(4.0); - //__dsub_rd(2.0, 1.0); - //__dsub_rn(2.0, 1.0); - //__dsub_ru(2.0, 1.0); - //__dsub_rz(2.0, 1.0); + __dsub_rd(2.0, 1.0); + __dsub_rn(2.0, 1.0); + __dsub_ru(2.0, 1.0); + __dsub_rz(2.0, 1.0); __fma_rd(1.0, 2.0, 3.0); __fma_rn(1.0, 2.0, 3.0); __fma_ru(1.0, 2.0, 3.0); diff --git a/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathDevice.cpp b/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathDevice.cpp index 996577e840..537fcbbba8 100644 --- a/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathDevice.cpp +++ b/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathDevice.cpp @@ -19,7 +19,8 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "hip/hip_runtime.h" +#include +#include #include "test_common.h" #pragma GCC diagnostic ignored "-Wall" @@ -43,8 +44,8 @@ __device__ void double_precision_math_functions() cos(0.0); cosh(0.0); cospi(0.0); - //cyl_bessel_i0(0.0); - //cyl_bessel_i1(0.0); + cyl_bessel_i0(0.0); + cyl_bessel_i1(0.0); erf(0.0); erfc(0.0); erfcinv(2.0); @@ -61,7 +62,7 @@ __device__ void double_precision_math_functions() fmax(0.0, 0.0); fmin(0.0, 0.0); fmod(0.0, 1.0); - //frexp(0.0, &iX); + frexp(0.0, &iX); hypot(1.0, 0.0); ilogb(1.0); isfinite(0.0); @@ -71,7 +72,7 @@ __device__ void double_precision_math_functions() j1(0.0); jn(-1.0, 1.0); ldexp(0.0, 0); - //lgamma(1.0); + lgamma(1.0); llrint(0.0); llround(0.0); log(1.0); @@ -81,19 +82,19 @@ __device__ void double_precision_math_functions() logb(1.0); lrint(0.0); lround(0.0); - //modf(0.0, &fX); + modf(0.0, &fX); nan("1"); nearbyint(0.0); - //nextafter(0.0); - //fX = 1.0; norm(1, &fX); + nextafter(0.0, 0.0); + fX = 1.0; norm(1, &fX); norm3d(1.0, 0.0, 0.0); norm4d(1.0, 0.0, 0.0, 0.0); normcdf(0.0); - //normcdfinv(1.0); + normcdfinv(1.0); pow(1.0, 0.0); rcbrt(1.0); remainder(2.0, 1.0); - //remquo(1.0, 2.0, &iX); + remquo(1.0, 2.0, &iX); rhypot(0.0, 1.0); rint(1.0); fX = 1.0; rnorm(1, &fX); diff --git a/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathHost.cpp b/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathHost.cpp index 9980dad277..eff39102c6 100644 --- a/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathHost.cpp +++ b/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathHost.cpp @@ -19,7 +19,8 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "hip/hip_runtime.h" +#include +#include #include "test_common.h" #pragma GCC diagnostic ignored "-Wall" @@ -85,7 +86,7 @@ __host__ void double_precision_math_functions() nan("1"); nearbyint(0.0); //nextafter(0.0); - //fX = 1.0; norm(1, &fX); + fX = 1.0; norm(1, &fX); #if defined(__HIP_PLATFORM_HCC__) norm3d(1.0, 0.0, 0.0); norm4d(1.0, 0.0, 0.0, 0.0); diff --git a/projects/hip/tests/src/deviceLib/hipFloatMath.cpp b/projects/hip/tests/src/deviceLib/hipFloatMath.cpp index f137ca2602..7a96b5cd0d 100644 --- a/projects/hip/tests/src/deviceLib/hipFloatMath.cpp +++ b/projects/hip/tests/src/deviceLib/hipFloatMath.cpp @@ -27,6 +27,7 @@ THE SOFTWARE. */ #include "test_common.h" +#include #define LEN 512 #define SIZE LEN<<2 diff --git a/projects/hip/tests/src/deviceLib/hipFloatMathPrecise.cpp b/projects/hip/tests/src/deviceLib/hipFloatMathPrecise.cpp index 4f6c2cd44a..12f7875949 100644 --- a/projects/hip/tests/src/deviceLib/hipFloatMathPrecise.cpp +++ b/projects/hip/tests/src/deviceLib/hipFloatMathPrecise.cpp @@ -19,7 +19,8 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "hip/hip_runtime.h" +#include +#include #include "test_common.h" __global__ void FloatMathPrecise(hipLaunchParm lp) diff --git a/projects/hip/tests/src/deviceLib/hipIntegerIntrinsics.cpp b/projects/hip/tests/src/deviceLib/hipIntegerIntrinsics.cpp index 63530574d8..d712c5a93b 100644 --- a/projects/hip/tests/src/deviceLib/hipIntegerIntrinsics.cpp +++ b/projects/hip/tests/src/deviceLib/hipIntegerIntrinsics.cpp @@ -19,8 +19,8 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "hip/hip_runtime.h" -#include "hip/device_functions.h" +#include +#include #include "test_common.h" #pragma GCC diagnostic ignored "-Wall" diff --git a/projects/hip/tests/src/deviceLib/hipSinglePrecisionIntrinsics.cpp b/projects/hip/tests/src/deviceLib/hipSinglePrecisionIntrinsics.cpp index caddcc0149..6737c6ee9d 100644 --- a/projects/hip/tests/src/deviceLib/hipSinglePrecisionIntrinsics.cpp +++ b/projects/hip/tests/src/deviceLib/hipSinglePrecisionIntrinsics.cpp @@ -19,7 +19,8 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "hip/hip_runtime.h" +#include +#include #include "test_common.h" #pragma GCC diagnostic ignored "-Wall" @@ -30,44 +31,44 @@ __device__ void single_precision_intrinsics() float fX, fY; __cosf(0.0f); - //__exp10f(0.0f); + __exp10f(0.0f); __expf(0.0f); - //__fadd_rd(0.0f, 1.0f); - //__fadd_rn(0.0f, 1.0f); - //__fadd_ru(0.0f, 1.0f); - //__fadd_rz(0.0f, 1.0f); - //__fdiv_rd(4.0f, 2.0f); - //__fdiv_rn(4.0f, 2.0f); - //__fdiv_ru(4.0f, 2.0f); - //__fdiv_rz(4.0f, 2.0f); - //__fdividef(4.0f, 2.0f); - //__fmaf_rd(1.0f, 2.0f, 3.0f); - //__fmaf_rn(1.0f, 2.0f, 3.0f); - //__fmaf_ru(1.0f, 2.0f, 3.0f); - //__fmaf_rz(1.0f, 2.0f, 3.0f); - //__fmul_rd(1.0f, 2.0f); - //__fmul_rn(1.0f, 2.0f); - //__fmul_ru(1.0f, 2.0f); - //__fmul_rz(1.0f, 2.0f); - //__frcp_rd(2.0f); - //__frcp_rn(2.0f); - //__frcp_ru(2.0f); - //__frcp_rz(2.0f); + __fadd_rd(0.0f, 1.0f); + __fadd_rn(0.0f, 1.0f); + __fadd_ru(0.0f, 1.0f); + __fadd_rz(0.0f, 1.0f); + __fdiv_rd(4.0f, 2.0f); + __fdiv_rn(4.0f, 2.0f); + __fdiv_ru(4.0f, 2.0f); + __fdiv_rz(4.0f, 2.0f); + __fdividef(4.0f, 2.0f); + __fmaf_rd(1.0f, 2.0f, 3.0f); + __fmaf_rn(1.0f, 2.0f, 3.0f); + __fmaf_ru(1.0f, 2.0f, 3.0f); + __fmaf_rz(1.0f, 2.0f, 3.0f); + __fmul_rd(1.0f, 2.0f); + __fmul_rn(1.0f, 2.0f); + __fmul_ru(1.0f, 2.0f); + __fmul_rz(1.0f, 2.0f); + __frcp_rd(2.0f); + __frcp_rn(2.0f); + __frcp_ru(2.0f); + __frcp_rz(2.0f); __frsqrt_rn(4.0f); __fsqrt_rd(4.0f); __fsqrt_rn(4.0f); __fsqrt_ru(4.0f); __fsqrt_rz(4.0f); - //__fsub_rd(2.0f, 1.0f); - //__fsub_rn(2.0f, 1.0f); - //__fsub_ru(2.0f, 1.0f); - //__fsub_rz(2.0f, 1.0f); + __fsub_rd(2.0f, 1.0f); + __fsub_rn(2.0f, 1.0f); + __fsub_ru(2.0f, 1.0f); + __fsub_rz(2.0f, 1.0f); __log10f(1.0f); __log2f(1.0f); __logf(1.0f); __powf(1.0f, 0.0f); - //__saturatef(0.1f); - //__sincosf(0.0f, &fX, &fY); + __saturatef(0.1f); + __sincosf(0.0f, &fX, &fY); __sinf(0.0f); __tanf(0.0f); } diff --git a/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathDevice.cpp b/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathDevice.cpp index a8c1194aab..4576faed93 100644 --- a/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathDevice.cpp +++ b/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathDevice.cpp @@ -19,7 +19,8 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "hip/hip_runtime.h" +#include +#include #include "test_common.h" #pragma GCC diagnostic ignored "-Wall" diff --git a/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathHost.cpp b/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathHost.cpp index 36aa852d81..d48cea5ff6 100644 --- a/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathHost.cpp +++ b/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathHost.cpp @@ -19,7 +19,8 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "hip/hip_runtime.h" +#include +#include #include "test_common.h" #pragma GCC diagnostic ignored "-Wall" diff --git a/projects/hip/tests/src/deviceLib/hipTestDevice.cpp b/projects/hip/tests/src/deviceLib/hipTestDevice.cpp index 9d90eb7de0..2c7488671b 100644 --- a/projects/hip/tests/src/deviceLib/hipTestDevice.cpp +++ b/projects/hip/tests/src/deviceLib/hipTestDevice.cpp @@ -24,8 +24,9 @@ THE SOFTWARE. */ #include"test_common.h" -#include "hip/hip_runtime.h" -#include "hip/hip_runtime_api.h" +#include +#include +#include #define N 512 #define SIZE N*sizeof(float) diff --git a/projects/hip/tests/src/deviceLib/hipTestDeviceDouble.cpp b/projects/hip/tests/src/deviceLib/hipTestDeviceDouble.cpp index c401a44cbd..f4e8ee20b8 100644 --- a/projects/hip/tests/src/deviceLib/hipTestDeviceDouble.cpp +++ b/projects/hip/tests/src/deviceLib/hipTestDeviceDouble.cpp @@ -24,8 +24,9 @@ THE SOFTWARE. */ #include"test_common.h" -#include "hip/hip_runtime.h" -#include "hip/hip_runtime_api.h" +#include +#include +#include #define N 512 #define SIZE N*sizeof(double) diff --git a/projects/hip/tests/src/deviceLib/hip_anyall.cpp b/projects/hip/tests/src/deviceLib/hip_anyall.cpp index a562b7810e..bba7915052 100644 --- a/projects/hip/tests/src/deviceLib/hip_anyall.cpp +++ b/projects/hip/tests/src/deviceLib/hip_anyall.cpp @@ -29,7 +29,8 @@ THE SOFTWARE. #include #include -#include "hip/hip_runtime.h" +#include +#include #define HIP_ASSERT(x) (assert((x)==hipSuccess)) __global__ void diff --git a/projects/hip/tests/src/deviceLib/hip_ballot.cpp b/projects/hip/tests/src/deviceLib/hip_ballot.cpp index 629e676bc7..742c47a065 100644 --- a/projects/hip/tests/src/deviceLib/hip_ballot.cpp +++ b/projects/hip/tests/src/deviceLib/hip_ballot.cpp @@ -25,8 +25,8 @@ THE SOFTWARE. #include -#include "hip/hip_runtime.h" -#include "hip/device_functions.h" +#include +#include #define HIP_ASSERT(x) (assert((x)==hipSuccess)) diff --git a/projects/hip/tests/src/deviceLib/hip_brev.cpp b/projects/hip/tests/src/deviceLib/hip_brev.cpp index d9228fe23c..855a8bec47 100644 --- a/projects/hip/tests/src/deviceLib/hip_brev.cpp +++ b/projects/hip/tests/src/deviceLib/hip_brev.cpp @@ -32,7 +32,7 @@ THE SOFTWARE. #include #include #include "hip/hip_runtime.h" -#include "hip/device_functions.h" +#include #define HIP_ASSERT(x) (assert((x)==hipSuccess)) diff --git a/projects/hip/tests/src/deviceLib/hip_clz.cpp b/projects/hip/tests/src/deviceLib/hip_clz.cpp index 869f4406f5..bdb31f3e8d 100644 --- a/projects/hip/tests/src/deviceLib/hip_clz.cpp +++ b/projects/hip/tests/src/deviceLib/hip_clz.cpp @@ -32,7 +32,7 @@ THE SOFTWARE. #include #include #include "hip/hip_runtime.h" -#include "hip/device_functions.h" +#include #define HIP_ASSERT(x) (assert((x)==hipSuccess)) #define WIDTH 8 diff --git a/projects/hip/tests/src/deviceLib/hip_ffs.cpp b/projects/hip/tests/src/deviceLib/hip_ffs.cpp index ba9bd7b9a0..c855ede060 100644 --- a/projects/hip/tests/src/deviceLib/hip_ffs.cpp +++ b/projects/hip/tests/src/deviceLib/hip_ffs.cpp @@ -31,8 +31,8 @@ THE SOFTWARE. #include #include #include -#include "hip/hip_runtime.h" -#include "hip/device_functions.h" +#include +#include #define HIP_ASSERT(x) (assert((x)==hipSuccess)) diff --git a/projects/hip/tests/src/deviceLib/hip_popc.cpp b/projects/hip/tests/src/deviceLib/hip_popc.cpp index 6fe214c7fa..e503e55b42 100644 --- a/projects/hip/tests/src/deviceLib/hip_popc.cpp +++ b/projects/hip/tests/src/deviceLib/hip_popc.cpp @@ -31,8 +31,8 @@ THE SOFTWARE. #include #include #include -#include "hip/hip_runtime.h" -#include "hip/device_functions.h" +#include +#include #define HIP_ASSERT(x) (assert((x)==hipSuccess)) diff --git a/projects/hip/tests/src/deviceLib/hip_trig.cpp b/projects/hip/tests/src/deviceLib/hip_trig.cpp index 7f9b5d60b0..5ec28101f3 100644 --- a/projects/hip/tests/src/deviceLib/hip_trig.cpp +++ b/projects/hip/tests/src/deviceLib/hip_trig.cpp @@ -21,7 +21,7 @@ THE SOFTWARE. */ /* HIT_START - * BUILD: %t %s + * BUILD: %t %s * RUN: %t * HIT_END */ @@ -30,6 +30,7 @@ THE SOFTWARE. #include #include #include"test_common.h" +#include #define LEN 512 #define SIZE LEN<<2 diff --git a/projects/hip/tests/src/runtimeApi/stream/hipAPIStreamDisable.cpp b/projects/hip/tests/src/runtimeApi/stream/hipAPIStreamDisable.cpp index a7cace0ebe..4e343121ed 100644 --- a/projects/hip/tests/src/runtimeApi/stream/hipAPIStreamDisable.cpp +++ b/projects/hip/tests/src/runtimeApi/stream/hipAPIStreamDisable.cpp @@ -24,6 +24,7 @@ THE SOFTWARE. #include #include"test_common.h" +#include"hip/math_functions.h" const int NN = 1 << 21; @@ -31,7 +32,7 @@ __global__ void kernel(hipLaunchParm lp, float *x, float *y, int n){ int tid = hipThreadIdx_x; if(tid < 1){ for(int i=0;i #include"test_common.h" +#include"hip/math_functions.h" const int NN = 1 << 21; @@ -33,7 +34,7 @@ __global__ void kernel(hipLaunchParm lp, float *x, float *y, int n){ int tid = hipThreadIdx_x; if(tid < 1){ for(int i=0;i Date: Wed, 18 Jan 2017 11:53:47 -0600 Subject: [PATCH 077/281] fixed compilation issues 1. Fixed compilation issues for tests 2. Added missing intrinsics + math functions 3. Disabled some device functions as they are causing linking error with HCC Change-Id: I79d52c4c7a539cc8ef40580247ad97ffcb975f09 [ROCm/hip commit: ea382e15f841ba0e06583de4262ca1159b498a1b] --- .../include/hip/hcc_detail/device_functions.h | 255 ++++++++++++++---- .../include/hip/hcc_detail/math_functions.h | 76 +++--- projects/hip/src/math_functions.cpp | 67 ++++- .../hipDoublePrecisionMathDevice.cpp | 12 +- .../deviceLib/hipDoublePrecisionMathHost.cpp | 6 +- 5 files changed, 299 insertions(+), 117 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/device_functions.h b/projects/hip/include/hip/hcc_detail/device_functions.h index 0489a72c8b..a2894f3d9b 100644 --- a/projects/hip/include/hip/hcc_detail/device_functions.h +++ b/projects/hip/include/hip/hcc_detail/device_functions.h @@ -61,6 +61,90 @@ __device__ inline float __expf(float x) { return __hip_fast_expf(x); } +__device__ static inline float __fadd_rd(float x, float y) { + return x + y; +} + +__device__ static inline float __fadd_rn(float x, float y) { + return x + y; +} + +__device__ static inline float __fadd_ru(float x, float y) { + return x + y; +} + +__device__ static inline float __fadd_rz(float x, float y) { + return x + y; +} + +__device__ static inline float __fdiv_rd(float x, float y) { + return x / y; +} + +__device__ static inline float __fdiv_rn(float x, float y) { + return x / y; +} + +__device__ static inline float __fdiv_ru(float x, float y) { + return x / y; +} + +__device__ static inline float __fdiv_rz(float x, float y) { + return x / y; +} + +__device__ static inline float __fdividef(float x, float y) { + return x / y; +} + +__device__ inline float __fmaf_rd(float x, float y, float z) { + return __hip_fast_fmaf(x, y, z); +} + +__device__ inline float __fmaf_rn(float x, float y, float z) { + return __hip_fast_fmaf(x, y, z); +} + +__device__ inline float __fmaf_ru(float x, float y, float z) { + return __hip_fast_fmaf(x, y, z); +} + +__device__ inline float __fmaf_rz(float x, float y, float z) { + return __hip_fast_fmaf(x, y, z); +} + +__device__ static inline float __fmul_rd(float x, float y) { + return x * y; +} + +__device__ static inline float __fmul_rn(float x, float y) { + return x * y; +} + +__device__ static inline float __fmul_ru(float x, float y) { + return x * y; +} + +__device__ static inline float __fmul_rz(float x, float y) { + return x * y; +} + +__device__ inline float __frcp_rd(float x) { + return __hip_fast_frcp(x); +} + +__device__ inline float __frcp_rn(float x) { + return __hip_fast_frcp(x); +} + +__device__ inline float __frcp_ru(float x) { + return __hip_fast_frcp(x); +} + +__device__ inline float __frcp_rz(float x) { + return __hip_fast_frcp(x); +} + __device__ inline float __frsqrt_rn(float x) { return __hip_fast_frsqrt_rn(x); } @@ -81,6 +165,23 @@ __device__ inline float __fsqrt_rz(float x) { return __hip_fast_fsqrt_rz(x); } +__device__ static inline float __fsub_rd(float x, float y) { + return x - y; +} + +__device__ static inline float __fsub_rn(float x, float y) { + return x - y; +} + +__device__ static inline float __fsub_ru(float x, float y) { + return x - y; +} + +__device__ static inline float __fsub_rz(float x, float y) { + return x - y; +} + + __device__ inline float __log10f(float x) { return __hip_fast_log10f(x); } @@ -97,6 +198,12 @@ __device__ inline float __powf(float base, float exponent) { return __hip_fast_powf(base, exponent); } +__device__ static inline float __saturatef(float x) { + x = x > 1.0f ? 1.0f : x; + x = x < 0.0f ? 0.0f : x; + return x; +} + __device__ inline void __sincosf(float x, float *s, float *c) { return __hip_fast_sincosf(x, s, c); } @@ -109,68 +216,57 @@ __device__ inline float __tanf(float x) { return __hip_fast_tanf(x); } -__device__ inline float __fmaf_rd(float x, float y, float z) { - return __hip_fast_fmaf(x, y, z); + +/* +Double Precision Intrinsics +*/ + +__device__ static inline double __dadd_rd(double x, double y) { + return x + y; } -__device__ inline float __fmaf_rn(float x, float y, float z) { - return __hip_fast_fmaf(x, y, z); +__device__ static inline double __dadd_rn(double x, double y) { + return x + y; } -__device__ inline float __fmaf_ru(float x, float y, float z) { - return __hip_fast_fmaf(x, y, z); +__device__ static inline double __dadd_ru(double x, double y) { + return x + y; } -__device__ inline float __fmaf_rz(float x, float y, float z) { - return __hip_fast_fmaf(x, y, z); +__device__ static inline double __dadd_rz(double x, double y) { + return x + y; } -__device__ inline float __frcp_rd(float x) { - return __hip_fast_frcp(x); +__device__ static inline double __ddiv_rd(double x, double y) { + return x / y; } -__device__ inline float __frcp_rn(float x) { - return __hip_fast_frcp(x); +__device__ static inline double __ddiv_rn(double x, double y) { + return x / y; } -__device__ inline float __frcp_ru(float x) { - return __hip_fast_frcp(x); +__device__ static inline double __ddiv_ru(double x, double y) { + return x / y; } -__device__ inline float __frcp_rz(float x) { - return __hip_fast_frcp(x); +__device__ static inline double __ddiv_rz(double x, double y) { + return x / y; } -__device__ inline double __dsqrt_rd(double x) { - return __hip_fast_dsqrt(x); +__device__ static inline double __dmul_rd(double x, double y) { + return x * y; } -__device__ inline double __dsqrt_rn(double x) { - return __hip_fast_dsqrt(x); +__device__ static inline double __dmul_rn(double x, double y) { + return x * y; } -__device__ inline double __dsqrt_ru(double x) { - return __hip_fast_dsqrt(x); +__device__ static inline double __dmul_ru(double x, double y) { + return x * y; } -__device__ inline double __dsqrt_rz(double x) { - return __hip_fast_dsqrt(x); -} - -__device__ inline double __fma_rd(double x, double y, double z) { - return __hip_fast_fma(x, y, z); -} - -__device__ inline double __fma_rn(double x, double y, double z) { - return __hip_fast_fma(x, y, z); -} - -__device__ inline double __fma_ru(double x, double y, double z) { - return __hip_fast_fma(x, y, z); -} - -__device__ inline double __fma_rz(double x, double y, double z) { - return __hip_fast_fma(x, y, z); +__device__ static inline double __dmul_rz(double x, double y) { + return x * y; } __device__ inline double __drcp_rd(double x) { @@ -190,6 +286,55 @@ __device__ inline double __drcp_rz(double x) { } +__device__ inline double __dsqrt_rd(double x) { + return __hip_fast_dsqrt(x); +} + +__device__ inline double __dsqrt_rn(double x) { + return __hip_fast_dsqrt(x); +} + +__device__ inline double __dsqrt_ru(double x) { + return __hip_fast_dsqrt(x); +} + +__device__ inline double __dsqrt_rz(double x) { + return __hip_fast_dsqrt(x); +} + +__device__ static inline double __dsub_rd(double x, double y) { + return x - y; +} + +__device__ static inline double __dsub_rn(double x, double y) { + return x - y; +} + +__device__ static inline double __dsub_ru(double x, double y) { + return x - y; +} + +__device__ static inline double __dsub_rz(double x, double y) { + return x - y; +} + +__device__ inline double __fma_rd(double x, double y, double z) { + return __hip_fast_fma(x, y, z); +} + +__device__ inline double __fma_rn(double x, double y, double z) { + return __hip_fast_fma(x, y, z); +} + +__device__ inline double __fma_ru(double x, double y, double z) { + return __hip_fast_fma(x, y, z); +} + +__device__ inline double __fma_rz(double x, double y, double z) { + return __hip_fast_fma(x, y, z); +} + + extern "C" unsigned int __hip_hc_ir_umul24_int(unsigned int, unsigned int); extern "C" signed int __hip_hc_ir_mul24_int(signed int, signed int); extern "C" signed int __hip_hc_ir_mulhi_int(signed int, signed int); @@ -204,51 +349,42 @@ __device__ unsigned int __clz(int x); __device__ unsigned int __clzll(long long int x); __device__ unsigned int __ffs(int x); __device__ unsigned int __ffsll(long long int x); -__device__ static inline unsigned int __hadd(int x, int y) -{ +__device__ static inline unsigned int __hadd(int x, int y) { int z = x + y; int sign = z & 0x8000000; int value = z & 0x7FFFFFFF; return ((value) >> 1 || sign); } -__device__ static inline int __mul24(int x, int y) -{ +__device__ static inline int __mul24(int x, int y) { return __hip_hc_ir_mul24_int(x, y); } __device__ long long int __mul64hi(long long int x, long long int y); -__device__ static inline int __mulhi(int x, int y) -{ +__device__ static inline int __mulhi(int x, int y) { return __hip_hc_ir_mulhi_int(x, y); } __device__ unsigned int __popc( unsigned int x); __device__ unsigned int __popcll( unsigned long long int x); -__device__ static inline int __rhadd(int x, int y) -{ +__device__ static inline int __rhadd(int x, int y) { int z = x + y + 1; int sign = z & 0x8000000; int value = z & 0x7FFFFFFF; return ((value) >> 1 || sign); } -__device__ static inline unsigned int __sad(int x, int y, int z) -{ +__device__ static inline unsigned int __sad(int x, int y, int z) { return x > y ? x - y + z : y - x + z; } -__device__ static inline unsigned int __uhadd(unsigned int x, unsigned int y) -{ +__device__ static inline unsigned int __uhadd(unsigned int x, unsigned int y) { return (x + y) >> 1; } -__device__ static inline int __umul24(unsigned int x, unsigned int y) -{ +__device__ static inline int __umul24(unsigned int x, unsigned int y) { return __hip_hc_ir_umul24_int(x, y); } __device__ unsigned long long int __umul64hi(unsigned long long int x, unsigned long long int y); -__device__ static inline unsigned int __umulhi(unsigned int x, unsigned int y) -{ +__device__ static inline unsigned int __umulhi(unsigned int x, unsigned int y) { return __hip_hc_ir_umulhi_int(x, y); } -__device__ static inline unsigned int __urhadd(unsigned int x, unsigned int y) -{ +__device__ static inline unsigned int __urhadd(unsigned int x, unsigned int y) { return (x + y + 1) >> 1; } __device__ static inline unsigned int __usad(unsigned int x, unsigned int y, unsigned int z) @@ -266,7 +402,6 @@ __device__ float __double2float_ru(double x); __device__ float __double2float_rz(double x); __device__ int __double2hiint(double x); -__device__ int __double2loint(double x); __device__ int __double2int_rd(double x); __device__ int __double2int_rn(double x); @@ -278,6 +413,8 @@ __device__ long long int __double2ll_rn(double x); __device__ long long int __double2ll_ru(double x); __device__ long long int __double2ll_rz(double x); +__device__ int __double2loint(double x); + __device__ unsigned int __double2uint_rd(double x); __device__ unsigned int __double2uint_rn(double x); __device__ unsigned int __double2uint_ru(double x); diff --git a/projects/hip/include/hip/hcc_detail/math_functions.h b/projects/hip/include/hip/hcc_detail/math_functions.h index 5a0e21f83c..21ec4510c6 100644 --- a/projects/hip/include/hip/hcc_detail/math_functions.h +++ b/projects/hip/include/hip/hcc_detail/math_functions.h @@ -34,16 +34,19 @@ __device__ float atanhf(float x); __device__ float cbrtf(float x); __device__ float ceilf(float x); __device__ float copysignf(float x, float y); +__device__ float cosf(float x); __device__ float coshf(float x); -__device__ float cyl_bessel_i0f(float x); -__device__ float cyl_bessel_i1f(float x); +__device__ __host__ float cospif(float x); +//__device__ float cyl_bessel_i0f(float x); +//__device__ float cyl_bessel_i1f(float x); __device__ float erfcf(float x); __device__ float erfcinvf(float y); - __device__ float erfcxf(float x); __device__ float erff(float x); __device__ float erfinvf(float y); +__device__ float exp10f(float x); __device__ float exp2f(float x); +__device__ float expf(float x); __device__ float expm1f(float x); __device__ float fabsf(float x); __device__ float fdimf(float x, float y); @@ -53,32 +56,34 @@ __device__ float fmaf(float x, float y, float z); __device__ float fmaxf(float x, float y); __device__ float fminf(float x, float y); __device__ float fmodf(float x, float y); -__device__ float frexpf(float x, float y); +//__device__ float frexpf(float x, int* nptr); __device__ float hypotf(float x, float y); __device__ float ilogbf(float x); -__host__ __device__ int isfinite(float a); +__device__ __host__ int isfinite(float a); __device__ unsigned isinf(float a); __device__ unsigned isnan(float a); __device__ float j0f(float x); __device__ float j1f(float x); __device__ float jnf(int n, float x); __device__ float ldexpf(float x, int exp); -__device__ float lgammaf(float x); +//__device__ float lgammaf(float x); __device__ long long int llrintf(float x); __device__ long long int llroundf(float x); +__device__ float log10f(float x); __device__ float log1pf(float x); __device__ float logbf(float x); __device__ long int lrintf(float x); __device__ long int lroundf(float x); -__device__ float modff(float x, float *iptr); +//__device__ float modff(float x, float *iptr); __device__ float nanf(const char* tagp); __device__ float nearbyintf(float x); -__device__ float nextafterf(float x, float y); +//__device__ float nextafterf(float x, float y); __device__ float norm3df(float a, float b, float c); __device__ float norm4df(float a, float b, float c, float d); __device__ float normcdff(float y); __device__ float normcdfinvf(float y); __device__ float normf(int dim, const float *a); +__device__ float powf(float x, float y); __device__ float rcbrtf(float x); __device__ float remainderf(float x, float y); __device__ float remquof(float x, float y, int *quo); @@ -88,14 +93,17 @@ __device__ float rnorm3df(float a, float b, float c); __device__ float rnorm4df(float a, float b, float c, float d); __device__ float rnormf(int dim, const float* a); __device__ float roundf(float x); -__device__ float rsqrtf(float x); +__device__ __host__ float rsqrtf(float x); __device__ float scalblnf(float x, long int n); __device__ float scalbnf(float x, int n); -__host__ __device__ unsigned signbit(float a); +__device__ __host__ unsigned signbit(float a); +__device__ void sincosf(float x, float *sptr, float *cptr); __device__ void sincospif(float x, float *sptr, float *cptr); +__device__ float sinf(float x); __device__ float sinhf(float x); -__device__ float sinpif(float x); +__device__ __host__ float sinpif(float x); __device__ float sqrtf(float x); +__device__ float tanf(float x); __device__ float tanhf(float x); __device__ float tgammaf(float x); __device__ float truncf(float x); @@ -103,12 +111,8 @@ __device__ float y0f(float x); __device__ float y1f(float x); __device__ float ynf(int n, float x); -__host__ __device__ float cospif(float x); -__host__ __device__ float sinpif(float x); -// /__device__ float sqrtf(float x); -__host__ __device__ float rsqrtf(float x); -__host__ float normcdff(float y); +__host__ float normcdff(float y); __host__ float erfcinvf(float y); __host__ float erfcxf(float x); __host__ float erfinvf(float y); @@ -122,6 +126,8 @@ __host__ float rnormf(int dim, const float* a); __host__ float rnorm4df(float a, float b, float c, float d); __host__ void sincospif(float x, float *sptr, float *cptr); + + __device__ double acos(double x); __device__ double acosh(double x); __device__ double asin(double x); @@ -134,7 +140,7 @@ __device__ double ceil(double x); __device__ double copysign(double x, double y); __device__ double cos(double x); __device__ double cosh(double x); -__host__ __device__ double cospi(double x); +__device__ __host__ double cospi(double x); __device__ double cyl_bessel_i0(double x); __device__ double cyl_bessel_i1(double x); __device__ double erf(double x); @@ -153,10 +159,10 @@ __device__ double fma(double x, double y, double z); __device__ double fmax(double x, double y); __device__ double fmin(double x, double y); __device__ double fmod(double x, double y); -__device__ double frexp(double x, int *nptr); +//__device__ double frexp(double x, int *nptr); __device__ double hypot(double x, double y); __device__ double ilogb(double x); -__host__ __device__ unsigned isfinite(double x); +__device__ __host__ unsigned isfinite(double x); __device__ unsigned isinf(double x); __device__ unsigned isnan(double x); __device__ double j0(double x); @@ -173,44 +179,34 @@ __device__ double log2(double x); __device__ double logb(double x); __device__ long int lrint(double x); __device__ long int lround(double x); -__device__ double modf(double x, double *iptr); +//__device__ double modf(double x, double *iptr); __device__ double nan(const char* tagp); __device__ double nearbyint(double x); __device__ double nextafter(double x, double y); __device__ double norm(int dim, const double* t); __device__ double norm3d(double a, double b, double c); -__host__ double norm3d(double a, double b, double c); __device__ double norm4d(double a, double b, double c, double d); -__host__ double norm4d(double a, double b, double c, double d); __device__ double normcdf(double y); -__host__ double normcdf(double y); __device__ double normcdfinv(double y); -__host__ double normcdfinv(double y); __device__ double pow(double x, double y); __device__ double rcbrt(double x); -__host__ double rcbrt(double x); __device__ double remainder(double x, double y); -__device__ double remquo(double x, double y, int *quo); +//__device__ double remquo(double x, double y, int *quo); __device__ double rhypot(double x, double y); -__host__ double rhypot(double x, double y); __device__ double rint(double x); __device__ double rnorm(int dim, const double* t); -__host__ double rnorm(int dim, const double* t); __device__ double rnorm3d(double a, double b, double c); -__host__ double rnorm3d(double a, double b, double c); __device__ double rnorm4d(double a, double b, double c, double d); -__host__ double rnorm4d(double a, double b, double c, double d); __device__ double round(double x); -__host__ __device__ double rsqrt(double x); +__device__ __host__ double rsqrt(double x); __device__ double scalbln(double x, long int n); __device__ double scalbn(double x, int n); -__host__ __device__ unsigned signbit(double a); +__device__ __host__ unsigned signbit(double a); __device__ double sin(double a); __device__ void sincos(double x, double *sptr, double *cptr); __device__ void sincospi(double x, double *sptr, double *cptr); -__host__ void sincospi(double x, double *sptr, double *cptr); __device__ double sinh(double x); -__host__ __device__ double sinpi(double x); +__device__ __host__ double sinpi(double x); __device__ double sqrt(double x); __device__ double tan(double x); __device__ double tanh(double x); @@ -224,7 +220,17 @@ __host__ double erfcinv(double y); __host__ double erfcx(double x); __host__ double erfinv(double y); __host__ double fdivide(double x, double y); -__host__ double norm(double x, const double *t); +__host__ double norm(int dim, const double *t); +__host__ double norm3d(double a, double b, double c); +__host__ double norm4d(double a, double b, double c, double d); +__host__ double normcdf(double y); +__host__ double normcdfinv(double y); +__host__ double rcbrt(double x); +__host__ double rhypot(double x, double y); +__host__ double rnorm(int dim, const double* t); +__host__ double rnorm3d(double a, double b, double c); +__host__ double rnorm4d(double a, double b, double c, double d); +__host__ void sincospi(double x, double *sptr, double *cptr); #ifdef HIP_FAST_MATH // Single Precision Precise Math when enabled diff --git a/projects/hip/src/math_functions.cpp b/projects/hip/src/math_functions.cpp index 34a80448db..130d4152ae 100644 --- a/projects/hip/src/math_functions.cpp +++ b/projects/hip/src/math_functions.cpp @@ -186,9 +186,10 @@ __device__ float ldexpf(float x, int exp) { return hc::precise_math::ldexpf(x, exp); } -__device__ float lgammaf(float x, int *sign) +__device__ float lgammaf(float x) { - return hc::precise_math::lgammaf(x, sign); + int sign; + return hc::precise_math::lgammaf(x, &sign); } __device__ long long int llrintf(float x) { @@ -566,9 +567,10 @@ __device__ double ldexp(double x, int exp) { return hc::precise_math::ldexp(x, exp); } -__device__ double lgamma(double x, int *sign) +__device__ double lgamma(double x) { - return hc::precise_math::lgamma(x, sign); + int sign; + return hc::precise_math::lgamma(x, &sign); } __device__ long long int llrint(double x) { @@ -626,6 +628,14 @@ __device__ double nextafter(double x, double y) { return hc::precise_math::nextafter(x, y); } +__device__ double norm(int x, const double *d) +{ + double val = 0; + for(int i=0;i Date: Wed, 18 Jan 2017 14:40:50 -0600 Subject: [PATCH 078/281] Added script for generating math api docs 1. Commented out unsupported device math functions 2. Moved function signatures to the top of implementation snippets 3. Added script to generate markdown documentation for device math apis 4. Added the generated file from the script which should be present everytime Change-Id: Ic579dd8b8fdffa6e1b4d4f5f3fd8a803f4dcaac7 [ROCm/hip commit: 91ae5d6bd773ff962228386b6d3c01c76512c692] --- projects/hip/docs/markdown/device_md_gen.py | 508 +++ projects/hip/docs/markdown/hip-math-api.md | 3470 +++++++++++++++++ .../include/hip/hcc_detail/device_functions.h | 108 +- .../include/hip/hcc_detail/math_functions.h | 6 +- 4 files changed, 4081 insertions(+), 11 deletions(-) create mode 100644 projects/hip/docs/markdown/device_md_gen.py create mode 100644 projects/hip/docs/markdown/hip-math-api.md diff --git a/projects/hip/docs/markdown/device_md_gen.py b/projects/hip/docs/markdown/device_md_gen.py new file mode 100644 index 0000000000..4795ea98e0 --- /dev/null +++ b/projects/hip/docs/markdown/device_md_gen.py @@ -0,0 +1,508 @@ +""" +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +""" + +""" +1. This files uses Python3 to run + +List of device functions: +acosf +acoshf +asinf +asinhf +atan2f +atanf +atanhf +cbrtf +ceilf +copysignf +cosf +coshf +cospif +cyl_bessel_i0f +cyl_bessel_i1f +erfcf +erfcinvf +erfcxf +erff +erfinvf +exp10f +exp2f +expf +expm1f +fabsf +fdimf +fdividef +floorf +fmaf +fmaxf +fminf +fmodf +frexpf +hypotf +ilogbf +isfinite +isinf +isnan +j0f +j1f +jnf +ldexpf +lgammaf +llrintf +llroundf +log10f +log1pf +logbf +lrintf +lroundf +modff +nanf +nearbyintf +nextafterf +norm3df +norm4df +normcdff +normcdfinvf +normf +powf +rcbrtf +remainderf +remquof +rhypotf +rintf +rnorm3df +rnorm4df +rnormf +roundf +rsqrtf +scalblnf +scalbnf +signbit +sincosf +sincospif +sinf +sinhf +sinpif +sqrtf +tanf +tanhf +tgammaf +truncf +y0f +y1f +ynf +acos +acosh +asin +asinh +atan +atan2 +atanh +cbrt +ceil +copysign +cos +cosh +cospi +cyl_bessel_i0 +cyl_bessel_i1 +erf +erfc +erfcinv +erfcx +erfinv +exp +exp10 +exp2 +expm1 +fabs +fdim +floor +fma +fmax +fmin +fmod +frexp +hypot +ilogb +isfinite +isinf +isnan +j0 +j1 +jn +ldexp +lgamma +llrint +llround +log +log10 +log1p +log2 +logb +lrint +lround +modf +nan +nearbyint +nextafter +norm +norm3d +norm4d +normcdf +normcdfinv +pow +rcbrt +remainder +remquo +rhypot +rint +rnorm +rnorm3d +rnorm4d +round +rsqrt +scalbln +scalbn +signbit +sin +sincos +sincospi +sinh +sinpi +sqrt +tan +tanh +tgamma +trunc +y0 +y1 +yn +__cosf +__exp10f +__expf +__fadd_rd +__fadd_rn +__fadd_ru +__fadd_rz +__fdiv_rd +__fdiv_rn +__fdiv_ru +__fdiv_rz +__fdividef +__fmaf_rd +__fmaf_rn +__fmaf_ru +__fmaf_rz +__fmul_rd +__fmul_rn +__fmul_ru +__fmul_rz +__frcp_rd +__frcp_rn +__frcp_ru +__frcp_rz +__frsqrt_rn +__fsqrt_rd +__fsqrt_rn +__fsqrt_ru +__fsqrt_rz +__fsub_rd +__fsub_rn +__fsub_ru +__log10f +__log2f +__logf +__powf +__saturatef +__sincosf +__sinf +__tanf +__dadd_rd +__dadd_rn +__dadd_ru +__dadd_rz +__ddiv_rd +__ddiv_rn +__ddiv_ru +__ddiv_rz +__dmul_rd +__dmul_rn +__dmul_ru +__dmul_rz +__drcp_rd +__drcp_rn +__drcp_ru +__drcp_rz +__dsqrt_rd +__dsqrt_rn +__dsqrt_ru +__dsqrt_rz +__dsub_rd +__dsub_rn +__dsub_ru +__dsub_rz +__fma_rd +__fma_rn +__fma_ru +__fma_rz +__brev +__brevll +__byte_perm +__clz +__clzll +__ffs +__ffsll +__hadd +__mul24 +__mul64hi +__mulhi +__popc +__popcll +__rhadd +__sad +__uhadd +__umul24 +__umul64hi +__umulhi +__urhadd +__usad +__double2float_rd +__double2float_rn +__double2float_ru +__double2float_rz +__double2hiint +__double2int_rd +__double2int_rn +__double2int_ru +__double2int_rz +__double2ll_rd +__double2ll_rn +__double2ll_ru +__double2ll_rz +__double2loint +__double2uint_rd +__double2uint_rn +__double2uint_ru +__double2uint_rz +__double2ull_rd +__double2ull_rn +__double2ull_ru +__double2ull_rz +__double_as_longlong +__float2half_rn +__half2float +__float2half_rn +__half2float +__float2int_rd +__float2int_rn +__float2int_ru +__float2int_rz +__float2ll_rd +__float2ll_rn +__float2ll_ru +__float2ll_rz +__float2uint_rd +__float2uint_rn +__float2uint_ru +__float2uint_rz +__float2ull_rd +__float2ull_rn +__float2ull_ru +__float2ull_rz +__float_as_int +__float_as_uint +__hiloint2double +__int2double_rn +__int2float_rd +__int2float_rn +__int2float_ru +__int2float_rz +__int_as_float +__ll2double_rd +__ll2double_rn +__ll2double_ru +__ll2double_rz +__ll2float_rd +__ll2float_rn +__ll2float_ru +__ll2float_rz +__longlong_as_double +__uint2double_rn +__uint2float_rd +__uint2float_rn +__uint2float_ru +__uint2float_rz +__uint_as_float +__ull2double_rd +__ull2double_rn +__ull2double_ru +__ull2double_rz +__ull2float_rd +__ull2float_rn +__ull2float_ru +__ull2float_rz +__heq +__hge +__hgt +__hisinf +__hisnan +__hle +__hlt +__hne +__hbeq2 +__hbge2 +__hbgt2 +__hble2 +__hblt2 +__hbne2 +__heq2 +__hge2 +__hgt2 +__hisnan2 +__hle2 +__hlt2 +__hne2 +__float22half2_rn +__float2half +__float2half2_rn +__float2half_rd +__float2half_rn +__float2half_ru +__float2half_rz +__floats2half2_rn +__half22float2 +__half2float +half2half2 +__half2int_rd +__half2int_rn +__half2int_ru +__half2int_rz +__half2ll_rd +__half2ll_rn +__half2ll_ru +__half2ll_rz +__half2short_rd +__half2short_rn +__half2short_ru +__half2short_rz +__half2uint_rd +__half2uint_rn +__half2uint_ru +__half2uint_rz +__half2ull_rd +__half2ull_rn +__half2ull_ru +__half2ull_rz +__half2ushort_rd +__half2ushort_rn +__half2ushort_ru +__half2ushort_rz +__half_as_short +__half_as_ushort +__halves2half2 +__high2float +__high2half +__high2half2 +__highs2half2 +__int2half_rd +__int2half_rn +__int2half_ru +__int2half_rz +__ll2half_rd +__ll2half_rn +__ll2half_ru +__ll2half_rz +__low2float +__low2half +__low2half2 +__low2half2 +__lowhigh2highlow +__lows2half2 +__short2half_rd +__short2half_rn +__short2half_ru +__short2half_rz +__uint2half_rd +__uint2half_rn +__uint2half_ru +__uint2half_rz +__ull2half_rd +__ull2half_rn +__ull2half_ru +__ull2half_rz +__ushort2half_rd +__ushort2half_rn +__ushort2half_ru +__ushort2half_rz +__ushort_as_half +""" +# The dictionary is to place description of each device function. Expand it to all the device functions +deviceFuncDesc = {'acosf': "This function returns floating point of arc cosine from a floating point input"} + +fnames = ["../../include/hip/hcc_detail/math_functions.h","../../include/hip/hcc_detail/device_functions.h","../../include/hip/hcc_detail/hip_fp16.h"] +markdownFileName = "./hip-math-api.md" + +preamble = "# HIP MATH APIs Documentation \n"+\ +"HIP supports most of the device functions supported by CUDA. Way to find the unsupported one is to search for the function and check its description\n" + \ +"Note: This document is not human generated. Any changes to this file will be discarded. Please make changes to Python3 script docs/markdown/device_md_gen.py\n\n" + \ +"## For Developers \n" + \ +"If you add or fixed a device function, make sure to add a signature of the function and definition later.\n" + \ +"For example, if you want to add `__device__ float __dotf(float4, float4)`, which does a dot product on 4 float vector components \n" + \ +"The way to add to the header is, \n" + \ +"```cpp \n" + \ +"__device__ static float __dotf(float4, float4); \n" + \ +"/*Way down in the file....*/\n" + \ +"__device__ static inline float __dotf(float4 x, float4 y) { \n" + \ +" /*implementation*/\n}\n" + \ +"```\n\n" + \ +"This helps python script to add the device function newly declared into markdown documentation (as it looks at functions with `;` at the end and `__device__` at the beginning)\n\n" + \ +"The next step would be to add Description to `deviceFuncDesc`.\n" + \ +"From the above example, it can be writtern as,\n`deviceFuncDesc['__dotf'] = 'This functions takes 2 4 component float vector and outputs dot product across them'`\n\n" + +def generateSnippet(name, description, signature): + return "### " + name + "\n" + \ + "```cpp \n" + signature + "\n```\n" + \ + "**Description:** " + description + "\n\n\n" + +def getName(line): + l1 = line.split('(') + l2 = l1[0].split(' ') + return l2[-1] + +with open(markdownFileName, 'w') as mdfd: + mdfd.truncate() + mdfd.write(preamble) + for fname in fnames: + with open(fname) as fd: + lines = fd.readlines() + for line in lines: + if line.find('HIP_FAST_MATH') != -1: + break; + if line.find('__device__') != -1 and line.find(';') != -1 and line.find('hip') == -1: + name = getName(line) + if line.find('//') == -1: + if name in deviceFuncDesc: + mdfd.write(generateSnippet(name, deviceFuncDesc[name], line)) + else: + mdfd.write(generateSnippet(name, "Supported", line)) + else: + mdfd.write(generateSnippet(name, "**NOT Supported**", line)) + fd.close() + mdfd.close() diff --git a/projects/hip/docs/markdown/hip-math-api.md b/projects/hip/docs/markdown/hip-math-api.md new file mode 100644 index 0000000000..daf34fbfa3 --- /dev/null +++ b/projects/hip/docs/markdown/hip-math-api.md @@ -0,0 +1,3470 @@ +# HIP MATH APIs Documentation +HIP supports most of the device functions supported by CUDA. Way to find the unsupported one is to search for the function and check its description +Note: This document is not human generated. Any changes to this file will be discarded. Please make changes to Python3 script docs/markdown/device_md_gen.py + +## For Developers +If you add or fixed a device function, make sure to add a signature of the function and definition later. +For example, if you want to add `__device__ float __dotf(float4, float4)`, which does a dot product on 4 float vector components +The way to add to the header is, +```cpp +__device__ static float __dotf(float4, float4); +/*Way down in the file....*/ +__device__ static inline float __dotf(float4 x, float4 y) { + /*implementation*/ +} +``` + +This helps python script to add the device function newly declared into markdown documentation (as it looks at functions with `;` at the end and `__device__` at the beginning) + +The next step would be to add Description to `deviceFuncDesc`. +From the above example, it can be writtern as, +`deviceFuncDesc['__dotf'] = 'This functions takes 2 4 component float vector and outputs dot product across them'` + +### acosf +```cpp +__device__ float acosf(float x); + +``` +**Description:** This function returns floating point of arc cosine from a floating point input + + +### acoshf +```cpp +__device__ float acoshf(float x); + +``` +**Description:** Supported + + +### asinf +```cpp +__device__ float asinf(float x); + +``` +**Description:** Supported + + +### asinhf +```cpp +__device__ float asinhf(float x); + +``` +**Description:** Supported + + +### atan2f +```cpp +__device__ float atan2f(float y, float x); + +``` +**Description:** Supported + + +### atanf +```cpp +__device__ float atanf(float x); + +``` +**Description:** Supported + + +### atanhf +```cpp +__device__ float atanhf(float x); + +``` +**Description:** Supported + + +### cbrtf +```cpp +__device__ float cbrtf(float x); + +``` +**Description:** Supported + + +### ceilf +```cpp +__device__ float ceilf(float x); + +``` +**Description:** Supported + + +### copysignf +```cpp +__device__ float copysignf(float x, float y); + +``` +**Description:** Supported + + +### cosf +```cpp +__device__ float cosf(float x); + +``` +**Description:** Supported + + +### coshf +```cpp +__device__ float coshf(float x); + +``` +**Description:** Supported + + +### cospif +```cpp +__device__ __host__ float cospif(float x); + +``` +**Description:** Supported + + +### cyl_bessel_i0f +```cpp +//__device__ float cyl_bessel_i0f(float x); + +``` +**Description:** **NOT Supported** + + +### cyl_bessel_i1f +```cpp +//__device__ float cyl_bessel_i1f(float x); + +``` +**Description:** **NOT Supported** + + +### erfcf +```cpp +__device__ float erfcf(float x); + +``` +**Description:** Supported + + +### erfcinvf +```cpp +__device__ float erfcinvf(float y); + +``` +**Description:** Supported + + +### erfcxf +```cpp +__device__ float erfcxf(float x); + +``` +**Description:** Supported + + +### erff +```cpp +__device__ float erff(float x); + +``` +**Description:** Supported + + +### erfinvf +```cpp +__device__ float erfinvf(float y); + +``` +**Description:** Supported + + +### exp10f +```cpp +__device__ float exp10f(float x); + +``` +**Description:** Supported + + +### exp2f +```cpp +__device__ float exp2f(float x); + +``` +**Description:** Supported + + +### expf +```cpp +__device__ float expf(float x); + +``` +**Description:** Supported + + +### expm1f +```cpp +__device__ float expm1f(float x); + +``` +**Description:** Supported + + +### fabsf +```cpp +__device__ float fabsf(float x); + +``` +**Description:** Supported + + +### fdimf +```cpp +__device__ float fdimf(float x, float y); + +``` +**Description:** Supported + + +### fdividef +```cpp +__device__ __host__ float fdividef(float x, float y); + +``` +**Description:** Supported + + +### floorf +```cpp +__device__ float floorf(float x); + +``` +**Description:** Supported + + +### fmaf +```cpp +__device__ float fmaf(float x, float y, float z); + +``` +**Description:** Supported + + +### fmaxf +```cpp +__device__ float fmaxf(float x, float y); + +``` +**Description:** Supported + + +### fminf +```cpp +__device__ float fminf(float x, float y); + +``` +**Description:** Supported + + +### fmodf +```cpp +__device__ float fmodf(float x, float y); + +``` +**Description:** Supported + + +### frexpf +```cpp +//__device__ float frexpf(float x, int* nptr); + +``` +**Description:** **NOT Supported** + + +### hypotf +```cpp +__device__ float hypotf(float x, float y); + +``` +**Description:** Supported + + +### ilogbf +```cpp +__device__ float ilogbf(float x); + +``` +**Description:** Supported + + +### isfinite +```cpp +__device__ __host__ int isfinite(float a); + +``` +**Description:** Supported + + +### isinf +```cpp +__device__ unsigned isinf(float a); + +``` +**Description:** Supported + + +### isnan +```cpp +__device__ unsigned isnan(float a); + +``` +**Description:** Supported + + +### j0f +```cpp +__device__ float j0f(float x); + +``` +**Description:** Supported + + +### j1f +```cpp +__device__ float j1f(float x); + +``` +**Description:** Supported + + +### jnf +```cpp +__device__ float jnf(int n, float x); + +``` +**Description:** Supported + + +### ldexpf +```cpp +__device__ float ldexpf(float x, int exp); + +``` +**Description:** Supported + + +### lgammaf +```cpp +//__device__ float lgammaf(float x); + +``` +**Description:** **NOT Supported** + + +### llrintf +```cpp +__device__ long long int llrintf(float x); + +``` +**Description:** Supported + + +### llroundf +```cpp +__device__ long long int llroundf(float x); + +``` +**Description:** Supported + + +### log10f +```cpp +__device__ float log10f(float x); + +``` +**Description:** Supported + + +### log1pf +```cpp +__device__ float log1pf(float x); + +``` +**Description:** Supported + + +### logbf +```cpp +__device__ float logbf(float x); + +``` +**Description:** Supported + + +### lrintf +```cpp +__device__ long int lrintf(float x); + +``` +**Description:** Supported + + +### lroundf +```cpp +__device__ long int lroundf(float x); + +``` +**Description:** Supported + + +### modff +```cpp +//__device__ float modff(float x, float *iptr); + +``` +**Description:** **NOT Supported** + + +### nanf +```cpp +__device__ float nanf(const char* tagp); + +``` +**Description:** Supported + + +### nearbyintf +```cpp +__device__ float nearbyintf(float x); + +``` +**Description:** Supported + + +### nextafterf +```cpp +//__device__ float nextafterf(float x, float y); + +``` +**Description:** **NOT Supported** + + +### norm3df +```cpp +__device__ float norm3df(float a, float b, float c); + +``` +**Description:** Supported + + +### norm4df +```cpp +__device__ float norm4df(float a, float b, float c, float d); + +``` +**Description:** Supported + + +### normcdff +```cpp +__device__ float normcdff(float y); + +``` +**Description:** Supported + + +### normcdfinvf +```cpp +__device__ float normcdfinvf(float y); + +``` +**Description:** Supported + + +### normf +```cpp +__device__ float normf(int dim, const float *a); + +``` +**Description:** Supported + + +### powf +```cpp +__device__ float powf(float x, float y); + +``` +**Description:** Supported + + +### rcbrtf +```cpp +__device__ float rcbrtf(float x); + +``` +**Description:** Supported + + +### remainderf +```cpp +__device__ float remainderf(float x, float y); + +``` +**Description:** Supported + + +### remquof +```cpp +__device__ float remquof(float x, float y, int *quo); + +``` +**Description:** Supported + + +### rhypotf +```cpp +__device__ float rhypotf(float x, float y); + +``` +**Description:** Supported + + +### rintf +```cpp +__device__ float rintf(float x); + +``` +**Description:** Supported + + +### rnorm3df +```cpp +__device__ float rnorm3df(float a, float b, float c); + +``` +**Description:** Supported + + +### rnorm4df +```cpp +__device__ float rnorm4df(float a, float b, float c, float d); + +``` +**Description:** Supported + + +### rnormf +```cpp +__device__ float rnormf(int dim, const float* a); + +``` +**Description:** Supported + + +### roundf +```cpp +__device__ float roundf(float x); + +``` +**Description:** Supported + + +### rsqrtf +```cpp +__device__ __host__ float rsqrtf(float x); + +``` +**Description:** Supported + + +### scalblnf +```cpp +__device__ float scalblnf(float x, long int n); + +``` +**Description:** Supported + + +### scalbnf +```cpp +__device__ float scalbnf(float x, int n); + +``` +**Description:** Supported + + +### signbit +```cpp +__device__ __host__ unsigned signbit(float a); + +``` +**Description:** Supported + + +### sincosf +```cpp +__device__ void sincosf(float x, float *sptr, float *cptr); + +``` +**Description:** Supported + + +### sincospif +```cpp +__device__ void sincospif(float x, float *sptr, float *cptr); + +``` +**Description:** Supported + + +### sinf +```cpp +__device__ float sinf(float x); + +``` +**Description:** Supported + + +### sinhf +```cpp +__device__ float sinhf(float x); + +``` +**Description:** Supported + + +### sinpif +```cpp +__device__ __host__ float sinpif(float x); + +``` +**Description:** Supported + + +### sqrtf +```cpp +__device__ float sqrtf(float x); + +``` +**Description:** Supported + + +### tanf +```cpp +__device__ float tanf(float x); + +``` +**Description:** Supported + + +### tanhf +```cpp +__device__ float tanhf(float x); + +``` +**Description:** Supported + + +### tgammaf +```cpp +__device__ float tgammaf(float x); + +``` +**Description:** Supported + + +### truncf +```cpp +__device__ float truncf(float x); + +``` +**Description:** Supported + + +### y0f +```cpp +__device__ float y0f(float x); + +``` +**Description:** Supported + + +### y1f +```cpp +__device__ float y1f(float x); + +``` +**Description:** Supported + + +### ynf +```cpp +__device__ float ynf(int n, float x); + +``` +**Description:** Supported + + +### acos +```cpp +__device__ double acos(double x); + +``` +**Description:** Supported + + +### acosh +```cpp +__device__ double acosh(double x); + +``` +**Description:** Supported + + +### asin +```cpp +__device__ double asin(double x); + +``` +**Description:** Supported + + +### asinh +```cpp +__device__ double asinh(double x); + +``` +**Description:** Supported + + +### atan +```cpp +__device__ double atan(double x); + +``` +**Description:** Supported + + +### atan2 +```cpp +__device__ double atan2(double y, double x); + +``` +**Description:** Supported + + +### atanh +```cpp +__device__ double atanh(double x); + +``` +**Description:** Supported + + +### cbrt +```cpp +__device__ double cbrt(double x); + +``` +**Description:** Supported + + +### ceil +```cpp +__device__ double ceil(double x); + +``` +**Description:** Supported + + +### copysign +```cpp +__device__ double copysign(double x, double y); + +``` +**Description:** Supported + + +### cos +```cpp +__device__ double cos(double x); + +``` +**Description:** Supported + + +### cosh +```cpp +__device__ double cosh(double x); + +``` +**Description:** Supported + + +### cospi +```cpp +__device__ __host__ double cospi(double x); + +``` +**Description:** Supported + + +### cyl_bessel_i0 +```cpp +//__device__ double cyl_bessel_i0(double x); + +``` +**Description:** **NOT Supported** + + +### cyl_bessel_i1 +```cpp +//__device__ double cyl_bessel_i1(double x); + +``` +**Description:** **NOT Supported** + + +### erf +```cpp +__device__ double erf(double x); + +``` +**Description:** Supported + + +### erfc +```cpp +__device__ double erfc(double x); + +``` +**Description:** Supported + + +### erfcinv +```cpp +__device__ double erfcinv(double y); + +``` +**Description:** Supported + + +### erfcx +```cpp +__device__ double erfcx(double x); + +``` +**Description:** Supported + + +### erfinv +```cpp +__device__ double erfinv(double x); + +``` +**Description:** Supported + + +### exp +```cpp +__device__ double exp(double x); + +``` +**Description:** Supported + + +### exp10 +```cpp +__device__ double exp10(double x); + +``` +**Description:** Supported + + +### exp2 +```cpp +__device__ double exp2(double x); + +``` +**Description:** Supported + + +### expm1 +```cpp +__device__ double expm1(double x); + +``` +**Description:** Supported + + +### fabs +```cpp +__device__ double fabs(double x); + +``` +**Description:** Supported + + +### fdim +```cpp +__device__ double fdim(double x, double y); + +``` +**Description:** Supported + + +### floor +```cpp +__device__ double floor(double x); + +``` +**Description:** Supported + + +### fma +```cpp +__device__ double fma(double x, double y, double z); + +``` +**Description:** Supported + + +### fmax +```cpp +__device__ double fmax(double x, double y); + +``` +**Description:** Supported + + +### fmin +```cpp +__device__ double fmin(double x, double y); + +``` +**Description:** Supported + + +### fmod +```cpp +__device__ double fmod(double x, double y); + +``` +**Description:** Supported + + +### frexp +```cpp +//__device__ double frexp(double x, int *nptr); + +``` +**Description:** **NOT Supported** + + +### hypot +```cpp +__device__ double hypot(double x, double y); + +``` +**Description:** Supported + + +### ilogb +```cpp +__device__ double ilogb(double x); + +``` +**Description:** Supported + + +### isfinite +```cpp +__device__ __host__ unsigned isfinite(double x); + +``` +**Description:** Supported + + +### isinf +```cpp +__device__ unsigned isinf(double x); + +``` +**Description:** Supported + + +### isnan +```cpp +__device__ unsigned isnan(double x); + +``` +**Description:** Supported + + +### j0 +```cpp +__device__ double j0(double x); + +``` +**Description:** Supported + + +### j1 +```cpp +__device__ double j1(double x); + +``` +**Description:** Supported + + +### jn +```cpp +__device__ double jn(int n, double x); + +``` +**Description:** Supported + + +### ldexp +```cpp +__device__ double ldexp(double x, int exp); + +``` +**Description:** Supported + + +### lgamma +```cpp +__device__ double lgamma(double x); + +``` +**Description:** Supported + + +### llrint +```cpp +__device__ long long llrint(double x); + +``` +**Description:** Supported + + +### llround +```cpp +__device__ long long llround(double x); + +``` +**Description:** Supported + + +### log +```cpp +__device__ double log(double x); + +``` +**Description:** Supported + + +### log10 +```cpp +__device__ double log10(double x); + +``` +**Description:** Supported + + +### log1p +```cpp +__device__ double log1p(double x); + +``` +**Description:** Supported + + +### log2 +```cpp +__device__ double log2(double x); + +``` +**Description:** Supported + + +### logb +```cpp +__device__ double logb(double x); + +``` +**Description:** Supported + + +### lrint +```cpp +__device__ long int lrint(double x); + +``` +**Description:** Supported + + +### lround +```cpp +__device__ long int lround(double x); + +``` +**Description:** Supported + + +### modf +```cpp +//__device__ double modf(double x, double *iptr); + +``` +**Description:** **NOT Supported** + + +### nan +```cpp +__device__ double nan(const char* tagp); + +``` +**Description:** Supported + + +### nearbyint +```cpp +__device__ double nearbyint(double x); + +``` +**Description:** Supported + + +### nextafter +```cpp +__device__ double nextafter(double x, double y); + +``` +**Description:** Supported + + +### norm +```cpp +__device__ double norm(int dim, const double* t); + +``` +**Description:** Supported + + +### norm3d +```cpp +__device__ double norm3d(double a, double b, double c); + +``` +**Description:** Supported + + +### norm4d +```cpp +__device__ double norm4d(double a, double b, double c, double d); + +``` +**Description:** Supported + + +### normcdf +```cpp +__device__ double normcdf(double y); + +``` +**Description:** Supported + + +### normcdfinv +```cpp +__device__ double normcdfinv(double y); + +``` +**Description:** Supported + + +### pow +```cpp +__device__ double pow(double x, double y); + +``` +**Description:** Supported + + +### rcbrt +```cpp +__device__ double rcbrt(double x); + +``` +**Description:** Supported + + +### remainder +```cpp +__device__ double remainder(double x, double y); + +``` +**Description:** Supported + + +### remquo +```cpp +//__device__ double remquo(double x, double y, int *quo); + +``` +**Description:** **NOT Supported** + + +### rhypot +```cpp +__device__ double rhypot(double x, double y); + +``` +**Description:** Supported + + +### rint +```cpp +__device__ double rint(double x); + +``` +**Description:** Supported + + +### rnorm +```cpp +__device__ double rnorm(int dim, const double* t); + +``` +**Description:** Supported + + +### rnorm3d +```cpp +__device__ double rnorm3d(double a, double b, double c); + +``` +**Description:** Supported + + +### rnorm4d +```cpp +__device__ double rnorm4d(double a, double b, double c, double d); + +``` +**Description:** Supported + + +### round +```cpp +__device__ double round(double x); + +``` +**Description:** Supported + + +### rsqrt +```cpp +__device__ __host__ double rsqrt(double x); + +``` +**Description:** Supported + + +### scalbln +```cpp +__device__ double scalbln(double x, long int n); + +``` +**Description:** Supported + + +### scalbn +```cpp +__device__ double scalbn(double x, int n); + +``` +**Description:** Supported + + +### signbit +```cpp +__device__ __host__ unsigned signbit(double a); + +``` +**Description:** Supported + + +### sin +```cpp +__device__ double sin(double a); + +``` +**Description:** Supported + + +### sincos +```cpp +__device__ void sincos(double x, double *sptr, double *cptr); + +``` +**Description:** Supported + + +### sincospi +```cpp +__device__ void sincospi(double x, double *sptr, double *cptr); + +``` +**Description:** Supported + + +### sinh +```cpp +__device__ double sinh(double x); + +``` +**Description:** Supported + + +### sinpi +```cpp +__device__ __host__ double sinpi(double x); + +``` +**Description:** Supported + + +### sqrt +```cpp +__device__ double sqrt(double x); + +``` +**Description:** Supported + + +### tan +```cpp +__device__ double tan(double x); + +``` +**Description:** Supported + + +### tanh +```cpp +__device__ double tanh(double x); + +``` +**Description:** Supported + + +### tgamma +```cpp +__device__ double tgamma(double x); + +``` +**Description:** Supported + + +### trunc +```cpp +__device__ double trunc(double x); + +``` +**Description:** Supported + + +### y0 +```cpp +__device__ double y0(double x); + +``` +**Description:** Supported + + +### y1 +```cpp +__device__ double y1(double y); + +``` +**Description:** Supported + + +### yn +```cpp +__device__ double yn(int n, double x); + +``` +**Description:** Supported + + +### __cosf +```cpp +__device__ float __cosf(float x); + +``` +**Description:** Supported + + +### __exp10f +```cpp +__device__ float __exp10f(float x); + +``` +**Description:** Supported + + +### __expf +```cpp +__device__ float __expf(float x); + +``` +**Description:** Supported + + +### __fadd_rd +```cpp +__device__ static float __fadd_rd(float x, float y); + +``` +**Description:** Supported + + +### __fadd_rn +```cpp +__device__ static float __fadd_rn(float x, float y); + +``` +**Description:** Supported + + +### __fadd_ru +```cpp +__device__ static float __fadd_ru(float x, float y); + +``` +**Description:** Supported + + +### __fadd_rz +```cpp +__device__ static float __fadd_rz(float x, float y); + +``` +**Description:** Supported + + +### __fdiv_rd +```cpp +__device__ static float __fdiv_rd(float x, float y); + +``` +**Description:** Supported + + +### __fdiv_rn +```cpp +__device__ static float __fdiv_rn(float x, float y); + +``` +**Description:** Supported + + +### __fdiv_ru +```cpp +__device__ static float __fdiv_ru(float x, float y); + +``` +**Description:** Supported + + +### __fdiv_rz +```cpp +__device__ static float __fdiv_rz(float x, float y); + +``` +**Description:** Supported + + +### __fdividef +```cpp +__device__ static float __fdividef(float x, float y); + +``` +**Description:** Supported + + +### __fmaf_rd +```cpp +__device__ float __fmaf_rd(float x, float y, float z); + +``` +**Description:** Supported + + +### __fmaf_rn +```cpp +__device__ float __fmaf_rn(float x, float y, float z); + +``` +**Description:** Supported + + +### __fmaf_ru +```cpp +__device__ float __fmaf_ru(float x, float y, float z); + +``` +**Description:** Supported + + +### __fmaf_rz +```cpp +__device__ float __fmaf_rz(float x, float y, float z); + +``` +**Description:** Supported + + +### __fmul_rd +```cpp +__device__ static float __fmul_rd(float x, float y); + +``` +**Description:** Supported + + +### __fmul_rn +```cpp +__device__ static float __fmul_rn(float x, float y); + +``` +**Description:** Supported + + +### __fmul_ru +```cpp +__device__ static float __fmul_ru(float x, float y); + +``` +**Description:** Supported + + +### __fmul_rz +```cpp +__device__ static float __fmul_rz(float x, float y); + +``` +**Description:** Supported + + +### __frcp_rd +```cpp +__device__ float __frcp_rd(float x); + +``` +**Description:** Supported + + +### __frcp_rn +```cpp +__device__ float __frcp_rn(float x); + +``` +**Description:** Supported + + +### __frcp_ru +```cpp +__device__ float __frcp_ru(float x); + +``` +**Description:** Supported + + +### __frcp_rz +```cpp +__device__ float __frcp_rz(float x); + +``` +**Description:** Supported + + +### __frsqrt_rn +```cpp +__device__ float __frsqrt_rn(float x); + +``` +**Description:** Supported + + +### __fsqrt_rd +```cpp +__device__ float __fsqrt_rd(float x); + +``` +**Description:** Supported + + +### __fsqrt_rn +```cpp +__device__ float __fsqrt_rn(float x); + +``` +**Description:** Supported + + +### __fsqrt_ru +```cpp +__device__ float __fsqrt_ru(float x); + +``` +**Description:** Supported + + +### __fsqrt_rz +```cpp +__device__ float __fsqrt_rz(float x); + +``` +**Description:** Supported + + +### __fsub_rd +```cpp +__device__ static float __fsub_rd(float x, float y); + +``` +**Description:** Supported + + +### __fsub_rn +```cpp +__device__ static float __fsub_rn(float x, float y); + +``` +**Description:** Supported + + +### __fsub_ru +```cpp +__device__ static float __fsub_ru(float x, float y); + +``` +**Description:** Supported + + +### __log10f +```cpp +__device__ float __log10f(float x); + +``` +**Description:** Supported + + +### __log2f +```cpp +__device__ float __log2f(float x); + +``` +**Description:** Supported + + +### __logf +```cpp +__device__ float __logf(float x); + +``` +**Description:** Supported + + +### __powf +```cpp +__device__ float __powf(float base, float exponent); + +``` +**Description:** Supported + + +### __saturatef +```cpp +__device__ static float __saturatef(float x); + +``` +**Description:** Supported + + +### __sincosf +```cpp +__device__ void __sincosf(float x, float *s, float *c); + +``` +**Description:** Supported + + +### __sinf +```cpp +__device__ float __sinf(float x); + +``` +**Description:** Supported + + +### __tanf +```cpp +__device__ float __tanf(float x); + +``` +**Description:** Supported + + +### __dadd_rd +```cpp +__device__ static double __dadd_rd(double x, double y); + +``` +**Description:** Supported + + +### __dadd_rn +```cpp +__device__ static double __dadd_rn(double x, double y); + +``` +**Description:** Supported + + +### __dadd_ru +```cpp +__device__ static double __dadd_ru(double x, double y); + +``` +**Description:** Supported + + +### __dadd_rz +```cpp +__device__ static double __dadd_rz(double x, double y); + +``` +**Description:** Supported + + +### __ddiv_rd +```cpp +__device__ static double __ddiv_rd(double x, double y); + +``` +**Description:** Supported + + +### __ddiv_rn +```cpp +__device__ static double __ddiv_rn(double x, double y); + +``` +**Description:** Supported + + +### __ddiv_ru +```cpp +__device__ static double __ddiv_ru(double x, double y); + +``` +**Description:** Supported + + +### __ddiv_rz +```cpp +__device__ static double __ddiv_rz(double x, double y); + +``` +**Description:** Supported + + +### __dmul_rd +```cpp +__device__ static double __dmul_rd(double x, double y); + +``` +**Description:** Supported + + +### __dmul_rn +```cpp +__device__ static double __dmul_rn(double x, double y); + +``` +**Description:** Supported + + +### __dmul_ru +```cpp +__device__ static double __dmul_ru(double x, double y); + +``` +**Description:** Supported + + +### __dmul_rz +```cpp +__device__ static double __dmul_rz(double x, double y); + +``` +**Description:** Supported + + +### __drcp_rd +```cpp +__device__ double __drcp_rd(double x); + +``` +**Description:** Supported + + +### __drcp_rn +```cpp +__device__ double __drcp_rn(double x); + +``` +**Description:** Supported + + +### __drcp_ru +```cpp +__device__ double __drcp_ru(double x); + +``` +**Description:** Supported + + +### __drcp_rz +```cpp +__device__ double __drcp_rz(double x); + +``` +**Description:** Supported + + +### __dsqrt_rd +```cpp +__device__ double __dsqrt_rd(double x); + +``` +**Description:** Supported + + +### __dsqrt_rn +```cpp +__device__ double __dsqrt_rn(double x); + +``` +**Description:** Supported + + +### __dsqrt_ru +```cpp +__device__ double __dsqrt_ru(double x); + +``` +**Description:** Supported + + +### __dsqrt_rz +```cpp +__device__ double __dsqrt_rz(double x); + +``` +**Description:** Supported + + +### __dsub_rd +```cpp +__device__ static double __dsub_rd(double x, double y); + +``` +**Description:** Supported + + +### __dsub_rn +```cpp +__device__ static double __dsub_rn(double x, double y); + +``` +**Description:** Supported + + +### __dsub_ru +```cpp +__device__ static double __dsub_ru(double x, double y); + +``` +**Description:** Supported + + +### __dsub_rz +```cpp +__device__ static double __dsub_rz(double x, double y); + +``` +**Description:** Supported + + +### __fma_rd +```cpp +__device__ double __fma_rd(double x, double y, double z); + +``` +**Description:** Supported + + +### __fma_rn +```cpp +__device__ double __fma_rn(double x, double y, double z); + +``` +**Description:** Supported + + +### __fma_ru +```cpp +__device__ double __fma_ru(double x, double y, double z); + +``` +**Description:** Supported + + +### __fma_rz +```cpp +__device__ double __fma_rz(double x, double y, double z); + +``` +**Description:** Supported + + +### __brev +```cpp +__device__ unsigned int __brev( unsigned int x); + +``` +**Description:** Supported + + +### __brevll +```cpp +__device__ unsigned long long int __brevll( unsigned long long int x); + +``` +**Description:** Supported + + +### __byte_perm +```cpp +__device__ unsigned int __byte_perm(unsigned int x, unsigned int y, unsigned int s); + +``` +**Description:** Supported + + +### __clz +```cpp +__device__ unsigned int __clz(int x); + +``` +**Description:** Supported + + +### __clzll +```cpp +__device__ unsigned int __clzll(long long int x); + +``` +**Description:** Supported + + +### __ffs +```cpp +__device__ unsigned int __ffs(int x); + +``` +**Description:** Supported + + +### __ffsll +```cpp +__device__ unsigned int __ffsll(long long int x); + +``` +**Description:** Supported + + +### __hadd +```cpp +__device__ static unsigned int __hadd(int x, int y); + +``` +**Description:** Supported + + +### __mul24 +```cpp +__device__ static int __mul24(int x, int y); + +``` +**Description:** Supported + + +### __mul64hi +```cpp +__device__ long long int __mul64hi(long long int x, long long int y); + +``` +**Description:** Supported + + +### __mulhi +```cpp +__device__ static int __mulhi(int x, int y); + +``` +**Description:** Supported + + +### __popc +```cpp +__device__ unsigned int __popc(unsigned int x); + +``` +**Description:** Supported + + +### __popcll +```cpp +__device__ unsigned int __popcll(unsigned long long int x); + +``` +**Description:** Supported + + +### __rhadd +```cpp +__device__ static int __rhadd(int x, int y); + +``` +**Description:** Supported + + +### __sad +```cpp +__device__ static unsigned int __sad(int x, int y, int z); + +``` +**Description:** Supported + + +### __uhadd +```cpp +__device__ static unsigned int __uhadd(unsigned int x, unsigned int y); + +``` +**Description:** Supported + + +### __umul24 +```cpp +__device__ static int __umul24(unsigned int x, unsigned int y); + +``` +**Description:** Supported + + +### __umul64hi +```cpp +__device__ unsigned long long int __umul64hi(unsigned long long int x, unsigned long long int y); + +``` +**Description:** Supported + + +### __umulhi +```cpp +__device__ static unsigned int __umulhi(unsigned int x, unsigned int y); + +``` +**Description:** Supported + + +### __urhadd +```cpp +__device__ static unsigned int __urhadd(unsigned int x, unsigned int y); + +``` +**Description:** Supported + + +### __usad +```cpp +__device__ static unsigned int __usad(unsigned int x, unsigned int y, unsigned int z); + +``` +**Description:** Supported + + +### __double2float_rd +```cpp +__device__ float __double2float_rd(double x); + +``` +**Description:** Supported + + +### __double2float_rn +```cpp +__device__ float __double2float_rn(double x); + +``` +**Description:** Supported + + +### __double2float_ru +```cpp +__device__ float __double2float_ru(double x); + +``` +**Description:** Supported + + +### __double2float_rz +```cpp +__device__ float __double2float_rz(double x); + +``` +**Description:** Supported + + +### __double2hiint +```cpp +__device__ int __double2hiint(double x); + +``` +**Description:** Supported + + +### __double2int_rd +```cpp +__device__ int __double2int_rd(double x); + +``` +**Description:** Supported + + +### __double2int_rn +```cpp +__device__ int __double2int_rn(double x); + +``` +**Description:** Supported + + +### __double2int_ru +```cpp +__device__ int __double2int_ru(double x); + +``` +**Description:** Supported + + +### __double2int_rz +```cpp +__device__ int __double2int_rz(double x); + +``` +**Description:** Supported + + +### __double2ll_rd +```cpp +__device__ long long int __double2ll_rd(double x); + +``` +**Description:** Supported + + +### __double2ll_rn +```cpp +__device__ long long int __double2ll_rn(double x); + +``` +**Description:** Supported + + +### __double2ll_ru +```cpp +__device__ long long int __double2ll_ru(double x); + +``` +**Description:** Supported + + +### __double2ll_rz +```cpp +__device__ long long int __double2ll_rz(double x); + +``` +**Description:** Supported + + +### __double2loint +```cpp +__device__ int __double2loint(double x); + +``` +**Description:** Supported + + +### __double2uint_rd +```cpp +__device__ unsigned int __double2uint_rd(double x); + +``` +**Description:** Supported + + +### __double2uint_rn +```cpp +__device__ unsigned int __double2uint_rn(double x); + +``` +**Description:** Supported + + +### __double2uint_ru +```cpp +__device__ unsigned int __double2uint_ru(double x); + +``` +**Description:** Supported + + +### __double2uint_rz +```cpp +__device__ unsigned int __double2uint_rz(double x); + +``` +**Description:** Supported + + +### __double2ull_rd +```cpp +__device__ unsigned long long int __double2ull_rd(double x); + +``` +**Description:** Supported + + +### __double2ull_rn +```cpp +__device__ unsigned long long int __double2ull_rn(double x); + +``` +**Description:** Supported + + +### __double2ull_ru +```cpp +__device__ unsigned long long int __double2ull_ru(double x); + +``` +**Description:** Supported + + +### __double2ull_rz +```cpp +__device__ unsigned long long int __double2ull_rz(double x); + +``` +**Description:** Supported + + +### __double_as_longlong +```cpp +__device__ long long int __double_as_longlong(double x); + +``` +**Description:** Supported + + +### __float2half_rn +```cpp +__device__ unsigned short __float2half_rn(float x); + +``` +**Description:** Supported + + +### __half2float +```cpp +__device__ float __half2float(unsigned short); + +``` +**Description:** Supported + + +### __float2half_rn +```cpp +__device__ __half __float2half_rn(float x); + +``` +**Description:** Supported + + +### __half2float +```cpp +__device__ float __half2float(__half); + +``` +**Description:** Supported + + +### __float2int_rd +```cpp +__device__ int __float2int_rd(float x); + +``` +**Description:** Supported + + +### __float2int_rn +```cpp +__device__ int __float2int_rn(float x); + +``` +**Description:** Supported + + +### __float2int_ru +```cpp +__device__ int __float2int_ru(float x); + +``` +**Description:** Supported + + +### __float2int_rz +```cpp +__device__ int __float2int_rz(float x); + +``` +**Description:** Supported + + +### __float2ll_rd +```cpp +__device__ long long int __float2ll_rd(float x); + +``` +**Description:** Supported + + +### __float2ll_rn +```cpp +__device__ long long int __float2ll_rn(float x); + +``` +**Description:** Supported + + +### __float2ll_ru +```cpp +__device__ long long int __float2ll_ru(float x); + +``` +**Description:** Supported + + +### __float2ll_rz +```cpp +__device__ long long int __float2ll_rz(float x); + +``` +**Description:** Supported + + +### __float2uint_rd +```cpp +__device__ unsigned int __float2uint_rd(float x); + +``` +**Description:** Supported + + +### __float2uint_rn +```cpp +__device__ unsigned int __float2uint_rn(float x); + +``` +**Description:** Supported + + +### __float2uint_ru +```cpp +__device__ unsigned int __float2uint_ru(float x); + +``` +**Description:** Supported + + +### __float2uint_rz +```cpp +__device__ unsigned int __float2uint_rz(float x); + +``` +**Description:** Supported + + +### __float2ull_rd +```cpp +__device__ unsigned long long int __float2ull_rd(float x); + +``` +**Description:** Supported + + +### __float2ull_rn +```cpp +__device__ unsigned long long int __float2ull_rn(float x); + +``` +**Description:** Supported + + +### __float2ull_ru +```cpp +__device__ unsigned long long int __float2ull_ru(float x); + +``` +**Description:** Supported + + +### __float2ull_rz +```cpp +__device__ unsigned long long int __float2ull_rz(float x); + +``` +**Description:** Supported + + +### __float_as_int +```cpp +__device__ int __float_as_int(float x); + +``` +**Description:** Supported + + +### __float_as_uint +```cpp +__device__ unsigned int __float_as_uint(float x); + +``` +**Description:** Supported + + +### __hiloint2double +```cpp +__device__ double __hiloint2double(int hi, int lo); + +``` +**Description:** Supported + + +### __int2double_rn +```cpp +__device__ double __int2double_rn(int x); + +``` +**Description:** Supported + + +### __int2float_rd +```cpp +__device__ float __int2float_rd(int x); + +``` +**Description:** Supported + + +### __int2float_rn +```cpp +__device__ float __int2float_rn(int x); + +``` +**Description:** Supported + + +### __int2float_ru +```cpp +__device__ float __int2float_ru(int x); + +``` +**Description:** Supported + + +### __int2float_rz +```cpp +__device__ float __int2float_rz(int x); + +``` +**Description:** Supported + + +### __int_as_float +```cpp +__device__ float __int_as_float(int x); + +``` +**Description:** Supported + + +### __ll2double_rd +```cpp +__device__ double __ll2double_rd(long long int x); + +``` +**Description:** Supported + + +### __ll2double_rn +```cpp +__device__ double __ll2double_rn(long long int x); + +``` +**Description:** Supported + + +### __ll2double_ru +```cpp +__device__ double __ll2double_ru(long long int x); + +``` +**Description:** Supported + + +### __ll2double_rz +```cpp +__device__ double __ll2double_rz(long long int x); + +``` +**Description:** Supported + + +### __ll2float_rd +```cpp +__device__ float __ll2float_rd(long long int x); + +``` +**Description:** Supported + + +### __ll2float_rn +```cpp +__device__ float __ll2float_rn(long long int x); + +``` +**Description:** Supported + + +### __ll2float_ru +```cpp +__device__ float __ll2float_ru(long long int x); + +``` +**Description:** Supported + + +### __ll2float_rz +```cpp +__device__ float __ll2float_rz(long long int x); + +``` +**Description:** Supported + + +### __longlong_as_double +```cpp +__device__ double __longlong_as_double(long long int x); + +``` +**Description:** Supported + + +### __uint2double_rn +```cpp +__device__ double __uint2double_rn(int x); + +``` +**Description:** Supported + + +### __uint2float_rd +```cpp +__device__ float __uint2float_rd(unsigned int x); + +``` +**Description:** Supported + + +### __uint2float_rn +```cpp +__device__ float __uint2float_rn(unsigned int x); + +``` +**Description:** Supported + + +### __uint2float_ru +```cpp +__device__ float __uint2float_ru(unsigned int x); + +``` +**Description:** Supported + + +### __uint2float_rz +```cpp +__device__ float __uint2float_rz(unsigned int x); + +``` +**Description:** Supported + + +### __uint_as_float +```cpp +__device__ float __uint_as_float(unsigned int x); + +``` +**Description:** Supported + + +### __ull2double_rd +```cpp +__device__ double __ull2double_rd(unsigned long long int x); + +``` +**Description:** Supported + + +### __ull2double_rn +```cpp +__device__ double __ull2double_rn(unsigned long long int x); + +``` +**Description:** Supported + + +### __ull2double_ru +```cpp +__device__ double __ull2double_ru(unsigned long long int x); + +``` +**Description:** Supported + + +### __ull2double_rz +```cpp +__device__ double __ull2double_rz(unsigned long long int x); + +``` +**Description:** Supported + + +### __ull2float_rd +```cpp +__device__ float __ull2float_rd(unsigned long long int x); + +``` +**Description:** Supported + + +### __ull2float_rn +```cpp +__device__ float __ull2float_rn(unsigned long long int x); + +``` +**Description:** Supported + + +### __ull2float_ru +```cpp +__device__ float __ull2float_ru(unsigned long long int x); + +``` +**Description:** Supported + + +### __ull2float_rz +```cpp +__device__ float __ull2float_rz(unsigned long long int x); + +``` +**Description:** Supported + + +### __heq +```cpp +__device__ bool __heq(__half a, __half b); + +``` +**Description:** Supported + + +### __hge +```cpp +__device__ bool __hge(__half a, __half b); + +``` +**Description:** Supported + + +### __hgt +```cpp +__device__ bool __hgt(__half a, __half b); + +``` +**Description:** Supported + + +### __hisinf +```cpp +__device__ bool __hisinf(__half a); + +``` +**Description:** Supported + + +### __hisnan +```cpp +__device__ bool __hisnan(__half a); + +``` +**Description:** Supported + + +### __hle +```cpp +__device__ bool __hle(__half a, __half b); + +``` +**Description:** Supported + + +### __hlt +```cpp +__device__ bool __hlt(__half a, __half b); + +``` +**Description:** Supported + + +### __hne +```cpp +__device__ bool __hne(__half a, __half b); + +``` +**Description:** Supported + + +### __hbeq2 +```cpp +__device__ bool __hbeq2(__half2 a, __half2 b); + +``` +**Description:** Supported + + +### __hbge2 +```cpp +__device__ bool __hbge2(__half2 a, __half2 b); + +``` +**Description:** Supported + + +### __hbgt2 +```cpp +__device__ bool __hbgt2(__half2 a, __half2 b); + +``` +**Description:** Supported + + +### __hble2 +```cpp +__device__ bool __hble2(__half2 a, __half2 b); + +``` +**Description:** Supported + + +### __hblt2 +```cpp +__device__ bool __hblt2(__half2 a, __half2 b); + +``` +**Description:** Supported + + +### __hbne2 +```cpp +__device__ bool __hbne2(__half2 a, __half2 b); + +``` +**Description:** Supported + + +### __heq2 +```cpp +__device__ __half2 __heq2(__half2 a, __half2 b); + +``` +**Description:** Supported + + +### __hge2 +```cpp +__device__ __half2 __hge2(__half2 a, __half2 b); + +``` +**Description:** Supported + + +### __hgt2 +```cpp +__device__ __half2 __hgt2(__half2 a, __half2 b); + +``` +**Description:** Supported + + +### __hisnan2 +```cpp +__device__ __half2 __hisnan2(__half2 a); + +``` +**Description:** Supported + + +### __hle2 +```cpp +__device__ __half2 __hle2(__half2 a, __half2 b); + +``` +**Description:** Supported + + +### __hlt2 +```cpp +__device__ __half2 __hlt2(__half2 a, __half2 b); + +``` +**Description:** Supported + + +### __hne2 +```cpp +__device__ __half2 __hne2(__half2 a, __half2 b); + +``` +**Description:** Supported + + +### __float22half2_rn +```cpp +__device__ __half2 __float22half2_rn(const float2 a); + +``` +**Description:** Supported + + +### __float2half +```cpp +__device__ __half __float2half(const float a); + +``` +**Description:** Supported + + +### __float2half2_rn +```cpp +__device__ __half2 __float2half2_rn(const float a); + +``` +**Description:** Supported + + +### __float2half_rd +```cpp +__device__ __half __float2half_rd(const float a); + +``` +**Description:** Supported + + +### __float2half_rn +```cpp +__device__ __half __float2half_rn(const float a); + +``` +**Description:** Supported + + +### __float2half_ru +```cpp +__device__ __half __float2half_ru(const float a); + +``` +**Description:** Supported + + +### __float2half_rz +```cpp +__device__ __half __float2half_rz(const float a); + +``` +**Description:** Supported + + +### __floats2half2_rn +```cpp +__device__ __half2 __floats2half2_rn(const float a, const float b); + +``` +**Description:** Supported + + +### __half22float2 +```cpp +__device__ float2 __half22float2(const __half2 a); + +``` +**Description:** Supported + + +### __half2float +```cpp +__device__ float __half2float(const __half a); + +``` +**Description:** Supported + + +### half2half2 +```cpp +__device__ __half2 half2half2(const __half a); + +``` +**Description:** Supported + + +### __half2int_rd +```cpp +__device__ int __half2int_rd(__half h); + +``` +**Description:** Supported + + +### __half2int_rn +```cpp +__device__ int __half2int_rn(__half h); + +``` +**Description:** Supported + + +### __half2int_ru +```cpp +__device__ int __half2int_ru(__half h); + +``` +**Description:** Supported + + +### __half2int_rz +```cpp +__device__ int __half2int_rz(__half h); + +``` +**Description:** Supported + + +### __half2ll_rd +```cpp +__device__ long long int __half2ll_rd(__half h); + +``` +**Description:** Supported + + +### __half2ll_rn +```cpp +__device__ long long int __half2ll_rn(__half h); + +``` +**Description:** Supported + + +### __half2ll_ru +```cpp +__device__ long long int __half2ll_ru(__half h); + +``` +**Description:** Supported + + +### __half2ll_rz +```cpp +__device__ long long int __half2ll_rz(__half h); + +``` +**Description:** Supported + + +### __half2short_rd +```cpp +__device__ short __half2short_rd(__half h); + +``` +**Description:** Supported + + +### __half2short_rn +```cpp +__device__ short __half2short_rn(__half h); + +``` +**Description:** Supported + + +### __half2short_ru +```cpp +__device__ short __half2short_ru(__half h); + +``` +**Description:** Supported + + +### __half2short_rz +```cpp +__device__ short __half2short_rz(__half h); + +``` +**Description:** Supported + + +### __half2uint_rd +```cpp +__device__ unsigned int __half2uint_rd(__half h); + +``` +**Description:** Supported + + +### __half2uint_rn +```cpp +__device__ unsigned int __half2uint_rn(__half h); + +``` +**Description:** Supported + + +### __half2uint_ru +```cpp +__device__ unsigned int __half2uint_ru(__half h); + +``` +**Description:** Supported + + +### __half2uint_rz +```cpp +__device__ unsigned int __half2uint_rz(__half h); + +``` +**Description:** Supported + + +### __half2ull_rd +```cpp +__device__ unsigned long long int __half2ull_rd(__half h); + +``` +**Description:** Supported + + +### __half2ull_rn +```cpp +__device__ unsigned long long int __half2ull_rn(__half h); + +``` +**Description:** Supported + + +### __half2ull_ru +```cpp +__device__ unsigned long long int __half2ull_ru(__half h); + +``` +**Description:** Supported + + +### __half2ull_rz +```cpp +__device__ unsigned long long int __half2ull_rz(__half h); + +``` +**Description:** Supported + + +### __half2ushort_rd +```cpp +__device__ unsigned short int __half2ushort_rd(__half h); + +``` +**Description:** Supported + + +### __half2ushort_rn +```cpp +__device__ unsigned short int __half2ushort_rn(__half h); + +``` +**Description:** Supported + + +### __half2ushort_ru +```cpp +__device__ unsigned short int __half2ushort_ru(__half h); + +``` +**Description:** Supported + + +### __half2ushort_rz +```cpp +__device__ unsigned short int __half2ushort_rz(__half h); + +``` +**Description:** Supported + + +### __half_as_short +```cpp +__device__ short int __half_as_short(const __half h); + +``` +**Description:** Supported + + +### __half_as_ushort +```cpp +__device__ unsigned short int __half_as_ushort(const __half h); + +``` +**Description:** Supported + + +### __halves2half2 +```cpp +__device__ __half2 __halves2half2(const __half a, const __half b); + +``` +**Description:** Supported + + +### __high2float +```cpp +__device__ float __high2float(const __half2 a); + +``` +**Description:** Supported + + +### __high2half +```cpp +__device__ __half __high2half(const __half2 a); + +``` +**Description:** Supported + + +### __high2half2 +```cpp +__device__ __half2 __high2half2(const __half2 a); + +``` +**Description:** Supported + + +### __highs2half2 +```cpp +__device__ __half2 __highs2half2(const __half2 a, const __half2 b); + +``` +**Description:** Supported + + +### __int2half_rd +```cpp +__device__ __half __int2half_rd(int i); + +``` +**Description:** Supported + + +### __int2half_rn +```cpp +__device__ __half __int2half_rn(int i); + +``` +**Description:** Supported + + +### __int2half_ru +```cpp +__device__ __half __int2half_ru(int i); + +``` +**Description:** Supported + + +### __int2half_rz +```cpp +__device__ __half __int2half_rz(int i); + +``` +**Description:** Supported + + +### __ll2half_rd +```cpp +__device__ __half __ll2half_rd(long long int i); + +``` +**Description:** Supported + + +### __ll2half_rn +```cpp +__device__ __half __ll2half_rn(long long int i); + +``` +**Description:** Supported + + +### __ll2half_ru +```cpp +__device__ __half __ll2half_ru(long long int i); + +``` +**Description:** Supported + + +### __ll2half_rz +```cpp +__device__ __half __ll2half_rz(long long int i); + +``` +**Description:** Supported + + +### __low2float +```cpp +__device__ float __low2float(const __half2 a); + +``` +**Description:** Supported + + +### __low2half +```cpp +__device__ __half __low2half(const __half2 a); + +``` +**Description:** Supported + + +### __low2half2 +```cpp +__device__ __half2 __low2half2(const __half2 a, const __half2 b); + +``` +**Description:** Supported + + +### __low2half2 +```cpp +__device__ __half2 __low2half2(const __half2 a); + +``` +**Description:** Supported + + +### __lowhigh2highlow +```cpp +__device__ __half2 __lowhigh2highlow(const __half2 a); + +``` +**Description:** Supported + + +### __lows2half2 +```cpp +__device__ __half2 __lows2half2(const __half2 a, const __half2 b); + +``` +**Description:** Supported + + +### __short2half_rd +```cpp +__device__ __half __short2half_rd(short int i); + +``` +**Description:** Supported + + +### __short2half_rn +```cpp +__device__ __half __short2half_rn(short int i); + +``` +**Description:** Supported + + +### __short2half_ru +```cpp +__device__ __half __short2half_ru(short int i); + +``` +**Description:** Supported + + +### __short2half_rz +```cpp +__device__ __half __short2half_rz(short int i); + +``` +**Description:** Supported + + +### __uint2half_rd +```cpp +__device__ __half __uint2half_rd(unsigned int i); + +``` +**Description:** Supported + + +### __uint2half_rn +```cpp +__device__ __half __uint2half_rn(unsigned int i); + +``` +**Description:** Supported + + +### __uint2half_ru +```cpp +__device__ __half __uint2half_ru(unsigned int i); + +``` +**Description:** Supported + + +### __uint2half_rz +```cpp +__device__ __half __uint2half_rz(unsigned int i); + +``` +**Description:** Supported + + +### __ull2half_rd +```cpp +__device__ __half __ull2half_rd(unsigned long long int i); + +``` +**Description:** Supported + + +### __ull2half_rn +```cpp +__device__ __half __ull2half_rn(unsigned long long int i); + +``` +**Description:** Supported + + +### __ull2half_ru +```cpp +__device__ __half __ull2half_ru(unsigned long long int i); + +``` +**Description:** Supported + + +### __ull2half_rz +```cpp +__device__ __half __ull2half_rz(unsigned long long int i); + +``` +**Description:** Supported + + +### __ushort2half_rd +```cpp +__device__ __half __ushort2half_rd(unsigned short int i); + +``` +**Description:** Supported + + +### __ushort2half_rn +```cpp +__device__ __half __ushort2half_rn(unsigned short int i); + +``` +**Description:** Supported + + +### __ushort2half_ru +```cpp +__device__ __half __ushort2half_ru(unsigned short int i); + +``` +**Description:** Supported + + +### __ushort2half_rz +```cpp +__device__ __half __ushort2half_rz(unsigned short int i); + +``` +**Description:** Supported + + +### __ushort_as_half +```cpp +__device__ __half __ushort_as_half(const unsigned short int i); + +``` +**Description:** Supported + + diff --git a/projects/hip/include/hip/hcc_detail/device_functions.h b/projects/hip/include/hip/hcc_detail/device_functions.h index a2894f3d9b..212f22d5dc 100644 --- a/projects/hip/include/hip/hcc_detail/device_functions.h +++ b/projects/hip/include/hip/hcc_detail/device_functions.h @@ -23,6 +23,86 @@ THE SOFTWARE. #include #include + + + + +// Single Precision Fast Math +__device__ float __cosf(float x); +__device__ float __exp10f(float x); +__device__ float __expf(float x); +__device__ static float __fadd_rd(float x, float y); +__device__ static float __fadd_rn(float x, float y); +__device__ static float __fadd_ru(float x, float y); +__device__ static float __fadd_rz(float x, float y); +__device__ static float __fdiv_rd(float x, float y); +__device__ static float __fdiv_rn(float x, float y); +__device__ static float __fdiv_ru(float x, float y); +__device__ static float __fdiv_rz(float x, float y); +__device__ static float __fdividef(float x, float y); +__device__ float __fmaf_rd(float x, float y, float z); +__device__ float __fmaf_rn(float x, float y, float z); +__device__ float __fmaf_ru(float x, float y, float z); +__device__ float __fmaf_rz(float x, float y, float z); +__device__ static float __fmul_rd(float x, float y); +__device__ static float __fmul_rn(float x, float y); +__device__ static float __fmul_ru(float x, float y); +__device__ static float __fmul_rz(float x, float y); +__device__ float __frcp_rd(float x); +__device__ float __frcp_rn(float x); +__device__ float __frcp_ru(float x); +__device__ float __frcp_rz(float x); +__device__ float __frsqrt_rn(float x); +__device__ float __fsqrt_rd(float x); +__device__ float __fsqrt_rn(float x); +__device__ float __fsqrt_ru(float x); +__device__ float __fsqrt_rz(float x); +__device__ static float __fsub_rd(float x, float y); +__device__ static float __fsub_rn(float x, float y); +__device__ static float __fsub_ru(float x, float y); +__device__ float __log10f(float x); +__device__ float __log2f(float x); +__device__ float __logf(float x); +__device__ float __powf(float base, float exponent); +__device__ static float __saturatef(float x); +__device__ void __sincosf(float x, float *s, float *c); +__device__ float __sinf(float x); +__device__ float __tanf(float x); + + +/* +Double Precision Intrinsics +*/ + +__device__ static double __dadd_rd(double x, double y); +__device__ static double __dadd_rn(double x, double y); +__device__ static double __dadd_ru(double x, double y); +__device__ static double __dadd_rz(double x, double y); +__device__ static double __ddiv_rd(double x, double y); +__device__ static double __ddiv_rn(double x, double y); +__device__ static double __ddiv_ru(double x, double y); +__device__ static double __ddiv_rz(double x, double y); +__device__ static double __dmul_rd(double x, double y); +__device__ static double __dmul_rn(double x, double y); +__device__ static double __dmul_ru(double x, double y); +__device__ static double __dmul_rz(double x, double y); +__device__ double __drcp_rd(double x); +__device__ double __drcp_rn(double x); +__device__ double __drcp_ru(double x); +__device__ double __drcp_rz(double x); +__device__ double __dsqrt_rd(double x); +__device__ double __dsqrt_rn(double x); +__device__ double __dsqrt_ru(double x); +__device__ double __dsqrt_rz(double x); +__device__ static double __dsub_rd(double x, double y); +__device__ static double __dsub_rn(double x, double y); +__device__ static double __dsub_ru(double x, double y); +__device__ static double __dsub_rz(double x, double y); +__device__ double __fma_rd(double x, double y, double z); +__device__ double __fma_rn(double x, double y, double z); +__device__ double __fma_ru(double x, double y, double z); +__device__ double __fma_rz(double x, double y, double z); + // Single Precision Fast Math extern __attribute__((const)) float __hip_fast_cosf(float) __asm("llvm.cos.f32"); extern __attribute__((const)) float __hip_fast_exp2f(float) __asm("llvm.exp2.f32"); @@ -349,6 +429,21 @@ __device__ unsigned int __clz(int x); __device__ unsigned int __clzll(long long int x); __device__ unsigned int __ffs(int x); __device__ unsigned int __ffsll(long long int x); +__device__ static unsigned int __hadd(int x, int y); +__device__ static int __mul24(int x, int y); +__device__ long long int __mul64hi(long long int x, long long int y); +__device__ static int __mulhi(int x, int y); +__device__ unsigned int __popc(unsigned int x); +__device__ unsigned int __popcll(unsigned long long int x); +__device__ static int __rhadd(int x, int y); +__device__ static unsigned int __sad(int x, int y, int z); +__device__ static unsigned int __uhadd(unsigned int x, unsigned int y); +__device__ static int __umul24(unsigned int x, unsigned int y); +__device__ unsigned long long int __umul64hi(unsigned long long int x, unsigned long long int y); +__device__ static unsigned int __umulhi(unsigned int x, unsigned int y); +__device__ static unsigned int __urhadd(unsigned int x, unsigned int y); +__device__ static unsigned int __usad(unsigned int x, unsigned int y, unsigned int z); + __device__ static inline unsigned int __hadd(int x, int y) { int z = x + y; int sign = z & 0x8000000; @@ -358,12 +453,9 @@ __device__ static inline unsigned int __hadd(int x, int y) { __device__ static inline int __mul24(int x, int y) { return __hip_hc_ir_mul24_int(x, y); } -__device__ long long int __mul64hi(long long int x, long long int y); __device__ static inline int __mulhi(int x, int y) { return __hip_hc_ir_mulhi_int(x, y); } -__device__ unsigned int __popc( unsigned int x); -__device__ unsigned int __popcll( unsigned long long int x); __device__ static inline int __rhadd(int x, int y) { int z = x + y + 1; int sign = z & 0x8000000; @@ -373,14 +465,12 @@ __device__ static inline int __rhadd(int x, int y) { __device__ static inline unsigned int __sad(int x, int y, int z) { return x > y ? x - y + z : y - x + z; } - __device__ static inline unsigned int __uhadd(unsigned int x, unsigned int y) { return (x + y) >> 1; } __device__ static inline int __umul24(unsigned int x, unsigned int y) { return __hip_hc_ir_umul24_int(x, y); } -__device__ unsigned long long int __umul64hi(unsigned long long int x, unsigned long long int y); __device__ static inline unsigned int __umulhi(unsigned int x, unsigned int y) { return __hip_hc_ir_umulhi_int(x, y); } @@ -440,10 +530,10 @@ CUDA implements half as unsigned short whereas, HIP doesn't. */ -__device__ int float2int_rd(float x); -__device__ int float2int_rn(float x); -__device__ int float2int_ru(float x); -__device__ int float2int_rz(float x); +__device__ int __float2int_rd(float x); +__device__ int __float2int_rn(float x); +__device__ int __float2int_ru(float x); +__device__ int __float2int_rz(float x); __device__ long long int __float2ll_rd(float x); __device__ long long int __float2ll_rn(float x); diff --git a/projects/hip/include/hip/hcc_detail/math_functions.h b/projects/hip/include/hip/hcc_detail/math_functions.h index 21ec4510c6..b07830958f 100644 --- a/projects/hip/include/hip/hcc_detail/math_functions.h +++ b/projects/hip/include/hip/hcc_detail/math_functions.h @@ -141,8 +141,8 @@ __device__ double copysign(double x, double y); __device__ double cos(double x); __device__ double cosh(double x); __device__ __host__ double cospi(double x); -__device__ double cyl_bessel_i0(double x); -__device__ double cyl_bessel_i1(double x); +//__device__ double cyl_bessel_i0(double x); +//__device__ double cyl_bessel_i1(double x); __device__ double erf(double x); __device__ double erfc(double x); __device__ double erfcinv(double y); @@ -232,6 +232,8 @@ __host__ double rnorm3d(double a, double b, double c); __host__ double rnorm4d(double a, double b, double c, double d); __host__ void sincospi(double x, double *sptr, double *cptr); +// ENDPARSER + #ifdef HIP_FAST_MATH // Single Precision Precise Math when enabled From 13c7583874b30a8f5e2998a444b765d0eafe2bad Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Wed, 18 Jan 2017 14:49:41 -0600 Subject: [PATCH 079/281] more clarification about using device_md_gen.py Change-Id: I3e207b65683f34d62be3454444ffb32f8814c0aa [ROCm/hip commit: db99ac798b28197c28b5e72f9d346038a3f42570] --- projects/hip/docs/markdown/device_md_gen.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/hip/docs/markdown/device_md_gen.py b/projects/hip/docs/markdown/device_md_gen.py index 4795ea98e0..995782189f 100644 --- a/projects/hip/docs/markdown/device_md_gen.py +++ b/projects/hip/docs/markdown/device_md_gen.py @@ -473,7 +473,7 @@ preamble = "# HIP MATH APIs Documentation \n"+\ " /*implementation*/\n}\n" + \ "```\n\n" + \ "This helps python script to add the device function newly declared into markdown documentation (as it looks at functions with `;` at the end and `__device__` at the beginning)\n\n" + \ -"The next step would be to add Description to `deviceFuncDesc`.\n" + \ +"The next step would be to add Description to `deviceFuncDesc` dictionary in python script.\n" + \ "From the above example, it can be writtern as,\n`deviceFuncDesc['__dotf'] = 'This functions takes 2 4 component float vector and outputs dot product across them'`\n\n" def generateSnippet(name, description, signature): From 99fc61be651a5daae5837bfd9b6589a43855ffc5 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Wed, 18 Jan 2017 15:06:18 -0600 Subject: [PATCH 080/281] moved half device function declarations to top of the file 1. Moved half device functions around so that script can catch the signatures 2. Generated docs for half precision apis Change-Id: Iee27658e3a639fdb02af135e71841dc6427f15e2 [ROCm/hip commit: 56d73aaee78eba849f6e7b9800c2e65901f35f4b] --- projects/hip/docs/markdown/hip-math-api.md | 370 +++++++++++++++++- .../hip/include/hip/hcc_detail/hip_fp16.h | 277 ++++++++----- 2 files changed, 544 insertions(+), 103 deletions(-) diff --git a/projects/hip/docs/markdown/hip-math-api.md b/projects/hip/docs/markdown/hip-math-api.md index daf34fbfa3..6a8e90eb59 100644 --- a/projects/hip/docs/markdown/hip-math-api.md +++ b/projects/hip/docs/markdown/hip-math-api.md @@ -16,7 +16,7 @@ __device__ static inline float __dotf(float4 x, float4 y) { This helps python script to add the device function newly declared into markdown documentation (as it looks at functions with `;` at the end and `__device__` at the beginning) -The next step would be to add Description to `deviceFuncDesc`. +The next step would be to add Description to `deviceFuncDesc` dictionary in python script. From the above example, it can be writtern as, `deviceFuncDesc['__dotf'] = 'This functions takes 2 4 component float vector and outputs dot product across them'` @@ -2716,6 +2716,166 @@ __device__ float __ull2float_rz(unsigned long long int x); **Description:** Supported +### __hadd +```cpp +__device__ static __half __hadd(const __half a, const __half b); + +``` +**Description:** Supported + + +### __hadd_sat +```cpp +__device__ static __half __hadd_sat(__half a, __half b); + +``` +**Description:** Supported + + +### __hfma +```cpp +__device__ static __half __hfma(__half a, __half b, __half c); + +``` +**Description:** Supported + + +### __hfma_sat +```cpp +__device__ static __half __hfma_sat(__half a, __half b, __half c); + +``` +**Description:** Supported + + +### __hmul +```cpp +__device__ static __half __hmul(__half a, __half b); + +``` +**Description:** Supported + + +### __hmul_sat +```cpp +__device__ static __half __hmul_sat(__half a, __half b); + +``` +**Description:** Supported + + +### __hneg +```cpp +__device__ static __half __hneg(__half a); + +``` +**Description:** Supported + + +### __hsub +```cpp +__device__ static __half __hsub(__half a, __half b); + +``` +**Description:** Supported + + +### __hsub_sat +```cpp +__device__ static __half __hsub_sat(__half a, __half b); + +``` +**Description:** Supported + + +### hdiv +```cpp +__device__ static __half hdiv(__half a, __half b); + +``` +**Description:** Supported + + +### __hadd2 +```cpp +__device__ static __half2 __hadd2(__half2 a, __half2 b); + +``` +**Description:** Supported + + +### __hadd2_sat +```cpp +__device__ static __half2 __hadd2_sat(__half2 a, __half2 b); + +``` +**Description:** Supported + + +### __hfma2 +```cpp +__device__ static __half2 __hfma2(__half2 a, __half2 b, __half2 c); + +``` +**Description:** Supported + + +### __hfma2_sat +```cpp +__device__ static __half2 __hfma2_sat(__half2 a, __half2 b, __half2 c); + +``` +**Description:** Supported + + +### __hmul2 +```cpp +__device__ static __half2 __hmul2(__half2 a, __half2 b); + +``` +**Description:** Supported + + +### __hmul2_sat +```cpp +__device__ static __half2 __hmul2_sat(__half2 a, __half2 b); + +``` +**Description:** Supported + + +### __hsub2 +```cpp +__device__ static __half2 __hsub2(__half2 a, __half2 b); + +``` +**Description:** Supported + + +### __hneg2 +```cpp +__device__ static __half2 __hneg2(__half2 a); + +``` +**Description:** Supported + + +### __hsub2_sat +```cpp +__device__ static __half2 __hsub2_sat(__half2 a, __half2 b); + +``` +**Description:** Supported + + +### h2div +```cpp +__device__ static __half2 h2div(__half2 a, __half2 b); + +``` +**Description:** Supported + + ### __heq ```cpp __device__ bool __heq(__half a, __half b); @@ -2884,6 +3044,214 @@ __device__ __half2 __hne2(__half2 a, __half2 b); **Description:** Supported +### hceil +```cpp +__device__ static __half hceil(const __half h); + +``` +**Description:** Supported + + +### hcos +```cpp +__device__ static __half hcos(const __half h); + +``` +**Description:** Supported + + +### hexp +```cpp +__device__ static __half hexp(const __half h); + +``` +**Description:** Supported + + +### hexp10 +```cpp +__device__ static __half hexp10(const __half h); + +``` +**Description:** Supported + + +### hexp2 +```cpp +__device__ static __half hexp2(const __half h); + +``` +**Description:** Supported + + +### hfloor +```cpp +__device__ static __half hfloor(const __half h); + +``` +**Description:** Supported + + +### hlog +```cpp +__device__ static __half hlog(const __half h); + +``` +**Description:** Supported + + +### hlog10 +```cpp +__device__ static __half hlog10(const __half h); + +``` +**Description:** Supported + + +### hlog2 +```cpp +__device__ static __half hlog2(const __half h); + +``` +**Description:** Supported + + +### hrcp +```cpp +//__device__ static __half hrcp(const __half h); + +``` +**Description:** **NOT Supported** + + +### hrint +```cpp +__device__ static __half hrint(const __half h); + +``` +**Description:** Supported + + +### hsin +```cpp +__device__ static __half hsin(const __half h); + +``` +**Description:** Supported + + +### hsqrt +```cpp +__device__ static __half hsqrt(const __half a); + +``` +**Description:** Supported + + +### htrunc +```cpp +__device__ static __half htrunc(const __half a); + +``` +**Description:** Supported + + +### h2ceil +```cpp +__device__ static __half2 h2ceil(const __half2 h); + +``` +**Description:** Supported + + +### h2exp +```cpp +__device__ static __half2 h2exp(const __half2 h); + +``` +**Description:** Supported + + +### h2exp10 +```cpp +__device__ static __half2 h2exp10(const __half2 h); + +``` +**Description:** Supported + + +### h2exp2 +```cpp +__device__ static __half2 h2exp2(const __half2 h); + +``` +**Description:** Supported + + +### h2floor +```cpp +__device__ static __half2 h2floor(const __half2 h); + +``` +**Description:** Supported + + +### h2log +```cpp +__device__ static __half2 h2log(const __half2 h); + +``` +**Description:** Supported + + +### h2log10 +```cpp +__device__ static __half2 h2log10(const __half2 h); + +``` +**Description:** Supported + + +### h2log2 +```cpp +__device__ static __half2 h2log2(const __half2 h); + +``` +**Description:** Supported + + +### h2rcp +```cpp +__device__ static __half2 h2rcp(const __half2 h); + +``` +**Description:** Supported + + +### h2rsqrt +```cpp +__device__ static __half2 h2rsqrt(const __half2 h); + +``` +**Description:** Supported + + +### h2sin +```cpp +__device__ static __half2 h2sin(const __half2 h); + +``` +**Description:** Supported + + +### h2sqrt +```cpp +__device__ static __half2 h2sqrt(const __half2 h); + +``` +**Description:** Supported + + ### __float22half2_rn ```cpp __device__ __half2 __float22half2_rn(const float2 a); diff --git a/projects/hip/include/hip/hcc_detail/hip_fp16.h b/projects/hip/include/hip/hcc_detail/hip_fp16.h index 73049eb5fb..67d1fe4e06 100644 --- a/projects/hip/include/hip/hcc_detail/hip_fp16.h +++ b/projects/hip/include/hip/hcc_detail/hip_fp16.h @@ -36,6 +36,181 @@ typedef struct __attribute__((aligned(4))){ }; } __half2; +/* +Half Arithmetic Functions +*/ +__device__ static __half __hadd(const __half a, const __half b); +__device__ static __half __hadd_sat(__half a, __half b); +__device__ static __half __hfma(__half a, __half b, __half c); +__device__ static __half __hfma_sat(__half a, __half b, __half c); +__device__ static __half __hmul(__half a, __half b); +__device__ static __half __hmul_sat(__half a, __half b); +__device__ static __half __hneg(__half a); +__device__ static __half __hsub(__half a, __half b); +__device__ static __half __hsub_sat(__half a, __half b); +__device__ static __half hdiv(__half a, __half b); + +/* +Half2 Arithmetic Functions +*/ + +__device__ static __half2 __hadd2(__half2 a, __half2 b); +__device__ static __half2 __hadd2_sat(__half2 a, __half2 b); +__device__ static __half2 __hfma2(__half2 a, __half2 b, __half2 c); +__device__ static __half2 __hfma2_sat(__half2 a, __half2 b, __half2 c); +__device__ static __half2 __hmul2(__half2 a, __half2 b); +__device__ static __half2 __hmul2_sat(__half2 a, __half2 b); +__device__ static __half2 __hsub2(__half2 a, __half2 b); +__device__ static __half2 __hneg2(__half2 a); +__device__ static __half2 __hsub2_sat(__half2 a, __half2 b); +__device__ static __half2 h2div(__half2 a, __half2 b); + +/* +Half Comparision Functions +*/ + +__device__ bool __heq(__half a, __half b); +__device__ bool __hge(__half a, __half b); +__device__ bool __hgt(__half a, __half b); +__device__ bool __hisinf(__half a); +__device__ bool __hisnan(__half a); +__device__ bool __hle(__half a, __half b); +__device__ bool __hlt(__half a, __half b); +__device__ bool __hne(__half a, __half b); + +/* +Half2 Comparision Functions +*/ + +__device__ bool __hbeq2(__half2 a, __half2 b); +__device__ bool __hbge2(__half2 a, __half2 b); +__device__ bool __hbgt2(__half2 a, __half2 b); +__device__ bool __hble2(__half2 a, __half2 b); +__device__ bool __hblt2(__half2 a, __half2 b); +__device__ bool __hbne2(__half2 a, __half2 b); +__device__ __half2 __heq2(__half2 a, __half2 b); +__device__ __half2 __hge2(__half2 a, __half2 b); +__device__ __half2 __hgt2(__half2 a, __half2 b); +__device__ __half2 __hisnan2(__half2 a); +__device__ __half2 __hle2(__half2 a, __half2 b); +__device__ __half2 __hlt2(__half2 a, __half2 b); +__device__ __half2 __hne2(__half2 a, __half2 b); + +/* +Half Math Functions +*/ + +__device__ static __half hceil(const __half h); +__device__ static __half hcos(const __half h); +__device__ static __half hexp(const __half h); +__device__ static __half hexp10(const __half h); +__device__ static __half hexp2(const __half h); +__device__ static __half hfloor(const __half h); +__device__ static __half hlog(const __half h); +__device__ static __half hlog10(const __half h); +__device__ static __half hlog2(const __half h); +//__device__ static __half hrcp(const __half h); +__device__ static __half hrint(const __half h); +__device__ static __half hsin(const __half h); +__device__ static __half hsqrt(const __half a); +__device__ static __half htrunc(const __half a); + +/* +Half2 Math Functions +*/ + +__device__ static __half2 h2ceil(const __half2 h); +__device__ static __half2 h2exp(const __half2 h); +__device__ static __half2 h2exp10(const __half2 h); +__device__ static __half2 h2exp2(const __half2 h); +__device__ static __half2 h2floor(const __half2 h); +__device__ static __half2 h2log(const __half2 h); +__device__ static __half2 h2log10(const __half2 h); +__device__ static __half2 h2log2(const __half2 h); +__device__ static __half2 h2rcp(const __half2 h); +__device__ static __half2 h2rsqrt(const __half2 h); +__device__ static __half2 h2sin(const __half2 h); +__device__ static __half2 h2sqrt(const __half2 h); + +/* +Half Conversion And Data Movement +*/ + +__device__ __half2 __float22half2_rn(const float2 a); +__device__ __half __float2half(const float a); +__device__ __half2 __float2half2_rn(const float a); +__device__ __half __float2half_rd(const float a); +__device__ __half __float2half_rn(const float a); +__device__ __half __float2half_ru(const float a); +__device__ __half __float2half_rz(const float a); +__device__ __half2 __floats2half2_rn(const float a, const float b); +__device__ float2 __half22float2(const __half2 a); +__device__ float __half2float(const __half a); +__device__ __half2 half2half2(const __half a); +__device__ int __half2int_rd(__half h); +__device__ int __half2int_rn(__half h); +__device__ int __half2int_ru(__half h); +__device__ int __half2int_rz(__half h); +__device__ long long int __half2ll_rd(__half h); +__device__ long long int __half2ll_rn(__half h); +__device__ long long int __half2ll_ru(__half h); +__device__ long long int __half2ll_rz(__half h); +__device__ short __half2short_rd(__half h); +__device__ short __half2short_rn(__half h); +__device__ short __half2short_ru(__half h); +__device__ short __half2short_rz(__half h); +__device__ unsigned int __half2uint_rd(__half h); +__device__ unsigned int __half2uint_rn(__half h); +__device__ unsigned int __half2uint_ru(__half h); +__device__ unsigned int __half2uint_rz(__half h); +__device__ unsigned long long int __half2ull_rd(__half h); +__device__ unsigned long long int __half2ull_rn(__half h); +__device__ unsigned long long int __half2ull_ru(__half h); +__device__ unsigned long long int __half2ull_rz(__half h); +__device__ unsigned short int __half2ushort_rd(__half h); +__device__ unsigned short int __half2ushort_rn(__half h); +__device__ unsigned short int __half2ushort_ru(__half h); +__device__ unsigned short int __half2ushort_rz(__half h); +__device__ short int __half_as_short(const __half h); +__device__ unsigned short int __half_as_ushort(const __half h); +__device__ __half2 __halves2half2(const __half a, const __half b); +__device__ float __high2float(const __half2 a); +__device__ __half __high2half(const __half2 a); +__device__ __half2 __high2half2(const __half2 a); +__device__ __half2 __highs2half2(const __half2 a, const __half2 b); +__device__ __half __int2half_rd(int i); +__device__ __half __int2half_rn(int i); +__device__ __half __int2half_ru(int i); +__device__ __half __int2half_rz(int i); +__device__ __half __ll2half_rd(long long int i); +__device__ __half __ll2half_rn(long long int i); +__device__ __half __ll2half_ru(long long int i); +__device__ __half __ll2half_rz(long long int i); +__device__ float __low2float(const __half2 a); + +__device__ __half __low2half(const __half2 a); +__device__ __half2 __low2half2(const __half2 a, const __half2 b); +__device__ __half2 __low2half2(const __half2 a); +__device__ __half2 __lowhigh2highlow(const __half2 a); +__device__ __half2 __lows2half2(const __half2 a, const __half2 b); +__device__ __half __short2half_rd(short int i); +__device__ __half __short2half_rn(short int i); +__device__ __half __short2half_ru(short int i); +__device__ __half __short2half_rz(short int i); +__device__ __half __uint2half_rd(unsigned int i); +__device__ __half __uint2half_rn(unsigned int i); +__device__ __half __uint2half_ru(unsigned int i); +__device__ __half __uint2half_rz(unsigned int i); +__device__ __half __ull2half_rd(unsigned long long int i); +__device__ __half __ull2half_rn(unsigned long long int i); +__device__ __half __ull2half_ru(unsigned long long int i); +__device__ __half __ull2half_rz(unsigned long long int i); +__device__ __half __ushort2half_rd(unsigned short int i); +__device__ __half __ushort2half_rn(unsigned short int i); +__device__ __half __ushort2half_ru(unsigned short int i); +__device__ __half __ushort2half_rz(unsigned short int i); +__device__ __half __ushort_as_half(const unsigned short int i); + extern "C" __half __hip_hc_ir_hadd_half(__half, __half); extern "C" __half __hip_hc_ir_hfma_half(__half, __half, __half); extern "C" __half __hip_hc_ir_hmul_half(__half, __half); @@ -331,109 +506,7 @@ __device__ static inline __half2 h2trunc(const __half2 h) { return a; } -__device__ bool __heq(__half a, __half b); -__device__ bool __hge(__half a, __half b); -__device__ bool __hgt(__half a, __half b); -__device__ bool __hisinf(__half a); -__device__ bool __hisnan(__half a); -__device__ bool __hle(__half a, __half b); -__device__ bool __hlt(__half a, __half b); -__device__ bool __hne(__half a, __half b); -/* -Half2 Comparision Functions -*/ -__device__ bool __hbeq2(__half2 a, __half2 b); -__device__ bool __hbge2(__half2 a, __half2 b); -__device__ bool __hbgt2(__half2 a, __half2 b); -__device__ bool __hble2(__half2 a, __half2 b); -__device__ bool __hblt2(__half2 a, __half2 b); -__device__ bool __hbne2(__half2 a, __half2 b); -__device__ __half2 __heq2(__half2 a, __half2 b); -__device__ __half2 __hge2(__half2 a, __half2 b); -__device__ __half2 __hgt2(__half2 a, __half2 b); -__device__ __half2 __hisnan2(__half2 a); -__device__ __half2 __hle2(__half2 a, __half2 b); -__device__ __half2 __hlt2(__half2 a, __half2 b); -__device__ __half2 __hne2(__half2 a, __half2 b); - -/* -Conversion instructions -*/ -__device__ __half2 __float22half2_rn(const float2 a); -__device__ __half __float2half(const float a); -__device__ __half2 __float2half2_rn(const float a); -__device__ __half __float2half_rd(const float a); -__device__ __half __float2half_rn(const float a); -__device__ __half __float2half_ru(const float a); -__device__ __half __float2half_rz(const float a); -__device__ __half2 __floats2half2_rn(const float a, const float b); -__device__ float2 __half22float2(const __half2 a); -__device__ float __half2float(const __half a); -__device__ __half2 half2half2(const __half a); -__device__ int __half2int_rd(__half h); -__device__ int __half2int_rn(__half h); -__device__ int __half2int_ru(__half h); -__device__ int __half2int_rz(__half h); -__device__ long long int __half2ll_rd(__half h); -__device__ long long int __half2ll_rn(__half h); -__device__ long long int __half2ll_ru(__half h); -__device__ long long int __half2ll_rz(__half h); -__device__ short __half2short_rd(__half h); -__device__ short __half2short_rn(__half h); -__device__ short __half2short_ru(__half h); -__device__ short __half2short_rz(__half h); -__device__ unsigned int __half2uint_rd(__half h); -__device__ unsigned int __half2uint_rn(__half h); -__device__ unsigned int __half2uint_ru(__half h); -__device__ unsigned int __half2uint_rz(__half h); -__device__ unsigned long long int __half2ull_rd(__half h); -__device__ unsigned long long int __half2ull_rn(__half h); -__device__ unsigned long long int __half2ull_ru(__half h); -__device__ unsigned long long int __half2ull_rz(__half h); -__device__ unsigned short int __half2ushort_rd(__half h); -__device__ unsigned short int __half2ushort_rn(__half h); -__device__ unsigned short int __half2ushort_ru(__half h); -__device__ unsigned short int __half2ushort_rz(__half h); -__device__ short int __half_as_short(const __half h); -__device__ unsigned short int __half_as_ushort(const __half h); -__device__ __half2 __halves2half2(const __half a, const __half b); -__device__ float __high2float(const __half2 a); -__device__ __half __high2half(const __half2 a); -__device__ __half2 __high2half2(const __half2 a); -__device__ __half2 __highs2half2(const __half2 a, const __half2 b); -__device__ __half __int2half_rd(int i); -__device__ __half __int2half_rn(int i); -__device__ __half __int2half_ru(int i); -__device__ __half __int2half_rz(int i); -__device__ __half __ll2half_rd(long long int i); -__device__ __half __ll2half_rn(long long int i); -__device__ __half __ll2half_ru(long long int i); -__device__ __half __ll2half_rz(long long int i); -__device__ float __low2float(const __half2 a); - -__device__ __half __low2half(const __half2 a); -__device__ __half2 __low2half2(const __half2 a, const __half2 b); -__device__ __half2 __low2half2(const __half2 a); -__device__ __half2 __lowhigh2highlow(const __half2 a); -__device__ __half2 __lows2half2(const __half2 a, const __half2 b); -__device__ __half __short2half_rd(short int i); -__device__ __half __short2half_rn(short int i); -__device__ __half __short2half_ru(short int i); -__device__ __half __short2half_rz(short int i); -__device__ __half __uint2half_rd(unsigned int i); -__device__ __half __uint2half_rn(unsigned int i); -__device__ __half __uint2half_ru(unsigned int i); -__device__ __half __uint2half_rz(unsigned int i); -__device__ __half __ull2half_rd(unsigned long long int i); -__device__ __half __ull2half_rn(unsigned long long int i); -__device__ __half __ull2half_ru(unsigned long long int i); -__device__ __half __ull2half_rz(unsigned long long int i); -__device__ __half __ushort2half_rd(unsigned short int i); -__device__ __half __ushort2half_rn(unsigned short int i); -__device__ __half __ushort2half_ru(unsigned short int i); -__device__ __half __ushort2half_rz(unsigned short int i); -__device__ __half __ushort_as_half(const unsigned short int i); #endif From dc2f0fdeba212066123cf3c3c183a1d027eee144 Mon Sep 17 00:00:00 2001 From: Rahul Garg Date: Thu, 19 Jan 2017 15:04:32 +0530 Subject: [PATCH 081/281] Fixed hipcommander default execution for HCSWAP-106 Change-Id: I9fbd10dfaeeb4928b2ec23ceed131b5200a658f9 [ROCm/hip commit: cc0d2a675390b2d449a99e140f44cb78b776ba2b] --- projects/hip/samples/1_Utils/hipCommander/hipCommander.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/hip/samples/1_Utils/hipCommander/hipCommander.cpp b/projects/hip/samples/1_Utils/hipCommander/hipCommander.cpp index 9c07d066ba..0add1ce3e3 100644 --- a/projects/hip/samples/1_Utils/hipCommander/hipCommander.cpp +++ b/projects/hip/samples/1_Utils/hipCommander/hipCommander.cpp @@ -23,7 +23,7 @@ bool g_printedTiming = false; // Cmdline parms: int p_device = 0; -const char* p_command = "H2D; NullKernel; D2H"; +const char* p_command = "setstream(1); H2D; NullKernel; D2H;"; const char* p_file = nullptr; unsigned p_verbose = 0x0; unsigned p_db = 0x0; From 93642a85c70628610834a4f27337adbcfb3fb06b Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Sat, 14 Jan 2017 08:54:18 -0600 Subject: [PATCH 082/281] Fix debug display for Module launch kernels [ROCm/hip commit: 1c73e44ebe0a53329518e7f8d5b2ddd6949c11d3] --- projects/hip/src/hip_module.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/projects/hip/src/hip_module.cpp b/projects/hip/src/hip_module.cpp index 7d77dbe8dd..d6c50e82a9 100644 --- a/projects/hip/src/hip_module.cpp +++ b/projects/hip/src/hip_module.cpp @@ -297,8 +297,9 @@ hipError_t hipModuleLaunchKernel(hipFunction_t f, /* Kernel argument preparation. */ - grid_launch_parm lp; // TODO - dummy arg but values are printed during debug. - hStream = ihipPreLaunchKernel(hStream, 0, 0, &lp, f._name); + grid_launch_parm lp; + lp.dynamic_group_mem_bytes = f._groupSegmentSize; // TODO - this should be part of preLaunchKernel. + hStream = ihipPreLaunchKernel(hStream, dim3(gridDimX, gridDimY, gridDimZ), dim3(blockDimX, blockDimY, blockDimZ), &lp, f._name); hsa_kernel_dispatch_packet_t aql; From 5998ca2d85e486cf56c58fe97aa56cea0f8996e4 Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Thu, 19 Jan 2017 12:33:06 -0600 Subject: [PATCH 083/281] Doc update - describe debug techniques Also tweak sample to remove unneeded HIP_KERNEL_NAME. Comment update [ROCm/hip commit: 1f5d16afe79f7539431e32a2b9c4b0ad18f5cbe2] --- projects/hip/docs/markdown/hip_profiling.md | 48 ++++++++++++++++++- .../samples/0_Intro/square/square.hipref.cpp | 2 +- projects/hip/src/hip_hcc.cpp | 1 + 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/projects/hip/docs/markdown/hip_profiling.md b/projects/hip/docs/markdown/hip_profiling.md index c198c4dc4b..4119ef47e9 100644 --- a/projects/hip/docs/markdown/hip_profiling.md +++ b/projects/hip/docs/markdown/hip_profiling.md @@ -315,7 +315,7 @@ libhsa-runtime64.so.1->hsaKmtDeregisterMemory(0x7f7776d3e010, 0x7f7776d3e010, 0x ``` Some key information from the trace above. - - The trace snippet shows the execution of a hipMemcpy API, bracketed by the first and last message in the trace output. The messages show the thread id and API sequence number (`1.17`). ltrace output intermixes messages from all threads, so the HIP debug information can be useful to determine which threads are executing. + - Thy trace snippet shows the execution of a hipMemcpy API, bracketed by the first and last message in the trace output. The messages show the thread id and API sequence number (`1.17`). ltrace output intermixes messages from all threads, so the HIP debug information can be useful to determine which threads are executing. - The code flows through HIP APIs into ROCr (HSA) APIs (hsa*) and into the thunk (hsaKmt*) calls. - The HCC runtime is "libmcwamp_hsa.so" and the HSA/ROCr runtime is "libhsa-runtime64.so". - In this particular case, the memory copy is for unpinned memory, and the selected copy algorithm is to pin the host memory "in-place" before performing the copy. The signaling APIs and calls to pin ("lock", "register") the memory are readily apparent in the trace output. @@ -362,3 +362,49 @@ TargetAddress:0x5ec7e9000 ... -->0x5ec7e9000-0x5f7e28fff:: allocSeqNum:488 hostPointer:(nil) devicePointer:0x5ec7e9000 sizeBytes:191102976 isInDeviceMem:1 isAmManaged:1 appId:0 appAllocFlags:0 appPtr:(nil) ``` +- Debugging GPUVM fault. +For example: +``` +Memory access fault by GPU node-1 on address 0x5924000. Reason: Page not present or supervisor privilege. + +Program received signal SIGABRT, Aborted. +[Switching to Thread 0x7fffdffb5700 (LWP 14893)] +0x00007ffff2057c37 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56 +56 ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory. +(gdb) bt +#0 0x00007ffff2057c37 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56 +#1 0x00007ffff205b028 in __GI_abort () at abort.c:89 +#2 0x00007ffff6f960eb in ?? () from /opt/rocm/hsa/lib/libhsa-runtime64.so.1 +#3 0x00007ffff6f99ea5 in ?? () from /opt/rocm/hsa/lib/libhsa-runtime64.so.1 +#4 0x00007ffff6f78107 in ?? () from /opt/rocm/hsa/lib/libhsa-runtime64.so.1 +#5 0x00007ffff744f184 in start_thread (arg=0x7fffdffb5700) at pthread_create.c:312 +#6 0x00007ffff211b37d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111 +(gdb) info threads + Id Target Id Frame + 4 Thread 0x7fffdd521700 (LWP 14895) "caffe" pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 + 3 Thread 0x7fffddd22700 (LWP 14894) "caffe" pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185 +* 2 Thread 0x7fffdffb5700 (LWP 14893) "caffe" 0x00007ffff2057c37 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56 + 1 Thread 0x7ffff7fa6ac0 (LWP 14892) "caffe" 0x00007ffff6f934d5 in ?? () from /opt/rocm/hsa/lib/libhsa-runtime64.so.1 +(gdb) thread 1 +[Switching to thread 1 (Thread 0x7ffff7fa6ac0 (LWP 14892))] +#0 0x00007ffff6f934d5 in ?? () from /opt/rocm/hsa/lib/libhsa-runtime64.so.1 +(gdb) bt +#0 0x00007ffff6f934d5 in ?? () from /opt/rocm/hsa/lib/libhsa-runtime64.so.1 +#1 0x00007ffff6f929ba in ?? () from /opt/rocm/hsa/lib/libhsa-runtime64.so.1 +#2 0x00007fffe080beca in HSADispatch::waitComplete() () from /opt/rocm/hcc/lib/libmcwamp_hsa.so +#3 0x00007fffe080415f in HSADispatch::dispatchKernelAsync(Kalmar::HSAQueue*, void const*, int, bool) () from /opt/rocm/hcc/lib/libmcwamp_hsa.so +#4 0x00007fffe080238e in Kalmar::HSAQueue::dispatch_hsa_kernel(hsa_kernel_dispatch_packet_s const*, void const*, unsigned long, hc::completion_future*) () from /opt/rocm/hcc/lib/libmcwamp_hsa.so +#5 0x00007ffff7bb7559 in hipModuleLaunchKernel () from /opt/rocm/hip/lib/libhip_hcc.so +#6 0x00007ffff2e6cd2c in mlopen::HIPOCKernel::run (this=0x7fffffffb5a8, args=0x7fffffffb2a8, size=80) at /root/MIOpen/src/hipoc/hipoc_kernel.cpp:15 +... +``` + +Some general tips: +- The fault will be caught by the runtime but was actually generated by an asynchronous command running on the GPU. So, the GDB backtrace will show a path in the runtime, ie inside "GI_Raise" as shown in the example above. +- To determine the true location of the fault, force the kernels to execute synchronously by seeing the environment variables HCC_SERIALIZE_KERNEL=3 HCC_SERIALIZE_COPY=3. This will force HCC to wait for the kernel to finish executing before retuning. If the fault occurs during the execution of a kernel, you can see the code which launched the kernel inside the backtrace. A bit of guesswork is required to determine which thread is actually causing the issue - typically it will the thread which is waiting inside the libhsa-runtime64.so. +- VM faults inside kernels can be caused byi: + - incorrect code (ie a for loop which extends past array boundaries), i + - memory issues - kernel arguments which are invalid (null pointers, unregistered host pointers, bad pointers). + - synchronization issues + - compiler issues (incorrect code generation from the compiler) + - runtime issues diff --git a/projects/hip/samples/0_Intro/square/square.hipref.cpp b/projects/hip/samples/0_Intro/square/square.hipref.cpp index 3c863b8b76..0073c1399a 100644 --- a/projects/hip/samples/0_Intro/square/square.hipref.cpp +++ b/projects/hip/samples/0_Intro/square/square.hipref.cpp @@ -81,7 +81,7 @@ int main(int argc, char *argv[]) const unsigned threadsPerBlock = 256; printf ("info: launch 'vector_square' kernel\n"); - hipLaunchKernel(HIP_KERNEL_NAME(vector_square), dim3(blocks), dim3(threadsPerBlock), 0, 0, C_d, A_d, N); + hipLaunchKernel(vector_square, dim3(blocks), dim3(threadsPerBlock), 0, 0, C_d, A_d, N); printf ("info: copy Device2Host\n"); CHECK ( hipMemcpy(C_h, C_d, Nbytes, hipMemcpyDeviceToHost)); diff --git a/projects/hip/src/hip_hcc.cpp b/projects/hip/src/hip_hcc.cpp index a2383245fc..544fdc110d 100644 --- a/projects/hip/src/hip_hcc.cpp +++ b/projects/hip/src/hip_hcc.cpp @@ -338,6 +338,7 @@ void ihipStream_t::locked_wait() }; // Causes current stream to wait for specified event to complete: +// Note this does not require any kind of host serialization. void ihipStream_t::locked_waitEvent(hipEvent_t event) { LockedAccessor_StreamCrit_t crit(_criticalData); From 584a4a10c1923de4092d918afcc3c138ec930bb1 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Thu, 19 Jan 2017 15:15:25 -0600 Subject: [PATCH 084/281] added operator overloading for complex data types Change-Id: Id96d5d000651914169f04497af6ff78ad96d846a [ROCm/hip commit: 6ca2b289a212e20642f0bf972957eb70b574a1c3] --- .../hip/include/hip/hcc_detail/hip_complex.h | 161 +++++++++++++++++- 1 file changed, 156 insertions(+), 5 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/hip_complex.h b/projects/hip/include/hip/hcc_detail/hip_complex.h index f4af5839ad..d4fea7f034 100644 --- a/projects/hip/include/hip/hcc_detail/hip_complex.h +++ b/projects/hip/include/hip/hcc_detail/hip_complex.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,11 +20,162 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef HIPCOMPLEX_H -#define HIPCOMPLEX_H +#ifndef INCLUDE_HIP_HCC_DETAIL_HIP_COMPLEX_H +#define INCLUDE_HIP_HCC_DETAIL_HIP_COMPLEX_H -typedef float2 hipFloatComplex; -typedef double2 hipDoubleComplex; +#include "./hip_fp16.h" +#include "./hip_vector_types.h" + +#if __cplusplus +#define COMPLEX_ADD_OP_OVERLOAD(type) \ +__device__ __host__ static type operator + (const type& lhs, const type& rhs) { \ + type ret; \ + ret.x = lhs.x + rhs.x ; \ + ret.y = lhs.y + rhs.y ; \ + return ret; \ +} + +#define COMPLEX_SUB_OP_OVERLOAD(type) \ +__device__ __host__ static type operator - (const type& lhs, const type& rhs) { \ + type ret; \ + ret.x = lhs.x - rhs.x; \ + ret.y = lhs.y - rhs.y; \ + return ret; \ +} + +#define COMPLEX_MUL_OP_OVERLOAD(type) \ +__device__ __host__ static type operator * (const type& lhs, const type& rhs) { \ + type ret; \ + ret.x = lhs.x * rhs.x - lhs.y * rhs.y; \ + ret.y = lhs.x * rhs.y + lhs.y * rhs.x; \ + return ret; \ +} + +#define COMPLEX_DIV_OP_OVERLOAD(type) \ +__device__ __host__ static type operator / (const type& lhs, const type& rhs) { \ + type ret; \ + ret.x = (lhs.x * rhs.x + lhs.y * rhs.y); \ + ret.y = (rhs.x * lhs.y - lhs.x * rhs.y); \ + ret.x = ret.x / (rhs.x * rhs.x + rhs.y * rhs.y); \ + ret.y = ret.y / (rhs.x * rhs.x + rhs.y * rhs.y); \ + return ret; \ +} + +#define COMPLEX_ADD_PREOP_OVERLOAD(type) \ +__device__ __host__ static inline type& operator += (type& lhs, const type& rhs) { \ + lhs.x += rhs.x; \ + lhs.y += rhs.y; \ + return lhs; \ +} + +#define COMPLEX_SUB_PREOP_OVERLOAD(type) \ +__device__ __host__ static inline type& operator -= (type& lhs, const type& rhs) { \ + lhs.x -= rhs.x; \ + lhs.y -= rhs.y; \ + return lhs; \ +} + +#define COMPLEX_MUL_PREOP_OVERLOAD(type) \ +__device__ __host__ static inline type& operator *= (type& lhs, const type& rhs) { \ + lhs = lhs * rhs; \ + return lhs; \ +} + +#define COMPLEX_DIV_PREOP_OVERLOAD(type) \ +__device__ __host__ static inline type& operator /= (type& lhs, const type& rhs) { \ + lhs = lhs / rhs; \ + return lhs; \ +} + +#define COMPLEX_SCALAR_PRODUCT(type, type1) \ +__device__ __host__ static type operator * (const type& lhs, type1 rhs) { \ + type ret; \ + ret.x = lhs.x * rhs; \ + ret.y = lhs.y * rhs; \ + return ret; \ +} + +#endif + +struct hipFloatComplex { + #ifdef __cplusplus + public: + __device__ __host__ hipFloatComplex() : x(0.0f), y(0.0f) {} + __device__ __host__ hipFloatComplex(float x) : x(x), y(0.0f) {} + __device__ __host__ hipFloatComplex(float x, float y) : x(x), y(y) {} + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(hipFloatComplex, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(hipFloatComplex, signed short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(hipFloatComplex, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(hipFloatComplex, signed int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(hipFloatComplex, double) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(hipFloatComplex, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(hipFloatComplex, signed long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(hipFloatComplex, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(hipFloatComplex, signed long long) + #endif + float x, y; +} __attribute__((aligned(8))); + +struct hipDoubleComplex { + #ifdef __cplusplus + public: + __device__ __host__ hipDoubleComplex() : x(0.0f), y(0.0f) {} + __device__ __host__ hipDoubleComplex(double x) : x(x), y(0.0f) {} + __device__ __host__ hipDoubleComplex(double x, double y) : x(x), y(y) {} + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(hipDoubleComplex, unsigned short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(hipDoubleComplex, signed short) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(hipDoubleComplex, unsigned int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(hipDoubleComplex, signed int) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(hipDoubleComplex, float) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(hipDoubleComplex, unsigned long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(hipDoubleComplex, signed long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(hipDoubleComplex, unsigned long long) + MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(hipDoubleComplex, signed long long) + #endif + double x, y; +} __attribute__((aligned(16))); + +#if __cplusplus + +COMPLEX_ADD_OP_OVERLOAD(hipFloatComplex) +COMPLEX_SUB_OP_OVERLOAD(hipFloatComplex) +COMPLEX_MUL_OP_OVERLOAD(hipFloatComplex) +COMPLEX_DIV_OP_OVERLOAD(hipFloatComplex) +COMPLEX_ADD_PREOP_OVERLOAD(hipFloatComplex) +COMPLEX_SUB_PREOP_OVERLOAD(hipFloatComplex) +COMPLEX_MUL_PREOP_OVERLOAD(hipFloatComplex) +COMPLEX_DIV_PREOP_OVERLOAD(hipFloatComplex) +COMPLEX_SCALAR_PRODUCT(hipFloatComplex, unsigned short) +COMPLEX_SCALAR_PRODUCT(hipFloatComplex, signed short) +COMPLEX_SCALAR_PRODUCT(hipFloatComplex, unsigned int) +COMPLEX_SCALAR_PRODUCT(hipFloatComplex, signed int) +COMPLEX_SCALAR_PRODUCT(hipFloatComplex, float) +COMPLEX_SCALAR_PRODUCT(hipFloatComplex, unsigned long) +COMPLEX_SCALAR_PRODUCT(hipFloatComplex, signed long) +COMPLEX_SCALAR_PRODUCT(hipFloatComplex, double) +COMPLEX_SCALAR_PRODUCT(hipFloatComplex, signed long long) +COMPLEX_SCALAR_PRODUCT(hipFloatComplex, unsigned long long) + +COMPLEX_ADD_OP_OVERLOAD(hipDoubleComplex) +COMPLEX_SUB_OP_OVERLOAD(hipDoubleComplex) +COMPLEX_MUL_OP_OVERLOAD(hipDoubleComplex) +COMPLEX_DIV_OP_OVERLOAD(hipDoubleComplex) +COMPLEX_ADD_PREOP_OVERLOAD(hipDoubleComplex) +COMPLEX_SUB_PREOP_OVERLOAD(hipDoubleComplex) +COMPLEX_MUL_PREOP_OVERLOAD(hipDoubleComplex) +COMPLEX_DIV_PREOP_OVERLOAD(hipDoubleComplex) +COMPLEX_SCALAR_PRODUCT(hipDoubleComplex, unsigned short) +COMPLEX_SCALAR_PRODUCT(hipDoubleComplex, signed short) +COMPLEX_SCALAR_PRODUCT(hipDoubleComplex, unsigned int) +COMPLEX_SCALAR_PRODUCT(hipDoubleComplex, signed int) +COMPLEX_SCALAR_PRODUCT(hipDoubleComplex, float) +COMPLEX_SCALAR_PRODUCT(hipDoubleComplex, unsigned long) +COMPLEX_SCALAR_PRODUCT(hipDoubleComplex, signed long) +COMPLEX_SCALAR_PRODUCT(hipDoubleComplex, double) +COMPLEX_SCALAR_PRODUCT(hipDoubleComplex, signed long long) +COMPLEX_SCALAR_PRODUCT(hipDoubleComplex, unsigned long long) + +#endif __device__ static inline float hipCrealf(hipFloatComplex z){ return z.x; From b6c7c5bd8bef8f6cc5248a7e577b327169de9faf Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Thu, 19 Jan 2017 21:26:36 -0600 Subject: [PATCH 085/281] Change ihipDeviceSetState,ihipDevice* so it doesn't log error Cleans up debug trace. [ROCm/hip commit: 8209320ef0854a04362cc81ca9fc570138c607f2] --- projects/hip/src/hip_device.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/projects/hip/src/hip_device.cpp b/projects/hip/src/hip_device.cpp index 131526b6e2..5139eba0af 100644 --- a/projects/hip/src/hip_device.cpp +++ b/projects/hip/src/hip_device.cpp @@ -189,7 +189,7 @@ hipError_t ihipDeviceSetState(void) e = hipSuccess; } - return ihipLogStatus(e); + return e; } @@ -261,7 +261,7 @@ hipError_t ihipDeviceGetAttribute(int* pi, hipDeviceAttribute_t attr, int device } else { e = hipErrorInvalidDevice; } - return ihipLogStatus(e); + return e; } hipError_t hipDeviceGetAttribute(int* pi, hipDeviceAttribute_t attr, int device) @@ -287,7 +287,7 @@ hipError_t ihipGetDeviceProperties(hipDeviceProp_t* props, int device) e = hipErrorInvalidDevice; } - return ihipLogStatus(e); + return e; } hipError_t hipGetDeviceProperties(hipDeviceProp_t* props, int device) From 7a402a7fb1d4633452c05ebc15cb2da1354ef4d6 Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Thu, 19 Jan 2017 23:22:06 -0600 Subject: [PATCH 086/281] Add HIP_SYNC_HOST_ALLOC, HipReadEnv [ROCm/hip commit: 927ac3d81c2105bbf7ffd86434e880ea6456da6f] --- projects/hip/src/hip_hcc.cpp | 37 ++++++++++++++++++++++----------- projects/hip/src/hip_hcc.h | 2 +- projects/hip/src/hip_memory.cpp | 9 ++++++++ 3 files changed, 35 insertions(+), 13 deletions(-) diff --git a/projects/hip/src/hip_hcc.cpp b/projects/hip/src/hip_hcc.cpp index 544fdc110d..6360097557 100644 --- a/projects/hip/src/hip_hcc.cpp +++ b/projects/hip/src/hip_hcc.cpp @@ -92,6 +92,10 @@ int HIP_FORCE_SYNC_COPY = 0; int HIP_COHERENT_HOST_ALLOC = 0; +// TODO - set to 0 once we resolve stability. +// USE_ HIP_SYNC_HOST_ALLOC +int HIP_SYNC_HOST_ALLOC = 1; + @@ -1270,19 +1274,8 @@ std::string HIP_VISIBLE_DEVICES_callback(void *var_ptr, const char *envVarString } -//--- -//Function called one-time at initialization time to construct a table of all GPU devices. -//HIP/CUDA uses integer "deviceIds" - these are indexes into this table. -//AMP maintains a table of accelerators, but some are emulated - ie for debug or CPU. -//This function creates a vector with only the GPU accelerators. -//It is called with C++11 call_once, which provided thread-safety. -void ihipInit() +void HipReadEnv() { - -#if COMPILE_HIP_ATP_MARKER - amdtInitializeActivityLogger(); - amdtScopedMarker("ihipInit", "HIP", NULL); -#endif /* * Environment variables */ @@ -1324,6 +1317,8 @@ void ihipInit() READ_ENV_I(release, HIP_FORCE_P2P_HOST, 0, "Force use of host/staging copy for peer-to-peer copies.1=always use copies, 2=always return false for hipDeviceCanAccessPeer"); READ_ENV_I(release, HIP_FORCE_SYNC_COPY, 0, "Force all copies (even hipMemcpyAsync) to use sync copies"); + READ_ENV_I(release, HIP_SYNC_HOST_ALLOC, 0, "Sync before and after all host memory allocations. May help stability"); + // TODO - review, can we remove this? READ_ENV_I(release, HIP_NUM_KERNELS_INFLIGHT, 128, "Max number of inflight kernels per stream before active synchronization is forced."); @@ -1375,9 +1370,27 @@ void ihipInit() parseTrigger(HIP_DB_START_API, g_dbStartTriggers); parseTrigger(HIP_DB_STOP_API, g_dbStopTriggers); +}; +//--- +//Function called one-time at initialization time to construct a table of all GPU devices. +//HIP/CUDA uses integer "deviceIds" - these are indexes into this table. +//AMP maintains a table of accelerators, but some are emulated - ie for debug or CPU. +//This function creates a vector with only the GPU accelerators. +//It is called with C++11 call_once, which provided thread-safety. +void ihipInit() +{ + +#if COMPILE_HIP_ATP_MARKER + amdtInitializeActivityLogger(); + amdtScopedMarker("ihipInit", "HIP", NULL); +#endif + + + HipReadEnv(); + /* * Build a table of valid compute devices. diff --git a/projects/hip/src/hip_hcc.h b/projects/hip/src/hip_hcc.h index 031c92fca7..f59019137b 100644 --- a/projects/hip/src/hip_hcc.h +++ b/projects/hip/src/hip_hcc.h @@ -62,7 +62,7 @@ extern int HIP_COHERENT_HOST_ALLOC; //--- // Chicken bits for disabling functionality to work around potential issues: -extern int HIP_DISABLE_HW_KERNEL_DEP; +extern int HIP_SYNC_HOST_ALLOC; // Class to assign a short TID to each new thread, for HIP debugging purposes. diff --git a/projects/hip/src/hip_memory.cpp b/projects/hip/src/hip_memory.cpp index c43b6991c6..3c727d34fc 100644 --- a/projects/hip/src/hip_memory.cpp +++ b/projects/hip/src/hip_memory.cpp @@ -164,6 +164,10 @@ hipError_t hipHostMalloc(void** ptr, size_t sizeBytes, unsigned int flags) HIP_SET_DEVICE(); hipError_t hip_status = hipSuccess; + if (HIP_SYNC_HOST_ALLOC) { + hipDeviceSynchronize(); + } + auto ctx = ihipGetTlsDefaultCtx(); if (sizeBytes == 0) { @@ -216,6 +220,9 @@ hipError_t hipHostMalloc(void** ptr, size_t sizeBytes, unsigned int flags) } } } + if (HIP_SYNC_HOST_ALLOC) { + hipDeviceSynchronize(); + } return ihipLogStatus(hip_status); } @@ -993,6 +1000,8 @@ hipError_t hipHostFree(void* ptr) return ihipLogStatus(hipStatus); }; + +// Deprecated: hipError_t hipFreeHost(void* ptr) { return hipHostFree(ptr); From f5e3b72d0a6b4b17ac463eb0de6fe1a116bba13a Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Fri, 20 Jan 2017 09:49:11 -0600 Subject: [PATCH 087/281] fixed compilation issues for vector types and math functions 1. Added math_functions.h to hip_runtime.h 2. Changed operator overloading classifier static to static inline 3. Added vector types test for gpu 4. Seperated __host__ and __device__ for math functions in headers Change-Id: I499862fad5d7b10da686da9011d7ecefe523f8e2 [ROCm/hip commit: f537d96633cf6ef1d2ca36f7de280cd0fefaf7a9] --- .../hip/include/hip/hcc_detail/hip_runtime.h | 2 + .../include/hip/hcc_detail/hip_vector_types.h | 40 +- .../include/hip/hcc_detail/math_functions.h | 35 +- projects/hip/src/math_functions.cpp | 12 +- .../tests/src/deviceLib/hipVectorTypes.cpp | 1981 +++++---- .../src/deviceLib/hipVectorTypesDevice.cpp | 3880 +++++++++++++++++ 6 files changed, 4942 insertions(+), 1008 deletions(-) create mode 100644 projects/hip/tests/src/deviceLib/hipVectorTypesDevice.cpp diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime.h b/projects/hip/include/hip/hcc_detail/hip_runtime.h index f11846a0da..909b7f5680 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime.h @@ -69,6 +69,8 @@ extern int HIP_TRACE_API; #include #endif #include +#include + // TODO-HCC remove old definitions ; ~1602 hcc supports __HCC_ACCELERATOR__ define. #if defined (__KALMAR_ACCELERATOR__) && !defined (__HCC_ACCELERATOR__) #define __HCC_ACCELERATOR__ __KALMAR_ACCELERATOR__ diff --git a/projects/hip/include/hip/hcc_detail/hip_vector_types.h b/projects/hip/include/hip/hcc_detail/hip_vector_types.h index e15da69b3f..3e3acb8f29 100644 --- a/projects/hip/include/hip/hcc_detail/hip_vector_types.h +++ b/projects/hip/include/hip/hcc_detail/hip_vector_types.h @@ -1228,20 +1228,20 @@ DECLOP_MAKE_FOUR_COMPONENT(signed long, longlong4); #if __cplusplus #define DECLOP_1VAR_2IN_1OUT(type, op) \ -__device__ __host__ static type operator op (const type& lhs, const type& rhs) { \ +__device__ __host__ static inline type operator op (const type& lhs, const type& rhs) { \ type ret; \ ret.x = lhs.x op rhs.x; \ return ret; \ } #define DECLOP_1VAR_SCALE_PRODUCT(type, type1) \ -__device__ __host__ static type operator * (const type& lhs, type1 rhs) { \ +__device__ __host__ static inline type operator * (const type& lhs, type1 rhs) { \ type ret; \ ret.x = lhs.x * rhs; \ return ret; \ } \ \ -__device__ __host__ static type operator * (type1 lhs, const type& rhs) { \ +__device__ __host__ static inline type operator * (type1 lhs, const type& rhs) { \ type ret; \ ret.x = lhs * rhs.x; \ return ret; \ @@ -1260,7 +1260,7 @@ __device__ __host__ static inline type& operator op (type& val) { \ } #define DECLOP_1VAR_POSTOP(type, op) \ -__device__ __host__ static type operator op (type& val, int i) { \ +__device__ __host__ static inline type operator op (type& val, int i) { \ type ret; \ ret.x = val.x; \ val.x op; \ @@ -1273,7 +1273,7 @@ __device__ __host__ static inline bool operator op (type& lhs, type& rhs) { \ } #define DECLOP_1VAR_1IN_1OUT(type, op) \ -__device__ __host__ static type operator op(type& rhs) { \ +__device__ __host__ static inline type operator op(type& rhs) { \ type ret; \ ret.x = op rhs.x; \ return ret; \ @@ -1289,7 +1289,7 @@ __device__ __host__ static inline bool operator op (type& rhs) { \ */ #define DECLOP_2VAR_2IN_1OUT(type, op) \ -__device__ __host__ static type operator op (const type& lhs, const type& rhs) { \ +__device__ __host__ static inline type operator op (const type& lhs, const type& rhs) { \ type ret; \ ret.x = lhs.x op rhs.x; \ ret.y = lhs.y op rhs.y; \ @@ -1297,14 +1297,14 @@ __device__ __host__ static type operator op (const type& lhs, const type& rhs) { } #define DECLOP_2VAR_SCALE_PRODUCT(type, type1) \ -__device__ __host__ static type operator * (const type& lhs, type1 rhs) { \ +__device__ __host__ static inline type operator * (const type& lhs, type1 rhs) { \ type ret; \ ret.x = lhs.x * rhs; \ ret.y = lhs.y * rhs; \ return ret; \ } \ \ -__device__ __host__ static type operator * (type1 lhs, const type& rhs) { \ +__device__ __host__ static inline type operator * (type1 lhs, const type& rhs) { \ type ret; \ ret.x = lhs * rhs.x; \ ret.y = lhs * rhs.y; \ @@ -1326,7 +1326,7 @@ __device__ __host__ static inline type& operator op (type& val) { \ } #define DECLOP_2VAR_POSTOP(type, op) \ -__device__ __host__ static type operator op (type& val, int i) { \ +__device__ __host__ static inline type operator op (type& val, int i) { \ type ret; \ ret.x = val.x; \ ret.y = val.y; \ @@ -1341,7 +1341,7 @@ __device__ __host__ static inline bool operator op (type& lhs, type& rhs) { \ } #define DECLOP_2VAR_1IN_1OUT(type, op) \ -__device__ __host__ static type operator op(type &rhs) { \ +__device__ __host__ static inline type operator op(type &rhs) { \ type ret; \ ret.x = op rhs.x; \ ret.y = op rhs.y; \ @@ -1359,7 +1359,7 @@ __device__ __host__ static inline bool operator op (type &rhs) { \ */ #define DECLOP_3VAR_2IN_1OUT(type, op) \ -__device__ __host__ static type operator op (const type& lhs, const type& rhs) { \ +__device__ __host__ static inline type operator op (const type& lhs, const type& rhs) { \ type ret; \ ret.x = lhs.x op rhs.x; \ ret.y = lhs.y op rhs.y; \ @@ -1368,7 +1368,7 @@ __device__ __host__ static type operator op (const type& lhs, const type& rhs) { } #define DECLOP_3VAR_SCALE_PRODUCT(type, type1) \ -__device__ __host__ static type operator * (const type& lhs, type1 rhs) { \ +__device__ __host__ static inline type operator * (const type& lhs, type1 rhs) { \ type ret; \ ret.x = lhs.x * rhs; \ ret.y = lhs.y * rhs; \ @@ -1376,7 +1376,7 @@ __device__ __host__ static type operator * (const type& lhs, type1 rhs) { \ return ret; \ } \ \ -__device__ __host__ static type operator * (type1 lhs, const type& rhs) { \ +__device__ __host__ static inline type operator * (type1 lhs, const type& rhs) { \ type ret; \ ret.x = lhs * rhs.x; \ ret.y = lhs * rhs.y; \ @@ -1401,7 +1401,7 @@ __device__ __host__ static inline type& operator op (type& val) { \ } #define DECLOP_3VAR_POSTOP(type, op) \ -__device__ __host__ static type operator op (type& val, int i) { \ +__device__ __host__ static inline type operator op (type& val, int i) { \ type ret; \ ret.x = val.x; \ ret.y = val.y; \ @@ -1418,7 +1418,7 @@ __device__ __host__ static inline bool operator op (type& lhs, type& rhs) { \ } #define DECLOP_3VAR_1IN_1OUT(type, op) \ -__device__ __host__ static type operator op(type &rhs) { \ +__device__ __host__ static inline type operator op(type &rhs) { \ type ret; \ ret.x = op rhs.x; \ ret.y = op rhs.y; \ @@ -1437,7 +1437,7 @@ __device__ __host__ static inline bool operator op (type &rhs) { \ */ #define DECLOP_4VAR_2IN_1OUT(type, op) \ -__device__ __host__ static type operator op ( const type& lhs, const type& rhs) { \ +__device__ __host__ static inline type operator op ( const type& lhs, const type& rhs) { \ type ret; \ ret.x = lhs.x op rhs.x; \ ret.y = lhs.y op rhs.y; \ @@ -1447,7 +1447,7 @@ __device__ __host__ static type operator op ( const type& lhs, const type& rhs) } #define DECLOP_4VAR_SCALE_PRODUCT(type, type1) \ -__device__ __host__ static type operator * (const type& lhs, type1 rhs) { \ +__device__ __host__ static inline type operator * (const type& lhs, type1 rhs) { \ type ret; \ ret.x = lhs.x * rhs; \ ret.y = lhs.y * rhs; \ @@ -1456,7 +1456,7 @@ __device__ __host__ static type operator * (const type& lhs, type1 rhs) { \ return ret; \ } \ \ -__device__ __host__ static type operator * (type1 lhs, const type& rhs) { \ +__device__ __host__ static inline type operator * (type1 lhs, const type& rhs) { \ type ret; \ ret.x = lhs * rhs.x; \ ret.y = lhs * rhs.y; \ @@ -1484,7 +1484,7 @@ __device__ __host__ static inline type& operator op (type& val) { \ } #define DECLOP_4VAR_POSTOP(type, op) \ -__device__ __host__ static type operator op (type& val, int i) { \ +__device__ __host__ static inline type operator op (type& val, int i) { \ type ret; \ ret.x = val.x; \ ret.y = val.y; \ @@ -1503,7 +1503,7 @@ __device__ __host__ static inline bool operator op (type& lhs, type& rhs) { \ } #define DECLOP_4VAR_1IN_1OUT(type, op) \ -__device__ __host__ static type operator op(type &rhs) { \ +__device__ __host__ static inline type operator op(type &rhs) { \ type ret; \ ret.x = op rhs.x; \ ret.y = op rhs.y; \ diff --git a/projects/hip/include/hip/hcc_detail/math_functions.h b/projects/hip/include/hip/hcc_detail/math_functions.h index b07830958f..2755c896db 100644 --- a/projects/hip/include/hip/hcc_detail/math_functions.h +++ b/projects/hip/include/hip/hcc_detail/math_functions.h @@ -36,7 +36,7 @@ __device__ float ceilf(float x); __device__ float copysignf(float x, float y); __device__ float cosf(float x); __device__ float coshf(float x); -__device__ __host__ float cospif(float x); +__device__ float cospif(float x); //__device__ float cyl_bessel_i0f(float x); //__device__ float cyl_bessel_i1f(float x); __device__ float erfcf(float x); @@ -50,7 +50,7 @@ __device__ float expf(float x); __device__ float expm1f(float x); __device__ float fabsf(float x); __device__ float fdimf(float x, float y); -__device__ __host__ float fdividef(float x, float y); +__device__ float fdividef(float x, float y); __device__ float floorf(float x); __device__ float fmaf(float x, float y, float z); __device__ float fmaxf(float x, float y); @@ -59,7 +59,7 @@ __device__ float fmodf(float x, float y); //__device__ float frexpf(float x, int* nptr); __device__ float hypotf(float x, float y); __device__ float ilogbf(float x); -__device__ __host__ int isfinite(float a); +__device__ int isfinite(float a); __device__ unsigned isinf(float a); __device__ unsigned isnan(float a); __device__ float j0f(float x); @@ -93,15 +93,15 @@ __device__ float rnorm3df(float a, float b, float c); __device__ float rnorm4df(float a, float b, float c, float d); __device__ float rnormf(int dim, const float* a); __device__ float roundf(float x); -__device__ __host__ float rsqrtf(float x); +__device__ float rsqrtf(float x); __device__ float scalblnf(float x, long int n); __device__ float scalbnf(float x, int n); -__device__ __host__ unsigned signbit(float a); +__device__ int signbit(float a); __device__ void sincosf(float x, float *sptr, float *cptr); __device__ void sincospif(float x, float *sptr, float *cptr); __device__ float sinf(float x); __device__ float sinhf(float x); -__device__ __host__ float sinpif(float x); +__device__ float sinpif(float x); __device__ float sqrtf(float x); __device__ float tanf(float x); __device__ float tanhf(float x); @@ -111,11 +111,12 @@ __device__ float y0f(float x); __device__ float y1f(float x); __device__ float ynf(int n, float x); - +__host__ float cospif(float x); __host__ float normcdff(float y); __host__ float erfcinvf(float y); __host__ float erfcxf(float x); __host__ float erfinvf(float y); +__host__ float fdividef(float x, float y); __host__ float norm3df(float a, float b, float c); __host__ float normcdfinvf(float y); __host__ float norm4df(float a, float b, float c, float d); @@ -125,7 +126,10 @@ __host__ float rnorm3df(float a, float b, float c); __host__ float rnormf(int dim, const float* a); __host__ float rnorm4df(float a, float b, float c, float d); __host__ void sincospif(float x, float *sptr, float *cptr); - +__host__ int isfinite(float a); +__host__ float rsqrtf(float x); +__host__ float sinpif(float x); +__host__ int signbit(float a); __device__ double acos(double x); @@ -140,7 +144,7 @@ __device__ double ceil(double x); __device__ double copysign(double x, double y); __device__ double cos(double x); __device__ double cosh(double x); -__device__ __host__ double cospi(double x); +__device__ double cospi(double x); //__device__ double cyl_bessel_i0(double x); //__device__ double cyl_bessel_i1(double x); __device__ double erf(double x); @@ -162,7 +166,7 @@ __device__ double fmod(double x, double y); //__device__ double frexp(double x, int *nptr); __device__ double hypot(double x, double y); __device__ double ilogb(double x); -__device__ __host__ unsigned isfinite(double x); +__device__ int isfinite(double x); __device__ unsigned isinf(double x); __device__ unsigned isnan(double x); __device__ double j0(double x); @@ -198,15 +202,15 @@ __device__ double rnorm(int dim, const double* t); __device__ double rnorm3d(double a, double b, double c); __device__ double rnorm4d(double a, double b, double c, double d); __device__ double round(double x); -__device__ __host__ double rsqrt(double x); +__device__ double rsqrt(double x); __device__ double scalbln(double x, long int n); __device__ double scalbn(double x, int n); -__device__ __host__ unsigned signbit(double a); +__device__ int signbit(double a); __device__ double sin(double a); __device__ void sincos(double x, double *sptr, double *cptr); __device__ void sincospi(double x, double *sptr, double *cptr); __device__ double sinh(double x); -__device__ __host__ double sinpi(double x); +__device__ double sinpi(double x); __device__ double sqrt(double x); __device__ double tan(double x); __device__ double tanh(double x); @@ -231,6 +235,11 @@ __host__ double rnorm(int dim, const double* t); __host__ double rnorm3d(double a, double b, double c); __host__ double rnorm4d(double a, double b, double c, double d); __host__ void sincospi(double x, double *sptr, double *cptr); +__host__ double cospi(double x); +__host__ int isfinite(double x); +__host__ double rsqrt(double x); +__host__ int signbit(double a); +__host__ double sinpi(double x); // ENDPARSER diff --git a/projects/hip/src/math_functions.cpp b/projects/hip/src/math_functions.cpp index 130d4152ae..a1ee9d3ce5 100644 --- a/projects/hip/src/math_functions.cpp +++ b/projects/hip/src/math_functions.cpp @@ -158,7 +158,7 @@ __device__ float ilogbf(float x) { return hc::precise_math::ilogbf(x); } -__device__ unsigned isfinite(float a) +__device__ int isfinite(float a) { return hc::precise_math::isfinite(a); } @@ -334,7 +334,7 @@ __device__ float scalbnf(float x, int n) { return hc::precise_math::scalbnf(x, n); } -__device__ unsigned signbit(float a) +__device__ int signbit(float a) { return hc::precise_math::signbit(a); } @@ -539,7 +539,7 @@ __device__ double ilogb(double x) { return hc::precise_math::ilogb(x); } -__device__ unsigned isfinite(double x) +__device__ int isfinite(double x) { return hc::precise_math::isfinite(x); } @@ -712,7 +712,7 @@ __device__ double scalbn(double x, int n) { return hc::precise_math::scalbn(x, n); } -__device__ unsigned signbit(double x) +__device__ int signbit(double x) { return hc::precise_math::signbit(x); } @@ -792,7 +792,7 @@ __host__ int signbit(float x) return std::signbit(x); } -__host__ int sinpif(float x) +__host__ float sinpif(float x) { return std::sin(x*HIP_PI); } @@ -984,7 +984,7 @@ __host__ double cospi(double a) return std::cos(HIP_PI * a); } -__host__ double isfinite(double a) +__host__ int isfinite(double a) { return std::isfinite(a); } diff --git a/projects/hip/tests/src/deviceLib/hipVectorTypes.cpp b/projects/hip/tests/src/deviceLib/hipVectorTypes.cpp index 0e5757b30d..957439c27e 100644 --- a/projects/hip/tests/src/deviceLib/hipVectorTypes.cpp +++ b/projects/hip/tests/src/deviceLib/hipVectorTypes.cpp @@ -20,29 +20,35 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/* HIT_START + * BUILD: %t %s ../test_common.cpp + * RUN: %t + * HIT_END + */ + #include #include -#include - -#define cmpFloat1(in, exp) \ +#include +#include"test_common.h" +#define cmpVal1(in, exp) \ if(in.x != exp) { \ std::cout<<"Failed at: "<<__LINE__<<" in func: "<<__func__<<" expected output: "<> f1; - cmpFloat1(f2, 2); + cmpVal1(f2, 2); f1.x = 2; f2.x = 1; f1 += f2; - cmpFloat1(f1, 3); + cmpVal1(f1, 3); f1 -= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 *= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 /= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 %= f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f1 &= f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f1 |= f2; - cmpFloat1(f1, 1); + cmpVal1(f1, 1); f1 ^= f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f1.x = 1; f1 <<= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 >>= f2; - cmpFloat1(f1, 1); + cmpVal1(f1, 1); f1.x = 2; f2 = f1++; - cmpFloat1(f1, 3); - cmpFloat1(f2, 2); + cmpVal1(f1, 3); + cmpVal1(f2, 2); f2 = f1--; - cmpFloat1(f2, 3); - cmpFloat1(f1, 2); + cmpVal1(f2, 3); + cmpVal1(f1, 2); f2 = ++f1; - cmpFloat1(f1, 3); - cmpFloat1(f2, 3); + cmpVal1(f1, 3); + cmpVal1(f2, 3); f2 = --f1; - cmpFloat1(f1, 2); - cmpFloat1(f2, 2); + cmpVal1(f1, 2); + cmpVal1(f2, 2); f2 = ~f1; - cmpFloat1(f2, 253); + cmpVal1(f2, 253); assert(!f1 == false); + f1.x = 3; + f1 = f1 * (unsigned char)1; + cmpVal1(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed char)1; + cmpVal1(f1, 3); + f1 = (signed char)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal1(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed short)1; + cmpVal1(f1, 3); + f1 = (signed short)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal1(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed int)1; + cmpVal1(f1, 3); + f1 = (signed int)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (float)1; + cmpVal1(f1, 3); + f1 = (float)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal1(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed long)1; + cmpVal1(f1, 3); + f1 = (signed long)1 * f1; + cmpVal1(f1, 3); + +// signed char sc = 1; f1.x = 3; f2.x = 4; @@ -137,72 +182,72 @@ bool TestUChar2() { f2.x = 1; f2.y = 1; f3 = f1 + f2; - cmpFloat2(f3, 2); + cmpVal2(f3, 2); f2 = f3 - f1; - cmpFloat2(f2, 1); + cmpVal2(f2, 1); f1 = f2 * f3; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f2 = f1 / f3; - cmpFloat2(f2, 2/2); + cmpVal2(f2, 2/2); f3 = f1 % f2; - cmpFloat2(f3, 0); + cmpVal2(f3, 0); f1 = f3 & f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f2 = f1 ^ f3; - cmpFloat2(f2, 0); + cmpVal2(f2, 0); f1.x = 1; f1.y = 1; f2.x = 2; f2.y = 2; f3 = f1 << f2; - cmpFloat2(f3, 4); + cmpVal2(f3, 4); f2 = f3 >> f1; - cmpFloat2(f2, 2); + cmpVal2(f2, 2); f1.x = 2; f1.y = 2; f2.x = 1; f2.y = 1; f1 += f2; - cmpFloat2(f1, 3); + cmpVal2(f1, 3); f1 -= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 *= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 /= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 %= f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f1 &= f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f1 |= f2; - cmpFloat2(f1, 1); + cmpVal2(f1, 1); f1 ^= f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f1.x = 1; f1.y = 1; f1 <<= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 >>= f2; - cmpFloat2(f1, 1); + cmpVal2(f1, 1); f1.x = 2; f1.y = 2; f2 = f1++; - cmpFloat2(f1, 3); - cmpFloat2(f2, 2); + cmpVal2(f1, 3); + cmpVal2(f2, 2); f2 = f1--; - cmpFloat2(f2, 3); - cmpFloat2(f1, 2); + cmpVal2(f2, 3); + cmpVal2(f1, 2); f2 = ++f1; - cmpFloat2(f1, 3); - cmpFloat2(f2, 3); + cmpVal2(f1, 3); + cmpVal2(f2, 3); f2 = --f1; - cmpFloat2(f1, 2); - cmpFloat2(f2, 2); + cmpVal2(f1, 2); + cmpVal2(f2, 2); f2 = ~f1; - cmpFloat2(f2, 253); + cmpVal2(f2, 253); assert(!f1 == false); f1.x = 3; @@ -232,19 +277,19 @@ bool TestUChar3() { f2.y = 1; f2.z = 1; f3 = f1 + f2; - cmpFloat3(f3, 2); + cmpVal3(f3, 2); f2 = f3 - f1; - cmpFloat3(f2, 1); + cmpVal3(f2, 1); f1 = f2 * f3; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f2 = f1 / f3; - cmpFloat3(f2, 2/2); + cmpVal3(f2, 2/2); f3 = f1 % f2; - cmpFloat3(f3, 0); + cmpVal3(f3, 0); f1 = f3 & f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f2 = f1 ^ f3; - cmpFloat3(f2, 0); + cmpVal3(f2, 0); f1.x = 1; f1.y = 1; f1.z = 1; @@ -252,9 +297,9 @@ bool TestUChar3() { f2.y = 2; f2.z = 2; f3 = f1 << f2; - cmpFloat3(f3, 4); + cmpVal3(f3, 4); f2 = f3 >> f1; - cmpFloat3(f2, 2); + cmpVal3(f2, 2); f1.x = 2; f1.y = 2; @@ -263,47 +308,47 @@ bool TestUChar3() { f2.y = 1; f2.z = 1; f1 += f2; - cmpFloat3(f1, 3); + cmpVal3(f1, 3); f1 -= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 *= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 /= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 %= f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f1 &= f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f1 |= f2; - cmpFloat3(f1, 1); + cmpVal3(f1, 1); f1 ^= f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f1.x = 1; f1.y = 1; f1.z = 1; f1 <<= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 >>= f2; - cmpFloat3(f1, 1); + cmpVal3(f1, 1); f1.x = 2; f1.y = 2; f1.z = 2; f2 = f1++; - cmpFloat3(f1, 3); - cmpFloat3(f2, 2); + cmpVal3(f1, 3); + cmpVal3(f2, 2); f2 = f1--; - cmpFloat3(f2, 3); - cmpFloat3(f1, 2); + cmpVal3(f2, 3); + cmpVal3(f1, 2); f2 = ++f1; - cmpFloat3(f1, 3); - cmpFloat3(f2, 3); + cmpVal3(f1, 3); + cmpVal3(f2, 3); f2 = --f1; - cmpFloat3(f1, 2); - cmpFloat3(f2, 2); + cmpVal3(f1, 2); + cmpVal3(f2, 2); f2 = ~f1; - cmpFloat3(f2, 253); + cmpVal3(f2, 253); assert(!f1 == false); f1.x = 3; @@ -338,19 +383,19 @@ bool TestUChar4() { f2.z = 1; f2.w = 1; f3 = f1 + f2; - cmpFloat4(f3, 2); + cmpVal4(f3, 2); f2 = f3 - f1; - cmpFloat4(f2, 1); + cmpVal4(f2, 1); f1 = f2 * f3; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f2 = f1 / f3; - cmpFloat4(f2, 2/2); + cmpVal4(f2, 2/2); f3 = f1 % f2; - cmpFloat4(f3, 0); + cmpVal4(f3, 0); f1 = f3 & f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f2 = f1 ^ f3; - cmpFloat4(f2, 0); + cmpVal4(f2, 0); f1.x = 1; f1.y = 1; f1.z = 1; @@ -360,9 +405,9 @@ bool TestUChar4() { f2.z = 2; f2.w = 2; f3 = f1 << f2; - cmpFloat4(f3, 4); + cmpVal4(f3, 4); f2 = f3 >> f1; - cmpFloat4(f2, 2); + cmpVal4(f2, 2); f1.x = 2; f1.y = 2; @@ -373,49 +418,49 @@ bool TestUChar4() { f2.z = 1; f2.w = 1; f1 += f2; - cmpFloat4(f1, 3); + cmpVal4(f1, 3); f1 -= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 *= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 /= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 %= f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f1 &= f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f1 |= f2; - cmpFloat4(f1, 1); + cmpVal4(f1, 1); f1 ^= f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f1.x = 1; f1.y = 1; f1.z = 1; f1.w = 1; f1 <<= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 >>= f2; - cmpFloat4(f1, 1); + cmpVal4(f1, 1); f1.x = 2; f1.y = 2; f1.z = 2; f1.w = 2; f2 = f1++; - cmpFloat4(f1, 3); - cmpFloat4(f2, 2); + cmpVal4(f1, 3); + cmpVal4(f2, 2); f2 = f1--; - cmpFloat4(f2, 3); - cmpFloat4(f1, 2); + cmpVal4(f2, 3); + cmpVal4(f1, 2); f2 = ++f1; - cmpFloat4(f1, 3); - cmpFloat4(f2, 3); + cmpVal4(f1, 3); + cmpVal4(f2, 3); f2 = --f1; - cmpFloat4(f1, 2); - cmpFloat4(f2, 2); + cmpVal4(f1, 2); + cmpVal4(f2, 2); f2 = ~f1; - cmpFloat4(f2, 253); + cmpVal4(f2, 253); assert(!f1 == false); f1.x = 3; @@ -447,66 +492,66 @@ bool TestChar1() { f1.x = 1; f2.x = 1; f3 = f1 + f2; - cmpFloat1(f3, 2); + cmpVal1(f3, 2); f2 = f3 - f1; - cmpFloat1(f2, 1); + cmpVal1(f2, 1); f1 = f2 * f3; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f2 = f1 / f3; - cmpFloat1(f2, 2/2); + cmpVal1(f2, 2/2); f3 = f1 % f2; - cmpFloat1(f3, 0); + cmpVal1(f3, 0); f1 = f3 & f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f2 = f1 ^ f3; - cmpFloat1(f2, 0); + cmpVal1(f2, 0); f1.x = 1; f2.x = 2; f3 = f1 << f2; - cmpFloat1(f3, 4); + cmpVal1(f3, 4); f2 = f3 >> f1; - cmpFloat1(f2, 2); + cmpVal1(f2, 2); f1.x = 2; f2.x = 1; f1 += f2; - cmpFloat1(f1, 3); + cmpVal1(f1, 3); f1 -= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 *= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 /= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 %= f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f1 &= f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f1 |= f2; - cmpFloat1(f1, 1); + cmpVal1(f1, 1); f1 ^= f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f1.x = 1; f1 <<= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 >>= f2; - cmpFloat1(f1, 1); + cmpVal1(f1, 1); f1.x = 2; f2 = f1++; - cmpFloat1(f1, 3); - cmpFloat1(f2, 2); + cmpVal1(f1, 3); + cmpVal1(f2, 2); f2 = f1--; - cmpFloat1(f2, 3); - cmpFloat1(f1, 2); + cmpVal1(f2, 3); + cmpVal1(f1, 2); f2 = ++f1; - cmpFloat1(f1, 3); - cmpFloat1(f2, 3); + cmpVal1(f1, 3); + cmpVal1(f2, 3); f2 = --f1; - cmpFloat1(f1, 2); - cmpFloat1(f2, 2); + cmpVal1(f1, 2); + cmpVal1(f2, 2); f2 = ~f1; - cmpFloat1(f2, (char)253); + cmpVal1(f2, (char)253); assert(!f1 == false); f1.x = 3; @@ -531,72 +576,72 @@ bool TestChar2() { f2.x = 1; f2.y = 1; f3 = f1 + f2; - cmpFloat2(f3, 2); + cmpVal2(f3, 2); f2 = f3 - f1; - cmpFloat2(f2, 1); + cmpVal2(f2, 1); f1 = f2 * f3; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f2 = f1 / f3; - cmpFloat2(f2, 2/2); + cmpVal2(f2, 2/2); f3 = f1 % f2; - cmpFloat2(f3, 0); + cmpVal2(f3, 0); f1 = f3 & f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f2 = f1 ^ f3; - cmpFloat2(f2, 0); + cmpVal2(f2, 0); f1.x = 1; f1.y = 1; f2.x = 2; f2.y = 2; f3 = f1 << f2; - cmpFloat2(f3, 4); + cmpVal2(f3, 4); f2 = f3 >> f1; - cmpFloat2(f2, 2); + cmpVal2(f2, 2); f1.x = 2; f1.y = 2; f2.x = 1; f2.y = 1; f1 += f2; - cmpFloat2(f1, 3); + cmpVal2(f1, 3); f1 -= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 *= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 /= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 %= f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f1 &= f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f1 |= f2; - cmpFloat2(f1, 1); + cmpVal2(f1, 1); f1 ^= f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f1.x = 1; f1.y = 1; f1 <<= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 >>= f2; - cmpFloat2(f1, 1); + cmpVal2(f1, 1); f1.x = 2; f1.y = 2; f2 = f1++; - cmpFloat2(f1, 3); - cmpFloat2(f2, 2); + cmpVal2(f1, 3); + cmpVal2(f2, 2); f2 = f1--; - cmpFloat2(f2, 3); - cmpFloat2(f1, 2); + cmpVal2(f2, 3); + cmpVal2(f1, 2); f2 = ++f1; - cmpFloat2(f1, 3); - cmpFloat2(f2, 3); + cmpVal2(f1, 3); + cmpVal2(f2, 3); f2 = --f1; - cmpFloat2(f1, 2); - cmpFloat2(f2, 2); + cmpVal2(f1, 2); + cmpVal2(f2, 2); f2 = ~f1; - cmpFloat2(f2, (char)253); + cmpVal2(f2, (char)253); assert(!f1 == false); f1.x = 3; @@ -626,19 +671,19 @@ bool TestChar3() { f2.y = 1; f2.z = 1; f3 = f1 + f2; - cmpFloat3(f3, 2); + cmpVal3(f3, 2); f2 = f3 - f1; - cmpFloat3(f2, 1); + cmpVal3(f2, 1); f1 = f2 * f3; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f2 = f1 / f3; - cmpFloat3(f2, 2/2); + cmpVal3(f2, 2/2); f3 = f1 % f2; - cmpFloat3(f3, 0); + cmpVal3(f3, 0); f1 = f3 & f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f2 = f1 ^ f3; - cmpFloat3(f2, 0); + cmpVal3(f2, 0); f1.x = 1; f1.y = 1; f1.z = 1; @@ -646,9 +691,9 @@ bool TestChar3() { f2.y = 2; f2.z = 2; f3 = f1 << f2; - cmpFloat3(f3, 4); + cmpVal3(f3, 4); f2 = f3 >> f1; - cmpFloat3(f2, 2); + cmpVal3(f2, 2); f1.x = 2; f1.y = 2; @@ -657,47 +702,47 @@ bool TestChar3() { f2.y = 1; f2.z = 1; f1 += f2; - cmpFloat3(f1, 3); + cmpVal3(f1, 3); f1 -= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 *= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 /= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 %= f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f1 &= f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f1 |= f2; - cmpFloat3(f1, 1); + cmpVal3(f1, 1); f1 ^= f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f1.x = 1; f1.y = 1; f1.z = 1; f1 <<= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 >>= f2; - cmpFloat3(f1, 1); + cmpVal3(f1, 1); f1.x = 2; f1.y = 2; f1.z = 2; f2 = f1++; - cmpFloat3(f1, 3); - cmpFloat3(f2, 2); + cmpVal3(f1, 3); + cmpVal3(f2, 2); f2 = f1--; - cmpFloat3(f2, 3); - cmpFloat3(f1, 2); + cmpVal3(f2, 3); + cmpVal3(f1, 2); f2 = ++f1; - cmpFloat3(f1, 3); - cmpFloat3(f2, 3); + cmpVal3(f1, 3); + cmpVal3(f2, 3); f2 = --f1; - cmpFloat3(f1, 2); - cmpFloat3(f2, 2); + cmpVal3(f1, 2); + cmpVal3(f2, 2); f2 = ~f1; - cmpFloat3(f2, (char)253); + cmpVal3(f2, (char)253); assert(!f1 == false); f1.x = 3; @@ -732,19 +777,19 @@ bool TestChar4() { f2.z = 1; f2.w = 1; f3 = f1 + f2; - cmpFloat4(f3, 2); + cmpVal4(f3, 2); f2 = f3 - f1; - cmpFloat4(f2, 1); + cmpVal4(f2, 1); f1 = f2 * f3; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f2 = f1 / f3; - cmpFloat4(f2, 2/2); + cmpVal4(f2, 2/2); f3 = f1 % f2; - cmpFloat4(f3, 0); + cmpVal4(f3, 0); f1 = f3 & f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f2 = f1 ^ f3; - cmpFloat4(f2, 0); + cmpVal4(f2, 0); f1.x = 1; f1.y = 1; f1.z = 1; @@ -754,9 +799,9 @@ bool TestChar4() { f2.z = 2; f2.w = 2; f3 = f1 << f2; - cmpFloat4(f3, 4); + cmpVal4(f3, 4); f2 = f3 >> f1; - cmpFloat4(f2, 2); + cmpVal4(f2, 2); f1.x = 2; f1.y = 2; @@ -767,49 +812,49 @@ bool TestChar4() { f2.z = 1; f2.w = 1; f1 += f2; - cmpFloat4(f1, 3); + cmpVal4(f1, 3); f1 -= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 *= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 /= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 %= f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f1 &= f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f1 |= f2; - cmpFloat4(f1, 1); + cmpVal4(f1, 1); f1 ^= f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f1.x = 1; f1.y = 1; f1.z = 1; f1.w = 1; f1 <<= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 >>= f2; - cmpFloat4(f1, 1); + cmpVal4(f1, 1); f1.x = 2; f1.y = 2; f1.z = 2; f1.w = 2; f2 = f1++; - cmpFloat4(f1, 3); - cmpFloat4(f2, 2); + cmpVal4(f1, 3); + cmpVal4(f2, 2); f2 = f1--; - cmpFloat4(f2, 3); - cmpFloat4(f1, 2); + cmpVal4(f2, 3); + cmpVal4(f1, 2); f2 = ++f1; - cmpFloat4(f1, 3); - cmpFloat4(f2, 3); + cmpVal4(f1, 3); + cmpVal4(f2, 3); f2 = --f1; - cmpFloat4(f1, 2); - cmpFloat4(f2, 2); + cmpVal4(f1, 2); + cmpVal4(f2, 2); f2 = ~f1; - cmpFloat4(f2, (char)253); + cmpVal4(f2, (char)253); assert(!f1 == false); f1.x = 3; @@ -841,66 +886,66 @@ bool TestUShort1() { f1.x = 1; f2.x = 1; f3 = f1 + f2; - cmpFloat1(f3, 2); + cmpVal1(f3, 2); f2 = f3 - f1; - cmpFloat1(f2, 1); + cmpVal1(f2, 1); f1 = f2 * f3; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f2 = f1 / f3; - cmpFloat1(f2, 2/2); + cmpVal1(f2, 2/2); f3 = f1 % f2; - cmpFloat1(f3, 0); + cmpVal1(f3, 0); f1 = f3 & f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f2 = f1 ^ f3; - cmpFloat1(f2, 0); + cmpVal1(f2, 0); f1.x = 1; f2.x = 2; f3 = f1 << f2; - cmpFloat1(f3, 4); + cmpVal1(f3, 4); f2 = f3 >> f1; - cmpFloat1(f2, 2); + cmpVal1(f2, 2); f1.x = 2; f2.x = 1; f1 += f2; - cmpFloat1(f1, 3); + cmpVal1(f1, 3); f1 -= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 *= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 /= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 %= f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f1 &= f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f1 |= f2; - cmpFloat1(f1, 1); + cmpVal1(f1, 1); f1 ^= f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f1.x = 1; f1 <<= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 >>= f2; - cmpFloat1(f1, 1); + cmpVal1(f1, 1); f1.x = 2; f2 = f1++; - cmpFloat1(f1, 3); - cmpFloat1(f2, 2); + cmpVal1(f1, 3); + cmpVal1(f2, 2); f2 = f1--; - cmpFloat1(f2, 3); - cmpFloat1(f1, 2); + cmpVal1(f2, 3); + cmpVal1(f1, 2); f2 = ++f1; - cmpFloat1(f1, 3); - cmpFloat1(f2, 3); + cmpVal1(f1, 3); + cmpVal1(f2, 3); f2 = --f1; - cmpFloat1(f1, 2); - cmpFloat1(f2, 2); + cmpVal1(f1, 2); + cmpVal1(f2, 2); f2 = ~f1; - cmpFloat1(f2, (unsigned short)65533); + cmpVal1(f2, (unsigned short)65533); assert(!f1 == false); f1.x = 3; @@ -925,72 +970,72 @@ bool TestUShort2() { f2.x = 1; f2.y = 1; f3 = f1 + f2; - cmpFloat2(f3, 2); + cmpVal2(f3, 2); f2 = f3 - f1; - cmpFloat2(f2, 1); + cmpVal2(f2, 1); f1 = f2 * f3; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f2 = f1 / f3; - cmpFloat2(f2, 2/2); + cmpVal2(f2, 2/2); f3 = f1 % f2; - cmpFloat2(f3, 0); + cmpVal2(f3, 0); f1 = f3 & f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f2 = f1 ^ f3; - cmpFloat2(f2, 0); + cmpVal2(f2, 0); f1.x = 1; f1.y = 1; f2.x = 2; f2.y = 2; f3 = f1 << f2; - cmpFloat2(f3, 4); + cmpVal2(f3, 4); f2 = f3 >> f1; - cmpFloat2(f2, 2); + cmpVal2(f2, 2); f1.x = 2; f1.y = 2; f2.x = 1; f2.y = 1; f1 += f2; - cmpFloat2(f1, 3); + cmpVal2(f1, 3); f1 -= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 *= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 /= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 %= f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f1 &= f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f1 |= f2; - cmpFloat2(f1, 1); + cmpVal2(f1, 1); f1 ^= f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f1.x = 1; f1.y = 1; f1 <<= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 >>= f2; - cmpFloat2(f1, 1); + cmpVal2(f1, 1); f1.x = 2; f1.y = 2; f2 = f1++; - cmpFloat2(f1, 3); - cmpFloat2(f2, 2); + cmpVal2(f1, 3); + cmpVal2(f2, 2); f2 = f1--; - cmpFloat2(f2, 3); - cmpFloat2(f1, 2); + cmpVal2(f2, 3); + cmpVal2(f1, 2); f2 = ++f1; - cmpFloat2(f1, 3); - cmpFloat2(f2, 3); + cmpVal2(f1, 3); + cmpVal2(f2, 3); f2 = --f1; - cmpFloat2(f1, 2); - cmpFloat2(f2, 2); + cmpVal2(f1, 2); + cmpVal2(f2, 2); f2 = ~f1; - cmpFloat2(f2, (unsigned short)65533); + cmpVal2(f2, (unsigned short)65533); assert(!f1 == false); f1.x = 3; @@ -1020,19 +1065,19 @@ bool TestUShort3() { f2.y = 1; f2.z = 1; f3 = f1 + f2; - cmpFloat3(f3, 2); + cmpVal3(f3, 2); f2 = f3 - f1; - cmpFloat3(f2, 1); + cmpVal3(f2, 1); f1 = f2 * f3; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f2 = f1 / f3; - cmpFloat3(f2, 2/2); + cmpVal3(f2, 2/2); f3 = f1 % f2; - cmpFloat3(f3, 0); + cmpVal3(f3, 0); f1 = f3 & f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f2 = f1 ^ f3; - cmpFloat3(f2, 0); + cmpVal3(f2, 0); f1.x = 1; f1.y = 1; f1.z = 1; @@ -1040,9 +1085,9 @@ bool TestUShort3() { f2.y = 2; f2.z = 2; f3 = f1 << f2; - cmpFloat3(f3, 4); + cmpVal3(f3, 4); f2 = f3 >> f1; - cmpFloat3(f2, 2); + cmpVal3(f2, 2); f1.x = 2; f1.y = 2; @@ -1051,47 +1096,47 @@ bool TestUShort3() { f2.y = 1; f2.z = 1; f1 += f2; - cmpFloat3(f1, 3); + cmpVal3(f1, 3); f1 -= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 *= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 /= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 %= f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f1 &= f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f1 |= f2; - cmpFloat3(f1, 1); + cmpVal3(f1, 1); f1 ^= f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f1.x = 1; f1.y = 1; f1.z = 1; f1 <<= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 >>= f2; - cmpFloat3(f1, 1); + cmpVal3(f1, 1); f1.x = 2; f1.y = 2; f1.z = 2; f2 = f1++; - cmpFloat3(f1, 3); - cmpFloat3(f2, 2); + cmpVal3(f1, 3); + cmpVal3(f2, 2); f2 = f1--; - cmpFloat3(f2, 3); - cmpFloat3(f1, 2); + cmpVal3(f2, 3); + cmpVal3(f1, 2); f2 = ++f1; - cmpFloat3(f1, 3); - cmpFloat3(f2, 3); + cmpVal3(f1, 3); + cmpVal3(f2, 3); f2 = --f1; - cmpFloat3(f1, 2); - cmpFloat3(f2, 2); + cmpVal3(f1, 2); + cmpVal3(f2, 2); f2 = ~f1; - cmpFloat3(f2, (unsigned short)65533); + cmpVal3(f2, (unsigned short)65533); assert(!f1 == false); f1.x = 3; @@ -1126,19 +1171,19 @@ bool TestUShort4() { f2.z = 1; f2.w = 1; f3 = f1 + f2; - cmpFloat4(f3, 2); + cmpVal4(f3, 2); f2 = f3 - f1; - cmpFloat4(f2, 1); + cmpVal4(f2, 1); f1 = f2 * f3; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f2 = f1 / f3; - cmpFloat4(f2, 2/2); + cmpVal4(f2, 2/2); f3 = f1 % f2; - cmpFloat4(f3, 0); + cmpVal4(f3, 0); f1 = f3 & f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f2 = f1 ^ f3; - cmpFloat4(f2, 0); + cmpVal4(f2, 0); f1.x = 1; f1.y = 1; f1.z = 1; @@ -1148,9 +1193,9 @@ bool TestUShort4() { f2.z = 2; f2.w = 2; f3 = f1 << f2; - cmpFloat4(f3, 4); + cmpVal4(f3, 4); f2 = f3 >> f1; - cmpFloat4(f2, 2); + cmpVal4(f2, 2); f1.x = 2; f1.y = 2; @@ -1161,49 +1206,49 @@ bool TestUShort4() { f2.z = 1; f2.w = 1; f1 += f2; - cmpFloat4(f1, 3); + cmpVal4(f1, 3); f1 -= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 *= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 /= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 %= f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f1 &= f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f1 |= f2; - cmpFloat4(f1, 1); + cmpVal4(f1, 1); f1 ^= f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f1.x = 1; f1.y = 1; f1.z = 1; f1.w = 1; f1 <<= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 >>= f2; - cmpFloat4(f1, 1); + cmpVal4(f1, 1); f1.x = 2; f1.y = 2; f1.z = 2; f1.w = 2; f2 = f1++; - cmpFloat4(f1, 3); - cmpFloat4(f2, 2); + cmpVal4(f1, 3); + cmpVal4(f2, 2); f2 = f1--; - cmpFloat4(f2, 3); - cmpFloat4(f1, 2); + cmpVal4(f2, 3); + cmpVal4(f1, 2); f2 = ++f1; - cmpFloat4(f1, 3); - cmpFloat4(f2, 3); + cmpVal4(f1, 3); + cmpVal4(f2, 3); f2 = --f1; - cmpFloat4(f1, 2); - cmpFloat4(f2, 2); + cmpVal4(f1, 2); + cmpVal4(f2, 2); f2 = ~f1; - cmpFloat4(f2, (unsigned short)65533); + cmpVal4(f2, (unsigned short)65533); assert(!f1 == false); f1.x = 3; @@ -1235,66 +1280,66 @@ bool TestShort1() { f1.x = 1; f2.x = 1; f3 = f1 + f2; - cmpFloat1(f3, 2); + cmpVal1(f3, 2); f2 = f3 - f1; - cmpFloat1(f2, 1); + cmpVal1(f2, 1); f1 = f2 * f3; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f2 = f1 / f3; - cmpFloat1(f2, 2/2); + cmpVal1(f2, 2/2); f3 = f1 % f2; - cmpFloat1(f3, 0); + cmpVal1(f3, 0); f1 = f3 & f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f2 = f1 ^ f3; - cmpFloat1(f2, 0); + cmpVal1(f2, 0); f1.x = 1; f2.x = 2; f3 = f1 << f2; - cmpFloat1(f3, 4); + cmpVal1(f3, 4); f2 = f3 >> f1; - cmpFloat1(f2, 2); + cmpVal1(f2, 2); f1.x = 2; f2.x = 1; f1 += f2; - cmpFloat1(f1, 3); + cmpVal1(f1, 3); f1 -= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 *= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 /= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 %= f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f1 &= f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f1 |= f2; - cmpFloat1(f1, 1); + cmpVal1(f1, 1); f1 ^= f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f1.x = 1; f1 <<= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 >>= f2; - cmpFloat1(f1, 1); + cmpVal1(f1, 1); f1.x = 2; f2 = f1++; - cmpFloat1(f1, 3); - cmpFloat1(f2, 2); + cmpVal1(f1, 3); + cmpVal1(f2, 2); f2 = f1--; - cmpFloat1(f2, 3); - cmpFloat1(f1, 2); + cmpVal1(f2, 3); + cmpVal1(f1, 2); f2 = ++f1; - cmpFloat1(f1, 3); - cmpFloat1(f2, 3); + cmpVal1(f1, 3); + cmpVal1(f2, 3); f2 = --f1; - cmpFloat1(f1, 2); - cmpFloat1(f2, 2); + cmpVal1(f1, 2); + cmpVal1(f2, 2); f2 = ~f1; - cmpFloat1(f2, (signed short)65533); + cmpVal1(f2, (signed short)65533); assert(!f1 == false); f1.x = 3; @@ -1319,72 +1364,72 @@ bool TestShort2() { f2.x = 1; f2.y = 1; f3 = f1 + f2; - cmpFloat2(f3, 2); + cmpVal2(f3, 2); f2 = f3 - f1; - cmpFloat2(f2, 1); + cmpVal2(f2, 1); f1 = f2 * f3; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f2 = f1 / f3; - cmpFloat2(f2, 2/2); + cmpVal2(f2, 2/2); f3 = f1 % f2; - cmpFloat2(f3, 0); + cmpVal2(f3, 0); f1 = f3 & f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f2 = f1 ^ f3; - cmpFloat2(f2, 0); + cmpVal2(f2, 0); f1.x = 1; f1.y = 1; f2.x = 2; f2.y = 2; f3 = f1 << f2; - cmpFloat2(f3, 4); + cmpVal2(f3, 4); f2 = f3 >> f1; - cmpFloat2(f2, 2); + cmpVal2(f2, 2); f1.x = 2; f1.y = 2; f2.x = 1; f2.y = 1; f1 += f2; - cmpFloat2(f1, 3); + cmpVal2(f1, 3); f1 -= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 *= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 /= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 %= f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f1 &= f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f1 |= f2; - cmpFloat2(f1, 1); + cmpVal2(f1, 1); f1 ^= f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f1.x = 1; f1.y = 1; f1 <<= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 >>= f2; - cmpFloat2(f1, 1); + cmpVal2(f1, 1); f1.x = 2; f1.y = 2; f2 = f1++; - cmpFloat2(f1, 3); - cmpFloat2(f2, 2); + cmpVal2(f1, 3); + cmpVal2(f2, 2); f2 = f1--; - cmpFloat2(f2, 3); - cmpFloat2(f1, 2); + cmpVal2(f2, 3); + cmpVal2(f1, 2); f2 = ++f1; - cmpFloat2(f1, 3); - cmpFloat2(f2, 3); + cmpVal2(f1, 3); + cmpVal2(f2, 3); f2 = --f1; - cmpFloat2(f1, 2); - cmpFloat2(f2, 2); + cmpVal2(f1, 2); + cmpVal2(f2, 2); f2 = ~f1; - cmpFloat2(f2, (signed short)65533); + cmpVal2(f2, (signed short)65533); assert(!f1 == false); f1.x = 3; @@ -1414,19 +1459,19 @@ bool TestShort3() { f2.y = 1; f2.z = 1; f3 = f1 + f2; - cmpFloat3(f3, 2); + cmpVal3(f3, 2); f2 = f3 - f1; - cmpFloat3(f2, 1); + cmpVal3(f2, 1); f1 = f2 * f3; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f2 = f1 / f3; - cmpFloat3(f2, 2/2); + cmpVal3(f2, 2/2); f3 = f1 % f2; - cmpFloat3(f3, 0); + cmpVal3(f3, 0); f1 = f3 & f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f2 = f1 ^ f3; - cmpFloat3(f2, 0); + cmpVal3(f2, 0); f1.x = 1; f1.y = 1; f1.z = 1; @@ -1434,9 +1479,9 @@ bool TestShort3() { f2.y = 2; f2.z = 2; f3 = f1 << f2; - cmpFloat3(f3, 4); + cmpVal3(f3, 4); f2 = f3 >> f1; - cmpFloat3(f2, 2); + cmpVal3(f2, 2); f1.x = 2; f1.y = 2; @@ -1445,47 +1490,47 @@ bool TestShort3() { f2.y = 1; f2.z = 1; f1 += f2; - cmpFloat3(f1, 3); + cmpVal3(f1, 3); f1 -= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 *= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 /= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 %= f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f1 &= f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f1 |= f2; - cmpFloat3(f1, 1); + cmpVal3(f1, 1); f1 ^= f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f1.x = 1; f1.y = 1; f1.z = 1; f1 <<= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 >>= f2; - cmpFloat3(f1, 1); + cmpVal3(f1, 1); f1.x = 2; f1.y = 2; f1.z = 2; f2 = f1++; - cmpFloat3(f1, 3); - cmpFloat3(f2, 2); + cmpVal3(f1, 3); + cmpVal3(f2, 2); f2 = f1--; - cmpFloat3(f2, 3); - cmpFloat3(f1, 2); + cmpVal3(f2, 3); + cmpVal3(f1, 2); f2 = ++f1; - cmpFloat3(f1, 3); - cmpFloat3(f2, 3); + cmpVal3(f1, 3); + cmpVal3(f2, 3); f2 = --f1; - cmpFloat3(f1, 2); - cmpFloat3(f2, 2); + cmpVal3(f1, 2); + cmpVal3(f2, 2); f2 = ~f1; - cmpFloat3(f2, (signed short)65533); + cmpVal3(f2, (signed short)65533); assert(!f1 == false); f1.x = 3; @@ -1520,19 +1565,19 @@ bool TestShort4() { f2.z = 1; f2.w = 1; f3 = f1 + f2; - cmpFloat4(f3, 2); + cmpVal4(f3, 2); f2 = f3 - f1; - cmpFloat4(f2, 1); + cmpVal4(f2, 1); f1 = f2 * f3; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f2 = f1 / f3; - cmpFloat4(f2, 2/2); + cmpVal4(f2, 2/2); f3 = f1 % f2; - cmpFloat4(f3, 0); + cmpVal4(f3, 0); f1 = f3 & f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f2 = f1 ^ f3; - cmpFloat4(f2, 0); + cmpVal4(f2, 0); f1.x = 1; f1.y = 1; f1.z = 1; @@ -1542,9 +1587,9 @@ bool TestShort4() { f2.z = 2; f2.w = 2; f3 = f1 << f2; - cmpFloat4(f3, 4); + cmpVal4(f3, 4); f2 = f3 >> f1; - cmpFloat4(f2, 2); + cmpVal4(f2, 2); f1.x = 2; f1.y = 2; @@ -1555,49 +1600,49 @@ bool TestShort4() { f2.z = 1; f2.w = 1; f1 += f2; - cmpFloat4(f1, 3); + cmpVal4(f1, 3); f1 -= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 *= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 /= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 %= f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f1 &= f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f1 |= f2; - cmpFloat4(f1, 1); + cmpVal4(f1, 1); f1 ^= f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f1.x = 1; f1.y = 1; f1.z = 1; f1.w = 1; f1 <<= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 >>= f2; - cmpFloat4(f1, 1); + cmpVal4(f1, 1); f1.x = 2; f1.y = 2; f1.z = 2; f1.w = 2; f2 = f1++; - cmpFloat4(f1, 3); - cmpFloat4(f2, 2); + cmpVal4(f1, 3); + cmpVal4(f2, 2); f2 = f1--; - cmpFloat4(f2, 3); - cmpFloat4(f1, 2); + cmpVal4(f2, 3); + cmpVal4(f1, 2); f2 = ++f1; - cmpFloat4(f1, 3); - cmpFloat4(f2, 3); + cmpVal4(f1, 3); + cmpVal4(f2, 3); f2 = --f1; - cmpFloat4(f1, 2); - cmpFloat4(f2, 2); + cmpVal4(f1, 2); + cmpVal4(f2, 2); f2 = ~f1; - cmpFloat4(f2, (signed short)65533); + cmpVal4(f2, (signed short)65533); assert(!f1 == false); f1.x = 3; @@ -1630,66 +1675,66 @@ bool TestUInt1() { f1.x = 1; f2.x = 1; f3 = f1 + f2; - cmpFloat1(f3, 2); + cmpVal1(f3, 2); f2 = f3 - f1; - cmpFloat1(f2, 1); + cmpVal1(f2, 1); f1 = f2 * f3; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f2 = f1 / f3; - cmpFloat1(f2, 2/2); + cmpVal1(f2, 2/2); f3 = f1 % f2; - cmpFloat1(f3, 0); + cmpVal1(f3, 0); f1 = f3 & f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f2 = f1 ^ f3; - cmpFloat1(f2, 0); + cmpVal1(f2, 0); f1.x = 1; f2.x = 2; f3 = f1 << f2; - cmpFloat1(f3, 4); + cmpVal1(f3, 4); f2 = f3 >> f1; - cmpFloat1(f2, 2); + cmpVal1(f2, 2); f1.x = 2; f2.x = 1; f1 += f2; - cmpFloat1(f1, 3); + cmpVal1(f1, 3); f1 -= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 *= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 /= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 %= f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f1 &= f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f1 |= f2; - cmpFloat1(f1, 1); + cmpVal1(f1, 1); f1 ^= f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f1.x = 1; f1 <<= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 >>= f2; - cmpFloat1(f1, 1); + cmpVal1(f1, 1); f1.x = 2; f2 = f1++; - cmpFloat1(f1, 3); - cmpFloat1(f2, 2); + cmpVal1(f1, 3); + cmpVal1(f2, 2); f2 = f1--; - cmpFloat1(f2, 3); - cmpFloat1(f1, 2); + cmpVal1(f2, 3); + cmpVal1(f1, 2); f2 = ++f1; - cmpFloat1(f1, 3); - cmpFloat1(f2, 3); + cmpVal1(f1, 3); + cmpVal1(f2, 3); f2 = --f1; - cmpFloat1(f1, 2); - cmpFloat1(f2, 2); + cmpVal1(f1, 2); + cmpVal1(f2, 2); f2 = ~f1; - cmpFloat1(f2, (unsigned int)4294967293); + cmpVal1(f2, (unsigned int)4294967293); assert(!f1 == false); f1.x = 3; @@ -1714,72 +1759,72 @@ bool TestUInt2() { f2.x = 1; f2.y = 1; f3 = f1 + f2; - cmpFloat2(f3, 2); + cmpVal2(f3, 2); f2 = f3 - f1; - cmpFloat2(f2, 1); + cmpVal2(f2, 1); f1 = f2 * f3; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f2 = f1 / f3; - cmpFloat2(f2, 2/2); + cmpVal2(f2, 2/2); f3 = f1 % f2; - cmpFloat2(f3, 0); + cmpVal2(f3, 0); f1 = f3 & f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f2 = f1 ^ f3; - cmpFloat2(f2, 0); + cmpVal2(f2, 0); f1.x = 1; f1.y = 1; f2.x = 2; f2.y = 2; f3 = f1 << f2; - cmpFloat2(f3, 4); + cmpVal2(f3, 4); f2 = f3 >> f1; - cmpFloat2(f2, 2); + cmpVal2(f2, 2); f1.x = 2; f1.y = 2; f2.x = 1; f2.y = 1; f1 += f2; - cmpFloat2(f1, 3); + cmpVal2(f1, 3); f1 -= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 *= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 /= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 %= f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f1 &= f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f1 |= f2; - cmpFloat2(f1, 1); + cmpVal2(f1, 1); f1 ^= f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f1.x = 1; f1.y = 1; f1 <<= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 >>= f2; - cmpFloat2(f1, 1); + cmpVal2(f1, 1); f1.x = 2; f1.y = 2; f2 = f1++; - cmpFloat2(f1, 3); - cmpFloat2(f2, 2); + cmpVal2(f1, 3); + cmpVal2(f2, 2); f2 = f1--; - cmpFloat2(f2, 3); - cmpFloat2(f1, 2); + cmpVal2(f2, 3); + cmpVal2(f1, 2); f2 = ++f1; - cmpFloat2(f1, 3); - cmpFloat2(f2, 3); + cmpVal2(f1, 3); + cmpVal2(f2, 3); f2 = --f1; - cmpFloat2(f1, 2); - cmpFloat2(f2, 2); + cmpVal2(f1, 2); + cmpVal2(f2, 2); f2 = ~f1; - cmpFloat2(f2, (unsigned int)4294967293); + cmpVal2(f2, (unsigned int)4294967293); assert(!f1 == false); f1.x = 3; @@ -1809,19 +1854,19 @@ bool TestUInt3() { f2.y = 1; f2.z = 1; f3 = f1 + f2; - cmpFloat3(f3, 2); + cmpVal3(f3, 2); f2 = f3 - f1; - cmpFloat3(f2, 1); + cmpVal3(f2, 1); f1 = f2 * f3; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f2 = f1 / f3; - cmpFloat3(f2, 2/2); + cmpVal3(f2, 2/2); f3 = f1 % f2; - cmpFloat3(f3, 0); + cmpVal3(f3, 0); f1 = f3 & f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f2 = f1 ^ f3; - cmpFloat3(f2, 0); + cmpVal3(f2, 0); f1.x = 1; f1.y = 1; f1.z = 1; @@ -1829,9 +1874,9 @@ bool TestUInt3() { f2.y = 2; f2.z = 2; f3 = f1 << f2; - cmpFloat3(f3, 4); + cmpVal3(f3, 4); f2 = f3 >> f1; - cmpFloat3(f2, 2); + cmpVal3(f2, 2); f1.x = 2; f1.y = 2; @@ -1840,47 +1885,47 @@ bool TestUInt3() { f2.y = 1; f2.z = 1; f1 += f2; - cmpFloat3(f1, 3); + cmpVal3(f1, 3); f1 -= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 *= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 /= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 %= f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f1 &= f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f1 |= f2; - cmpFloat3(f1, 1); + cmpVal3(f1, 1); f1 ^= f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f1.x = 1; f1.y = 1; f1.z = 1; f1 <<= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 >>= f2; - cmpFloat3(f1, 1); + cmpVal3(f1, 1); f1.x = 2; f1.y = 2; f1.z = 2; f2 = f1++; - cmpFloat3(f1, 3); - cmpFloat3(f2, 2); + cmpVal3(f1, 3); + cmpVal3(f2, 2); f2 = f1--; - cmpFloat3(f2, 3); - cmpFloat3(f1, 2); + cmpVal3(f2, 3); + cmpVal3(f1, 2); f2 = ++f1; - cmpFloat3(f1, 3); - cmpFloat3(f2, 3); + cmpVal3(f1, 3); + cmpVal3(f2, 3); f2 = --f1; - cmpFloat3(f1, 2); - cmpFloat3(f2, 2); + cmpVal3(f1, 2); + cmpVal3(f2, 2); f2 = ~f1; - cmpFloat3(f2, (unsigned int)4294967293); + cmpVal3(f2, (unsigned int)4294967293); assert(!f1 == false); f1.x = 3; @@ -1915,19 +1960,19 @@ bool TestUInt4() { f2.z = 1; f2.w = 1; f3 = f1 + f2; - cmpFloat4(f3, 2); + cmpVal4(f3, 2); f2 = f3 - f1; - cmpFloat4(f2, 1); + cmpVal4(f2, 1); f1 = f2 * f3; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f2 = f1 / f3; - cmpFloat4(f2, 2/2); + cmpVal4(f2, 2/2); f3 = f1 % f2; - cmpFloat4(f3, 0); + cmpVal4(f3, 0); f1 = f3 & f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f2 = f1 ^ f3; - cmpFloat4(f2, 0); + cmpVal4(f2, 0); f1.x = 1; f1.y = 1; f1.z = 1; @@ -1937,9 +1982,9 @@ bool TestUInt4() { f2.z = 2; f2.w = 2; f3 = f1 << f2; - cmpFloat4(f3, 4); + cmpVal4(f3, 4); f2 = f3 >> f1; - cmpFloat4(f2, 2); + cmpVal4(f2, 2); f1.x = 2; f1.y = 2; @@ -1950,49 +1995,49 @@ bool TestUInt4() { f2.z = 1; f2.w = 1; f1 += f2; - cmpFloat4(f1, 3); + cmpVal4(f1, 3); f1 -= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 *= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 /= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 %= f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f1 &= f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f1 |= f2; - cmpFloat4(f1, 1); + cmpVal4(f1, 1); f1 ^= f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f1.x = 1; f1.y = 1; f1.z = 1; f1.w = 1; f1 <<= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 >>= f2; - cmpFloat4(f1, 1); + cmpVal4(f1, 1); f1.x = 2; f1.y = 2; f1.z = 2; f1.w = 2; f2 = f1++; - cmpFloat4(f1, 3); - cmpFloat4(f2, 2); + cmpVal4(f1, 3); + cmpVal4(f2, 2); f2 = f1--; - cmpFloat4(f2, 3); - cmpFloat4(f1, 2); + cmpVal4(f2, 3); + cmpVal4(f1, 2); f2 = ++f1; - cmpFloat4(f1, 3); - cmpFloat4(f2, 3); + cmpVal4(f1, 3); + cmpVal4(f2, 3); f2 = --f1; - cmpFloat4(f1, 2); - cmpFloat4(f2, 2); + cmpVal4(f1, 2); + cmpVal4(f2, 2); f2 = ~f1; - cmpFloat4(f2, (unsigned int)4294967293); + cmpVal4(f2, (unsigned int)4294967293); assert(!f1 == false); f1.x = 3; @@ -2024,66 +2069,66 @@ bool TestInt1() { f1.x = 1; f2.x = 1; f3 = f1 + f2; - cmpFloat1(f3, 2); + cmpVal1(f3, 2); f2 = f3 - f1; - cmpFloat1(f2, 1); + cmpVal1(f2, 1); f1 = f2 * f3; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f2 = f1 / f3; - cmpFloat1(f2, 2/2); + cmpVal1(f2, 2/2); f3 = f1 % f2; - cmpFloat1(f3, 0); + cmpVal1(f3, 0); f1 = f3 & f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f2 = f1 ^ f3; - cmpFloat1(f2, 0); + cmpVal1(f2, 0); f1.x = 1; f2.x = 2; f3 = f1 << f2; - cmpFloat1(f3, 4); + cmpVal1(f3, 4); f2 = f3 >> f1; - cmpFloat1(f2, 2); + cmpVal1(f2, 2); f1.x = 2; f2.x = 1; f1 += f2; - cmpFloat1(f1, 3); + cmpVal1(f1, 3); f1 -= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 *= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 /= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 %= f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f1 &= f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f1 |= f2; - cmpFloat1(f1, 1); + cmpVal1(f1, 1); f1 ^= f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f1.x = 1; f1 <<= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 >>= f2; - cmpFloat1(f1, 1); + cmpVal1(f1, 1); f1.x = 2; f2 = f1++; - cmpFloat1(f1, 3); - cmpFloat1(f2, 2); + cmpVal1(f1, 3); + cmpVal1(f2, 2); f2 = f1--; - cmpFloat1(f2, 3); - cmpFloat1(f1, 2); + cmpVal1(f2, 3); + cmpVal1(f1, 2); f2 = ++f1; - cmpFloat1(f1, 3); - cmpFloat1(f2, 3); + cmpVal1(f1, 3); + cmpVal1(f2, 3); f2 = --f1; - cmpFloat1(f1, 2); - cmpFloat1(f2, 2); + cmpVal1(f1, 2); + cmpVal1(f2, 2); f2 = ~f1; - cmpFloat1(f2, (signed int)4294967293); + cmpVal1(f2, (signed int)4294967293); assert(!f1 == false); f1.x = 3; @@ -2108,72 +2153,72 @@ bool TestInt2() { f2.x = 1; f2.y = 1; f3 = f1 + f2; - cmpFloat2(f3, 2); + cmpVal2(f3, 2); f2 = f3 - f1; - cmpFloat2(f2, 1); + cmpVal2(f2, 1); f1 = f2 * f3; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f2 = f1 / f3; - cmpFloat2(f2, 2/2); + cmpVal2(f2, 2/2); f3 = f1 % f2; - cmpFloat2(f3, 0); + cmpVal2(f3, 0); f1 = f3 & f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f2 = f1 ^ f3; - cmpFloat2(f2, 0); + cmpVal2(f2, 0); f1.x = 1; f1.y = 1; f2.x = 2; f2.y = 2; f3 = f1 << f2; - cmpFloat2(f3, 4); + cmpVal2(f3, 4); f2 = f3 >> f1; - cmpFloat2(f2, 2); + cmpVal2(f2, 2); f1.x = 2; f1.y = 2; f2.x = 1; f2.y = 1; f1 += f2; - cmpFloat2(f1, 3); + cmpVal2(f1, 3); f1 -= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 *= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 /= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 %= f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f1 &= f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f1 |= f2; - cmpFloat2(f1, 1); + cmpVal2(f1, 1); f1 ^= f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f1.x = 1; f1.y = 1; f1 <<= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 >>= f2; - cmpFloat2(f1, 1); + cmpVal2(f1, 1); f1.x = 2; f1.y = 2; f2 = f1++; - cmpFloat2(f1, 3); - cmpFloat2(f2, 2); + cmpVal2(f1, 3); + cmpVal2(f2, 2); f2 = f1--; - cmpFloat2(f2, 3); - cmpFloat2(f1, 2); + cmpVal2(f2, 3); + cmpVal2(f1, 2); f2 = ++f1; - cmpFloat2(f1, 3); - cmpFloat2(f2, 3); + cmpVal2(f1, 3); + cmpVal2(f2, 3); f2 = --f1; - cmpFloat2(f1, 2); - cmpFloat2(f2, 2); + cmpVal2(f1, 2); + cmpVal2(f2, 2); f2 = ~f1; - cmpFloat2(f2, (signed int)4294967293); + cmpVal2(f2, (signed int)4294967293); assert(!f1 == false); f1.x = 3; @@ -2203,19 +2248,19 @@ bool TestInt3() { f2.y = 1; f2.z = 1; f3 = f1 + f2; - cmpFloat3(f3, 2); + cmpVal3(f3, 2); f2 = f3 - f1; - cmpFloat3(f2, 1); + cmpVal3(f2, 1); f1 = f2 * f3; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f2 = f1 / f3; - cmpFloat3(f2, 2/2); + cmpVal3(f2, 2/2); f3 = f1 % f2; - cmpFloat3(f3, 0); + cmpVal3(f3, 0); f1 = f3 & f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f2 = f1 ^ f3; - cmpFloat3(f2, 0); + cmpVal3(f2, 0); f1.x = 1; f1.y = 1; f1.z = 1; @@ -2223,9 +2268,9 @@ bool TestInt3() { f2.y = 2; f2.z = 2; f3 = f1 << f2; - cmpFloat3(f3, 4); + cmpVal3(f3, 4); f2 = f3 >> f1; - cmpFloat3(f2, 2); + cmpVal3(f2, 2); f1.x = 2; f1.y = 2; @@ -2234,47 +2279,47 @@ bool TestInt3() { f2.y = 1; f2.z = 1; f1 += f2; - cmpFloat3(f1, 3); + cmpVal3(f1, 3); f1 -= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 *= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 /= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 %= f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f1 &= f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f1 |= f2; - cmpFloat3(f1, 1); + cmpVal3(f1, 1); f1 ^= f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f1.x = 1; f1.y = 1; f1.z = 1; f1 <<= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 >>= f2; - cmpFloat3(f1, 1); + cmpVal3(f1, 1); f1.x = 2; f1.y = 2; f1.z = 2; f2 = f1++; - cmpFloat3(f1, 3); - cmpFloat3(f2, 2); + cmpVal3(f1, 3); + cmpVal3(f2, 2); f2 = f1--; - cmpFloat3(f2, 3); - cmpFloat3(f1, 2); + cmpVal3(f2, 3); + cmpVal3(f1, 2); f2 = ++f1; - cmpFloat3(f1, 3); - cmpFloat3(f2, 3); + cmpVal3(f1, 3); + cmpVal3(f2, 3); f2 = --f1; - cmpFloat3(f1, 2); - cmpFloat3(f2, 2); + cmpVal3(f1, 2); + cmpVal3(f2, 2); f2 = ~f1; - cmpFloat3(f2, (signed int)4294967293); + cmpVal3(f2, (signed int)4294967293); assert(!f1 == false); f1.x = 3; @@ -2309,19 +2354,19 @@ bool TestInt4() { f2.z = 1; f2.w = 1; f3 = f1 + f2; - cmpFloat4(f3, 2); + cmpVal4(f3, 2); f2 = f3 - f1; - cmpFloat4(f2, 1); + cmpVal4(f2, 1); f1 = f2 * f3; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f2 = f1 / f3; - cmpFloat4(f2, 2/2); + cmpVal4(f2, 2/2); f3 = f1 % f2; - cmpFloat4(f3, 0); + cmpVal4(f3, 0); f1 = f3 & f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f2 = f1 ^ f3; - cmpFloat4(f2, 0); + cmpVal4(f2, 0); f1.x = 1; f1.y = 1; f1.z = 1; @@ -2331,9 +2376,9 @@ bool TestInt4() { f2.z = 2; f2.w = 2; f3 = f1 << f2; - cmpFloat4(f3, 4); + cmpVal4(f3, 4); f2 = f3 >> f1; - cmpFloat4(f2, 2); + cmpVal4(f2, 2); f1.x = 2; f1.y = 2; @@ -2344,49 +2389,49 @@ bool TestInt4() { f2.z = 1; f2.w = 1; f1 += f2; - cmpFloat4(f1, 3); + cmpVal4(f1, 3); f1 -= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 *= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 /= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 %= f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f1 &= f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f1 |= f2; - cmpFloat4(f1, 1); + cmpVal4(f1, 1); f1 ^= f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f1.x = 1; f1.y = 1; f1.z = 1; f1.w = 1; f1 <<= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 >>= f2; - cmpFloat4(f1, 1); + cmpVal4(f1, 1); f1.x = 2; f1.y = 2; f1.z = 2; f1.w = 2; f2 = f1++; - cmpFloat4(f1, 3); - cmpFloat4(f2, 2); + cmpVal4(f1, 3); + cmpVal4(f2, 2); f2 = f1--; - cmpFloat4(f2, 3); - cmpFloat4(f1, 2); + cmpVal4(f2, 3); + cmpVal4(f1, 2); f2 = ++f1; - cmpFloat4(f1, 3); - cmpFloat4(f2, 3); + cmpVal4(f1, 3); + cmpVal4(f2, 3); f2 = --f1; - cmpFloat4(f1, 2); - cmpFloat4(f2, 2); + cmpVal4(f1, 2); + cmpVal4(f2, 2); f2 = ~f1; - cmpFloat4(f2, (signed int)4294967293); + cmpVal4(f2, (signed int)4294967293); assert(!f1 == false); f1.x = 3; @@ -2418,66 +2463,66 @@ bool TestULong1() { f1.x = 1; f2.x = 1; f3 = f1 + f2; - cmpFloat1(f3, 2); + cmpVal1(f3, 2); f2 = f3 - f1; - cmpFloat1(f2, 1); + cmpVal1(f2, 1); f1 = f2 * f3; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f2 = f1 / f3; - cmpFloat1(f2, 2/2); + cmpVal1(f2, 2/2); f3 = f1 % f2; - cmpFloat1(f3, 0); + cmpVal1(f3, 0); f1 = f3 & f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f2 = f1 ^ f3; - cmpFloat1(f2, 0); + cmpVal1(f2, 0); f1.x = 1; f2.x = 2; f3 = f1 << f2; - cmpFloat1(f3, 4); + cmpVal1(f3, 4); f2 = f3 >> f1; - cmpFloat1(f2, 2); + cmpVal1(f2, 2); f1.x = 2; f2.x = 1; f1 += f2; - cmpFloat1(f1, 3); + cmpVal1(f1, 3); f1 -= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 *= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 /= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 %= f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f1 &= f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f1 |= f2; - cmpFloat1(f1, 1); + cmpVal1(f1, 1); f1 ^= f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f1.x = 1; f1 <<= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 >>= f2; - cmpFloat1(f1, 1); + cmpVal1(f1, 1); f1.x = 2; f2 = f1++; - cmpFloat1(f1, 3); - cmpFloat1(f2, 2); + cmpVal1(f1, 3); + cmpVal1(f2, 2); f2 = f1--; - cmpFloat1(f2, 3); - cmpFloat1(f1, 2); + cmpVal1(f2, 3); + cmpVal1(f1, 2); f2 = ++f1; - cmpFloat1(f1, 3); - cmpFloat1(f2, 3); + cmpVal1(f1, 3); + cmpVal1(f2, 3); f2 = --f1; - cmpFloat1(f1, 2); - cmpFloat1(f2, 2); + cmpVal1(f1, 2); + cmpVal1(f2, 2); f2 = ~f1; - cmpFloat1(f2, 18446744073709551613UL); + cmpVal1(f2, 18446744073709551613UL); assert(!f1 == false); f1.x = 3; @@ -2502,72 +2547,72 @@ bool TestULong2() { f2.x = 1; f2.y = 1; f3 = f1 + f2; - cmpFloat2(f3, 2); + cmpVal2(f3, 2); f2 = f3 - f1; - cmpFloat2(f2, 1); + cmpVal2(f2, 1); f1 = f2 * f3; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f2 = f1 / f3; - cmpFloat2(f2, 2/2); + cmpVal2(f2, 2/2); f3 = f1 % f2; - cmpFloat2(f3, 0); + cmpVal2(f3, 0); f1 = f3 & f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f2 = f1 ^ f3; - cmpFloat2(f2, 0); + cmpVal2(f2, 0); f1.x = 1; f1.y = 1; f2.x = 2; f2.y = 2; f3 = f1 << f2; - cmpFloat2(f3, 4); + cmpVal2(f3, 4); f2 = f3 >> f1; - cmpFloat2(f2, 2); + cmpVal2(f2, 2); f1.x = 2; f1.y = 2; f2.x = 1; f2.y = 1; f1 += f2; - cmpFloat2(f1, 3); + cmpVal2(f1, 3); f1 -= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 *= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 /= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 %= f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f1 &= f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f1 |= f2; - cmpFloat2(f1, 1); + cmpVal2(f1, 1); f1 ^= f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f1.x = 1; f1.y = 1; f1 <<= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 >>= f2; - cmpFloat2(f1, 1); + cmpVal2(f1, 1); f1.x = 2; f1.y = 2; f2 = f1++; - cmpFloat2(f1, 3); - cmpFloat2(f2, 2); + cmpVal2(f1, 3); + cmpVal2(f2, 2); f2 = f1--; - cmpFloat2(f2, 3); - cmpFloat2(f1, 2); + cmpVal2(f2, 3); + cmpVal2(f1, 2); f2 = ++f1; - cmpFloat2(f1, 3); - cmpFloat2(f2, 3); + cmpVal2(f1, 3); + cmpVal2(f2, 3); f2 = --f1; - cmpFloat2(f1, 2); - cmpFloat2(f2, 2); + cmpVal2(f1, 2); + cmpVal2(f2, 2); f2 = ~f1; - cmpFloat2(f2, 18446744073709551613UL); + cmpVal2(f2, 18446744073709551613UL); assert(!f1 == false); f1.x = 3; @@ -2597,19 +2642,19 @@ bool TestULong3() { f2.y = 1; f2.z = 1; f3 = f1 + f2; - cmpFloat3(f3, 2); + cmpVal3(f3, 2); f2 = f3 - f1; - cmpFloat3(f2, 1); + cmpVal3(f2, 1); f1 = f2 * f3; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f2 = f1 / f3; - cmpFloat3(f2, 2/2); + cmpVal3(f2, 2/2); f3 = f1 % f2; - cmpFloat3(f3, 0); + cmpVal3(f3, 0); f1 = f3 & f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f2 = f1 ^ f3; - cmpFloat3(f2, 0); + cmpVal3(f2, 0); f1.x = 1; f1.y = 1; f1.z = 1; @@ -2617,9 +2662,9 @@ bool TestULong3() { f2.y = 2; f2.z = 2; f3 = f1 << f2; - cmpFloat3(f3, 4); + cmpVal3(f3, 4); f2 = f3 >> f1; - cmpFloat3(f2, 2); + cmpVal3(f2, 2); f1.x = 2; f1.y = 2; @@ -2628,47 +2673,47 @@ bool TestULong3() { f2.y = 1; f2.z = 1; f1 += f2; - cmpFloat3(f1, 3); + cmpVal3(f1, 3); f1 -= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 *= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 /= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 %= f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f1 &= f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f1 |= f2; - cmpFloat3(f1, 1); + cmpVal3(f1, 1); f1 ^= f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f1.x = 1; f1.y = 1; f1.z = 1; f1 <<= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 >>= f2; - cmpFloat3(f1, 1); + cmpVal3(f1, 1); f1.x = 2; f1.y = 2; f1.z = 2; f2 = f1++; - cmpFloat3(f1, 3); - cmpFloat3(f2, 2); + cmpVal3(f1, 3); + cmpVal3(f2, 2); f2 = f1--; - cmpFloat3(f2, 3); - cmpFloat3(f1, 2); + cmpVal3(f2, 3); + cmpVal3(f1, 2); f2 = ++f1; - cmpFloat3(f1, 3); - cmpFloat3(f2, 3); + cmpVal3(f1, 3); + cmpVal3(f2, 3); f2 = --f1; - cmpFloat3(f1, 2); - cmpFloat3(f2, 2); + cmpVal3(f1, 2); + cmpVal3(f2, 2); f2 = ~f1; - cmpFloat3(f2, 18446744073709551613UL); + cmpVal3(f2, 18446744073709551613UL); assert(!f1 == false); f1.x = 3; @@ -2703,19 +2748,19 @@ bool TestULong4() { f2.z = 1; f2.w = 1; f3 = f1 + f2; - cmpFloat4(f3, 2); + cmpVal4(f3, 2); f2 = f3 - f1; - cmpFloat4(f2, 1); + cmpVal4(f2, 1); f1 = f2 * f3; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f2 = f1 / f3; - cmpFloat4(f2, 2/2); + cmpVal4(f2, 2/2); f3 = f1 % f2; - cmpFloat4(f3, 0); + cmpVal4(f3, 0); f1 = f3 & f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f2 = f1 ^ f3; - cmpFloat4(f2, 0); + cmpVal4(f2, 0); f1.x = 1; f1.y = 1; f1.z = 1; @@ -2725,9 +2770,9 @@ bool TestULong4() { f2.z = 2; f2.w = 2; f3 = f1 << f2; - cmpFloat4(f3, 4); + cmpVal4(f3, 4); f2 = f3 >> f1; - cmpFloat4(f2, 2); + cmpVal4(f2, 2); f1.x = 2; f1.y = 2; @@ -2738,49 +2783,49 @@ bool TestULong4() { f2.z = 1; f2.w = 1; f1 += f2; - cmpFloat4(f1, 3); + cmpVal4(f1, 3); f1 -= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 *= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 /= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 %= f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f1 &= f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f1 |= f2; - cmpFloat4(f1, 1); + cmpVal4(f1, 1); f1 ^= f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f1.x = 1; f1.y = 1; f1.z = 1; f1.w = 1; f1 <<= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 >>= f2; - cmpFloat4(f1, 1); + cmpVal4(f1, 1); f1.x = 2; f1.y = 2; f1.z = 2; f1.w = 2; f2 = f1++; - cmpFloat4(f1, 3); - cmpFloat4(f2, 2); + cmpVal4(f1, 3); + cmpVal4(f2, 2); f2 = f1--; - cmpFloat4(f2, 3); - cmpFloat4(f1, 2); + cmpVal4(f2, 3); + cmpVal4(f1, 2); f2 = ++f1; - cmpFloat4(f1, 3); - cmpFloat4(f2, 3); + cmpVal4(f1, 3); + cmpVal4(f2, 3); f2 = --f1; - cmpFloat4(f1, 2); - cmpFloat4(f2, 2); + cmpVal4(f1, 2); + cmpVal4(f2, 2); f2 = ~f1; - cmpFloat4(f2, 18446744073709551613UL); + cmpVal4(f2, 18446744073709551613UL); assert(!f1 == false); f1.x = 3; @@ -2812,66 +2857,66 @@ bool TestLong1() { f1.x = 1; f2.x = 1; f3 = f1 + f2; - cmpFloat1(f3, 2); + cmpVal1(f3, 2); f2 = f3 - f1; - cmpFloat1(f2, 1); + cmpVal1(f2, 1); f1 = f2 * f3; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f2 = f1 / f3; - cmpFloat1(f2, 2/2); + cmpVal1(f2, 2/2); f3 = f1 % f2; - cmpFloat1(f3, 0); + cmpVal1(f3, 0); f1 = f3 & f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f2 = f1 ^ f3; - cmpFloat1(f2, 0); + cmpVal1(f2, 0); f1.x = 1; f2.x = 2; f3 = f1 << f2; - cmpFloat1(f3, 4); + cmpVal1(f3, 4); f2 = f3 >> f1; - cmpFloat1(f2, 2); + cmpVal1(f2, 2); f1.x = 2; f2.x = 1; f1 += f2; - cmpFloat1(f1, 3); + cmpVal1(f1, 3); f1 -= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 *= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 /= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 %= f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f1 &= f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f1 |= f2; - cmpFloat1(f1, 1); + cmpVal1(f1, 1); f1 ^= f2; - cmpFloat1(f1, 0); + cmpVal1(f1, 0); f1.x = 1; f1 <<= f2; - cmpFloat1(f1, 2); + cmpVal1(f1, 2); f1 >>= f2; - cmpFloat1(f1, 1); + cmpVal1(f1, 1); f1.x = 2; f2 = f1++; - cmpFloat1(f1, 3); - cmpFloat1(f2, 2); + cmpVal1(f1, 3); + cmpVal1(f2, 2); f2 = f1--; - cmpFloat1(f2, 3); - cmpFloat1(f1, 2); + cmpVal1(f2, 3); + cmpVal1(f1, 2); f2 = ++f1; - cmpFloat1(f1, 3); - cmpFloat1(f2, 3); + cmpVal1(f1, 3); + cmpVal1(f2, 3); f2 = --f1; - cmpFloat1(f1, 2); - cmpFloat1(f2, 2); + cmpVal1(f1, 2); + cmpVal1(f2, 2); f2 = ~f1; - cmpFloat1(f2, -3); + cmpVal1(f2, -3); assert(!f1 == false); f1.x = 3; @@ -2896,72 +2941,72 @@ bool TestLong2() { f2.x = 1; f2.y = 1; f3 = f1 + f2; - cmpFloat2(f3, 2); + cmpVal2(f3, 2); f2 = f3 - f1; - cmpFloat2(f2, 1); + cmpVal2(f2, 1); f1 = f2 * f3; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f2 = f1 / f3; - cmpFloat2(f2, 2/2); + cmpVal2(f2, 2/2); f3 = f1 % f2; - cmpFloat2(f3, 0); + cmpVal2(f3, 0); f1 = f3 & f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f2 = f1 ^ f3; - cmpFloat2(f2, 0); + cmpVal2(f2, 0); f1.x = 1; f1.y = 1; f2.x = 2; f2.y = 2; f3 = f1 << f2; - cmpFloat2(f3, 4); + cmpVal2(f3, 4); f2 = f3 >> f1; - cmpFloat2(f2, 2); + cmpVal2(f2, 2); f1.x = 2; f1.y = 2; f2.x = 1; f2.y = 1; f1 += f2; - cmpFloat2(f1, 3); + cmpVal2(f1, 3); f1 -= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 *= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 /= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 %= f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f1 &= f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f1 |= f2; - cmpFloat2(f1, 1); + cmpVal2(f1, 1); f1 ^= f2; - cmpFloat2(f1, 0); + cmpVal2(f1, 0); f1.x = 1; f1.y = 1; f1 <<= f2; - cmpFloat2(f1, 2); + cmpVal2(f1, 2); f1 >>= f2; - cmpFloat2(f1, 1); + cmpVal2(f1, 1); f1.x = 2; f1.y = 2; f2 = f1++; - cmpFloat2(f1, 3); - cmpFloat2(f2, 2); + cmpVal2(f1, 3); + cmpVal2(f2, 2); f2 = f1--; - cmpFloat2(f2, 3); - cmpFloat2(f1, 2); + cmpVal2(f2, 3); + cmpVal2(f1, 2); f2 = ++f1; - cmpFloat2(f1, 3); - cmpFloat2(f2, 3); + cmpVal2(f1, 3); + cmpVal2(f2, 3); f2 = --f1; - cmpFloat2(f1, 2); - cmpFloat2(f2, 2); + cmpVal2(f1, 2); + cmpVal2(f2, 2); f2 = ~f1; - cmpFloat2(f2, -3); + cmpVal2(f2, -3); assert(!f1 == false); f1.x = 3; @@ -2991,19 +3036,19 @@ bool TestLong3() { f2.y = 1; f2.z = 1; f3 = f1 + f2; - cmpFloat3(f3, 2); + cmpVal3(f3, 2); f2 = f3 - f1; - cmpFloat3(f2, 1); + cmpVal3(f2, 1); f1 = f2 * f3; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f2 = f1 / f3; - cmpFloat3(f2, 2/2); + cmpVal3(f2, 2/2); f3 = f1 % f2; - cmpFloat3(f3, 0); + cmpVal3(f3, 0); f1 = f3 & f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f2 = f1 ^ f3; - cmpFloat3(f2, 0); + cmpVal3(f2, 0); f1.x = 1; f1.y = 1; f1.z = 1; @@ -3011,9 +3056,9 @@ bool TestLong3() { f2.y = 2; f2.z = 2; f3 = f1 << f2; - cmpFloat3(f3, 4); + cmpVal3(f3, 4); f2 = f3 >> f1; - cmpFloat3(f2, 2); + cmpVal3(f2, 2); f1.x = 2; f1.y = 2; @@ -3022,47 +3067,47 @@ bool TestLong3() { f2.y = 1; f2.z = 1; f1 += f2; - cmpFloat3(f1, 3); + cmpVal3(f1, 3); f1 -= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 *= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 /= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 %= f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f1 &= f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f1 |= f2; - cmpFloat3(f1, 1); + cmpVal3(f1, 1); f1 ^= f2; - cmpFloat3(f1, 0); + cmpVal3(f1, 0); f1.x = 1; f1.y = 1; f1.z = 1; f1 <<= f2; - cmpFloat3(f1, 2); + cmpVal3(f1, 2); f1 >>= f2; - cmpFloat3(f1, 1); + cmpVal3(f1, 1); f1.x = 2; f1.y = 2; f1.z = 2; f2 = f1++; - cmpFloat3(f1, 3); - cmpFloat3(f2, 2); + cmpVal3(f1, 3); + cmpVal3(f2, 2); f2 = f1--; - cmpFloat3(f2, 3); - cmpFloat3(f1, 2); + cmpVal3(f2, 3); + cmpVal3(f1, 2); f2 = ++f1; - cmpFloat3(f1, 3); - cmpFloat3(f2, 3); + cmpVal3(f1, 3); + cmpVal3(f2, 3); f2 = --f1; - cmpFloat3(f1, 2); - cmpFloat3(f2, 2); + cmpVal3(f1, 2); + cmpVal3(f2, 2); f2 = ~f1; - cmpFloat3(f2, -3); + cmpVal3(f2, -3); assert(!f1 == false); f1.x = 3; @@ -3097,19 +3142,19 @@ bool TestLong4() { f2.z = 1; f2.w = 1; f3 = f1 + f2; - cmpFloat4(f3, 2); + cmpVal4(f3, 2); f2 = f3 - f1; - cmpFloat4(f2, 1); + cmpVal4(f2, 1); f1 = f2 * f3; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f2 = f1 / f3; - cmpFloat4(f2, 2/2); + cmpVal4(f2, 2/2); f3 = f1 % f2; - cmpFloat4(f3, 0); + cmpVal4(f3, 0); f1 = f3 & f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f2 = f1 ^ f3; - cmpFloat4(f2, 0); + cmpVal4(f2, 0); f1.x = 1; f1.y = 1; f1.z = 1; @@ -3119,9 +3164,9 @@ bool TestLong4() { f2.z = 2; f2.w = 2; f3 = f1 << f2; - cmpFloat4(f3, 4); + cmpVal4(f3, 4); f2 = f3 >> f1; - cmpFloat4(f2, 2); + cmpVal4(f2, 2); f1.x = 2; f1.y = 2; @@ -3132,49 +3177,49 @@ bool TestLong4() { f2.z = 1; f2.w = 1; f1 += f2; - cmpFloat4(f1, 3); + cmpVal4(f1, 3); f1 -= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 *= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 /= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 %= f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f1 &= f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f1 |= f2; - cmpFloat4(f1, 1); + cmpVal4(f1, 1); f1 ^= f2; - cmpFloat4(f1, 0); + cmpVal4(f1, 0); f1.x = 1; f1.y = 1; f1.z = 1; f1.w = 1; f1 <<= f2; - cmpFloat4(f1, 2); + cmpVal4(f1, 2); f1 >>= f2; - cmpFloat4(f1, 1); + cmpVal4(f1, 1); f1.x = 2; f1.y = 2; f1.z = 2; f1.w = 2; f2 = f1++; - cmpFloat4(f1, 3); - cmpFloat4(f2, 2); + cmpVal4(f1, 3); + cmpVal4(f2, 2); f2 = f1--; - cmpFloat4(f2, 3); - cmpFloat4(f1, 2); + cmpVal4(f2, 3); + cmpVal4(f1, 2); f2 = ++f1; - cmpFloat4(f1, 3); - cmpFloat4(f2, 3); + cmpVal4(f1, 3); + cmpVal4(f2, 3); f2 = --f1; - cmpFloat4(f1, 2); - cmpFloat4(f2, 2); + cmpVal4(f1, 2); + cmpVal4(f2, 2); f2 = ~f1; - cmpFloat4(f2, -3); + cmpVal4(f2, -3); assert(!f1 == false); f1.x = 3; @@ -3205,39 +3250,39 @@ bool TestLong4() { bool TestFloat1() { float1 f1, f2, f3; // float1 f4(1); -// cmpFloat1(f4, 1.0f); +// cmpVal1(f4, 1.0f); // float1 f5(2.0f); -// cmpFloat1(f5, 2.0f); +// cmpVal1(f5, 2.0f); f1.x = 1.0f; f2.x = 1.0f; f3 = f1 + f2; - cmpFloat1(f3, 2.0f); + cmpVal1(f3, 2.0f); f2 = f3 - f1; - cmpFloat1(f2, 1.0f); + cmpVal1(f2, 1.0f); f1 = f2 * f3; - cmpFloat1(f1, 2.0f); + cmpVal1(f1, 2.0f); f2 = f1 / f3; - cmpFloat1(f2, 2.0f/2.0f); + cmpVal1(f2, 2.0f/2.0f); f1 += f2; - cmpFloat1(f1, 3.0f); + cmpVal1(f1, 3.0f); f1 -= f2; - cmpFloat1(f1, 2.0f); + cmpVal1(f1, 2.0f); f1 *= f2; - cmpFloat1(f1, 2.0f); + cmpVal1(f1, 2.0f); f1 /= f2; - cmpFloat1(f1, 2.0f); + cmpVal1(f1, 2.0f); f2 = f1++; - cmpFloat1(f1, 3.0f); - cmpFloat1(f2, 2.0f); + cmpVal1(f1, 3.0f); + cmpVal1(f2, 2.0f); f2 = f1--; - cmpFloat1(f2, 3.0f); - cmpFloat1(f1, 2.0f); + cmpVal1(f2, 3.0f); + cmpVal1(f1, 2.0f); f2 = ++f1; - cmpFloat1(f1, 3.0f); - cmpFloat1(f2, 3.0f); + cmpVal1(f1, 3.0f); + cmpVal1(f2, 3.0f); f2 = --f1; - cmpFloat1(f1, 2.0f); - cmpFloat1(f1, 2.0f); + cmpVal1(f1, 2.0f); + cmpVal1(f1, 2.0f); f1.x = 3.0f; f2.x = 4.0f; @@ -3259,34 +3304,34 @@ bool TestFloat2() { f2.x = 1.0f; f2.y = 1.0f; f3 = f1 + f2; - cmpFloat2(f3, 2.0f); + cmpVal2(f3, 2.0f); f2 = f3 - f1; - cmpFloat2(f2, 1.0f); + cmpVal2(f2, 1.0f); f1 = f2 * f3; - cmpFloat2(f1, 2.0f); + cmpVal2(f1, 2.0f); f2 = f1 / f3; - cmpFloat2(f2, 2.0f/2.0f); + cmpVal2(f2, 2.0f/2.0f); f1 += f2; - cmpFloat2(f1, 3.0f); + cmpVal2(f1, 3.0f); f1 -= f2; - cmpFloat2(f1, 2.0f); + cmpVal2(f1, 2.0f); f1 *= f2; - cmpFloat2(f1, 2.0f); + cmpVal2(f1, 2.0f); f1 /= f2; - cmpFloat2(f1, 2.0f); + cmpVal2(f1, 2.0f); f2 = f1++; - cmpFloat2(f1, 3.0f); - cmpFloat2(f2, 2.0f); + cmpVal2(f1, 3.0f); + cmpVal2(f2, 2.0f); f2 = f1--; - cmpFloat2(f2, 3.0f); - cmpFloat2(f1, 2.0f); + cmpVal2(f2, 3.0f); + cmpVal2(f1, 2.0f); f2 = ++f1; - cmpFloat2(f1, 3.0f); - cmpFloat2(f2, 3.0f); + cmpVal2(f1, 3.0f); + cmpVal2(f2, 3.0f); f2 = --f1; - cmpFloat2(f1, 2.0f); - cmpFloat2(f1, 2.0f); + cmpVal2(f1, 2.0f); + cmpVal2(f1, 2.0f); f1.x = 3.0f; f1.y = 3.0f; @@ -3314,32 +3359,32 @@ bool TestFloat3() { f2.y = 1.0f; f2.z = 1.0f; f3 = f1 + f2; - cmpFloat3(f3, 2.0f); + cmpVal3(f3, 2.0f); f2 = f3 - f1; - cmpFloat3(f2, 1.0f); + cmpVal3(f2, 1.0f); f1 = f2 * f3; - cmpFloat3(f1, 2.0f); + cmpVal3(f1, 2.0f); f2 = f1 / f3; - cmpFloat3(f2, 2.0f/2.0f); + cmpVal3(f2, 2.0f/2.0f); f1 += f2; - cmpFloat3(f1, 3.0f); + cmpVal3(f1, 3.0f); f1 -= f2; - cmpFloat3(f1, 2.0f); + cmpVal3(f1, 2.0f); f1 *= f2; - cmpFloat3(f1, 2.0f); + cmpVal3(f1, 2.0f); f1 /= f2; f2 = f1++; - cmpFloat3(f1, 3.0f); - cmpFloat3(f2, 2.0f); + cmpVal3(f1, 3.0f); + cmpVal3(f2, 2.0f); f2 = f1--; - cmpFloat3(f2, 3.0f); - cmpFloat3(f1, 2.0f); + cmpVal3(f2, 3.0f); + cmpVal3(f1, 2.0f); f2 = ++f1; - cmpFloat3(f1, 3.0f); - cmpFloat3(f2, 3.0f); + cmpVal3(f1, 3.0f); + cmpVal3(f2, 3.0f); f2 = --f1; - cmpFloat3(f1, 2.0f); - cmpFloat3(f1, 2.0f); + cmpVal3(f1, 2.0f); + cmpVal3(f1, 2.0f); f1.x = 3.0f; f1.y = 3.0f; @@ -3373,32 +3418,32 @@ bool TestFloat4() { f2.z = 1.0f; f2.w = 1.0f; f3 = f1 + f2; - cmpFloat4(f3, 2.0f); + cmpVal4(f3, 2.0f); f2 = f3 - f1; - cmpFloat4(f2, 1.0f); + cmpVal4(f2, 1.0f); f1 = f2 * f3; - cmpFloat4(f1, 2.0f); + cmpVal4(f1, 2.0f); f2 = f1 / f3; - cmpFloat4(f2, 2.0f/2.0f); + cmpVal4(f2, 2.0f/2.0f); f1 += f2; - cmpFloat4(f1, 3.0f); + cmpVal4(f1, 3.0f); f1 -= f2; - cmpFloat4(f1, 2.0f); + cmpVal4(f1, 2.0f); f1 *= f2; - cmpFloat4(f1, 2.0f); + cmpVal4(f1, 2.0f); f1 /= f2; f2 = f1++; - cmpFloat4(f1, 3.0f); - cmpFloat4(f2, 2.0f); + cmpVal4(f1, 3.0f); + cmpVal4(f2, 2.0f); f2 = f1--; - cmpFloat4(f2, 3.0f); - cmpFloat4(f1, 2.0f); + cmpVal4(f2, 3.0f); + cmpVal4(f1, 2.0f); f2 = ++f1; - cmpFloat4(f1, 3.0f); - cmpFloat4(f2, 3.0f); + cmpVal4(f1, 3.0f); + cmpVal4(f2, 3.0f); f2 = --f1; - cmpFloat4(f1, 2.0f); - cmpFloat4(f1, 2.0f); + cmpVal4(f1, 2.0f); + cmpVal4(f1, 2.0f); f1.x = 3.0f; f1.y = 3.0f; @@ -3422,8 +3467,6 @@ bool TestFloat4() { return true; } - - int main() { assert(sizeof(float1) == 4); assert(sizeof(float2) == 8); @@ -3438,6 +3481,6 @@ int main() { && TestInt1() && TestInt2() && TestInt3() && TestInt4() && TestULong1() && TestULong2() && TestULong3() && TestULong4() && TestLong1() && TestLong2() && TestLong3() && TestLong4() == true); - + passed(); float1 f1 = make_float1(1.0f); } diff --git a/projects/hip/tests/src/deviceLib/hipVectorTypesDevice.cpp b/projects/hip/tests/src/deviceLib/hipVectorTypesDevice.cpp new file mode 100644 index 0000000000..87351a1e83 --- /dev/null +++ b/projects/hip/tests/src/deviceLib/hipVectorTypesDevice.cpp @@ -0,0 +1,3880 @@ +/* +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +/* HIT_START + * BUILD: %t %s ../test_common.cpp + * RUN: %t + * HIT_END + */ + +#include +#include +#include"test_common.h" +#define cmpVal1(in, exp) \ + if(in.x != exp) { \ + } \ + +#define cmpVal2(in, exp) \ + if(in.x != exp || in.y != exp) { \ + } \ + +#define cmpVal3(in, exp) \ + if(in.x != exp || in.y != exp || in.z != exp) { \ + } \ + +#define cmpVal4(in, exp) \ + if(in.x != exp || in.y != exp || in.z != exp || in.w != exp ) { \ + } \ + +__device__ bool TestUChar1() { + uchar1 f1, f2, f3; + f1.x = 1; + f2.x = 1; + f3 = f1 + f2; + cmpVal1(f3, 2); + f2 = f3 - f1; + cmpVal1(f2, 1); + f1 = f2 * f3; + cmpVal1(f1, 2); + f2 = f1 / f3; + cmpVal1(f2, 2/2); + f3 = f1 % f2; + cmpVal1(f3, 0); + f1 = f3 & f2; + cmpVal1(f1, 0); + f2 = f1 ^ f3; + cmpVal1(f2, 0); + f1.x = 1; + f2.x = 2; + f3 = f1 << f2; + cmpVal1(f3, 4); + f2 = f3 >> f1; + cmpVal1(f2, 2); + + f1.x = 2; + f2.x = 1; + f1 += f2; + cmpVal1(f1, 3); + f1 -= f2; + cmpVal1(f1, 2); + f1 *= f2; + cmpVal1(f1, 2); + f1 /= f2; + cmpVal1(f1, 2); + f1 %= f2; + cmpVal1(f1, 0); + f1 &= f2; + cmpVal1(f1, 0); + f1 |= f2; + cmpVal1(f1, 1); + f1 ^= f2; + cmpVal1(f1, 0); + f1.x = 1; + f1 <<= f2; + cmpVal1(f1, 2); + f1 >>= f2; + cmpVal1(f1, 1); + + f1.x = 2; + f2 = f1++; + cmpVal1(f1, 3); + cmpVal1(f2, 2); + f2 = f1--; + cmpVal1(f2, 3); + cmpVal1(f1, 2); + f2 = ++f1; + cmpVal1(f1, 3); + cmpVal1(f2, 3); + f2 = --f1; + cmpVal1(f1, 2); + cmpVal1(f2, 2); + + f2 = ~f1; + cmpVal1(f2, 253); + + f1.x = 3; + f1 = f1 * (unsigned char)1; + cmpVal1(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed char)1; + cmpVal1(f1, 3); + f1 = (signed char)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal1(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed short)1; + cmpVal1(f1, 3); + f1 = (signed short)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal1(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed int)1; + cmpVal1(f1, 3); + f1 = (signed int)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (float)1; + cmpVal1(f1, 3); + f1 = (float)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal1(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed long)1; + cmpVal1(f1, 3); + f1 = (signed long)1 * f1; + cmpVal1(f1, 3); + +// signed char sc = 1; + + f1.x = 3; + f2.x = 4; + f3.x = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestUChar2() { + uchar2 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f2.x = 1; + f2.y = 1; + f3 = f1 + f2; + cmpVal2(f3, 2); + f2 = f3 - f1; + cmpVal2(f2, 1); + f1 = f2 * f3; + cmpVal2(f1, 2); + f2 = f1 / f3; + cmpVal2(f2, 2/2); + f3 = f1 % f2; + cmpVal2(f3, 0); + f1 = f3 & f2; + cmpVal2(f1, 0); + f2 = f1 ^ f3; + cmpVal2(f2, 0); + f1.x = 1; + f1.y = 1; + f2.x = 2; + f2.y = 2; + f3 = f1 << f2; + cmpVal2(f3, 4); + f2 = f3 >> f1; + cmpVal2(f2, 2); + + f1.x = 2; + f1.y = 2; + f2.x = 1; + f2.y = 1; + f1 += f2; + cmpVal2(f1, 3); + f1 -= f2; + cmpVal2(f1, 2); + f1 *= f2; + cmpVal2(f1, 2); + f1 /= f2; + cmpVal2(f1, 2); + f1 %= f2; + cmpVal2(f1, 0); + f1 &= f2; + cmpVal2(f1, 0); + f1 |= f2; + cmpVal2(f1, 1); + f1 ^= f2; + cmpVal2(f1, 0); + f1.x = 1; + f1.y = 1; + f1 <<= f2; + cmpVal2(f1, 2); + f1 >>= f2; + cmpVal2(f1, 1); + + f1.x = 2; + f1.y = 2; + f2 = f1++; + cmpVal2(f1, 3); + cmpVal2(f2, 2); + f2 = f1--; + cmpVal2(f2, 3); + cmpVal2(f1, 2); + f2 = ++f1; + cmpVal2(f1, 3); + cmpVal2(f2, 3); + f2 = --f1; + cmpVal2(f1, 2); + cmpVal2(f2, 2); + + f2 = ~f1; + cmpVal2(f2, 253); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f2.x = 4; + f2.y = 4; + f3.x = 3; + f3.y = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestUChar3() { + uchar3 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f3 = f1 + f2; + cmpVal3(f3, 2); + f2 = f3 - f1; + cmpVal3(f2, 1); + f1 = f2 * f3; + cmpVal3(f1, 2); + f2 = f1 / f3; + cmpVal3(f2, 2/2); + f3 = f1 % f2; + cmpVal3(f3, 0); + f1 = f3 & f2; + cmpVal3(f1, 0); + f2 = f1 ^ f3; + cmpVal3(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f3 = f1 << f2; + cmpVal3(f3, 4); + f2 = f3 >> f1; + cmpVal3(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f1 += f2; + cmpVal3(f1, 3); + f1 -= f2; + cmpVal3(f1, 2); + f1 *= f2; + cmpVal3(f1, 2); + f1 /= f2; + cmpVal3(f1, 2); + f1 %= f2; + cmpVal3(f1, 0); + f1 &= f2; + cmpVal3(f1, 0); + f1 |= f2; + cmpVal3(f1, 1); + f1 ^= f2; + cmpVal3(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1 <<= f2; + cmpVal3(f1, 2); + f1 >>= f2; + cmpVal3(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2 = f1++; + cmpVal3(f1, 3); + cmpVal3(f2, 2); + f2 = f1--; + cmpVal3(f2, 3); + cmpVal3(f1, 2); + f2 = ++f1; + cmpVal3(f1, 3); + cmpVal3(f2, 3); + f2 = --f1; + cmpVal3(f1, 2); + cmpVal3(f2, 2); + + f2 = ~f1; + cmpVal3(f2, 253); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestUChar4() { + uchar4 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f3 = f1 + f2; + cmpVal4(f3, 2); + f2 = f3 - f1; + cmpVal4(f2, 1); + f1 = f2 * f3; + cmpVal4(f1, 2); + f2 = f1 / f3; + cmpVal4(f2, 2/2); + f3 = f1 % f2; + cmpVal4(f3, 0); + f1 = f3 & f2; + cmpVal4(f1, 0); + f2 = f1 ^ f3; + cmpVal4(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f2.w = 2; + f3 = f1 << f2; + cmpVal4(f3, 4); + f2 = f3 >> f1; + cmpVal4(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f1 += f2; + cmpVal4(f1, 3); + f1 -= f2; + cmpVal4(f1, 2); + f1 *= f2; + cmpVal4(f1, 2); + f1 /= f2; + cmpVal4(f1, 2); + f1 %= f2; + cmpVal4(f1, 0); + f1 &= f2; + cmpVal4(f1, 0); + f1 |= f2; + cmpVal4(f1, 1); + f1 ^= f2; + cmpVal4(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f1 <<= f2; + cmpVal4(f1, 2); + f1 >>= f2; + cmpVal4(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2 = f1++; + cmpVal4(f1, 3); + cmpVal4(f2, 2); + f2 = f1--; + cmpVal4(f2, 3); + cmpVal4(f1, 2); + f2 = ++f1; + cmpVal4(f1, 3); + cmpVal4(f2, 3); + f2 = --f1; + cmpVal4(f1, 2); + cmpVal4(f2, 2); + + f2 = ~f1; + cmpVal4(f2, 253); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f2.w = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + f3.w = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestChar1() { + char1 f1, f2, f3; + f1.x = 1; + f2.x = 1; + f3 = f1 + f2; + cmpVal1(f3, 2); + f2 = f3 - f1; + cmpVal1(f2, 1); + f1 = f2 * f3; + cmpVal1(f1, 2); + f2 = f1 / f3; + cmpVal1(f2, 2/2); + f3 = f1 % f2; + cmpVal1(f3, 0); + f1 = f3 & f2; + cmpVal1(f1, 0); + f2 = f1 ^ f3; + cmpVal1(f2, 0); + f1.x = 1; + f2.x = 2; + f3 = f1 << f2; + cmpVal1(f3, 4); + f2 = f3 >> f1; + cmpVal1(f2, 2); + + f1.x = 2; + f2.x = 1; + f1 += f2; + cmpVal1(f1, 3); + f1 -= f2; + cmpVal1(f1, 2); + f1 *= f2; + cmpVal1(f1, 2); + f1 /= f2; + cmpVal1(f1, 2); + f1 %= f2; + cmpVal1(f1, 0); + f1 &= f2; + cmpVal1(f1, 0); + f1 |= f2; + cmpVal1(f1, 1); + f1 ^= f2; + cmpVal1(f1, 0); + f1.x = 1; + f1 <<= f2; + cmpVal1(f1, 2); + f1 >>= f2; + cmpVal1(f1, 1); + + f1.x = 2; + f2 = f1++; + cmpVal1(f1, 3); + cmpVal1(f2, 2); + f2 = f1--; + cmpVal1(f2, 3); + cmpVal1(f1, 2); + f2 = ++f1; + cmpVal1(f1, 3); + cmpVal1(f2, 3); + f2 = --f1; + cmpVal1(f1, 2); + cmpVal1(f2, 2); + + f2 = ~f1; + cmpVal1(f2, (char)253); + if(!f1 == false){} + + f1.x = 3; + f2.x = 4; + f3.x = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestChar2() { + char2 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f2.x = 1; + f2.y = 1; + f3 = f1 + f2; + cmpVal2(f3, 2); + f2 = f3 - f1; + cmpVal2(f2, 1); + f1 = f2 * f3; + cmpVal2(f1, 2); + f2 = f1 / f3; + cmpVal2(f2, 2/2); + f3 = f1 % f2; + cmpVal2(f3, 0); + f1 = f3 & f2; + cmpVal2(f1, 0); + f2 = f1 ^ f3; + cmpVal2(f2, 0); + f1.x = 1; + f1.y = 1; + f2.x = 2; + f2.y = 2; + f3 = f1 << f2; + cmpVal2(f3, 4); + f2 = f3 >> f1; + cmpVal2(f2, 2); + + f1.x = 2; + f1.y = 2; + f2.x = 1; + f2.y = 1; + f1 += f2; + cmpVal2(f1, 3); + f1 -= f2; + cmpVal2(f1, 2); + f1 *= f2; + cmpVal2(f1, 2); + f1 /= f2; + cmpVal2(f1, 2); + f1 %= f2; + cmpVal2(f1, 0); + f1 &= f2; + cmpVal2(f1, 0); + f1 |= f2; + cmpVal2(f1, 1); + f1 ^= f2; + cmpVal2(f1, 0); + f1.x = 1; + f1.y = 1; + f1 <<= f2; + cmpVal2(f1, 2); + f1 >>= f2; + cmpVal2(f1, 1); + + f1.x = 2; + f1.y = 2; + f2 = f1++; + cmpVal2(f1, 3); + cmpVal2(f2, 2); + f2 = f1--; + cmpVal2(f2, 3); + cmpVal2(f1, 2); + f2 = ++f1; + cmpVal2(f1, 3); + cmpVal2(f2, 3); + f2 = --f1; + cmpVal2(f1, 2); + cmpVal2(f2, 2); + + f2 = ~f1; + cmpVal2(f2, (char)253); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f2.x = 4; + f2.y = 4; + f3.x = 3; + f3.y = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestChar3() { + char3 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f3 = f1 + f2; + cmpVal3(f3, 2); + f2 = f3 - f1; + cmpVal3(f2, 1); + f1 = f2 * f3; + cmpVal3(f1, 2); + f2 = f1 / f3; + cmpVal3(f2, 2/2); + f3 = f1 % f2; + cmpVal3(f3, 0); + f1 = f3 & f2; + cmpVal3(f1, 0); + f2 = f1 ^ f3; + cmpVal3(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f3 = f1 << f2; + cmpVal3(f3, 4); + f2 = f3 >> f1; + cmpVal3(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f1 += f2; + cmpVal3(f1, 3); + f1 -= f2; + cmpVal3(f1, 2); + f1 *= f2; + cmpVal3(f1, 2); + f1 /= f2; + cmpVal3(f1, 2); + f1 %= f2; + cmpVal3(f1, 0); + f1 &= f2; + cmpVal3(f1, 0); + f1 |= f2; + cmpVal3(f1, 1); + f1 ^= f2; + cmpVal3(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1 <<= f2; + cmpVal3(f1, 2); + f1 >>= f2; + cmpVal3(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2 = f1++; + cmpVal3(f1, 3); + cmpVal3(f2, 2); + f2 = f1--; + cmpVal3(f2, 3); + cmpVal3(f1, 2); + f2 = ++f1; + cmpVal3(f1, 3); + cmpVal3(f2, 3); + f2 = --f1; + cmpVal3(f1, 2); + cmpVal3(f2, 2); + + f2 = ~f1; + cmpVal3(f2, (char)253); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestChar4() { + char4 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f3 = f1 + f2; + cmpVal4(f3, 2); + f2 = f3 - f1; + cmpVal4(f2, 1); + f1 = f2 * f3; + cmpVal4(f1, 2); + f2 = f1 / f3; + cmpVal4(f2, 2/2); + f3 = f1 % f2; + cmpVal4(f3, 0); + f1 = f3 & f2; + cmpVal4(f1, 0); + f2 = f1 ^ f3; + cmpVal4(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f2.w = 2; + f3 = f1 << f2; + cmpVal4(f3, 4); + f2 = f3 >> f1; + cmpVal4(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f1 += f2; + cmpVal4(f1, 3); + f1 -= f2; + cmpVal4(f1, 2); + f1 *= f2; + cmpVal4(f1, 2); + f1 /= f2; + cmpVal4(f1, 2); + f1 %= f2; + cmpVal4(f1, 0); + f1 &= f2; + cmpVal4(f1, 0); + f1 |= f2; + cmpVal4(f1, 1); + f1 ^= f2; + cmpVal4(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f1 <<= f2; + cmpVal4(f1, 2); + f1 >>= f2; + cmpVal4(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2 = f1++; + cmpVal4(f1, 3); + cmpVal4(f2, 2); + f2 = f1--; + cmpVal4(f2, 3); + cmpVal4(f1, 2); + f2 = ++f1; + cmpVal4(f1, 3); + cmpVal4(f2, 3); + f2 = --f1; + cmpVal4(f1, 2); + cmpVal4(f2, 2); + + f2 = ~f1; + cmpVal4(f2, (char)253); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f2.w = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + f3.w = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestUShort1() { + ushort1 f1, f2, f3; + f1.x = 1; + f2.x = 1; + f3 = f1 + f2; + cmpVal1(f3, 2); + f2 = f3 - f1; + cmpVal1(f2, 1); + f1 = f2 * f3; + cmpVal1(f1, 2); + f2 = f1 / f3; + cmpVal1(f2, 2/2); + f3 = f1 % f2; + cmpVal1(f3, 0); + f1 = f3 & f2; + cmpVal1(f1, 0); + f2 = f1 ^ f3; + cmpVal1(f2, 0); + f1.x = 1; + f2.x = 2; + f3 = f1 << f2; + cmpVal1(f3, 4); + f2 = f3 >> f1; + cmpVal1(f2, 2); + + f1.x = 2; + f2.x = 1; + f1 += f2; + cmpVal1(f1, 3); + f1 -= f2; + cmpVal1(f1, 2); + f1 *= f2; + cmpVal1(f1, 2); + f1 /= f2; + cmpVal1(f1, 2); + f1 %= f2; + cmpVal1(f1, 0); + f1 &= f2; + cmpVal1(f1, 0); + f1 |= f2; + cmpVal1(f1, 1); + f1 ^= f2; + cmpVal1(f1, 0); + f1.x = 1; + f1 <<= f2; + cmpVal1(f1, 2); + f1 >>= f2; + cmpVal1(f1, 1); + + f1.x = 2; + f2 = f1++; + cmpVal1(f1, 3); + cmpVal1(f2, 2); + f2 = f1--; + cmpVal1(f2, 3); + cmpVal1(f1, 2); + f2 = ++f1; + cmpVal1(f1, 3); + cmpVal1(f2, 3); + f2 = --f1; + cmpVal1(f1, 2); + cmpVal1(f2, 2); + + f2 = ~f1; + cmpVal1(f2, (unsigned short)65533); + if(!f1 == false){} + + f1.x = 3; + f2.x = 4; + f3.x = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestUShort2() { + ushort2 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f2.x = 1; + f2.y = 1; + f3 = f1 + f2; + cmpVal2(f3, 2); + f2 = f3 - f1; + cmpVal2(f2, 1); + f1 = f2 * f3; + cmpVal2(f1, 2); + f2 = f1 / f3; + cmpVal2(f2, 2/2); + f3 = f1 % f2; + cmpVal2(f3, 0); + f1 = f3 & f2; + cmpVal2(f1, 0); + f2 = f1 ^ f3; + cmpVal2(f2, 0); + f1.x = 1; + f1.y = 1; + f2.x = 2; + f2.y = 2; + f3 = f1 << f2; + cmpVal2(f3, 4); + f2 = f3 >> f1; + cmpVal2(f2, 2); + + f1.x = 2; + f1.y = 2; + f2.x = 1; + f2.y = 1; + f1 += f2; + cmpVal2(f1, 3); + f1 -= f2; + cmpVal2(f1, 2); + f1 *= f2; + cmpVal2(f1, 2); + f1 /= f2; + cmpVal2(f1, 2); + f1 %= f2; + cmpVal2(f1, 0); + f1 &= f2; + cmpVal2(f1, 0); + f1 |= f2; + cmpVal2(f1, 1); + f1 ^= f2; + cmpVal2(f1, 0); + f1.x = 1; + f1.y = 1; + f1 <<= f2; + cmpVal2(f1, 2); + f1 >>= f2; + cmpVal2(f1, 1); + + f1.x = 2; + f1.y = 2; + f2 = f1++; + cmpVal2(f1, 3); + cmpVal2(f2, 2); + f2 = f1--; + cmpVal2(f2, 3); + cmpVal2(f1, 2); + f2 = ++f1; + cmpVal2(f1, 3); + cmpVal2(f2, 3); + f2 = --f1; + cmpVal2(f1, 2); + cmpVal2(f2, 2); + + f2 = ~f1; + cmpVal2(f2, (unsigned short)65533); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f2.x = 4; + f2.y = 4; + f3.x = 3; + f3.y = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestUShort3() { + ushort3 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f3 = f1 + f2; + cmpVal3(f3, 2); + f2 = f3 - f1; + cmpVal3(f2, 1); + f1 = f2 * f3; + cmpVal3(f1, 2); + f2 = f1 / f3; + cmpVal3(f2, 2/2); + f3 = f1 % f2; + cmpVal3(f3, 0); + f1 = f3 & f2; + cmpVal3(f1, 0); + f2 = f1 ^ f3; + cmpVal3(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f3 = f1 << f2; + cmpVal3(f3, 4); + f2 = f3 >> f1; + cmpVal3(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f1 += f2; + cmpVal3(f1, 3); + f1 -= f2; + cmpVal3(f1, 2); + f1 *= f2; + cmpVal3(f1, 2); + f1 /= f2; + cmpVal3(f1, 2); + f1 %= f2; + cmpVal3(f1, 0); + f1 &= f2; + cmpVal3(f1, 0); + f1 |= f2; + cmpVal3(f1, 1); + f1 ^= f2; + cmpVal3(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1 <<= f2; + cmpVal3(f1, 2); + f1 >>= f2; + cmpVal3(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2 = f1++; + cmpVal3(f1, 3); + cmpVal3(f2, 2); + f2 = f1--; + cmpVal3(f2, 3); + cmpVal3(f1, 2); + f2 = ++f1; + cmpVal3(f1, 3); + cmpVal3(f2, 3); + f2 = --f1; + cmpVal3(f1, 2); + cmpVal3(f2, 2); + + f2 = ~f1; + cmpVal3(f2, (unsigned short)65533); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestUShort4() { + ushort4 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f3 = f1 + f2; + cmpVal4(f3, 2); + f2 = f3 - f1; + cmpVal4(f2, 1); + f1 = f2 * f3; + cmpVal4(f1, 2); + f2 = f1 / f3; + cmpVal4(f2, 2/2); + f3 = f1 % f2; + cmpVal4(f3, 0); + f1 = f3 & f2; + cmpVal4(f1, 0); + f2 = f1 ^ f3; + cmpVal4(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f2.w = 2; + f3 = f1 << f2; + cmpVal4(f3, 4); + f2 = f3 >> f1; + cmpVal4(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f1 += f2; + cmpVal4(f1, 3); + f1 -= f2; + cmpVal4(f1, 2); + f1 *= f2; + cmpVal4(f1, 2); + f1 /= f2; + cmpVal4(f1, 2); + f1 %= f2; + cmpVal4(f1, 0); + f1 &= f2; + cmpVal4(f1, 0); + f1 |= f2; + cmpVal4(f1, 1); + f1 ^= f2; + cmpVal4(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f1 <<= f2; + cmpVal4(f1, 2); + f1 >>= f2; + cmpVal4(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2 = f1++; + cmpVal4(f1, 3); + cmpVal4(f2, 2); + f2 = f1--; + cmpVal4(f2, 3); + cmpVal4(f1, 2); + f2 = ++f1; + cmpVal4(f1, 3); + cmpVal4(f2, 3); + f2 = --f1; + cmpVal4(f1, 2); + cmpVal4(f2, 2); + + f2 = ~f1; + cmpVal4(f2, (unsigned short)65533); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f2.w = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + f3.w = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestShort1() { + short1 f1, f2, f3; + f1.x = 1; + f2.x = 1; + f3 = f1 + f2; + cmpVal1(f3, 2); + f2 = f3 - f1; + cmpVal1(f2, 1); + f1 = f2 * f3; + cmpVal1(f1, 2); + f2 = f1 / f3; + cmpVal1(f2, 2/2); + f3 = f1 % f2; + cmpVal1(f3, 0); + f1 = f3 & f2; + cmpVal1(f1, 0); + f2 = f1 ^ f3; + cmpVal1(f2, 0); + f1.x = 1; + f2.x = 2; + f3 = f1 << f2; + cmpVal1(f3, 4); + f2 = f3 >> f1; + cmpVal1(f2, 2); + + f1.x = 2; + f2.x = 1; + f1 += f2; + cmpVal1(f1, 3); + f1 -= f2; + cmpVal1(f1, 2); + f1 *= f2; + cmpVal1(f1, 2); + f1 /= f2; + cmpVal1(f1, 2); + f1 %= f2; + cmpVal1(f1, 0); + f1 &= f2; + cmpVal1(f1, 0); + f1 |= f2; + cmpVal1(f1, 1); + f1 ^= f2; + cmpVal1(f1, 0); + f1.x = 1; + f1 <<= f2; + cmpVal1(f1, 2); + f1 >>= f2; + cmpVal1(f1, 1); + + f1.x = 2; + f2 = f1++; + cmpVal1(f1, 3); + cmpVal1(f2, 2); + f2 = f1--; + cmpVal1(f2, 3); + cmpVal1(f1, 2); + f2 = ++f1; + cmpVal1(f1, 3); + cmpVal1(f2, 3); + f2 = --f1; + cmpVal1(f1, 2); + cmpVal1(f2, 2); + + f2 = ~f1; + cmpVal1(f2, (signed short)65533); + if(!f1 == false){} + + f1.x = 3; + f2.x = 4; + f3.x = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestShort2() { + short2 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f2.x = 1; + f2.y = 1; + f3 = f1 + f2; + cmpVal2(f3, 2); + f2 = f3 - f1; + cmpVal2(f2, 1); + f1 = f2 * f3; + cmpVal2(f1, 2); + f2 = f1 / f3; + cmpVal2(f2, 2/2); + f3 = f1 % f2; + cmpVal2(f3, 0); + f1 = f3 & f2; + cmpVal2(f1, 0); + f2 = f1 ^ f3; + cmpVal2(f2, 0); + f1.x = 1; + f1.y = 1; + f2.x = 2; + f2.y = 2; + f3 = f1 << f2; + cmpVal2(f3, 4); + f2 = f3 >> f1; + cmpVal2(f2, 2); + + f1.x = 2; + f1.y = 2; + f2.x = 1; + f2.y = 1; + f1 += f2; + cmpVal2(f1, 3); + f1 -= f2; + cmpVal2(f1, 2); + f1 *= f2; + cmpVal2(f1, 2); + f1 /= f2; + cmpVal2(f1, 2); + f1 %= f2; + cmpVal2(f1, 0); + f1 &= f2; + cmpVal2(f1, 0); + f1 |= f2; + cmpVal2(f1, 1); + f1 ^= f2; + cmpVal2(f1, 0); + f1.x = 1; + f1.y = 1; + f1 <<= f2; + cmpVal2(f1, 2); + f1 >>= f2; + cmpVal2(f1, 1); + + f1.x = 2; + f1.y = 2; + f2 = f1++; + cmpVal2(f1, 3); + cmpVal2(f2, 2); + f2 = f1--; + cmpVal2(f2, 3); + cmpVal2(f1, 2); + f2 = ++f1; + cmpVal2(f1, 3); + cmpVal2(f2, 3); + f2 = --f1; + cmpVal2(f1, 2); + cmpVal2(f2, 2); + + f2 = ~f1; + cmpVal2(f2, (signed short)65533); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f2.x = 4; + f2.y = 4; + f3.x = 3; + f3.y = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestShort3() { + short3 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f3 = f1 + f2; + cmpVal3(f3, 2); + f2 = f3 - f1; + cmpVal3(f2, 1); + f1 = f2 * f3; + cmpVal3(f1, 2); + f2 = f1 / f3; + cmpVal3(f2, 2/2); + f3 = f1 % f2; + cmpVal3(f3, 0); + f1 = f3 & f2; + cmpVal3(f1, 0); + f2 = f1 ^ f3; + cmpVal3(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f3 = f1 << f2; + cmpVal3(f3, 4); + f2 = f3 >> f1; + cmpVal3(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f1 += f2; + cmpVal3(f1, 3); + f1 -= f2; + cmpVal3(f1, 2); + f1 *= f2; + cmpVal3(f1, 2); + f1 /= f2; + cmpVal3(f1, 2); + f1 %= f2; + cmpVal3(f1, 0); + f1 &= f2; + cmpVal3(f1, 0); + f1 |= f2; + cmpVal3(f1, 1); + f1 ^= f2; + cmpVal3(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1 <<= f2; + cmpVal3(f1, 2); + f1 >>= f2; + cmpVal3(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2 = f1++; + cmpVal3(f1, 3); + cmpVal3(f2, 2); + f2 = f1--; + cmpVal3(f2, 3); + cmpVal3(f1, 2); + f2 = ++f1; + cmpVal3(f1, 3); + cmpVal3(f2, 3); + f2 = --f1; + cmpVal3(f1, 2); + cmpVal3(f2, 2); + + f2 = ~f1; + cmpVal3(f2, (signed short)65533); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestShort4() { + short4 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f3 = f1 + f2; + cmpVal4(f3, 2); + f2 = f3 - f1; + cmpVal4(f2, 1); + f1 = f2 * f3; + cmpVal4(f1, 2); + f2 = f1 / f3; + cmpVal4(f2, 2/2); + f3 = f1 % f2; + cmpVal4(f3, 0); + f1 = f3 & f2; + cmpVal4(f1, 0); + f2 = f1 ^ f3; + cmpVal4(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f2.w = 2; + f3 = f1 << f2; + cmpVal4(f3, 4); + f2 = f3 >> f1; + cmpVal4(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f1 += f2; + cmpVal4(f1, 3); + f1 -= f2; + cmpVal4(f1, 2); + f1 *= f2; + cmpVal4(f1, 2); + f1 /= f2; + cmpVal4(f1, 2); + f1 %= f2; + cmpVal4(f1, 0); + f1 &= f2; + cmpVal4(f1, 0); + f1 |= f2; + cmpVal4(f1, 1); + f1 ^= f2; + cmpVal4(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f1 <<= f2; + cmpVal4(f1, 2); + f1 >>= f2; + cmpVal4(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2 = f1++; + cmpVal4(f1, 3); + cmpVal4(f2, 2); + f2 = f1--; + cmpVal4(f2, 3); + cmpVal4(f1, 2); + f2 = ++f1; + cmpVal4(f1, 3); + cmpVal4(f2, 3); + f2 = --f1; + cmpVal4(f1, 2); + cmpVal4(f2, 2); + + f2 = ~f1; + cmpVal4(f2, (signed short)65533); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f2.w = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + f3.w = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + + +__device__ bool TestUInt1() { + uint1 f1, f2, f3; + f1.x = 1; + f2.x = 1; + f3 = f1 + f2; + cmpVal1(f3, 2); + f2 = f3 - f1; + cmpVal1(f2, 1); + f1 = f2 * f3; + cmpVal1(f1, 2); + f2 = f1 / f3; + cmpVal1(f2, 2/2); + f3 = f1 % f2; + cmpVal1(f3, 0); + f1 = f3 & f2; + cmpVal1(f1, 0); + f2 = f1 ^ f3; + cmpVal1(f2, 0); + f1.x = 1; + f2.x = 2; + f3 = f1 << f2; + cmpVal1(f3, 4); + f2 = f3 >> f1; + cmpVal1(f2, 2); + + f1.x = 2; + f2.x = 1; + f1 += f2; + cmpVal1(f1, 3); + f1 -= f2; + cmpVal1(f1, 2); + f1 *= f2; + cmpVal1(f1, 2); + f1 /= f2; + cmpVal1(f1, 2); + f1 %= f2; + cmpVal1(f1, 0); + f1 &= f2; + cmpVal1(f1, 0); + f1 |= f2; + cmpVal1(f1, 1); + f1 ^= f2; + cmpVal1(f1, 0); + f1.x = 1; + f1 <<= f2; + cmpVal1(f1, 2); + f1 >>= f2; + cmpVal1(f1, 1); + + f1.x = 2; + f2 = f1++; + cmpVal1(f1, 3); + cmpVal1(f2, 2); + f2 = f1--; + cmpVal1(f2, 3); + cmpVal1(f1, 2); + f2 = ++f1; + cmpVal1(f1, 3); + cmpVal1(f2, 3); + f2 = --f1; + cmpVal1(f1, 2); + cmpVal1(f2, 2); + + f2 = ~f1; + cmpVal1(f2, (unsigned int)4294967293); + if(!f1 == false){} + + f1.x = 3; + f2.x = 4; + f3.x = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestUInt2() { + uint2 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f2.x = 1; + f2.y = 1; + f3 = f1 + f2; + cmpVal2(f3, 2); + f2 = f3 - f1; + cmpVal2(f2, 1); + f1 = f2 * f3; + cmpVal2(f1, 2); + f2 = f1 / f3; + cmpVal2(f2, 2/2); + f3 = f1 % f2; + cmpVal2(f3, 0); + f1 = f3 & f2; + cmpVal2(f1, 0); + f2 = f1 ^ f3; + cmpVal2(f2, 0); + f1.x = 1; + f1.y = 1; + f2.x = 2; + f2.y = 2; + f3 = f1 << f2; + cmpVal2(f3, 4); + f2 = f3 >> f1; + cmpVal2(f2, 2); + + f1.x = 2; + f1.y = 2; + f2.x = 1; + f2.y = 1; + f1 += f2; + cmpVal2(f1, 3); + f1 -= f2; + cmpVal2(f1, 2); + f1 *= f2; + cmpVal2(f1, 2); + f1 /= f2; + cmpVal2(f1, 2); + f1 %= f2; + cmpVal2(f1, 0); + f1 &= f2; + cmpVal2(f1, 0); + f1 |= f2; + cmpVal2(f1, 1); + f1 ^= f2; + cmpVal2(f1, 0); + f1.x = 1; + f1.y = 1; + f1 <<= f2; + cmpVal2(f1, 2); + f1 >>= f2; + cmpVal2(f1, 1); + + f1.x = 2; + f1.y = 2; + f2 = f1++; + cmpVal2(f1, 3); + cmpVal2(f2, 2); + f2 = f1--; + cmpVal2(f2, 3); + cmpVal2(f1, 2); + f2 = ++f1; + cmpVal2(f1, 3); + cmpVal2(f2, 3); + f2 = --f1; + cmpVal2(f1, 2); + cmpVal2(f2, 2); + + f2 = ~f1; + cmpVal2(f2, (unsigned int)4294967293); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f2.x = 4; + f2.y = 4; + f3.x = 3; + f3.y = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestUInt3() { + uint3 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f3 = f1 + f2; + cmpVal3(f3, 2); + f2 = f3 - f1; + cmpVal3(f2, 1); + f1 = f2 * f3; + cmpVal3(f1, 2); + f2 = f1 / f3; + cmpVal3(f2, 2/2); + f3 = f1 % f2; + cmpVal3(f3, 0); + f1 = f3 & f2; + cmpVal3(f1, 0); + f2 = f1 ^ f3; + cmpVal3(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f3 = f1 << f2; + cmpVal3(f3, 4); + f2 = f3 >> f1; + cmpVal3(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f1 += f2; + cmpVal3(f1, 3); + f1 -= f2; + cmpVal3(f1, 2); + f1 *= f2; + cmpVal3(f1, 2); + f1 /= f2; + cmpVal3(f1, 2); + f1 %= f2; + cmpVal3(f1, 0); + f1 &= f2; + cmpVal3(f1, 0); + f1 |= f2; + cmpVal3(f1, 1); + f1 ^= f2; + cmpVal3(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1 <<= f2; + cmpVal3(f1, 2); + f1 >>= f2; + cmpVal3(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2 = f1++; + cmpVal3(f1, 3); + cmpVal3(f2, 2); + f2 = f1--; + cmpVal3(f2, 3); + cmpVal3(f1, 2); + f2 = ++f1; + cmpVal3(f1, 3); + cmpVal3(f2, 3); + f2 = --f1; + cmpVal3(f1, 2); + cmpVal3(f2, 2); + + f2 = ~f1; + cmpVal3(f2, (unsigned int)4294967293); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestUInt4() { + uint4 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f3 = f1 + f2; + cmpVal4(f3, 2); + f2 = f3 - f1; + cmpVal4(f2, 1); + f1 = f2 * f3; + cmpVal4(f1, 2); + f2 = f1 / f3; + cmpVal4(f2, 2/2); + f3 = f1 % f2; + cmpVal4(f3, 0); + f1 = f3 & f2; + cmpVal4(f1, 0); + f2 = f1 ^ f3; + cmpVal4(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f2.w = 2; + f3 = f1 << f2; + cmpVal4(f3, 4); + f2 = f3 >> f1; + cmpVal4(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f1 += f2; + cmpVal4(f1, 3); + f1 -= f2; + cmpVal4(f1, 2); + f1 *= f2; + cmpVal4(f1, 2); + f1 /= f2; + cmpVal4(f1, 2); + f1 %= f2; + cmpVal4(f1, 0); + f1 &= f2; + cmpVal4(f1, 0); + f1 |= f2; + cmpVal4(f1, 1); + f1 ^= f2; + cmpVal4(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f1 <<= f2; + cmpVal4(f1, 2); + f1 >>= f2; + cmpVal4(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2 = f1++; + cmpVal4(f1, 3); + cmpVal4(f2, 2); + f2 = f1--; + cmpVal4(f2, 3); + cmpVal4(f1, 2); + f2 = ++f1; + cmpVal4(f1, 3); + cmpVal4(f2, 3); + f2 = --f1; + cmpVal4(f1, 2); + cmpVal4(f2, 2); + + f2 = ~f1; + cmpVal4(f2, (unsigned int)4294967293); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f2.w = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + f3.w = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestInt1() { + int1 f1, f2, f3; + f1.x = 1; + f2.x = 1; + f3 = f1 + f2; + cmpVal1(f3, 2); + f2 = f3 - f1; + cmpVal1(f2, 1); + f1 = f2 * f3; + cmpVal1(f1, 2); + f2 = f1 / f3; + cmpVal1(f2, 2/2); + f3 = f1 % f2; + cmpVal1(f3, 0); + f1 = f3 & f2; + cmpVal1(f1, 0); + f2 = f1 ^ f3; + cmpVal1(f2, 0); + f1.x = 1; + f2.x = 2; + f3 = f1 << f2; + cmpVal1(f3, 4); + f2 = f3 >> f1; + cmpVal1(f2, 2); + + f1.x = 2; + f2.x = 1; + f1 += f2; + cmpVal1(f1, 3); + f1 -= f2; + cmpVal1(f1, 2); + f1 *= f2; + cmpVal1(f1, 2); + f1 /= f2; + cmpVal1(f1, 2); + f1 %= f2; + cmpVal1(f1, 0); + f1 &= f2; + cmpVal1(f1, 0); + f1 |= f2; + cmpVal1(f1, 1); + f1 ^= f2; + cmpVal1(f1, 0); + f1.x = 1; + f1 <<= f2; + cmpVal1(f1, 2); + f1 >>= f2; + cmpVal1(f1, 1); + + f1.x = 2; + f2 = f1++; + cmpVal1(f1, 3); + cmpVal1(f2, 2); + f2 = f1--; + cmpVal1(f2, 3); + cmpVal1(f1, 2); + f2 = ++f1; + cmpVal1(f1, 3); + cmpVal1(f2, 3); + f2 = --f1; + cmpVal1(f1, 2); + cmpVal1(f2, 2); + + f2 = ~f1; + cmpVal1(f2, (signed int)4294967293); + if(!f1 == false){} + + f1.x = 3; + f2.x = 4; + f3.x = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestInt2() { + int2 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f2.x = 1; + f2.y = 1; + f3 = f1 + f2; + cmpVal2(f3, 2); + f2 = f3 - f1; + cmpVal2(f2, 1); + f1 = f2 * f3; + cmpVal2(f1, 2); + f2 = f1 / f3; + cmpVal2(f2, 2/2); + f3 = f1 % f2; + cmpVal2(f3, 0); + f1 = f3 & f2; + cmpVal2(f1, 0); + f2 = f1 ^ f3; + cmpVal2(f2, 0); + f1.x = 1; + f1.y = 1; + f2.x = 2; + f2.y = 2; + f3 = f1 << f2; + cmpVal2(f3, 4); + f2 = f3 >> f1; + cmpVal2(f2, 2); + + f1.x = 2; + f1.y = 2; + f2.x = 1; + f2.y = 1; + f1 += f2; + cmpVal2(f1, 3); + f1 -= f2; + cmpVal2(f1, 2); + f1 *= f2; + cmpVal2(f1, 2); + f1 /= f2; + cmpVal2(f1, 2); + f1 %= f2; + cmpVal2(f1, 0); + f1 &= f2; + cmpVal2(f1, 0); + f1 |= f2; + cmpVal2(f1, 1); + f1 ^= f2; + cmpVal2(f1, 0); + f1.x = 1; + f1.y = 1; + f1 <<= f2; + cmpVal2(f1, 2); + f1 >>= f2; + cmpVal2(f1, 1); + + f1.x = 2; + f1.y = 2; + f2 = f1++; + cmpVal2(f1, 3); + cmpVal2(f2, 2); + f2 = f1--; + cmpVal2(f2, 3); + cmpVal2(f1, 2); + f2 = ++f1; + cmpVal2(f1, 3); + cmpVal2(f2, 3); + f2 = --f1; + cmpVal2(f1, 2); + cmpVal2(f2, 2); + + f2 = ~f1; + cmpVal2(f2, (signed int)4294967293); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f2.x = 4; + f2.y = 4; + f3.x = 3; + f3.y = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestInt3() { + int3 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f3 = f1 + f2; + cmpVal3(f3, 2); + f2 = f3 - f1; + cmpVal3(f2, 1); + f1 = f2 * f3; + cmpVal3(f1, 2); + f2 = f1 / f3; + cmpVal3(f2, 2/2); + f3 = f1 % f2; + cmpVal3(f3, 0); + f1 = f3 & f2; + cmpVal3(f1, 0); + f2 = f1 ^ f3; + cmpVal3(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f3 = f1 << f2; + cmpVal3(f3, 4); + f2 = f3 >> f1; + cmpVal3(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f1 += f2; + cmpVal3(f1, 3); + f1 -= f2; + cmpVal3(f1, 2); + f1 *= f2; + cmpVal3(f1, 2); + f1 /= f2; + cmpVal3(f1, 2); + f1 %= f2; + cmpVal3(f1, 0); + f1 &= f2; + cmpVal3(f1, 0); + f1 |= f2; + cmpVal3(f1, 1); + f1 ^= f2; + cmpVal3(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1 <<= f2; + cmpVal3(f1, 2); + f1 >>= f2; + cmpVal3(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2 = f1++; + cmpVal3(f1, 3); + cmpVal3(f2, 2); + f2 = f1--; + cmpVal3(f2, 3); + cmpVal3(f1, 2); + f2 = ++f1; + cmpVal3(f1, 3); + cmpVal3(f2, 3); + f2 = --f1; + cmpVal3(f1, 2); + cmpVal3(f2, 2); + + f2 = ~f1; + cmpVal3(f2, (signed int)4294967293); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestInt4() { + int4 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f3 = f1 + f2; + cmpVal4(f3, 2); + f2 = f3 - f1; + cmpVal4(f2, 1); + f1 = f2 * f3; + cmpVal4(f1, 2); + f2 = f1 / f3; + cmpVal4(f2, 2/2); + f3 = f1 % f2; + cmpVal4(f3, 0); + f1 = f3 & f2; + cmpVal4(f1, 0); + f2 = f1 ^ f3; + cmpVal4(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f2.w = 2; + f3 = f1 << f2; + cmpVal4(f3, 4); + f2 = f3 >> f1; + cmpVal4(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f1 += f2; + cmpVal4(f1, 3); + f1 -= f2; + cmpVal4(f1, 2); + f1 *= f2; + cmpVal4(f1, 2); + f1 /= f2; + cmpVal4(f1, 2); + f1 %= f2; + cmpVal4(f1, 0); + f1 &= f2; + cmpVal4(f1, 0); + f1 |= f2; + cmpVal4(f1, 1); + f1 ^= f2; + cmpVal4(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f1 <<= f2; + cmpVal4(f1, 2); + f1 >>= f2; + cmpVal4(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2 = f1++; + cmpVal4(f1, 3); + cmpVal4(f2, 2); + f2 = f1--; + cmpVal4(f2, 3); + cmpVal4(f1, 2); + f2 = ++f1; + cmpVal4(f1, 3); + cmpVal4(f2, 3); + f2 = --f1; + cmpVal4(f1, 2); + cmpVal4(f2, 2); + + f2 = ~f1; + cmpVal4(f2, (signed int)4294967293); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f2.w = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + f3.w = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestULong1() { + ulong1 f1, f2, f3; + f1.x = 1; + f2.x = 1; + f3 = f1 + f2; + cmpVal1(f3, 2); + f2 = f3 - f1; + cmpVal1(f2, 1); + f1 = f2 * f3; + cmpVal1(f1, 2); + f2 = f1 / f3; + cmpVal1(f2, 2/2); + f3 = f1 % f2; + cmpVal1(f3, 0); + f1 = f3 & f2; + cmpVal1(f1, 0); + f2 = f1 ^ f3; + cmpVal1(f2, 0); + f1.x = 1; + f2.x = 2; + f3 = f1 << f2; + cmpVal1(f3, 4); + f2 = f3 >> f1; + cmpVal1(f2, 2); + + f1.x = 2; + f2.x = 1; + f1 += f2; + cmpVal1(f1, 3); + f1 -= f2; + cmpVal1(f1, 2); + f1 *= f2; + cmpVal1(f1, 2); + f1 /= f2; + cmpVal1(f1, 2); + f1 %= f2; + cmpVal1(f1, 0); + f1 &= f2; + cmpVal1(f1, 0); + f1 |= f2; + cmpVal1(f1, 1); + f1 ^= f2; + cmpVal1(f1, 0); + f1.x = 1; + f1 <<= f2; + cmpVal1(f1, 2); + f1 >>= f2; + cmpVal1(f1, 1); + + f1.x = 2; + f2 = f1++; + cmpVal1(f1, 3); + cmpVal1(f2, 2); + f2 = f1--; + cmpVal1(f2, 3); + cmpVal1(f1, 2); + f2 = ++f1; + cmpVal1(f1, 3); + cmpVal1(f2, 3); + f2 = --f1; + cmpVal1(f1, 2); + cmpVal1(f2, 2); + + f2 = ~f1; + cmpVal1(f2, 18446744073709551613UL); + if(!f1 == false){} + + f1.x = 3; + f2.x = 4; + f3.x = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestULong2() { + ulong2 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f2.x = 1; + f2.y = 1; + f3 = f1 + f2; + cmpVal2(f3, 2); + f2 = f3 - f1; + cmpVal2(f2, 1); + f1 = f2 * f3; + cmpVal2(f1, 2); + f2 = f1 / f3; + cmpVal2(f2, 2/2); + f3 = f1 % f2; + cmpVal2(f3, 0); + f1 = f3 & f2; + cmpVal2(f1, 0); + f2 = f1 ^ f3; + cmpVal2(f2, 0); + f1.x = 1; + f1.y = 1; + f2.x = 2; + f2.y = 2; + f3 = f1 << f2; + cmpVal2(f3, 4); + f2 = f3 >> f1; + cmpVal2(f2, 2); + + f1.x = 2; + f1.y = 2; + f2.x = 1; + f2.y = 1; + f1 += f2; + cmpVal2(f1, 3); + f1 -= f2; + cmpVal2(f1, 2); + f1 *= f2; + cmpVal2(f1, 2); + f1 /= f2; + cmpVal2(f1, 2); + f1 %= f2; + cmpVal2(f1, 0); + f1 &= f2; + cmpVal2(f1, 0); + f1 |= f2; + cmpVal2(f1, 1); + f1 ^= f2; + cmpVal2(f1, 0); + f1.x = 1; + f1.y = 1; + f1 <<= f2; + cmpVal2(f1, 2); + f1 >>= f2; + cmpVal2(f1, 1); + + f1.x = 2; + f1.y = 2; + f2 = f1++; + cmpVal2(f1, 3); + cmpVal2(f2, 2); + f2 = f1--; + cmpVal2(f2, 3); + cmpVal2(f1, 2); + f2 = ++f1; + cmpVal2(f1, 3); + cmpVal2(f2, 3); + f2 = --f1; + cmpVal2(f1, 2); + cmpVal2(f2, 2); + + f2 = ~f1; + cmpVal2(f2, 18446744073709551613UL); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f2.x = 4; + f2.y = 4; + f3.x = 3; + f3.y = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestULong3() { + ulong3 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f3 = f1 + f2; + cmpVal3(f3, 2); + f2 = f3 - f1; + cmpVal3(f2, 1); + f1 = f2 * f3; + cmpVal3(f1, 2); + f2 = f1 / f3; + cmpVal3(f2, 2/2); + f3 = f1 % f2; + cmpVal3(f3, 0); + f1 = f3 & f2; + cmpVal3(f1, 0); + f2 = f1 ^ f3; + cmpVal3(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f3 = f1 << f2; + cmpVal3(f3, 4); + f2 = f3 >> f1; + cmpVal3(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f1 += f2; + cmpVal3(f1, 3); + f1 -= f2; + cmpVal3(f1, 2); + f1 *= f2; + cmpVal3(f1, 2); + f1 /= f2; + cmpVal3(f1, 2); + f1 %= f2; + cmpVal3(f1, 0); + f1 &= f2; + cmpVal3(f1, 0); + f1 |= f2; + cmpVal3(f1, 1); + f1 ^= f2; + cmpVal3(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1 <<= f2; + cmpVal3(f1, 2); + f1 >>= f2; + cmpVal3(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2 = f1++; + cmpVal3(f1, 3); + cmpVal3(f2, 2); + f2 = f1--; + cmpVal3(f2, 3); + cmpVal3(f1, 2); + f2 = ++f1; + cmpVal3(f1, 3); + cmpVal3(f2, 3); + f2 = --f1; + cmpVal3(f1, 2); + cmpVal3(f2, 2); + + f2 = ~f1; + cmpVal3(f2, 18446744073709551613UL); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestULong4() { + ulong4 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f3 = f1 + f2; + cmpVal4(f3, 2); + f2 = f3 - f1; + cmpVal4(f2, 1); + f1 = f2 * f3; + cmpVal4(f1, 2); + f2 = f1 / f3; + cmpVal4(f2, 2/2); + f3 = f1 % f2; + cmpVal4(f3, 0); + f1 = f3 & f2; + cmpVal4(f1, 0); + f2 = f1 ^ f3; + cmpVal4(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f2.w = 2; + f3 = f1 << f2; + cmpVal4(f3, 4); + f2 = f3 >> f1; + cmpVal4(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f1 += f2; + cmpVal4(f1, 3); + f1 -= f2; + cmpVal4(f1, 2); + f1 *= f2; + cmpVal4(f1, 2); + f1 /= f2; + cmpVal4(f1, 2); + f1 %= f2; + cmpVal4(f1, 0); + f1 &= f2; + cmpVal4(f1, 0); + f1 |= f2; + cmpVal4(f1, 1); + f1 ^= f2; + cmpVal4(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f1 <<= f2; + cmpVal4(f1, 2); + f1 >>= f2; + cmpVal4(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2 = f1++; + cmpVal4(f1, 3); + cmpVal4(f2, 2); + f2 = f1--; + cmpVal4(f2, 3); + cmpVal4(f1, 2); + f2 = ++f1; + cmpVal4(f1, 3); + cmpVal4(f2, 3); + f2 = --f1; + cmpVal4(f1, 2); + cmpVal4(f2, 2); + + f2 = ~f1; + cmpVal4(f2, 18446744073709551613UL); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f2.w = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + f3.w = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestLong1() { + long1 f1, f2, f3; + f1.x = 1; + f2.x = 1; + f3 = f1 + f2; + cmpVal1(f3, 2); + f2 = f3 - f1; + cmpVal1(f2, 1); + f1 = f2 * f3; + cmpVal1(f1, 2); + f2 = f1 / f3; + cmpVal1(f2, 2/2); + f3 = f1 % f2; + cmpVal1(f3, 0); + f1 = f3 & f2; + cmpVal1(f1, 0); + f2 = f1 ^ f3; + cmpVal1(f2, 0); + f1.x = 1; + f2.x = 2; + f3 = f1 << f2; + cmpVal1(f3, 4); + f2 = f3 >> f1; + cmpVal1(f2, 2); + + f1.x = 2; + f2.x = 1; + f1 += f2; + cmpVal1(f1, 3); + f1 -= f2; + cmpVal1(f1, 2); + f1 *= f2; + cmpVal1(f1, 2); + f1 /= f2; + cmpVal1(f1, 2); + f1 %= f2; + cmpVal1(f1, 0); + f1 &= f2; + cmpVal1(f1, 0); + f1 |= f2; + cmpVal1(f1, 1); + f1 ^= f2; + cmpVal1(f1, 0); + f1.x = 1; + f1 <<= f2; + cmpVal1(f1, 2); + f1 >>= f2; + cmpVal1(f1, 1); + + f1.x = 2; + f2 = f1++; + cmpVal1(f1, 3); + cmpVal1(f2, 2); + f2 = f1--; + cmpVal1(f2, 3); + cmpVal1(f1, 2); + f2 = ++f1; + cmpVal1(f1, 3); + cmpVal1(f2, 3); + f2 = --f1; + cmpVal1(f1, 2); + cmpVal1(f2, 2); + + f2 = ~f1; + cmpVal1(f2, -3); + if(!f1 == false){} + + f1.x = 3; + f2.x = 4; + f3.x = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestLong2() { + long2 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f2.x = 1; + f2.y = 1; + f3 = f1 + f2; + cmpVal2(f3, 2); + f2 = f3 - f1; + cmpVal2(f2, 1); + f1 = f2 * f3; + cmpVal2(f1, 2); + f2 = f1 / f3; + cmpVal2(f2, 2/2); + f3 = f1 % f2; + cmpVal2(f3, 0); + f1 = f3 & f2; + cmpVal2(f1, 0); + f2 = f1 ^ f3; + cmpVal2(f2, 0); + f1.x = 1; + f1.y = 1; + f2.x = 2; + f2.y = 2; + f3 = f1 << f2; + cmpVal2(f3, 4); + f2 = f3 >> f1; + cmpVal2(f2, 2); + + f1.x = 2; + f1.y = 2; + f2.x = 1; + f2.y = 1; + f1 += f2; + cmpVal2(f1, 3); + f1 -= f2; + cmpVal2(f1, 2); + f1 *= f2; + cmpVal2(f1, 2); + f1 /= f2; + cmpVal2(f1, 2); + f1 %= f2; + cmpVal2(f1, 0); + f1 &= f2; + cmpVal2(f1, 0); + f1 |= f2; + cmpVal2(f1, 1); + f1 ^= f2; + cmpVal2(f1, 0); + f1.x = 1; + f1.y = 1; + f1 <<= f2; + cmpVal2(f1, 2); + f1 >>= f2; + cmpVal2(f1, 1); + + f1.x = 2; + f1.y = 2; + f2 = f1++; + cmpVal2(f1, 3); + cmpVal2(f2, 2); + f2 = f1--; + cmpVal2(f2, 3); + cmpVal2(f1, 2); + f2 = ++f1; + cmpVal2(f1, 3); + cmpVal2(f2, 3); + f2 = --f1; + cmpVal2(f1, 2); + cmpVal2(f2, 2); + + f2 = ~f1; + cmpVal2(f2, -3); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f2.x = 4; + f2.y = 4; + f3.x = 3; + f3.y = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestLong3() { + long3 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f3 = f1 + f2; + cmpVal3(f3, 2); + f2 = f3 - f1; + cmpVal3(f2, 1); + f1 = f2 * f3; + cmpVal3(f1, 2); + f2 = f1 / f3; + cmpVal3(f2, 2/2); + f3 = f1 % f2; + cmpVal3(f3, 0); + f1 = f3 & f2; + cmpVal3(f1, 0); + f2 = f1 ^ f3; + cmpVal3(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f3 = f1 << f2; + cmpVal3(f3, 4); + f2 = f3 >> f1; + cmpVal3(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f1 += f2; + cmpVal3(f1, 3); + f1 -= f2; + cmpVal3(f1, 2); + f1 *= f2; + cmpVal3(f1, 2); + f1 /= f2; + cmpVal3(f1, 2); + f1 %= f2; + cmpVal3(f1, 0); + f1 &= f2; + cmpVal3(f1, 0); + f1 |= f2; + cmpVal3(f1, 1); + f1 ^= f2; + cmpVal3(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1 <<= f2; + cmpVal3(f1, 2); + f1 >>= f2; + cmpVal3(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2 = f1++; + cmpVal3(f1, 3); + cmpVal3(f2, 2); + f2 = f1--; + cmpVal3(f2, 3); + cmpVal3(f1, 2); + f2 = ++f1; + cmpVal3(f1, 3); + cmpVal3(f2, 3); + f2 = --f1; + cmpVal3(f1, 2); + cmpVal3(f2, 2); + + f2 = ~f1; + cmpVal3(f2, -3); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestLong4() { + long4 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f3 = f1 + f2; + cmpVal4(f3, 2); + f2 = f3 - f1; + cmpVal4(f2, 1); + f1 = f2 * f3; + cmpVal4(f1, 2); + f2 = f1 / f3; + cmpVal4(f2, 2/2); + f3 = f1 % f2; + cmpVal4(f3, 0); + f1 = f3 & f2; + cmpVal4(f1, 0); + f2 = f1 ^ f3; + cmpVal4(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f2.w = 2; + f3 = f1 << f2; + cmpVal4(f3, 4); + f2 = f3 >> f1; + cmpVal4(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f1 += f2; + cmpVal4(f1, 3); + f1 -= f2; + cmpVal4(f1, 2); + f1 *= f2; + cmpVal4(f1, 2); + f1 /= f2; + cmpVal4(f1, 2); + f1 %= f2; + cmpVal4(f1, 0); + f1 &= f2; + cmpVal4(f1, 0); + f1 |= f2; + cmpVal4(f1, 1); + f1 ^= f2; + cmpVal4(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f1 <<= f2; + cmpVal4(f1, 2); + f1 >>= f2; + cmpVal4(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2 = f1++; + cmpVal4(f1, 3); + cmpVal4(f2, 2); + f2 = f1--; + cmpVal4(f2, 3); + cmpVal4(f1, 2); + f2 = ++f1; + cmpVal4(f1, 3); + cmpVal4(f2, 3); + f2 = --f1; + cmpVal4(f1, 2); + cmpVal4(f2, 2); + + f2 = ~f1; + cmpVal4(f2, -3); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f2.w = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + f3.w = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + + +__device__ bool TestFloat1() { + float1 f1, f2, f3; +// float1 f4(1); +// cmpVal1(f4, 1.0f); +// float1 f5(2.0f); +// cmpVal1(f5, 2.0f); + f1.x = 1.0f; + f2.x = 1.0f; + f3 = f1 + f2; + cmpVal1(f3, 2.0f); + f2 = f3 - f1; + cmpVal1(f2, 1.0f); + f1 = f2 * f3; + cmpVal1(f1, 2.0f); + f2 = f1 / f3; + cmpVal1(f2, 2.0f/2.0f); + f1 += f2; + cmpVal1(f1, 3.0f); + f1 -= f2; + cmpVal1(f1, 2.0f); + f1 *= f2; + cmpVal1(f1, 2.0f); + f1 /= f2; + cmpVal1(f1, 2.0f); + f2 = f1++; + cmpVal1(f1, 3.0f); + cmpVal1(f2, 2.0f); + f2 = f1--; + cmpVal1(f2, 3.0f); + cmpVal1(f1, 2.0f); + f2 = ++f1; + cmpVal1(f1, 3.0f); + cmpVal1(f2, 3.0f); + f2 = --f1; + cmpVal1(f1, 2.0f); + cmpVal1(f1, 2.0f); + + f1.x = 3.0f; + f2.x = 4.0f; + f3.x = 3.0f; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + return true; +} + +__device__ bool TestFloat2() { + float2 f1, f2, f3; + f1.x = 1.0f; + f1.y = 1.0f; + f2.x = 1.0f; + f2.y = 1.0f; + f3 = f1 + f2; + cmpVal2(f3, 2.0f); + f2 = f3 - f1; + cmpVal2(f2, 1.0f); + f1 = f2 * f3; + cmpVal2(f1, 2.0f); + f2 = f1 / f3; + cmpVal2(f2, 2.0f/2.0f); + f1 += f2; + cmpVal2(f1, 3.0f); + f1 -= f2; + cmpVal2(f1, 2.0f); + f1 *= f2; + cmpVal2(f1, 2.0f); + f1 /= f2; + cmpVal2(f1, 2.0f); + + f2 = f1++; + cmpVal2(f1, 3.0f); + cmpVal2(f2, 2.0f); + f2 = f1--; + cmpVal2(f2, 3.0f); + cmpVal2(f1, 2.0f); + f2 = ++f1; + cmpVal2(f1, 3.0f); + cmpVal2(f2, 3.0f); + f2 = --f1; + cmpVal2(f1, 2.0f); + cmpVal2(f1, 2.0f); + + f1.x = 3.0f; + f1.y = 3.0f; + f2.x = 4.0f; + f2.y = 4.0f; + f3.x = 3.0f; + f3.y = 3.0f; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + + return true; +} + +__device__ bool TestFloat3() { + float3 f1, f2, f3; + f1.x = 1.0f; + f1.y = 1.0f; + f1.z = 1.0f; + f2.x = 1.0f; + f2.y = 1.0f; + f2.z = 1.0f; + f3 = f1 + f2; + cmpVal3(f3, 2.0f); + f2 = f3 - f1; + cmpVal3(f2, 1.0f); + f1 = f2 * f3; + cmpVal3(f1, 2.0f); + f2 = f1 / f3; + cmpVal3(f2, 2.0f/2.0f); + f1 += f2; + cmpVal3(f1, 3.0f); + f1 -= f2; + cmpVal3(f1, 2.0f); + f1 *= f2; + cmpVal3(f1, 2.0f); + f1 /= f2; + f2 = f1++; + cmpVal3(f1, 3.0f); + cmpVal3(f2, 2.0f); + f2 = f1--; + cmpVal3(f2, 3.0f); + cmpVal3(f1, 2.0f); + f2 = ++f1; + cmpVal3(f1, 3.0f); + cmpVal3(f2, 3.0f); + f2 = --f1; + cmpVal3(f1, 2.0f); + cmpVal3(f1, 2.0f); + + f1.x = 3.0f; + f1.y = 3.0f; + f1.z = 3.0f; + f2.x = 4.0f; + f2.y = 4.0f; + f2.z = 4.0f; + f3.x = 3.0f; + f3.y = 3.0f; + f3.z = 3.0f; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + + return true; +} + + +__device__ bool TestFloat4() { + float4 f1, f2, f3; + f1.x = 1.0f; + f1.y = 1.0f; + f1.z = 1.0f; + f1.w = 1.0f; + f2.x = 1.0f; + f2.y = 1.0f; + f2.z = 1.0f; + f2.w = 1.0f; + f3 = f1 + f2; + cmpVal4(f3, 2.0f); + f2 = f3 - f1; + cmpVal4(f2, 1.0f); + f1 = f2 * f3; + cmpVal4(f1, 2.0f); + f2 = f1 / f3; + cmpVal4(f2, 2.0f/2.0f); + f1 += f2; + cmpVal4(f1, 3.0f); + f1 -= f2; + cmpVal4(f1, 2.0f); + f1 *= f2; + cmpVal4(f1, 2.0f); + f1 /= f2; + f2 = f1++; + cmpVal4(f1, 3.0f); + cmpVal4(f2, 2.0f); + f2 = f1--; + cmpVal4(f2, 3.0f); + cmpVal4(f1, 2.0f); + f2 = ++f1; + cmpVal4(f1, 3.0f); + cmpVal4(f2, 3.0f); + f2 = --f1; + cmpVal4(f1, 2.0f); + cmpVal4(f1, 2.0f); + + f1.x = 3.0f; + f1.y = 3.0f; + f1.z = 3.0f; + f1.w = 3.0f; + f2.x = 4.0f; + f2.y = 4.0f; + f2.z = 4.0f; + f2.w = 4.0f; + f3.x = 3.0f; + f3.y = 3.0f; + f3.z = 3.0f; + f3.w = 3.0f; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + return true; +} + +__device__ bool TestULongLong1() { + ulonglong1 f1, f2, f3; + f1.x = 1; + f2.x = 1; + f3 = f1 + f2; + cmpVal1(f3, 2); + f2 = f3 - f1; + cmpVal1(f2, 1); + f1 = f2 * f3; + cmpVal1(f1, 2); + f2 = f1 / f3; + cmpVal1(f2, 2/2); + f3 = f1 % f2; + cmpVal1(f3, 0); + f1 = f3 & f2; + cmpVal1(f1, 0); + f2 = f1 ^ f3; + cmpVal1(f2, 0); + f1.x = 1; + f2.x = 2; + f3 = f1 << f2; + cmpVal1(f3, 4); + f2 = f3 >> f1; + cmpVal1(f2, 2); + + f1.x = 2; + f2.x = 1; + f1 += f2; + cmpVal1(f1, 3); + f1 -= f2; + cmpVal1(f1, 2); + f1 *= f2; + cmpVal1(f1, 2); + f1 /= f2; + cmpVal1(f1, 2); + f1 %= f2; + cmpVal1(f1, 0); + f1 &= f2; + cmpVal1(f1, 0); + f1 |= f2; + cmpVal1(f1, 1); + f1 ^= f2; + cmpVal1(f1, 0); + f1.x = 1; + f1 <<= f2; + cmpVal1(f1, 2); + f1 >>= f2; + cmpVal1(f1, 1); + + f1.x = 2; + f2 = f1++; + cmpVal1(f1, 3); + cmpVal1(f2, 2); + f2 = f1--; + cmpVal1(f2, 3); + cmpVal1(f1, 2); + f2 = ++f1; + cmpVal1(f1, 3); + cmpVal1(f2, 3); + f2 = --f1; + cmpVal1(f1, 2); + cmpVal1(f2, 2); + + f2 = ~f1; + cmpVal1(f2, -3); + if(!f1 == false){} + + f1.x = 3; + f2.x = 4; + f3.x = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + + +__device__ bool TestULongLong2() { + ulonglong2 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f2.x = 1; + f2.y = 1; + f3 = f1 + f2; + cmpVal2(f3, 2); + f2 = f3 - f1; + cmpVal2(f2, 1); + f1 = f2 * f3; + cmpVal2(f1, 2); + f2 = f1 / f3; + cmpVal2(f2, 2/2); + f3 = f1 % f2; + cmpVal2(f3, 0); + f1 = f3 & f2; + cmpVal2(f1, 0); + f2 = f1 ^ f3; + cmpVal2(f2, 0); + f1.x = 1; + f1.y = 1; + f2.x = 2; + f2.y = 2; + f3 = f1 << f2; + cmpVal2(f3, 4); + f2 = f3 >> f1; + cmpVal2(f2, 2); + + f1.x = 2; + f1.y = 2; + f2.x = 1; + f2.y = 1; + f1 += f2; + cmpVal2(f1, 3); + f1 -= f2; + cmpVal2(f1, 2); + f1 *= f2; + cmpVal2(f1, 2); + f1 /= f2; + cmpVal2(f1, 2); + f1 %= f2; + cmpVal2(f1, 0); + f1 &= f2; + cmpVal2(f1, 0); + f1 |= f2; + cmpVal2(f1, 1); + f1 ^= f2; + cmpVal2(f1, 0); + f1.x = 1; + f1.y = 1; + f1 <<= f2; + cmpVal2(f1, 2); + f1 >>= f2; + cmpVal2(f1, 1); + + f1.x = 2; + f1.y = 2; + f2 = f1++; + cmpVal2(f1, 3); + cmpVal2(f2, 2); + f2 = f1--; + cmpVal2(f2, 3); + cmpVal2(f1, 2); + f2 = ++f1; + cmpVal2(f1, 3); + cmpVal2(f2, 3); + f2 = --f1; + cmpVal2(f1, 2); + cmpVal2(f2, 2); + + f2 = ~f1; + cmpVal2(f2, -3); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f2.x = 4; + f2.y = 4; + f3.x = 3; + f3.y = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestULongLong3() { + ulonglong3 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f3 = f1 + f2; + cmpVal3(f3, 2); + f2 = f3 - f1; + cmpVal3(f2, 1); + f1 = f2 * f3; + cmpVal3(f1, 2); + f2 = f1 / f3; + cmpVal3(f2, 2/2); + f3 = f1 % f2; + cmpVal3(f3, 0); + f1 = f3 & f2; + cmpVal3(f1, 0); + f2 = f1 ^ f3; + cmpVal3(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f3 = f1 << f2; + cmpVal3(f3, 4); + f2 = f3 >> f1; + cmpVal3(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f1 += f2; + cmpVal3(f1, 3); + f1 -= f2; + cmpVal3(f1, 2); + f1 *= f2; + cmpVal3(f1, 2); + f1 /= f2; + cmpVal3(f1, 2); + f1 %= f2; + cmpVal3(f1, 0); + f1 &= f2; + cmpVal3(f1, 0); + f1 |= f2; + cmpVal3(f1, 1); + f1 ^= f2; + cmpVal3(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1 <<= f2; + cmpVal3(f1, 2); + f1 >>= f2; + cmpVal3(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2 = f1++; + cmpVal3(f1, 3); + cmpVal3(f2, 2); + f2 = f1--; + cmpVal3(f2, 3); + cmpVal3(f1, 2); + f2 = ++f1; + cmpVal3(f1, 3); + cmpVal3(f2, 3); + f2 = --f1; + cmpVal3(f1, 2); + cmpVal3(f2, 2); + + f2 = ~f1; + cmpVal3(f2, -3); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + +__device__ bool TestULongLong4() { + ulonglong4 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f3 = f1 + f2; + cmpVal4(f3, 2); + f2 = f3 - f1; + cmpVal4(f2, 1); + f1 = f2 * f3; + cmpVal4(f1, 2); + f2 = f1 / f3; + cmpVal4(f2, 2/2); + f3 = f1 % f2; + cmpVal4(f3, 0); + f1 = f3 & f2; + cmpVal4(f1, 0); + f2 = f1 ^ f3; + cmpVal4(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f2.w = 2; + f3 = f1 << f2; + cmpVal4(f3, 4); + f2 = f3 >> f1; + cmpVal4(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f1 += f2; + cmpVal4(f1, 3); + f1 -= f2; + cmpVal4(f1, 2); + f1 *= f2; + cmpVal4(f1, 2); + f1 /= f2; + cmpVal4(f1, 2); + f1 %= f2; + cmpVal4(f1, 0); + f1 &= f2; + cmpVal4(f1, 0); + f1 |= f2; + cmpVal4(f1, 1); + f1 ^= f2; + cmpVal4(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f1 <<= f2; + cmpVal4(f1, 2); + f1 >>= f2; + cmpVal4(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2 = f1++; + cmpVal4(f1, 3); + cmpVal4(f2, 2); + f2 = f1--; + cmpVal4(f2, 3); + cmpVal4(f1, 2); + f2 = ++f1; + cmpVal4(f1, 3); + cmpVal4(f2, 3); + f2 = --f1; + cmpVal4(f1, 2); + cmpVal4(f2, 2); + + f2 = ~f1; + cmpVal4(f2, -3); + if(!f1 == false){} + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f2.w = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + f3.w = 3; + if((f1 == f2) == false){} + if((f1 != f2) == true){} + if((f1 < f2) == true){} + if((f2 > f1) == true){} + if((f1 >= f3) == true){} + if((f1 <= f3) == true){} + + if((f1 && f2) == true){} + if((f1 || f2) == true){} + return true; +} + + +__global__ void CheckVectorTypes(hipLaunchParm lp, bool *ptr){ + if(TestFloat1() && TestFloat2() && TestFloat3() && TestFloat4() + && TestUChar1() && TestUChar2() && TestUChar3() && TestUChar4() + && TestChar1() && TestChar2() && TestChar3() && TestChar4() + && TestUShort1() && TestUShort2() && TestUShort3() && TestUShort4() + && TestShort1() && TestShort2() && TestShort3() && TestShort4() + && TestUInt1() && TestUInt2() && TestUInt3() && TestUInt4() + && TestInt1() && TestInt2() && TestInt3() && TestInt4() + && TestULong1() && TestULong2() && TestULong3() && TestULong4() + && TestLong1() && TestLong2() && TestLong3() && TestLong4() + && TestULongLong1() && TestULongLong2() && TestULongLong3() && TestULongLong4() == true){ + ptr[0] = true; + } +} + +int main() { + assert(sizeof(float1) == 4); + assert(sizeof(float2) == 8); + assert(sizeof(float3) == 12); + assert(sizeof(float4) == 16); + bool *ptr; + hipLaunchKernel(CheckVectorTypes, dim3(1,1,1), dim3(1,1,1), 0, 0, ptr); + passed(); +} From 6119b9c47539f69d0467f5bf581a6b5697fd7e95 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Fri, 20 Jan 2017 13:52:02 -0600 Subject: [PATCH 088/281] added more test coverage for vector data types Change-Id: I9f57a8b597bd2ee4b265eadfd0859531497a6ada [ROCm/hip commit: b134a1a640547a06b63cdab5169571d275f81859] --- .../tests/src/deviceLib/hipVectorTypes.cpp | 4606 ++++++++++++++++- 1 file changed, 4479 insertions(+), 127 deletions(-) diff --git a/projects/hip/tests/src/deviceLib/hipVectorTypes.cpp b/projects/hip/tests/src/deviceLib/hipVectorTypes.cpp index 957439c27e..12a8cc76a3 100644 --- a/projects/hip/tests/src/deviceLib/hipVectorTypes.cpp +++ b/projects/hip/tests/src/deviceLib/hipVectorTypes.cpp @@ -157,8 +157,28 @@ bool TestUChar1() { cmpVal1(f1, 3); f1 = (signed long)1 * f1; cmpVal1(f1, 3); + f1 = f1 * (double)1; + cmpVal1(f1, 3); + f1 = (double)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal1(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal1(f1, 3); + + uchar1 fa((unsigned char)1); + uchar1 fb((signed char)1); + uchar1 fc((unsigned short)1); + uchar1 fd((signed short)1); + uchar1 fe((unsigned int)1); + uchar1 fg((signed int)1); + uchar1 fh((float)1); + uchar1 fi((double)1); + uchar1 fj((unsigned long)1); + uchar1 fk((signed long)1); + uchar1 fl((unsigned long long)1); + uchar1 fm((signed long long)1); -// signed char sc = 1; f1.x = 3; f2.x = 4; @@ -250,6 +270,79 @@ bool TestUChar2() { cmpVal2(f2, 253); assert(!f1 == false); + f1.x = 3; + f1.y = 3; + f1 = f1 * (unsigned char)1; + cmpVal2(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed char)1; + cmpVal2(f1, 3); + f1 = (signed char)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal2(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed short)1; + cmpVal2(f1, 3); + f1 = (signed short)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal2(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed int)1; + cmpVal2(f1, 3); + f1 = (signed int)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (float)1; + cmpVal2(f1, 3); + f1 = (float)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal2(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed long)1; + cmpVal2(f1, 3); + f1 = (signed long)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (double)1; + cmpVal2(f1, 3); + f1 = (double)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal2(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal2(f1, 3); + + uchar2 fa1((unsigned char)1); + uchar2 fa2((unsigned char)1, (unsigned char)1); + uchar2 fb1((signed char)1); + uchar2 fb2((signed char)1, (signed char)1); + uchar2 fc1((unsigned short)1); + uchar2 fc2((unsigned short)1,(unsigned short)1); + uchar2 fd1((signed short)1); + uchar2 fd2((signed short)1, (signed short)1); + uchar2 fe1((unsigned int)1); + uchar2 fe2((unsigned int)1, (unsigned int)1); + uchar2 fg1((signed int)1); + uchar2 fg2((signed int)1, (signed int)1); + uchar2 fh1((float)1); + uchar2 fh2((float)1, (float)1); + uchar2 fi1((double)1); + uchar2 fi2((double)1, (double)1); + uchar2 fj1((unsigned long)1); + uchar2 fj2((unsigned long)1, (unsigned long)1); + uchar2 fk1((signed long)1); + uchar2 fk2((signed long)1, (signed long)1); + uchar2 fl1((unsigned long long)1); + uchar2 fl2((unsigned long long)1, (unsigned long long)1); + uchar2 fm1((signed long long)1); + uchar2 fm2((signed long long)1, (signed long long)1); + + f1.x = 3; f1.y = 3; f2.x = 4; @@ -351,6 +444,79 @@ bool TestUChar3() { cmpVal3(f2, 253); assert(!f1 == false); + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1 = f1 * (unsigned char)1; + cmpVal3(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed char)1; + cmpVal3(f1, 3); + f1 = (signed char)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal3(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed short)1; + cmpVal3(f1, 3); + f1 = (signed short)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal3(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed int)1; + cmpVal3(f1, 3); + f1 = (signed int)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (float)1; + cmpVal3(f1, 3); + f1 = (float)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal3(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed long)1; + cmpVal3(f1, 3); + f1 = (signed long)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (double)1; + cmpVal3(f1, 3); + f1 = (double)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal3(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal3(f1, 3); + + uchar3 fa1((unsigned char)1); + uchar3 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1); + uchar3 fb1((signed char)1); + uchar3 fb2((signed char)1, (signed char)1, (signed char)1); + uchar3 fc1((unsigned short)1); + uchar3 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1); + uchar3 fd1((signed short)1); + uchar3 fd2((signed short)1, (signed short)1, (signed short)1); + uchar3 fe1((unsigned int)1); + uchar3 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1); + uchar3 fg1((signed int)1); + uchar3 fg2((signed int)1, (signed int)1, (signed int)1); + uchar3 fh1((float)1); + uchar3 fh2((float)1, (float)1, (float)1); + uchar3 fi1((double)1); + uchar3 fi2((double)1, (double)1, (double)1); + uchar3 fj1((unsigned long)1); + uchar3 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1); + uchar3 fk1((signed long)1); + uchar3 fk2((signed long)1, (signed long)1, (signed long)1); + uchar3 fl1((unsigned long long)1); + uchar3 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + uchar3 fm1((signed long long)1); + uchar3 fm2((signed long long)1, (signed long long)1, (signed long long)1); + f1.x = 3; f1.y = 3; f1.z = 3; @@ -463,6 +629,81 @@ bool TestUChar4() { cmpVal4(f2, 253); assert(!f1 == false); + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f1 = f1 * (unsigned char)1; + cmpVal4(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed char)1; + cmpVal4(f1, 3); + f1 = (signed char)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal4(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed short)1; + cmpVal4(f1, 3); + f1 = (signed short)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal4(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed int)1; + cmpVal4(f1, 3); + f1 = (signed int)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (float)1; + cmpVal4(f1, 3); + f1 = (float)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal4(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed long)1; + cmpVal4(f1, 3); + f1 = (signed long)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (double)1; + cmpVal4(f1, 3); + f1 = (double)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal4(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal4(f1, 3); + + + uchar4 fa1((unsigned char)1); + uchar4 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1); + uchar4 fb1((signed char)1); + uchar4 fb2((signed char)1, (signed char)1, (signed char)1, (signed char)1); + uchar4 fc1((unsigned short)1); + uchar4 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1, (unsigned short)1); + uchar4 fd1((signed short)1); + uchar4 fd2((signed short)1, (signed short)1, (signed short)1, (signed short)1); + uchar4 fe1((unsigned int)1); + uchar4 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1, (unsigned int)1); + uchar4 fg1((signed int)1); + uchar4 fg2((signed int)1, (signed int)1, (signed int)1, (signed int)1); + uchar4 fh1((float)1); + uchar4 fh2((float)1, (float)1, (float)1, (float)1); + uchar4 fi1((double)1); + uchar4 fi2((double)1, (double)1, (double)1, (double)1); + uchar4 fj1((unsigned long)1); + uchar4 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1, (unsigned long)1); + uchar4 fk1((signed long)1); + uchar4 fk2((signed long)1, (signed long)1, (signed long)1, (signed long)1); + uchar4 fl1((unsigned long long)1); + uchar4 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + uchar4 fm1((signed long long)1); + uchar4 fm2((signed long long)1, (signed long long)1, (signed long long)1, (signed long long)1); + f1.x = 3; f1.y = 3; f1.z = 3; @@ -487,6 +728,7 @@ bool TestUChar4() { return true; } + bool TestChar1() { char1 f1, f2, f3; f1.x = 1; @@ -554,6 +796,66 @@ bool TestChar1() { cmpVal1(f2, (char)253); assert(!f1 == false); + f1.x = 3; + f1 = f1 * (unsigned char)1; + cmpVal1(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed char)1; + cmpVal1(f1, 3); + f1 = (signed char)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal1(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed short)1; + cmpVal1(f1, 3); + f1 = (signed short)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal1(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed int)1; + cmpVal1(f1, 3); + f1 = (signed int)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (float)1; + cmpVal1(f1, 3); + f1 = (float)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal1(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed long)1; + cmpVal1(f1, 3); + f1 = (signed long)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (double)1; + cmpVal1(f1, 3); + f1 = (double)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal1(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal1(f1, 3); + + char1 fa((unsigned char)1); + char1 fb((signed char)1); + char1 fc((unsigned short)1); + char1 fd((signed short)1); + char1 fe((unsigned int)1); + char1 fg((signed int)1); + char1 fh((float)1); + char1 fi((double)1); + char1 fj((unsigned long)1); + char1 fk((signed long)1); + char1 fl((unsigned long long)1); + char1 fm((signed long long)1); + + f1.x = 3; f2.x = 4; f3.x = 3; @@ -644,6 +946,79 @@ bool TestChar2() { cmpVal2(f2, (char)253); assert(!f1 == false); + f1.x = 3; + f1.y = 3; + f1 = f1 * (unsigned char)1; + cmpVal2(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed char)1; + cmpVal2(f1, 3); + f1 = (signed char)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal2(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed short)1; + cmpVal2(f1, 3); + f1 = (signed short)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal2(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed int)1; + cmpVal2(f1, 3); + f1 = (signed int)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (float)1; + cmpVal2(f1, 3); + f1 = (float)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal2(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed long)1; + cmpVal2(f1, 3); + f1 = (signed long)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (double)1; + cmpVal2(f1, 3); + f1 = (double)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal2(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal2(f1, 3); + + char2 fa1((unsigned char)1); + char2 fa2((unsigned char)1, (unsigned char)1); + char2 fb1((signed char)1); + char2 fb2((signed char)1, (signed char)1); + char2 fc1((unsigned short)1); + char2 fc2((unsigned short)1,(unsigned short)1); + char2 fd1((signed short)1); + char2 fd2((signed short)1, (signed short)1); + char2 fe1((unsigned int)1); + char2 fe2((unsigned int)1, (unsigned int)1); + char2 fg1((signed int)1); + char2 fg2((signed int)1, (signed int)1); + char2 fh1((float)1); + char2 fh2((float)1, (float)1); + char2 fi1((double)1); + char2 fi2((double)1, (double)1); + char2 fj1((unsigned long)1); + char2 fj2((unsigned long)1, (unsigned long)1); + char2 fk1((signed long)1); + char2 fk2((signed long)1, (signed long)1); + char2 fl1((unsigned long long)1); + char2 fl2((unsigned long long)1, (unsigned long long)1); + char2 fm1((signed long long)1); + char2 fm2((signed long long)1, (signed long long)1); + + f1.x = 3; f1.y = 3; f2.x = 4; @@ -745,6 +1120,80 @@ bool TestChar3() { cmpVal3(f2, (char)253); assert(!f1 == false); + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1 = f1 * (unsigned char)1; + cmpVal3(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed char)1; + cmpVal3(f1, 3); + f1 = (signed char)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal3(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed short)1; + cmpVal3(f1, 3); + f1 = (signed short)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal3(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed int)1; + cmpVal3(f1, 3); + f1 = (signed int)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (float)1; + cmpVal3(f1, 3); + f1 = (float)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal3(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed long)1; + cmpVal3(f1, 3); + f1 = (signed long)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (double)1; + cmpVal3(f1, 3); + f1 = (double)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal3(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal3(f1, 3); + + char3 fa1((unsigned char)1); + char3 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1); + char3 fb1((signed char)1); + char3 fb2((signed char)1, (signed char)1, (signed char)1); + char3 fc1((unsigned short)1); + char3 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1); + char3 fd1((signed short)1); + char3 fd2((signed short)1, (signed short)1, (signed short)1); + char3 fe1((unsigned int)1); + char3 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1); + char3 fg1((signed int)1); + char3 fg2((signed int)1, (signed int)1, (signed int)1); + char3 fh1((float)1); + char3 fh2((float)1, (float)1, (float)1); + char3 fi1((double)1); + char3 fi2((double)1, (double)1, (double)1); + char3 fj1((unsigned long)1); + char3 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1); + char3 fk1((signed long)1); + char3 fk2((signed long)1, (signed long)1, (signed long)1); + char3 fl1((unsigned long long)1); + char3 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + char3 fm1((signed long long)1); + char3 fm2((signed long long)1, (signed long long)1, (signed long long)1); + + f1.x = 3; f1.y = 3; f1.z = 3; @@ -857,6 +1306,81 @@ bool TestChar4() { cmpVal4(f2, (char)253); assert(!f1 == false); + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f1 = f1 * (unsigned char)1; + cmpVal4(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed char)1; + cmpVal4(f1, 3); + f1 = (signed char)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal4(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed short)1; + cmpVal4(f1, 3); + f1 = (signed short)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal4(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed int)1; + cmpVal4(f1, 3); + f1 = (signed int)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (float)1; + cmpVal4(f1, 3); + f1 = (float)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal4(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed long)1; + cmpVal4(f1, 3); + f1 = (signed long)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (double)1; + cmpVal4(f1, 3); + f1 = (double)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal4(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal4(f1, 3); + + char4 fa1((unsigned char)1); + char4 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1); + char4 fb1((signed char)1); + char4 fb2((signed char)1, (signed char)1, (signed char)1, (signed char)1); + char4 fc1((unsigned short)1); + char4 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1, (unsigned short)1); + char4 fd1((signed short)1); + char4 fd2((signed short)1, (signed short)1, (signed short)1, (signed short)1); + char4 fe1((unsigned int)1); + char4 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1, (unsigned int)1); + char4 fg1((signed int)1); + char4 fg2((signed int)1, (signed int)1, (signed int)1, (signed int)1); + char4 fh1((float)1); + char4 fh2((float)1, (float)1, (float)1, (float)1); + char4 fi1((double)1); + char4 fi2((double)1, (double)1, (double)1, (double)1); + char4 fj1((unsigned long)1); + char4 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1, (unsigned long)1); + char4 fk1((signed long)1); + char4 fk2((signed long)1, (signed long)1, (signed long)1, (signed long)1); + char4 fl1((unsigned long long)1); + char4 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + char4 fm1((signed long long)1); + char4 fm2((signed long long)1, (signed long long)1, (signed long long)1, (signed long long)1); + + f1.x = 3; f1.y = 3; f1.z = 3; @@ -881,6 +1405,7 @@ bool TestChar4() { return true; } + bool TestUShort1() { ushort1 f1, f2, f3; f1.x = 1; @@ -948,6 +1473,66 @@ bool TestUShort1() { cmpVal1(f2, (unsigned short)65533); assert(!f1 == false); + f1.x = 3; + f1 = f1 * (unsigned char)1; + cmpVal1(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed char)1; + cmpVal1(f1, 3); + f1 = (signed char)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal1(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed short)1; + cmpVal1(f1, 3); + f1 = (signed short)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal1(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed int)1; + cmpVal1(f1, 3); + f1 = (signed int)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (float)1; + cmpVal1(f1, 3); + f1 = (float)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal1(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed long)1; + cmpVal1(f1, 3); + f1 = (signed long)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (double)1; + cmpVal1(f1, 3); + f1 = (double)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal1(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal1(f1, 3); + + ushort1 fa((unsigned char)1); + ushort1 fb((signed char)1); + ushort1 fc((unsigned short)1); + ushort1 fd((signed short)1); + ushort1 fe((unsigned int)1); + ushort1 fg((signed int)1); + ushort1 fh((float)1); + ushort1 fi((double)1); + ushort1 fj((unsigned long)1); + ushort1 fk((signed long)1); + ushort1 fl((unsigned long long)1); + ushort1 fm((signed long long)1); + + f1.x = 3; f2.x = 4; f3.x = 3; @@ -1038,6 +1623,79 @@ bool TestUShort2() { cmpVal2(f2, (unsigned short)65533); assert(!f1 == false); + f1.x = 3; + f1.y = 3; + f1 = f1 * (unsigned char)1; + cmpVal2(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed char)1; + cmpVal2(f1, 3); + f1 = (signed char)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal2(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed short)1; + cmpVal2(f1, 3); + f1 = (signed short)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal2(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed int)1; + cmpVal2(f1, 3); + f1 = (signed int)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (float)1; + cmpVal2(f1, 3); + f1 = (float)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal2(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed long)1; + cmpVal2(f1, 3); + f1 = (signed long)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (double)1; + cmpVal2(f1, 3); + f1 = (double)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal2(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal2(f1, 3); + + ushort2 fa1((unsigned char)1); + ushort2 fa2((unsigned char)1, (unsigned char)1); + ushort2 fb1((signed char)1); + ushort2 fb2((signed char)1, (signed char)1); + ushort2 fc1((unsigned short)1); + ushort2 fc2((unsigned short)1, (unsigned short)1); + ushort2 fd1((signed short)1); + ushort2 fd2((signed short)1, (signed short)1); + ushort2 fe1((unsigned int)1); + ushort2 fe2((unsigned int)1, (unsigned int)1); + ushort2 fg1((signed int)1); + ushort2 fg2((signed int)1, (signed int)1); + ushort2 fh1((float)1); + ushort2 fh2((float)1, (float)1); + ushort2 fi1((double)1); + ushort2 fi2((double)1, (double)1); + ushort2 fj1((unsigned long)1); + ushort2 fj2((unsigned long)1, (unsigned long)1); + ushort2 fk1((signed long)1); + ushort2 fk2((signed long)1, (signed long)1); + ushort2 fl1((unsigned long long)1); + ushort2 fl2((unsigned long long)1, (unsigned long long)1); + ushort2 fm1((signed long long)1); + ushort2 fm2((signed long long)1, (signed long long)1); + + f1.x = 3; f1.y = 3; f2.x = 4; @@ -1139,6 +1797,80 @@ bool TestUShort3() { cmpVal3(f2, (unsigned short)65533); assert(!f1 == false); + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1 = f1 * (unsigned char)1; + cmpVal3(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed char)1; + cmpVal3(f1, 3); + f1 = (signed char)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal3(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed short)1; + cmpVal3(f1, 3); + f1 = (signed short)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal3(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed int)1; + cmpVal3(f1, 3); + f1 = (signed int)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (float)1; + cmpVal3(f1, 3); + f1 = (float)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal3(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed long)1; + cmpVal3(f1, 3); + f1 = (signed long)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (double)1; + cmpVal3(f1, 3); + f1 = (double)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal3(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal3(f1, 3); + + ushort3 fa1((unsigned char)1); + ushort3 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1); + ushort3 fb1((signed char)1); + ushort3 fb2((signed char)1, (signed char)1, (signed char)1); + ushort3 fc1((unsigned short)1); + ushort3 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1); + ushort3 fd1((signed short)1); + ushort3 fd2((signed short)1, (signed short)1, (signed short)1); + ushort3 fe1((unsigned int)1); + ushort3 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1); + ushort3 fg1((signed int)1); + ushort3 fg2((signed int)1, (signed int)1, (signed int)1); + ushort3 fh1((float)1); + ushort3 fh2((float)1, (float)1, (float)1); + ushort3 fi1((double)1); + ushort3 fi2((double)1, (double)1, (double)1); + ushort3 fj1((unsigned long)1); + ushort3 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1); + ushort3 fk1((signed long)1); + ushort3 fk2((signed long)1, (signed long)1, (signed long)1); + ushort3 fl1((unsigned long long)1); + ushort3 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + ushort3 fm1((signed long long)1); + ushort3 fm2((signed long long)1, (signed long long)1, (signed long long)1); + + f1.x = 3; f1.y = 3; f1.z = 3; @@ -1251,6 +1983,80 @@ bool TestUShort4() { cmpVal4(f2, (unsigned short)65533); assert(!f1 == false); + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f1 = f1 * (unsigned char)1; + cmpVal4(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed char)1; + cmpVal4(f1, 3); + f1 = (signed char)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal4(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed short)1; + cmpVal4(f1, 3); + f1 = (signed short)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal4(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed int)1; + cmpVal4(f1, 3); + f1 = (signed int)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (float)1; + cmpVal4(f1, 3); + f1 = (float)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal4(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed long)1; + cmpVal4(f1, 3); + f1 = (signed long)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (double)1; + cmpVal4(f1, 3); + f1 = (double)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal4(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal4(f1, 3); + + ushort4 fa1((unsigned char)1); + ushort4 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1); + ushort4 fb1((signed char)1); + ushort4 fb2((signed char)1, (signed char)1, (signed char)1, (signed char)1); + ushort4 fc1((unsigned short)1); + ushort4 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1, (unsigned short)1); + ushort4 fd1((signed short)1); + ushort4 fd2((signed short)1, (signed short)1, (signed short)1, (signed short)1); + ushort4 fe1((unsigned int)1); + ushort4 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1, (unsigned int)1); + ushort4 fg1((signed int)1); + ushort4 fg2((signed int)1, (signed int)1, (signed int)1, (signed int)1); + ushort4 fh1((float)1); + ushort4 fh2((float)1, (float)1, (float)1, (float)1); + ushort4 fi1((double)1); + ushort4 fi2((double)1, (double)1, (double)1, (double)1); + ushort4 fj1((unsigned long)1); + ushort4 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1, (unsigned long)1); + ushort4 fk1((signed long)1); + ushort4 fk2((signed long)1, (signed long)1, (signed long)1, (signed long)1); + ushort4 fl1((unsigned long long)1); + ushort4 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + ushort4 fm1((signed long long)1); + ushort4 fm2((signed long long)1, (signed long long)1, (signed long long)1, (signed long long)1); + f1.x = 3; f1.y = 3; f1.z = 3; @@ -1275,6 +2081,7 @@ bool TestUShort4() { return true; } + bool TestShort1() { short1 f1, f2, f3; f1.x = 1; @@ -1342,6 +2149,66 @@ bool TestShort1() { cmpVal1(f2, (signed short)65533); assert(!f1 == false); + f1.x = 3; + f1 = f1 * (unsigned char)1; + cmpVal1(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed char)1; + cmpVal1(f1, 3); + f1 = (signed char)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal1(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed short)1; + cmpVal1(f1, 3); + f1 = (signed short)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal1(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed int)1; + cmpVal1(f1, 3); + f1 = (signed int)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (float)1; + cmpVal1(f1, 3); + f1 = (float)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal1(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed long)1; + cmpVal1(f1, 3); + f1 = (signed long)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (double)1; + cmpVal1(f1, 3); + f1 = (double)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal1(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal1(f1, 3); + + short1 fa((unsigned char)1); + short1 fb((signed char)1); + short1 fc((unsigned short)1); + short1 fd((signed short)1); + short1 fe((unsigned int)1); + short1 fg((signed int)1); + short1 fh((float)1); + short1 fi((double)1); + short1 fj((unsigned long)1); + short1 fk((signed long)1); + short1 fl((unsigned long long)1); + short1 fm((signed long long)1); + + f1.x = 3; f2.x = 4; f3.x = 3; @@ -1432,6 +2299,80 @@ bool TestShort2() { cmpVal2(f2, (signed short)65533); assert(!f1 == false); + cmpVal2(f1, 3); + f1.x = 3; + f1.y = 3; + f1 = f1 * (unsigned char)1; + cmpVal2(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed char)1; + cmpVal2(f1, 3); + f1 = (signed char)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal2(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed short)1; + cmpVal2(f1, 3); + f1 = (signed short)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal2(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed int)1; + cmpVal2(f1, 3); + f1 = (signed int)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (float)1; + cmpVal2(f1, 3); + f1 = (float)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal2(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed long)1; + cmpVal2(f1, 3); + f1 = (signed long)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (double)1; + cmpVal2(f1, 3); + f1 = (double)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal2(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal2(f1, 3); + + short2 fa1((unsigned char)1); + short2 fa2((unsigned char)1, (unsigned char)1); + short2 fb1((signed char)1); + short2 fb2((signed char)1, (signed char)1); + short2 fc1((unsigned short)1); + short2 fc2((unsigned short)1,(unsigned short)1); + short2 fd1((signed short)1); + short2 fd2((signed short)1, (signed short)1); + short2 fe1((unsigned int)1); + short2 fe2((unsigned int)1, (unsigned int)1); + short2 fg1((signed int)1); + short2 fg2((signed int)1, (signed int)1); + short2 fh1((float)1); + short2 fh2((float)1, (float)1); + short2 fi1((double)1); + short2 fi2((double)1, (double)1); + short2 fj1((unsigned long)1); + short2 fj2((unsigned long)1, (unsigned long)1); + short2 fk1((signed long)1); + short2 fk2((signed long)1, (signed long)1); + short2 fl1((unsigned long long)1); + short2 fl2((unsigned long long)1, (unsigned long long)1); + short2 fm1((signed long long)1); + short2 fm2((signed long long)1, (signed long long)1); + + f1.x = 3; f1.y = 3; f2.x = 4; @@ -1533,6 +2474,79 @@ bool TestShort3() { cmpVal3(f2, (signed short)65533); assert(!f1 == false); + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1 = f1 * (unsigned char)1; + cmpVal3(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed char)1; + cmpVal3(f1, 3); + f1 = (signed char)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal3(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed short)1; + cmpVal3(f1, 3); + f1 = (signed short)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal3(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed int)1; + cmpVal3(f1, 3); + f1 = (signed int)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (float)1; + cmpVal3(f1, 3); + f1 = (float)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal3(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed long)1; + cmpVal3(f1, 3); + f1 = (signed long)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (double)1; + cmpVal3(f1, 3); + f1 = (double)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal3(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal3(f1, 3); + + short3 fa1((unsigned char)1); + short3 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1); + short3 fb1((signed char)1); + short3 fb2((signed char)1, (signed char)1, (signed char)1); + short3 fc1((unsigned short)1); + short3 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1); + short3 fd1((signed short)1); + short3 fd2((signed short)1, (signed short)1, (signed short)1); + short3 fe1((unsigned int)1); + short3 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1); + short3 fg1((signed int)1); + short3 fg2((signed int)1, (signed int)1, (signed int)1); + short3 fh1((float)1); + short3 fh2((float)1, (float)1, (float)1); + short3 fi1((double)1); + short3 fi2((double)1, (double)1, (double)1); + short3 fj1((unsigned long)1); + short3 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1); + short3 fk1((signed long)1); + short3 fk2((signed long)1, (signed long)1, (signed long)1); + short3 fl1((unsigned long long)1); + short3 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + short3 fm1((signed long long)1); + short3 fm2((signed long long)1, (signed long long)1, (signed long long)1); + f1.x = 3; f1.y = 3; f1.z = 3; @@ -1645,6 +2659,81 @@ bool TestShort4() { cmpVal4(f2, (signed short)65533); assert(!f1 == false); + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f1 = f1 * (unsigned char)1; + cmpVal4(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed char)1; + cmpVal4(f1, 3); + f1 = (signed char)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal4(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed short)1; + cmpVal4(f1, 3); + f1 = (signed short)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal4(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed int)1; + cmpVal4(f1, 3); + f1 = (signed int)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (float)1; + cmpVal4(f1, 3); + f1 = (float)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal4(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed long)1; + cmpVal4(f1, 3); + f1 = (signed long)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (double)1; + cmpVal4(f1, 3); + f1 = (double)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal4(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal4(f1, 3); + + short4 fa1((unsigned char)1); + short4 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1); + short4 fb1((signed char)1); + short4 fb2((signed char)1, (signed char)1, (signed char)1, (signed char)1); + short4 fc1((unsigned short)1); + short4 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1, (unsigned short)1); + short4 fd1((signed short)1); + short4 fd2((signed short)1, (signed short)1, (signed short)1, (signed short)1); + short4 fe1((unsigned int)1); + short4 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1, (unsigned int)1); + short4 fg1((signed int)1); + short4 fg2((signed int)1, (signed int)1, (signed int)1, (signed int)1); + short4 fh1((float)1); + short4 fh2((float)1, (float)1, (float)1, (float)1); + short4 fi1((double)1); + short4 fi2((double)1, (double)1, (double)1, (double)1); + short4 fj1((unsigned long)1); + short4 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1, (unsigned long)1); + short4 fk1((signed long)1); + short4 fk2((signed long)1, (signed long)1, (signed long)1, (signed long)1); + short4 fl1((unsigned long long)1); + short4 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + short4 fm1((signed long long)1); + short4 fm2((signed long long)1, (signed long long)1, (signed long long)1, (signed long long)1); + + f1.x = 3; f1.y = 3; f1.z = 3; @@ -1737,6 +2826,66 @@ bool TestUInt1() { cmpVal1(f2, (unsigned int)4294967293); assert(!f1 == false); + f1.x = 3; + f1 = f1 * (unsigned char)1; + cmpVal1(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed char)1; + cmpVal1(f1, 3); + f1 = (signed char)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal1(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed short)1; + cmpVal1(f1, 3); + f1 = (signed short)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal1(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed int)1; + cmpVal1(f1, 3); + f1 = (signed int)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (float)1; + cmpVal1(f1, 3); + f1 = (float)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal1(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed long)1; + cmpVal1(f1, 3); + f1 = (signed long)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (double)1; + cmpVal1(f1, 3); + f1 = (double)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal1(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal1(f1, 3); + + uint1 fa((unsigned char)1); + uint1 fb((signed char)1); + uint1 fc((unsigned short)1); + uint1 fd((signed short)1); + uint1 fe((unsigned int)1); + uint1 fg((signed int)1); + uint1 fh((float)1); + uint1 fi((double)1); + uint1 fj((unsigned long)1); + uint1 fk((signed long)1); + uint1 fl((unsigned long long)1); + uint1 fm((signed long long)1); + + f1.x = 3; f2.x = 4; f3.x = 3; @@ -1827,6 +2976,79 @@ bool TestUInt2() { cmpVal2(f2, (unsigned int)4294967293); assert(!f1 == false); + f1.x = 3; + f1.y = 3; + f1 = f1 * (unsigned char)1; + cmpVal2(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed char)1; + cmpVal2(f1, 3); + f1 = (signed char)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal2(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed short)1; + cmpVal2(f1, 3); + f1 = (signed short)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal2(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed int)1; + cmpVal2(f1, 3); + f1 = (signed int)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (float)1; + cmpVal2(f1, 3); + f1 = (float)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal2(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed long)1; + cmpVal2(f1, 3); + f1 = (signed long)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (double)1; + cmpVal2(f1, 3); + f1 = (double)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal2(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal2(f1, 3); + + uint2 fa1((unsigned char)1); + uint2 fa2((unsigned char)1, (unsigned char)1); + uint2 fb1((signed char)1); + uint2 fb2((signed char)1, (signed char)1); + uint2 fc1((unsigned short)1); + uint2 fc2((unsigned short)1,(unsigned short)1); + uint2 fd1((signed short)1); + uint2 fd2((signed short)1, (signed short)1); + uint2 fe1((unsigned int)1); + uint2 fe2((unsigned int)1, (unsigned int)1); + uint2 fg1((signed int)1); + uint2 fg2((signed int)1, (signed int)1); + uint2 fh1((float)1); + uint2 fh2((float)1, (float)1); + uint2 fi1((double)1); + uint2 fi2((double)1, (double)1); + uint2 fj1((unsigned long)1); + uint2 fj2((unsigned long)1, (unsigned long)1); + uint2 fk1((signed long)1); + uint2 fk2((signed long)1, (signed long)1); + uint2 fl1((unsigned long long)1); + uint2 fl2((unsigned long long)1, (unsigned long long)1); + uint2 fm1((signed long long)1); + uint2 fm2((signed long long)1, (signed long long)1); + + f1.x = 3; f1.y = 3; f2.x = 4; @@ -1928,6 +3150,80 @@ bool TestUInt3() { cmpVal3(f2, (unsigned int)4294967293); assert(!f1 == false); + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1 = f1 * (unsigned char)1; + cmpVal3(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed char)1; + cmpVal3(f1, 3); + f1 = (signed char)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal3(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed short)1; + cmpVal3(f1, 3); + f1 = (signed short)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal3(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed int)1; + cmpVal3(f1, 3); + f1 = (signed int)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (float)1; + cmpVal3(f1, 3); + f1 = (float)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal3(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed long)1; + cmpVal3(f1, 3); + f1 = (signed long)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (double)1; + cmpVal3(f1, 3); + f1 = (double)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal3(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal3(f1, 3); + + uint3 fa1((unsigned char)1); + uint3 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1); + uint3 fb1((signed char)1); + uint3 fb2((signed char)1, (signed char)1, (signed char)1); + uint3 fc1((unsigned short)1); + uint3 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1); + uint3 fd1((signed short)1); + uint3 fd2((signed short)1, (signed short)1, (signed short)1); + uint3 fe1((unsigned int)1); + uint3 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1); + uint3 fg1((signed int)1); + uint3 fg2((signed int)1, (signed int)1, (signed int)1); + uint3 fh1((float)1); + uint3 fh2((float)1, (float)1, (float)1); + uint3 fi1((double)1); + uint3 fi2((double)1, (double)1, (double)1); + uint3 fj1((unsigned long)1); + uint3 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1); + uint3 fk1((signed long)1); + uint3 fk2((signed long)1, (signed long)1, (signed long)1); + uint3 fl1((unsigned long long)1); + uint3 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + uint3 fm1((signed long long)1); + uint3 fm2((signed long long)1, (signed long long)1, (signed long long)1); + + f1.x = 3; f1.y = 3; f1.z = 3; @@ -2040,6 +3336,81 @@ bool TestUInt4() { cmpVal4(f2, (unsigned int)4294967293); assert(!f1 == false); + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f1 = f1 * (unsigned char)1; + cmpVal4(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed char)1; + cmpVal4(f1, 3); + f1 = (signed char)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal4(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed short)1; + cmpVal4(f1, 3); + f1 = (signed short)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal4(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed int)1; + cmpVal4(f1, 3); + f1 = (signed int)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (float)1; + cmpVal4(f1, 3); + f1 = (float)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal4(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed long)1; + cmpVal4(f1, 3); + f1 = (signed long)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (double)1; + cmpVal4(f1, 3); + f1 = (double)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal4(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal4(f1, 3); + + uint4 fa1((unsigned char)1); + uint4 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1); + uint4 fb1((signed char)1); + uint4 fb2((signed char)1, (signed char)1, (signed char)1, (signed char)1); + uint4 fc1((unsigned short)1); + uint4 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1, (unsigned short)1); + uint4 fd1((signed short)1); + uint4 fd2((signed short)1, (signed short)1, (signed short)1, (signed short)1); + uint4 fe1((unsigned int)1); + uint4 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1, (unsigned int)1); + uint4 fg1((signed int)1); + uint4 fg2((signed int)1, (signed int)1, (signed int)1, (signed int)1); + uint4 fh1((float)1); + uint4 fh2((float)1, (float)1, (float)1, (float)1); + uint4 fi1((double)1); + uint4 fi2((double)1, (double)1, (double)1, (double)1); + uint4 fj1((unsigned long)1); + uint4 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1, (unsigned long)1); + uint4 fk1((signed long)1); + uint4 fk2((signed long)1, (signed long)1, (signed long)1, (signed long)1); + uint4 fl1((unsigned long long)1); + uint4 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + uint4 fm1((signed long long)1); + uint4 fm2((signed long long)1, (signed long long)1, (signed long long)1, (signed long long)1); + + f1.x = 3; f1.y = 3; f1.z = 3; @@ -2064,6 +3435,7 @@ bool TestUInt4() { return true; } + bool TestInt1() { int1 f1, f2, f3; f1.x = 1; @@ -2131,6 +3503,66 @@ bool TestInt1() { cmpVal1(f2, (signed int)4294967293); assert(!f1 == false); + f1.x = 3; + f1 = f1 * (unsigned char)1; + cmpVal1(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed char)1; + cmpVal1(f1, 3); + f1 = (signed char)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal1(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed short)1; + cmpVal1(f1, 3); + f1 = (signed short)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal1(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed int)1; + cmpVal1(f1, 3); + f1 = (signed int)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (float)1; + cmpVal1(f1, 3); + f1 = (float)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal1(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed long)1; + cmpVal1(f1, 3); + f1 = (signed long)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (double)1; + cmpVal1(f1, 3); + f1 = (double)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal1(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal1(f1, 3); + + int1 fa((unsigned char)1); + int1 fb((signed char)1); + int1 fc((unsigned short)1); + int1 fd((signed short)1); + int1 fe((unsigned int)1); + int1 fg((signed int)1); + int1 fh((float)1); + int1 fi((double)1); + int1 fj((unsigned long)1); + int1 fk((signed long)1); + int1 fl((unsigned long long)1); + int1 fm((signed long long)1); + + f1.x = 3; f2.x = 4; f3.x = 3; @@ -2221,6 +3653,79 @@ bool TestInt2() { cmpVal2(f2, (signed int)4294967293); assert(!f1 == false); + f1.x = 3; + f1.y = 3; + f1 = f1 * (unsigned char)1; + cmpVal2(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed char)1; + cmpVal2(f1, 3); + f1 = (signed char)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal2(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed short)1; + cmpVal2(f1, 3); + f1 = (signed short)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal2(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed int)1; + cmpVal2(f1, 3); + f1 = (signed int)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (float)1; + cmpVal2(f1, 3); + f1 = (float)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal2(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed long)1; + cmpVal2(f1, 3); + f1 = (signed long)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (double)1; + cmpVal2(f1, 3); + f1 = (double)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal2(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal2(f1, 3); + + int2 fa1((unsigned char)1); + int2 fa2((unsigned char)1, (unsigned char)1); + int2 fb1((signed char)1); + int2 fb2((signed char)1, (signed char)1); + int2 fc1((unsigned short)1); + int2 fc2((unsigned short)1,(unsigned short)1); + int2 fd1((signed short)1); + int2 fd2((signed short)1, (signed short)1); + int2 fe1((unsigned int)1); + int2 fe2((unsigned int)1, (unsigned int)1); + int2 fg1((signed int)1); + int2 fg2((signed int)1, (signed int)1); + int2 fh1((float)1); + int2 fh2((float)1, (float)1); + int2 fi1((double)1); + int2 fi2((double)1, (double)1); + int2 fj1((unsigned long)1); + int2 fj2((unsigned long)1, (unsigned long)1); + int2 fk1((signed long)1); + int2 fk2((signed long)1, (signed long)1); + int2 fl1((unsigned long long)1); + int2 fl2((unsigned long long)1, (unsigned long long)1); + int2 fm1((signed long long)1); + int2 fm2((signed long long)1, (signed long long)1); + + f1.x = 3; f1.y = 3; f2.x = 4; @@ -2322,6 +3827,80 @@ bool TestInt3() { cmpVal3(f2, (signed int)4294967293); assert(!f1 == false); + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1 = f1 * (unsigned char)1; + cmpVal3(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed char)1; + cmpVal3(f1, 3); + f1 = (signed char)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal3(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed short)1; + cmpVal3(f1, 3); + f1 = (signed short)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal3(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed int)1; + cmpVal3(f1, 3); + f1 = (signed int)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (float)1; + cmpVal3(f1, 3); + f1 = (float)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal3(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed long)1; + cmpVal3(f1, 3); + f1 = (signed long)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (double)1; + cmpVal3(f1, 3); + f1 = (double)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal3(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal3(f1, 3); + + int3 fa1((unsigned char)1); + int3 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1); + int3 fb1((signed char)1); + int3 fb2((signed char)1, (signed char)1, (signed char)1); + int3 fc1((unsigned short)1); + int3 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1); + int3 fd1((signed short)1); + int3 fd2((signed short)1, (signed short)1, (signed short)1); + int3 fe1((unsigned int)1); + int3 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1); + int3 fg1((signed int)1); + int3 fg2((signed int)1, (signed int)1, (signed int)1); + int3 fh1((float)1); + int3 fh2((float)1, (float)1, (float)1); + int3 fi1((double)1); + int3 fi2((double)1, (double)1, (double)1); + int3 fj1((unsigned long)1); + int3 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1); + int3 fk1((signed long)1); + int3 fk2((signed long)1, (signed long)1, (signed long)1); + int3 fl1((unsigned long long)1); + int3 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + int3 fm1((signed long long)1); + int3 fm2((signed long long)1, (signed long long)1, (signed long long)1); + + f1.x = 3; f1.y = 3; f1.z = 3; @@ -2434,6 +4013,81 @@ bool TestInt4() { cmpVal4(f2, (signed int)4294967293); assert(!f1 == false); + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f1 = f1 * (unsigned char)1; + cmpVal4(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed char)1; + cmpVal4(f1, 3); + f1 = (signed char)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal4(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed short)1; + cmpVal4(f1, 3); + f1 = (signed short)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal4(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed int)1; + cmpVal4(f1, 3); + f1 = (signed int)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (float)1; + cmpVal4(f1, 3); + f1 = (float)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal4(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed long)1; + cmpVal4(f1, 3); + f1 = (signed long)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (double)1; + cmpVal4(f1, 3); + f1 = (double)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal4(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal4(f1, 3); + + int4 fa1((unsigned char)1); + int4 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1); + int4 fb1((signed char)1); + int4 fb2((signed char)1, (signed char)1, (signed char)1, (signed char)1); + int4 fc1((unsigned short)1); + int4 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1, (unsigned short)1); + int4 fd1((signed short)1); + int4 fd2((signed short)1, (signed short)1, (signed short)1, (signed short)1); + int4 fe1((unsigned int)1); + int4 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1, (unsigned int)1); + int4 fg1((signed int)1); + int4 fg2((signed int)1, (signed int)1, (signed int)1, (signed int)1); + int4 fh1((float)1); + int4 fh2((float)1, (float)1, (float)1, (float)1); + int4 fi1((double)1); + int4 fi2((double)1, (double)1, (double)1, (double)1); + int4 fj1((unsigned long)1); + int4 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1, (unsigned long)1); + int4 fk1((signed long)1); + int4 fk2((signed long)1, (signed long)1, (signed long)1, (signed long)1); + int4 fl1((unsigned long long)1); + int4 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + int4 fm1((signed long long)1); + int4 fm2((signed long long)1, (signed long long)1, (signed long long)1, (signed long long)1); + + f1.x = 3; f1.y = 3; f1.z = 3; @@ -2458,6 +4112,505 @@ bool TestInt4() { return true; } + +bool TestFloat1() { + float1 f1, f2, f3; + f1.x = 1.0f; + f2.x = 1.0f; + f3 = f1 + f2; + cmpVal1(f3, 2.0f); + f2 = f3 - f1; + cmpVal1(f2, 1.0f); + f1 = f2 * f3; + cmpVal1(f1, 2.0f); + f2 = f1 / f3; + cmpVal1(f2, 2.0f/2.0f); + f1 += f2; + cmpVal1(f1, 3.0f); + f1 -= f2; + cmpVal1(f1, 2.0f); + f1 *= f2; + cmpVal1(f1, 2.0f); + f1 /= f2; + cmpVal1(f1, 2.0f); + f2 = f1++; + cmpVal1(f1, 3.0f); + cmpVal1(f2, 2.0f); + f2 = f1--; + cmpVal1(f2, 3.0f); + cmpVal1(f1, 2.0f); + f2 = ++f1; + cmpVal1(f1, 3.0f); + cmpVal1(f2, 3.0f); + f2 = --f1; + cmpVal1(f1, 2.0f); + cmpVal1(f1, 2.0f); + + f1.x = 3.0f; + f1 = f1 * (unsigned char)1; + cmpVal1(f1, 3.0f); + f1 = (unsigned char)1 * f1; + cmpVal1(f1, 3.0f); + f1 = f1 * (signed char)1; + cmpVal1(f1, 3.0f); + f1 = (signed char)1 * f1; + cmpVal1(f1, 3.0f); + f1 = f1 * (unsigned short)1; + cmpVal1(f1, 3.0f); + f1 = (unsigned short)1 * f1; + cmpVal1(f1, 3.0f); + f1 = f1 * (signed short)1; + cmpVal1(f1, 3.0f); + f1 = (signed short)1 * f1; + cmpVal1(f1, 3.0f); + f1 = f1 * (unsigned int)1; + cmpVal1(f1, 3.0f); + f1 = (unsigned int)1 * f1; + cmpVal1(f1, 3.0f); + f1 = f1 * (signed int)1; + cmpVal1(f1, 3.0f); + f1 = (signed int)1 * f1; + cmpVal1(f1, 3.0f); + f1 = f1 * (float)1; + cmpVal1(f1, 3.0f); + f1 = (float)1 * f1; + cmpVal1(f1, 3.0f); + f1 = f1 * (unsigned long)1; + cmpVal1(f1, 3.0f); + f1 = (unsigned long)1 * f1; + cmpVal1(f1, 3.0f); + f1 = f1 * (signed long)1; + cmpVal1(f1, 3.0f); + f1 = (signed long)1 * f1; + cmpVal1(f1, 3.0f); + f1 = f1 * (double)1; + cmpVal1(f1, 3.0f); + f1 = (double)1 * f1; + cmpVal1(f1, 3.0f); + f1 = f1 * (unsigned long long)1; + cmpVal1(f1, 3.0f); + f1 = (unsigned long long)1 * f1; + cmpVal1(f1, 3.0f); + + float1 fa((unsigned char)1); + float1 fb((signed char)1); + float1 fc((unsigned short)1); + float1 fd((signed short)1); + float1 fe((unsigned int)1); + float1 fg((signed int)1); + float1 fh((float)1); + float1 fi((double)1); + float1 fj((unsigned long)1); + float1 fk((signed long)1); + float1 fl((unsigned long long)1); + float1 fm((signed long long)1); + + + f1.x = 3.0f; + f2.x = 4.0f; + f3.x = 3.0f; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + return true; +} + +bool TestFloat2() { + float2 f1, f2, f3; + f1.x = 1.0f; + f1.y = 1.0f; + f2.x = 1.0f; + f2.y = 1.0f; + f3 = f1 + f2; + cmpVal2(f3, 2.0f); + f2 = f3 - f1; + cmpVal2(f2, 1.0f); + f1 = f2 * f3; + cmpVal2(f1, 2.0f); + f2 = f1 / f3; + cmpVal2(f2, 2.0f/2.0f); + f1 += f2; + cmpVal2(f1, 3.0f); + f1 -= f2; + cmpVal2(f1, 2.0f); + f1 *= f2; + cmpVal2(f1, 2.0f); + f1 /= f2; + cmpVal2(f1, 2.0f); + + f2 = f1++; + cmpVal2(f1, 3.0f); + cmpVal2(f2, 2.0f); + f2 = f1--; + cmpVal2(f2, 3.0f); + cmpVal2(f1, 2.0f); + f2 = ++f1; + cmpVal2(f1, 3.0f); + cmpVal2(f2, 3.0f); + f2 = --f1; + cmpVal2(f1, 2.0f); + cmpVal2(f1, 2.0f); + + f1.x = 3.0f; + f1.y = 3.0f; + f1 = f1 * (unsigned char)1; + cmpVal2(f1, 3.0f); + f1 = (unsigned char)1 * f1; + cmpVal2(f1, 3.0f); + f1 = f1 * (signed char)1; + cmpVal2(f1, 3.0f); + f1 = (signed char)1 * f1; + cmpVal2(f1, 3.0f); + f1 = f1 * (unsigned short)1; + cmpVal2(f1, 3.0f); + f1 = (unsigned short)1 * f1; + cmpVal2(f1, 3.0f); + f1 = f1 * (signed short)1; + cmpVal2(f1, 3.0f); + f1 = (signed short)1 * f1; + cmpVal2(f1, 3.0f); + f1 = f1 * (unsigned int)1; + cmpVal2(f1, 3.0f); + f1 = (unsigned int)1 * f1; + cmpVal2(f1, 3.0f); + f1 = f1 * (signed int)1; + cmpVal2(f1, 3.0f); + f1 = (signed int)1 * f1; + cmpVal2(f1, 3.0f); + f1 = f1 * (float)1; + cmpVal2(f1, 3.0f); + f1 = (float)1 * f1; + cmpVal2(f1, 3.0f); + f1 = f1 * (unsigned long)1; + cmpVal2(f1, 3.0f); + f1 = (unsigned long)1 * f1; + cmpVal2(f1, 3.0f); + f1 = f1 * (signed long)1; + cmpVal2(f1, 3.0f); + f1 = (signed long)1 * f1; + cmpVal2(f1, 3.0f); + f1 = f1 * (double)1; + cmpVal2(f1, 3.0f); + f1 = (double)1 * f1; + cmpVal2(f1, 3.0f); + f1 = f1 * (unsigned long long)1; + cmpVal2(f1, 3.0f); + f1 = (unsigned long long)1 * f1; + cmpVal2(f1, 3.0f); + + float2 fa1((unsigned char)1); + float2 fa2((unsigned char)1, (unsigned char)1); + float2 fb1((signed char)1); + float2 fb2((signed char)1, (signed char)1); + float2 fc1((unsigned short)1); + float2 fc2((unsigned short)1,(unsigned short)1); + float2 fd1((signed short)1); + float2 fd2((signed short)1, (signed short)1); + float2 fe1((unsigned int)1); + float2 fe2((unsigned int)1, (unsigned int)1); + float2 fg1((signed int)1); + float2 fg2((signed int)1, (signed int)1); + float2 fh1((float)1); + float2 fh2((float)1, (float)1); + float2 fi1((double)1); + float2 fi2((double)1, (double)1); + float2 fj1((unsigned long)1); + float2 fj2((unsigned long)1, (unsigned long)1); + float2 fk1((signed long)1); + float2 fk2((signed long)1, (signed long)1); + float2 fl1((unsigned long long)1); + float2 fl2((unsigned long long)1, (unsigned long long)1); + float2 fm1((signed long long)1); + float2 fm2((signed long long)1, (signed long long)1); + + + f1.x = 3.0f; + f1.y = 3.0f; + f2.x = 4.0f; + f2.y = 4.0f; + f3.x = 3.0f; + f3.y = 3.0f; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + + return true; +} + +bool TestFloat3() { + float3 f1, f2, f3; + f1.x = 1.0f; + f1.y = 1.0f; + f1.z = 1.0f; + f2.x = 1.0f; + f2.y = 1.0f; + f2.z = 1.0f; + f3 = f1 + f2; + cmpVal3(f3, 2.0f); + f2 = f3 - f1; + cmpVal3(f2, 1.0f); + f1 = f2 * f3; + cmpVal3(f1, 2.0f); + f2 = f1 / f3; + cmpVal3(f2, 2.0f/2.0f); + f1 += f2; + cmpVal3(f1, 3.0f); + f1 -= f2; + cmpVal3(f1, 2.0f); + f1 *= f2; + cmpVal3(f1, 2.0f); + f1 /= f2; + f2 = f1++; + cmpVal3(f1, 3.0f); + cmpVal3(f2, 2.0f); + f2 = f1--; + cmpVal3(f2, 3.0f); + cmpVal3(f1, 2.0f); + f2 = ++f1; + cmpVal3(f1, 3.0f); + cmpVal3(f2, 3.0f); + f2 = --f1; + cmpVal3(f1, 2.0f); + cmpVal3(f1, 2.0f); + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1 = f1 * (unsigned char)1; + cmpVal3(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed char)1; + cmpVal3(f1, 3); + f1 = (signed char)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal3(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed short)1; + cmpVal3(f1, 3); + f1 = (signed short)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal3(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed int)1; + cmpVal3(f1, 3); + f1 = (signed int)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (float)1; + cmpVal3(f1, 3); + f1 = (float)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal3(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed long)1; + cmpVal3(f1, 3); + f1 = (signed long)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (double)1; + cmpVal3(f1, 3); + f1 = (double)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal3(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal3(f1, 3); + + float3 fa1((unsigned char)1); + float3 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1); + float3 fb1((signed char)1); + float3 fb2((signed char)1, (signed char)1, (signed char)1); + float3 fc1((unsigned short)1); + float3 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1); + float3 fd1((signed short)1); + float3 fd2((signed short)1, (signed short)1, (signed short)1); + float3 fe1((unsigned int)1); + float3 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1); + float3 fg1((signed int)1); + float3 fg2((signed int)1, (signed int)1, (signed int)1); + float3 fh1((float)1); + float3 fh2((float)1, (float)1, (float)1); + float3 fi1((double)1); + float3 fi2((double)1, (double)1, (double)1); + float3 fj1((unsigned long)1); + float3 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1); + float3 fk1((signed long)1); + float3 fk2((signed long)1, (signed long)1, (signed long)1); + float3 fl1((unsigned long long)1); + float3 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + float3 fm1((signed long long)1); + float3 fm2((signed long long)1, (signed long long)1, (signed long long)1); + + + f1.x = 3.0f; + f1.y = 3.0f; + f1.z = 3.0f; + f2.x = 4.0f; + f2.y = 4.0f; + f2.z = 4.0f; + f3.x = 3.0f; + f3.y = 3.0f; + f3.z = 3.0f; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + + return true; +} + +bool TestFloat4() { + float4 f1, f2, f3; + f1.x = 1.0f; + f1.y = 1.0f; + f1.z = 1.0f; + f1.w = 1.0f; + f2.x = 1.0f; + f2.y = 1.0f; + f2.z = 1.0f; + f2.w = 1.0f; + f3 = f1 + f2; + cmpVal4(f3, 2.0f); + f2 = f3 - f1; + cmpVal4(f2, 1.0f); + f1 = f2 * f3; + cmpVal4(f1, 2.0f); + f2 = f1 / f3; + cmpVal4(f2, 2.0f/2.0f); + f1 += f2; + cmpVal4(f1, 3.0f); + f1 -= f2; + cmpVal4(f1, 2.0f); + f1 *= f2; + cmpVal4(f1, 2.0f); + f1 /= f2; + f2 = f1++; + cmpVal4(f1, 3.0f); + cmpVal4(f2, 2.0f); + f2 = f1--; + cmpVal4(f2, 3.0f); + cmpVal4(f1, 2.0f); + f2 = ++f1; + cmpVal4(f1, 3.0f); + cmpVal4(f2, 3.0f); + f2 = --f1; + cmpVal4(f1, 2.0f); + cmpVal4(f1, 2.0f); + + f1.x = 3.0f; + f1.y = 3.0f; + f1.z = 3.0f; + f1.w = 3.0f; + f1 = f1 * (unsigned char)1; + cmpVal4(f1, 3.0f); + f1 = (unsigned char)1 * f1; + cmpVal4(f1, 3.0f); + f1 = f1 * (signed char)1; + cmpVal4(f1, 3.0f); + f1 = (signed char)1 * f1; + cmpVal4(f1, 3.0f); + f1 = f1 * (unsigned short)1; + cmpVal4(f1, 3.0f); + f1 = (unsigned short)1 * f1; + cmpVal4(f1, 3.0f); + f1 = f1 * (signed short)1; + cmpVal4(f1, 3.0f); + f1 = (signed short)1 * f1; + cmpVal4(f1, 3.0f); + f1 = f1 * (unsigned int)1; + cmpVal4(f1, 3.0f); + f1 = (unsigned int)1 * f1; + cmpVal4(f1, 3.0f); + f1 = f1 * (signed int)1; + cmpVal4(f1, 3.0f); + f1 = (signed int)1 * f1; + cmpVal4(f1, 3.0f); + f1 = f1 * (float)1; + cmpVal4(f1, 3.0f); + f1 = (float)1 * f1; + cmpVal4(f1, 3.0f); + f1 = f1 * (unsigned long)1; + cmpVal4(f1, 3.0f); + f1 = (unsigned long)1 * f1; + cmpVal4(f1, 3.0f); + f1 = f1 * (signed long)1; + cmpVal4(f1, 3.0f); + f1 = (signed long)1 * f1; + cmpVal4(f1, 3.0f); + f1 = f1 * (double)1; + cmpVal4(f1, 3.0f); + f1 = (double)1 * f1; + cmpVal4(f1, 3.0f); + f1 = f1 * (unsigned long long)1; + cmpVal4(f1, 3.0f); + f1 = (unsigned long long)1 * f1; + cmpVal4(f1, 3.0f); + + float4 fa1((unsigned char)1); + float4 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1); + float4 fb1((signed char)1); + float4 fb2((signed char)1, (signed char)1, (signed char)1, (signed char)1); + float4 fc1((unsigned short)1); + float4 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1, (unsigned short)1); + float4 fd1((signed short)1); + float4 fd2((signed short)1, (signed short)1, (signed short)1, (signed short)1); + float4 fe1((unsigned int)1); + float4 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1, (unsigned int)1); + float4 fg1((signed int)1); + float4 fg2((signed int)1, (signed int)1, (signed int)1, (signed int)1); + float4 fh1((float)1); + float4 fh2((float)1, (float)1, (float)1, (float)1); + float4 fi1((double)1); + float4 fi2((double)1, (double)1, (double)1, (double)1); + float4 fj1((unsigned long)1); + float4 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1, (unsigned long)1); + float4 fk1((signed long)1); + float4 fk2((signed long)1, (signed long)1, (signed long)1, (signed long)1); + float4 fl1((unsigned long long)1); + float4 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + float4 fm1((signed long long)1); + float4 fm2((signed long long)1, (signed long long)1, (signed long long)1, (signed long long)1); + + + f1.x = 3.0f; + f1.y = 3.0f; + f1.z = 3.0f; + f1.w = 3.0f; + f2.x = 4.0f; + f2.y = 4.0f; + f2.z = 4.0f; + f2.w = 4.0f; + f3.x = 3.0f; + f3.y = 3.0f; + f3.z = 3.0f; + f3.w = 3.0f; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + return true; +} + + bool TestULong1() { ulong1 f1, f2, f3; f1.x = 1; @@ -2525,6 +4678,66 @@ bool TestULong1() { cmpVal1(f2, 18446744073709551613UL); assert(!f1 == false); + f1.x = 3; + f1 = f1 * (unsigned char)1; + cmpVal1(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed char)1; + cmpVal1(f1, 3); + f1 = (signed char)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal1(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed short)1; + cmpVal1(f1, 3); + f1 = (signed short)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal1(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed int)1; + cmpVal1(f1, 3); + f1 = (signed int)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (float)1; + cmpVal1(f1, 3); + f1 = (float)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal1(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed long)1; + cmpVal1(f1, 3); + f1 = (signed long)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (double)1; + cmpVal1(f1, 3); + f1 = (double)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal1(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal1(f1, 3); + + ulong1 fa((unsigned char)1); + ulong1 fb((signed char)1); + ulong1 fc((unsigned short)1); + ulong1 fd((signed short)1); + ulong1 fe((unsigned int)1); + ulong1 fg((signed int)1); + ulong1 fh((float)1); + ulong1 fi((double)1); + ulong1 fj((unsigned long)1); + ulong1 fk((signed long)1); + ulong1 fl((unsigned long long)1); + ulong1 fm((signed long long)1); + + f1.x = 3; f2.x = 4; f3.x = 3; @@ -2615,6 +4828,79 @@ bool TestULong2() { cmpVal2(f2, 18446744073709551613UL); assert(!f1 == false); + f1.x = 3; + f1.y = 3; + f1 = f1 * (unsigned char)1; + cmpVal2(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed char)1; + cmpVal2(f1, 3); + f1 = (signed char)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal2(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed short)1; + cmpVal2(f1, 3); + f1 = (signed short)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal2(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed int)1; + cmpVal2(f1, 3); + f1 = (signed int)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (float)1; + cmpVal2(f1, 3); + f1 = (float)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal2(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed long)1; + cmpVal2(f1, 3); + f1 = (signed long)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (double)1; + cmpVal2(f1, 3); + f1 = (double)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal2(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal2(f1, 3); + + ulong2 fa1((unsigned char)1); + ulong2 fa2((unsigned char)1, (unsigned char)1); + ulong2 fb1((signed char)1); + ulong2 fb2((signed char)1, (signed char)1); + ulong2 fc1((unsigned short)1); + ulong2 fc2((unsigned short)1,(unsigned short)1); + ulong2 fd1((signed short)1); + ulong2 fd2((signed short)1, (signed short)1); + ulong2 fe1((unsigned int)1); + ulong2 fe2((unsigned int)1, (unsigned int)1); + ulong2 fg1((signed int)1); + ulong2 fg2((signed int)1, (signed int)1); + ulong2 fh1((float)1); + ulong2 fh2((float)1, (float)1); + ulong2 fi1((double)1); + ulong2 fi2((double)1, (double)1); + ulong2 fj1((unsigned long)1); + ulong2 fj2((unsigned long)1, (unsigned long)1); + ulong2 fk1((signed long)1); + ulong2 fk2((signed long)1, (signed long)1); + ulong2 fl1((unsigned long long)1); + ulong2 fl2((unsigned long long)1, (unsigned long long)1); + ulong2 fm1((signed long long)1); + ulong2 fm2((signed long long)1, (signed long long)1); + + f1.x = 3; f1.y = 3; f2.x = 4; @@ -2716,6 +5002,80 @@ bool TestULong3() { cmpVal3(f2, 18446744073709551613UL); assert(!f1 == false); + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1 = f1 * (unsigned char)1; + cmpVal3(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed char)1; + cmpVal3(f1, 3); + f1 = (signed char)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal3(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed short)1; + cmpVal3(f1, 3); + f1 = (signed short)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal3(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed int)1; + cmpVal3(f1, 3); + f1 = (signed int)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (float)1; + cmpVal3(f1, 3); + f1 = (float)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal3(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed long)1; + cmpVal3(f1, 3); + f1 = (signed long)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (double)1; + cmpVal3(f1, 3); + f1 = (double)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal3(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal3(f1, 3); + + ulong3 fa1((unsigned char)1); + ulong3 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1); + ulong3 fb1((signed char)1); + ulong3 fb2((signed char)1, (signed char)1, (signed char)1); + ulong3 fc1((unsigned short)1); + ulong3 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1); + ulong3 fd1((signed short)1); + ulong3 fd2((signed short)1, (signed short)1, (signed short)1); + ulong3 fe1((unsigned int)1); + ulong3 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1); + ulong3 fg1((signed int)1); + ulong3 fg2((signed int)1, (signed int)1, (signed int)1); + ulong3 fh1((float)1); + ulong3 fh2((float)1, (float)1, (float)1); + ulong3 fi1((double)1); + ulong3 fi2((double)1, (double)1, (double)1); + ulong3 fj1((unsigned long)1); + ulong3 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1); + ulong3 fk1((signed long)1); + ulong3 fk2((signed long)1, (signed long)1, (signed long)1); + ulong3 fl1((unsigned long long)1); + ulong3 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + ulong3 fm1((signed long long)1); + ulong3 fm2((signed long long)1, (signed long long)1, (signed long long)1); + + f1.x = 3; f1.y = 3; f1.z = 3; @@ -2828,6 +5188,81 @@ bool TestULong4() { cmpVal4(f2, 18446744073709551613UL); assert(!f1 == false); + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f1 = f1 * (unsigned char)1; + cmpVal4(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed char)1; + cmpVal4(f1, 3); + f1 = (signed char)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal4(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed short)1; + cmpVal4(f1, 3); + f1 = (signed short)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal4(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed int)1; + cmpVal4(f1, 3); + f1 = (signed int)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (float)1; + cmpVal4(f1, 3); + f1 = (float)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal4(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed long)1; + cmpVal4(f1, 3); + f1 = (signed long)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (double)1; + cmpVal4(f1, 3); + f1 = (double)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal4(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal4(f1, 3); + + ulong4 fa1((unsigned char)1); + ulong4 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1); + ulong4 fb1((signed char)1); + ulong4 fb2((signed char)1, (signed char)1, (signed char)1, (signed char)1); + ulong4 fc1((unsigned short)1); + ulong4 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1, (unsigned short)1); + ulong4 fd1((signed short)1); + ulong4 fd2((signed short)1, (signed short)1, (signed short)1, (signed short)1); + ulong4 fe1((unsigned int)1); + ulong4 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1, (unsigned int)1); + ulong4 fg1((signed int)1); + ulong4 fg2((signed int)1, (signed int)1, (signed int)1, (signed int)1); + ulong4 fh1((float)1); + ulong4 fh2((float)1, (float)1, (float)1, (float)1); + ulong4 fi1((double)1); + ulong4 fi2((double)1, (double)1, (double)1, (double)1); + ulong4 fj1((unsigned long)1); + ulong4 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1, (unsigned long)1); + ulong4 fk1((signed long)1); + ulong4 fk2((signed long)1, (signed long)1, (signed long)1, (signed long)1); + ulong4 fl1((unsigned long long)1); + ulong4 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + ulong4 fm1((signed long long)1); + ulong4 fm2((signed long long)1, (signed long long)1, (signed long long)1, (signed long long)1); + + f1.x = 3; f1.y = 3; f1.z = 3; @@ -2852,6 +5287,7 @@ bool TestULong4() { return true; } + bool TestLong1() { long1 f1, f2, f3; f1.x = 1; @@ -2919,6 +5355,66 @@ bool TestLong1() { cmpVal1(f2, -3); assert(!f1 == false); + f1.x = 3; + f1 = f1 * (unsigned char)1; + cmpVal1(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed char)1; + cmpVal1(f1, 3); + f1 = (signed char)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal1(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed short)1; + cmpVal1(f1, 3); + f1 = (signed short)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal1(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed int)1; + cmpVal1(f1, 3); + f1 = (signed int)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (float)1; + cmpVal1(f1, 3); + f1 = (float)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal1(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed long)1; + cmpVal1(f1, 3); + f1 = (signed long)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (double)1; + cmpVal1(f1, 3); + f1 = (double)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal1(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal1(f1, 3); + + long1 fa((unsigned char)1); + long1 fb((signed char)1); + long1 fc((unsigned short)1); + long1 fd((signed short)1); + long1 fe((unsigned int)1); + long1 fg((signed int)1); + long1 fh((float)1); + long1 fi((double)1); + long1 fj((unsigned long)1); + long1 fk((signed long)1); + long1 fl((unsigned long long)1); + long1 fm((signed long long)1); + + f1.x = 3; f2.x = 4; f3.x = 3; @@ -3009,6 +5505,79 @@ bool TestLong2() { cmpVal2(f2, -3); assert(!f1 == false); + f1.x = 3; + f1.y = 3; + f1 = f1 * (unsigned char)1; + cmpVal2(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed char)1; + cmpVal2(f1, 3); + f1 = (signed char)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal2(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed short)1; + cmpVal2(f1, 3); + f1 = (signed short)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal2(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed int)1; + cmpVal2(f1, 3); + f1 = (signed int)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (float)1; + cmpVal2(f1, 3); + f1 = (float)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal2(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed long)1; + cmpVal2(f1, 3); + f1 = (signed long)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (double)1; + cmpVal2(f1, 3); + f1 = (double)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal2(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal2(f1, 3); + + long2 fa1((unsigned char)1); + long2 fa2((unsigned char)1, (unsigned char)1); + long2 fb1((signed char)1); + long2 fb2((signed char)1, (signed char)1); + long2 fc1((unsigned short)1); + long2 fc2((unsigned short)1,(unsigned short)1); + long2 fd1((signed short)1); + long2 fd2((signed short)1, (signed short)1); + long2 fe1((unsigned int)1); + long2 fe2((unsigned int)1, (unsigned int)1); + long2 fg1((signed int)1); + long2 fg2((signed int)1, (signed int)1); + long2 fh1((float)1); + long2 fh2((float)1, (float)1); + long2 fi1((double)1); + long2 fi2((double)1, (double)1); + long2 fj1((unsigned long)1); + long2 fj2((unsigned long)1, (unsigned long)1); + long2 fk1((signed long)1); + long2 fk2((signed long)1, (signed long)1); + long2 fl1((unsigned long long)1); + long2 fl2((unsigned long long)1, (unsigned long long)1); + long2 fm1((signed long long)1); + long2 fm2((signed long long)1, (signed long long)1); + + f1.x = 3; f1.y = 3; f2.x = 4; @@ -3110,6 +5679,80 @@ bool TestLong3() { cmpVal3(f2, -3); assert(!f1 == false); + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1 = f1 * (unsigned char)1; + cmpVal3(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed char)1; + cmpVal3(f1, 3); + f1 = (signed char)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal3(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed short)1; + cmpVal3(f1, 3); + f1 = (signed short)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal3(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed int)1; + cmpVal3(f1, 3); + f1 = (signed int)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (float)1; + cmpVal3(f1, 3); + f1 = (float)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal3(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed long)1; + cmpVal3(f1, 3); + f1 = (signed long)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (double)1; + cmpVal3(f1, 3); + f1 = (double)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal3(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal3(f1, 3); + + + long3 fa1((unsigned char)1); + long3 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1); + long3 fb1((signed char)1); + long3 fb2((signed char)1, (signed char)1, (signed char)1); + long3 fc1((unsigned short)1); + long3 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1); + long3 fd1((signed short)1); + long3 fd2((signed short)1, (signed short)1, (signed short)1); + long3 fe1((unsigned int)1); + long3 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1); + long3 fg1((signed int)1); + long3 fg2((signed int)1, (signed int)1, (signed int)1); + long3 fh1((float)1); + long3 fh2((float)1, (float)1, (float)1); + long3 fi1((double)1); + long3 fi2((double)1, (double)1, (double)1); + long3 fj1((unsigned long)1); + long3 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1); + long3 fk1((signed long)1); + long3 fk2((signed long)1, (signed long)1, (signed long)1); + long3 fl1((unsigned long long)1); + long3 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + long3 fm1((signed long long)1); + long3 fm2((signed long long)1, (signed long long)1, (signed long long)1); + f1.x = 3; f1.y = 3; f1.z = 3; @@ -3222,6 +5865,81 @@ bool TestLong4() { cmpVal4(f2, -3); assert(!f1 == false); + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f1 = f1 * (unsigned char)1; + cmpVal4(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed char)1; + cmpVal4(f1, 3); + f1 = (signed char)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal4(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed short)1; + cmpVal4(f1, 3); + f1 = (signed short)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal4(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed int)1; + cmpVal4(f1, 3); + f1 = (signed int)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (float)1; + cmpVal4(f1, 3); + f1 = (float)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal4(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed long)1; + cmpVal4(f1, 3); + f1 = (signed long)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (double)1; + cmpVal4(f1, 3); + f1 = (double)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal4(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal4(f1, 3); + + long4 fa1((unsigned char)1); + long4 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1); + long4 fb1((signed char)1); + long4 fb2((signed char)1, (signed char)1, (signed char)1, (signed char)1); + long4 fc1((unsigned short)1); + long4 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1, (unsigned short)1); + long4 fd1((signed short)1); + long4 fd2((signed short)1, (signed short)1, (signed short)1, (signed short)1); + long4 fe1((unsigned int)1); + long4 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1, (unsigned int)1); + long4 fg1((signed int)1); + long4 fg2((signed int)1, (signed int)1, (signed int)1, (signed int)1); + long4 fh1((float)1); + long4 fh2((float)1, (float)1, (float)1, (float)1); + long4 fi1((double)1); + long4 fi2((double)1, (double)1, (double)1, (double)1); + long4 fj1((unsigned long)1); + long4 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1, (unsigned long)1); + long4 fk1((signed long)1); + long4 fk2((signed long)1, (signed long)1, (signed long)1, (signed long)1); + long4 fl1((unsigned long long)1); + long4 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + long4 fm1((signed long long)1); + long4 fm2((signed long long)1, (signed long long)1, (signed long long)1, (signed long long)1); + + f1.x = 3; f1.y = 3; f1.z = 3; @@ -3247,46 +5965,102 @@ bool TestLong4() { } -bool TestFloat1() { - float1 f1, f2, f3; -// float1 f4(1); -// cmpVal1(f4, 1.0f); -// float1 f5(2.0f); -// cmpVal1(f5, 2.0f); - f1.x = 1.0f; - f2.x = 1.0f; +bool TestDouble1() { + double1 f1, f2, f3; + f1.x = 1.0; + f2.x = 1.0; f3 = f1 + f2; - cmpVal1(f3, 2.0f); + cmpVal1(f3, 2.0); f2 = f3 - f1; - cmpVal1(f2, 1.0f); + cmpVal1(f2, 1.0); f1 = f2 * f3; - cmpVal1(f1, 2.0f); + cmpVal1(f1, 2.0); f2 = f1 / f3; - cmpVal1(f2, 2.0f/2.0f); + cmpVal1(f2, 2.0/2.0); f1 += f2; - cmpVal1(f1, 3.0f); + cmpVal1(f1, 3.0); f1 -= f2; - cmpVal1(f1, 2.0f); + cmpVal1(f1, 2.0); f1 *= f2; - cmpVal1(f1, 2.0f); + cmpVal1(f1, 2.0); f1 /= f2; - cmpVal1(f1, 2.0f); + cmpVal1(f1, 2.0); f2 = f1++; - cmpVal1(f1, 3.0f); - cmpVal1(f2, 2.0f); + cmpVal1(f1, 3.0); + cmpVal1(f2, 2.0); f2 = f1--; - cmpVal1(f2, 3.0f); - cmpVal1(f1, 2.0f); + cmpVal1(f2, 3.0); + cmpVal1(f1, 2.0); f2 = ++f1; - cmpVal1(f1, 3.0f); - cmpVal1(f2, 3.0f); + cmpVal1(f1, 3.0); + cmpVal1(f2, 3.0); f2 = --f1; - cmpVal1(f1, 2.0f); - cmpVal1(f1, 2.0f); + cmpVal1(f1, 2.0); + cmpVal1(f1, 2.0); - f1.x = 3.0f; - f2.x = 4.0f; - f3.x = 3.0f; + f1.x = 3.0; + f1 = f1 * (unsigned char)1; + cmpVal1(f1, 3.0); + f1 = (unsigned char)1 * f1; + cmpVal1(f1, 3.0); + f1 = f1 * (signed char)1; + cmpVal1(f1, 3.0); + f1 = (signed char)1 * f1; + cmpVal1(f1, 3.0); + f1 = f1 * (unsigned short)1; + cmpVal1(f1, 3.0); + f1 = (unsigned short)1 * f1; + cmpVal1(f1, 3.0); + f1 = f1 * (signed short)1; + cmpVal1(f1, 3.0); + f1 = (signed short)1 * f1; + cmpVal1(f1, 3.0); + f1 = f1 * (unsigned int)1; + cmpVal1(f1, 3.0); + f1 = (unsigned int)1 * f1; + cmpVal1(f1, 3.0); + f1 = f1 * (signed int)1; + cmpVal1(f1, 3.0); + f1 = (signed int)1 * f1; + cmpVal1(f1, 3.0); + f1 = f1 * (float)1; + cmpVal1(f1, 3.0); + f1 = (float)1 * f1; + cmpVal1(f1, 3.0); + f1 = f1 * (unsigned long)1; + cmpVal1(f1, 3.0); + f1 = (unsigned long)1 * f1; + cmpVal1(f1, 3.0); + f1 = f1 * (signed long)1; + cmpVal1(f1, 3.0); + f1 = (signed long)1 * f1; + cmpVal1(f1, 3.0); + f1 = f1 * (double)1; + cmpVal1(f1, 3.0); + f1 = (double)1 * f1; + cmpVal1(f1, 3.0); + f1 = f1 * (unsigned long long)1; + cmpVal1(f1, 3.0); + f1 = (unsigned long long)1 * f1; + cmpVal1(f1, 3.0); + + double1 fa((unsigned char)1); + double1 fb((signed char)1); + double1 fc((unsigned short)1); + double1 fd((signed short)1); + double1 fe((unsigned int)1); + double1 fg((signed int)1); + double1 fh((float)1); + double1 fi((double)1); + double1 fj((unsigned long)1); + double1 fk((signed long)1); + double1 fl((unsigned long long)1); + double1 fm((signed long long)1); + + + f1.x = 3.0; + f2.x = 4.0; + f3.x = 3.0; assert((f1 == f2) == false); assert((f1 != f2) == true); assert((f1 < f2) == true); @@ -3297,48 +6071,121 @@ bool TestFloat1() { return true; } -bool TestFloat2() { - float2 f1, f2, f3; - f1.x = 1.0f; - f1.y = 1.0f; - f2.x = 1.0f; - f2.y = 1.0f; +bool TestDouble2() { + double2 f1, f2, f3; + f1.x = 1.0; + f1.y = 1.0; + f2.x = 1.0; + f2.y = 1.0; f3 = f1 + f2; - cmpVal2(f3, 2.0f); + cmpVal2(f3, 2.0); f2 = f3 - f1; - cmpVal2(f2, 1.0f); + cmpVal2(f2, 1.0); f1 = f2 * f3; - cmpVal2(f1, 2.0f); + cmpVal2(f1, 2.0); f2 = f1 / f3; - cmpVal2(f2, 2.0f/2.0f); + cmpVal2(f2, 2.0f/2.0); f1 += f2; - cmpVal2(f1, 3.0f); + cmpVal2(f1, 3.0); f1 -= f2; - cmpVal2(f1, 2.0f); + cmpVal2(f1, 2.0); f1 *= f2; - cmpVal2(f1, 2.0f); + cmpVal2(f1, 2.0); f1 /= f2; - cmpVal2(f1, 2.0f); + cmpVal2(f1, 2.0); f2 = f1++; - cmpVal2(f1, 3.0f); - cmpVal2(f2, 2.0f); + cmpVal2(f1, 3.0); + cmpVal2(f2, 2.0); f2 = f1--; - cmpVal2(f2, 3.0f); - cmpVal2(f1, 2.0f); + cmpVal2(f2, 3.0); + cmpVal2(f1, 2.0); f2 = ++f1; - cmpVal2(f1, 3.0f); - cmpVal2(f2, 3.0f); + cmpVal2(f1, 3.0); + cmpVal2(f2, 3.0); f2 = --f1; - cmpVal2(f1, 2.0f); - cmpVal2(f1, 2.0f); + cmpVal2(f1, 2.0); + cmpVal2(f1, 2.0); - f1.x = 3.0f; - f1.y = 3.0f; - f2.x = 4.0f; - f2.y = 4.0f; - f3.x = 3.0f; - f3.y = 3.0f; + f1.x = 3.0; + f1.y = 3.0; + f1 = f1 * (unsigned char)1; + cmpVal2(f1, 3.0); + f1 = (unsigned char)1 * f1; + cmpVal2(f1, 3.0); + f1 = f1 * (signed char)1; + cmpVal2(f1, 3.0); + f1 = (signed char)1 * f1; + cmpVal2(f1, 3.0); + f1 = f1 * (unsigned short)1; + cmpVal2(f1, 3.0); + f1 = (unsigned short)1 * f1; + cmpVal2(f1, 3.0); + f1 = f1 * (signed short)1; + cmpVal2(f1, 3.0); + f1 = (signed short)1 * f1; + cmpVal2(f1, 3.0); + f1 = f1 * (unsigned int)1; + cmpVal2(f1, 3.0); + f1 = (unsigned int)1 * f1; + cmpVal2(f1, 3.0); + f1 = f1 * (signed int)1; + cmpVal2(f1, 3.0); + f1 = (signed int)1 * f1; + cmpVal2(f1, 3.0); + f1 = f1 * (float)1; + cmpVal2(f1, 3.0); + f1 = (float)1 * f1; + cmpVal2(f1, 3.0); + f1 = f1 * (unsigned long)1; + cmpVal2(f1, 3.0); + f1 = (unsigned long)1 * f1; + cmpVal2(f1, 3.0); + f1 = f1 * (signed long)1; + cmpVal2(f1, 3.0); + f1 = (signed long)1 * f1; + cmpVal2(f1, 3.0); + f1 = f1 * (double)1; + cmpVal2(f1, 3.0); + f1 = (double)1 * f1; + cmpVal2(f1, 3.0); + f1 = f1 * (unsigned long long)1; + cmpVal2(f1, 3.0); + f1 = (unsigned long long)1 * f1; + cmpVal2(f1, 3.0); + + double2 fa1((unsigned char)1); + double2 fa2((unsigned char)1, (unsigned char)1); + double2 fb1((signed char)1); + double2 fb2((signed char)1, (signed char)1); + double2 fc1((unsigned short)1); + double2 fc2((unsigned short)1,(unsigned short)1); + double2 fd1((signed short)1); + double2 fd2((signed short)1, (signed short)1); + double2 fe1((unsigned int)1); + double2 fe2((unsigned int)1, (unsigned int)1); + double2 fg1((signed int)1); + double2 fg2((signed int)1, (signed int)1); + double2 fh1((float)1); + double2 fh2((float)1, (float)1); + double2 fi1((double)1); + double2 fi2((double)1, (double)1); + double2 fj1((unsigned long)1); + double2 fj2((unsigned long)1, (unsigned long)1); + double2 fk1((signed long)1); + double2 fk2((signed long)1, (signed long)1); + double2 fl1((unsigned long long)1); + double2 fl2((unsigned long long)1, (unsigned long long)1); + double2 fm1((signed long long)1); + double2 fm2((signed long long)1, (signed long long)1); + + + f1.x = 3.0; + f1.y = 3.0; + f2.x = 4.0; + f2.y = 4.0; + f3.x = 3.0; + f3.y = 3.0; assert((f1 == f2) == false); assert((f1 != f2) == true); assert((f1 < f2) == true); @@ -3350,51 +6197,125 @@ bool TestFloat2() { return true; } -bool TestFloat3() { - float3 f1, f2, f3; - f1.x = 1.0f; - f1.y = 1.0f; - f1.z = 1.0f; - f2.x = 1.0f; - f2.y = 1.0f; - f2.z = 1.0f; +bool TestDouble3() { + double3 f1, f2, f3; + f1.x = 1.0; + f1.y = 1.0; + f1.z = 1.0; + f2.x = 1.0; + f2.y = 1.0; + f2.z = 1.0; f3 = f1 + f2; - cmpVal3(f3, 2.0f); + cmpVal3(f3, 2.0); f2 = f3 - f1; - cmpVal3(f2, 1.0f); + cmpVal3(f2, 1.0); f1 = f2 * f3; - cmpVal3(f1, 2.0f); + cmpVal3(f1, 2.0); f2 = f1 / f3; - cmpVal3(f2, 2.0f/2.0f); + cmpVal3(f2, 2.0f/2.0); f1 += f2; - cmpVal3(f1, 3.0f); + cmpVal3(f1, 3.0); f1 -= f2; - cmpVal3(f1, 2.0f); + cmpVal3(f1, 2.0); f1 *= f2; - cmpVal3(f1, 2.0f); + cmpVal3(f1, 2.0); f1 /= f2; f2 = f1++; - cmpVal3(f1, 3.0f); - cmpVal3(f2, 2.0f); + cmpVal3(f1, 3.0); + cmpVal3(f2, 2.0); f2 = f1--; - cmpVal3(f2, 3.0f); - cmpVal3(f1, 2.0f); + cmpVal3(f2, 3.0); + cmpVal3(f1, 2.0); f2 = ++f1; - cmpVal3(f1, 3.0f); - cmpVal3(f2, 3.0f); + cmpVal3(f1, 3.0); + cmpVal3(f2, 3.0); f2 = --f1; - cmpVal3(f1, 2.0f); - cmpVal3(f1, 2.0f); + cmpVal3(f1, 2.0); + cmpVal3(f1, 2.0); - f1.x = 3.0f; - f1.y = 3.0f; - f1.z = 3.0f; - f2.x = 4.0f; - f2.y = 4.0f; - f2.z = 4.0f; - f3.x = 3.0f; - f3.y = 3.0f; - f3.z = 3.0f; + f1.x = 3.0; + f1.y = 3.0; + f1.z = 3.0; + f1 = f1 * (unsigned char)1; + cmpVal3(f1, 3.0); + f1 = (unsigned char)1 * f1; + cmpVal3(f1, 3.0); + f1 = f1 * (signed char)1; + cmpVal3(f1, 3.0); + f1 = (signed char)1 * f1; + cmpVal3(f1, 3.0); + f1 = f1 * (unsigned short)1; + cmpVal3(f1, 3.0); + f1 = (unsigned short)1 * f1; + cmpVal3(f1, 3.0); + f1 = f1 * (signed short)1; + cmpVal3(f1, 3.0); + f1 = (signed short)1 * f1; + cmpVal3(f1, 3.0); + f1 = f1 * (unsigned int)1; + cmpVal3(f1, 3.0); + f1 = (unsigned int)1 * f1; + cmpVal3(f1, 3.0); + f1 = f1 * (signed int)1; + cmpVal3(f1, 3.0); + f1 = (signed int)1 * f1; + cmpVal3(f1, 3.0); + f1 = f1 * (float)1; + cmpVal3(f1, 3.0); + f1 = (float)1 * f1; + cmpVal3(f1, 3.0); + f1 = f1 * (unsigned long)1; + cmpVal3(f1, 3.0); + f1 = (unsigned long)1 * f1; + cmpVal3(f1, 3.0); + f1 = f1 * (signed long)1; + cmpVal3(f1, 3.0); + f1 = (signed long)1 * f1; + cmpVal3(f1, 3.0); + f1 = f1 * (double)1; + cmpVal3(f1, 3.0); + f1 = (double)1 * f1; + cmpVal3(f1, 3.0); + f1 = f1 * (unsigned long long)1; + cmpVal3(f1, 3.0); + f1 = (unsigned long long)1 * f1; + cmpVal3(f1, 3.0); + + double3 fa1((unsigned char)1); + double3 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1); + double3 fb1((signed char)1); + double3 fb2((signed char)1, (signed char)1, (signed char)1); + double3 fc1((unsigned short)1); + double3 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1); + double3 fd1((signed short)1); + double3 fd2((signed short)1, (signed short)1, (signed short)1); + double3 fe1((unsigned int)1); + double3 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1); + double3 fg1((signed int)1); + double3 fg2((signed int)1, (signed int)1, (signed int)1); + double3 fh1((float)1); + double3 fh2((float)1, (float)1, (float)1); + double3 fi1((double)1); + double3 fi2((double)1, (double)1, (double)1); + double3 fj1((unsigned long)1); + double3 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1); + double3 fk1((signed long)1); + double3 fk2((signed long)1, (signed long)1, (signed long)1); + double3 fl1((unsigned long long)1); + double3 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + double3 fm1((signed long long)1); + double3 fm2((signed long long)1, (signed long long)1, (signed long long)1); + + + f1.x = 3.0; + f1.y = 3.0; + f1.z = 3.0; + f2.x = 4.0; + f2.y = 4.0; + f2.z = 4.0; + f3.x = 3.0; + f3.y = 3.0; + f3.z = 3.0; assert((f1 == f2) == false); assert((f1 != f2) == true); assert((f1 < f2) == true); @@ -3406,57 +6327,131 @@ bool TestFloat3() { return true; } - -bool TestFloat4() { - float4 f1, f2, f3; - f1.x = 1.0f; - f1.y = 1.0f; - f1.z = 1.0f; - f1.w = 1.0f; - f2.x = 1.0f; - f2.y = 1.0f; - f2.z = 1.0f; - f2.w = 1.0f; +bool TestDouble4() { + double4 f1, f2, f3; + f1.x = 1.0; + f1.y = 1.0; + f1.z = 1.0; + f1.w = 1.0; + f2.x = 1.0; + f2.y = 1.0; + f2.z = 1.0; + f2.w = 1.0; f3 = f1 + f2; - cmpVal4(f3, 2.0f); + cmpVal4(f3, 2.0); f2 = f3 - f1; - cmpVal4(f2, 1.0f); + cmpVal4(f2, 1.0); f1 = f2 * f3; - cmpVal4(f1, 2.0f); + cmpVal4(f1, 2.0); f2 = f1 / f3; - cmpVal4(f2, 2.0f/2.0f); + cmpVal4(f2, 2.0f/2.0); f1 += f2; - cmpVal4(f1, 3.0f); + cmpVal4(f1, 3.0); f1 -= f2; - cmpVal4(f1, 2.0f); + cmpVal4(f1, 2.0); f1 *= f2; - cmpVal4(f1, 2.0f); + cmpVal4(f1, 2.0); f1 /= f2; f2 = f1++; - cmpVal4(f1, 3.0f); - cmpVal4(f2, 2.0f); + cmpVal4(f1, 3.0); + cmpVal4(f2, 2.0); f2 = f1--; - cmpVal4(f2, 3.0f); - cmpVal4(f1, 2.0f); + cmpVal4(f2, 3.0); + cmpVal4(f1, 2.0); f2 = ++f1; - cmpVal4(f1, 3.0f); - cmpVal4(f2, 3.0f); + cmpVal4(f1, 3.0); + cmpVal4(f2, 3.0); f2 = --f1; - cmpVal4(f1, 2.0f); - cmpVal4(f1, 2.0f); + cmpVal4(f1, 2.0); + cmpVal4(f1, 2.0); - f1.x = 3.0f; - f1.y = 3.0f; - f1.z = 3.0f; - f1.w = 3.0f; - f2.x = 4.0f; - f2.y = 4.0f; - f2.z = 4.0f; - f2.w = 4.0f; - f3.x = 3.0f; - f3.y = 3.0f; - f3.z = 3.0f; - f3.w = 3.0f; + f1.x = 3.0; + f1.y = 3.0; + f1.z = 3.0; + f1.w = 3.0; + f1 = f1 * (unsigned char)1; + cmpVal4(f1, 3.0); + f1 = (unsigned char)1 * f1; + cmpVal4(f1, 3.0); + f1 = f1 * (signed char)1; + cmpVal4(f1, 3.0); + f1 = (signed char)1 * f1; + cmpVal4(f1, 3.0); + f1 = f1 * (unsigned short)1; + cmpVal4(f1, 3.0); + f1 = (unsigned short)1 * f1; + cmpVal4(f1, 3.0); + f1 = f1 * (signed short)1; + cmpVal4(f1, 3.0); + f1 = (signed short)1 * f1; + cmpVal4(f1, 3.0); + f1 = f1 * (unsigned int)1; + cmpVal4(f1, 3.0); + f1 = (unsigned int)1 * f1; + cmpVal4(f1, 3.0); + f1 = f1 * (signed int)1; + cmpVal4(f1, 3.0); + f1 = (signed int)1 * f1; + cmpVal4(f1, 3.0); + f1 = f1 * (float)1; + cmpVal4(f1, 3.0); + f1 = (float)1 * f1; + cmpVal4(f1, 3.0); + f1 = f1 * (unsigned long)1; + cmpVal4(f1, 3.0); + f1 = (unsigned long)1 * f1; + cmpVal4(f1, 3.0); + f1 = f1 * (signed long)1; + cmpVal4(f1, 3.0); + f1 = (signed long)1 * f1; + cmpVal4(f1, 3.0); + f1 = f1 * (double)1; + cmpVal4(f1, 3.0); + f1 = (double)1 * f1; + cmpVal4(f1, 3.0); + f1 = f1 * (unsigned long long)1; + cmpVal4(f1, 3.0); + f1 = (unsigned long long)1 * f1; + cmpVal4(f1, 3.0); + + double4 fa1((unsigned char)1); + double4 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1); + double4 fb1((signed char)1); + double4 fb2((signed char)1, (signed char)1, (signed char)1, (signed char)1); + double4 fc1((unsigned short)1); + double4 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1, (unsigned short)1); + double4 fd1((signed short)1); + double4 fd2((signed short)1, (signed short)1, (signed short)1, (signed short)1); + double4 fe1((unsigned int)1); + double4 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1, (unsigned int)1); + double4 fg1((signed int)1); + double4 fg2((signed int)1, (signed int)1, (signed int)1, (signed int)1); + double4 fh1((float)1); + double4 fh2((float)1, (float)1, (float)1, (float)1); + double4 fi1((double)1); + double4 fi2((double)1, (double)1, (double)1, (double)1); + double4 fj1((unsigned long)1); + double4 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1, (unsigned long)1); + double4 fk1((signed long)1); + double4 fk2((signed long)1, (signed long)1, (signed long)1, (signed long)1); + double4 fl1((unsigned long long)1); + double4 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + double4 fm1((signed long long)1); + double4 fm2((signed long long)1, (signed long long)1, (signed long long)1, (signed long long)1); + + + f1.x = 3.0; + f1.y = 3.0; + f1.z = 3.0; + f1.w = 3.0; + f2.x = 4.0; + f2.y = 4.0; + f2.z = 4.0; + f2.w = 4.0; + f3.x = 3.0; + f3.y = 3.0; + f3.z = 3.0; + f3.w = 3.0; assert((f1 == f2) == false); assert((f1 != f2) == true); assert((f1 < f2) == true); @@ -3467,12 +6462,1367 @@ bool TestFloat4() { return true; } + +bool TestULongLong1() { + long1 f1, f2, f3; + f1.x = 1; + f2.x = 1; + f3 = f1 + f2; + cmpVal1(f3, 2); + f2 = f3 - f1; + cmpVal1(f2, 1); + f1 = f2 * f3; + cmpVal1(f1, 2); + f2 = f1 / f3; + cmpVal1(f2, 2/2); + f3 = f1 % f2; + cmpVal1(f3, 0); + f1 = f3 & f2; + cmpVal1(f1, 0); + f2 = f1 ^ f3; + cmpVal1(f2, 0); + f1.x = 1; + f2.x = 2; + f3 = f1 << f2; + cmpVal1(f3, 4); + f2 = f3 >> f1; + cmpVal1(f2, 2); + + f1.x = 2; + f2.x = 1; + f1 += f2; + cmpVal1(f1, 3); + f1 -= f2; + cmpVal1(f1, 2); + f1 *= f2; + cmpVal1(f1, 2); + f1 /= f2; + cmpVal1(f1, 2); + f1 %= f2; + cmpVal1(f1, 0); + f1 &= f2; + cmpVal1(f1, 0); + f1 |= f2; + cmpVal1(f1, 1); + f1 ^= f2; + cmpVal1(f1, 0); + f1.x = 1; + f1 <<= f2; + cmpVal1(f1, 2); + f1 >>= f2; + cmpVal1(f1, 1); + + f1.x = 2; + f2 = f1++; + cmpVal1(f1, 3); + cmpVal1(f2, 2); + f2 = f1--; + cmpVal1(f2, 3); + cmpVal1(f1, 2); + f2 = ++f1; + cmpVal1(f1, 3); + cmpVal1(f2, 3); + f2 = --f1; + cmpVal1(f1, 2); + cmpVal1(f2, 2); + + f2 = ~f1; + cmpVal1(f2, -3); + assert(!f1 == false); + + f1.x = 3; + f1 = f1 * (unsigned char)1; + cmpVal1(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed char)1; + cmpVal1(f1, 3); + f1 = (signed char)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal1(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed short)1; + cmpVal1(f1, 3); + f1 = (signed short)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal1(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed int)1; + cmpVal1(f1, 3); + f1 = (signed int)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (float)1; + cmpVal1(f1, 3); + f1 = (float)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal1(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed long)1; + cmpVal1(f1, 3); + f1 = (signed long)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (double)1; + cmpVal1(f1, 3); + f1 = (double)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal1(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal1(f1, 3); + + ulonglong1 fa((unsigned char)1); + ulonglong1 fb((signed char)1); + ulonglong1 fc((unsigned short)1); + ulonglong1 fd((signed short)1); + ulonglong1 fe((unsigned int)1); + ulonglong1 fg((signed int)1); + ulonglong1 fh((float)1); + ulonglong1 fi((double)1); + ulonglong1 fj((unsigned long)1); + ulonglong1 fk((signed long)1); + ulonglong1 fl((unsigned long long)1); + ulonglong1 fm((signed long long)1); + + + f1.x = 3; + f2.x = 4; + f3.x = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestULongLong2() { + long2 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f2.x = 1; + f2.y = 1; + f3 = f1 + f2; + cmpVal2(f3, 2); + f2 = f3 - f1; + cmpVal2(f2, 1); + f1 = f2 * f3; + cmpVal2(f1, 2); + f2 = f1 / f3; + cmpVal2(f2, 2/2); + f3 = f1 % f2; + cmpVal2(f3, 0); + f1 = f3 & f2; + cmpVal2(f1, 0); + f2 = f1 ^ f3; + cmpVal2(f2, 0); + f1.x = 1; + f1.y = 1; + f2.x = 2; + f2.y = 2; + f3 = f1 << f2; + cmpVal2(f3, 4); + f2 = f3 >> f1; + cmpVal2(f2, 2); + + f1.x = 2; + f1.y = 2; + f2.x = 1; + f2.y = 1; + f1 += f2; + cmpVal2(f1, 3); + f1 -= f2; + cmpVal2(f1, 2); + f1 *= f2; + cmpVal2(f1, 2); + f1 /= f2; + cmpVal2(f1, 2); + f1 %= f2; + cmpVal2(f1, 0); + f1 &= f2; + cmpVal2(f1, 0); + f1 |= f2; + cmpVal2(f1, 1); + f1 ^= f2; + cmpVal2(f1, 0); + f1.x = 1; + f1.y = 1; + f1 <<= f2; + cmpVal2(f1, 2); + f1 >>= f2; + cmpVal2(f1, 1); + + f1.x = 2; + f1.y = 2; + f2 = f1++; + cmpVal2(f1, 3); + cmpVal2(f2, 2); + f2 = f1--; + cmpVal2(f2, 3); + cmpVal2(f1, 2); + f2 = ++f1; + cmpVal2(f1, 3); + cmpVal2(f2, 3); + f2 = --f1; + cmpVal2(f1, 2); + cmpVal2(f2, 2); + + f2 = ~f1; + cmpVal2(f2, -3); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1 = f1 * (unsigned char)1; + cmpVal2(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed char)1; + cmpVal2(f1, 3); + f1 = (signed char)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal2(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed short)1; + cmpVal2(f1, 3); + f1 = (signed short)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal2(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed int)1; + cmpVal2(f1, 3); + f1 = (signed int)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (float)1; + cmpVal2(f1, 3); + f1 = (float)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal2(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed long)1; + cmpVal2(f1, 3); + f1 = (signed long)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (double)1; + cmpVal2(f1, 3); + f1 = (double)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal2(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal2(f1, 3); + + ulonglong2 fa1((unsigned char)1); + ulonglong2 fa2((unsigned char)1, (unsigned char)1); + ulonglong2 fb1((signed char)1); + ulonglong2 fb2((signed char)1, (signed char)1); + ulonglong2 fc1((unsigned short)1); + ulonglong2 fc2((unsigned short)1,(unsigned short)1); + ulonglong2 fd1((signed short)1); + ulonglong2 fd2((signed short)1, (signed short)1); + ulonglong2 fe1((unsigned int)1); + ulonglong2 fe2((unsigned int)1, (unsigned int)1); + ulonglong2 fg1((signed int)1); + ulonglong2 fg2((signed int)1, (signed int)1); + ulonglong2 fh1((float)1); + ulonglong2 fh2((float)1, (float)1); + ulonglong2 fi1((double)1); + ulonglong2 fi2((double)1, (double)1); + ulonglong2 fj1((unsigned long)1); + ulonglong2 fj2((unsigned long)1, (unsigned long)1); + ulonglong2 fk1((signed long)1); + ulonglong2 fk2((signed long)1, (signed long)1); + ulonglong2 fl1((unsigned long long)1); + ulonglong2 fl2((unsigned long long)1, (unsigned long long)1); + ulonglong2 fm1((signed long long)1); + ulonglong2 fm2((signed long long)1, (signed long long)1); + + + f1.x = 3; + f1.y = 3; + f2.x = 4; + f2.y = 4; + f3.x = 3; + f3.y = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestULongLong3() { + long3 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f3 = f1 + f2; + cmpVal3(f3, 2); + f2 = f3 - f1; + cmpVal3(f2, 1); + f1 = f2 * f3; + cmpVal3(f1, 2); + f2 = f1 / f3; + cmpVal3(f2, 2/2); + f3 = f1 % f2; + cmpVal3(f3, 0); + f1 = f3 & f2; + cmpVal3(f1, 0); + f2 = f1 ^ f3; + cmpVal3(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f3 = f1 << f2; + cmpVal3(f3, 4); + f2 = f3 >> f1; + cmpVal3(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f1 += f2; + cmpVal3(f1, 3); + f1 -= f2; + cmpVal3(f1, 2); + f1 *= f2; + cmpVal3(f1, 2); + f1 /= f2; + cmpVal3(f1, 2); + f1 %= f2; + cmpVal3(f1, 0); + f1 &= f2; + cmpVal3(f1, 0); + f1 |= f2; + cmpVal3(f1, 1); + f1 ^= f2; + cmpVal3(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1 <<= f2; + cmpVal3(f1, 2); + f1 >>= f2; + cmpVal3(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2 = f1++; + cmpVal3(f1, 3); + cmpVal3(f2, 2); + f2 = f1--; + cmpVal3(f2, 3); + cmpVal3(f1, 2); + f2 = ++f1; + cmpVal3(f1, 3); + cmpVal3(f2, 3); + f2 = --f1; + cmpVal3(f1, 2); + cmpVal3(f2, 2); + + f2 = ~f1; + cmpVal3(f2, -3); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1 = f1 * (unsigned char)1; + cmpVal3(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed char)1; + cmpVal3(f1, 3); + f1 = (signed char)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal3(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed short)1; + cmpVal3(f1, 3); + f1 = (signed short)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal3(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed int)1; + cmpVal3(f1, 3); + f1 = (signed int)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (float)1; + cmpVal3(f1, 3); + f1 = (float)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal3(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed long)1; + cmpVal3(f1, 3); + f1 = (signed long)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (double)1; + cmpVal3(f1, 3); + f1 = (double)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal3(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal3(f1, 3); + + ulonglong3 fa1((unsigned char)1); + ulonglong3 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1); + ulonglong3 fb1((signed char)1); + ulonglong3 fb2((signed char)1, (signed char)1, (signed char)1); + ulonglong3 fc1((unsigned short)1); + ulonglong3 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1); + ulonglong3 fd1((signed short)1); + ulonglong3 fd2((signed short)1, (signed short)1, (signed short)1); + ulonglong3 fe1((unsigned int)1); + ulonglong3 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1); + ulonglong3 fg1((signed int)1); + ulonglong3 fg2((signed int)1, (signed int)1, (signed int)1); + ulonglong3 fh1((float)1); + ulonglong3 fh2((float)1, (float)1, (float)1); + ulonglong3 fi1((double)1); + ulonglong3 fi2((double)1, (double)1, (double)1); + ulonglong3 fj1((unsigned long)1); + ulonglong3 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1); + ulonglong3 fk1((signed long)1); + ulonglong3 fk2((signed long)1, (signed long)1, (signed long)1); + ulonglong3 fl1((unsigned long long)1); + ulonglong3 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + ulonglong3 fm1((signed long long)1); + ulonglong3 fm2((signed long long)1, (signed long long)1, (signed long long)1); + + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestULongLong4() { + long4 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f3 = f1 + f2; + cmpVal4(f3, 2); + f2 = f3 - f1; + cmpVal4(f2, 1); + f1 = f2 * f3; + cmpVal4(f1, 2); + f2 = f1 / f3; + cmpVal4(f2, 2/2); + f3 = f1 % f2; + cmpVal4(f3, 0); + f1 = f3 & f2; + cmpVal4(f1, 0); + f2 = f1 ^ f3; + cmpVal4(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f2.w = 2; + f3 = f1 << f2; + cmpVal4(f3, 4); + f2 = f3 >> f1; + cmpVal4(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f1 += f2; + cmpVal4(f1, 3); + f1 -= f2; + cmpVal4(f1, 2); + f1 *= f2; + cmpVal4(f1, 2); + f1 /= f2; + cmpVal4(f1, 2); + f1 %= f2; + cmpVal4(f1, 0); + f1 &= f2; + cmpVal4(f1, 0); + f1 |= f2; + cmpVal4(f1, 1); + f1 ^= f2; + cmpVal4(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f1 <<= f2; + cmpVal4(f1, 2); + f1 >>= f2; + cmpVal4(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2 = f1++; + cmpVal4(f1, 3); + cmpVal4(f2, 2); + f2 = f1--; + cmpVal4(f2, 3); + cmpVal4(f1, 2); + f2 = ++f1; + cmpVal4(f1, 3); + cmpVal4(f2, 3); + f2 = --f1; + cmpVal4(f1, 2); + cmpVal4(f2, 2); + + f2 = ~f1; + cmpVal4(f2, -3); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f1 = f1 * (unsigned char)1; + cmpVal4(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed char)1; + cmpVal4(f1, 3); + f1 = (signed char)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal4(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed short)1; + cmpVal4(f1, 3); + f1 = (signed short)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal4(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed int)1; + cmpVal4(f1, 3); + f1 = (signed int)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (float)1; + cmpVal4(f1, 3); + f1 = (float)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal4(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed long)1; + cmpVal4(f1, 3); + f1 = (signed long)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (double)1; + cmpVal4(f1, 3); + f1 = (double)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal4(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal4(f1, 3); + + ulonglong4 fa1((unsigned char)1); + ulonglong4 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1); + ulonglong4 fb1((signed char)1); + ulonglong4 fb2((signed char)1, (signed char)1, (signed char)1, (signed char)1); + ulonglong4 fc1((unsigned short)1); + ulonglong4 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1, (unsigned short)1); + ulonglong4 fd1((signed short)1); + ulonglong4 fd2((signed short)1, (signed short)1, (signed short)1, (signed short)1); + ulonglong4 fe1((unsigned int)1); + ulonglong4 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1, (unsigned int)1); + ulonglong4 fg1((signed int)1); + ulonglong4 fg2((signed int)1, (signed int)1, (signed int)1, (signed int)1); + ulonglong4 fh1((float)1); + ulonglong4 fh2((float)1, (float)1, (float)1, (float)1); + ulonglong4 fi1((double)1); + ulonglong4 fi2((double)1, (double)1, (double)1, (double)1); + ulonglong4 fj1((unsigned long)1); + ulonglong4 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1, (unsigned long)1); + ulonglong4 fk1((signed long)1); + ulonglong4 fk2((signed long)1, (signed long)1, (signed long)1, (signed long)1); + ulonglong4 fl1((unsigned long long)1); + ulonglong4 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + ulonglong4 fm1((signed long long)1); + ulonglong4 fm2((signed long long)1, (signed long long)1, (signed long long)1, (signed long long)1); + + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f2.w = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + f3.w = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + + +bool TestLongLong1() { + long1 f1, f2, f3; + f1.x = 1; + f2.x = 1; + f3 = f1 + f2; + cmpVal1(f3, 2); + f2 = f3 - f1; + cmpVal1(f2, 1); + f1 = f2 * f3; + cmpVal1(f1, 2); + f2 = f1 / f3; + cmpVal1(f2, 2/2); + f3 = f1 % f2; + cmpVal1(f3, 0); + f1 = f3 & f2; + cmpVal1(f1, 0); + f2 = f1 ^ f3; + cmpVal1(f2, 0); + f1.x = 1; + f2.x = 2; + f3 = f1 << f2; + cmpVal1(f3, 4); + f2 = f3 >> f1; + cmpVal1(f2, 2); + + f1.x = 2; + f2.x = 1; + f1 += f2; + cmpVal1(f1, 3); + f1 -= f2; + cmpVal1(f1, 2); + f1 *= f2; + cmpVal1(f1, 2); + f1 /= f2; + cmpVal1(f1, 2); + f1 %= f2; + cmpVal1(f1, 0); + f1 &= f2; + cmpVal1(f1, 0); + f1 |= f2; + cmpVal1(f1, 1); + f1 ^= f2; + cmpVal1(f1, 0); + f1.x = 1; + f1 <<= f2; + cmpVal1(f1, 2); + f1 >>= f2; + cmpVal1(f1, 1); + + f1.x = 2; + f2 = f1++; + cmpVal1(f1, 3); + cmpVal1(f2, 2); + f2 = f1--; + cmpVal1(f2, 3); + cmpVal1(f1, 2); + f2 = ++f1; + cmpVal1(f1, 3); + cmpVal1(f2, 3); + f2 = --f1; + cmpVal1(f1, 2); + cmpVal1(f2, 2); + + f2 = ~f1; + cmpVal1(f2, -3); + assert(!f1 == false); + + f1.x = 3; + f1 = f1 * (unsigned char)1; + cmpVal1(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed char)1; + cmpVal1(f1, 3); + f1 = (signed char)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal1(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed short)1; + cmpVal1(f1, 3); + f1 = (signed short)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal1(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed int)1; + cmpVal1(f1, 3); + f1 = (signed int)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (float)1; + cmpVal1(f1, 3); + f1 = (float)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal1(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (signed long)1; + cmpVal1(f1, 3); + f1 = (signed long)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (double)1; + cmpVal1(f1, 3); + f1 = (double)1 * f1; + cmpVal1(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal1(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal1(f1, 3); + + longlong1 fa((unsigned char)1); + longlong1 fb((signed char)1); + longlong1 fc((unsigned short)1); + longlong1 fd((signed short)1); + longlong1 fe((unsigned int)1); + longlong1 fg((signed int)1); + longlong1 fh((float)1); + longlong1 fi((double)1); + longlong1 fj((unsigned long)1); + longlong1 fk((signed long)1); + longlong1 fl((unsigned long long)1); + longlong1 fm((signed long long)1); + + + f1.x = 3; + f2.x = 4; + f3.x = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestLongLong2() { + long2 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f2.x = 1; + f2.y = 1; + f3 = f1 + f2; + cmpVal2(f3, 2); + f2 = f3 - f1; + cmpVal2(f2, 1); + f1 = f2 * f3; + cmpVal2(f1, 2); + f2 = f1 / f3; + cmpVal2(f2, 2/2); + f3 = f1 % f2; + cmpVal2(f3, 0); + f1 = f3 & f2; + cmpVal2(f1, 0); + f2 = f1 ^ f3; + cmpVal2(f2, 0); + f1.x = 1; + f1.y = 1; + f2.x = 2; + f2.y = 2; + f3 = f1 << f2; + cmpVal2(f3, 4); + f2 = f3 >> f1; + cmpVal2(f2, 2); + + f1.x = 2; + f1.y = 2; + f2.x = 1; + f2.y = 1; + f1 += f2; + cmpVal2(f1, 3); + f1 -= f2; + cmpVal2(f1, 2); + f1 *= f2; + cmpVal2(f1, 2); + f1 /= f2; + cmpVal2(f1, 2); + f1 %= f2; + cmpVal2(f1, 0); + f1 &= f2; + cmpVal2(f1, 0); + f1 |= f2; + cmpVal2(f1, 1); + f1 ^= f2; + cmpVal2(f1, 0); + f1.x = 1; + f1.y = 1; + f1 <<= f2; + cmpVal2(f1, 2); + f1 >>= f2; + cmpVal2(f1, 1); + + f1.x = 2; + f1.y = 2; + f2 = f1++; + cmpVal2(f1, 3); + cmpVal2(f2, 2); + f2 = f1--; + cmpVal2(f2, 3); + cmpVal2(f1, 2); + f2 = ++f1; + cmpVal2(f1, 3); + cmpVal2(f2, 3); + f2 = --f1; + cmpVal2(f1, 2); + cmpVal2(f2, 2); + + f2 = ~f1; + cmpVal2(f2, -3); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1 = f1 * (unsigned char)1; + cmpVal2(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed char)1; + cmpVal2(f1, 3); + f1 = (signed char)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal2(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed short)1; + cmpVal2(f1, 3); + f1 = (signed short)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal2(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed int)1; + cmpVal2(f1, 3); + f1 = (signed int)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (float)1; + cmpVal2(f1, 3); + f1 = (float)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal2(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (signed long)1; + cmpVal2(f1, 3); + f1 = (signed long)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (double)1; + cmpVal2(f1, 3); + f1 = (double)1 * f1; + cmpVal2(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal2(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal2(f1, 3); + + longlong2 fa1((unsigned char)1); + longlong2 fa2((unsigned char)1, (unsigned char)1); + longlong2 fb1((signed char)1); + longlong2 fb2((signed char)1, (signed char)1); + longlong2 fc1((unsigned short)1); + longlong2 fc2((unsigned short)1,(unsigned short)1); + longlong2 fd1((signed short)1); + longlong2 fd2((signed short)1, (signed short)1); + longlong2 fe1((unsigned int)1); + longlong2 fe2((unsigned int)1, (unsigned int)1); + longlong2 fg1((signed int)1); + longlong2 fg2((signed int)1, (signed int)1); + longlong2 fh1((float)1); + longlong2 fh2((float)1, (float)1); + longlong2 fi1((double)1); + longlong2 fi2((double)1, (double)1); + longlong2 fj1((unsigned long)1); + longlong2 fj2((unsigned long)1, (unsigned long)1); + longlong2 fk1((signed long)1); + longlong2 fk2((signed long)1, (signed long)1); + longlong2 fl1((unsigned long long)1); + longlong2 fl2((unsigned long long)1, (unsigned long long)1); + longlong2 fm1((signed long long)1); + longlong2 fm2((signed long long)1, (signed long long)1); + + + f1.x = 3; + f1.y = 3; + f2.x = 4; + f2.y = 4; + f3.x = 3; + f3.y = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestLongLong3() { + long3 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f3 = f1 + f2; + cmpVal3(f3, 2); + f2 = f3 - f1; + cmpVal3(f2, 1); + f1 = f2 * f3; + cmpVal3(f1, 2); + f2 = f1 / f3; + cmpVal3(f2, 2/2); + f3 = f1 % f2; + cmpVal3(f3, 0); + f1 = f3 & f2; + cmpVal3(f1, 0); + f2 = f1 ^ f3; + cmpVal3(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f3 = f1 << f2; + cmpVal3(f3, 4); + f2 = f3 >> f1; + cmpVal3(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f1 += f2; + cmpVal3(f1, 3); + f1 -= f2; + cmpVal3(f1, 2); + f1 *= f2; + cmpVal3(f1, 2); + f1 /= f2; + cmpVal3(f1, 2); + f1 %= f2; + cmpVal3(f1, 0); + f1 &= f2; + cmpVal3(f1, 0); + f1 |= f2; + cmpVal3(f1, 1); + f1 ^= f2; + cmpVal3(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1 <<= f2; + cmpVal3(f1, 2); + f1 >>= f2; + cmpVal3(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f2 = f1++; + cmpVal3(f1, 3); + cmpVal3(f2, 2); + f2 = f1--; + cmpVal3(f2, 3); + cmpVal3(f1, 2); + f2 = ++f1; + cmpVal3(f1, 3); + cmpVal3(f2, 3); + f2 = --f1; + cmpVal3(f1, 2); + cmpVal3(f2, 2); + + f2 = ~f1; + cmpVal3(f2, -3); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1 = f1 * (unsigned char)1; + cmpVal3(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed char)1; + cmpVal3(f1, 3); + f1 = (signed char)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal3(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed short)1; + cmpVal3(f1, 3); + f1 = (signed short)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal3(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed int)1; + cmpVal3(f1, 3); + f1 = (signed int)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (float)1; + cmpVal3(f1, 3); + f1 = (float)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal3(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (signed long)1; + cmpVal3(f1, 3); + f1 = (signed long)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (double)1; + cmpVal3(f1, 3); + f1 = (double)1 * f1; + cmpVal3(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal3(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal3(f1, 3); + + longlong3 fa1((unsigned char)1); + longlong3 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1); + longlong3 fb1((signed char)1); + longlong3 fb2((signed char)1, (signed char)1, (signed char)1); + longlong3 fc1((unsigned short)1); + longlong3 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1); + longlong3 fd1((signed short)1); + longlong3 fd2((signed short)1, (signed short)1, (signed short)1); + longlong3 fe1((unsigned int)1); + longlong3 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1); + longlong3 fg1((signed int)1); + longlong3 fg2((signed int)1, (signed int)1, (signed int)1); + longlong3 fh1((float)1); + longlong3 fh2((float)1, (float)1, (float)1); + longlong3 fi1((double)1); + longlong3 fi2((double)1, (double)1, (double)1); + longlong3 fj1((unsigned long)1); + longlong3 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1); + longlong3 fk1((signed long)1); + longlong3 fk2((signed long)1, (signed long)1, (signed long)1); + longlong3 fl1((unsigned long long)1); + longlong3 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + longlong3 fm1((signed long long)1); + longlong3 fm2((signed long long)1, (signed long long)1, (signed long long)1); + + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + +bool TestLongLong4() { + long4 f1, f2, f3; + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f3 = f1 + f2; + cmpVal4(f3, 2); + f2 = f3 - f1; + cmpVal4(f2, 1); + f1 = f2 * f3; + cmpVal4(f1, 2); + f2 = f1 / f3; + cmpVal4(f2, 2/2); + f3 = f1 % f2; + cmpVal4(f3, 0); + f1 = f3 & f2; + cmpVal4(f1, 0); + f2 = f1 ^ f3; + cmpVal4(f2, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f2.x = 2; + f2.y = 2; + f2.z = 2; + f2.w = 2; + f3 = f1 << f2; + cmpVal4(f3, 4); + f2 = f3 >> f1; + cmpVal4(f2, 2); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2.x = 1; + f2.y = 1; + f2.z = 1; + f2.w = 1; + f1 += f2; + cmpVal4(f1, 3); + f1 -= f2; + cmpVal4(f1, 2); + f1 *= f2; + cmpVal4(f1, 2); + f1 /= f2; + cmpVal4(f1, 2); + f1 %= f2; + cmpVal4(f1, 0); + f1 &= f2; + cmpVal4(f1, 0); + f1 |= f2; + cmpVal4(f1, 1); + f1 ^= f2; + cmpVal4(f1, 0); + f1.x = 1; + f1.y = 1; + f1.z = 1; + f1.w = 1; + f1 <<= f2; + cmpVal4(f1, 2); + f1 >>= f2; + cmpVal4(f1, 1); + + f1.x = 2; + f1.y = 2; + f1.z = 2; + f1.w = 2; + f2 = f1++; + cmpVal4(f1, 3); + cmpVal4(f2, 2); + f2 = f1--; + cmpVal4(f2, 3); + cmpVal4(f1, 2); + f2 = ++f1; + cmpVal4(f1, 3); + cmpVal4(f2, 3); + f2 = --f1; + cmpVal4(f1, 2); + cmpVal4(f2, 2); + + f2 = ~f1; + cmpVal4(f2, -3); + assert(!f1 == false); + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f1 = f1 * (unsigned char)1; + cmpVal4(f1, 3); + f1 = (unsigned char)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed char)1; + cmpVal4(f1, 3); + f1 = (signed char)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned short)1; + cmpVal4(f1, 3); + f1 = (unsigned short)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed short)1; + cmpVal4(f1, 3); + f1 = (signed short)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned int)1; + cmpVal4(f1, 3); + f1 = (unsigned int)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed int)1; + cmpVal4(f1, 3); + f1 = (signed int)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (float)1; + cmpVal4(f1, 3); + f1 = (float)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned long)1; + cmpVal4(f1, 3); + f1 = (unsigned long)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (signed long)1; + cmpVal4(f1, 3); + f1 = (signed long)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (double)1; + cmpVal4(f1, 3); + f1 = (double)1 * f1; + cmpVal4(f1, 3); + f1 = f1 * (unsigned long long)1; + cmpVal4(f1, 3); + f1 = (unsigned long long)1 * f1; + cmpVal4(f1, 3); + + longlong4 fa1((unsigned char)1); + longlong4 fa2((unsigned char)1, (unsigned char)1, (unsigned char)1, (unsigned char)1); + longlong4 fb1((signed char)1); + longlong4 fb2((signed char)1, (signed char)1, (signed char)1, (signed char)1); + longlong4 fc1((unsigned short)1); + longlong4 fc2((unsigned short)1, (unsigned short)1, (unsigned short)1, (unsigned short)1); + longlong4 fd1((signed short)1); + longlong4 fd2((signed short)1, (signed short)1, (signed short)1, (signed short)1); + longlong4 fe1((unsigned int)1); + longlong4 fe2((unsigned int)1, (unsigned int)1, (unsigned int)1, (unsigned int)1); + longlong4 fg1((signed int)1); + longlong4 fg2((signed int)1, (signed int)1, (signed int)1, (signed int)1); + longlong4 fh1((float)1); + longlong4 fh2((float)1, (float)1, (float)1, (float)1); + longlong4 fi1((double)1); + longlong4 fi2((double)1, (double)1, (double)1, (double)1); + longlong4 fj1((unsigned long)1); + longlong4 fj2((unsigned long)1, (unsigned long)1, (unsigned long)1, (unsigned long)1); + longlong4 fk1((signed long)1); + longlong4 fk2((signed long)1, (signed long)1, (signed long)1, (signed long)1); + longlong4 fl1((unsigned long long)1); + longlong4 fl2((unsigned long long)1, (unsigned long long)1, (unsigned long long)1, (unsigned long long)1); + longlong4 fm1((signed long long)1); + longlong4 fm2((signed long long)1, (signed long long)1, (signed long long)1, (signed long long)1); + + + f1.x = 3; + f1.y = 3; + f1.z = 3; + f1.w = 3; + f2.x = 4; + f2.y = 4; + f2.z = 4; + f2.w = 4; + f3.x = 3; + f3.y = 3; + f3.z = 3; + f3.w = 3; + assert((f1 == f2) == false); + assert((f1 != f2) == true); + assert((f1 < f2) == true); + assert((f2 > f1) == true); + assert((f1 >= f3) == true); + assert((f1 <= f3) == true); + + assert((f1 && f2) == true); + assert((f1 || f2) == true); + return true; +} + int main() { assert(sizeof(float1) == 4); assert(sizeof(float2) == 8); assert(sizeof(float3) == 12); assert(sizeof(float4) == 16); assert(TestFloat1() && TestFloat2() && TestFloat3() && TestFloat4() + && TestDouble1() && TestDouble2() && TestDouble3() && TestDouble4() && TestUChar1() && TestUChar2() && TestUChar3() && TestUChar4() && TestChar1() && TestChar2() && TestChar3() && TestChar4() && TestUShort1() && TestUShort2() && TestUShort3() && TestUShort4() @@ -3480,7 +7830,9 @@ int main() { && TestUInt1() && TestUInt2() && TestUInt3() && TestUInt4() && TestInt1() && TestInt2() && TestInt3() && TestInt4() && TestULong1() && TestULong2() && TestULong3() && TestULong4() - && TestLong1() && TestLong2() && TestLong3() && TestLong4() == true); + && TestLong1() && TestLong2() && TestLong3() && TestLong4() + && TestULongLong1() && TestULongLong2() && TestULongLong3() && TestULongLong4() + && TestLongLong1() && TestLongLong2() && TestLongLong3() && TestLongLong4() == true); passed(); float1 f1 = make_float1(1.0f); } From 35d8bac54280fd88a11c6d5963e062f33321d1f1 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Fri, 20 Jan 2017 14:11:45 -0600 Subject: [PATCH 089/281] added nvcc backend for hipArrays 1. Added hip_texture.h to hip_runtime_api.h as cuda does declare array runtime apis inside cuda_runtime_api.h 2. Added nvcc backend for hipArray runtime apis 3. Didn't test on nvidia platform (should work) Change-Id: I1a14aef41840e4f55e5535132e3443a918b55967 [ROCm/hip commit: b1eca6c855fbc8444aa62b75551d7d3ea33bd23b] --- .../include/hip/hcc_detail/hip_runtime_api.h | 1 + .../include/hip/nvcc_detail/hip_runtime_api.h | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h index 4c9cedecc4..448102a1c6 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h @@ -33,6 +33,7 @@ THE SOFTWARE. #include #include +#include #if defined (__HCC__) && (__hcc_workweek__ < 16155) #error("This version of HIP requires a newer version of HCC."); diff --git a/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h b/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h index 7df6706186..482e91e440 100644 --- a/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h @@ -85,6 +85,10 @@ typedef CUdevice hipDevice_t; typedef CUmodule hipModule_t; typedef CUfunction hipFunction_t; typedef CUdeviceptr hipDeviceptr_t; +typedef cudaChannelFormatKind hipChannelFormatKind; +typedef cudaChannelFormatDesc hipChannelFormatDesc; +typedef cudaTextureReadMode hipTextureReadMode; +typedef cudaArray hipArray // Flags that can be used with hipStreamCreateWithFlags #define hipStreamDefault cudaStreamDefault @@ -215,6 +219,14 @@ inline static hipError_t hipHostMalloc(void** ptr, size_t size, unsigned int fla return hipCUDAErrorTohipError(cudaHostAlloc(ptr, size, flags)); } +inline static hipError_t hipMallocArray(hipArray** array, const hipChannelFormatDesc* desc, size_width, size_t height, unsigned int flags) { + return hipCUDAErrorTohipError(cudaMallocArray(array, desc, width, height, flags)); +} + +inline static hipError_t hipFreeArray(hipArray* array) { + return hipCUDAErrorTohipError(cudaFreeArray(array)); +} + inline static hipError_t hipHostGetDevicePointer(void** devPtr, void* hostPtr, unsigned int flags){ return hipCUDAErrorTohipError(cudaHostGetDevicePointer(devPtr, hostPtr, flags)); } @@ -321,6 +333,18 @@ inline static hipError_t hipMemcpyToSymbolAsync(const void* symbol, const void* return hipCUDAErrorTohipError(cudaMemcpyToSymbolAsync(symbol, src, sizeBytes, offset, hipMemcpyKindToCudaMemcpyKind(copyType))); } +inline static hipError_t hipMemcpy2D(void* dst, size_t dpitch, const void* src, size_t spitch, size_t width, size_t height, hipMemcpyKind kind){ + return hipCUDAErrorTohipError(cudaMemcpy2D(dst, dpitch, src, width, height, kind)); +} + +inline static hipError_t hipMemcpy2DToArray(hipArray *dst, size_t wOffset, size_t hOffset, const void* src, size_t spitch, size_t width, size_t height, hipMemcpyKind kind){ + return hipCUDAErrorTohipError(cudaMemcpy2DToArray(dst, wOffset, hOffset, src, spitch, width, height, kind)); +} + +inline static hipError_t hipMemcpyToArray(hipArray* dst, size_t wOffset, size_t hOffset, const void* src, size_t count, hipMemcpyKind kind) { + return hipCUDAErrorTohipError(cudaMemcpy2DToArray(dst, wOffset, hOffset, src, count, kind)); +} + inline static hipError_t hipDeviceSynchronize() { return hipCUDAErrorTohipError(cudaDeviceSynchronize()); } From 83260101e1f540a0f803d506259b326136a46c72 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Fri, 20 Jan 2017 14:19:09 -0600 Subject: [PATCH 090/281] changes device functions documentation according to the supported apis Change-Id: I47ac6bbde11d54d8265e0d27ec8cd5da4d03eb8e [ROCm/hip commit: 7765469987fe1745db38556850f496e04cb6f7f9] --- projects/hip/docs/markdown/hip-math-api.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/projects/hip/docs/markdown/hip-math-api.md b/projects/hip/docs/markdown/hip-math-api.md index 6a8e90eb59..37efafbbbf 100644 --- a/projects/hip/docs/markdown/hip-math-api.md +++ b/projects/hip/docs/markdown/hip-math-api.md @@ -118,7 +118,7 @@ __device__ float coshf(float x); ### cospif ```cpp -__device__ __host__ float cospif(float x); +__device__ float cospif(float x); ``` **Description:** Supported @@ -230,7 +230,7 @@ __device__ float fdimf(float x, float y); ### fdividef ```cpp -__device__ __host__ float fdividef(float x, float y); +__device__ float fdividef(float x, float y); ``` **Description:** Supported @@ -302,7 +302,7 @@ __device__ float ilogbf(float x); ### isfinite ```cpp -__device__ __host__ int isfinite(float a); +__device__ int isfinite(float a); ``` **Description:** Supported @@ -574,7 +574,7 @@ __device__ float roundf(float x); ### rsqrtf ```cpp -__device__ __host__ float rsqrtf(float x); +__device__ float rsqrtf(float x); ``` **Description:** Supported @@ -598,7 +598,7 @@ __device__ float scalbnf(float x, int n); ### signbit ```cpp -__device__ __host__ unsigned signbit(float a); +__device__ int signbit(float a); ``` **Description:** Supported @@ -638,7 +638,7 @@ __device__ float sinhf(float x); ### sinpif ```cpp -__device__ __host__ float sinpif(float x); +__device__ float sinpif(float x); ``` **Description:** Supported @@ -806,7 +806,7 @@ __device__ double cosh(double x); ### cospi ```cpp -__device__ __host__ double cospi(double x); +__device__ double cospi(double x); ``` **Description:** Supported @@ -982,7 +982,7 @@ __device__ double ilogb(double x); ### isfinite ```cpp -__device__ __host__ unsigned isfinite(double x); +__device__ int isfinite(double x); ``` **Description:** Supported @@ -1270,7 +1270,7 @@ __device__ double round(double x); ### rsqrt ```cpp -__device__ __host__ double rsqrt(double x); +__device__ double rsqrt(double x); ``` **Description:** Supported @@ -1294,7 +1294,7 @@ __device__ double scalbn(double x, int n); ### signbit ```cpp -__device__ __host__ unsigned signbit(double a); +__device__ int signbit(double a); ``` **Description:** Supported @@ -1334,7 +1334,7 @@ __device__ double sinh(double x); ### sinpi ```cpp -__device__ __host__ double sinpi(double x); +__device__ double sinpi(double x); ``` **Description:** Supported From d48571b65bc7a8758e5ed94d32d380684af5d6f6 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Fri, 20 Jan 2017 16:54:48 -0600 Subject: [PATCH 091/281] fixed hipArray issues 1. Fixed build issues produced from previous commit 2. Create new header files to manage data structures better Change-Id: I704d82c196c1858ed7617d76e40612eb507d2aa0 [ROCm/hip commit: 22acd654cf788dd3435d41b13f376617ec9a10b2] --- projects/hip/include/hip/channel_descriptor.h | 36 ++ .../hip/hcc_detail/channel_descriptor.h | 374 ++++++++++++++++++ .../hip/include/hip/hcc_detail/driver_types.h | 41 ++ .../include/hip/hcc_detail/hip_runtime_api.h | 171 +++++++- .../hip/include/hip/hcc_detail/hip_texture.h | 238 +---------- .../include/hip/hcc_detail/texture_types.h | 42 ++ projects/hip/include/hip/math_functions.h | 13 - .../hip/nvcc_detail/channel_descriptor.h | 25 ++ .../include/hip/nvcc_detail/hip_runtime_api.h | 2 +- 9 files changed, 691 insertions(+), 251 deletions(-) create mode 100644 projects/hip/include/hip/channel_descriptor.h create mode 100644 projects/hip/include/hip/hcc_detail/channel_descriptor.h create mode 100644 projects/hip/include/hip/hcc_detail/driver_types.h create mode 100644 projects/hip/include/hip/hcc_detail/texture_types.h create mode 100644 projects/hip/include/hip/nvcc_detail/channel_descriptor.h diff --git a/projects/hip/include/hip/channel_descriptor.h b/projects/hip/include/hip/channel_descriptor.h new file mode 100644 index 0000000000..af8875e256 --- /dev/null +++ b/projects/hip/include/hip/channel_descriptor.h @@ -0,0 +1,36 @@ +/* +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#pragma once + +// Some standard header files, these are included by hc.hpp and so want to make them avail on both +// paths to provide a consistent include env and avoid "missing symbol" errors that only appears +// on NVCC path: + + +#if defined(__HIP_PLATFORM_HCC__) && !defined (__HIP_PLATFORM_NVCC__) +#include +#elif defined(__HIP_PLATFORM_NVCC__) && !defined (__HIP_PLATFORM_HCC__) +#include +#else +#error("Must define exactly one of __HIP_PLATFORM_HCC__ or __HIP_PLATFORM_NVCC__"); +#endif diff --git a/projects/hip/include/hip/hcc_detail/channel_descriptor.h b/projects/hip/include/hip/hcc_detail/channel_descriptor.h new file mode 100644 index 0000000000..91d48af4cf --- /dev/null +++ b/projects/hip/include/hip/hcc_detail/channel_descriptor.h @@ -0,0 +1,374 @@ +/* +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#ifndef HIP_HCC_DETAIL_CHANNEL_DESCRIPTOR_H +#define HIP_HCC_DETAIL_CHANNEL_DESCRIPTOR_H + +#include +#include + +hipChannelFormatDesc hipCreateChannelDesc(int x, int y, int z, int w, hipChannelFormatKind f); + +template +static inline hipChannelFormatDesc hipCreateChannelDesc() { + return hipCreateChannelDesc(0, 0, 0, 0, hipChannelFormatKindNone); +} + +static inline hipChannelFormatDesc hipCreateChannelDescHalf() { + int e = (int)sizeof(unsigned short) * 8; + return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindFloat); +} + +static inline hipChannelFormatDesc hipCreateChannelDescHalf1() { + int e = (int)sizeof(unsigned short) * 8; + return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindFloat); +} + +static inline hipChannelFormatDesc hipCreateChannelDescHalf2() +{ + int e = (int)sizeof(unsigned short) * 8; + return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindFloat); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(char) * 8; + return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindSigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(signed char) * 8; + return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindUnsigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(unsigned char) * 8; + return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindUnsigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(unsigned char) * 8; + return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindSigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(signed char) * 8; + return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindSigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(unsigned char) * 8; + return hipCreateChannelDesc(e, e, 0, 0, hipChannelFormatKindSigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(signed char) * 8; + return hipCreateChannelDesc(e, e, 0, 0, hipChannelFormatKindSigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(unsigned char) * 8; + return hipCreateChannelDesc(e, e, e, 0, hipChannelFormatKindSigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(signed char) * 8; + return hipCreateChannelDesc(e, e, e, 0, hipChannelFormatKindSigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(unsigned char) * 8; + return hipCreateChannelDesc(e, e, e, e, hipChannelFormatKindSigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(signed char) * 8; + return hipCreateChannelDesc(e, e, e, e, hipChannelFormatKindSigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(unsigned short) * 8; + return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindUnsigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(signed short) * 8; + return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindSigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(unsigned short) * 8; + return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindUnsigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(signed short) * 8; + return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindSigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(unsigned short) * 8; + return hipCreateChannelDesc(e, e, 0, 0, hipChannelFormatKindUnsigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(signed short) * 8; + return hipCreateChannelDesc(e, e, 0, 0, hipChannelFormatKindSigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(unsigned short) * 8; + return hipCreateChannelDesc(e, e, e, 0, hipChannelFormatKindUnsigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(signed short) * 8; + return hipCreateChannelDesc(e, e, e, 0, hipChannelFormatKindSigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(unsigned short) * 8; + return hipCreateChannelDesc(e, e, e, e, hipChannelFormatKindUnsigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(signed short) * 8; + return hipCreateChannelDesc(e, e, e, e, hipChannelFormatKindSigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(unsigned int) * 8; + return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindUnsigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(signed int) * 8; + return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindSigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(unsigned int) * 8; + return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindUnsigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(signed int) * 8; + return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindSigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(unsigned int) * 8; + return hipCreateChannelDesc(e, e, 0, 0, hipChannelFormatKindUnsigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(signed int) * 8; + return hipCreateChannelDesc(e, e, 0, 0, hipChannelFormatKindSigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(unsigned int) * 8; + return hipCreateChannelDesc(e, e, e, 0, hipChannelFormatKindUnsigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(signed int) * 8; + return hipCreateChannelDesc(e, e, e, 0, hipChannelFormatKindSigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(unsigned int) * 8; + return hipCreateChannelDesc(e, e, e, e, hipChannelFormatKindUnsigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(signed int) * 8; + return hipCreateChannelDesc(e, e, e, e, hipChannelFormatKindSigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(float) * 8; + return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindFloat); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(float) * 8; + return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindFloat); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(float) * 8; + return hipCreateChannelDesc(e, e, 0, 0, hipChannelFormatKindFloat); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(float) * 8; + return hipCreateChannelDesc(e, e, e, 0, hipChannelFormatKindFloat); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(float) * 8; + return hipCreateChannelDesc(e, e, e, e, hipChannelFormatKindFloat); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(unsigned long) * 8; + return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindUnsigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(signed long) * 8; + return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindSigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(unsigned long) * 8; + return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindUnsigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(signed long) * 8; + return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindSigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(unsigned long) * 8; + return hipCreateChannelDesc(e, e, 0, 0, hipChannelFormatKindUnsigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(signed long) * 8; + return hipCreateChannelDesc(e, e, 0, 0, hipChannelFormatKindSigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(unsigned long) * 8; + return hipCreateChannelDesc(e, e, e, 0, hipChannelFormatKindUnsigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(signed long) * 8; + return hipCreateChannelDesc(e, e, e, 0, hipChannelFormatKindSigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(unsigned long) * 8; + return hipCreateChannelDesc(e, e, e, e, hipChannelFormatKindUnsigned); +} + +template<> +inline hipChannelFormatDesc hipCreateChannelDesc() +{ + int e = (int)sizeof(signed long) * 8; + return hipCreateChannelDesc(e, e, e, e, hipChannelFormatKindSigned); +} + +#endif diff --git a/projects/hip/include/hip/hcc_detail/driver_types.h b/projects/hip/include/hip/hcc_detail/driver_types.h new file mode 100644 index 0000000000..1fe72b0507 --- /dev/null +++ b/projects/hip/include/hip/hcc_detail/driver_types.h @@ -0,0 +1,41 @@ +/* +Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#ifndef HIP_HCC_DETAIL_DRIVER_TYPES_H +#define HIP_HCC_DETAIL_DRIVER_TYPES_H + +enum hipChannelFormatKind +{ + hipChannelFormatKindSigned = 0, + hipChannelFormatKindUnsigned = 1, + hipChannelFormatKindFloat = 2, + hipChannelFormatKindNone = 3 +}; + +struct hipChannelFormatDesc +{ + int x; + int y; + int z; + int w; + enum hipChannelFormatKind f; +}; + + +#endif diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h index 448102a1c6..f9ab03901a 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -21,8 +21,8 @@ THE SOFTWARE. */ //#pragma once -#ifndef HIP_RUNTIME_API_H -#define HIP_RUNTIME_API_H +#ifndef HIP_HCC_DETAIL_HIP_RUNTIME_API_H +#define HIP_HCC_DETAIL_HIP_RUNTIME_API_H /** * @file hcc_detail/hip_runtime_api.h * @brief Contains C function APIs for HIP runtime. This file does not use any HCC builtin or special language extensions (-hc mode) ; those functions in hip_runtime.h. @@ -177,6 +177,12 @@ typedef enum hipMemcpyKind { ,hipMemcpyDefault = 4, ///< Runtime will automatically determine copy-kind based on virtual addresses. } hipMemcpyKind; +typedef struct { + unsigned int width; + unsigned int height; + hipChannelFormatKind f; + void* data; //FIXME: generalize this +} hipArray; @@ -1235,6 +1241,84 @@ hipError_t hipMemsetAsync(void* dst, int value, size_t sizeBytes, hipStream_t st **/ hipError_t hipMemGetInfo (size_t * free, size_t * total) ; + +/** + * @brief Allocate an array on the device. + * + * @param[out] array Pointer to allocated array in device memory + * @param[in] desc Requested channel format + * @param[in] width Requested array allocation width + * @param[in] height Requested array allocation height + * @param[in] flags Requested properties of allocated array + * @return #hipSuccess, #hipErrorMemoryAllocation + * + * @see hipMalloc, hipMallocPitch, hipFree, hipFreeArray, hipHostMalloc, hipHostFree + */ +hipError_t hipMallocArray(hipArray** array, const hipChannelFormatDesc* desc, + size_t width, size_t height = 0, unsigned int flags = 0); + +/** + * @brief Frees an array on the device. + * + * @param[in] array Pointer to array to free + * @return #hipSuccess, #hipErrorInvalidValue, #hipErrorInitializationError + * + * @see hipMalloc, hipMallocPitch, hipFree, hipMallocArray, hipHostMalloc, hipHostFree + */ +hipError_t hipFreeArray(hipArray* array); + +/** + * @brief Copies data between host and device. + * + * @param[in] dst Destination memory address + * @param[in] dpitch Pitch of destination memory + * @param[in] src Source memory address + * @param[in] spitch Pitch of source memory + * @param[in] width Width of matrix transfer (columns in bytes) + * @param[in] height Height of matrix transfer (rows) + * @param[in] kind Type of transfer + * @return #hipSuccess, #hipErrorInvalidValue, #hipErrorInvalidPitchValue, #hipErrorInvalidDevicePointer, #hipErrorInvalidMemcpyDirection + * + * @see hipMemcpy, hipMemcpyToArray, hipMemcpy2DToArray, hipMemcpyFromArray, hipMemcpyToSymbol, hipMemcpyAsync + */ +hipError_t hipMemcpy2D(void* dst, size_t dpitch, const void* src, size_t spitch, size_t width, size_t height, hipMemcpyKind kind); + +/** + * @brief Copies data between host and device. + * + * @param[in] dst Destination memory address + * @param[in] dpitch Pitch of destination memory + * @param[in] src Source memory address + * @param[in] spitch Pitch of source memory + * @param[in] width Width of matrix transfer (columns in bytes) + * @param[in] height Height of matrix transfer (rows) + * @param[in] kind Type of transfer + * @return #hipSuccess, #hipErrorInvalidValue, #hipErrorInvalidPitchValue, #hipErrorInvalidDevicePointer, #hipErrorInvalidMemcpyDirection + * + * @see hipMemcpy, hipMemcpyToArray, hipMemcpy2D, hipMemcpyFromArray, hipMemcpyToSymbol, hipMemcpyAsync + */ +hipError_t hipMemcpy2DToArray(hipArray* dst, size_t wOffset, size_t hOffset, const void* src, + size_t spitch, size_t width, size_t height, hipMemcpyKind kind); + +/** + * @brief Copies data between host and device. + * + * @param[in] dst Destination memory address + * @param[in] dpitch Pitch of destination memory + * @param[in] src Source memory address + * @param[in] spitch Pitch of source memory + * @param[in] width Width of matrix transfer (columns in bytes) + * @param[in] height Height of matrix transfer (rows) + * @param[in] kind Type of transfer + * @return #hipSuccess, #hipErrorInvalidValue, #hipErrorInvalidPitchValue, #hipErrorInvalidDevicePointer, #hipErrorInvalidMemcpyDirection + * + * @see hipMemcpy, hipMemcpy2DToArray, hipMemcpy2D, hipMemcpyFromArray, hipMemcpyToSymbol, hipMemcpyAsync + */ +hipError_t hipMemcpyToArray(hipArray* dst, size_t wOffset, size_t hOffset, + const void* src, size_t count, hipMemcpyKind kind); + + + // doxygen end Memory /** * @} @@ -1911,6 +1995,87 @@ hipError_t hipIpcCloseMemHandle(void *devPtr); } /* extern "c" */ #endif +#ifdef __cplusplus +/* + * @brief hipBindTexture Binds size bytes of the memory area pointed to by @p devPtr to the texture reference tex. + * + * @p desc describes how the memory is interpreted when fetching values from the texture. The @p offset parameter is an optional byte offset as with the low-level + * hipBindTexture() function. Any memory previously bound to tex is unbound. + * + * @param[in] offset - Offset in bytes + * @param[out] tex - texture to bind + * @param[in] devPtr - Memory area on device + * @param[in] desc - Channel format + * @param[in] size - Size of the memory area pointed to by devPtr + * @return #hipSuccess, #hipErrorInvalidValue, #hipErrorMemoryFree, #hipErrorUnknown + **/ +template +hipError_t hipBindTexture(size_t *offset, + struct texture &tex, + const void *devPtr, + const struct hipChannelFormatDesc *desc, + size_t size=UINT_MAX) +{ + tex._dataPtr = static_cast(devPtr); + + return hipSuccess; +} + +/* + * @brief hipBindTexture Binds size bytes of the memory area pointed to by @p devPtr to the texture reference tex. + * + * @p desc describes how the memory is interpreted when fetching values from the texture. The @p offset parameter is an optional byte offset as with the low-level + * hipBindTexture() function. Any memory previously bound to tex is unbound. + * + * @param[in] offset - Offset in bytes + * @param[in] tex - texture to bind + * @param[in] devPtr - Memory area on device + * @param[in] size - Size of the memory area pointed to by devPtr + * @return #hipSuccess, #hipErrorInvalidValue, #hipErrorMemoryFree, #hipErrorUnknown + **/ +template +hipError_t hipBindTexture(size_t *offset, + struct texture &tex, + const void *devPtr, + size_t size=UINT_MAX) +{ + return hipBindTexture(offset, tex, devPtr, &tex.channelDesc, size); +} + +template +hipError_t hipBindTextureToArray(struct texture &tex, hipArray* array) { + tex.width = array->width; + tex.height = array->height; + tex._dataPtr = static_cast(array->data); + return hipSuccess; +} + +/* + * @brief Unbinds the textuer bound to @p tex + * + * @param[in] tex - texture to unbind + * + * @return #hipSuccess + **/ +template +hipError_t hipUnbindTexture(struct texture &tex) +{ + tex._dataPtr = NULL; + + return hipSuccess; +} + + + +// doxygen end Texture +/** + * @} + */ + + +#endif + + /** *------------------------------------------------------------------------------------------------- *------------------------------------------------------------------------------------------------- diff --git a/projects/hip/include/hip/hcc_detail/hip_texture.h b/projects/hip/include/hip/hcc_detail/hip_texture.h index fe13f11e49..bd44206be4 100644 --- a/projects/hip/include/hip/hcc_detail/hip_texture.h +++ b/projects/hip/include/hip/hcc_detail/hip_texture.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -31,48 +31,16 @@ THE SOFTWARE. */ #include - +#include +#include //#include //---- //Texture - TODO - likely need to move this to a separate file only included with kernel compilation. #define hipTextureType1D 1 -typedef enum { - hipChannelFormatKindSigned = 0, - hipChannelFormatKindUnsigned, - hipChannelFormatKindFloat, - hipChannelFormatKindNone - -} hipChannelFormatKind; - -typedef struct hipChannelFormatDesc { - int x; - int y; - int z; - int w; - hipChannelFormatKind f; -} hipChannelFormatDesc; - -typedef enum hipTextureReadMode -{ - hipReadModeElementType, ///< Read texture as specified element type -//! @warning cudaReadModeNormalizedFloat is not supported. -} hipTextureReadMode; - -typedef enum hipTextureFilterMode -{ - hipFilterModePoint, ///< Point filter mode. -//! @warning cudaFilterModeLinear is not supported. -} hipTextureFilterMode; - -struct textureReference { - hipTextureFilterMode filterMode; - bool normalized; - hipChannelFormatDesc channelDesc; -}; #if __cplusplus -template +template struct texture : public textureReference { const T * _dataPtr; // pointer to underlying data. @@ -84,95 +52,12 @@ struct texture : public textureReference { }; #endif -typedef struct { - unsigned int width; - unsigned int height; - hipChannelFormatKind f; - void* data; //FIXME: generalize this -} hipArray; - #define tex1Dfetch(_tex, _addr) (_tex._dataPtr[_addr]) #define tex2D(_tex, _dx, _dy) \ _tex._dataPtr[(unsigned int)_dx + (unsigned int)_dy*(_tex.width)] -/** - * @brief Allocate an array on the device. - * - * @param[out] array Pointer to allocated array in device memory - * @param[in] desc Requested channel format - * @param[in] width Requested array allocation width - * @param[in] height Requested array allocation height - * @param[in] flags Requested properties of allocated array - * @return #hipSuccess, #hipErrorMemoryAllocation - * - * @see hipMalloc, hipMallocPitch, hipFree, hipFreeArray, hipHostMalloc, hipHostFree - */ -hipError_t hipMallocArray(hipArray** array, const hipChannelFormatDesc* desc, - size_t width, size_t height = 0, unsigned int flags = 0); - -/** - * @brief Frees an array on the device. - * - * @param[in] array Pointer to array to free - * @return #hipSuccess, #hipErrorInvalidValue, #hipErrorInitializationError - * - * @see hipMalloc, hipMallocPitch, hipFree, hipMallocArray, hipHostMalloc, hipHostFree - */ -hipError_t hipFreeArray(hipArray* array); - -/** - * @brief Copies data between host and device. - * - * @param[in] dst Destination memory address - * @param[in] dpitch Pitch of destination memory - * @param[in] src Source memory address - * @param[in] spitch Pitch of source memory - * @param[in] width Width of matrix transfer (columns in bytes) - * @param[in] height Height of matrix transfer (rows) - * @param[in] kind Type of transfer - * @return #hipSuccess, #hipErrorInvalidValue, #hipErrorInvalidPitchValue, #hipErrorInvalidDevicePointer, #hipErrorInvalidMemcpyDirection - * - * @see hipMemcpy, hipMemcpyToArray, hipMemcpy2DToArray, hipMemcpyFromArray, hipMemcpyToSymbol, hipMemcpyAsync - */ -hipError_t hipMemcpy2D(void* dst, size_t dpitch, const void* src, size_t spitch, size_t width, size_t height, hipMemcpyKind kind); - -/** - * @brief Copies data between host and device. - * - * @param[in] dst Destination memory address - * @param[in] dpitch Pitch of destination memory - * @param[in] src Source memory address - * @param[in] spitch Pitch of source memory - * @param[in] width Width of matrix transfer (columns in bytes) - * @param[in] height Height of matrix transfer (rows) - * @param[in] kind Type of transfer - * @return #hipSuccess, #hipErrorInvalidValue, #hipErrorInvalidPitchValue, #hipErrorInvalidDevicePointer, #hipErrorInvalidMemcpyDirection - * - * @see hipMemcpy, hipMemcpyToArray, hipMemcpy2D, hipMemcpyFromArray, hipMemcpyToSymbol, hipMemcpyAsync - */ -hipError_t hipMemcpy2DToArray(hipArray* dst, size_t wOffset, size_t hOffset, const void* src, - size_t spitch, size_t width, size_t height, hipMemcpyKind kind); - -/** - * @brief Copies data between host and device. - * - * @param[in] dst Destination memory address - * @param[in] dpitch Pitch of destination memory - * @param[in] src Source memory address - * @param[in] spitch Pitch of source memory - * @param[in] width Width of matrix transfer (columns in bytes) - * @param[in] height Height of matrix transfer (rows) - * @param[in] kind Type of transfer - * @return #hipSuccess, #hipErrorInvalidValue, #hipErrorInvalidPitchValue, #hipErrorInvalidDevicePointer, #hipErrorInvalidMemcpyDirection - * - * @see hipMemcpy, hipMemcpy2DToArray, hipMemcpy2D, hipMemcpyFromArray, hipMemcpyToSymbol, hipMemcpyAsync - */ -hipError_t hipMemcpyToArray(hipArray* dst, size_t wOffset, size_t hOffset, - const void* src, size_t count, hipMemcpyKind kind); - - /** * @addtogroup API HIP API * @{ @@ -212,120 +97,6 @@ hipChannelFormatDesc hipBindTexture(size_t *offset, struct textureReference *te } #endif -/** - * @brief Returns a channel descriptor using the specified format. - * - * @param[in] x X component - * @param[in] y Y component - * @param[in] z Z component - * @param[in] w W component - * @param[in] f Channel format - * @return Channel descriptor with format f - * - */ -hipChannelFormatDesc hipCreateChannelDesc(int x, int y, int z, int w, hipChannelFormatKind f); - -// descriptors -template inline hipChannelFormatDesc hipCreateChannelDesc() { - return hipCreateChannelDesc(0, 0, 0, 0, hipChannelFormatKindNone); -} -template <> inline hipChannelFormatDesc hipCreateChannelDesc() { - int e = (int)sizeof(int) * 8; - return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindSigned); -} -template <> inline hipChannelFormatDesc hipCreateChannelDesc() { - int e = (int)sizeof(unsigned int) * 8; - return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindUnsigned); -} -template <> inline hipChannelFormatDesc hipCreateChannelDesc() { - int e = (int)sizeof(long) * 8; - return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindSigned); -} -template <> inline hipChannelFormatDesc hipCreateChannelDesc() { - int e = (int)sizeof(unsigned long) * 8; - return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindUnsigned); -} -template <> inline hipChannelFormatDesc hipCreateChannelDesc() { - int e = (int)sizeof(float) * 8; - return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindFloat); -} - -/* - * @brief hipBindTexture Binds size bytes of the memory area pointed to by @p devPtr to the texture reference tex. - * - * @p desc describes how the memory is interpreted when fetching values from the texture. The @p offset parameter is an optional byte offset as with the low-level - * hipBindTexture() function. Any memory previously bound to tex is unbound. - * - * @param[in] offset - Offset in bytes - * @param[out] tex - texture to bind - * @param[in] devPtr - Memory area on device - * @param[in] desc - Channel format - * @param[in] size - Size of the memory area pointed to by devPtr - * @return #hipSuccess, #hipErrorInvalidValue, #hipErrorMemoryFree, #hipErrorUnknown - **/ -template -hipError_t hipBindTexture(size_t *offset, - struct texture &tex, - const void *devPtr, - const struct hipChannelFormatDesc *desc, - size_t size=UINT_MAX) -{ - tex._dataPtr = static_cast(devPtr); - - return hipSuccess; -} - -/* - * @brief hipBindTexture Binds size bytes of the memory area pointed to by @p devPtr to the texture reference tex. - * - * @p desc describes how the memory is interpreted when fetching values from the texture. The @p offset parameter is an optional byte offset as with the low-level - * hipBindTexture() function. Any memory previously bound to tex is unbound. - * - * @param[in] offset - Offset in bytes - * @param[in] tex - texture to bind - * @param[in] devPtr - Memory area on device - * @param[in] size - Size of the memory area pointed to by devPtr - * @return #hipSuccess, #hipErrorInvalidValue, #hipErrorMemoryFree, #hipErrorUnknown - **/ -template -hipError_t hipBindTexture(size_t *offset, - struct texture &tex, - const void *devPtr, - size_t size=UINT_MAX) -{ - return hipBindTexture(offset, tex, devPtr, &tex.channelDesc, size); -} - -template -hipError_t hipBindTextureToArray(struct texture &tex, hipArray* array) { - tex.width = array->width; - tex.height = array->height; - tex._dataPtr = static_cast(array->data); - return hipSuccess; -} - -/* - * @brief Unbinds the textuer bound to @p tex - * - * @param[in] tex - texture to unbind - * - * @return #hipSuccess - **/ -template -hipError_t hipUnbindTexture(struct texture &tex) -{ - tex._dataPtr = NULL; - - return hipSuccess; -} - - - -// doxygen end Texture -/** - * @} - */ - // End doxygen API: /** @@ -333,4 +104,3 @@ hipError_t hipUnbindTexture(struct texture &tex) */ #endif - diff --git a/projects/hip/include/hip/hcc_detail/texture_types.h b/projects/hip/include/hip/hcc_detail/texture_types.h new file mode 100644 index 0000000000..d9221dc009 --- /dev/null +++ b/projects/hip/include/hip/hcc_detail/texture_types.h @@ -0,0 +1,42 @@ +/* +Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + + +#ifndef HIP_HCC_DETAIL_TEXTURE_TYPES_H +#define HIP_HCC_DETAIL_TEXTURE_TYPES_H + +#include + +enum hipTextureReadMode +{ + hipReadModeElementType = 0 +}; + +enum hipTextureFilterMode +{ + hipFilterModePoint = 0 +}; + +struct textureReference { + hipTextureFilterMode filterMode; + bool normalized; + hipChannelFormatDesc channelDesc; +}; + +#endif diff --git a/projects/hip/include/hip/math_functions.h b/projects/hip/include/hip/math_functions.h index d33f7a2e90..6afe463a5d 100644 --- a/projects/hip/include/hip/math_functions.h +++ b/projects/hip/include/hip/math_functions.h @@ -20,19 +20,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -//! HIP = Heterogeneous-compute Interface for Portability -//! -//! Define a extremely thin runtime layer that allows source code to be compiled unmodified -//! through either AMD HCC or NVCC. Key features tend to be in the spirit -//! and terminology of CUDA, but with a portable path to other accelerators as well: -// -//! Both paths support rich C++ features including classes, templates, lambdas, etc. -//! Runtime API is C -//! Memory management is based on pure pointers and resembles malloc/free/copy. -// -//! hip_runtime.h : includes everything in hip_api.h, plus math builtins and kernel launch macros. -//! hip_runtime_api.h : Defines HIP API. This is a C header file and does not use any C++ features. - #pragma once // Some standard header files, these are included by hc.hpp and so want to make them avail on both diff --git a/projects/hip/include/hip/nvcc_detail/channel_descriptor.h b/projects/hip/include/hip/nvcc_detail/channel_descriptor.h new file mode 100644 index 0000000000..8502745968 --- /dev/null +++ b/projects/hip/include/hip/nvcc_detail/channel_descriptor.h @@ -0,0 +1,25 @@ +/* +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#pragma once + +#include"channel_descriptor.h" diff --git a/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h b/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h index 482e91e440..3cd5667175 100644 --- a/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From ed03475a09db87c1d60634e34abdc04a1391426c Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Fri, 20 Jan 2017 17:09:52 -0600 Subject: [PATCH 092/281] added driver_types.h and texture_types.h header files to hip Change-Id: Ic3b2403f07d6767dadf83d6c278fd14e87f6acdb [ROCm/hip commit: 8ddec0426ba9d23fe45caa03c2200aeb49e104c6] --- projects/hip/include/hip/driver_types.h | 29 +++++++++++++++++++++++ projects/hip/include/hip/texture_types.h | 30 ++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 projects/hip/include/hip/driver_types.h create mode 100644 projects/hip/include/hip/texture_types.h diff --git a/projects/hip/include/hip/driver_types.h b/projects/hip/include/hip/driver_types.h new file mode 100644 index 0000000000..a4010d6b4e --- /dev/null +++ b/projects/hip/include/hip/driver_types.h @@ -0,0 +1,29 @@ +/* +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#pragma once + +#include + +#if defined(__HIP_PLATFORM_HCC__) && !defined (__HIP_PLATFORM_NVCC__) +#include +#elif defined(__HIP_PLATFORM_NVCC__) && !defined (__HIP_PLATFORM_HCC__) +#include "driver_types.h" +#else +#error("Must define exactly one of __HIP_PLATFORM_HCC__ or __HIP_PLATFORM_NVCC__"); +#endif diff --git a/projects/hip/include/hip/texture_types.h b/projects/hip/include/hip/texture_types.h new file mode 100644 index 0000000000..2561e12eb5 --- /dev/null +++ b/projects/hip/include/hip/texture_types.h @@ -0,0 +1,30 @@ +/* +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#pragma once + +#include + +#if defined(__HIP_PLATFORM_HCC__) && !defined (__HIP_PLATFORM_NVCC__) +#include +#elif defined(__HIP_PLATFORM_NVCC__) && !defined (__HIP_PLATFORM_HCC__) +#include "texture_types.h" +#else +#error("Must define exactly one of __HIP_PLATFORM_HCC__ or __HIP_PLATFORM_NVCC__"); +#endif From b7340001099883f6ae12b28c59de8e337af2270e Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Fri, 20 Jan 2017 17:21:51 -0600 Subject: [PATCH 093/281] added ir code sad u8 Change-Id: Ie0d454b3bb9a6c9a028c091ad3aa969719b02cc9 [ROCm/hip commit: 4e3afa65140520feba7712a0f123d8ea29b80c28] --- projects/hip/src/hip_ir.ll | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/projects/hip/src/hip_ir.ll b/projects/hip/src/hip_ir.ll index a20b57016e..c68e9879f2 100644 --- a/projects/hip/src/hip_ir.ll +++ b/projects/hip/src/hip_ir.ll @@ -171,4 +171,9 @@ define i32 @__hip_hc_ir_usad_int(i32 %a, i32 %b, i32 %c) #1 { ret i32 %1 } +define i32 @__hip_hc_ir_sadu8_int(i32 %a, i32 %b, i32 %c) #1 { + %1 = tail call i32 asm sideeffect "v_sad_u8 $0, $1, $2 $3","=v,v,v,v"(i32 %a, i32 %b, i32 %c) + ret i32 %1 +} + attributes #1 = { alwaysinline nounwind } From bda5602f066e4fd3a96690e7485eca5345b5a408 Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Fri, 20 Jan 2017 14:37:39 -0600 Subject: [PATCH 094/281] Add HIP_IGNORE_HCC_VERSION. Ignores strict checking of HCC and HIP version. Can be useful when developing new HCC code. [ROCm/hip commit: 138cf3654738f0d00950dbb016ea9fe88d340148] --- projects/hip/bin/hipcc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/projects/hip/bin/hipcc b/projects/hip/bin/hipcc index de8f0cb9a3..004463bc2c 100755 --- a/projects/hip/bin/hipcc +++ b/projects/hip/bin/hipcc @@ -374,7 +374,8 @@ if ($printHipVersion) { } if ($runCmd) { if ($HIP_PLATFORM eq "hcc" and exists($hipConfig{'HCC_VERSION'}) and $HCC_VERSION ne $hipConfig{'HCC_VERSION'}) { - print ("HIP ($HIP_PATH) was built using hcc $hipConfig{'HCC_VERSION'}, but you are using $HCC_HOME/hcc with version $HCC_VERSION from hipcc. Please rebuild HIP including cmake or update HCC_HOME variable.\n") && die (); + print ("HIP ($HIP_PATH) was built using hcc $hipConfig{'HCC_VERSION'}, but you are using $HCC_HOME/hcc with version $HCC_VERSION from hipcc. Please rebuild HIP including cmake or update HCC_HOME variable.\n") ; + die unless $ENV{'HIP_IGNORE_HCC_VERSION'}; } system ("$CMD") and die (); } From c275c0ff72e0e2ace54653c3bf07adc6aefc2e78 Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Fri, 20 Jan 2017 14:38:35 -0600 Subject: [PATCH 095/281] Log error with ihipLogError. Cleans up CXL trace display. [ROCm/hip commit: 4586091dfe922183287f21837b0cc703eac7834f] --- projects/hip/src/hip_device.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/hip/src/hip_device.cpp b/projects/hip/src/hip_device.cpp index 5139eba0af..3cefca82e7 100644 --- a/projects/hip/src/hip_device.cpp +++ b/projects/hip/src/hip_device.cpp @@ -267,7 +267,7 @@ hipError_t ihipDeviceGetAttribute(int* pi, hipDeviceAttribute_t attr, int device hipError_t hipDeviceGetAttribute(int* pi, hipDeviceAttribute_t attr, int device) { HIP_INIT_API(pi, attr, device); - return ihipDeviceGetAttribute(pi,attr,device); + return ihipLogStatus(ihipDeviceGetAttribute(pi,attr,device)); } hipError_t ihipGetDeviceProperties(hipDeviceProp_t* props, int device) From d1c61adcf9fc83ba609fad6ce11f10017da23b13 Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Fri, 20 Jan 2017 14:39:45 -0600 Subject: [PATCH 096/281] Add debug tips to docs [ROCm/hip commit: 85d41dcd056089a81ceb32a351eef640d3293ab4] --- projects/hip/docs/markdown/hip_profiling.md | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/projects/hip/docs/markdown/hip_profiling.md b/projects/hip/docs/markdown/hip_profiling.md index 4119ef47e9..772f762912 100644 --- a/projects/hip/docs/markdown/hip_profiling.md +++ b/projects/hip/docs/markdown/hip_profiling.md @@ -349,7 +349,8 @@ These options cause HCC to serialize. Useful if you have libraries or code whic $32 = {_shortTid = 1, _apiSeqNum = 803} ``` -- HCC tracks all of the application memory allocations, including those from HIP and HC's "am_alloc". These can be printed by calling the function 'hc::am_memtracker_print()'. +- HCC tracks all of the application memory allocations, including those from HIP and HC's "am_alloc". +If the HCC runtime is built with debug information (HCC_RUNTIME_DEBUG=ON when building HCC), then calling the function 'hc::am_memtracker_print()' will show all memory allocations. An optional argument specifies a void * targetPointer - the print routine will mark the allocation which contains the specified pointer with "-->" in the printed output. This example shows a sample GDB session where we print the memory allocated by this process and mark a specified address by using the gdb "call" function.. The gdb syntax also supports using the variable name (in this case 'dst'): @@ -399,7 +400,7 @@ Program received signal SIGABRT, Aborted. ... ``` -Some general tips: +### General Debugging Tips - The fault will be caught by the runtime but was actually generated by an asynchronous command running on the GPU. So, the GDB backtrace will show a path in the runtime, ie inside "GI_Raise" as shown in the example above. - To determine the true location of the fault, force the kernels to execute synchronously by seeing the environment variables HCC_SERIALIZE_KERNEL=3 HCC_SERIALIZE_COPY=3. This will force HCC to wait for the kernel to finish executing before retuning. If the fault occurs during the execution of a kernel, you can see the code which launched the kernel inside the backtrace. A bit of guesswork is required to determine which thread is actually causing the issue - typically it will the thread which is waiting inside the libhsa-runtime64.so. - VM faults inside kernels can be caused byi: @@ -408,3 +409,15 @@ Some general tips: - synchronization issues - compiler issues (incorrect code generation from the compiler) - runtime issues + +-- General debug tips: +- 'gdb --args' can be used to conviently pass the executable and arguments to gdb. +- From inside GDB, you can set environment variables "set env". Note the command does not use an '=' sign: +``` +(gdb) set env HIP_DB 1 +``` +Setting HIP_PRINT_ENV=1 and then running a HIP application will print the HIP environment variables, their current values, and usage info. +Setting HCC_PRINT_ENV=1 and then running a HCC application will print the HCC environment variables, their current values, and usage info. + + + From f9ecf383e37ea11b56ab3799c6faa16b388d24e1 Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Fri, 20 Jan 2017 14:48:29 -0600 Subject: [PATCH 097/281] Add debug tips to docs [ROCm/hip commit: 96eac6792994688871896e60787973db67a6c8dc] --- projects/hip/src/hip_hcc.cpp | 2 +- projects/hip/src/hip_hcc.h | 123 +++++++++++++++++++------------- projects/hip/src/hip_memory.cpp | 42 +++++------ 3 files changed, 97 insertions(+), 70 deletions(-) diff --git a/projects/hip/src/hip_hcc.cpp b/projects/hip/src/hip_hcc.cpp index 6360097557..c84b93b503 100644 --- a/projects/hip/src/hip_hcc.cpp +++ b/projects/hip/src/hip_hcc.cpp @@ -1475,7 +1475,7 @@ hipStream_t ihipSyncAndResolveStream(hipStream_t stream) void ihipPrintKernelLaunch(const char *kernelName, const grid_launch_parm *lp, const hipStream_t stream) { - if (HIP_PROFILE_API || (COMPILE_HIP_DB && HIP_TRACE_API)) { + if ((HIP_TRACE_API & (1<>%s\n", (localHipStatus == 0) ? API_COLOR:KRED, tls_tidInfo.tid(),tls_tidInfo.apiSeqNum(), __func__, localHipStatus, ihipErrorString(localHipStatus), API_COLOR_END);\ - }\ - if (HIP_PROFILE_API) { MARKER_END(); }\ - localHipStatus;\ - }) - - +//--- +//HIP Trace modes +#define TRACE_ALL 0 // 0x1 +#define TRACE_CMD 1 // 0x2 +#define TRACE_MEM 2 // 0x4 //--- @@ -238,12 +195,14 @@ extern void recordApiTrace(std::string *fullStr, const std::string &apiStr); #define DB_MAX_FLAG 4 // When adding a new debug flag, also add to the char name table below. // +// struct DbName { const char *_color; const char *_shortName; }; +// This table must be kept in-sync with the defines above. static const DbName dbName [] = { {KGRN, "api"}, // not used, @@ -270,6 +229,74 @@ static const DbName dbName [] = +//--- +extern void recordApiTrace(std::string *fullStr, const std::string &apiStr); + +#if COMPILE_HIP_ATP_MARKER || (COMPILE_HIP_TRACE_API & 0x1) +#define API_TRACE(forceTrace, ...)\ +{\ + tls_tidInfo.incApiSeqNum();\ + if (forceTrace || (HIP_PROFILE_API || (COMPILE_HIP_DB && (HIP_TRACE_API & (1<>%s\n", (localHipStatus == 0) ? API_COLOR:KRED, tls_tidInfo.tid(),tls_tidInfo.apiSeqNum(), __func__, localHipStatus, ihipErrorString(localHipStatus), API_COLOR_END);\ + }\ + if (HIP_PROFILE_API) { MARKER_END(); }\ + localHipStatus;\ + }) + + + + + + + + class ihipException : public std::exception { diff --git a/projects/hip/src/hip_memory.cpp b/projects/hip/src/hip_memory.cpp index 3c727d34fc..d66c151266 100644 --- a/projects/hip/src/hip_memory.cpp +++ b/projects/hip/src/hip_memory.cpp @@ -160,7 +160,7 @@ hipError_t hipMalloc(void** ptr, size_t sizeBytes) hipError_t hipHostMalloc(void** ptr, size_t sizeBytes, unsigned int flags) { - HIP_INIT_API(ptr, sizeBytes, flags); + HIP_INIT_CMD_API(ptr, sizeBytes, flags); HIP_SET_DEVICE(); hipError_t hip_status = hipSuccess; @@ -239,7 +239,7 @@ hipError_t hipHostAlloc(void** ptr, size_t sizeBytes, unsigned int flags) // width in bytes hipError_t hipMallocPitch(void** ptr, size_t* pitch, size_t width, size_t height) { - HIP_INIT_API(ptr, pitch, width, height); + HIP_INIT_CMD_API(ptr, pitch, width, height); HIP_SET_DEVICE(); hipError_t hip_status = hipSuccess; @@ -291,7 +291,7 @@ hipChannelFormatDesc hipCreateChannelDesc(int x, int y, int z, int w, hipChannel hipError_t hipMallocArray(hipArray** array, const hipChannelFormatDesc* desc, size_t width, size_t height, unsigned int flags) { - HIP_INIT_API(array, desc, width, height, flags); + HIP_INIT_CMD_API(array, desc, width, height, flags); HIP_SET_DEVICE(); hipError_t hip_status = hipSuccess; @@ -438,7 +438,7 @@ hipError_t hipHostUnregister(void *hostPtr) hipError_t hipMemcpyToSymbol(const char* symbolName, const void *src, size_t count, size_t offset, hipMemcpyKind kind) { - HIP_INIT_API(symbolName, src, count, offset, kind); + HIP_INIT_CMD_API(symbolName, src, count, offset, kind); if(symbolName == nullptr) { @@ -466,7 +466,7 @@ hipError_t hipMemcpyToSymbol(const char* symbolName, const void *src, size_t cou hipError_t hipMemcpyToSymbolAsync(const char* symbolName, const void *src, size_t count, size_t offset, hipMemcpyKind kind, hipStream_t stream) { - HIP_INIT_API(symbolName, src, count, offset, kind, stream); + HIP_INIT_CMD_API(symbolName, src, count, offset, kind, stream); if(symbolName == nullptr) { @@ -506,7 +506,7 @@ hipError_t hipMemcpyToSymbolAsync(const char* symbolName, const void *src, size_ //--- hipError_t hipMemcpy(void* dst, const void* src, size_t sizeBytes, hipMemcpyKind kind) { - HIP_INIT_API(dst, src, sizeBytes, kind); + HIP_INIT_CMD_API(dst, src, sizeBytes, kind); hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull); @@ -527,7 +527,7 @@ hipError_t hipMemcpy(void* dst, const void* src, size_t sizeBytes, hipMemcpyKind hipError_t hipMemcpyHtoD(hipDeviceptr_t dst, void* src, size_t sizeBytes) { - HIP_INIT_API(dst, src, sizeBytes); + HIP_INIT_CMD_API(dst, src, sizeBytes); hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull); @@ -548,7 +548,7 @@ hipError_t hipMemcpyHtoD(hipDeviceptr_t dst, void* src, size_t sizeBytes) hipError_t hipMemcpyDtoH(void* dst, hipDeviceptr_t src, size_t sizeBytes) { - HIP_INIT_API(dst, src, sizeBytes); + HIP_INIT_CMD_API(dst, src, sizeBytes); hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull); @@ -569,7 +569,7 @@ hipError_t hipMemcpyDtoH(void* dst, hipDeviceptr_t src, size_t sizeBytes) hipError_t hipMemcpyDtoD(hipDeviceptr_t dst, hipDeviceptr_t src, size_t sizeBytes) { - HIP_INIT_API(dst, src, sizeBytes); + HIP_INIT_CMD_API(dst, src, sizeBytes); hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull); @@ -590,7 +590,7 @@ hipError_t hipMemcpyDtoD(hipDeviceptr_t dst, hipDeviceptr_t src, size_t sizeByte hipError_t hipMemcpyHtoH(void* dst, void* src, size_t sizeBytes) { - HIP_INIT_API(dst, src, sizeBytes); + HIP_INIT_CMD_API(dst, src, sizeBytes); hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull); @@ -641,7 +641,7 @@ hipError_t memcpyAsync (void* dst, const void* src, size_t sizeBytes, hipMemcpyK hipError_t hipMemcpyAsync(void* dst, const void* src, size_t sizeBytes, hipMemcpyKind kind, hipStream_t stream) { - HIP_INIT_API(dst, src, sizeBytes, kind, stream); + HIP_INIT_CMD_API(dst, src, sizeBytes, kind, stream); return ihipLogStatus(hip_internal::memcpyAsync(dst, src, sizeBytes, kind, stream)); @@ -650,21 +650,21 @@ hipError_t hipMemcpyAsync(void* dst, const void* src, size_t sizeBytes, hipMemcp hipError_t hipMemcpyHtoDAsync(hipDeviceptr_t dst, void* src, size_t sizeBytes, hipStream_t stream) { - HIP_INIT_API(dst, src, sizeBytes, stream); + HIP_INIT_CMD_API(dst, src, sizeBytes, stream); return ihipLogStatus(hip_internal::memcpyAsync(dst, src, sizeBytes, hipMemcpyHostToDevice, stream)); } hipError_t hipMemcpyDtoDAsync(hipDeviceptr_t dst, hipDeviceptr_t src, size_t sizeBytes, hipStream_t stream) { - HIP_INIT_API(dst, src, sizeBytes, stream); + HIP_INIT_CMD_API(dst, src, sizeBytes, stream); return ihipLogStatus(hip_internal::memcpyAsync(dst, src, sizeBytes, hipMemcpyDeviceToDevice, stream)); } hipError_t hipMemcpyDtoHAsync(void* dst, hipDeviceptr_t src, size_t sizeBytes, hipStream_t stream) { - HIP_INIT_API(dst, src, sizeBytes, stream); + HIP_INIT_CMD_API(dst, src, sizeBytes, stream); return ihipLogStatus(hip_internal::memcpyAsync(dst, src, sizeBytes, hipMemcpyDeviceToHost, stream)); } @@ -673,7 +673,7 @@ hipError_t hipMemcpyDtoHAsync(void* dst, hipDeviceptr_t src, size_t sizeBytes, h hipError_t hipMemcpy2D(void* dst, size_t dpitch, const void* src, size_t spitch, size_t width, size_t height, hipMemcpyKind kind) { - HIP_INIT_API(dst, dpitch, src, spitch, width, height, kind); + HIP_INIT_CMD_API(dst, dpitch, src, spitch, width, height, kind); if(width > dpitch || width > spitch) return ihipLogStatus(hipErrorUnknown); @@ -699,7 +699,7 @@ hipError_t hipMemcpy2D(void* dst, size_t dpitch, const void* src, size_t spitch, hipError_t hipMemcpy2DToArray(hipArray* dst, size_t wOffset, size_t hOffset, const void* src, size_t spitch, size_t width, size_t height, hipMemcpyKind kind) { - HIP_INIT_API(dst, wOffset, hOffset, src, spitch, width, height, kind); + HIP_INIT_CMD_API(dst, wOffset, hOffset, src, spitch, width, height, kind); hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull); @@ -752,7 +752,7 @@ hipError_t hipMemcpy2DToArray(hipArray* dst, size_t wOffset, size_t hOffset, con hipError_t hipMemcpyToArray(hipArray* dst, size_t wOffset, size_t hOffset, const void* src, size_t count, hipMemcpyKind kind) { - HIP_INIT_API(dst, wOffset, hOffset, src, count, kind); + HIP_INIT_CMD_API(dst, wOffset, hOffset, src, count, kind); hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull); @@ -811,7 +811,7 @@ ihipMemsetKernel(hipStream_t stream, // TODO-sync: function is async unless target is pinned host memory - then these are fully sync. hipError_t hipMemsetAsync(void* dst, int value, size_t sizeBytes, hipStream_t stream ) { - HIP_INIT_API(dst, value, sizeBytes, stream); + HIP_INIT_CMD_API(dst, value, sizeBytes, stream); hipError_t e = hipSuccess; @@ -861,12 +861,12 @@ hipError_t hipMemsetAsync(void* dst, int value, size_t sizeBytes, hipStream_t s hipError_t hipMemset(void* dst, int value, size_t sizeBytes ) { - hipStream_t stream = hipStreamNull; - // TODO - call an ihip memset so HIP_TRACE is correct. - HIP_INIT_API(dst, value, sizeBytes, stream); + HIP_INIT_CMD_API(dst, value, sizeBytes); hipError_t e = hipSuccess; + hipStream_t stream = hipStreamNull; + // TODO - call an ihip memset so HIP_TRACE is correct. stream = ihipSyncAndResolveStream(stream); if (stream) { From 3be19a4ffa6005687460c5a0adbd3ec2a49cc4df Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Fri, 20 Jan 2017 21:19:52 -0600 Subject: [PATCH 098/281] Move core env var processing to env.cpp [ROCm/hip commit: 0dabdeb01f8725089262f14110191c8cf27d0d09] --- projects/hip/CMakeLists.txt | 3 +- projects/hip/src/env.cpp | 91 ++++++++++++++++ projects/hip/src/env.h | 24 +++++ projects/hip/src/hip_hcc.cpp | 200 +++++++---------------------------- projects/hip/src/hip_hcc.h | 7 +- 5 files changed, 160 insertions(+), 165 deletions(-) create mode 100644 projects/hip/src/env.cpp create mode 100644 projects/hip/src/env.h diff --git a/projects/hip/CMakeLists.txt b/projects/hip/CMakeLists.txt index cbd2050025..53663e44b3 100644 --- a/projects/hip/CMakeLists.txt +++ b/projects/hip/CMakeLists.txt @@ -175,7 +175,8 @@ if(HIP_PLATFORM STREQUAL "hcc") src/hip_memory.cpp src/hip_peer.cpp src/hip_stream.cpp - src/hip_module.cpp) + src/hip_module.cpp + src/env.cpp) set(SOURCE_FILES_DEVICE src/device_util.cpp diff --git a/projects/hip/src/env.cpp b/projects/hip/src/env.cpp new file mode 100644 index 0000000000..90d00feac0 --- /dev/null +++ b/projects/hip/src/env.cpp @@ -0,0 +1,91 @@ +#include "hip_hcc.h" +#include "trace_helper.h" +#include "env.h" + +//--- +// Read environment variables. +void ihipReadEnv_I(int *var_ptr, const char *var_name1, const char *var_name2, const char *description) +{ + char * env = getenv(var_name1); + + // Check second name if first not defined, used to allow HIP_ or CUDA_ env vars. + if ((env == NULL) && strcmp(var_name2, "0")) { + env = getenv(var_name2); + } + + // Default is set when variable is initialized (at top of this file), so only override if we find + // an environment variable. + if (env) { + long int v = strtol(env, NULL, 0); + *var_ptr = (int) (v); + } + if (HIP_PRINT_ENV) { + printf ("%-30s = %2d : %s\n", var_name1, *var_ptr, description); + } +} + + +void ihipReadEnv_S(std::string *var_ptr, const char *var_name1, const char *var_name2, const char *description) +{ + char * env = getenv(var_name1); + + // Check second name if first not defined, used to allow HIP_ or CUDA_ env vars. + if ((env == NULL) && strcmp(var_name2, "0")) { + env = getenv(var_name2); + } + + if (env) { + *static_cast(var_ptr) = env; + } + if (HIP_PRINT_ENV) { + printf ("%-30s = %s : %s\n", var_name1, var_ptr->c_str(), description); + } +} + + +void ihipReadEnv_Callback(void *var_ptr, const char *var_name1, const char *var_name2, const char *description, std::string (*setterCallback)(void * var_ptr, const char * env)) +{ + char * env = getenv(var_name1); + + // Check second name if first not defined, used to allow HIP_ or CUDA_ env vars. + if ((env == NULL) && strcmp(var_name2, "0")) { + env = getenv(var_name2); + } + + std::string var_string = "0"; + if (env) { + var_string = setterCallback(var_ptr, env); + } + if (HIP_PRINT_ENV) { + printf ("%-30s = %s : %s\n", var_name1, var_string.c_str(), description); + } +} + + + + +void tokenize(const std::string &s, char delim, std::vector *tokens) +{ + std::stringstream ss; + ss.str(s); + std::string item; + while (getline(ss, item, delim)) { + item.erase (std::remove (item.begin(), item.end(), ' '), item.end()); // remove whitespace. + tokens->push_back(item); + } +} + +void trim(std::string *s) +{ + // trim whitespace from beginning and end: + const char *t = "\t\n\r\f\v"; + s->erase(0, s->find_first_not_of(t)); + s->erase(s->find_last_not_of(t)+1); +} + +static void ltrim(std::string *s) +{ + // trim whitespace from beginning + const char *t = "\t\n\r\f\v"; + s->erase(0, s->find_first_not_of(t)); +} diff --git a/projects/hip/src/env.h b/projects/hip/src/env.h new file mode 100644 index 0000000000..d1ec36f0c8 --- /dev/null +++ b/projects/hip/src/env.h @@ -0,0 +1,24 @@ +#pragma once + +extern void HipReadEnv(); + + + +#define READ_ENV_I(_build, _ENV_VAR, _ENV_VAR2, _description) \ + ihipReadEnv_I(&_ENV_VAR, #_ENV_VAR, #_ENV_VAR2, _description); + +#define READ_ENV_S(_build, _ENV_VAR, _ENV_VAR2, _description) \ + ihipReadEnv_S(&_ENV_VAR, #_ENV_VAR, #_ENV_VAR2, _description); + +#define READ_ENV_C(_build, _ENV_VAR, _ENV_VAR2, _description, _callback) \ + ihipReadEnv_Callback(&_ENV_VAR, #_ENV_VAR, #_ENV_VAR2, _description, _callback); + + +extern void ihipReadEnv_I(int *var_ptr, const char *var_name1, const char *var_name2, const char *description); +extern void ihipReadEnv_S(std::string *var_ptr, const char *var_name1, const char *var_name2, const char *description); +extern void ihipReadEnv_Callback(void *var_ptr, const char *var_name1, const char *var_name2, const char *description, std::string (*setterCallback)(void * var_ptr, const char * env)); + + +// String functions: +extern void trim(std::string *s); +extern void tokenize(const std::string &s, char delim, std::vector *tokens); diff --git a/projects/hip/src/hip_hcc.cpp b/projects/hip/src/hip_hcc.cpp index c84b93b503..1de3a9e7d3 100644 --- a/projects/hip/src/hip_hcc.cpp +++ b/projects/hip/src/hip_hcc.cpp @@ -46,6 +46,7 @@ THE SOFTWARE. #include "hip/hip_runtime.h" #include "hip_hcc.h" #include "trace_helper.h" +#include "env.h" #ifndef USE_COPY_EXT_V2 @@ -1037,166 +1038,6 @@ void ihipCtx_t::locked_waitAllStreams() } - -//--- -// Read environment variables. -void ihipReadEnv_I(int *var_ptr, const char *var_name1, const char *var_name2, const char *description) -{ - char * env = getenv(var_name1); - - // Check second name if first not defined, used to allow HIP_ or CUDA_ env vars. - if ((env == NULL) && strcmp(var_name2, "0")) { - env = getenv(var_name2); - } - - // Default is set when variable is initialized (at top of this file), so only override if we find - // an environment variable. - if (env) { - long int v = strtol(env, NULL, 0); - *var_ptr = (int) (v); - } - if (HIP_PRINT_ENV) { - printf ("%-30s = %2d : %s\n", var_name1, *var_ptr, description); - } -} - - -void ihipReadEnv_S(std::string *var_ptr, const char *var_name1, const char *var_name2, const char *description) -{ - char * env = getenv(var_name1); - - // Check second name if first not defined, used to allow HIP_ or CUDA_ env vars. - if ((env == NULL) && strcmp(var_name2, "0")) { - env = getenv(var_name2); - } - - if (env) { - *static_cast(var_ptr) = env; - } - if (HIP_PRINT_ENV) { - printf ("%-30s = %s : %s\n", var_name1, var_ptr->c_str(), description); - } -} - - -void ihipReadEnv_Callback(void *var_ptr, const char *var_name1, const char *var_name2, const char *description, std::string (*setterCallback)(void * var_ptr, const char * env)) -{ - char * env = getenv(var_name1); - - // Check second name if first not defined, used to allow HIP_ or CUDA_ env vars. - if ((env == NULL) && strcmp(var_name2, "0")) { - env = getenv(var_name2); - } - - std::string var_string = "0"; - if (env) { - var_string = setterCallback(var_ptr, env); - } - if (HIP_PRINT_ENV) { - printf ("%-30s = %s : %s\n", var_name1, var_string.c_str(), description); - } -} - - -#if defined (DEBUG) - -#define READ_ENV_I(_build, _ENV_VAR, _ENV_VAR2, _description) \ - if ((_build == release) || (_build == debug) {\ - ihipReadEnv_I(&_ENV_VAR, #_ENV_VAR, #_ENV_VAR2, _description);\ - }; -#define READ_ENV_S(_build, _ENV_VAR, _ENV_VAR2, _description) \ - if ((_build == release) || (_build == debug) {\ - ihipReadEnv_S(&_ENV_VAR, #_ENV_VAR, #_ENV_VAR2, _description);\ - }; -#define READ_ENV_C(_build, _ENV_VAR, _ENV_VAR2, _description, _callback) \ - if ((_build == release) || (_build == debug) {\ - ihipReadEnv_Callback(&_ENV_VAR, #_ENV_VAR, #_ENV_VAR2, _description, _callback);\ - }; - -#else - -#define READ_ENV_I(_build, _ENV_VAR, _ENV_VAR2, _description) \ - if (_build == release) {\ - ihipReadEnv_I(&_ENV_VAR, #_ENV_VAR, #_ENV_VAR2, _description);\ - }; - -#define READ_ENV_S(_build, _ENV_VAR, _ENV_VAR2, _description) \ - if (_build == release) {\ - ihipReadEnv_S(&_ENV_VAR, #_ENV_VAR, #_ENV_VAR2, _description);\ - }; -#define READ_ENV_C(_build, _ENV_VAR, _ENV_VAR2, _description, _callback) \ - if (_build == release) {\ - ihipReadEnv_Callback(&_ENV_VAR, #_ENV_VAR, #_ENV_VAR2, _description, _callback);\ - }; - -#endif - - -static void tokenize(const std::string &s, char delim, std::vector *tokens) -{ - std::stringstream ss; - ss.str(s); - std::string item; - while (getline(ss, item, delim)) { - item.erase (std::remove (item.begin(), item.end(), ' '), item.end()); // remove whitespace. - tokens->push_back(item); - } -} - -static void trim(std::string *s) -{ - // trim whitespace from beginning and end: - const char *t = "\t\n\r\f\v"; - s->erase(0, s->find_first_not_of(t)); - s->erase(s->find_last_not_of(t)+1); -} - -static void ltrim(std::string *s) -{ - // trim whitespace from beginning - const char *t = "\t\n\r\f\v"; - s->erase(0, s->find_first_not_of(t)); -} - - -// TODO - change last arg to pointer. -void parseTrigger(std::string triggerString, std::vector &profTriggers ) -{ - std::vector tidApiTokens; - tokenize(std::string(triggerString), ',', &tidApiTokens); - for (auto t=tidApiTokens.begin(); t != tidApiTokens.end(); t++) { - std::vector oneToken; - //std::cout << "token=" << *t << "\n"; - tokenize(std::string(*t), '.', &oneToken); - int tid = 1; - uint64_t apiTrigger = 0; - if (oneToken.size() == 1) { - // the case with just apiNum - apiTrigger = std::strtoull(oneToken[0].c_str(), nullptr, 0); - } else if (oneToken.size() == 2) { - // the case with tid.apiNum - tid = std::strtoul(oneToken[0].c_str(), nullptr, 0); - apiTrigger = std::strtoull(oneToken[1].c_str(), nullptr, 0); - } else { - throw ihipException(hipErrorRuntimeOther); // TODO -> bad env var? - } - - if (tid > 10000) { - throw ihipException(hipErrorRuntimeOther); // TODO -> bad env var? - } else { - profTriggers.resize(tid+1); - //std::cout << "tid:" << tid << " add: " << apiTrigger << "\n"; - profTriggers[tid].add(apiTrigger); - } - } - - - for (int tid=1; tid &profTriggers ) +{ + std::vector tidApiTokens; + tokenize(std::string(triggerString), ',', &tidApiTokens); + for (auto t=tidApiTokens.begin(); t != tidApiTokens.end(); t++) { + std::vector oneToken; + //std::cout << "token=" << *t << "\n"; + tokenize(std::string(*t), '.', &oneToken); + int tid = 1; + uint64_t apiTrigger = 0; + if (oneToken.size() == 1) { + // the case with just apiNum + apiTrigger = std::strtoull(oneToken[0].c_str(), nullptr, 0); + } else if (oneToken.size() == 2) { + // the case with tid.apiNum + tid = std::strtoul(oneToken[0].c_str(), nullptr, 0); + apiTrigger = std::strtoull(oneToken[1].c_str(), nullptr, 0); + } else { + throw ihipException(hipErrorRuntimeOther); // TODO -> bad env var? + } + + if (tid > 10000) { + throw ihipException(hipErrorRuntimeOther); // TODO -> bad env var? + } else { + profTriggers.resize(tid+1); + //std::cout << "tid:" << tid << " add: " << apiTrigger << "\n"; + profTriggers[tid].add(apiTrigger); + } + } + + + for (int tid=1; tid #include #include "hsa/hsa_ext_amd.h" + +#include "hip/hip_runtime.h" #include "hip_util.h" +#include "env.h" #if defined(__HCC__) && (__hcc_workweek__ < 16354) @@ -35,7 +38,6 @@ THE SOFTWARE. #define USE_IPC 0 - //--- // Environment variables: @@ -295,9 +297,6 @@ extern void recordApiTrace(std::string *fullStr, const std::string &apiStr); - - - class ihipException : public std::exception { public: From e95ebf93b1edda1479761aab310b59f46038b218 Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Mon, 23 Jan 2017 22:33:21 -0600 Subject: [PATCH 099/281] Show dynamic shared mem usage not static. [ROCm/hip commit: 813c189b335207d6b6d84add0e96d5b1ff959810] --- projects/hip/src/hip_module.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/hip/src/hip_module.cpp b/projects/hip/src/hip_module.cpp index d6c50e82a9..5cce7cbb1b 100644 --- a/projects/hip/src/hip_module.cpp +++ b/projects/hip/src/hip_module.cpp @@ -298,7 +298,7 @@ hipError_t hipModuleLaunchKernel(hipFunction_t f, Kernel argument preparation. */ grid_launch_parm lp; - lp.dynamic_group_mem_bytes = f._groupSegmentSize; // TODO - this should be part of preLaunchKernel. + lp.dynamic_group_mem_bytes = sharedMemBytes; // TODO - this should be part of preLaunchKernel. hStream = ihipPreLaunchKernel(hStream, dim3(gridDimX, gridDimY, gridDimZ), dim3(blockDimX, blockDimY, blockDimZ), &lp, f._name); From 0e2ccecc0b41e60ef08c14ae874b3b88f353e7f1 Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Mon, 23 Jan 2017 22:34:09 -0600 Subject: [PATCH 100/281] Add debug tip to docs [ROCm/hip commit: 9dff0782a4e29285b041712ad1cc609d369292fe] --- projects/hip/docs/markdown/hip_profiling.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/projects/hip/docs/markdown/hip_profiling.md b/projects/hip/docs/markdown/hip_profiling.md index 772f762912..463c9c13b3 100644 --- a/projects/hip/docs/markdown/hip_profiling.md +++ b/projects/hip/docs/markdown/hip_profiling.md @@ -362,6 +362,12 @@ TargetAddress:0x5ec7e9000 0x504cfc000-0x504cfc00f:: allocSeqNum:1 hostPointer:0x504cfc000 devicePointer:0x504cfc000 sizeBytes:16 isInDeviceMem:0 isAmManaged:1 appId:0 appAllocFlags:0 appPtr:(nil) ... -->0x5ec7e9000-0x5f7e28fff:: allocSeqNum:488 hostPointer:(nil) devicePointer:0x5ec7e9000 sizeBytes:191102976 isInDeviceMem:1 isAmManaged:1 appId:0 appAllocFlags:0 appPtr:(nil) + +``` + +To debug an explicit address, cast the address to (void*) : +``` +(gdb) call hc::am_memtracker_print((void*)0x508c7f000) ``` - Debugging GPUVM fault. For example: From 90a02002c9c809793ab231da1d28c7cf8a50f47e Mon Sep 17 00:00:00 2001 From: pensun Date: Tue, 24 Jan 2017 22:30:36 -0600 Subject: [PATCH 101/281] Initial commit on hip_bugs markdown doc Change-Id: I5a6915337b8664cfed9eaee9443c6e4406348574 [ROCm/hip commit: f3da91de4e676e8a9411bebe74c530f35cc48257] --- projects/hip/docs/markdown/hip_bugs.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 projects/hip/docs/markdown/hip_bugs.md diff --git a/projects/hip/docs/markdown/hip_bugs.md b/projects/hip/docs/markdown/hip_bugs.md new file mode 100644 index 0000000000..0bece74974 --- /dev/null +++ b/projects/hip/docs/markdown/hip_bugs.md @@ -0,0 +1,24 @@ +# HIP Bugs + + + +- [Errors related to undefined reference to `__hcLaunchKernel__***__grid_launch_parm**](#error-undefined-reference) + + + +### Errors related to undefined reference to `__hcLaunchKernel__***__grid_launch_parm** + +Some common code practices may lead to hipcc generating a error with the form : +undefined reference to `__hcLaunchKernel__ZN15vecAddNamespace6vecAddIidEEv16grid_launch_parmPT0_S3_S3_T_ + +To workaround, try: +- Avoid calling hcLaunchKernel from a function with the __host__ attribute +__host__ MyFunc(…) { +hipLaunchKernel(myKernel, …) +- Avoid use of static with kernel definition: +static __global__ MyKernel +- Avoid defining kernels in anonymous namespace +namespace { +__global__ MyKernel … +- Avoid calling member functions + From 716d972e53ed826aff118e64c3323e77885a2123 Mon Sep 17 00:00:00 2001 From: pensun Date: Tue, 24 Jan 2017 22:43:25 -0600 Subject: [PATCH 102/281] Add more hip_bug.md entry, regarding hang after hipLaunchKernel Change-Id: I5800cb627179ec0e913cd36d332fb8c2994ab71e [ROCm/hip commit: 95677edabbe4e1fca92ab762b451c2207bc6ff70] --- projects/hip/docs/markdown/hip_bugs.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/projects/hip/docs/markdown/hip_bugs.md b/projects/hip/docs/markdown/hip_bugs.md index 0bece74974..834cd9f8ce 100644 --- a/projects/hip/docs/markdown/hip_bugs.md +++ b/projects/hip/docs/markdown/hip_bugs.md @@ -2,7 +2,8 @@ -- [Errors related to undefined reference to `__hcLaunchKernel__***__grid_launch_parm**](#error-undefined-reference) +- [Errors related to undefined reference to `__hcLaunchKernel__***__grid_launch_parm**](#errors-related-to-undefined-reference-to-hclaunchkernel__grid_launch_parm) +- [Application hangs after a hipLaunchKernel call](#what-if-i-see-application-hangs-after-a-hiplaunchkernel-call) @@ -22,3 +23,11 @@ namespace { __global__ MyKernel … - Avoid calling member functions + +### What if I see application hangs after a hipLaunchKernel call? +If hipLaunchKernel takes parameters that request explicitly memcpy, then it will cause application hang. +Reason is that the hipLaunchKernel macro locks the stream. +If kernel paramters are actually function calls which invoke other hip apis (i.e. memcpy) to the same stream, then deadlock occurs. + +To workaround, try: +Move the function calls so they occur outside the hipLaunchKernel macro, store results in temps, then use the tems inside the kernel. \ No newline at end of file From 43958812067b8d7d7dfc146c7d9269362d4f7158 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Wed, 25 Jan 2017 08:14:30 -0600 Subject: [PATCH 103/281] added device functions header to hip_runtime.h Change-Id: I635931e1fbe4b7f0f64f3a126c0f1badcd6d234b [ROCm/hip commit: d75d0596bfd466ef1aaf3404ec377513a3ce35ce] --- projects/hip/include/hip/hcc_detail/hip_runtime.h | 1 + 1 file changed, 1 insertion(+) diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime.h b/projects/hip/include/hip/hcc_detail/hip_runtime.h index 909b7f5680..822ee31f2b 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime.h @@ -70,6 +70,7 @@ extern int HIP_TRACE_API; #endif #include #include +#include // TODO-HCC remove old definitions ; ~1602 hcc supports __HCC_ACCELERATOR__ define. #if defined (__KALMAR_ACCELERATOR__) && !defined (__HCC_ACCELERATOR__) From e129b09a6f8dc6db7c0eb7124c0f979812c99015 Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Wed, 25 Jan 2017 21:50:52 -0600 Subject: [PATCH 104/281] Read HCC_OPT_FLUSH and optimize dispatch accordingly. If HCC is in this mode, we can use less aggressive flushes in some cases. [ROCm/hip commit: 1635b8f43fd024a891b008a473de6e09907c2459] --- projects/hip/src/hip_hcc.cpp | 5 +++++ projects/hip/src/hip_hcc.h | 3 +++ projects/hip/src/hip_module.cpp | 14 ++++++++++---- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/projects/hip/src/hip_hcc.cpp b/projects/hip/src/hip_hcc.cpp index 1de3a9e7d3..7048947005 100644 --- a/projects/hip/src/hip_hcc.cpp +++ b/projects/hip/src/hip_hcc.cpp @@ -97,6 +97,8 @@ int HIP_COHERENT_HOST_ALLOC = 0; // USE_ HIP_SYNC_HOST_ALLOC int HIP_SYNC_HOST_ALLOC = 1; +int HCC_OPT_FLUSH = 0; + @@ -1204,6 +1206,9 @@ void HipReadEnv() READ_ENV_I(release, HIP_COHERENT_HOST_ALLOC, 0, "If set, all host memory will be allocated as fine-grained system memory. This allows threadfence_system to work but prevents host memory from being cached on GPU which may have performance impact."); + + READ_ENV_I(release, HCC_OPT_FLUSH, 0, "Note this flag also impact HCC. When set, use agent-scope flush rather than system-scope flush when possible."); + // Some flags have both compile-time and runtime flags - generate a warning if user enables the runtime flag but the compile-time flag is disabled. if (HIP_DB && !COMPILE_HIP_DB) { fprintf (stderr, "warning: env var HIP_DB=0x%x but COMPILE_HIP_DB=0. (perhaps enable COMPILE_HIP_DB in src code before compiling?)\n", HIP_DB); diff --git a/projects/hip/src/hip_hcc.h b/projects/hip/src/hip_hcc.h index 276b93176e..9998c4ec0e 100644 --- a/projects/hip/src/hip_hcc.h +++ b/projects/hip/src/hip_hcc.h @@ -66,6 +66,9 @@ extern int HIP_COHERENT_HOST_ALLOC; // Chicken bits for disabling functionality to work around potential issues: extern int HIP_SYNC_HOST_ALLOC; +// TODO - remove when this is standard behavior. +extern int HCC_OPT_FLUSH; + // Class to assign a short TID to each new thread, for HIP debugging purposes. class TidInfo { diff --git a/projects/hip/src/hip_module.cpp b/projects/hip/src/hip_module.cpp index 5cce7cbb1b..5eb3a6cf09 100644 --- a/projects/hip/src/hip_module.cpp +++ b/projects/hip/src/hip_module.cpp @@ -320,11 +320,17 @@ hipError_t hipModuleLaunchKernel(hipFunction_t f, aql.kernel_object = f._object; aql.setup = 3 << HSA_KERNEL_DISPATCH_PACKET_SETUP_DIMENSIONS; aql.header = (HSA_PACKET_TYPE_KERNEL_DISPATCH << HSA_PACKET_HEADER_TYPE) | - (1 << HSA_PACKET_HEADER_BARRIER) | - (HSA_FENCE_SCOPE_SYSTEM << HSA_PACKET_HEADER_ACQUIRE_FENCE_SCOPE) | - (HSA_FENCE_SCOPE_SYSTEM << HSA_PACKET_HEADER_RELEASE_FENCE_SCOPE); + (1 << HSA_PACKET_HEADER_BARRIER); // TODO - honor queue setting for execute_in_order - lp.av->dispatch_hsa_kernel(&aql, config[1] /* kernarg*/, kernArgSize); + if (HCC_OPT_FLUSH) { + aql.header |= (HSA_FENCE_SCOPE_AGENT << HSA_PACKET_HEADER_ACQUIRE_FENCE_SCOPE) | + (HSA_FENCE_SCOPE_AGENT << HSA_PACKET_HEADER_RELEASE_FENCE_SCOPE); + } else { + aql.header |= (HSA_FENCE_SCOPE_SYSTEM << HSA_PACKET_HEADER_ACQUIRE_FENCE_SCOPE) | + (HSA_FENCE_SCOPE_SYSTEM << HSA_PACKET_HEADER_RELEASE_FENCE_SCOPE); + }; + + lp.av->dispatch_hsa_kernel(&aql, config[1] /* kernarg*/, kernArgSize, nullptr/*completion_future*/); ihipPostLaunchKernel(f._name, hStream, lp); From bf3b6354ae0b44117cfcfb23bdd2127fa055c8ec Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Wed, 25 Jan 2017 21:53:17 -0600 Subject: [PATCH 105/281] Add HIP_FAIL_SOC. Fail sub-optimal-copies rather than perform them slowly. SOC occur on async copy of unpinned memory, or P2P copy between GPUs that are not peers. [ROCm/hip commit: 0409bf639c796666b119517a62fb07bae3c46e92] --- projects/hip/src/hip_hcc.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/projects/hip/src/hip_hcc.cpp b/projects/hip/src/hip_hcc.cpp index 7048947005..20ff1722e3 100644 --- a/projects/hip/src/hip_hcc.cpp +++ b/projects/hip/src/hip_hcc.cpp @@ -86,6 +86,7 @@ int HIP_NUM_KERNELS_INFLIGHT = 128; int HIP_WAIT_MODE = 0; int HIP_FORCE_P2P_HOST = 0; +int HIP_FAIL_SOC = 0; int HIP_DENY_PEER_ACCESS = 0; // Force async copies to actually use the synchronous copy interface. @@ -1198,6 +1199,7 @@ void HipReadEnv() READ_ENV_I(release, HIP_WAIT_MODE, 0, "Force synchronization mode. 1= force yield, 2=force spin, 0=defaults specified in application"); READ_ENV_I(release, HIP_FORCE_P2P_HOST, 0, "Force use of host/staging copy for peer-to-peer copies.1=always use copies, 2=always return false for hipDeviceCanAccessPeer"); READ_ENV_I(release, HIP_FORCE_SYNC_COPY, 0, "Force all copies (even hipMemcpyAsync) to use sync copies"); + READ_ENV_I(release, HIP_FAIL_SOC, 0, "Fault on Sub-Optimal-Copy, rather than use a slower but functional implementation. Bit 0x1=Fail on async copy with unpinned memory. Bit 0x2=Fail peer copy rather than use staging buffer copy"); READ_ENV_I(release, HIP_SYNC_HOST_ALLOC, 0, "Sync before and after all host memory allocations. May help stability"); @@ -1721,8 +1723,13 @@ void ihipStream_t::resolveHcMemcpyDirection(unsigned hipMemKind, } } else { *forceUnpinnedCopy = true; - tprintf (DB_COPY, "P2P: copy engine(dev:%d agent=0x%lx) cannot see both host and device pointers - forcing copy with unpinned engine.\n", + tprintf (DB_COPY, "P2P: Copy engine(dev:%d agent=0x%lx) cannot see both host and device pointers - forcing copy with unpinned engine.\n", (*copyDevice)->getDeviceNum(), (*copyDevice)->getDevice()->_hsaAgent.handle); + if (HIP_FAIL_SOC & 0x2) { + fprintf (stderr, "HIP_FAIL_SOC: P2P: copy engine(dev:%d agent=0x%lx) cannot see both host and device pointers - forcing copy with unpinned engine.\n", + (*copyDevice)->getDeviceNum(), (*copyDevice)->getDevice()->_hsaAgent.handle); + throw ihipException(hipErrorRuntimeOther); + } } } @@ -1855,6 +1862,22 @@ void ihipStream_t::locked_copyAsync(void* dst, const void* src, size_t sizeBytes } } else { + if (HIP_FAIL_SOC & 0x1) { + fprintf (stderr, "HIP_FAIL_SOC failed, async_copy requested but could not be completed since src or dst not accesible to copy agent\n"); + fprintf (stderr, "copyASync copyDev:%d dst=%p (phys_dev:%d, isDevMem:%d) src=%p(phys_dev:%d, isDevMem:%d) sz=%zu dir=%s forceUnpinnedCopy=%d\n", + copyDevice ? copyDevice->getDeviceNum():-1, + dst, dstPtrInfo._appId, dstPtrInfo._isInDeviceMem, + src, srcPtrInfo._appId, srcPtrInfo._isInDeviceMem, + sizeBytes, hcMemcpyStr(hcCopyDir), forceUnpinnedCopy); + fprintf (stderr, " dst=%p baseHost=%p baseDev=%p sz=%zu home_dev=%d tracked=%d isDevMem=%d\n", + dst, dstPtrInfo._hostPointer, dstPtrInfo._devicePointer, dstPtrInfo._sizeBytes, + dstPtrInfo._appId, dstTracked, dstPtrInfo._isInDeviceMem); + fprintf (stderr, " src=%p baseHost=%p baseDev=%p sz=%zu home_dev=%d tracked=%d isDevMem=%d\n", + src, srcPtrInfo._hostPointer, srcPtrInfo._devicePointer, srcPtrInfo._sizeBytes, + srcPtrInfo._appId, srcTracked, srcPtrInfo._isInDeviceMem); + throw ihipException(hipErrorRuntimeOther); + } + // Perform slow synchronous copy: LockedAccessor_StreamCrit_t crit(_criticalData); this->ensureHaveQueue(crit); From 5eb33462b7ae9502ad137f44536fa1e2211344fe Mon Sep 17 00:00:00 2001 From: pensun Date: Thu, 26 Jan 2017 11:28:15 -0600 Subject: [PATCH 106/281] fix missing semicolon on NV path Change-Id: I3cfecb7bd534578a1f5a07ca9397092dcf01db07 [ROCm/hip commit: 84042156589635a17ddf2180809c18434f336e59] --- projects/hip/include/hip/nvcc_detail/hip_runtime_api.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h b/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h index 3cd5667175..7b970da8df 100644 --- a/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h @@ -88,7 +88,7 @@ typedef CUdeviceptr hipDeviceptr_t; typedef cudaChannelFormatKind hipChannelFormatKind; typedef cudaChannelFormatDesc hipChannelFormatDesc; typedef cudaTextureReadMode hipTextureReadMode; -typedef cudaArray hipArray +typedef cudaArray hipArray; // Flags that can be used with hipStreamCreateWithFlags #define hipStreamDefault cudaStreamDefault From 58721e8b7d1ea4c83f6e50509e723affa60015de Mon Sep 17 00:00:00 2001 From: pensun Date: Thu, 26 Jan 2017 12:30:52 -0600 Subject: [PATCH 107/281] more fix on hipmallocarray on NV path Change-Id: I890a36cab10c101f4a112bc4567f765b318d486c [ROCm/hip commit: 2e1a66103a8fbe2f89e2a5e3de8fe657f3cb6606] --- projects/hip/include/hip/nvcc_detail/hip_runtime_api.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h b/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h index 7b970da8df..11fde6aa10 100644 --- a/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h @@ -220,7 +220,7 @@ inline static hipError_t hipHostMalloc(void** ptr, size_t size, unsigned int fla } inline static hipError_t hipMallocArray(hipArray** array, const hipChannelFormatDesc* desc, size_width, size_t height, unsigned int flags) { - return hipCUDAErrorTohipError(cudaMallocArray(array, desc, width, height, flags)); + return hipCUDAErrorTohipError(cudaMallocArray(array, desc, size_width, height, flags)); } inline static hipError_t hipFreeArray(hipArray* array) { @@ -334,15 +334,15 @@ inline static hipError_t hipMemcpyToSymbolAsync(const void* symbol, const void* } inline static hipError_t hipMemcpy2D(void* dst, size_t dpitch, const void* src, size_t spitch, size_t width, size_t height, hipMemcpyKind kind){ - return hipCUDAErrorTohipError(cudaMemcpy2D(dst, dpitch, src, width, height, kind)); + return hipCUDAErrorTohipError(cudaMemcpy2D(dst, dpitch, src, width, height, hipMemcpyKindToCudaMemcpyKind(Kind))); } inline static hipError_t hipMemcpy2DToArray(hipArray *dst, size_t wOffset, size_t hOffset, const void* src, size_t spitch, size_t width, size_t height, hipMemcpyKind kind){ - return hipCUDAErrorTohipError(cudaMemcpy2DToArray(dst, wOffset, hOffset, src, spitch, width, height, kind)); + return hipCUDAErrorTohipError(cudaMemcpy2DToArray(dst, wOffset, hOffset, src, spitch, width, height, hipMemcpyKindToCudaMemcpyKind(kind))); } inline static hipError_t hipMemcpyToArray(hipArray* dst, size_t wOffset, size_t hOffset, const void* src, size_t count, hipMemcpyKind kind) { - return hipCUDAErrorTohipError(cudaMemcpy2DToArray(dst, wOffset, hOffset, src, count, kind)); + return hipCUDAErrorTohipError(cudaMemcpy2DToArray(dst, wOffset, hOffset, src, count, hipMemcpyKindToCudaMemcpyKind(kind))); } inline static hipError_t hipDeviceSynchronize() { From 1d4c0862f116a756df6848d876e190b77f3c502a Mon Sep 17 00:00:00 2001 From: Rahul Garg Date: Fri, 27 Jan 2017 14:32:08 +0530 Subject: [PATCH 108/281] hipMallocArray fixes for NV path Change-Id: I1ca43e6bc0cd405998888005c20dfb1ea57003d5 [ROCm/hip commit: 3e21d55c98c72b934500d977d7c64b4c84edce71] --- projects/hip/include/hip/nvcc_detail/hip_runtime_api.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h b/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h index 11fde6aa10..f5e7960d45 100644 --- a/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h @@ -219,8 +219,8 @@ inline static hipError_t hipHostMalloc(void** ptr, size_t size, unsigned int fla return hipCUDAErrorTohipError(cudaHostAlloc(ptr, size, flags)); } -inline static hipError_t hipMallocArray(hipArray** array, const hipChannelFormatDesc* desc, size_width, size_t height, unsigned int flags) { - return hipCUDAErrorTohipError(cudaMallocArray(array, desc, size_width, height, flags)); +inline static hipError_t hipMallocArray(hipArray** array, const hipChannelFormatDesc* desc, size_t width, size_t height, unsigned int flags) { + return hipCUDAErrorTohipError(cudaMallocArray(array, desc, width, height, flags)); } inline static hipError_t hipFreeArray(hipArray* array) { @@ -334,7 +334,7 @@ inline static hipError_t hipMemcpyToSymbolAsync(const void* symbol, const void* } inline static hipError_t hipMemcpy2D(void* dst, size_t dpitch, const void* src, size_t spitch, size_t width, size_t height, hipMemcpyKind kind){ - return hipCUDAErrorTohipError(cudaMemcpy2D(dst, dpitch, src, width, height, hipMemcpyKindToCudaMemcpyKind(Kind))); + return hipCUDAErrorTohipError(cudaMemcpy2D(dst, dpitch, src, spitch, width, height, hipMemcpyKindToCudaMemcpyKind(kind))); } inline static hipError_t hipMemcpy2DToArray(hipArray *dst, size_t wOffset, size_t hOffset, const void* src, size_t spitch, size_t width, size_t height, hipMemcpyKind kind){ @@ -342,7 +342,7 @@ inline static hipError_t hipMemcpy2DToArray(hipArray *dst, size_t wOffset, size_ } inline static hipError_t hipMemcpyToArray(hipArray* dst, size_t wOffset, size_t hOffset, const void* src, size_t count, hipMemcpyKind kind) { - return hipCUDAErrorTohipError(cudaMemcpy2DToArray(dst, wOffset, hOffset, src, count, hipMemcpyKindToCudaMemcpyKind(kind))); + return hipCUDAErrorTohipError(cudaMemcpyToArray(dst, wOffset, hOffset, src, count, hipMemcpyKindToCudaMemcpyKind(kind))); } inline static hipError_t hipDeviceSynchronize() { From a13cb5af4fe2c09d5675ffcd25359d26c8374341 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Fri, 27 Jan 2017 08:41:42 -0600 Subject: [PATCH 109/281] fixed kernel only compilation for module api Change-Id: I567992fa9b87125318edba41fd82d2f7bc5504a1 [ROCm/hip commit: 6ba848a40fc6cc43e97382524041920a401b917c] --- projects/hip/bin/hccgenco.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/projects/hip/bin/hccgenco.sh b/projects/hip/bin/hccgenco.sh index dcedfa174d..a7b4177624 100755 --- a/projects/hip/bin/hccgenco.sh +++ b/projects/hip/bin/hccgenco.sh @@ -46,17 +46,15 @@ done printf "\nint main(){}\n" >> $hipgenisa_main $HIP_PATH/bin/hipcc $hipgenisa_files -o $hipgenisa_dir/a.out -mv dump.* $hipgenisa_dir -$ROCM_PATH/hcc-lc/bin/llvm-mc -arch=amdgcn -mcpu=$ROCM_TARGET -filetype=obj $hipgenisa_dir/dump.isa -o $hipgenisa_dir/dump.o -$ROCM_PATH/llvm/bin/clang -target amdgcn--amdhsa $hipgenisa_dir/dump.o -o $hipgenisa_dir/dump.co +mv dump* $hipgenisa_dir map_sym="" -kernels=$(objdump -t $hipgenisa_dir/dump.co | grep grid_launch_parm | sed 's/ \+/ /g; s/\t/ /g' | cut -d" " -f6) +kernels=$(objdump -t $hipgenisa_dir/dump-fiji.hsaco | grep grid_launch_parm | sed 's/ \+/ /g; s/\t/ /g' | cut -d" " -f6) for mangled_sym in $kernels; do - real_sym=$(c++filt $(c++filt _$mangled_sym | cut -d: -f3 | sed 's/_functor//g') | cut -d\( -f1) + real_sym=$(c++filt $(c++filt $mangled_sym | cut -d: -f3 | sed 's/_functor//g') | cut -d\( -f1) map_sym="--redefine-sym $mangled_sym=$real_sym $map_sym" done -objcopy -F elf64-little $map_sym $hipgenisa_dir/dump.co $OUTPUT_FILE +objcopy -F elf64-little $map_sym $hipgenisa_dir/dump-fiji.hsaco $OUTPUT_FILE rm $hipgenisa_files rm -r $hipgenisa_dir From ad08bdcfb0857564b0739597d174898f95533bb9 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Fri, 27 Jan 2017 08:42:26 -0600 Subject: [PATCH 110/281] fixed threadfence ir Change-Id: Ia3afb54bdb50864e678d849608d72a3c321edba1 [ROCm/hip commit: f7ff199daab40ee83899bc34679c66e505f82a90] --- projects/hip/src/hip_ir.ll | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/hip/src/hip_ir.ll b/projects/hip/src/hip_ir.ll index c68e9879f2..5a14266086 100644 --- a/projects/hip/src/hip_ir.ll +++ b/projects/hip/src/hip_ir.ll @@ -2,12 +2,12 @@ target datalayout = "e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-i64: target triple = "amdgcn--amdhsa" -define linkonce_odr spir_func void @__threadfence() #1 { +define void @__threadfence() #1 { fence syncscope(2) seq_cst ret void } -define linkonce_odr spir_func void @__threadfence_block() #1 { +define void @__threadfence_block() #1 { fence syncscope(3) seq_cst ret void } From 08a67a522da82943615e6f63fd452506012218db Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Fri, 27 Jan 2017 08:51:48 -0600 Subject: [PATCH 111/281] fixed arch compiler flag Change-Id: I19f7a0ea513d6b8059f0c10cd0e7a5ead510e246 [ROCm/hip commit: b37422d30b4ecfcc7195cbea87ee6213edfebb1f] --- projects/hip/bin/hipcc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/projects/hip/bin/hipcc b/projects/hip/bin/hipcc index 004463bc2c..e43131501c 100755 --- a/projects/hip/bin/hipcc +++ b/projects/hip/bin/hipcc @@ -131,16 +131,16 @@ if ($HIP_PLATFORM eq "hcc") { # Handle ROCm target platform if ($ROCM_TARGET eq "fiji") { - $HIPLDFLAGS .= " -amdgpu-target=AMD:AMDGPU:8:0:3"; + $HIPLDFLAGS .= " --amdgpu-target=gfx803"; } if ($ROCM_TARGET eq "carrizo") { - $HIPLDFLAGS .= " -amdgpu-target=AMD:AMDGPU:8:0:1"; + $HIPLDFLAGS .= " --amdgpu-target=gfx801"; } if ($ROCM_TARGET eq "hawaii") { - $HIPLDFLAGS .= " -amdgpu-target=AMD:AMDGPU:7:0:1"; + $HIPLDFLAGS .= " --amdgpu-target=gfx701"; } if ($ROCM_TARGET eq "polaris") { - $HIPLDFLAGS .= " -amdgpu-target=AMD:AMDGPU:8:0:3"; + $HIPLDFLAGS .= " --amdgpu-target=gfx803"; } # Add trace marker library: From 9d445cbf358f5847e3e6d6ad651b7a32f33ac187 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Fri, 27 Jan 2017 09:20:14 -0600 Subject: [PATCH 112/281] changed device code tests to work not to work as one Change-Id: I0eec1eab19dda3b703bc3a0d778a6bbb2802a412 [ROCm/hip commit: 66dc2d42db6ede00096214591ce869e2c34551d1] --- .../src/deviceLib/hipDoublePrecisionIntrinsics.cpp | 13 +++++++++++++ .../src/deviceLib/hipDoublePrecisionMathDevice.cpp | 13 +++++++++++++ .../src/deviceLib/hipDoublePrecisionMathHost.cpp | 13 +++++++++++++ .../tests/src/deviceLib/hipFloatMathPrecise.cpp | 8 ++++++++ .../tests/src/deviceLib/hipIntegerIntrinsics.cpp | 14 ++++++++++++++ .../hip/tests/src/deviceLib/hipMathFunctions.cpp | 9 --------- .../src/deviceLib/hipSinglePrecisionIntrinsics.cpp | 13 +++++++++++++ .../src/deviceLib/hipSinglePrecisionMathDevice.cpp | 13 +++++++++++++ .../src/deviceLib/hipSinglePrecisionMathHost.cpp | 13 +++++++++++++ .../tests/src/deviceLib/hipTestDeviceSymbol.cpp | 8 ++++++++ .../hip/tests/src/deviceLib/hipThreadFence.cpp | 9 ++++++++- 11 files changed, 116 insertions(+), 10 deletions(-) diff --git a/projects/hip/tests/src/deviceLib/hipDoublePrecisionIntrinsics.cpp b/projects/hip/tests/src/deviceLib/hipDoublePrecisionIntrinsics.cpp index 1b087118b8..a3a302a3ef 100644 --- a/projects/hip/tests/src/deviceLib/hipDoublePrecisionIntrinsics.cpp +++ b/projects/hip/tests/src/deviceLib/hipDoublePrecisionIntrinsics.cpp @@ -19,6 +19,13 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + +/* HIT_START + * BUILD: %t %s ../test_common.cpp + * RUN: %t + * HIT_END + */ + #include #include #include "test_common.h" @@ -62,3 +69,9 @@ __global__ void compileDoublePrecisionIntrinsics(hipLaunchParm lp, int ignored) { double_precision_intrinsics(); } + +int main() +{ + hipLaunchKernel(compileDoublePrecisionIntrinsics, dim3(1,1,1), dim3(1,1,1), 0, 0, 1); + passed(); +} diff --git a/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathDevice.cpp b/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathDevice.cpp index e5d57b4dce..df5dad3968 100644 --- a/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathDevice.cpp +++ b/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathDevice.cpp @@ -19,6 +19,13 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + +/* HIT_START + * BUILD: %t %s ../test_common.cpp + * RUN: %t + * HIT_END + */ + #include #include #include "test_common.h" @@ -124,3 +131,9 @@ __global__ void compileDoublePrecisionMathOnDevice(hipLaunchParm lp, int ignored { double_precision_math_functions(); } + +int main() +{ + hipLaunchKernel(compileDoublePrecisionMathOnDevice, dim3(1,1,1), dim3(1,1,1), 0, 0, 1); + passed(); +} diff --git a/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathHost.cpp b/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathHost.cpp index af923da3aa..bfdf874c6d 100644 --- a/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathHost.cpp +++ b/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathHost.cpp @@ -19,6 +19,13 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + +/* HIT_START + * BUILD: %t %s ../test_common.cpp + * RUN: %t + * HIT_END + */ + #include #include #include "test_common.h" @@ -130,3 +137,9 @@ static void compileOnHost() { double_precision_math_functions(); } + +int main() +{ + compileOnHost(); + passed(); +} diff --git a/projects/hip/tests/src/deviceLib/hipFloatMathPrecise.cpp b/projects/hip/tests/src/deviceLib/hipFloatMathPrecise.cpp index 12f7875949..78fe47cfe8 100644 --- a/projects/hip/tests/src/deviceLib/hipFloatMathPrecise.cpp +++ b/projects/hip/tests/src/deviceLib/hipFloatMathPrecise.cpp @@ -19,6 +19,13 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + +/* HIT_START + * BUILD: %t %s ../test_common.cpp + * RUN: %t + * HIT_END + */ + #include #include #include "test_common.h" @@ -120,4 +127,5 @@ __global__ void FloatMathPrecise(hipLaunchParm lp) int main() { hipLaunchKernel(FloatMathPrecise, dim3(1,1,1), dim3(1,1,1), 0, 0); + passed(); } diff --git a/projects/hip/tests/src/deviceLib/hipIntegerIntrinsics.cpp b/projects/hip/tests/src/deviceLib/hipIntegerIntrinsics.cpp index d712c5a93b..6bf13a0809 100644 --- a/projects/hip/tests/src/deviceLib/hipIntegerIntrinsics.cpp +++ b/projects/hip/tests/src/deviceLib/hipIntegerIntrinsics.cpp @@ -19,6 +19,14 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + +/* HIT_START + * BUILD: %t %s ../test_common.cpp + * RUN: %t + * HIT_END + */ + + #include #include #include "test_common.h" @@ -57,3 +65,9 @@ __global__ void compileIntegerIntrinsics(hipLaunchParm lp, int ignored) { integer_intrinsics(); } + +int main() +{ + hipLaunchKernel(compileIntegerIntrinsics, dim3(1,1,1), dim3(1,1,1), 0, 0, 1); + passed(); +} diff --git a/projects/hip/tests/src/deviceLib/hipMathFunctions.cpp b/projects/hip/tests/src/deviceLib/hipMathFunctions.cpp index ed62120613..450b6126b0 100644 --- a/projects/hip/tests/src/deviceLib/hipMathFunctions.cpp +++ b/projects/hip/tests/src/deviceLib/hipMathFunctions.cpp @@ -20,15 +20,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* HIT_START - * BUILD: %tHost %s hipSinglePrecisionMathHost.cpp hipDoublePrecisionMathHost.cpp ../test_common.cpp - * BUILD: %tDevice %s hipSinglePrecisionMathDevice.cpp hipDoublePrecisionMathDevice.cpp ../test_common.cpp - * BUILD: hipIntrinsics %s hipSinglePrecisionIntrinsics.cpp hipDoublePrecisionIntrinsics.cpp hipIntegerIntrinsics.cpp ../test_common.cpp - * RUN: %tHost - * RUN: %tDevice - * RUN: hipIntrinsics - * HIT_END - */ #include "hip/hip_runtime.h" #include "test_common.h" diff --git a/projects/hip/tests/src/deviceLib/hipSinglePrecisionIntrinsics.cpp b/projects/hip/tests/src/deviceLib/hipSinglePrecisionIntrinsics.cpp index 6737c6ee9d..3407748437 100644 --- a/projects/hip/tests/src/deviceLib/hipSinglePrecisionIntrinsics.cpp +++ b/projects/hip/tests/src/deviceLib/hipSinglePrecisionIntrinsics.cpp @@ -19,6 +19,12 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/* HIT_START + * BUILD: %t %s ../test_common.cpp + * RUN: %t + * HIT_END + */ + #include #include #include "test_common.h" @@ -78,3 +84,10 @@ __global__ void compileSinglePrecisionIntrinsics(hipLaunchParm lp, int ignored) { single_precision_intrinsics(); } + + +int main() +{ + hipLaunchKernel(compileSinglePrecisionIntrinsics, dim3(1,1,1), dim3(1,1,1), 0, 0, 1); + passed(); +} diff --git a/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathDevice.cpp b/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathDevice.cpp index 4576faed93..53ccd2251f 100644 --- a/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathDevice.cpp +++ b/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathDevice.cpp @@ -19,6 +19,13 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + +/* HIT_START + * BUILD: %t %s ../test_common.cpp + * RUN: %t + * HIT_END + */ + #include #include #include "test_common.h" @@ -125,3 +132,9 @@ __global__ void compileSinglePrecisionMathOnDevice(hipLaunchParm lp, int ignored { single_precision_math_functions(); } + +int main() +{ + hipLaunchKernel(compileSinglePrecisionMathOnDevice, dim3(1,1,1), dim3(1,1,1), 0, 0, 1); + passed(); +} diff --git a/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathHost.cpp b/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathHost.cpp index d48cea5ff6..933a51074f 100644 --- a/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathHost.cpp +++ b/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathHost.cpp @@ -19,6 +19,13 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + +/* HIT_START + * BUILD: %t %s ../test_common.cpp + * RUN: %t + * HIT_END + */ + #include #include #include "test_common.h" @@ -133,3 +140,9 @@ static void compileOnHost() { single_precision_math_functions(); } + +int main() +{ + compileOnHost(); + passed(); +} diff --git a/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp b/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp index 1158bf3f9d..f90ed38967 100644 --- a/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp +++ b/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp @@ -17,8 +17,15 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/* HIT_START + * BUILD: %t %s ../test_common.cpp + * RUN: %t + * HIT_END + */ + #include #include +#include"test_common.h" #include #define NUM 1024 @@ -72,4 +79,5 @@ int main() for(unsigned i=0;i #include #include +#include"test_common.h" #define NUM 1024 #define SIZE NUM*sizeof(float) @@ -65,5 +72,5 @@ int main(){ hipLaunchKernel(vAdd, dim3(32,1,1), dim3(32,1,1), 0, 0, In1d, In2d, In3d, In4d, Outd); hipMemcpy(Out, Outd, SIZE, hipMemcpyDeviceToHost); assert(Out[10] == 2*In1[10] + 2*In2[10] + In3[10]); - + passed(); } From 76fa20bd8977493462e4b9c51325b9fd6c5b66e5 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Fri, 27 Jan 2017 17:38:43 -0600 Subject: [PATCH 113/281] removed host math functions from math_functions.h Change-Id: I90d8784e2d6b58c6fade9f0fa12c0db3ee417d3e [ROCm/hip commit: 60013396f6f4fa9e960e31141c83ffe2cd8d3371] --- .../include/hip/hcc_detail/math_functions.h | 42 ------------------- .../deviceLib/hipDoublePrecisionMathHost.cpp | 34 ++++++++------- .../deviceLib/hipSinglePrecisionMathHost.cpp | 37 ++++++++-------- .../hip/tests/src/deviceLib/hipTestDevice.cpp | 4 +- .../src/deviceLib/hipTestDeviceDouble.cpp | 4 +- 5 files changed, 41 insertions(+), 80 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/math_functions.h b/projects/hip/include/hip/hcc_detail/math_functions.h index 2755c896db..2cc4ef81bd 100644 --- a/projects/hip/include/hip/hcc_detail/math_functions.h +++ b/projects/hip/include/hip/hcc_detail/math_functions.h @@ -111,27 +111,6 @@ __device__ float y0f(float x); __device__ float y1f(float x); __device__ float ynf(int n, float x); -__host__ float cospif(float x); -__host__ float normcdff(float y); -__host__ float erfcinvf(float y); -__host__ float erfcxf(float x); -__host__ float erfinvf(float y); -__host__ float fdividef(float x, float y); -__host__ float norm3df(float a, float b, float c); -__host__ float normcdfinvf(float y); -__host__ float norm4df(float a, float b, float c, float d); -__host__ float rcbrtf(float x); -__host__ float rhypotf(float x, float y); -__host__ float rnorm3df(float a, float b, float c); -__host__ float rnormf(int dim, const float* a); -__host__ float rnorm4df(float a, float b, float c, float d); -__host__ void sincospif(float x, float *sptr, float *cptr); -__host__ int isfinite(float a); -__host__ float rsqrtf(float x); -__host__ float sinpif(float x); -__host__ int signbit(float a); - - __device__ double acos(double x); __device__ double acosh(double x); __device__ double asin(double x); @@ -220,27 +199,6 @@ __device__ double y0(double x); __device__ double y1(double y); __device__ double yn(int n, double x); -__host__ double erfcinv(double y); -__host__ double erfcx(double x); -__host__ double erfinv(double y); -__host__ double fdivide(double x, double y); -__host__ double norm(int dim, const double *t); -__host__ double norm3d(double a, double b, double c); -__host__ double norm4d(double a, double b, double c, double d); -__host__ double normcdf(double y); -__host__ double normcdfinv(double y); -__host__ double rcbrt(double x); -__host__ double rhypot(double x, double y); -__host__ double rnorm(int dim, const double* t); -__host__ double rnorm3d(double a, double b, double c); -__host__ double rnorm4d(double a, double b, double c, double d); -__host__ void sincospi(double x, double *sptr, double *cptr); -__host__ double cospi(double x); -__host__ int isfinite(double x); -__host__ double rsqrt(double x); -__host__ int signbit(double a); -__host__ double sinpi(double x); - // ENDPARSER #ifdef HIP_FAST_MATH diff --git a/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathHost.cpp b/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathHost.cpp index bfdf874c6d..7f63d32e3d 100644 --- a/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathHost.cpp +++ b/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathHost.cpp @@ -27,8 +27,9 @@ THE SOFTWARE. */ #include -#include +//#include #include "test_common.h" +#include #pragma GCC diagnostic ignored "-Wall" #pragma clang diagnostic ignored "-Wunused-variable" @@ -50,14 +51,14 @@ __host__ void double_precision_math_functions() copysign(1.0, -2.0); cos(0.0); cosh(0.0); - cospi(0.0); + //cospi(0.0); //cyl_bessel_i0(0.0); //cyl_bessel_i1(0.0); erf(0.0); erfc(0.0); - erfcinv(2.0); - erfcx(0.0); - erfinv(1.0); + //erfcinv(2.0); + //erfcx(0.0); + //erfinv(1.0); exp(0.0); exp10(0.0); exp2(0.0); @@ -93,36 +94,37 @@ __host__ void double_precision_math_functions() nan("1"); nearbyint(0.0); //nextafter(0.0); - fX = 1.0; norm(1, &fX); + fX = 1.0; //norm(1, &fX); #if defined(__HIP_PLATFORM_HCC__) - norm3d(1.0, 0.0, 0.0); - norm4d(1.0, 0.0, 0.0, 0.0); + //norm3d(1.0, 0.0, 0.0); + //norm4d(1.0, 0.0, 0.0, 0.0); #endif // normcdf(0.0); // normcdfinv(1.0); pow(1.0, 0.0); - rcbrt(1.0); + //rcbrt(1.0); + remainder(2.0, 1.0); remquo(1.0, 2.0, &iX); #if defined(__HIP_PLATFORM_HCC__) - rhypot(0.0, 1.0); + //rhypot(0.0, 1.0); #endif rint(1.0); #if defined(__HIP_PLATFORM_HCC__) - fX = 1.0; rnorm(1, &fX); - rnorm3d(0.0, 0.0, 1.0); - rnorm4d(0.0, 0.0, 0.0, 1.0); + fX = 1.0; //rnorm(1, &fX); + //rnorm3d(0.0, 0.0, 1.0); + //rnorm4d(0.0, 0.0, 0.0, 1.0); #endif round(0.0); - rsqrt(1.0); + //rsqrt(1.0); scalbln(0.0, 1); scalbn(0.0, 1); signbit(1.0); sin(0.0); sincos(0.0, &fX, &fY); - sincospi(0.0, &fX, &fY); + //sincospi(0.0, &fX, &fY); sinh(0.0); - sinpi(0.0); + //sinpi(0.0); sqrt(0.0); tan(0.0); tanh(0.0); diff --git a/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathHost.cpp b/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathHost.cpp index 933a51074f..83bc740e9e 100644 --- a/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathHost.cpp +++ b/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathHost.cpp @@ -27,8 +27,9 @@ THE SOFTWARE. */ #include -#include +//#include #include "test_common.h" +#include #pragma GCC diagnostic ignored "-Wall" #pragma clang diagnostic ignored "-Wunused-variable" @@ -50,14 +51,14 @@ __host__ void single_precision_math_functions() copysignf(1.0f, -2.0f); cosf(0.0f); coshf(0.0f); - cospif(0.0f); + //cospif(0.0f); //cyl_bessel_i0f(0.0f); //cyl_bessel_i1f(0.0f); erfcf(0.0f); - erfcinvf(2.0f); - erfcxf(0.0f); + //erfcinvf(2.0f); + //erfcxf(0.0f); erff(0.0f); - erfinvf(1.0f); + //erfinvf(1.0f); exp10f(0.0f); exp2f(0.0f); expf(0.0f); @@ -65,7 +66,7 @@ __host__ void single_precision_math_functions() fabsf(1.0f); fdimf(1.0f, 0.0f); #if defined(__HIP_PLATFORM_HCC__) - fdividef(0.0f, 1.0f); + //fdividef(0.0f, 1.0f); #endif floorf(0.0f); fmaf(1.0f, 2.0f, 3.0f); @@ -97,35 +98,35 @@ __host__ void single_precision_math_functions() nearbyintf(0.0f); //nextafterf(0.0f); #if defined(__HIP_PLATFORM_HCC__) - norm3df(1.0f, 0.0f, 0.0f); - norm4df(1.0f, 0.0f, 0.0f, 0.0f); + //norm3df(1.0f, 0.0f, 0.0f); + //norm4df(1.0f, 0.0f, 0.0f, 0.0f); #endif - normcdff(0.0f); - normcdfinvf(1.0f); + //normcdff(0.0f); + //normcdfinvf(1.0f); //fX = 1.0f; normf(1, &fX); powf(1.0f, 0.0f); - rcbrtf(1.0f); + //rcbrtf(1.0f); remainderf(2.0f, 1.0f); remquof(1.0f, 2.0f, &iX); #if defined(__HIP_PLATFORM_HCC__) - rhypotf(0.0f, 1.0f); + //rhypotf(0.0f, 1.0f); #endif rintf(1.0f); #if defined(__HIP_PLATFORM_HCC__) - rnorm3df(0.0f, 0.0f, 1.0f); - rnorm4df(0.0f, 0.0f, 0.0f, 1.0f); - fX = 1.0f; rnormf(1, &fX); + //rnorm3df(0.0f, 0.0f, 1.0f); + //rnorm4df(0.0f, 0.0f, 0.0f, 1.0f); + fX = 1.0f; //rnormf(1, &fX); #endif roundf(0.0f); - rsqrtf(1.0f); + ///rsqrtf(1.0f); scalblnf(0.0f, 1); scalbnf(0.0f, 1); signbit(1.0f); sincosf(0.0f, &fX, &fY); - sincospif(0.0f, &fX, &fY); + //sincospif(0.0f, &fX, &fY); sinf(0.0f); sinhf(0.0f); - sinpif(0.0f); + //sinpif(0.0f); sqrtf(0.0f); tanf(0.0f); tanhf(0.0f); diff --git a/projects/hip/tests/src/deviceLib/hipTestDevice.cpp b/projects/hip/tests/src/deviceLib/hipTestDevice.cpp index 2c7488671b..570f3baaf0 100644 --- a/projects/hip/tests/src/deviceLib/hipTestDevice.cpp +++ b/projects/hip/tests/src/deviceLib/hipTestDevice.cpp @@ -164,13 +164,13 @@ hipMemcpy(B, Bd, SIZE, hipMemcpyDeviceToHost); hipMemcpy(C, Cd, SIZE, hipMemcpyDeviceToHost); int passed = 0; for(int i=0;i<512;i++){ - if(B[i] - sinpif(1.0f) < 0.1){ + if(B[i] - sinf(3.14*1.0f) < 0.1){ passed = 1; } } passed = 0; for(int i=0;i<512;i++){ - if(C[i] - cospif(1.0f) < 0.1){ + if(C[i] - cosf(3.14*1.0f) < 0.1){ passed = 1; } } diff --git a/projects/hip/tests/src/deviceLib/hipTestDeviceDouble.cpp b/projects/hip/tests/src/deviceLib/hipTestDeviceDouble.cpp index f4e8ee20b8..5bdbbf1b8f 100644 --- a/projects/hip/tests/src/deviceLib/hipTestDeviceDouble.cpp +++ b/projects/hip/tests/src/deviceLib/hipTestDeviceDouble.cpp @@ -153,13 +153,13 @@ hipMemcpy(B, Bd, SIZE, hipMemcpyDeviceToHost); hipMemcpy(C, Cd, SIZE, hipMemcpyDeviceToHost); int passed = 0; for(int i=0;i<512;i++){ - if(B[i] - sinpi(1.0) < 0.1){ + if(B[i] - sin(3.14*1.0) < 0.1){ passed = 1; } } passed = 0; for(int i=0;i<512;i++){ - if(C[i] - cospi(1.0) < 0.1){ + if(C[i] - cos(3.14*1.0) < 0.1){ passed = 1; } } From afb38e15de69eb7317f69d1317418d391b765a04 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Wed, 1 Feb 2017 17:54:59 -0600 Subject: [PATCH 114/281] fixed symbol memcpy issue Change-Id: I89d7401be51d194bcbf771020ba66e3d3b6a18f8 [ROCm/hip commit: 2790e9a448255a219c369aad5c345a92ace04c57] --- projects/hip/src/hip_hcc.cpp | 23 +++++++++++++++++++ projects/hip/src/hip_hcc.h | 8 +++---- projects/hip/src/hip_memory.cpp | 22 +++++++++++------- .../src/deviceLib/hipTestDeviceSymbol.cpp | 8 +++++-- 4 files changed, 46 insertions(+), 15 deletions(-) diff --git a/projects/hip/src/hip_hcc.cpp b/projects/hip/src/hip_hcc.cpp index 20ff1722e3..68bf74cd21 100644 --- a/projects/hip/src/hip_hcc.cpp +++ b/projects/hip/src/hip_hcc.cpp @@ -1780,6 +1780,28 @@ void ihipStream_t::locked_copySync(void* dst, const void* src, size_t sizeBytes, } } +void ihipStream_t::lockedSymbolCopySync(hc::accelerator &acc, void* dst, const void* src, size_t sizeBytes, unsigned kind) +{ + if(kind == hipMemcpyHostToHost){ + acc.memcpy_symbol(dst, (void*)src, sizeBytes, Kalmar::hcMemcpyHostToHost); + } + if(kind == hipMemcpyHostToDevice){ + acc.memcpy_symbol(dst, (void*)src, sizeBytes); + } + if(kind == hipMemcpyDeviceToDevice){ + acc.memcpy_symbol(dst, (void*)src, sizeBytes, Kalmar::hcMemcpyDeviceToDevice); + } + if(kind == hipMemcpyDeviceToHost){ + acc.memcpy_symbol(dst, (void*)src, sizeBytes, Kalmar::hcMemcpyDeviceToHost); + } +} + +void ihipStream_t::lockedSymbolCopyAsync(hc::accelerator &acc, void* dst, const void* src, size_t sizeBytes, unsigned kind) +{ + hc::AmPointerInfo dstPtrInfo(NULL, dst, sizeBytes, acc, true, false); + hc::am_memtracker_add(dst, dstPtrInfo); + locked_getAv()->copy_async((void*)src, dst, sizeBytes); +} void ihipStream_t::locked_copyAsync(void* dst, const void* src, size_t sizeBytes, unsigned kind) { @@ -1881,6 +1903,7 @@ void ihipStream_t::locked_copyAsync(void* dst, const void* src, size_t sizeBytes LockedAccessor_StreamCrit_t crit(_criticalData); this->ensureHaveQueue(crit); + #if USE_COPY_EXT_V2 crit->_av.copy_ext(src, dst, sizeBytes, hcCopyDir, srcPtrInfo, dstPtrInfo, copyDevice ? ©Device->getDevice()->_acc : nullptr, forceUnpinnedCopy); #else diff --git a/projects/hip/src/hip_hcc.h b/projects/hip/src/hip_hcc.h index 9998c4ec0e..28ae6a2e8e 100644 --- a/projects/hip/src/hip_hcc.h +++ b/projects/hip/src/hip_hcc.h @@ -273,7 +273,7 @@ extern void recordApiTrace(std::string *fullStr, const std::string &apiStr); API_TRACE(0, __VA_ARGS__); -// Like above, but will trace with DB_CMD. +// Like above, but will trace with DB_CMD. // Replace HIP_INIT_API with this call inside important APIs that launch work on the GPU: // kernel launches, copy commands, memory sets, etc. #define HIP_INIT_CMD_API(...) \ @@ -479,8 +479,6 @@ private: typedef ihipStreamCriticalBase_t ihipStreamCritical_t; typedef LockedAccessor LockedAccessor_StreamCrit_t; - - //--- // Internal stream structure. class ihipStream_t { @@ -494,10 +492,10 @@ public: // kind is hipMemcpyKind void locked_copySync (void* dst, const void* src, size_t sizeBytes, unsigned kind, bool resolveOn = true); - - void locked_copyAsync(void* dst, const void* src, size_t sizeBytes, unsigned kind); + void lockedSymbolCopySync(hc::accelerator &acc, void *dst, const void* src, size_t sizeBytes, unsigned kind); + void lockedSymbolCopyAsync(hc::accelerator &acc, void *dst, const void* src, size_t sizeBytes, unsigned kind); //--- // Member functions that begin with locked_ are thread-safe accessors - these acquire / release the critical mutex. diff --git a/projects/hip/src/hip_memory.cpp b/projects/hip/src/hip_memory.cpp index d66c151266..df776aa707 100644 --- a/projects/hip/src/hip_memory.cpp +++ b/projects/hip/src/hip_memory.cpp @@ -449,17 +449,23 @@ hipError_t hipMemcpyToSymbol(const char* symbolName, const void *src, size_t cou hc::accelerator acc = ctx->getDevice()->_acc; - void *ptr = acc.get_symbol_address(symbolName); - tprintf(DB_MEM, " symbol '%s' resolved to address:%p\n", symbolName, ptr); + void *dst = acc.get_symbol_address(symbolName); + tprintf(DB_MEM, " symbol '%s' resolved to address:%p\n", symbolName, dst); - if(ptr == nullptr) + if(dst == nullptr) { return ihipLogStatus(hipErrorInvalidSymbol); } hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull); - stream->locked_copySync(ptr, src, count + offset, kind); + if(kind == hipMemcpyHostToDevice || kind == hipMemcpyDeviceToHost || kind == hipMemcpyDeviceToDevice || kind == hipMemcpyHostToHost) + { + stream->lockedSymbolCopySync(acc, dst, src, count + offset, kind); + // acc.memcpy_symbol(dst, (void*)src, count+offset); + } else { + return ihipLogStatus(hipErrorInvalidValue); + } return ihipLogStatus(hipSuccess); } @@ -479,17 +485,17 @@ hipError_t hipMemcpyToSymbolAsync(const char* symbolName, const void *src, size_ hc::accelerator acc = ctx->getDevice()->_acc; - void *ptr = acc.get_symbol_address(symbolName); - tprintf(DB_MEM, " symbol '%s' resolved to address:%p\n", symbolName, ptr); + void *dst = acc.get_symbol_address(symbolName); + tprintf(DB_MEM, " symbol '%s' resolved to address:%p\n", symbolName, dst); - if(ptr == nullptr) + if(dst == nullptr) { return ihipLogStatus(hipErrorInvalidSymbol); } if (stream) { try { - stream->locked_copyAsync(ptr, src, count + offset, kind); + stream->lockedSymbolCopyAsync(acc, dst, src, count + offset, kind); } catch (ihipException ex) { e = ex._code; diff --git a/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp b/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp index f90ed38967..70fe794f67 100644 --- a/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp +++ b/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp @@ -47,7 +47,7 @@ __global__ void Assign(hipLaunchParm lp, int* Out) int main() { - int *A, *B, *Ad; + int *A, *Am, *B, *Ad; A = new int[NUM]; B = new int[NUM]; for(unsigned i=0;i Date: Fri, 3 Feb 2017 10:53:36 -0600 Subject: [PATCH 115/281] changed __global__ attribute 1. Moved around tests and added them to HIT Change-Id: I5d75280c42a5af852670ebabc7305ee56721ec7b [ROCm/hip commit: 5e3d63c0a38d5407e87182ada0360b3cc7f674bd] --- .../hip/include/hip/hcc_detail/hip_runtime.h | 31 +++- .../hip/include/hip/hcc_detail/host_defines.h | 2 +- projects/hip/src/device_util.cpp | 14 +- .../device}/hipFuncDeviceSynchronize.cpp | 11 +- .../device}/hipFuncGetDevice.cpp | 4 +- .../device}/hipFuncSetDevice.cpp | 4 +- .../device}/hipFuncSetDeviceFlags.cpp | 16 +-- .../Negative/Device/hipDeviceGetAttribute.cpp | 0 .../Negative/Device/hipDeviceUtil.h | 0 .../Negative/Device/hipGetDevice.cpp | 0 .../Negative/Device/hipGetDeviceCount.cpp | 0 .../Device/hipGetDeviceProperties.cpp | 0 .../Negative/Device/hipSetDevice.cpp | 0 .../memory}/hipPerfMemcpy.cpp | 0 projects/hip/tests/src/buildHIPC.sh | 3 - .../src/{ => context}/hipDrvGetPCIBusId.cpp | 0 .../tests/src/{ => context}/hipDrvMemcpy.cpp | 0 .../tests/src/{ => deviceLib}/hipComplex.cpp | 0 .../src/{ => deviceLib}/hipDeviceMemcpy.cpp | 0 .../hip/tests/src/deviceLib/hipTestHalf.cpp | 132 ++++-------------- .../tests/src/{ => deviceLib}/hipTestHost.cpp | 0 projects/hip/tests/src/hipC.c | 30 ++++ projects/hip/tests/src/hipC.cpp | 27 +++- projects/hip/tests/src/hipCKernel.c | 1 + projects/hip/tests/src/hipChooseDevice.cpp | 17 --- .../hip/tests/src/hipPeerToPeer_simple.cpp | 36 ++--- projects/hip/tests/src/hipTestHalf.cpp | 56 -------- .../src/{ => kernel}/hipDynamicShared.cpp | 7 +- .../hipEmptyKernel.cpp} | 9 +- .../hip/tests/src/kernel/hipGridLaunch.cpp | 5 +- .../src/kernel/hipLanguageExtensions.cpp | 6 +- .../tests/src/{ => kernel}/hipLaunchParm.cpp | 4 +- .../hip/tests/src/kernel/hipTestConstant.cpp | 6 + .../tests/src/kernel/hipTestMallocKernel.cpp | 8 +- .../hip/tests/src/kernel/hipTestMemKernel.cpp | 28 ++++ .../hip/tests/src/kernel/launch_bounds.cpp | 10 +- .../src/runtimeApi/device/hipChooseDevice.cpp | 49 +++++++ .../device}/hipGetDeviceAttribute.cpp | 3 +- .../{ => runtimeApi/event}/hipEventRecord.cpp | 10 +- .../src/{ => runtimeApi/memory}/hipArray.cpp | 26 +++- .../memory}/hipHostGetFlags.cpp | 2 +- .../{ => runtimeApi/memory}/hipHostMalloc.cpp | 2 +- .../memory}/hipHostRegister.cpp | 2 +- .../src/runtimeApi/memory/hipMemcpyAsync2.cpp | 24 ++++ .../memory}/hipRandomMemcpyAsync.cpp | 2 +- .../memory}/hipTestMemcpyPin.cpp | 2 +- .../src/{ => runtimeApi/module}/hipModule.cpp | 0 .../module}/hipModuleUnload.cpp | 0 projects/hip/tests/src/sampleModule.cpp | 94 ------------- projects/hip/tests/src/vcpy_isa.co | Bin 9416 -> 0 bytes projects/hip/tests/src/vcpy_isa.cu | 6 - projects/hip/tests/src/vcpy_isa.ptx | 38 ----- 52 files changed, 316 insertions(+), 411 deletions(-) rename projects/hip/tests/src/{ => Functional/device}/hipFuncDeviceSynchronize.cpp (94%) rename projects/hip/tests/src/{ => Functional/device}/hipFuncGetDevice.cpp (93%) rename projects/hip/tests/src/{ => Functional/device}/hipFuncSetDevice.cpp (93%) rename projects/hip/tests/src/{ => Functional/device}/hipFuncSetDeviceFlags.cpp (67%) rename projects/hip/tests/src/{Functional => }/Negative/Device/hipDeviceGetAttribute.cpp (100%) rename projects/hip/tests/src/{Functional => }/Negative/Device/hipDeviceUtil.h (100%) rename projects/hip/tests/src/{Functional => }/Negative/Device/hipGetDevice.cpp (100%) rename projects/hip/tests/src/{Functional => }/Negative/Device/hipGetDeviceCount.cpp (100%) rename projects/hip/tests/src/{Functional => }/Negative/Device/hipGetDeviceProperties.cpp (100%) rename projects/hip/tests/src/{Functional => }/Negative/Device/hipSetDevice.cpp (100%) rename projects/hip/tests/src/{ => Performance/memory}/hipPerfMemcpy.cpp (100%) delete mode 100755 projects/hip/tests/src/buildHIPC.sh rename projects/hip/tests/src/{ => context}/hipDrvGetPCIBusId.cpp (100%) rename projects/hip/tests/src/{ => context}/hipDrvMemcpy.cpp (100%) rename projects/hip/tests/src/{ => deviceLib}/hipComplex.cpp (100%) rename projects/hip/tests/src/{ => deviceLib}/hipDeviceMemcpy.cpp (100%) rename projects/hip/tests/src/{ => deviceLib}/hipTestHost.cpp (100%) delete mode 100644 projects/hip/tests/src/hipChooseDevice.cpp delete mode 100644 projects/hip/tests/src/hipTestHalf.cpp rename projects/hip/tests/src/{ => kernel}/hipDynamicShared.cpp (97%) rename projects/hip/tests/src/{hipKernel.cpp => kernel/hipEmptyKernel.cpp} (89%) rename projects/hip/tests/src/{ => kernel}/hipLaunchParm.cpp (96%) create mode 100644 projects/hip/tests/src/runtimeApi/device/hipChooseDevice.cpp rename projects/hip/tests/src/{ => runtimeApi/device}/hipGetDeviceAttribute.cpp (99%) rename projects/hip/tests/src/{ => runtimeApi/event}/hipEventRecord.cpp (96%) rename projects/hip/tests/src/{ => runtimeApi/memory}/hipArray.cpp (87%) rename projects/hip/tests/src/{ => runtimeApi/memory}/hipHostGetFlags.cpp (98%) rename projects/hip/tests/src/{ => runtimeApi/memory}/hipHostMalloc.cpp (98%) rename projects/hip/tests/src/{ => runtimeApi/memory}/hipHostRegister.cpp (98%) rename projects/hip/tests/src/{ => runtimeApi/memory}/hipRandomMemcpyAsync.cpp (98%) rename projects/hip/tests/src/{ => runtimeApi/memory}/hipTestMemcpyPin.cpp (97%) rename projects/hip/tests/src/{ => runtimeApi/module}/hipModule.cpp (100%) rename projects/hip/tests/src/{ => runtimeApi/module}/hipModuleUnload.cpp (100%) delete mode 100644 projects/hip/tests/src/sampleModule.cpp delete mode 100755 projects/hip/tests/src/vcpy_isa.co delete mode 100644 projects/hip/tests/src/vcpy_isa.cu delete mode 100644 projects/hip/tests/src/vcpy_isa.ptx diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime.h b/projects/hip/include/hip/hcc_detail/hip_runtime.h index 822ee31f2b..aa6fe06337 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime.h @@ -26,8 +26,8 @@ THE SOFTWARE. */ //#pragma once -#ifndef HIP_RUNTIME_H -#define HIP_RUNTIME_H +#ifndef HIP_HCC_DETAIL_RUNTIME_H +#define HIP_HCC_DETAIL_RUNTIME_H //--- // Top part of file can be compiled with any compiler @@ -345,14 +345,31 @@ __device__ int __hip_move_dpp(int src, int dpp_ctrl, int row_mask, int bank_mask #define hipGridDim_y (hc_get_num_groups(1)) #define hipGridDim_z (hc_get_num_groups(2)) -//extern "C" __device__ void* memcpy(void* dst, void* src, size_t size); -//extern "C" __device__ void* memset(void* ptr, uint8_t val, size_t size); - +extern "C" __device__ void* __hip_hc_memcpy(void* dst, void* src, size_t size); +extern "C" __device__ void* __hip_hc_memset(void* ptr, uint8_t val, size_t size); extern "C" __device__ void* __hip_hc_malloc(size_t); extern "C" __device__ void* __hip_hc_free(void *ptr); -//extern "C" __device__ void* malloc(size_t size); -//extern "C" __device__ void* free(void *ptr); +static inline __device__ void* malloc(size_t size) +{ + return __hip_hc_malloc(size); +} + +static inline __device__ void* free(void *ptr) +{ + return __hip_hc_free(ptr); +} + +static inline __device__ void* memcpy(void* dst, void* src, size_t size) +{ + return __hip_hc_memcpy(dst, src, size); +} + +static inline __device__ void* memset(void* ptr, uint8_t val, size_t size) +{ + return __hip_hc_memset(ptr, val, size); +} + #define __syncthreads() hc_barrier(CLK_LOCAL_MEM_FENCE) diff --git a/projects/hip/include/hip/hcc_detail/host_defines.h b/projects/hip/include/hip/hcc_detail/host_defines.h index 906c39421e..e401cb24f3 100644 --- a/projects/hip/include/hip/hcc_detail/host_defines.h +++ b/projects/hip/include/hip/hcc_detail/host_defines.h @@ -35,7 +35,7 @@ THE SOFTWARE. #define __host__ __attribute__((cpu)) #define __device__ __attribute__((hc)) -#define __global__ __attribute__((hc_grid_launch)) +#define __global__ __attribute__((hc_grid_launch)) __attribute__((used)) #define __noinline__ __attribute__((noinline)) #define __forceinline__ __attribute__((always_inline)) diff --git a/projects/hip/src/device_util.cpp b/projects/hip/src/device_util.cpp index d80d9e7ef5..fb207e3996 100644 --- a/projects/hip/src/device_util.cpp +++ b/projects/hip/src/device_util.cpp @@ -99,7 +99,7 @@ __device__ void* __hip_hc_free(void *ptr) // loop unrolling -__device__ void* memcpy(void* dst, void* src, size_t size) +__device__ void* __hip_hc_memcpy(void* dst, void* src, size_t size) { uint8_t *dstPtr, *srcPtr; dstPtr = (uint8_t*)dst; @@ -110,7 +110,7 @@ __device__ void* memcpy(void* dst, void* src, size_t size) return nullptr; } -__device__ void* memset(void* ptr, uint8_t val, size_t size) +__device__ void* __hip_hc_memset(void* ptr, uint8_t val, size_t size) { uint8_t *dstPtr; dstPtr = (uint8_t*)ptr; @@ -120,16 +120,6 @@ __device__ void* memset(void* ptr, uint8_t val, size_t size) return nullptr; } -__device__ void* malloc(size_t size) -{ - return __hip_hc_malloc(size); -} - -__device__ void* free(void *ptr) -{ - return __hip_hc_free(ptr); -} - __device__ float __hip_erfinvf(float x){ float ret; int sign; diff --git a/projects/hip/tests/src/hipFuncDeviceSynchronize.cpp b/projects/hip/tests/src/Functional/device/hipFuncDeviceSynchronize.cpp similarity index 94% rename from projects/hip/tests/src/hipFuncDeviceSynchronize.cpp rename to projects/hip/tests/src/Functional/device/hipFuncDeviceSynchronize.cpp index 930bc37b8b..dac56bf709 100644 --- a/projects/hip/tests/src/hipFuncDeviceSynchronize.cpp +++ b/projects/hip/tests/src/Functional/device/hipFuncDeviceSynchronize.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights @@ -23,7 +23,7 @@ THE SOFTWARE. */ /* HIT_START - * BUILD: %t %s test_common.cpp + * BUILD: %t %s ../../test_common.cpp * RUN: %t * HIT_END */ @@ -63,13 +63,12 @@ int main(){ HIPCHECK(hipMemcpyAsync(A[i], Ad[i], _SIZE, hipMemcpyDeviceToHost, stream[i])); } - - // This first check but relies on the kernel running for so long that the D2H async memcopy has not started yet. - // This will be true in an optimal asynchronous implementation. + + // This first check but relies on the kernel running for so long that the D2H async memcopy has not started yet. + // This will be true in an optimal asynchronous implementation. // Conservative implementations which synchronize the hipMemcpyAsync will fail, ie if HIP_LAUNCH_BLOCKING=true HIPASSERT(1<<30 != A[NUM_STREAMS-1][0]-1); HIPCHECK(hipDeviceSynchronize()); HIPASSERT(1<<30 == A[NUM_STREAMS-1][0]-1); passed(); } - diff --git a/projects/hip/tests/src/hipFuncGetDevice.cpp b/projects/hip/tests/src/Functional/device/hipFuncGetDevice.cpp similarity index 93% rename from projects/hip/tests/src/hipFuncGetDevice.cpp rename to projects/hip/tests/src/Functional/device/hipFuncGetDevice.cpp index f903149f91..a268ec0acd 100644 --- a/projects/hip/tests/src/hipFuncGetDevice.cpp +++ b/projects/hip/tests/src/Functional/device/hipFuncGetDevice.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights @@ -23,7 +23,7 @@ THE SOFTWARE. */ /* HIT_START - * BUILD: %t %s test_common.cpp + * BUILD: %t %s ../../test_common.cpp * RUN: %t * HIT_END */ diff --git a/projects/hip/tests/src/hipFuncSetDevice.cpp b/projects/hip/tests/src/Functional/device/hipFuncSetDevice.cpp similarity index 93% rename from projects/hip/tests/src/hipFuncSetDevice.cpp rename to projects/hip/tests/src/Functional/device/hipFuncSetDevice.cpp index 030ceb7b0c..b1b7cac12d 100644 --- a/projects/hip/tests/src/hipFuncSetDevice.cpp +++ b/projects/hip/tests/src/Functional/device/hipFuncSetDevice.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights @@ -18,7 +18,7 @@ THE SOFTWARE. */ /* HIT_START - * BUILD: %t %s test_common.cpp + * BUILD: %t %s ../../test_common.cpp * RUN: %t EXCLUDE_HIP_PLATFORM * HIT_END */ diff --git a/projects/hip/tests/src/hipFuncSetDeviceFlags.cpp b/projects/hip/tests/src/Functional/device/hipFuncSetDeviceFlags.cpp similarity index 67% rename from projects/hip/tests/src/hipFuncSetDeviceFlags.cpp rename to projects/hip/tests/src/Functional/device/hipFuncSetDeviceFlags.cpp index 9bda91f113..eacd4d2b63 100644 --- a/projects/hip/tests/src/hipFuncSetDeviceFlags.cpp +++ b/projects/hip/tests/src/Functional/device/hipFuncSetDeviceFlags.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights @@ -8,17 +8,17 @@ copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANNTY OF ANY KIND, EXPRESS OR -IMPLIED, INNCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANNY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER INN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* HIT_START - * BUILD: %t %s test_common.cpp + * BUILD: %t %s ../../test_common.cpp * RUN: %t * HIT_END */ diff --git a/projects/hip/tests/src/Functional/Negative/Device/hipDeviceGetAttribute.cpp b/projects/hip/tests/src/Negative/Device/hipDeviceGetAttribute.cpp similarity index 100% rename from projects/hip/tests/src/Functional/Negative/Device/hipDeviceGetAttribute.cpp rename to projects/hip/tests/src/Negative/Device/hipDeviceGetAttribute.cpp diff --git a/projects/hip/tests/src/Functional/Negative/Device/hipDeviceUtil.h b/projects/hip/tests/src/Negative/Device/hipDeviceUtil.h similarity index 100% rename from projects/hip/tests/src/Functional/Negative/Device/hipDeviceUtil.h rename to projects/hip/tests/src/Negative/Device/hipDeviceUtil.h diff --git a/projects/hip/tests/src/Functional/Negative/Device/hipGetDevice.cpp b/projects/hip/tests/src/Negative/Device/hipGetDevice.cpp similarity index 100% rename from projects/hip/tests/src/Functional/Negative/Device/hipGetDevice.cpp rename to projects/hip/tests/src/Negative/Device/hipGetDevice.cpp diff --git a/projects/hip/tests/src/Functional/Negative/Device/hipGetDeviceCount.cpp b/projects/hip/tests/src/Negative/Device/hipGetDeviceCount.cpp similarity index 100% rename from projects/hip/tests/src/Functional/Negative/Device/hipGetDeviceCount.cpp rename to projects/hip/tests/src/Negative/Device/hipGetDeviceCount.cpp diff --git a/projects/hip/tests/src/Functional/Negative/Device/hipGetDeviceProperties.cpp b/projects/hip/tests/src/Negative/Device/hipGetDeviceProperties.cpp similarity index 100% rename from projects/hip/tests/src/Functional/Negative/Device/hipGetDeviceProperties.cpp rename to projects/hip/tests/src/Negative/Device/hipGetDeviceProperties.cpp diff --git a/projects/hip/tests/src/Functional/Negative/Device/hipSetDevice.cpp b/projects/hip/tests/src/Negative/Device/hipSetDevice.cpp similarity index 100% rename from projects/hip/tests/src/Functional/Negative/Device/hipSetDevice.cpp rename to projects/hip/tests/src/Negative/Device/hipSetDevice.cpp diff --git a/projects/hip/tests/src/hipPerfMemcpy.cpp b/projects/hip/tests/src/Performance/memory/hipPerfMemcpy.cpp similarity index 100% rename from projects/hip/tests/src/hipPerfMemcpy.cpp rename to projects/hip/tests/src/Performance/memory/hipPerfMemcpy.cpp diff --git a/projects/hip/tests/src/buildHIPC.sh b/projects/hip/tests/src/buildHIPC.sh deleted file mode 100755 index b2c9ce2a07..0000000000 --- a/projects/hip/tests/src/buildHIPC.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -$HCC_HOME/bin/hcc -I$HCC_HOME/include -I$HSA_PATH/include -I$HIP_PATH/include -std=c11 -c hipC.c diff --git a/projects/hip/tests/src/hipDrvGetPCIBusId.cpp b/projects/hip/tests/src/context/hipDrvGetPCIBusId.cpp similarity index 100% rename from projects/hip/tests/src/hipDrvGetPCIBusId.cpp rename to projects/hip/tests/src/context/hipDrvGetPCIBusId.cpp diff --git a/projects/hip/tests/src/hipDrvMemcpy.cpp b/projects/hip/tests/src/context/hipDrvMemcpy.cpp similarity index 100% rename from projects/hip/tests/src/hipDrvMemcpy.cpp rename to projects/hip/tests/src/context/hipDrvMemcpy.cpp diff --git a/projects/hip/tests/src/hipComplex.cpp b/projects/hip/tests/src/deviceLib/hipComplex.cpp similarity index 100% rename from projects/hip/tests/src/hipComplex.cpp rename to projects/hip/tests/src/deviceLib/hipComplex.cpp diff --git a/projects/hip/tests/src/hipDeviceMemcpy.cpp b/projects/hip/tests/src/deviceLib/hipDeviceMemcpy.cpp similarity index 100% rename from projects/hip/tests/src/hipDeviceMemcpy.cpp rename to projects/hip/tests/src/deviceLib/hipDeviceMemcpy.cpp diff --git a/projects/hip/tests/src/deviceLib/hipTestHalf.cpp b/projects/hip/tests/src/deviceLib/hipTestHalf.cpp index 12b7e2e270..7455037923 100644 --- a/projects/hip/tests/src/deviceLib/hipTestHalf.cpp +++ b/projects/hip/tests/src/deviceLib/hipTestHalf.cpp @@ -1,16 +1,13 @@ /* -Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. - +Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -20,113 +17,40 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* HIT_START - * BUILD: %t %s ../test_common.cpp - * RUN: %t - * HIT_END - */ - -#include "test_common.h" -#include "hip/hip_runtime.h" +#include +#include #include "hip/hip_runtime_api.h" -#include "hip/hip_fp16.h" -#define hInf 0x7C00 -#define hInfPK 0x7C007C00 -#define h65504 0xF7FF -#define h65504PK 0xF7FFF7FF -#define h27 0x4EC0 -#define h27PK 0x4EC04EC0 -#define h7 0x4700 -#define h7PK 0x47004700 -#define h3 0x4200 -#define h3PK 0x42004200 -#define h1 0x3C00 -#define h1PK 0x3C003C00 -#define hPoint5 0x3800 -#define hPoint5PK 0x38003800 -#define hZero 0x0000 -#define hNeg1 0xBC00 -#define hNeg1PK 0xBC00BC00 +#define DSIZE 4 +#define SCF 0.5f +#define nTPB 256 +__global__ void half_scale_kernel(hipLaunchParm lp, float *din, float *dout, int dsize){ -__global__ void CheckHalf(hipLaunchParm lp, __half* In1, __half* In2, __half* In3, __half* Out){ - Out[0] = __hadd(In1[0], In2[0]); - Out[1] = __hadd_sat(In1[1], In2[1]); - Out[2] = __hfma(In1[2], In2[2],In3[2]); - Out[3] = __hfma_sat(In1[3], In2[3], In3[3]); - Out[4] = __hmul(In1[4], In2[4]); - Out[5] = __hmul_sat(In1[5], In2[5]); - Out[6] = __hneg(In1[6]); - Out[7] = __hsub(In1[7], In2[7]); - Out[8] = __hsub_sat(In1[8], In2[8]); - Out[9] = hdiv(In1[9], In2[9]); - Out[10] = hceil(In1[10]); - Out[11] = hcos(In1[11]); - Out[12] = hexp(In1[12]); - Out[13] = hexp10(In1[13]); - Out[14] = hexp2(In1[14]); - Out[15] = hfloor(In1[15]); - Out[16] = hlog(In1[16]); - Out[17] = hlog10(In1[17]); - Out[18] = hlog2(In1[18]); -// Out[19] = hrcp(In1[19]); - Out[20] = hrint(In1[20]); - Out[21] = hrsqrt(In1[21]); - Out[22] = hsin(In1[22]); - Out[23] = hsqrt(In1[23]); - Out[24] = htrunc(In1[24]); -} + int idx = hipThreadIdx_x+ hipBlockDim_x*hipBlockIdx_x; + if (idx < dsize){ + __half scf = __float2half(SCF); + __half kin = __float2half(din[idx]); + __half kout; -__global__ void CheckHalf2(hipLaunchParm lp, __half2* In1, __half2* In2, __half2* In3, __half2* Out){ - Out[0] = __hadd2(In1[0], In2[0]); - Out[1] = __hadd2_sat(In1[1], In2[1]); - Out[2] = __hfma2(In1[2], In2[2],In3[2]); - Out[3] = __hfma2_sat(In1[3], In2[3], In3[3]); - Out[4] = __hmul2(In1[4], In2[4]); - Out[5] = __hmul2_sat(In1[5], In2[5]); - Out[6] = __hneg2(In1[6]); - Out[7] = __hsub2(In1[7], In2[7]); - Out[8] = __hsub2_sat(In1[8], In2[8]); - Out[9] = h2div(In1[9], In2[9]); - Out[10] = h2ceil(In1[10]); - Out[11] = h2cos(In1[11]); - Out[12] = h2exp(In1[12]); - Out[13] = h2exp10(In1[13]); - Out[14] = h2exp2(In1[14]); - Out[15] = h2floor(In1[15]); - Out[16] = h2log(In1[16]); - Out[17] = h2log10(In1[17]); - Out[18] = h2log2(In1[18]); - Out[19] = h2rcp(In1[19]); -// Out[20] = h2rint(In1[20]); - Out[21] = h2rsqrt(In1[21]); - Out[22] = h2sin(In1[22]); - Out[23] = h2sqrt(In1[23]); - Out[24] = h2trunc(In1[24]); -} + kout = __hmul(kin, scf); -__global__ void CheckCmpHalf(hipLaunchParm lp, __half* In1, __half* In2, bool* Out) { - Out[0] = __heq(In1[0], In2[0]); - Out[1] = __hge(In1[1], In2[1]); - Out[2] = __hgt(In1[2], In2[2]); - Out[3] = __hisinf(In1[3]); - Out[4] = __hisnan(In1[4]); - Out[5] = __hle(In1[5], In2[5]); - Out[6] = __hlt(In1[6], In2[6]); - Out[7] = __hne(In1[7], In2[7]); -} - -__global__ void CheckCmpHalf2(hipLaunchParm lp, __half2* In1, __half2* In2, __half2* Out) { - Out[0] = __heq2(In1[0], In2[0]); - Out[1] = __hge2(In1[1], In2[1]); - Out[2] = __hgt2(In1[2], In2[2]); - Out[4] = __hisnan2(In1[4]); - Out[5] = __hle2(In1[5], In2[5]); - Out[6] = __hlt2(In1[6], In2[6]); - Out[7] = __hne2(In1[7], In2[7]); +// kout = cvt_float_to_half(cvt_half_to_float(kin)*cvt_half_to_float(scf)); + dout[idx] = __half2float(kout); + } } int main(){ - passed(); + + float *hin, *hout, *din, *dout; + hin = (float *)malloc(DSIZE*sizeof(float)); + hout = (float *)malloc(DSIZE*sizeof(float)); + for (int i = 0; i < DSIZE; i++) hin[i] = i; + hipMalloc(&din, DSIZE*sizeof(float)); + hipMalloc(&dout, DSIZE*sizeof(float)); + hipMemcpy(din, hin, DSIZE*sizeof(float), hipMemcpyHostToDevice); + hipLaunchKernel(half_scale_kernel, dim3((DSIZE+nTPB-1)/nTPB),dim3(nTPB), 0, 0, din, dout, DSIZE); + hipMemcpy(hout, dout, DSIZE*sizeof(float), hipMemcpyDeviceToHost); + for (int i = 0; i < DSIZE; i++) printf("%f\n", hout[i]); + return 0; } diff --git a/projects/hip/tests/src/hipTestHost.cpp b/projects/hip/tests/src/deviceLib/hipTestHost.cpp similarity index 100% rename from projects/hip/tests/src/hipTestHost.cpp rename to projects/hip/tests/src/deviceLib/hipTestHost.cpp diff --git a/projects/hip/tests/src/hipC.c b/projects/hip/tests/src/hipC.c index 50177ac6c2..cdecc2cf9d 100644 --- a/projects/hip/tests/src/hipC.c +++ b/projects/hip/tests/src/hipC.c @@ -1,4 +1,33 @@ +/* +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +/* HIT_START + * BUILD: %t %s + * RUN: %t + * HIT_END + */ + #include "hip/hip_runtime.h" +#include "test_common.h" #include #define ITER 1<<20 @@ -22,4 +51,5 @@ int main(){ dimBlock.x = 1, dimBlock.y = 1, dimGrid.z = 1; hipLaunchKernel(HIP_KERNEL_NAME(Iter), dimGrid, dimBlock, 0, 0, Ad); hipMemcpy(&A, Ad, SIZE, hipMemcpyDeviceToHost); + passed(); } diff --git a/projects/hip/tests/src/hipC.cpp b/projects/hip/tests/src/hipC.cpp index 3380e8abd9..8abb877808 100644 --- a/projects/hip/tests/src/hipC.cpp +++ b/projects/hip/tests/src/hipC.cpp @@ -1,5 +1,29 @@ +/* +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + + #include "hip/hip_runtime.h" -#include +#include "test_common.h" +#include #define ITER 1<<20 #define SIZE 1024*1024*sizeof(int) @@ -19,4 +43,5 @@ int main(){ hipMemcpy(Ad, &A, SIZE, hipMemcpyHostToDevice); hipLaunchKernel(HIP_KERNEL_NAME(Iter), dim3(1), dim3(1), 0, 0, Ad); hipMemcpy(&A, Ad, SIZE, hipMemcpyDeviceToHost); + passed(); } diff --git a/projects/hip/tests/src/hipCKernel.c b/projects/hip/tests/src/hipCKernel.c index 19a034d843..7a72cf84ca 100644 --- a/projects/hip/tests/src/hipCKernel.c +++ b/projects/hip/tests/src/hipCKernel.c @@ -3,6 +3,7 @@ __global__ void Kernel(hipLaunchParm lp, float *Ad){ int tx = hipThreadIdx_x + hipBlockIdx_x * hipBlockDim_x; + Ad[tx] += Ad[tx-1]; } int main(){ diff --git a/projects/hip/tests/src/hipChooseDevice.cpp b/projects/hip/tests/src/hipChooseDevice.cpp deleted file mode 100644 index 4f289b9eb8..0000000000 --- a/projects/hip/tests/src/hipChooseDevice.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include "hip/hip_runtime.h" -int main( void ) { - hipDeviceProp_t prop; - int dev; - - hipGetDevice( &dev ) ; - printf( "ID of current HIP device: %d\n", dev ); - - memset( &prop, 0, sizeof( hipDeviceProp_t ) ); - prop.major = 1; - prop.minor = 3; - hipChooseDevice( &dev, &prop ); - printf( "ID of hip device closest to revision 1.3: %d\n", dev ); - - hipSetDevice( dev ); -} diff --git a/projects/hip/tests/src/hipPeerToPeer_simple.cpp b/projects/hip/tests/src/hipPeerToPeer_simple.cpp index 1dfbdafdfc..1ea594f4bb 100644 --- a/projects/hip/tests/src/hipPeerToPeer_simple.cpp +++ b/projects/hip/tests/src/hipPeerToPeer_simple.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -50,7 +50,7 @@ void help(char *argv[]) }; -static hipError_t myHipMemcpy(void *dest, const void *src, size_t sizeBytes, hipMemcpyKind kind, hipStream_t stream, bool async) +static hipError_t myHipMemcpy(void *dest, const void *src, size_t sizeBytes, hipMemcpyKind kind, hipStream_t stream, bool async) { if (async) { hipError_t e = hipMemcpyAsync(dest, src, sizeBytes, kind, stream); @@ -78,7 +78,7 @@ void parseMyArguments(int argc, char *argv[]) p_mirrorPeers = true; } else if (!strcmp(arg, "--peerDevice")) { if (++i >= argc || !HipTest::parseInt(argv[i], &p_peerDevice)) { - failed("Bad peerDevice argument"); + failed("Bad peerDevice argument"); } } else { failed("Bad argument '%s'", arg); @@ -101,7 +101,7 @@ void syncBothDevices() // Sets globals g_currentDevice, g_peerDevice -void setupPeerTests() +void setupPeerTests() { int deviceCnt; @@ -159,17 +159,17 @@ void enablePeerFirst(bool useAsyncCopy) // allocate and initialize memory on device0 HIPCHECK (hipSetDevice(g_currentDevice)); HIPCHECK (hipMalloc(&A_d0, Nbytes) ); - HIPCHECK (hipMemset(A_d0, memsetval, Nbytes) ); + HIPCHECK (hipMemset(A_d0, memsetval, Nbytes) ); // allocate and initialize memory on peer device HIPCHECK (hipSetDevice(g_peerDevice)); HIPCHECK (hipMalloc(&A_d1, Nbytes) ); - HIPCHECK (hipMemset(A_d1, 0x13, Nbytes) ); + HIPCHECK (hipMemset(A_d1, 0x13, Nbytes) ); // Device0 push to device1, using P2P: - // NOTE : if p_mirrorPeers=0 and p_memcpyWithPeer=1, then peer device does not have mapping for A_d1 and we need to use a + // NOTE : if p_mirrorPeers=0 and p_memcpyWithPeer=1, then peer device does not have mapping for A_d1 and we need to use a // a host staging copy for the P2P access. HIPCHECK (hipSetDevice(p_memcpyWithPeer ? g_peerDevice : g_currentDevice)); HIPCHECK (myHipMemcpy(A_d1, A_d0, Nbytes, hipMemcpyDefault, 0/*stream*/, useAsyncCopy)); // This is P2P copy. @@ -177,7 +177,7 @@ void enablePeerFirst(bool useAsyncCopy) // Copy data back to host: // Have to wait for previous operation to finish, since we are switching to another one: HIPCHECK(hipDeviceSynchronize()); - + HIPCHECK (hipSetDevice(g_peerDevice)); HIPCHECK (myHipMemcpy(A_h, A_d1, Nbytes, hipMemcpyDeviceToHost, 0/*stream*/, useAsyncCopy)); HIPCHECK(hipDeviceSynchronize()); @@ -215,12 +215,12 @@ void allocMemoryFirst(bool useAsyncCopy) // allocate and initialize memory on device0 HIPCHECK (hipSetDevice(g_currentDevice)); HIPCHECK (hipMalloc(&A_d0, Nbytes) ); - HIPCHECK ( hipMemset(A_d0, memsetval, Nbytes) ); + HIPCHECK ( hipMemset(A_d0, memsetval, Nbytes) ); // allocate and initialize memory on peer device HIPCHECK (hipSetDevice(g_peerDevice)); HIPCHECK (hipMalloc(&A_d1, Nbytes) ); - HIPCHECK ( hipMemset(A_d1, 0x13, Nbytes) ); + HIPCHECK ( hipMemset(A_d1, 0x13, Nbytes) ); //--- @@ -268,7 +268,7 @@ void allocMemoryFirst(bool useAsyncCopy) // Test which tests peer H2D copy - ie: copy-engine=1, dst=1, src=0 (Host) // A_d0 is pinned host on dev0 (this) // A_d1 is device memory on dev1 (peer) -// +// void testPeerHostToDevice(bool useAsyncCopy) { printf ("\n==testing: %s useAsyncCopy=%d\n", __func__, useAsyncCopy); @@ -299,12 +299,12 @@ void testPeerHostToDevice(bool useAsyncCopy) // allocate and initialize memory on device0 HIPCHECK (hipSetDevice(g_currentDevice)); HIPCHECK (hipHostMalloc(&A_host_d0, Nbytes) ); - HIPCHECK (hipMemset(A_host_d0, memsetval, Nbytes) ); + HIPCHECK (hipMemset(A_host_d0, memsetval, Nbytes) ); // allocate and initialize memory on peer device HIPCHECK (hipSetDevice(g_peerDevice)); HIPCHECK (hipMalloc(&A_d1, Nbytes) ); - HIPCHECK (hipMemset(A_d1, 0x13, Nbytes) ); + HIPCHECK (hipMemset(A_d1, 0x13, Nbytes) ); bool firstAsyncCopy = useAsyncCopy; /*TODO - should be useAsyncCopy*/ @@ -313,17 +313,17 @@ void testPeerHostToDevice(bool useAsyncCopy) // Device0 push to device1, using P2P: - // NOTE : if p_mirrorPeers=0 and p_memcpyWithPeer=1, then peer device does not have mapping for A_d1 and we need to use a + // NOTE : if p_mirrorPeers=0 and p_memcpyWithPeer=1, then peer device does not have mapping for A_d1 and we need to use a // a host staging copy for the P2P access. if (p_memcpyWithPeer) { // p_memcpyWithPeer=1 case is HostToDevice. - // if p_mirrorPeers = 1, this is accelerated copy over PCIe. + // if p_mirrorPeers = 1, this is accelerated copy over PCIe. // if p_mirrorPeers = 0, this should fall back to host (because peer can't see A_host_d0) HIPCHECK (hipSetDevice(g_peerDevice)); HIPCHECK (myHipMemcpy(A_d1, A_host_d0, Nbytes, hipMemcpyHostToDevice, 0/*stream*/, firstAsyncCopy)); // This is P2P copy. } else { // p_memcpyWithPeer=0 case is HostToDevice. - // if p_mirrorPeers = 1, this is accelerated copy over PCIe. + // if p_mirrorPeers = 1, this is accelerated copy over PCIe. // if p_mirrorPeers = 0, this should fall back to host (because device0 can't see A_d1) HIPCHECK (hipSetDevice(g_currentDevice)); HIPCHECK (myHipMemcpy(A_d1, A_host_d0, Nbytes, hipMemcpyHostToDevice, 0/*stream*/, firstAsyncCopy)); // This is P2P copy. @@ -367,7 +367,7 @@ void simpleNegative() HIPASSERT( e == hipSuccess); // no error returned, it doesn't hurt to ask. HIPASSERT (canAccessPeer == 0); // but self is not a peer. - e = hipSuccess; + e = hipSuccess; //--- // Enable same device twice in a row: HIPCHECK(hipSetDevice(g_currentDevice)); @@ -381,7 +381,7 @@ void simpleNegative() e =(hipDeviceDisablePeerAccess(g_peerDevice)); HIPASSERT (e == hipErrorPeerAccessNotEnabled); - + // More tests here: printf ("==done: %s\n\n", __func__); } diff --git a/projects/hip/tests/src/hipTestHalf.cpp b/projects/hip/tests/src/hipTestHalf.cpp deleted file mode 100644 index 7455037923..0000000000 --- a/projects/hip/tests/src/hipTestHalf.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#include -#include -#include "hip/hip_runtime_api.h" - -#define DSIZE 4 -#define SCF 0.5f -#define nTPB 256 -__global__ void half_scale_kernel(hipLaunchParm lp, float *din, float *dout, int dsize){ - - int idx = hipThreadIdx_x+ hipBlockDim_x*hipBlockIdx_x; - if (idx < dsize){ - __half scf = __float2half(SCF); - __half kin = __float2half(din[idx]); - __half kout; - - kout = __hmul(kin, scf); - -// kout = cvt_float_to_half(cvt_half_to_float(kin)*cvt_half_to_float(scf)); - - dout[idx] = __half2float(kout); - } -} - -int main(){ - - float *hin, *hout, *din, *dout; - hin = (float *)malloc(DSIZE*sizeof(float)); - hout = (float *)malloc(DSIZE*sizeof(float)); - for (int i = 0; i < DSIZE; i++) hin[i] = i; - hipMalloc(&din, DSIZE*sizeof(float)); - hipMalloc(&dout, DSIZE*sizeof(float)); - hipMemcpy(din, hin, DSIZE*sizeof(float), hipMemcpyHostToDevice); - hipLaunchKernel(half_scale_kernel, dim3((DSIZE+nTPB-1)/nTPB),dim3(nTPB), 0, 0, din, dout, DSIZE); - hipMemcpy(hout, dout, DSIZE*sizeof(float), hipMemcpyDeviceToHost); - for (int i = 0; i < DSIZE; i++) printf("%f\n", hout[i]); - return 0; -} diff --git a/projects/hip/tests/src/hipDynamicShared.cpp b/projects/hip/tests/src/kernel/hipDynamicShared.cpp similarity index 97% rename from projects/hip/tests/src/hipDynamicShared.cpp rename to projects/hip/tests/src/kernel/hipDynamicShared.cpp index d5aed7b24f..522572a191 100644 --- a/projects/hip/tests/src/hipDynamicShared.cpp +++ b/projects/hip/tests/src/kernel/hipDynamicShared.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -21,7 +21,7 @@ THE SOFTWARE. */ /* HIT_START - * BUILD: %t %s test_common.cpp + * BUILD: %t %s ../test_common.cpp * RUN: %t EXCLUDE_HIP_PLATFORM nvcc * HIT_END */ @@ -45,7 +45,7 @@ __global__ void testExternSharedKernel(hipLaunchParm lp, const T* A_d, const T* // initialize dynamic shared memory if (tid < groupElements) { - sdata[tid] = static_cast(tid); + sdata[tid] = static_cast(tid); } // prefix sum inside dynamic shared memory @@ -146,4 +146,3 @@ int main(int argc, char *argv[]) { passed(); } - diff --git a/projects/hip/tests/src/hipKernel.cpp b/projects/hip/tests/src/kernel/hipEmptyKernel.cpp similarity index 89% rename from projects/hip/tests/src/hipKernel.cpp rename to projects/hip/tests/src/kernel/hipEmptyKernel.cpp index bb6135ef5d..37245053be 100644 --- a/projects/hip/tests/src/hipKernel.cpp +++ b/projects/hip/tests/src/kernel/hipEmptyKernel.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights @@ -17,6 +17,12 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/* HIT_START + * BUILD: %t %s ../test_common.cpp + * RUN: %t + * HIT_END + */ + #include"test_common.h" __global__ void Empty(hipLaunchParm lp, int param){} @@ -24,4 +30,5 @@ __global__ void Empty(hipLaunchParm lp, int param){} int main(){ hipLaunchKernel(HIP_KERNEL_NAME(Empty), dim3(1), dim3(1), 0, 0, 0); hipDeviceSynchronize(); +passed(); } diff --git a/projects/hip/tests/src/kernel/hipGridLaunch.cpp b/projects/hip/tests/src/kernel/hipGridLaunch.cpp index 99c6a29557..6cd724a070 100644 --- a/projects/hip/tests/src/kernel/hipGridLaunch.cpp +++ b/projects/hip/tests/src/kernel/hipGridLaunch.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -33,7 +33,7 @@ THE SOFTWARE. // __device__ maps to __attribute__((hc)) -__device__ int foo(int i) +__device__ int foo(int i) { return i+1; } @@ -96,4 +96,3 @@ int main(int argc, char *argv[]) passed(); } - diff --git a/projects/hip/tests/src/kernel/hipLanguageExtensions.cpp b/projects/hip/tests/src/kernel/hipLanguageExtensions.cpp index cc170f9c8a..e519a1c2a8 100644 --- a/projects/hip/tests/src/kernel/hipLanguageExtensions.cpp +++ b/projects/hip/tests/src/kernel/hipLanguageExtensions.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -42,7 +42,7 @@ __device__ int deviceVar; // TODO-HCC __constant__ not working yet. __constant__ int constantVar1; -__constant__ __device__ int constantVar2; +__constant__ __device__ int constantVar2; // Test HOST space: __host__ void foo() { @@ -53,7 +53,7 @@ __device__ __noinline__ int sum1_noinline(int a) { return a+1;}; __device__ __forceinline__ int sum1_forceinline(int a) { return a+1;}; -__device__ __host__ float PlusOne(float x) +__device__ __host__ float PlusOne(float x) { return x + 1.0; } diff --git a/projects/hip/tests/src/hipLaunchParm.cpp b/projects/hip/tests/src/kernel/hipLaunchParm.cpp similarity index 96% rename from projects/hip/tests/src/hipLaunchParm.cpp rename to projects/hip/tests/src/kernel/hipLaunchParm.cpp index 5ffb557662..4dfd8a42ed 100644 --- a/projects/hip/tests/src/hipLaunchParm.cpp +++ b/projects/hip/tests/src/kernel/hipLaunchParm.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights @@ -18,7 +18,7 @@ THE SOFTWARE. */ /* HIT_START - * BUILD: %t %s test_common.cpp + * BUILD: %t %s ../test_common.cpp * RUN: %t * HIT_END */ diff --git a/projects/hip/tests/src/kernel/hipTestConstant.cpp b/projects/hip/tests/src/kernel/hipTestConstant.cpp index f86e8ace4f..2d637e3f1a 100644 --- a/projects/hip/tests/src/kernel/hipTestConstant.cpp +++ b/projects/hip/tests/src/kernel/hipTestConstant.cpp @@ -17,6 +17,12 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/* HIT_START + * BUILD: %t %s ../test_common.cpp + * RUN: %t + * HIT_END + */ + #include #include #include diff --git a/projects/hip/tests/src/kernel/hipTestMallocKernel.cpp b/projects/hip/tests/src/kernel/hipTestMallocKernel.cpp index 826f6164c3..bd0c17d898 100644 --- a/projects/hip/tests/src/kernel/hipTestMallocKernel.cpp +++ b/projects/hip/tests/src/kernel/hipTestMallocKernel.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights @@ -17,6 +17,12 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/* HIT_START + * BUILD: %t %s ../test_common.cpp + * RUN: %t + * HIT_END + */ + #include #include #include diff --git a/projects/hip/tests/src/kernel/hipTestMemKernel.cpp b/projects/hip/tests/src/kernel/hipTestMemKernel.cpp index bf97fc1dc8..9298e20e1b 100644 --- a/projects/hip/tests/src/kernel/hipTestMemKernel.cpp +++ b/projects/hip/tests/src/kernel/hipTestMemKernel.cpp @@ -1,6 +1,32 @@ +/* +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +/* HIT_START + * BUILD: %t %s ../test_common.cpp + * RUN: %t + * HIT_END + */ + #include #include #include +#include"test_common.h" #define LEN8 8 * 4 #define LEN9 9 * 4 @@ -184,4 +210,6 @@ int main(){ delete A; delete B; delete C; + + passed(); } diff --git a/projects/hip/tests/src/kernel/launch_bounds.cpp b/projects/hip/tests/src/kernel/launch_bounds.cpp index 2e10a9204a..3b1476fb11 100644 --- a/projects/hip/tests/src/kernel/launch_bounds.cpp +++ b/projects/hip/tests/src/kernel/launch_bounds.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,12 +20,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* HIT_START - * BUILD: %t %s ../test_common.cpp - * RUN: %t - * HIT_END - */ - // Test launch bounds and initialization conditions. #include "hip/hip_runtime.h" @@ -34,7 +28,7 @@ THE SOFTWARE. int p_blockSize = 256; -__global__ +__global__ void __launch_bounds__(256, 2) myKern(hipLaunchParm lp, int *C, const int *A, int N, int xfactor) diff --git a/projects/hip/tests/src/runtimeApi/device/hipChooseDevice.cpp b/projects/hip/tests/src/runtimeApi/device/hipChooseDevice.cpp new file mode 100644 index 0000000000..4ddffe8aad --- /dev/null +++ b/projects/hip/tests/src/runtimeApi/device/hipChooseDevice.cpp @@ -0,0 +1,49 @@ +/* +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +/* HIT_START + * BUILD: %t %s ../../test_common.cpp + * RUN: %t + * HIT_END + */ + +#include +#include "hip/hip_runtime.h" +#include "test_common.h" + +int main( void ) { + hipDeviceProp_t prop; + int dev; + + hipGetDevice( &dev ) ; + printf( "ID of current HIP device: %d\n", dev ); + + memset( &prop, 0, sizeof( hipDeviceProp_t ) ); + prop.major = 1; + prop.minor = 3; + hipChooseDevice( &dev, &prop ); + printf( "ID of hip device closest to revision 1.3: %d\n", dev ); + + hipSetDevice( dev ); + + passed(); +} diff --git a/projects/hip/tests/src/hipGetDeviceAttribute.cpp b/projects/hip/tests/src/runtimeApi/device/hipGetDeviceAttribute.cpp similarity index 99% rename from projects/hip/tests/src/hipGetDeviceAttribute.cpp rename to projects/hip/tests/src/runtimeApi/device/hipGetDeviceAttribute.cpp index a67296476f..8e55e2f699 100644 --- a/projects/hip/tests/src/hipGetDeviceAttribute.cpp +++ b/projects/hip/tests/src/runtimeApi/device/hipGetDeviceAttribute.cpp @@ -22,7 +22,7 @@ THE SOFTWARE. // Test the device info API extensions for HIP: /* HIT_START - * BUILD: %t %s test_common.cpp + * BUILD: %t %s ../../test_common.cpp * RUN: %t EXCLUDE_HIP_PLATFORM nvcc * HIT_END */ @@ -89,4 +89,3 @@ int main(int argc, char *argv[]) passed(); }; - diff --git a/projects/hip/tests/src/hipEventRecord.cpp b/projects/hip/tests/src/runtimeApi/event/hipEventRecord.cpp similarity index 96% rename from projects/hip/tests/src/hipEventRecord.cpp rename to projects/hip/tests/src/runtimeApi/event/hipEventRecord.cpp index f8ef36b0bb..5606b4ab9b 100644 --- a/projects/hip/tests/src/hipEventRecord.cpp +++ b/projects/hip/tests/src/runtimeApi/event/hipEventRecord.cpp @@ -20,11 +20,11 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ // Test hipEventRecord serialization behavior. -// Through manual inspection of the reported timestamps, can determine if recording a NULL event forces synchronization : -// set +// Through manual inspection of the reported timestamps, can determine if recording a NULL event forces synchronization : +// set /* HIT_START - * BUILD: %t %s test_common.cpp + * BUILD: %t %s ../../test_common.cpp * RUN: %t --iterations 10 * HIT_END */ @@ -39,7 +39,7 @@ int main(int argc, char *argv[]) unsigned blocks = (N+threadsPerBlock-1)/threadsPerBlock; if (blocks > 1024) blocks = 1024; - if (blocks ==0 ) + if (blocks ==0 ) blocks = 1; printf ("N=%zu (A+B+C= %6.1f MB total) blocks=%u threadsPerBlock=%u iterations=%d\n", N, ((double)3*N*sizeof(float))/1024/1024, blocks, threadsPerBlock, iterations); @@ -81,7 +81,7 @@ int main(int argc, char *argv[]) float eventMs = 1.0f; HIPCHECK (hipEventElapsedTime(&eventMs, start, stop)); float hostMs = HipTest::elapsed_time(hostStart, hostStop); - + printf ("host_time (gettimeofday) =%6.3fms\n", hostMs); printf ("kernel_time (hipEventElapsedTime) =%6.3fms\n", eventMs); printf ("\n"); diff --git a/projects/hip/tests/src/hipArray.cpp b/projects/hip/tests/src/runtimeApi/memory/hipArray.cpp similarity index 87% rename from projects/hip/tests/src/hipArray.cpp rename to projects/hip/tests/src/runtimeApi/memory/hipArray.cpp index 9f9875a8d2..8f831bf5e0 100644 --- a/projects/hip/tests/src/hipArray.cpp +++ b/projects/hip/tests/src/runtimeApi/memory/hipArray.cpp @@ -1,5 +1,27 @@ +/* +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + /* HIT_START - * BUILD: %t %s test_common.cpp EXCLUDE_HIP_PLATFORM nvcc + * BUILD: %t %s ../../test_common.cpp EXCLUDE_HIP_PLATFORM nvcc * RUN: %t EXCLUDE_HIP_PLATFORM * HIT_END */ @@ -170,7 +192,7 @@ void memcpyArraytest_size(size_t maxElem=0, size_t offset=0) maxElem = free/sizeof(T)/5; } - printf (" device#%d: hipMemGetInfo: free=%zu (%4.2fMB) total=%zu (%4.2fMB) maxSize=%6.1fMB offset=%lu\n", + printf (" device#%d: hipMemGetInfo: free=%zu (%4.2fMB) total=%zu (%4.2fMB) maxSize=%6.1fMB offset=%lu\n", deviceId, free, (float)(free/1024.0/1024.0), total, (float)(total/1024.0/1024.0), maxElem*sizeof(T)/1024.0/1024.0, offset); // Test 1D diff --git a/projects/hip/tests/src/hipHostGetFlags.cpp b/projects/hip/tests/src/runtimeApi/memory/hipHostGetFlags.cpp similarity index 98% rename from projects/hip/tests/src/hipHostGetFlags.cpp rename to projects/hip/tests/src/runtimeApi/memory/hipHostGetFlags.cpp index a58ba7aa43..a989b879ac 100644 --- a/projects/hip/tests/src/hipHostGetFlags.cpp +++ b/projects/hip/tests/src/runtimeApi/memory/hipHostGetFlags.cpp @@ -21,7 +21,7 @@ THE SOFTWARE. */ /* HIT_START - * BUILD: %t %s test_common.cpp + * BUILD: %t %s ../../test_common.cpp * RUN: %t * HIT_END */ diff --git a/projects/hip/tests/src/hipHostMalloc.cpp b/projects/hip/tests/src/runtimeApi/memory/hipHostMalloc.cpp similarity index 98% rename from projects/hip/tests/src/hipHostMalloc.cpp rename to projects/hip/tests/src/runtimeApi/memory/hipHostMalloc.cpp index d1950f825f..d6b3b05a1d 100644 --- a/projects/hip/tests/src/hipHostMalloc.cpp +++ b/projects/hip/tests/src/runtimeApi/memory/hipHostMalloc.cpp @@ -21,7 +21,7 @@ */ /* HIT_START - * BUILD: %t %s test_common.cpp + * BUILD: %t %s ../../test_common.cpp * RUN: %t * HIT_END */ diff --git a/projects/hip/tests/src/hipHostRegister.cpp b/projects/hip/tests/src/runtimeApi/memory/hipHostRegister.cpp similarity index 98% rename from projects/hip/tests/src/hipHostRegister.cpp rename to projects/hip/tests/src/runtimeApi/memory/hipHostRegister.cpp index e9044d5a86..37ee9b1b78 100644 --- a/projects/hip/tests/src/hipHostRegister.cpp +++ b/projects/hip/tests/src/runtimeApi/memory/hipHostRegister.cpp @@ -18,7 +18,7 @@ THE SOFTWARE. */ /* HIT_START - * BUILD: %t %s test_common.cpp + * BUILD: %t %s ../../test_common.cpp * RUN: %t * HIT_END */ diff --git a/projects/hip/tests/src/runtimeApi/memory/hipMemcpyAsync2.cpp b/projects/hip/tests/src/runtimeApi/memory/hipMemcpyAsync2.cpp index 4d7af21c72..7f19db559d 100644 --- a/projects/hip/tests/src/runtimeApi/memory/hipMemcpyAsync2.cpp +++ b/projects/hip/tests/src/runtimeApi/memory/hipMemcpyAsync2.cpp @@ -1,3 +1,27 @@ +/* +Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +/* HIT_START + * BUILD: %t %s ../../test_common.cpp + * HIT_END + */ + #include"test_common.h" #define SIZE 1024*1024 diff --git a/projects/hip/tests/src/hipRandomMemcpyAsync.cpp b/projects/hip/tests/src/runtimeApi/memory/hipRandomMemcpyAsync.cpp similarity index 98% rename from projects/hip/tests/src/hipRandomMemcpyAsync.cpp rename to projects/hip/tests/src/runtimeApi/memory/hipRandomMemcpyAsync.cpp index 8a5067ac8d..9a5636c24b 100644 --- a/projects/hip/tests/src/hipRandomMemcpyAsync.cpp +++ b/projects/hip/tests/src/runtimeApi/memory/hipRandomMemcpyAsync.cpp @@ -18,7 +18,7 @@ THE SOFTWARE. */ /* HIT_START - * BUILD: %t %s test_common.cpp + * BUILD: %t %s ../../test_common.cpp * RUN: %t * HIT_END */ diff --git a/projects/hip/tests/src/hipTestMemcpyPin.cpp b/projects/hip/tests/src/runtimeApi/memory/hipTestMemcpyPin.cpp similarity index 97% rename from projects/hip/tests/src/hipTestMemcpyPin.cpp rename to projects/hip/tests/src/runtimeApi/memory/hipTestMemcpyPin.cpp index 3ac4e09765..c6634ebbbb 100644 --- a/projects/hip/tests/src/hipTestMemcpyPin.cpp +++ b/projects/hip/tests/src/runtimeApi/memory/hipTestMemcpyPin.cpp @@ -18,7 +18,7 @@ THE SOFTWARE. */ /* HIT_START - * BUILD: %t %s test_common.cpp + * BUILD: %t %s ../../test_common.cpp * RUN: %t * HIT_END */ diff --git a/projects/hip/tests/src/hipModule.cpp b/projects/hip/tests/src/runtimeApi/module/hipModule.cpp similarity index 100% rename from projects/hip/tests/src/hipModule.cpp rename to projects/hip/tests/src/runtimeApi/module/hipModule.cpp diff --git a/projects/hip/tests/src/hipModuleUnload.cpp b/projects/hip/tests/src/runtimeApi/module/hipModuleUnload.cpp similarity index 100% rename from projects/hip/tests/src/hipModuleUnload.cpp rename to projects/hip/tests/src/runtimeApi/module/hipModuleUnload.cpp diff --git a/projects/hip/tests/src/sampleModule.cpp b/projects/hip/tests/src/sampleModule.cpp deleted file mode 100644 index 7ee9147e45..0000000000 --- a/projects/hip/tests/src/sampleModule.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANNTY OF ANY KIND, EXPRESS OR -IMPLIED, INNCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANNY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER INN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#include "hip/hip_runtime.h" -#include "hip/hip_runtime_api.h" -#include -#include -#include - -#define LEN 64 -#define SIZE LEN<<2 - -#ifdef __HIP_PLATFORM_HCC__ -#define fileName "vcpy_isa.co" -#endif - -#ifdef __HIP_PLATFORM_NVCC__ -#define fileName "vcpy_isa.ptx" -#endif - -#define kernel_name "hello_world" - -int main(){ - float *A, *B; - hipDeviceptr_t Ad, Bd; - A = new float[LEN]; - B = new float[LEN]; - - for(uint32_t i=0;iargBuffer(2); - memcpy(&argBuffer[0], &Ad, sizeof(void*)); - memcpy(&argBuffer[1], &Bd, sizeof(void*)); - - size_t size = argBuffer.size()*sizeof(void*); - - void *config[] = { - HIP_LAUNCH_PARAM_BUFFER_POINTER, &argBuffer[0], - HIP_LAUNCH_PARAM_BUFFER_SIZE, &size, - HIP_LAUNCH_PARAM_END - }; - - hipModuleLaunchKernel(Function, 1, 1, 1, LEN, 1, 1, 0, 0, NULL, (void**)&config); - - hipMemcpyDtoH(B, Bd, SIZE); - for(uint32_t i=0;ig>F%yYE55 zFR+Z2LV0lu%{!G%XF?)RhVeIfnBT*1N!!dXbRFkp)4`B#*z|z&%=euCq(b_=EKEDT zz>CaF9(*_bPPfzVj~XvW<9<8ER8a<$0cAiLPzIC%Wk4BF29yD1KpFV&89@E#kyNgQ z83p0=6sxpK`wY#|xhV(AaRC=>g`WC@AUMsEHtqK`6rYL*($72cuM)levddNRE)@@i zjUC$m#HSQDJioZ@m5ODe`XSfMfzMdMr)|$GmN!hy#-VSD{Wl!1O&L%IlmTTx8Bhk4 z0cAiLPzIC%Wk4DD_ZUE7{@EP_%)238a?;$jv%Vyk#oSQ!FIqFb!~cPU1cyUNSuC}* zxU1{6^v+rEEBx?@gTVv-qX2j3z&QSP{jua8(>dpwarivSkc~`}j9K^I6t%a8ldSAXse6%TqXiiV@4Ly;XoG~OI0y+Nlj=p=DFPU6(j8V#TIo*$VL>*el~ z_$ft`?j#vo%}UB%t~Y8=?pN3E-pma81ggwe*3K;xVLc(QyS{~6i3QhK=Q+k?t&xxQ zghZU=N;AhD8F`*{=^OdjFOb+T9AX;!fqjt`!LT3kzXBxwTR?n%ODwxw8G~uzv}`&P ze#{@|R@c~Haxq!a46Rkmf~;fyfLB?`&q;jmLwQ?ntY+W&*foapm_&XE<^5~R$3Eha zJSJIxn&0ABtexbceGIL3#{mm0nzB6eyp2}&B`CF*u)FJ G$^Qui; - .reg .b32 %r<2>; - .reg .b64 %rd<8>; - - - ld.param.u64 %rd1, [hello_world_param_0]; - ld.param.u64 %rd2, [hello_world_param_1]; - cvta.to.global.u64 %rd3, %rd2; - cvta.to.global.u64 %rd4, %rd1; - mov.u32 %r1, %tid.x; - mul.wide.s32 %rd5, %r1, 4; - add.s64 %rd6, %rd4, %rd5; - ld.global.f32 %f1, [%rd6]; - add.s64 %rd7, %rd3, %rd5; - st.global.f32 [%rd7], %f1; - ret; -} - - From 82e6141cfd711d44a53c8a6b076b0b65159cae7f Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Mon, 6 Feb 2017 13:00:50 +0530 Subject: [PATCH 116/281] Disable broken test: hipC Change-Id: I061aa125bbdc9f14bc870266ab0735593c861903 [ROCm/hip commit: 939909e96cdd1f852c228c784e23335c789d77d2] --- projects/hip/tests/src/hipC.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/hip/tests/src/hipC.c b/projects/hip/tests/src/hipC.c index cdecc2cf9d..644df6c98f 100644 --- a/projects/hip/tests/src/hipC.c +++ b/projects/hip/tests/src/hipC.c @@ -21,7 +21,7 @@ THE SOFTWARE. */ /* HIT_START - * BUILD: %t %s + * BUILD: %t %s EXCLUDE_HIP_PLATFORM all * RUN: %t * HIT_END */ From 3d04971de32fad25a1f383c80cb6726b0578ec4a Mon Sep 17 00:00:00 2001 From: Rahul Garg Date: Tue, 7 Feb 2017 15:03:46 +0530 Subject: [PATCH 117/281] Command scripts for latency measurements Change-Id: I8c28765a09fb0358447367939de524b12699a317 [ROCm/hip commit: 55df1b6ff2e4c2fa81ccab3fd14ee6437f341b5d] --- .../hipCommander/perf/scripts/latency_2_d2h_h2d.hcm | 9 +++++++++ .../hipCommander/perf/scripts/latency_2_d2h_kernel.hcm | 9 +++++++++ .../perf/scripts/latency_2_d2h_sync_h2d.hcm | 9 +++++++++ .../perf/scripts/latency_2_d2h_sync_kernel.hcm | 9 +++++++++ .../hipCommander/perf/scripts/latency_2_h2d_d2h.hcm | 9 +++++++++ .../hipCommander/perf/scripts/latency_2_h2d_kernel.hcm | 9 +++++++++ .../perf/scripts/latency_2_h2d_sync_d2h.hcm | 9 +++++++++ .../perf/scripts/latency_2_h2d_sync_kernel.hcm | 9 +++++++++ .../hipCommander/perf/scripts/latency_2_kernel_d2h.hcm | 9 +++++++++ .../hipCommander/perf/scripts/latency_2_kernel_h2d.hcm | 9 +++++++++ .../perf/scripts/latency_2_kernel_sync_d2h.hcm | 9 +++++++++ .../perf/scripts/latency_2_kernel_sync_h2d.hcm | 9 +++++++++ .../hipCommander/perf/scripts/latency_2_sync.hcm | 9 +++++++++ .../1_Utils/hipCommander/perf/scripts/latency_2d2h.hcm | 10 ++++++++++ .../hipCommander/perf/scripts/latency_2d2h_wosync.hcm | 10 ++++++++++ .../1_Utils/hipCommander/perf/scripts/latency_2h2d.hcm | 10 ++++++++++ .../hipCommander/perf/scripts/latency_2h2d_kernel.hcm | 9 +++++++++ .../perf/scripts/latency_2h2d_kernel_wosync.hcm | 9 +++++++++ .../hipCommander/perf/scripts/latency_2h2d_wosync.hcm | 10 ++++++++++ .../hipCommander/perf/scripts/latency_2kernels.hcm | 10 ++++++++++ .../perf/scripts/latency_2kernels_wosync.hcm | 10 ++++++++++ .../hipCommander/perf/scripts/latency_3_d2h_h2d.hcm | 9 +++++++++ .../hipCommander/perf/scripts/latency_3_d2h_kernel.hcm | 9 +++++++++ .../perf/scripts/latency_3_d2h_sync_h2d.hcm | 9 +++++++++ .../perf/scripts/latency_3_d2h_sync_kernel.hcm | 9 +++++++++ .../hipCommander/perf/scripts/latency_3_h2d_d2h.hcm | 10 ++++++++++ .../hipCommander/perf/scripts/latency_3_h2d_kernel.hcm | 9 +++++++++ .../perf/scripts/latency_3_h2d_sync_d2h.hcm | 9 +++++++++ .../perf/scripts/latency_3_h2d_sync_kernel.hcm | 9 +++++++++ .../hipCommander/perf/scripts/latency_3_kernel_d2h.hcm | 9 +++++++++ .../hipCommander/perf/scripts/latency_3_kernel_h2d.hcm | 9 +++++++++ .../perf/scripts/latency_3_kernel_sync_d2h.hcm | 9 +++++++++ .../perf/scripts/latency_3_kernel_sync_h2d.hcm | 9 +++++++++ .../hipCommander/perf/scripts/latency_3_sync.hcm | 9 +++++++++ .../1_Utils/hipCommander/perf/scripts/latency_3d2h.hcm | 9 +++++++++ .../hipCommander/perf/scripts/latency_3d2h_wosync.hcm | 9 +++++++++ .../1_Utils/hipCommander/perf/scripts/latency_3h2d.hcm | 10 ++++++++++ .../hipCommander/perf/scripts/latency_3h2d_wosync.hcm | 10 ++++++++++ .../hipCommander/perf/scripts/latency_3kernels.hcm | 10 ++++++++++ .../perf/scripts/latency_3kernels_wosync.hcm | 10 ++++++++++ .../hipCommander/perf/scripts/latency_4kernels.hcm | 10 ++++++++++ .../hipCommander/perf/scripts/latency_5kernels.hcm | 10 ++++++++++ .../hipCommander/perf/scripts/latency_6kernels.hcm | 10 ++++++++++ .../1_Utils/hipCommander/perf/scripts/latency_d2h.hcm | 9 +++++++++ .../hipCommander/perf/scripts/latency_d2h_h2d.hcm | 9 +++++++++ .../hipCommander/perf/scripts/latency_d2h_kernel.hcm | 9 +++++++++ .../hipCommander/perf/scripts/latency_d2h_sync_h2d.hcm | 9 +++++++++ .../perf/scripts/latency_d2h_sync_kernel.hcm | 9 +++++++++ .../1_Utils/hipCommander/perf/scripts/latency_h2d.hcm | 10 ++++++++++ .../hipCommander/perf/scripts/latency_h2d_10.hcm | 2 ++ .../hipCommander/perf/scripts/latency_h2d_d2h.hcm | 9 +++++++++ .../hipCommander/perf/scripts/latency_h2d_kernel.hcm | 9 +++++++++ .../perf/scripts/latency_h2d_kernel_d2h.hcm | 9 +++++++++ .../perf/scripts/latency_h2d_kernel_d2h_wosync.hcm | 9 +++++++++ .../perf/scripts/latency_h2d_kernel_wosync.hcm | 9 +++++++++ .../hipCommander/perf/scripts/latency_h2d_sync_d2h.hcm | 9 +++++++++ .../perf/scripts/latency_h2d_sync_kernel_sync.hcm | 9 +++++++++ .../perf/scripts/latency_h2d_sync_kernel_sync_d2h.hcm | 9 +++++++++ .../hipCommander/perf/scripts/latency_kernel.hcm | 10 ++++++++++ .../perf/scripts/latency_kernel_barrier.hcm | 9 +++++++++ .../hipCommander/perf/scripts/latency_kernel_d2h.hcm | 9 +++++++++ .../hipCommander/perf/scripts/latency_kernel_h2d.hcm | 9 +++++++++ .../perf/scripts/latency_kernel_sync_d2h.hcm | 9 +++++++++ .../perf/scripts/latency_kernel_sync_h2d.hcm | 9 +++++++++ .../hipCommander/perf/scripts/latency_streamcreate.hcm | 2 ++ .../1_Utils/hipCommander/perf/scripts/latency_sync.hcm | 9 +++++++++ 66 files changed, 596 insertions(+) create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_d2h_h2d.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_d2h_kernel.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_d2h_sync_h2d.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_d2h_sync_kernel.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_h2d_d2h.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_h2d_kernel.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_h2d_sync_d2h.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_h2d_sync_kernel.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_kernel_d2h.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_kernel_h2d.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_kernel_sync_d2h.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_kernel_sync_h2d.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_sync.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2d2h.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2d2h_wosync.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2h2d.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2h2d_kernel.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2h2d_kernel_wosync.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2h2d_wosync.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2kernels.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2kernels_wosync.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_d2h_h2d.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_d2h_kernel.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_d2h_sync_h2d.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_d2h_sync_kernel.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_h2d_d2h.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_h2d_kernel.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_h2d_sync_d2h.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_h2d_sync_kernel.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_kernel_d2h.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_kernel_h2d.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_kernel_sync_d2h.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_kernel_sync_h2d.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_sync.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3d2h.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3d2h_wosync.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3h2d.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3h2d_wosync.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3kernels.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3kernels_wosync.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_4kernels.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_5kernels.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_6kernels.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_d2h.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_d2h_h2d.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_d2h_kernel.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_d2h_sync_h2d.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_d2h_sync_kernel.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_10.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_d2h.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_kernel.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_kernel_d2h.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_kernel_d2h_wosync.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_kernel_wosync.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_sync_d2h.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_sync_kernel_sync.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_sync_kernel_sync_d2h.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_kernel.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_kernel_barrier.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_kernel_d2h.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_kernel_h2d.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_kernel_sync_d2h.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_kernel_sync_h2d.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_streamcreate.hcm create mode 100644 projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_sync.hcm diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_d2h_h2d.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_d2h_h2d.hcm new file mode 100644 index 0000000000..640bb2be79 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_d2h_h2d.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); D2H; H2D; streamsync;D2H; H2D; streamsync; endloop(1); +loop(10); D2H; H2D; streamsync;D2H; H2D; streamsync; endloop(1); +loop(100); D2H; H2D; streamsync;D2H; H2D; streamsync; endloop(1); +loop(100); D2H; H2D; streamsync;D2H; H2D; streamsync; endloop(1); +loop(1000); D2H; H2D; streamsync;D2H; H2D; streamsync; endloop(1); +loop(1000); D2H; H2D; streamsync;D2H; H2D; streamsync; endloop(1); +loop(10000); D2H; H2D; streamsync;D2H; H2D; streamsync; endloop(1); +loop(10000); D2H; H2D; streamsync;D2H; H2D; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_d2h_kernel.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_d2h_kernel.hcm new file mode 100644 index 0000000000..c1bc0f6702 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_d2h_kernel.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); D2H; NullKernel; streamsync;D2H; NullKernel; streamsync; endloop(1); +loop(10); D2H; NullKernel; streamsync;D2H; NullKernel; streamsync; endloop(1); +loop(100); D2H; NullKernel; streamsync;D2H; NullKernel; streamsync; endloop(1); +loop(100); D2H; NullKernel; streamsync;D2H; NullKernel; streamsync; endloop(1); +loop(1000); D2H; NullKernel; streamsync;D2H; NullKernel; streamsync; endloop(1); +loop(1000); D2H; NullKernel; streamsync;D2H; NullKernel; streamsync; endloop(1); +loop(10000); D2H; NullKernel; streamsync;D2H; NullKernel; streamsync; endloop(1); +loop(10000); D2H; NullKernel; streamsync;D2H; NullKernel; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_d2h_sync_h2d.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_d2h_sync_h2d.hcm new file mode 100644 index 0000000000..0e787f9bd0 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_d2h_sync_h2d.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); D2H; streamsync; H2D; streamsync;D2H; streamsync; H2D; streamsync; endloop(1); +loop(10); D2H; streamsync; H2D; streamsync;D2H; streamsync; H2D; streamsync; endloop(1); +loop(100); D2H; streamsync; H2D; streamsync;D2H; streamsync; H2D; streamsync; endloop(1); +loop(100); D2H; streamsync; H2D; streamsync;D2H; streamsync; H2D; streamsync; endloop(1); +loop(1000); D2H; streamsync; H2D; streamsync;D2H; streamsync; H2D; streamsync; endloop(1); +loop(1000); D2H; streamsync; H2D; streamsync;D2H; streamsync; H2D; streamsync; endloop(1); +loop(10000); D2H; streamsync; H2D; streamsync;D2H; streamsync; H2D; streamsync; endloop(1); +loop(10000); D2H; streamsync; H2D; streamsync;D2H; streamsync; H2D; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_d2h_sync_kernel.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_d2h_sync_kernel.hcm new file mode 100644 index 0000000000..8d7fddc146 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_d2h_sync_kernel.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); D2H; streamsync; NullKernel; streamsync;D2H; streamsync; NullKernel; streamsync; endloop(1); +loop(10); D2H; streamsync; NullKernel; streamsync;D2H; streamsync; NullKernel; streamsync; endloop(1); +loop(100); D2H; streamsync; NullKernel; streamsync;D2H; streamsync; NullKernel; streamsync; endloop(1); +loop(100); D2H; streamsync; NullKernel; streamsync;D2H; streamsync; NullKernel; streamsync; endloop(1); +loop(1000); D2H; streamsync; NullKernel; streamsync;D2H; streamsync; NullKernel; streamsync; endloop(1); +loop(1000); D2H; streamsync; NullKernel; streamsync;D2H; streamsync; NullKernel; streamsync; endloop(1); +loop(10000); D2H; streamsync; NullKernel; streamsync;D2H; streamsync; NullKernel; streamsync; endloop(1); +loop(10000); D2H; streamsync; NullKernel; streamsync;D2H; streamsync; NullKernel; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_h2d_d2h.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_h2d_d2h.hcm new file mode 100644 index 0000000000..7d845d03a4 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_h2d_d2h.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); H2D; D2H; streamsync;H2D; D2H; streamsync; endloop(1); +loop(10); H2D; D2H; streamsync;H2D; D2H; streamsync; endloop(1); +loop(100); H2D; D2H; streamsync;H2D; D2H; streamsync; endloop(1); +loop(100); H2D; D2H; streamsync;H2D; D2H; streamsync; endloop(1); +loop(1000); H2D; D2H; streamsync;H2D; D2H; streamsync; endloop(1); +loop(1000); H2D; D2H; streamsync;H2D; D2H; streamsync; endloop(1); +loop(10000); H2D; D2H; streamsync;H2D; D2H; streamsync; endloop(1); +loop(10000); H2D; D2H; streamsync;H2D; D2H; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_h2d_kernel.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_h2d_kernel.hcm new file mode 100644 index 0000000000..49c0d77146 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_h2d_kernel.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); H2D; NullKernel; streamsync;H2D; NullKernel; streamsync; endloop(1); +loop(10); H2D; NullKernel; streamsync; H2D; NullKernel; streamsync;endloop(1); +loop(100); H2D; NullKernel; streamsync; H2D; NullKernel; streamsync;endloop(1); +loop(100); H2D; NullKernel; streamsync; H2D; NullKernel; streamsync; endloop(1); +loop(1000); H2D; NullKernel; streamsync; H2D; NullKernel; streamsync; endloop(1); +loop(1000); H2D; NullKernel; streamsync; H2D; NullKernel; streamsync; endloop(1); +loop(10000); H2D; NullKernel; streamsync;H2D; NullKernel; streamsync; endloop(1); +loop(10000); H2D; NullKernel; streamsync; H2D; NullKernel; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_h2d_sync_d2h.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_h2d_sync_d2h.hcm new file mode 100644 index 0000000000..fe1f14bee5 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_h2d_sync_d2h.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); H2D; streamsync; D2H; streamsync;H2D; streamsync; D2H; streamsync; endloop(1); +loop(10); H2D; streamsync; D2H; streamsync;H2D; streamsync; D2H; streamsync; endloop(1); +loop(100); H2D; streamsync; D2H; streamsync;H2D; streamsync; D2H; streamsync; endloop(1); +loop(100); H2D; streamsync; D2H; streamsync;H2D; streamsync; D2H; streamsync; endloop(1); +loop(1000); H2D; streamsync; D2H; streamsync;H2D; streamsync; D2H; streamsync; endloop(1); +loop(1000); H2D; streamsync; D2H; streamsync;H2D; streamsync; D2H; streamsync; endloop(1); +loop(10000); H2D; streamsync; D2H; streamsync;H2D; streamsync; D2H; streamsync; endloop(1); +loop(10000); H2D; streamsync; D2H; streamsync;H2D; streamsync; D2H; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_h2d_sync_kernel.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_h2d_sync_kernel.hcm new file mode 100644 index 0000000000..0762001daa --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_h2d_sync_kernel.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); H2D; streamsync; NullKernel; streamsync;H2D; streamsync; NullKernel; streamsync; endloop(1); +loop(10); H2D; streamsync; NullKernel; streamsync;H2D; streamsync; NullKernel; streamsync; endloop(1); +loop(100); H2D; streamsync; NullKernel; streamsync;H2D; streamsync; NullKernel; streamsync; endloop(1); +loop(100); H2D; streamsync; NullKernel; streamsync;H2D; streamsync; NullKernel; streamsync; endloop(1); +loop(1000); H2D; streamsync; NullKernel; streamsync;H2D; streamsync; NullKernel; streamsync; endloop(1); +loop(1000); H2D; streamsync; NullKernel; streamsync;H2D; streamsync; NullKernel; streamsync; endloop(1); +loop(10000); H2D; streamsync; NullKernel; streamsync;H2D; streamsync; NullKernel; streamsync; endloop(1); +loop(10000); H2D; streamsync; NullKernel; streamsync;H2D; streamsync; NullKernel; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_kernel_d2h.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_kernel_d2h.hcm new file mode 100644 index 0000000000..88003ba476 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_kernel_d2h.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); NullKernel; D2H; streamsync;NullKernel; D2H; streamsync; endloop(1); +loop(10); NullKernel; D2H; streamsync;NullKernel; D2H; streamsync; endloop(1); +loop(100); NullKernel; D2H; streamsync;NullKernel; D2H; streamsync; endloop(1); +loop(100); NullKernel; D2H; streamsync;NullKernel; D2H; streamsync; endloop(1); +loop(1000); NullKernel; D2H; streamsync;NullKernel; D2H; streamsync; endloop(1); +loop(1000); NullKernel; D2H; streamsync;NullKernel; D2H; streamsync; endloop(1); +loop(10000); NullKernel; D2H; streamsync;NullKernel; D2H; streamsync; endloop(1); +loop(10000); NullKernel; D2H; streamsync;NullKernel; D2H; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_kernel_h2d.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_kernel_h2d.hcm new file mode 100644 index 0000000000..01913f8481 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_kernel_h2d.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); NullKernel; H2D; streamsync;NullKernel; H2D; streamsync; endloop(1); +loop(10); NullKernel; H2D; streamsync;NullKernel; H2D; streamsync; endloop(1); +loop(100); NullKernel; H2D; streamsync;NullKernel; H2D; streamsync; endloop(1); +loop(100); NullKernel; H2D; streamsync;NullKernel; H2D; streamsync; endloop(1); +loop(1000); NullKernel; H2D; streamsync;NullKernel; H2D; streamsync; endloop(1); +loop(1000); NullKernel; H2D; streamsync;NullKernel; H2D; streamsync; endloop(1); +loop(10000); NullKernel; H2D; streamsync;NullKernel; H2D; streamsync; endloop(1); +loop(10000); NullKernel; H2D; streamsync;NullKernel; H2D; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_kernel_sync_d2h.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_kernel_sync_d2h.hcm new file mode 100644 index 0000000000..530eb8f68e --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_kernel_sync_d2h.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); NullKernel; streamsync; D2H; streamsync;NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(10); NullKernel; streamsync; D2H; streamsync;NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(100); NullKernel; streamsync; D2H; streamsync;NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(100); NullKernel; streamsync; D2H; streamsync;NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(1000); NullKernel; streamsync; D2H; streamsync;NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(1000); NullKernel; streamsync; D2H; streamsync;NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(10000); NullKernel; streamsync; D2H; streamsync;NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(10000); NullKernel; streamsync; D2H; streamsync;NullKernel; streamsync; D2H; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_kernel_sync_h2d.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_kernel_sync_h2d.hcm new file mode 100644 index 0000000000..6d83ee87c9 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_kernel_sync_h2d.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); NullKernel; streamsync; H2D; streamsync;NullKernel; streamsync; H2D; streamsync; endloop(1); +loop(10); NullKernel; streamsync; H2D; streamsync;NullKernel; streamsync; H2D; streamsync; endloop(1); +loop(100); NullKernel; streamsync; H2D; streamsync;NullKernel; streamsync; H2D; streamsync; endloop(1); +loop(100); NullKernel; streamsync; H2D; streamsync;NullKernel; streamsync; H2D; streamsync; endloop(1); +loop(1000); NullKernel; streamsync; H2D; streamsync;NullKernel; streamsync; H2D; streamsync; endloop(1); +loop(1000); NullKernel; streamsync; H2D; streamsync;NullKernel; streamsync; H2D; streamsync; endloop(1); +loop(10000); NullKernel; streamsync; H2D; streamsync;NullKernel; streamsync; H2D; streamsync; endloop(1); +loop(10000); NullKernel; streamsync; H2D; streamsync;NullKernel; streamsync; H2D; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_sync.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_sync.hcm new file mode 100644 index 0000000000..8b9e233a9e --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2_sync.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); streamsync; streamsync; endloop(1); +loop(10); streamsync; streamsync; endloop(1); +loop(100); streamsync; streamsync; endloop(1); +loop(100); streamsync; streamsync; endloop(1); +loop(1000); streamsync; streamsync; endloop(1); +loop(1000); streamsync; streamsync; endloop(1); +loop(10000); streamsync; streamsync; endloop(1); +loop(10000); streamsync; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2d2h.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2d2h.hcm new file mode 100644 index 0000000000..83cdc4ff75 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2d2h.hcm @@ -0,0 +1,10 @@ +setstream(1); +loop(10); D2H; streamsync; D2H; streamsync; endloop(1); +loop(10); D2H; streamsync; D2H; streamsync; endloop(1); +loop(100); D2H; streamsync; D2H; streamsync; endloop(1); +loop(100); D2H; streamsync; D2H; streamsync; endloop(1); +loop(1000); D2H;streamsync; D2H; streamsync; endloop(1); +loop(1000); D2H; streamsync; D2H; streamsync; endloop(1); +loop(1000); D2H; streamsync; D2H; streamsync; endloop(1); +loop(10000); D2H; streamsync; D2H; streamsync; endloop(1); +loop(10000); D2H; streamsync; D2H; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2d2h_wosync.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2d2h_wosync.hcm new file mode 100644 index 0000000000..4b91403582 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2d2h_wosync.hcm @@ -0,0 +1,10 @@ +setstream(1); +loop(10); D2H; D2H; streamsync; endloop(1); +loop(10); D2H; D2H; streamsync; endloop(1); +loop(100); D2H; D2H; streamsync; endloop(1); +loop(100); D2H; D2H; streamsync; endloop(1); +loop(1000); D2H; D2H; streamsync; endloop(1); +loop(1000); D2H; D2H; streamsync; endloop(1); +loop(1000); D2H; D2H; streamsync; endloop(1); +loop(10000); D2H; D2H; streamsync; endloop(1); +loop(10000); D2H; D2H; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2h2d.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2h2d.hcm new file mode 100644 index 0000000000..a2e4311bf6 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2h2d.hcm @@ -0,0 +1,10 @@ +setstream(1); +loop(10); H2D; streamsync; H2D; streamsync; endloop(1); +loop(10); H2D; streamsync; H2D; streamsync; endloop(1); +loop(100); H2D; streamsync; H2D; streamsync; endloop(1); +loop(100); H2D; streamsync; H2D; streamsync; endloop(1); +loop(1000); H2D;streamsync; H2D; streamsync; endloop(1); +loop(1000); H2D; streamsync; H2D; streamsync; endloop(1); +loop(1000); H2D; streamsync; H2D; streamsync; endloop(1); +loop(10000); H2D; streamsync; H2D; streamsync; endloop(1); +loop(10000); H2D; streamsync; H2D; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2h2d_kernel.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2h2d_kernel.hcm new file mode 100644 index 0000000000..0c622614cc --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2h2d_kernel.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); H2D; streamsync; NullKernel; streamsync; H2D; streamsync; NullKernel; streamsync;endloop(1); +loop(10); H2D; streamsync; NullKernel; streamsync;H2D; streamsync; NullKernel; streamsync; endloop(1); +loop(100); H2D; streamsync; NullKernel; streamsync; H2D; streamsync; NullKernel; streamsync;endloop(1); +loop(100); H2D; streamsync; NullKernel; streamsync; H2D; streamsync; NullKernel; streamsync;endloop(1); +loop(1000); H2D; streamsync; NullKernel; streamsync; H2D; streamsync; NullKernel; streamsync;endloop(1); +loop(1000); H2D; streamsync; NullKernel; streamsync; H2D; streamsync; NullKernel; streamsync;endloop(1); +loop(10000); H2D; streamsync; NullKernel; streamsync;H2D; streamsync; NullKernel; streamsync; endloop(1); +loop(10000); H2D; streamsync; NullKernel; streamsync; H2D; streamsync; NullKernel; streamsync;endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2h2d_kernel_wosync.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2h2d_kernel_wosync.hcm new file mode 100644 index 0000000000..d73467da10 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2h2d_kernel_wosync.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); H2D; NullKernel; streamsync;H2D; NullKernel; streamsync; endloop(1); +loop(10); H2D; NullKernel; streamsync; H2D; NullKernel; streamsync;endloop(1); +loop(100); H2D; NullKernel; streamsync; H2D; NullKernel; streamsync;endloop(1); +loop(100); H2D; NullKernel; streamsync; H2D; NullKernel; streamsync;endloop(1); +loop(1000); H2D; NullKernel; streamsync;H2D; NullKernel; streamsync; endloop(1); +loop(1000); H2D; NullKernel; streamsync;H2D; NullKernel; streamsync; endloop(1); +loop(10000); H2D; NullKernel; streamsync;H2D; NullKernel; streamsync; endloop(1); +loop(10000); H2D ; NullKernel; streamsync;H2D; NullKernel; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2h2d_wosync.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2h2d_wosync.hcm new file mode 100644 index 0000000000..35f5e68522 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2h2d_wosync.hcm @@ -0,0 +1,10 @@ +setstream(1); +loop(10); H2D; H2D; streamsync; endloop(1); +loop(10); H2D; H2D; streamsync; endloop(1); +loop(100); H2D; H2D; streamsync; endloop(1); +loop(100); H2D; H2D; streamsync; endloop(1); +loop(1000); H2D; H2D; streamsync; endloop(1); +loop(1000); H2D; H2D; streamsync; endloop(1); +loop(1000); H2D; H2D; streamsync; endloop(1); +loop(10000); H2D; H2D; streamsync; endloop(1); +loop(10000); H2D; H2D; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2kernels.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2kernels.hcm new file mode 100644 index 0000000000..3b85c6bef8 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2kernels.hcm @@ -0,0 +1,10 @@ +setstream(1); +loop(10); NullKernel; streamsync; NullKernel; streamsync; endloop(1); +loop(10); NullKernel; streamsync; NullKernel; streamsync; endloop(1); +loop(100); NullKernel; streamsync; NullKernel; streamsync; endloop(1); +loop(100); NullKernel; streamsync; NullKernel; streamsync; endloop(1); +loop(1000); NullKernel; streamsync; NullKernel; streamsync; endloop(1); +loop(1000); NullKernel; streamsync; NullKernel; streamsync; endloop(1); +loop(1000); NullKernel; streamsync; NullKernel; streamsync; endloop(1); +loop(10000); NullKernel; streamsync; NullKernel; streamsync; endloop(1); +loop(10000); NullKernel; streamsync; NullKernel; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2kernels_wosync.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2kernels_wosync.hcm new file mode 100644 index 0000000000..584d6b8021 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_2kernels_wosync.hcm @@ -0,0 +1,10 @@ +setstream(1); +loop(10); NullKernel; NullKernel; streamsync; endloop(1); +loop(10); NullKernel; NullKernel; streamsync; endloop(1); +loop(100); NullKernel; NullKernel; streamsync; endloop(1); +loop(100); NullKernel; NullKernel; streamsync; endloop(1); +loop(1000); NullKernel; NullKernel; streamsync; endloop(1); +loop(1000); NullKernel; NullKernel; streamsync; endloop(1); +loop(1000); NullKernel; NullKernel; streamsync; endloop(1); +loop(10000); NullKernel; NullKernel; streamsync; endloop(1); +loop(10000); NullKernel; NullKernel; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_d2h_h2d.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_d2h_h2d.hcm new file mode 100644 index 0000000000..7f0fce96c5 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_d2h_h2d.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); D2H; H2D; streamsync;D2H; H2D; streamsync; D2H; H2D; streamsync; endloop(1); +loop(10); D2H; H2D; streamsync;D2H; H2D; streamsync; D2H; H2D; streamsync; endloop(1); +loop(100); D2H; H2D; streamsync;D2H; H2D; streamsync; D2H; H2D; streamsync; endloop(1); +loop(100); D2H; H2D; streamsync;D2H; H2D; streamsync; D2H; H2D; streamsync; endloop(1); +loop(1000); D2H; H2D; streamsync;D2H; H2D; streamsync; D2H; H2D; streamsync; endloop(1); +loop(1000); D2H; H2D; streamsync;D2H; H2D; streamsync; D2H; H2D; streamsync; endloop(1); +loop(10000); D2H; H2D; streamsync;D2H; H2D; streamsync; D2H; H2D; streamsync; endloop(1); +loop(10000); D2H; H2D; streamsync;D2H; H2D; streamsync; D2H; H2D; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_d2h_kernel.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_d2h_kernel.hcm new file mode 100644 index 0000000000..a384439b5c --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_d2h_kernel.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); D2H; NullKernel; streamsync;D2H; NullKernel; streamsync;streamsync; D2H; NullKernel; streamsync; endloop(1); +loop(10); D2H; NullKernel; streamsync;D2H; NullKernel; streamsync;streamsync; D2H; NullKernel; streamsync; endloop(1); +loop(100); D2H; NullKernel; streamsync;D2H; NullKernel; streamsync;streamsync; D2H; NullKernel; streamsync; endloop(1); +loop(100); D2H; NullKernel; streamsync;D2H; NullKernel; streamsync;streamsync; D2H; NullKernel; streamsync; endloop(1); +loop(1000); D2H; NullKernel; streamsync;D2H; NullKernel; streamsync;streamsync; D2H; NullKernel; streamsync; endloop(1); +loop(1000); D2H; NullKernel; streamsync;D2H; NullKernel; streamsync;streamsync; D2H; NullKernel; streamsync; endloop(1); +loop(10000); D2H; NullKernel; streamsync;D2H; NullKernel; streamsync;streamsync; D2H; NullKernel; streamsync; endloop(1); +loop(10000); D2H; NullKernel; streamsync;D2H; NullKernel; streamsync;streamsync; D2H; NullKernel; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_d2h_sync_h2d.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_d2h_sync_h2d.hcm new file mode 100644 index 0000000000..1cab6ff0d2 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_d2h_sync_h2d.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); D2H; streamsync; H2D; streamsync;D2H; streamsync; H2D; streamsync; D2H; streamsync; H2D;streamsync; endloop(1); +loop(10); D2H; streamsync; H2D; streamsync;D2H; streamsync; H2D; streamsync; D2H; streamsync; H2D;streamsync; endloop(1); +loop(100); D2H; streamsync; H2D; streamsync;D2H; streamsync; H2D; streamsync; D2H; streamsync; H2D;streamsync; endloop(1); +loop(100); D2H; streamsync; H2D; streamsync;D2H; streamsync; H2D; streamsync; D2H; streamsync; H2D;streamsync; endloop(1); +loop(1000); D2H; streamsync; H2D; streamsync;D2H; streamsync; H2D; streamsync; D2H; streamsync; H2D;streamsync; endloop(1); +loop(1000); D2H; streamsync; H2D; streamsync;D2H; streamsync; H2D; streamsync; D2H; streamsync; H2D;streamsync; endloop(1); +loop(10000); D2H; streamsync; H2D; streamsync;D2H; streamsync; H2D; streamsync; D2H; streamsync; H2D;streamsync; endloop(1); +loop(10000); D2H; streamsync; H2D; streamsync;D2H; streamsync; H2D; streamsync; D2H; streamsync; H2D;streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_d2h_sync_kernel.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_d2h_sync_kernel.hcm new file mode 100644 index 0000000000..ff5b09a3dc --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_d2h_sync_kernel.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); D2H; streamsync; NullKernel; streamsync;D2H; streamsync; NullKernel; streamsync; D2H; streamsync; NullKernel;streamsync; endloop(1); +loop(10); D2H; streamsync; NullKernel; streamsync;D2H; streamsync; NullKernel; streamsync; D2H; streamsync; NullKernel;streamsync; endloop(1); +loop(100); D2H; streamsync; NullKernel; streamsync;D2H; streamsync; NullKernel; streamsync; D2H; streamsync; NullKernel;streamsync; endloop(1); +loop(100); D2H; streamsync; NullKernel; streamsync;D2H; streamsync; NullKernel; streamsync; D2H; streamsync; NullKernel;streamsync; endloop(1); +loop(1000); D2H; streamsync; NullKernel; streamsync;D2H; streamsync; NullKernel; streamsync; D2H; streamsync; NullKernel;streamsync; endloop(1); +loop(1000); D2H; streamsync; NullKernel; streamsync;D2H; streamsync; NullKernel; streamsync; D2H; streamsync; NullKernel;streamsync; endloop(1); +loop(10000); D2H; streamsync; NullKernel; streamsync;D2H; streamsync; NullKernel; streamsync; D2H; streamsync; NullKernel;streamsync; endloop(1); +loop(10000); D2H; streamsync; NullKernel; streamsync;D2H; streamsync; NullKernel; streamsync; D2H; streamsync; NullKernel;streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_h2d_d2h.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_h2d_d2h.hcm new file mode 100644 index 0000000000..d8921a64e7 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_h2d_d2h.hcm @@ -0,0 +1,10 @@ +setstream(1); +loop(10); H2D; D2H; streamsync;H2D; D2H; streamsync; H2D; D2H; streamsync; endloop(1); +loop(10); H2D; D2H; streamsync;H2D; D2H; streamsync; H2D; D2H; streamsync; endloop(1); +loop(100); H2D; D2H; streamsync;H2D; D2H; streamsync; H2D; D2H; streamsync; endloop(1); +loop(100); H2D; D2H; streamsync;H2D; D2H; streamsync; H2D; D2H; streamsync; endloop(1); +loop(1000); H2D; D2H; streamsync;H2D; D2H; streamsync; H2D; D2H; streamsync; endloop(1); +loop(1000); H2D; D2H; streamsync;H2D; D2H; streamsync; H2D; D2H; streamsync; endloop(1); +loop(10000); H2D; D2H; streamsync;H2D; D2H; streamsync; H2D; D2H; streamsync; endloop(1); +loop(10000); H2D; D2H; streamsync;H2D; D2H; streamsync; H2D; D2H; streamsync; endloop(1); + diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_h2d_kernel.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_h2d_kernel.hcm new file mode 100644 index 0000000000..4ccbf9a83c --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_h2d_kernel.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); H2D; NullKernel; streamsync;H2D; NullKernel; streamsync;streamsync; H2D; NullKernel; streamsync; endloop(1); +loop(10); H2D; NullKernel; streamsync;H2D; NullKernel; streamsync;streamsync; H2D; NullKernel; streamsync; endloop(1); +loop(100); H2D; NullKernel; streamsync;H2D; NullKernel; streamsync;streamsync; H2D; NullKernel; streamsync; endloop(1); +loop(100); H2D; NullKernel; streamsync;H2D; NullKernel; streamsync;streamsync; H2D; NullKernel; streamsync; endloop(1); +loop(1000); H2D; NullKernel; streamsync;H2D; NullKernel; streamsync;streamsync; H2D; NullKernel; streamsync; endloop(1); +loop(1000); H2D; NullKernel; streamsync;H2D; NullKernel; streamsync;streamsync; H2D; NullKernel; streamsync; endloop(1); +loop(10000); H2D; NullKernel; streamsync;H2D; NullKernel; streamsync;streamsync; H2D; NullKernel; streamsync; endloop(1); +loop(10000); H2D; NullKernel; streamsync;H2D; NullKernel; streamsync;streamsync; H2D; NullKernel; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_h2d_sync_d2h.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_h2d_sync_d2h.hcm new file mode 100644 index 0000000000..a3d9a282f5 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_h2d_sync_d2h.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); H2D; streamsync; D2H; streamsync;H2D; streamsync; D2H; streamsync; H2D; streamsync; D2H;streamsync; endloop(1); +loop(10); H2D; streamsync; D2H; streamsync;H2D; streamsync; D2H; streamsync; H2D; streamsync; D2H;streamsync; endloop(1); +loop(100); H2D; streamsync; D2H; streamsync;H2D; streamsync; D2H; streamsync; H2D; streamsync; D2H;streamsync; endloop(1); +loop(100); H2D; streamsync; D2H; streamsync;H2D; streamsync; D2H; streamsync; H2D; streamsync; D2H;streamsync; endloop(1); +loop(1000); H2D; streamsync; D2H; streamsync;H2D; streamsync; D2H; streamsync; H2D; streamsync; D2H;streamsync; endloop(1); +loop(1000); H2D; streamsync; D2H; streamsync;H2D; streamsync; D2H; streamsync; H2D; streamsync; D2H;streamsync; endloop(1); +loop(10000); H2D; streamsync; D2H; streamsync;H2D; streamsync; D2H; streamsync; H2D; streamsync; D2H;streamsync; endloop(1); +loop(10000); H2D; streamsync; D2H; streamsync;H2D; streamsync; D2H; streamsync; H2D; streamsync; D2H;streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_h2d_sync_kernel.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_h2d_sync_kernel.hcm new file mode 100644 index 0000000000..56554d15fd --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_h2d_sync_kernel.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); H2D; streamsync; NullKernel; streamsync;H2D; streamsync; NullKernel; streamsync; H2D; streamsync; NullKernel;streamsync; endloop(1); +loop(10); H2D; streamsync; NullKernel; streamsync;H2D; streamsync; NullKernel; streamsync; H2D; streamsync; NullKernel;streamsync; endloop(1); +loop(100); H2D; streamsync; NullKernel; streamsync;H2D; streamsync; NullKernel; streamsync; H2D; streamsync; NullKernel;streamsync; endloop(1); +loop(100); H2D; streamsync; NullKernel; streamsync;H2D; streamsync; NullKernel; streamsync; H2D; streamsync; NullKernel;streamsync; endloop(1); +loop(1000); H2D; streamsync; NullKernel; streamsync;H2D; streamsync; NullKernel; streamsync; H2D; streamsync; NullKernel;streamsync; endloop(1); +loop(1000); H2D; streamsync; NullKernel; streamsync;H2D; streamsync; NullKernel; streamsync; H2D; streamsync; NullKernel;streamsync; endloop(1); +loop(10000); H2D; streamsync; NullKernel; streamsync;H2D; streamsync; NullKernel; streamsync; H2D; streamsync; NullKernel;streamsync; endloop(1); +loop(10000); H2D; streamsync; NullKernel; streamsync;H2D; streamsync; NullKernel; streamsync; H2D; streamsync; NullKernel;streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_kernel_d2h.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_kernel_d2h.hcm new file mode 100644 index 0000000000..a6e3a683d2 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_kernel_d2h.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); NullKernel; D2H; streamsync;NullKernel; D2H; streamsync; NullKernel; D2H; streamsync;endloop(1); +loop(10); NullKernel; D2H; streamsync;NullKernel; D2H; streamsync; NullKernel; D2H; streamsync;endloop(1); +loop(100); NullKernel; D2H; streamsync;NullKernel; D2H; streamsync; NullKernel; D2H; streamsync;endloop(1); +loop(100); NullKernel; D2H; streamsync;NullKernel; D2H; streamsync; NullKernel; D2H; streamsync;endloop(1); +loop(1000); NullKernel; D2H; streamsync;NullKernel; D2H; streamsync; NullKernel; D2H; streamsync;endloop(1); +loop(1000); NullKernel; D2H; streamsync;NullKernel; D2H; streamsync; NullKernel; D2H; streamsync;endloop(1); +loop(10000); NullKernel; D2H; streamsync;NullKernel; D2H; streamsync; NullKernel; D2H; streamsync;endloop(1); +loop(10000); NullKernel; D2H; streamsync;NullKernel; D2H; streamsync; NullKernel; D2H; streamsync;endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_kernel_h2d.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_kernel_h2d.hcm new file mode 100644 index 0000000000..eae3eadc5b --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_kernel_h2d.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); NullKernel; H2D; streamsync;NullKernel; H2D; streamsync; NullKernel; H2D; streamsync;endloop(1); +loop(10); NullKernel; H2D; streamsync;NullKernel; H2D; streamsync; NullKernel; H2D; streamsync;endloop(1); +loop(100); NullKernel; H2D; streamsync;NullKernel; H2D; streamsync; NullKernel; H2D; streamsync;endloop(1); +loop(100); NullKernel; H2D; streamsync;NullKernel; H2D; streamsync; NullKernel; H2D; streamsync;endloop(1); +loop(1000); NullKernel; H2D; streamsync;NullKernel; H2D; streamsync; NullKernel; H2D; streamsync;endloop(1); +loop(1000); NullKernel; H2D; streamsync;NullKernel; H2D; streamsync; NullKernel; H2D; streamsync;endloop(1); +loop(10000); NullKernel; H2D; streamsync;NullKernel; H2D; streamsync; NullKernel; H2D; streamsync;endloop(1); +loop(10000); NullKernel; H2D; streamsync;NullKernel; H2D; streamsync; NullKernel; H2D; streamsync;endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_kernel_sync_d2h.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_kernel_sync_d2h.hcm new file mode 100644 index 0000000000..9e21709b0b --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_kernel_sync_d2h.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); NullKernel; streamsync; D2H; streamsync;NullKernel; streamsync; D2H; streamsync;NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(10); NullKernel; streamsync; D2H; streamsync;NullKernel; streamsync; D2H; streamsync;NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(100); NullKernel; streamsync; D2H; streamsync;NullKernel; streamsync; D2H; streamsync;NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(100); NullKernel; streamsync; D2H; streamsync;NullKernel; streamsync; D2H; streamsync;NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(1000); NullKernel; streamsync; D2H; streamsync;NullKernel; streamsync; D2H; streamsync;NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(1000); NullKernel; streamsync; D2H; streamsync;NullKernel; streamsync; D2H; streamsync;NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(10000); NullKernel; streamsync; D2H; streamsync;NullKernel; streamsync; D2H; streamsync;NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(10000); NullKernel; streamsync; D2H; streamsync;NullKernel; streamsync; D2H; streamsync;NullKernel; streamsync; D2H; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_kernel_sync_h2d.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_kernel_sync_h2d.hcm new file mode 100644 index 0000000000..b1ef7ef9f4 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_kernel_sync_h2d.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); NullKernel; streamsync; H2D; streamsync;NullKernel; streamsync; H2D; streamsync;NullKernel; streamsync; H2D; streamsync; endloop(1); +loop(10); NullKernel; streamsync; H2D; streamsync;NullKernel; streamsync; H2D; streamsync;NullKernel; streamsync; H2D; streamsync; endloop(1); +loop(100); NullKernel; streamsync; H2D; streamsync;NullKernel; streamsync; H2D; streamsync;NullKernel; streamsync; H2D; streamsync; endloop(1); +loop(100); NullKernel; streamsync; H2D; streamsync;NullKernel; streamsync; H2D; streamsync;NullKernel; streamsync; H2D; streamsync; endloop(1); +loop(1000); NullKernel; streamsync; H2D; streamsync;NullKernel; streamsync; H2D; streamsync;NullKernel; streamsync; H2D; streamsync; endloop(1); +loop(1000); NullKernel; streamsync; H2D; streamsync;NullKernel; streamsync; H2D; streamsync;NullKernel; streamsync; H2D; streamsync; endloop(1); +loop(10000); NullKernel; streamsync; H2D; streamsync;NullKernel; streamsync; H2D; streamsync;NullKernel; streamsync; H2D; streamsync; endloop(1); +loop(10000); NullKernel; streamsync; H2D; streamsync;NullKernel; streamsync; H2D; streamsync;NullKernel; streamsync; H2D; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_sync.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_sync.hcm new file mode 100644 index 0000000000..bc8d21c594 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3_sync.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10);streamsync; streamsync; streamsync; endloop(1); +loop(10);streamsync; streamsync; streamsync; endloop(1); +loop(100);streamsync; streamsync; streamsync; endloop(1); +loop(100);streamsync; streamsync; streamsync; endloop(1); +loop(1000);streamsync; streamsync; streamsync; endloop(1); +loop(1000);streamsync; streamsync; streamsync; endloop(1); +loop(10000);streamsync; streamsync; streamsync; endloop(1); +loop(10000);streamsync; streamsync; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3d2h.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3d2h.hcm new file mode 100644 index 0000000000..4e07574b99 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3d2h.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); D2H; streamsync; D2H; streamsync; D2H; streamsync; endloop(1); +loop(10); D2H; streamsync; D2H; streamsync; D2H; streamsync; endloop(1); +loop(100); D2H; streamsync; D2H; streamsync; D2H; streamsync; endloop(1); +loop(100); D2H; streamsync; D2H; streamsync; D2H; streamsync; endloop(1); +loop(1000); D2H;streamsync; D2H; streamsync; D2H; streamsync; endloop(1); +loop(1000); D2H; streamsync; D2H; streamsync; D2H; streamsync; endloop(1); +loop(10000); D2H; streamsync; D2H; streamsync; D2H; streamsync; endloop(1); +loop(10000); D2H; streamsync; D2H; streamsync; D2H; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3d2h_wosync.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3d2h_wosync.hcm new file mode 100644 index 0000000000..e96707fed9 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3d2h_wosync.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); D2H; D2H; D2H; streamsync; endloop(1); +loop(10); D2H; D2H; D2H; streamsync; endloop(1); +loop(100); D2H; D2H; D2H; streamsync; endloop(1); +loop(100); D2H; D2H; D2H; streamsync; endloop(1); +loop(1000); D2H; D2H; D2H; streamsync; endloop(1); +loop(1000); D2H; D2H; D2H; streamsync; endloop(1); +loop(10000); D2H; D2H; D2H; streamsync; endloop(1); +loop(10000); D2H; D2H; D2H;streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3h2d.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3h2d.hcm new file mode 100644 index 0000000000..82151adb8b --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3h2d.hcm @@ -0,0 +1,10 @@ +setstream(1); +loop(10); H2D; streamsync;H2D;streamsync; H2D; streamsync; endloop(1); +loop(10); H2D; streamsync;H2D;streamsync; H2D; streamsync; endloop(1); +loop(100); H2D; streamsync;H2D; streamsync;H2D; streamsync; endloop(1); +loop(100); H2D;streamsync; H2D; streamsync;H2D; streamsync; endloop(1); +loop(1000); H2D;streamsync; H2D;streamsync; H2D; streamsync; endloop(1); +loop(1000); H2D;streamsync; H2D; streamsync;H2D; streamsync; endloop(1); +loop(1000); H2D;streamsync; H2D; streamsync;H2D; streamsync; endloop(1); +loop(10000); H2D;streamsync; H2D; streamsync;H2D; streamsync; endloop(1); +loop(10000); H2D;streamsync; H2D;streamsync; H2D; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3h2d_wosync.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3h2d_wosync.hcm new file mode 100644 index 0000000000..7d96bfcfab --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3h2d_wosync.hcm @@ -0,0 +1,10 @@ +setstream(1); +loop(10); H2D; H2D; H2D; streamsync; endloop(1); +loop(10); H2D; H2D; H2D; streamsync; endloop(1); +loop(100); H2D; H2D; H2D; streamsync; endloop(1); +loop(100); H2D; H2D; H2D; streamsync; endloop(1); +loop(1000); H2D; H2D; H2D; streamsync; endloop(1); +loop(1000); H2D; H2D; H2D; streamsync; endloop(1); +loop(1000); H2D; H2D; H2D; streamsync; endloop(1); +loop(10000); H2D; H2D; H2D; streamsync; endloop(1); +loop(10000); H2D; H2D; H2D; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3kernels.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3kernels.hcm new file mode 100644 index 0000000000..2e8306dfde --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3kernels.hcm @@ -0,0 +1,10 @@ +setstream(1); +loop(10); NullKernel; streamsync; NullKernel; streamsync; NullKernel; streamsync; endloop(1); +loop(10); NullKernel; streamsync; NullKernel; streamsync; NullKernel; streamsync; endloop(1); +loop(100); NullKernel; streamsync; NullKernel; streamsync; NullKernel; streamsync; endloop(1); +loop(100); NullKernel; streamsync; NullKernel; streamsync; NullKernel; streamsync; endloop(1); +loop(1000); NullKernel; streamsync; NullKernel; streamsync; NullKernel; streamsync; endloop(1); +loop(1000); NullKernel; streamsync; NullKernel; streamsync; NullKernel; streamsync; endloop(1); +loop(1000); NullKernel; streamsync; NullKernel; streamsync; NullKernel; streamsync; endloop(1); +loop(10000); NullKernel; streamsync; NullKernel; streamsync; NullKernel; streamsync; endloop(1); +loop(10000); NullKernel; streamsync; NullKernel; streamsync; NullKernel; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3kernels_wosync.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3kernels_wosync.hcm new file mode 100644 index 0000000000..85cd0dd4d2 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_3kernels_wosync.hcm @@ -0,0 +1,10 @@ +setstream(1); +loop(10); NullKernel; NullKernel; NullKernel; streamsync; endloop(1); +loop(10); NullKernel; NullKernel; NullKernel; streamsync; endloop(1); +loop(100); NullKernel; NullKernel; NullKernel; streamsync; endloop(1); +loop(100); NullKernel; NullKernel; NullKernel; streamsync; endloop(1); +loop(1000); NullKernel; NullKernel; NullKernel; streamsync; endloop(1); +loop(1000); NullKernel; NullKernel; NullKernel; streamsync; endloop(1); +loop(1000); NullKernel; NullKernel; NullKernel; streamsync; endloop(1); +loop(10000); NullKernel; NullKernel; NullKernel; streamsync; endloop(1); +loop(10000); NullKernel; NullKernel; NullKernel; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_4kernels.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_4kernels.hcm new file mode 100644 index 0000000000..48a8223626 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_4kernels.hcm @@ -0,0 +1,10 @@ +setstream(1); +loop(10); NullKernel; NullKernel; NullKernel; NullKernel; streamsync; endloop(1); +loop(10); NullKernel; NullKernel; NullKernel; NullKernel; streamsync; endloop(1); +loop(100); NullKernel; NullKernel; NullKernel; NullKernel;streamsync; endloop(1); +loop(100); NullKernel; NullKernel; NullKernel; NullKernel; streamsync; endloop(1); +loop(1000); NullKernel; NullKernel; NullKernel; NullKernel; streamsync; endloop(1); +loop(1000); NullKernel; NullKernel; NullKernel; NullKernel; streamsync; endloop(1); +loop(1000); NullKernel; NullKernel; NullKernel; NullKernel; streamsync; endloop(1); +loop(10000); NullKernel; NullKernel; NullKernel; NullKernel; streamsync; endloop(1); +loop(10000); NullKernel; NullKernel; NullKernel; NullKernel; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_5kernels.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_5kernels.hcm new file mode 100644 index 0000000000..70ad00c248 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_5kernels.hcm @@ -0,0 +1,10 @@ +setstream(1); +loop(10); NullKernel; NullKernel; NullKernel; NullKernel;NullKernel; streamsync; endloop(1); +loop(10); NullKernel; NullKernel; NullKernel; NullKernel; NullKernel; streamsync; endloop(1); +loop(100); NullKernel; NullKernel; NullKernel; NullKernel; NullKernel;streamsync; endloop(1); +loop(100); NullKernel; NullKernel; NullKernel; NullKernel; NullKernel; streamsync; endloop(1); +loop(1000); NullKernel; NullKernel; NullKernel; NullKernel; NullKernel; streamsync; endloop(1); +loop(1000); NullKernel; NullKernel; NullKernel; NullKernel; NullKernel; streamsync; endloop(1); +loop(1000); NullKernel; NullKernel; NullKernel; NullKernel; NullKernel; streamsync; endloop(1); +loop(10000); NullKernel; NullKernel; NullKernel; NullKernel; NullKernel; streamsync; endloop(1); +loop(10000); NullKernel; NullKernel; NullKernel; NullKernel; NullKernel; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_6kernels.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_6kernels.hcm new file mode 100644 index 0000000000..1bbb5694b1 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_6kernels.hcm @@ -0,0 +1,10 @@ +setstream(1); +loop(10); NullKernel; NullKernel; NullKernel; NullKernel;NullKernel;NullKernel; streamsync; endloop(1); +loop(10); NullKernel; NullKernel; NullKernel; NullKernel; NullKernel; NullKernel;streamsync; endloop(1); +loop(100); NullKernel; NullKernel; NullKernel; NullKernel; NullKernel;NullKernel;streamsync; endloop(1); +loop(100); NullKernel; NullKernel; NullKernel; NullKernel; NullKernel; NullKernel;streamsync; endloop(1); +loop(1000); NullKernel; NullKernel; NullKernel; NullKernel; NullKernel; NullKernel;streamsync; endloop(1); +loop(1000); NullKernel; NullKernel; NullKernel; NullKernel; NullKernel; NullKernel;streamsync; endloop(1); +loop(1000); NullKernel; NullKernel; NullKernel; NullKernel; NullKernel; NullKernel;streamsync; endloop(1); +loop(10000); NullKernel; NullKernel; NullKernel; NullKernel; NullKernel; NullKernel;streamsync; endloop(1); +loop(10000); NullKernel; NullKernel; NullKernel; NullKernel; NullKernel; NullKernel;streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_d2h.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_d2h.hcm new file mode 100644 index 0000000000..54f06a3481 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_d2h.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); D2H; streamsync; endloop(1); +loop(10); D2H; streamsync; endloop(1); +loop(100); D2H; streamsync; endloop(1); +loop(100); D2H; streamsync; endloop(1); +loop(1000); D2H; streamsync; endloop(1); +loop(1000); D2H; streamsync; endloop(1); +loop(10000); D2H; streamsync; endloop(1); +loop(10000); D2H; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_d2h_h2d.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_d2h_h2d.hcm new file mode 100644 index 0000000000..6667ba95fa --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_d2h_h2d.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); D2H; H2D; streamsync; endloop(1); +loop(10); D2H; H2D; streamsync; endloop(1); +loop(100); D2H; H2D; streamsync; endloop(1); +loop(100); D2H; H2D; streamsync; endloop(1); +loop(1000); D2H; H2D; streamsync; endloop(1); +loop(1000); D2H; H2D; streamsync; endloop(1); +loop(10000); D2H; H2D; streamsync; endloop(1); +loop(10000); D2H; H2D; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_d2h_kernel.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_d2h_kernel.hcm new file mode 100644 index 0000000000..fe770c5e9d --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_d2h_kernel.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); D2H; NullKernel; streamsync; endloop(1); +loop(10); D2H; NullKernel; streamsync; endloop(1); +loop(100); D2H; NullKernel; streamsync; endloop(1); +loop(100); D2H; NullKernel; streamsync; endloop(1); +loop(1000); D2H; NullKernel; streamsync; endloop(1); +loop(1000); D2H; NullKernel; streamsync; endloop(1); +loop(10000); D2H; NullKernel; streamsync; endloop(1); +loop(10000); D2H; NullKernel; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_d2h_sync_h2d.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_d2h_sync_h2d.hcm new file mode 100644 index 0000000000..20ec951509 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_d2h_sync_h2d.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); D2H; streamsync; H2D; streamsync; endloop(1); +loop(10); D2H; streamsync; H2D; streamsync; endloop(1); +loop(100); D2H; streamsync; H2D; streamsync; endloop(1); +loop(100); D2H; streamsync; H2D; streamsync; endloop(1); +loop(1000); D2H; streamsync; H2D; streamsync; endloop(1); +loop(1000); D2H; streamsync; H2D; streamsync; endloop(1); +loop(10000); D2H; streamsync; H2D; streamsync; endloop(1); +loop(10000); D2H; streamsync; H2D; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_d2h_sync_kernel.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_d2h_sync_kernel.hcm new file mode 100644 index 0000000000..77e483b3df --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_d2h_sync_kernel.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); D2H; streamsync;NullKernel; streamsync; endloop(1); +loop(10); D2H; streamsync;NullKernel; streamsync; endloop(1); +loop(100); D2H; streamsync;NullKernel; streamsync; endloop(1); +loop(100); D2H; streamsync;NullKernel; streamsync; endloop(1); +loop(1000); D2H; streamsync;NullKernel; streamsync; endloop(1); +loop(1000); D2H; streamsync;NullKernel; streamsync; endloop(1); +loop(10000); D2H; streamsync;NullKernel; streamsync; endloop(1); +loop(10000); D2H; streamsync;NullKernel; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d.hcm new file mode 100644 index 0000000000..f5642bfdf0 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d.hcm @@ -0,0 +1,10 @@ +setstream(1); +loop(10); H2D; streamsync; endloop(1); +loop(10); H2D; streamsync; endloop(1); +loop(100); H2D; streamsync; endloop(1); +loop(100); H2D; streamsync; endloop(1); +loop(1000); H2D; streamsync; endloop(1); +loop(1000); H2D; streamsync; endloop(1); +loop(1000); H2D; streamsync; endloop(1); +loop(10000); H2D; streamsync; endloop(1); +loop(10000); H2D; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_10.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_10.hcm new file mode 100644 index 0000000000..05452b9c87 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_10.hcm @@ -0,0 +1,2 @@ +setstream(1); +loop(10); H2D; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_d2h.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_d2h.hcm new file mode 100644 index 0000000000..dad9fc7437 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_d2h.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); H2D; D2H; streamsync; endloop(1); +loop(10); H2D; D2H; streamsync; endloop(1); +loop(100); H2D; D2H; streamsync; endloop(1); +loop(100); H2D; D2H; streamsync; endloop(1); +loop(1000); H2D; D2H; streamsync; endloop(1); +loop(1000); H2D; D2H; streamsync; endloop(1); +loop(10000); H2D; D2H; streamsync; endloop(1); +loop(10000); H2D; D2H; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_kernel.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_kernel.hcm new file mode 100644 index 0000000000..1b60640b9e --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_kernel.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); H2D; NullKernel; streamsync; endloop(1); +loop(10); H2D; NullKernel; streamsync; endloop(1); +loop(100); H2D; NullKernel; streamsync; endloop(1); +loop(100); H2D; NullKernel; streamsync; endloop(1); +loop(1000); H2D; NullKernel; streamsync; endloop(1); +loop(1000); H2D; NullKernel; streamsync; endloop(1); +loop(10000); H2D; NullKernel; streamsync; endloop(1); +loop(10000); H2D; NullKernel; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_kernel_d2h.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_kernel_d2h.hcm new file mode 100644 index 0000000000..6e4e9f3544 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_kernel_d2h.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10);H2D; streamsync; NullKernel; D2H; streamsync;endloop(1); +loop(10); H2D; streamsync; NullKernel; D2H; streamsync; endloop(1); +loop(100); H2D; streamsync; NullKernel; D2H; streamsync; endloop(1); +loop(100); H2D; streamsync; NullKernel; D2H; streamsync; endloop(1); +loop(1000); H2D; streamsync; NullKernel; D2H; streamsync; endloop(1); +loop(1000); H2D; streamsync; NullKernel; D2H; streamsync; endloop(1); +loop(10000); H2D; streamsync; NullKernel; D2H; streamsync; endloop(1); +loop(10000); H2D; streamsync; NullKernel; D2H; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_kernel_d2h_wosync.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_kernel_d2h_wosync.hcm new file mode 100644 index 0000000000..4e94a26ebf --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_kernel_d2h_wosync.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10);H2D; NullKernel; D2H; streamsync;endloop(1); +loop(10); H2D; NullKernel; D2H; streamsync; endloop(1); +loop(100); H2D; NullKernel; D2H; streamsync; endloop(1); +loop(100); H2D; NullKernel; D2H; streamsync; endloop(1); +loop(1000); H2D; NullKernel; D2H; streamsync; endloop(1); +loop(1000); H2D; NullKernel; D2H; streamsync; endloop(1); +loop(10000); H2D; NullKernel; D2H; streamsync; endloop(1); +loop(10000); H2D; NullKernel; D2H; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_kernel_wosync.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_kernel_wosync.hcm new file mode 100644 index 0000000000..b3b40d3190 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_kernel_wosync.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); H2D; NullKernel; streamsync; endloop(1); +loop(10); H2D; NullKernel; streamsync; endloop(1); +loop(100); H2D; NullKernel; streamsync; endloop(1); +loop(100); H2D; NullKernel; streamsync; endloop(1); +loop(1000); H2D; NullKernel; streamsync; endloop(1); +loop(1000); H2D; NullKernel; streamsync; endloop(1); +loop(10000); H2D; NullKernel; streamsync; endloop(1); +loop(10000); H2D ; NullKernel; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_sync_d2h.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_sync_d2h.hcm new file mode 100644 index 0000000000..030213d1b3 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_sync_d2h.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); H2D; streamsync; D2H; streamsync; endloop(1); +loop(10); H2D; streamsync; D2H; streamsync; endloop(1); +loop(100); H2D; streamsync; D2H; streamsync; endloop(1); +loop(100); H2D; streamsync; D2H; streamsync; endloop(1); +loop(1000); H2D; streamsync; D2H; streamsync; endloop(1); +loop(1000); H2D; streamsync; D2H; streamsync; endloop(1); +loop(10000); H2D; streamsync; D2H; streamsync; endloop(1); +loop(10000); H2D; streamsync; D2H; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_sync_kernel_sync.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_sync_kernel_sync.hcm new file mode 100644 index 0000000000..146c74bcae --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_sync_kernel_sync.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); H2D; streamsync; NullKernel; streamsync; endloop(1); +loop(10); H2D; streamsync; NullKernel; streamsync; endloop(1); +loop(100); H2D; streamsync; NullKernel; streamsync; endloop(1); +loop(100); H2D; streamsync; NullKernel; streamsync; endloop(1); +loop(1000); H2D; streamsync; NullKernel; streamsync; endloop(1); +loop(1000); H2D; streamsync; NullKernel; streamsync; endloop(1); +loop(10000); H2D; streamsync; NullKernel; streamsync; endloop(1); +loop(10000); H2D; streamsync; NullKernel; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_sync_kernel_sync_d2h.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_sync_kernel_sync_d2h.hcm new file mode 100644 index 0000000000..366d04f469 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_h2d_sync_kernel_sync_d2h.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10);H2D; streamsync; NullKernel;streamsync; D2H; streamsync;endloop(1); +loop(10); H2D; streamsync; NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(100); H2D; streamsync; NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(100); H2D; streamsync; NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(1000); H2D; streamsync; NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(1000); H2D; streamsync; NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(10000); H2D; streamsync; NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(10000); H2D; streamsync; NullKernel; streamsync; D2H; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_kernel.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_kernel.hcm new file mode 100644 index 0000000000..027d89aad0 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_kernel.hcm @@ -0,0 +1,10 @@ +setstream(1); +loop(10); NullKernel; streamsync; endloop(1); +loop(10); NullKernel; streamsync; endloop(1); +loop(100); NullKernel; streamsync; endloop(1); +loop(100); NullKernel; streamsync; endloop(1); +loop(1000); NullKernel; streamsync; endloop(1); +loop(1000); NullKernel; streamsync; endloop(1); +loop(1000); NullKernel; streamsync; endloop(1); +loop(10000); NullKernel; streamsync; endloop(1); +loop(10000); NullKernel; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_kernel_barrier.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_kernel_barrier.hcm new file mode 100644 index 0000000000..fb6a867e7f --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_kernel_barrier.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); NullKernel; streamsync; streamsync; endloop(1); +loop(10); NullKernel; streamsync; streamsync; endloop(1); +loop(100); NullKernel; streamsync; streamsync; endloop(1); +loop(100); NullKernel; streamsync; streamsync; endloop(1); +loop(1000); NullKernel; streamsync; streamsync; endloop(1); +loop(1000); NullKernel; streamsync; streamsync; endloop(1); +loop(10000); NullKernel; streamsync; streamsync; endloop(1); +loop(10000); NullKernel; streamsync; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_kernel_d2h.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_kernel_d2h.hcm new file mode 100644 index 0000000000..2e64472dbd --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_kernel_d2h.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); NullKernel; D2H; streamsync; endloop(1); +loop(10); NullKernel; D2H; streamsync; endloop(1); +loop(100); NullKernel; D2H; streamsync; endloop(1); +loop(100); NullKernel; D2H; streamsync; endloop(1); +loop(1000); NullKernel; D2H; streamsync; endloop(1); +loop(1000); NullKernel; D2H; streamsync; endloop(1); +loop(10000); NullKernel; D2H; streamsync; endloop(1); +loop(10000); NullKernel; D2H; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_kernel_h2d.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_kernel_h2d.hcm new file mode 100644 index 0000000000..b220a69c68 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_kernel_h2d.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); NullKernel; H2D; streamsync; endloop(1); +loop(10); NullKernel; H2D; streamsync; endloop(1); +loop(100); NullKernel; H2D; streamsync; endloop(1); +loop(100); NullKernel; H2D; streamsync; endloop(1); +loop(1000); NullKernel; H2D; streamsync; endloop(1); +loop(1000); NullKernel; H2D; streamsync; endloop(1); +loop(10000); NullKernel; H2D; streamsync; endloop(1); +loop(10000); NullKernel; H2D; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_kernel_sync_d2h.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_kernel_sync_d2h.hcm new file mode 100644 index 0000000000..48b332b1c3 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_kernel_sync_d2h.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(10); NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(100); NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(100); NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(1000); NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(1000); NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(10000); NullKernel; streamsync; D2H; streamsync; endloop(1); +loop(10000); NullKernel; streamsync; D2H; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_kernel_sync_h2d.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_kernel_sync_h2d.hcm new file mode 100644 index 0000000000..5a45d55376 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_kernel_sync_h2d.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); NullKernel; streamsync; H2D; streamsync; endloop(1); +loop(10); NullKernel; streamsync; H2D; streamsync; endloop(1); +loop(100); NullKernel; streamsync; H2D; streamsync; endloop(1); +loop(100); NullKernel; streamsync; H2D; streamsync; endloop(1); +loop(1000); NullKernel; streamsync; H2D; streamsync; endloop(1); +loop(1000); NullKernel; streamsync; H2D; streamsync; endloop(1); +loop(10000); NullKernel; streamsync; H2D; streamsync; endloop(1); +loop(10000); NullKernel; streamsync; H2D; streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_streamcreate.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_streamcreate.hcm new file mode 100644 index 0000000000..1e6aef5dc1 --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_streamcreate.hcm @@ -0,0 +1,2 @@ +setstream(1); +loop(10);setstream(1);setstream(2);setstream(3);setstream(4);setstream(5);streamsync; endloop(1); diff --git a/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_sync.hcm b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_sync.hcm new file mode 100644 index 0000000000..a784013b1a --- /dev/null +++ b/projects/hip/samples/1_Utils/hipCommander/perf/scripts/latency_sync.hcm @@ -0,0 +1,9 @@ +setstream(1); +loop(10); streamsync; endloop(1); +loop(10); streamsync; endloop(1); +loop(100); streamsync; endloop(1); +loop(100); streamsync; endloop(1); +loop(1000); streamsync; endloop(1); +loop(1000); streamsync; endloop(1); +loop(10000); streamsync; endloop(1); +loop(10000); streamsync; endloop(1); From 172161a5b502754c3000a82ba6fd79f03919033e Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Tue, 7 Feb 2017 11:09:54 -0600 Subject: [PATCH 118/281] fixed vector types for c Change-Id: I2330e976060f9a038929cd51be07ae2ee98e81ce [ROCm/hip commit: 3664e8784f7eb9bb5191c356f36f52bff0d50dc6] --- .../include/hip/hcc_detail/hip_vector_types.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/hip_vector_types.h b/projects/hip/include/hip/hcc_detail/hip_vector_types.h index 3e3acb8f29..cd5a09215a 100644 --- a/projects/hip/include/hip/hcc_detail/hip_vector_types.h +++ b/projects/hip/include/hip/hcc_detail/hip_vector_types.h @@ -1131,23 +1131,23 @@ struct longlong4 { } __attribute__((aligned(32))); #define DECLOP_MAKE_ONE_COMPONENT(comp, type) \ -__device__ __host__ static inline type make_##type(comp x) { \ - type ret; \ +__device__ __host__ static inline struct type make_##type(comp x) { \ + struct type ret; \ ret.x = x; \ return ret; \ } #define DECLOP_MAKE_TWO_COMPONENT(comp, type) \ -__device__ __host__ static inline type make_##type(comp x, comp y) { \ - type ret; \ +__device__ __host__ static inline struct type make_##type(comp x, comp y) { \ + struct type ret; \ ret.x = x; \ ret.y = y; \ return ret; \ } #define DECLOP_MAKE_THREE_COMPONENT(comp, type) \ -__device__ __host__ static inline type make_##type(comp x, comp y, comp z) { \ - type ret; \ +__device__ __host__ static inline struct type make_##type(comp x, comp y, comp z) { \ + struct type ret; \ ret.x = x; \ ret.y = y; \ ret.z = z; \ @@ -1155,8 +1155,8 @@ __device__ __host__ static inline type make_##type(comp x, comp y, comp z) { \ } #define DECLOP_MAKE_FOUR_COMPONENT(comp, type) \ -__device__ __host__ static inline type make_##type(comp x, comp y, comp z, comp w) { \ - type ret; \ +__device__ __host__ static inline struct type make_##type(comp x, comp y, comp z, comp w) { \ + struct type ret; \ ret.x = x; \ ret.y = y; \ ret.z = z; \ From e0f59128990cb93c7d42b61782bbd1b371d83578 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Tue, 7 Feb 2017 13:15:36 -0600 Subject: [PATCH 119/281] Fixed HIP for C runtime 1. fixed constant memory test 2. added runtime gcc/g++ test 3. added fix for runtime with gcc/g++ Change-Id: Ie14dad6633411b188bdeea044e140b6d5beabe16 [ROCm/hip commit: 05c8aa1cf536094b5908309988ef8ba8577f4983] --- .../hip/hcc_detail/channel_descriptor.h | 18 +++++++++++++----- .../include/hip/hcc_detail/hip_runtime_api.h | 10 +++++++--- .../hip/include/hip/hcc_detail/hip_texture.h | 1 + .../hip/include/hip/hcc_detail/texture_types.h | 6 +++--- projects/hip/tests/src/g++/hipMalloc.cpp | 8 ++++++++ projects/hip/tests/src/gcc/hipMalloc.c | 8 ++++++++ .../hip/tests/src/kernel/hipTestConstant.cpp | 2 ++ 7 files changed, 42 insertions(+), 11 deletions(-) create mode 100644 projects/hip/tests/src/g++/hipMalloc.cpp create mode 100644 projects/hip/tests/src/gcc/hipMalloc.c diff --git a/projects/hip/include/hip/hcc_detail/channel_descriptor.h b/projects/hip/include/hip/hcc_detail/channel_descriptor.h index 91d48af4cf..85689438e2 100644 --- a/projects/hip/include/hip/hcc_detail/channel_descriptor.h +++ b/projects/hip/include/hip/hcc_detail/channel_descriptor.h @@ -26,12 +26,9 @@ THE SOFTWARE. #include #include -hipChannelFormatDesc hipCreateChannelDesc(int x, int y, int z, int w, hipChannelFormatKind f); +#ifdef __cplusplus -template -static inline hipChannelFormatDesc hipCreateChannelDesc() { - return hipCreateChannelDesc(0, 0, 0, 0, hipChannelFormatKindNone); -} +hipChannelFormatDesc hipCreateChannelDesc(int x, int y, int z, int w, hipChannelFormatKind f); static inline hipChannelFormatDesc hipCreateChannelDescHalf() { int e = (int)sizeof(unsigned short) * 8; @@ -49,6 +46,11 @@ static inline hipChannelFormatDesc hipCreateChannelDescHalf2() return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindFloat); } +template +static inline hipChannelFormatDesc hipCreateChannelDesc() { + return hipCreateChannelDesc(0, 0, 0, 0, hipChannelFormatKindNone); +} + template<> inline hipChannelFormatDesc hipCreateChannelDesc() { @@ -371,4 +373,10 @@ inline hipChannelFormatDesc hipCreateChannelDesc() return hipCreateChannelDesc(e, e, e, e, hipChannelFormatKindSigned); } +#else + +struct hipChannelFormatDesc hipCreateChannelDesc(int x, int y, int z, int w, enum hipChannelFormatKind f); + +#endif + #endif diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h index f9ab03901a..4e5390a968 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h @@ -180,7 +180,7 @@ typedef enum hipMemcpyKind { typedef struct { unsigned int width; unsigned int height; - hipChannelFormatKind f; + enum hipChannelFormatKind f; void* data; //FIXME: generalize this } hipArray; @@ -371,7 +371,7 @@ hipError_t hipDeviceGetCacheConfig ( hipFuncCache_t *cacheConfig ); * Note: Currently, only hipLimitMallocHeapSize is available * */ -hipError_t hipDeviceGetLimit(size_t *pValue, hipLimit_t limit); +hipError_t hipDeviceGetLimit(size_t *pValue, enum hipLimit_t limit); /** @@ -1254,9 +1254,13 @@ hipError_t hipMemGetInfo (size_t * free, size_t * total) ; * * @see hipMalloc, hipMallocPitch, hipFree, hipFreeArray, hipHostMalloc, hipHostFree */ +#if __cplusplus hipError_t hipMallocArray(hipArray** array, const hipChannelFormatDesc* desc, size_t width, size_t height = 0, unsigned int flags = 0); - +#else +hipError_t hipMallocArray(hipArray** array, const struct hipChannelFormatDesc* desc, + size_t width, size_t height, unsigned int flags); +#endif /** * @brief Frees an array on the device. * diff --git a/projects/hip/include/hip/hcc_detail/hip_texture.h b/projects/hip/include/hip/hcc_detail/hip_texture.h index bd44206be4..d60f66ddc2 100644 --- a/projects/hip/include/hip/hcc_detail/hip_texture.h +++ b/projects/hip/include/hip/hcc_detail/hip_texture.h @@ -31,6 +31,7 @@ THE SOFTWARE. */ #include +#include #include #include //#include diff --git a/projects/hip/include/hip/hcc_detail/texture_types.h b/projects/hip/include/hip/hcc_detail/texture_types.h index d9221dc009..107b5d26c1 100644 --- a/projects/hip/include/hip/hcc_detail/texture_types.h +++ b/projects/hip/include/hip/hcc_detail/texture_types.h @@ -34,9 +34,9 @@ enum hipTextureFilterMode }; struct textureReference { - hipTextureFilterMode filterMode; - bool normalized; - hipChannelFormatDesc channelDesc; + enum hipTextureFilterMode filterMode; + unsigned normalized; + struct hipChannelFormatDesc channelDesc; }; #endif diff --git a/projects/hip/tests/src/g++/hipMalloc.cpp b/projects/hip/tests/src/g++/hipMalloc.cpp new file mode 100644 index 0000000000..24e3126c96 --- /dev/null +++ b/projects/hip/tests/src/g++/hipMalloc.cpp @@ -0,0 +1,8 @@ +#include +#include + +int main() +{ + int *Ad; + hipMalloc((void**)&Ad, 1024); +} diff --git a/projects/hip/tests/src/gcc/hipMalloc.c b/projects/hip/tests/src/gcc/hipMalloc.c new file mode 100644 index 0000000000..95e4bf29ea --- /dev/null +++ b/projects/hip/tests/src/gcc/hipMalloc.c @@ -0,0 +1,8 @@ +#include +#include + +int main() +{ + int *Ad; + hipMalloc((void**)&Ad, 1024); +} diff --git a/projects/hip/tests/src/kernel/hipTestConstant.cpp b/projects/hip/tests/src/kernel/hipTestConstant.cpp index 2d637e3f1a..e4d187b4d6 100644 --- a/projects/hip/tests/src/kernel/hipTestConstant.cpp +++ b/projects/hip/tests/src/kernel/hipTestConstant.cpp @@ -26,6 +26,7 @@ THE SOFTWARE. #include #include #include +#include "test_common.h" #define HIP_ASSERT(status) \ assert(status == hipSuccess) @@ -62,4 +63,5 @@ int main() { assert(A[i] == B[i]); } + passed(); } From 655045d722f8f7dee482b43023db9059ceb35bd4 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Wed, 8 Feb 2017 19:43:32 +0300 Subject: [PATCH 120/281] [HIPIFY] Readme.md update. + Launching example. + Delimiter "--" is strongly recommended. + "-x cuda" option is mentioned as well. [ROCm/hip commit: 841510481ed3b85887d7fad359ba9cc31d0823dc] --- projects/hip/hipify-clang/README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/projects/hip/hipify-clang/README.md b/projects/hip/hipify-clang/README.md index 6e58f719b7..3996a63b8c 100644 --- a/projects/hip/hipify-clang/README.md +++ b/projects/hip/hipify-clang/README.md @@ -47,6 +47,14 @@ wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1404/x86_64/c sudo dpkg -i cuda-repo-ubuntu1404_7.5-18_amd64.deb sudo apt-get update && sudo apt-get install cuda-minimal-build-7-5 cuda-curand-dev-7-5 ``` +To set additional options like Language Selection (only "-x cuda" is supported), Preprocessor Definition (-D), Include Path (-I), etc., options delimiter "--" should be used before them, for instance: + +```shell +./hipify-clang -print-stats sort_kernel.cu -- -x cuda -I/srv/git/HIP/include -I/usr/local/cuda-7.5/include -DX=1 +``` +Delimiter "--" is used to separate hipify-clang options (before the delimeter) from clang options (after the delimeter). It is strongly recomended to always specify the delimeter, even if there are no clang specific options at all, in order to avoid possible errors regarding compilation database; in such case delimeter should be the last option in hipify-clang's command line. + +Option "-x clang" is also worth specifying in order to convert source CUDA files with extensions other than standard extensions (*.cu, *.cuh). #### Disclaimer From dbd5346cffa674428e91d25f9d208dc1e2d431f4 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Wed, 8 Feb 2017 19:50:05 +0300 Subject: [PATCH 121/281] [HIPIFY] Readme.md update. [ROCm/hip commit: 9ba480037ae8ed666e3deaa8bb9255e19fd6d072] --- projects/hip/hipify-clang/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/projects/hip/hipify-clang/README.md b/projects/hip/hipify-clang/README.md index 3996a63b8c..850dfb3ffa 100644 --- a/projects/hip/hipify-clang/README.md +++ b/projects/hip/hipify-clang/README.md @@ -47,12 +47,14 @@ wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1404/x86_64/c sudo dpkg -i cuda-repo-ubuntu1404_7.5-18_amd64.deb sudo apt-get update && sudo apt-get install cuda-minimal-build-7-5 cuda-curand-dev-7-5 ``` + To set additional options like Language Selection (only "-x cuda" is supported), Preprocessor Definition (-D), Include Path (-I), etc., options delimiter "--" should be used before them, for instance: ```shell ./hipify-clang -print-stats sort_kernel.cu -- -x cuda -I/srv/git/HIP/include -I/usr/local/cuda-7.5/include -DX=1 ``` -Delimiter "--" is used to separate hipify-clang options (before the delimeter) from clang options (after the delimeter). It is strongly recomended to always specify the delimeter, even if there are no clang specific options at all, in order to avoid possible errors regarding compilation database; in such case delimeter should be the last option in hipify-clang's command line. + +Delimiter "--" is used to separate hipify-clang options (before the delimiter) from clang options (after the delimiter). It is strongly recommended to always specify the delimiter, even if there are no clang specific options at all, in order to avoid possible errors regarding compilation database; in such case delimeter should be the last option in hipify-clang's command line. Option "-x clang" is also worth specifying in order to convert source CUDA files with extensions other than standard extensions (*.cu, *.cuh). From 82c0dcb03fcd2fc329342d823c65bac942661d8b Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Wed, 8 Feb 2017 12:04:05 -0600 Subject: [PATCH 122/281] Fixed Hawaii link issues 1. Split hip_ir.ll to hip_hc.ll and hip_hc_gfx803.ll a. hip_hc.ll contains arch generic ir implementations b. hip_hc_gfx803.ll contains gfx803 (fiji, polaris) specific ir 2. HIPCC can now parse --amdgpu-target=*. a. Usage: hipcc --amdgpu-target=gfx803 --amdgpu-target=gfx701 b. TODO: Convert to --amdgpu-target=gfx803,gfx701 3. With LLC in HCC able to generate native f16 isa, removed inline half asm math ops 4. Fixed threadfence and threadfence_block to use functions in rocdl Change-Id: Ic9a9e3e04139b0d75d2c2a263c030ca77adc1019 [ROCm/hip commit: 01b66dd998a56f5c88764bb18d438f4b731af6ac] --- projects/hip/CMakeLists.txt | 2 +- projects/hip/bin/hipcc | 47 ++++++++-- .../hip/include/hip/hcc_detail/hip_fp16.h | 73 +++------------ .../hip/include/hip/hcc_detail/hip_runtime.h | 12 ++- projects/hip/src/hip_fp16.cpp | 41 +++++++++ projects/hip/src/hip_hc.ll | 30 +++++++ .../hip/src/{hip_ir.ll => hip_hc_gfx803.ll} | 89 ------------------- 7 files changed, 134 insertions(+), 160 deletions(-) create mode 100644 projects/hip/src/hip_hc.ll rename projects/hip/src/{hip_ir.ll => hip_hc_gfx803.ll} (62%) diff --git a/projects/hip/CMakeLists.txt b/projects/hip/CMakeLists.txt index 53663e44b3..9c469afbc1 100644 --- a/projects/hip/CMakeLists.txt +++ b/projects/hip/CMakeLists.txt @@ -218,7 +218,7 @@ add_custom_target(doc COMMAND HIP_PATH=${CMAKE_CURRENT_SOURCE_DIR} doxygen ${CMA # Install hip_hcc if platform is hcc if(HIP_PLATFORM STREQUAL "hcc") install(TARGETS hip_hcc_static hip_hcc hip_device DESTINATION lib) - install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/hip_ir.ll DESTINATION lib) + install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/hip_hc.ll ${CMAKE_CURRENT_SOURCE_DIR}/src/hip_hc_gfx803.ll DESTINATION lib) # Install .hipInfo install(FILES ${PROJECT_BINARY_DIR}/.hipInfo DESTINATION lib) diff --git a/projects/hip/bin/hipcc b/projects/hip/bin/hipcc index e43131501c..777a1b3f9d 100755 --- a/projects/hip/bin/hipcc +++ b/projects/hip/bin/hipcc @@ -70,6 +70,11 @@ if ($verbose & 0x2) { # set if user explicitly requests -stdlib=libc++. (else we default to libstdc++ for better interop with g++): $setStdLib = 0; # TODO - set to 0 +$target_gfx701 = 0; +$target_gfx801 = 0; +$target_gfx802 = 0; +$target_gfx803 = 0; + if ($HIP_PLATFORM eq "hcc") { $HSA_PATH=$ENV{'HSA_PATH'} // "/opt/rocm/hsa"; @@ -129,18 +134,25 @@ if ($HIP_PLATFORM eq "hcc") { } $HIPLDFLAGS .= " -L$HSA_PATH/lib -L$ROCM_PATH/lib -lhsa-runtime64 -lhc_am -lhsakmt"; + $ENV{HCC_EXTRA_LIBRARIES}="$HIP_PATH/lib/hip_hc.ll\n"; + # Handle ROCm target platform - if ($ROCM_TARGET eq "fiji") { - $HIPLDFLAGS .= " --amdgpu-target=gfx803"; - } - if ($ROCM_TARGET eq "carrizo") { - $HIPLDFLAGS .= " --amdgpu-target=gfx801"; - } - if ($ROCM_TARGET eq "hawaii") { + if ($target_gfx701 eq 1) { $HIPLDFLAGS .= " --amdgpu-target=gfx701"; } - if ($ROCM_TARGET eq "polaris") { + if ($target_gfx801 eq 1) { + $HIPLDFLAGS .= " --amdgpu-target=gfx801"; + } + if ($target_gfx802 eq 1) { + $HIPLDFLAGS .= " --amdgpu-target=gfx802"; + } + if ($target_gfx803 eq 1) { $HIPLDFLAGS .= " --amdgpu-target=gfx803"; + $ENV{HIP_HC_IR_GFX803}="$HIP_PATH/lib/hip_hc_gfx803.ll\n"; + } + if ($target_gfx701 eq 0 and $target_gfx801 eq 0 and $target_gfx802 eq 0 and $target_gfx803 eq 0) + { + $HIPLDFLAGS .= " --amdgpu-target=gfx701 --amdgpu-target=gfx801 --amdgpu-target=gfx802 --amdgpu-target=gfx803"; } # Add trace marker library: @@ -222,7 +234,8 @@ if($HIP_PLATFORM eq "hcc"){ if(($HIP_PLATFORM eq "hcc")){ $EXPORT_LL=" "; - $ENV{HCC_EXTRA_LIBRARIES}="$HIP_PATH/lib/hip_ir.ll\n"; + $ENV{HCC_EXTRA_LIBRARIES}="$HIP_PATH/lib/hip_hc.ll\n"; + $ENV{HIP_HC_IR_FILE}=""; } if($HIP_PLATFORM eq "nvcc"){ @@ -261,6 +274,22 @@ foreach $arg (@ARGV) $HIPCXXFLAGS .= " -stdlib=libc++"; $setStdLib = 1; } + if($arg eq '--amdgpu-target=gfx701') + { + $target_gfx701 = 1; + } + if($arg eq '--amdgpu-target=gfx801') + { + $target_gfx801 = 1; + } + if($arg eq '--amdgpu-target=gfx802') + { + $target_gfx802 = 1; + } + if($arg eq '--amdgpu-target=gfx803') + { + $target_gfx803 = 1; + } if(($trimarg eq '-stdlib=libstdc++') and ($setStdLib eq 0)) { $HIPCXXFLAGS .= " -stdlib=libstdc++"; diff --git a/projects/hip/include/hip/hcc_detail/hip_fp16.h b/projects/hip/include/hip/hcc_detail/hip_fp16.h index 67d1fe4e06..2c7c23440c 100644 --- a/projects/hip/include/hip/hcc_detail/hip_fp16.h +++ b/projects/hip/include/hip/hcc_detail/hip_fp16.h @@ -39,16 +39,16 @@ typedef struct __attribute__((aligned(4))){ /* Half Arithmetic Functions */ -__device__ static __half __hadd(const __half a, const __half b); -__device__ static __half __hadd_sat(__half a, __half b); -__device__ static __half __hfma(__half a, __half b, __half c); -__device__ static __half __hfma_sat(__half a, __half b, __half c); -__device__ static __half __hmul(__half a, __half b); -__device__ static __half __hmul_sat(__half a, __half b); -__device__ static __half __hneg(__half a); -__device__ static __half __hsub(__half a, __half b); -__device__ static __half __hsub_sat(__half a, __half b); -__device__ static __half hdiv(__half a, __half b); +__device__ __half __hadd(const __half a, const __half b); +__device__ __half __hadd_sat(__half a, __half b); +__device__ __half __hfma(__half a, __half b, __half c); +__device__ __half __hfma_sat(__half a, __half b, __half c); +__device__ __half __hmul(__half a, __half b); +__device__ __half __hmul_sat(__half a, __half b); +__device__ __half __hneg(__half a); +__device__ __half __hsub(__half a, __half b); +__device__ __half __hsub_sat(__half a, __half b); +__device__ __half hdiv(__half a, __half b); /* Half2 Arithmetic Functions @@ -211,11 +211,6 @@ __device__ __half __ushort2half_ru(unsigned short int i); __device__ __half __ushort2half_rz(unsigned short int i); __device__ __half __ushort_as_half(const unsigned short int i); -extern "C" __half __hip_hc_ir_hadd_half(__half, __half); -extern "C" __half __hip_hc_ir_hfma_half(__half, __half, __half); -extern "C" __half __hip_hc_ir_hmul_half(__half, __half); -extern "C" __half __hip_hc_ir_hsub_half(__half, __half); - extern "C" int __hip_hc_ir_hadd2_int(int, int); extern "C" int __hip_hc_ir_hfma2_int(int, int, int); extern "C" int __hip_hc_ir_hmul2_int(int, int); @@ -244,46 +239,6 @@ extern "C" int __hip_hc_ir_h2sin_int(int); extern "C" int __hip_hc_ir_h2sqrt_int(int); extern "C" int __hip_hc_ir_h2trunc_int(int); -__device__ static inline __half __hadd(const __half a, const __half b) { - return __hip_hc_ir_hadd_half(a, b); -} - -__device__ static inline __half __hadd_sat(__half a, __half b) { - return __hip_hc_ir_hadd_half(a, b); -} - -__device__ static inline __half __hfma(__half a, __half b, __half c) { - return __hip_hc_ir_hfma_half(a, b, c); -} - -__device__ static inline __half __hfma_sat(__half a, __half b, __half c) { - return __hip_hc_ir_hfma_half(a, b, c); -} - -__device__ static inline __half __hmul(__half a, __half b) { - return __hip_hc_ir_hmul_half(a, b); -} - -__device__ static inline __half __hmul_sat(__half a, __half b) { - return __hip_hc_ir_hmul_half(a, b); -} - -__device__ static inline __half __hneg(__half a) { - return -a; -} - -__device__ static inline __half __hsub(__half a, __half b) { - return __hip_hc_ir_hsub_half(a, b); -} - -__device__ static inline __half __hsub_sat(__half a, __half b) { - return __hip_hc_ir_hsub_half(a, b); -} - -__device__ static inline __half hdiv(__half a, __half b) { - return a/b; -} - /* Half2 Arithmetic Functions */ @@ -360,11 +315,11 @@ __device__ static inline __half hcos(const __half h) { } __device__ static inline __half hexp(const __half h) { - return __hip_hc_ir_hexp2_half(__hip_hc_ir_hmul_half(h, 1.442694)); + return __hip_hc_ir_hexp2_half(__hmul(h, 1.442694)); } __device__ static inline __half hexp10(const __half h) { - return __hip_hc_ir_hexp2_half(__hip_hc_ir_hmul_half(h, 3.3219281)); + return __hip_hc_ir_hexp2_half(__hmul(h, 3.3219281)); } __device__ static inline __half hexp2(const __half h) { @@ -376,11 +331,11 @@ __device__ static inline __half hfloor(const __half h) { } __device__ static inline __half hlog(const __half h) { - return __hip_hc_ir_hmul_half(__hip_hc_ir_hlog2_half(h), 0.693147); + return __hmul(__hip_hc_ir_hlog2_half(h), 0.693147); } __device__ static inline __half hlog10(const __half h) { - return __hip_hc_ir_hmul_half(__hip_hc_ir_hlog2_half(h), 0.301029); + return __hmul(__hip_hc_ir_hlog2_half(h), 0.301029); } __device__ static inline __half hlog2(const __half h) { diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime.h b/projects/hip/include/hip/hcc_detail/hip_runtime.h index aa6fe06337..98c3ada969 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime.h @@ -277,6 +277,10 @@ __device__ __attribute__((address_space(3))) void* __get_dynamicgroupbaseptr(); * On AMD platforms, the threadfence* routines are currently empty stubs. */ +extern __attribute__((const)) __device__ void __hip_hc_threadfence() __asm("__llvm_fence_sc_dev"); +extern __attribute__((const)) __device__ void __hip_hc_threadfence_block() __asm("__llvm_fence_sc_wg"); + + /** * @brief threadfence_block makes writes visible to threads running in same block. * @@ -287,7 +291,9 @@ __device__ __attribute__((address_space(3))) void* __get_dynamicgroupbaseptr(); * @warning __threadfence_block is a stub and map to no-op. */ // __device__ void __threadfence_block(void); -extern "C" __device__ void __threadfence_block(void); +__device__ static inline void __threadfence_block(void) { + return __hip_hc_threadfence_block(); +} /** * @brief threadfence makes wirtes visible to other threads running on same GPU. @@ -299,7 +305,9 @@ extern "C" __device__ void __threadfence_block(void); * @warning __threadfence is a stub and map to no-op, application should set "export HSA_DISABLE_CACHE=1" to disable both L1 and L2 caches. */ // __device__ void __threadfence(void) __attribute__((deprecated("Provided for compile-time compatibility, not yet functional"))); -extern "C" __device__ void __threadfence(void); +__device__ static inline void __threadfence(void) { + return __hip_hc_threadfence(); +} /** * @brief threadfence_system makes writes to pinned system memory visible on host CPU. diff --git a/projects/hip/src/hip_fp16.cpp b/projects/hip/src/hip_fp16.cpp index ac79ddba08..b306a9d3de 100644 --- a/projects/hip/src/hip_fp16.cpp +++ b/projects/hip/src/hip_fp16.cpp @@ -32,6 +32,47 @@ struct hipHalfHolder{ #define HINF 65504 static struct hipHalfHolder __hInfValue = {HINF}; + +__device__ __half __hadd(__half a, __half b) { + return a + b; +} + +__device__ __half __hadd_sat(__half a, __half b) { + return a + b; +} + +__device__ __half __hfma(__half a, __half b, __half c) { + return a * b + c; +} + +__device__ __half __hfma_sat(__half a, __half b, __half c) { + return a * b + c; +} + +__device__ __half __hmul(__half a, __half b) { + return a * b; +} + +__device__ __half __hmul_sat(__half a, __half b) { + return a * b; +} + +__device__ __half __hneg(__half a) { + return -a; +} + +__device__ __half __hsub(__half a, __half b) { + return a - b; +} + +__device__ __half __hsub_sat(__half a, __half b) { + return a - b; +} + +__device__ __half hdiv(__half a, __half b) { + return a / b; +} + /* Half comparision Functions */ diff --git a/projects/hip/src/hip_hc.ll b/projects/hip/src/hip_hc.ll new file mode 100644 index 0000000000..aba9205912 --- /dev/null +++ b/projects/hip/src/hip_hc.ll @@ -0,0 +1,30 @@ +target datalayout = "e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64" +target triple = "amdgcn--amdhsa" + +define i32 @__hip_hc_ir_mul24_int(i32 %a, i32 %b) #1 { + %1 = tail call i32 asm sideeffect "v_mul_i32_i24 $0, $1, $2","=v,v,v"(i32 %a, i32 %b) + ret i32 %1 +} + +define i32 @__hip_hc_ir_umul24_int(i32 %a, i32 %b) #1 { + %1 = tail call i32 asm sideeffect "v_mul_u32_u24 $0, $1, $2","=v,v,v"(i32 %a, i32 %b) + ret i32 %1 +} + +define i32 @__hip_hc_ir_mulhi_int(i32 %a, i32 %b) #1 { + %1 = tail call i32 asm sideeffect "v_mul_hi_i32 $0, $1, $2","=v,v,v"(i32 %a, i32 %b) + ret i32 %1 +} + +define i32 @__hip_hc_ir_umulhi_int(i32 %a, i32 %b) #1 { + %1 = tail call i32 asm sideeffect "v_mul_hi_u32 $0, $1, $2","=v,v,v"(i32 %a, i32 %b) + ret i32 %1 +} + +define i32 @__hip_hc_ir_usad_int(i32 %a, i32 %b, i32 %c) #1 { + %1 = tail call i32 asm sideeffect "v_sad_u32 $0, $1, $2, $3","=v,v,v,v"(i32 %a, i32 %b, i32 %c) + ret i32 %1 +} + +attributes #1 = { alwaysinline nounwind } + diff --git a/projects/hip/src/hip_ir.ll b/projects/hip/src/hip_hc_gfx803.ll similarity index 62% rename from projects/hip/src/hip_ir.ll rename to projects/hip/src/hip_hc_gfx803.ll index 5a14266086..0080fc7d81 100644 --- a/projects/hip/src/hip_ir.ll +++ b/projects/hip/src/hip_hc_gfx803.ll @@ -2,65 +2,6 @@ target datalayout = "e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-i64: target triple = "amdgcn--amdhsa" -define void @__threadfence() #1 { - fence syncscope(2) seq_cst - ret void -} - -define void @__threadfence_block() #1 { - fence syncscope(3) seq_cst - ret void -} - -; Lightning does not support inline asm for 16-bit data types -; So, bitcast half to short and then extend to 32bit i32 -; After inline asm, convert back to half -define half @__hip_hc_ir_hadd_half(half %a, half %b) #1 { - %1 = bitcast half %a to i16 - %2 = bitcast half %b to i16 - %3 = zext i16 %1 to i32 - %4 = zext i16 %2 to i32 - %5 = tail call i32 asm "v_add_f16 $0, $1, $2","=v,v,v"(i32 %3, i32 %4) - %6 = trunc i32 %5 to i16 - %7 = bitcast i16 %6 to half - ret half %7 -} - -define half @__hip_hc_ir_hsub_half(half %a, half %b) #1 { - %1 = bitcast half %a to i16 - %2 = bitcast half %b to i16 - %3 = zext i16 %1 to i32 - %4 = zext i16 %2 to i32 - %5 = tail call i32 asm "v_sub_f16 $0, $1, $2","=v,v,v"(i32 %3, i32 %4) - %6 = trunc i32 %5 to i16 - %7 = bitcast i16 %6 to half - ret half %7 -} - -define half @__hip_hc_ir_hmul_half(half %a, half %b) #1 { - %1 = bitcast half %a to i16 - %2 = bitcast half %b to i16 - %3 = zext i16 %1 to i32 - %4 = zext i16 %2 to i32 - %5 = tail call i32 asm "v_mul_f16 $0, $1, $2","=v,v,v"(i32 %3, i32 %4) - %6 = trunc i32 %5 to i16 - %7 = bitcast i16 %6 to half - ret half %7 -} - -define half @__hip_hc_ir_hfma_half(half %a, half %b, half %c) #1 { - %1 = bitcast half %a to i16 - %2 = bitcast half %b to i16 - %3 = bitcast half %c to i16 - %4 = zext i16 %1 to i32 - %5 = zext i16 %2 to i32 - %6 = zext i16 %3 to i32 - %7 = tail call i32 asm "v_mad_f16 $0, $1, $2, $3","=v,v,v,v"(i32 %4, i32 %5, i32 %6) - %8 = trunc i32 %7 to i16 - %9 = bitcast i16 %8 to half - ret half %9 -} - define i32 @__hip_hc_ir_hadd2_int(i32 %a, i32 %b) #1 { %1 = tail call i32 asm sideeffect "v_add_f16 $0, $1, $2","=v,v,v"(i32 %a, i32 %b) tail call void asm sideeffect "v_add_f16_sdwa $0, $1, $2 dst_sel:WORD_1 dst_unused:UNUSED_PRESERVE src0_sel:WORD_1 src1_sel:WORD_1","v,v,v"(i32 %1, i32 %a, i32 %b) @@ -146,34 +87,4 @@ define i32 @__hip_hc_ir_h2trunc_int(i32 %a) #1 { ret i32 %1 } -define i32 @__hip_hc_ir_mul24_int(i32 %a, i32 %b) #1 { - %1 = tail call i32 asm sideeffect "v_mul_i32_i24 $0, $1, $2","=v,v,v"(i32 %a, i32 %b) - ret i32 %1 -} - -define i32 @__hip_hc_ir_umul24_int(i32 %a, i32 %b) #1 { - %1 = tail call i32 asm sideeffect "v_mul_u32_u24 $0, $1, $2","=v,v,v"(i32 %a, i32 %b) - ret i32 %1 -} - -define i32 @__hip_hc_ir_mulhi_int(i32 %a, i32 %b) #1 { - %1 = tail call i32 asm sideeffect "v_mul_hi_i32 $0, $1, $2","=v,v,v"(i32 %a, i32 %b) - ret i32 %1 -} - -define i32 @__hip_hc_ir_umulhi_int(i32 %a, i32 %b) #1 { - %1 = tail call i32 asm sideeffect "v_mul_hi_u32 $0, $1, $2","=v,v,v"(i32 %a, i32 %b) - ret i32 %1 -} - -define i32 @__hip_hc_ir_usad_int(i32 %a, i32 %b, i32 %c) #1 { - %1 = tail call i32 asm sideeffect "v_sad_u32 $0, $1, $2, $3","=v,v,v,v"(i32 %a, i32 %b, i32 %c) - ret i32 %1 -} - -define i32 @__hip_hc_ir_sadu8_int(i32 %a, i32 %b, i32 %c) #1 { - %1 = tail call i32 asm sideeffect "v_sad_u8 $0, $1, $2 $3","=v,v,v,v"(i32 %a, i32 %b, i32 %c) - ret i32 %1 -} - attributes #1 = { alwaysinline nounwind } From c692cd5d4ada4db9d697babdf9146ec4b0f61d75 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Wed, 8 Feb 2017 12:19:06 -0600 Subject: [PATCH 123/281] include arch specific ir on fallback path Change-Id: Ib04996aae2c21eb73ef2a9f6305915e0caccd704 [ROCm/hip commit: 27d2fc99ca083c44c312b7f05d11ae38ffa75495] --- projects/hip/bin/hipcc | 1 + .../hip/tests/src/deviceLib/hipTestHalf.cpp | 36 ++++--------------- 2 files changed, 7 insertions(+), 30 deletions(-) diff --git a/projects/hip/bin/hipcc b/projects/hip/bin/hipcc index 777a1b3f9d..7df674f57b 100755 --- a/projects/hip/bin/hipcc +++ b/projects/hip/bin/hipcc @@ -153,6 +153,7 @@ if ($HIP_PLATFORM eq "hcc") { if ($target_gfx701 eq 0 and $target_gfx801 eq 0 and $target_gfx802 eq 0 and $target_gfx803 eq 0) { $HIPLDFLAGS .= " --amdgpu-target=gfx701 --amdgpu-target=gfx801 --amdgpu-target=gfx802 --amdgpu-target=gfx803"; + $ENV{HIP_HC_IR_GFX803}="$HIP_PATH/lib/hip_hc_gfx803.ll\n"; } # Add trace marker library: diff --git a/projects/hip/tests/src/deviceLib/hipTestHalf.cpp b/projects/hip/tests/src/deviceLib/hipTestHalf.cpp index 7455037923..2284148bb5 100644 --- a/projects/hip/tests/src/deviceLib/hipTestHalf.cpp +++ b/projects/hip/tests/src/deviceLib/hipTestHalf.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights @@ -17,40 +17,16 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include +#include #include #include "hip/hip_runtime_api.h" -#define DSIZE 4 -#define SCF 0.5f -#define nTPB 256 -__global__ void half_scale_kernel(hipLaunchParm lp, float *din, float *dout, int dsize){ - - int idx = hipThreadIdx_x+ hipBlockDim_x*hipBlockIdx_x; - if (idx < dsize){ - __half scf = __float2half(SCF); - __half kin = __float2half(din[idx]); - __half kout; - - kout = __hmul(kin, scf); - -// kout = cvt_float_to_half(cvt_half_to_float(kin)*cvt_half_to_float(scf)); - - dout[idx] = __half2float(kout); - } +__global__ void halfMath(hipLaunchParm lp, half *A, half *B, half *C) { + int tx = hipThreadIdx_x; + __half a = A[tx]; + } int main(){ - float *hin, *hout, *din, *dout; - hin = (float *)malloc(DSIZE*sizeof(float)); - hout = (float *)malloc(DSIZE*sizeof(float)); - for (int i = 0; i < DSIZE; i++) hin[i] = i; - hipMalloc(&din, DSIZE*sizeof(float)); - hipMalloc(&dout, DSIZE*sizeof(float)); - hipMemcpy(din, hin, DSIZE*sizeof(float), hipMemcpyHostToDevice); - hipLaunchKernel(half_scale_kernel, dim3((DSIZE+nTPB-1)/nTPB),dim3(nTPB), 0, 0, din, dout, DSIZE); - hipMemcpy(hout, dout, DSIZE*sizeof(float), hipMemcpyDeviceToHost); - for (int i = 0; i < DSIZE; i++) printf("%f\n", hout[i]); - return 0; } From 8794954411d5933e67013b0c20a3c183973659ee Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Wed, 8 Feb 2017 14:06:01 -0600 Subject: [PATCH 124/281] fixed hipcc for new compiler flags Change-Id: I49ec059be20ff26b7482c84d91ab7a43826c6a8d [ROCm/hip commit: 55d92833fb771d724cc81c6a7eabd184cd0ac38f] --- projects/hip/bin/hipcc | 48 ++++++++++--------- .../hip/tests/src/deviceLib/hipTestHalf.cpp | 43 ++++++++++++++++- 2 files changed, 67 insertions(+), 24 deletions(-) diff --git a/projects/hip/bin/hipcc b/projects/hip/bin/hipcc index 7df674f57b..2a16b5702a 100755 --- a/projects/hip/bin/hipcc +++ b/projects/hip/bin/hipcc @@ -134,28 +134,6 @@ if ($HIP_PLATFORM eq "hcc") { } $HIPLDFLAGS .= " -L$HSA_PATH/lib -L$ROCM_PATH/lib -lhsa-runtime64 -lhc_am -lhsakmt"; - $ENV{HCC_EXTRA_LIBRARIES}="$HIP_PATH/lib/hip_hc.ll\n"; - - # Handle ROCm target platform - if ($target_gfx701 eq 1) { - $HIPLDFLAGS .= " --amdgpu-target=gfx701"; - } - if ($target_gfx801 eq 1) { - $HIPLDFLAGS .= " --amdgpu-target=gfx801"; - } - if ($target_gfx802 eq 1) { - $HIPLDFLAGS .= " --amdgpu-target=gfx802"; - } - if ($target_gfx803 eq 1) { - $HIPLDFLAGS .= " --amdgpu-target=gfx803"; - $ENV{HIP_HC_IR_GFX803}="$HIP_PATH/lib/hip_hc_gfx803.ll\n"; - } - if ($target_gfx701 eq 0 and $target_gfx801 eq 0 and $target_gfx802 eq 0 and $target_gfx803 eq 0) - { - $HIPLDFLAGS .= " --amdgpu-target=gfx701 --amdgpu-target=gfx801 --amdgpu-target=gfx802 --amdgpu-target=gfx803"; - $ENV{HIP_HC_IR_GFX803}="$HIP_PATH/lib/hip_hc_gfx803.ll\n"; - } - # Add trace marker library: # TODO - once we cleanly separate the HIP API headers from HIP library headers this logic should move to CMakebuild option - apps do not need to see the marker library. if ($HIP_ATP_MARKER) { @@ -352,6 +330,32 @@ foreach $arg (@ARGV) $toolArgs .= " $arg" unless $swallowArg; } +if($HIP_PLATFORM eq "hcc"){ + + $ENV{HCC_EXTRA_LIBRARIES}="$HIP_PATH/lib/hip_hc.ll\n"; + + # Handle ROCm target platform + if ($target_gfx701 eq 1) { + $HIPLDFLAGS .= " --amdgpu-target=gfx701"; + } + if ($target_gfx801 eq 1) { + $HIPLDFLAGS .= " --amdgpu-target=gfx801"; + } + if ($target_gfx802 eq 1) { + $HIPLDFLAGS .= " --amdgpu-target=gfx802"; + } + if ($target_gfx803 eq 1) { + $HIPLDFLAGS .= " --amdgpu-target=gfx803"; + $ENV{HIP_HC_IR_GFX803}="$HIP_PATH/lib/hip_hc_gfx803.ll\n"; + } + if ($target_gfx701 eq 0 and $target_gfx801 eq 0 and $target_gfx802 eq 0 and $target_gfx803 eq 0) + { + $HIPLDFLAGS .= " --amdgpu-target=gfx701 --amdgpu-target=gfx801 --amdgpu-target=gfx802 --amdgpu-target=gfx803"; + $ENV{HIP_HC_IR_GFX803}="$HIP_PATH/lib/hip_hc_gfx803.ll\n"; + } + +} + if ($hasC and $HIP_PLATFORM eq 'nvcc') { $HIPCXXFLAGS .= " -x cu"; } diff --git a/projects/hip/tests/src/deviceLib/hipTestHalf.cpp b/projects/hip/tests/src/deviceLib/hipTestHalf.cpp index 2284148bb5..997c445a10 100644 --- a/projects/hip/tests/src/deviceLib/hipTestHalf.cpp +++ b/projects/hip/tests/src/deviceLib/hipTestHalf.cpp @@ -21,12 +21,51 @@ THE SOFTWARE. #include #include "hip/hip_runtime_api.h" -__global__ void halfMath(hipLaunchParm lp, half *A, half *B, half *C) { +#define LEN 64 +#define HALF_SIZE 64*sizeof(__half) +#define HALF2_SIZE 64*sizeof(__half2) + +__global__ void __halfMath(hipLaunchParm lp, __half *A, __half *B, __half *C) { int tx = hipThreadIdx_x; __half a = A[tx]; - + __half b = B[tx]; + __half c = C[tx]; + c = __hadd(a, c); + c = __hadd_sat(b, c); + c = __hfma(a, c, b); + c = __hfma_sat(b, c, a); + c = __hsub(a, c); + c = __hsub_sat(b, c); + c = __hmul(a, c); + c = __hmul_sat(b, c); + c = hdiv(a, c); +} + +__global__ void __half2Math(hipLaunchParm lp, __half2 *A, __half2 *B, __half2 *C) { + int tx = hipThreadIdx_x; + __half2 a = A[tx]; + __half2 b = B[tx]; + __half2 c = C[tx]; + c = __hadd2(a, c); + c = __hadd2_sat(b, c); + c = __hfma2(a, c, b); + c = __hfma2_sat(b, c, a); + c = __hsub2(a, c); + c = __hsub2_sat(b, c); + c = __hmul2(a, c); + c = __hmul2_sat(b, c); } int main(){ + __half *A, *B, *C; + hipMalloc(&A, HALF_SIZE); + hipMalloc(&B, HALF_SIZE); + hipMalloc(&C, HALF_SIZE); + hipLaunchKernel(__halfMath, dim3(1,1,1), dim3(LEN,1,1), 0, 0, A, B, C); + __half2 *A2, *B2, *C2; + hipMalloc(&A, HALF2_SIZE); + hipMalloc(&B, HALF2_SIZE); + hipMalloc(&C, HALF2_SIZE); + hipLaunchKernel(__half2Math, dim3(1,1,1), dim3(LEN,1,1), 0, 0, A2, B2, C2); } From 036a95a4db28465d8b127085f0f4545084b087b2 Mon Sep 17 00:00:00 2001 From: pensun Date: Wed, 8 Feb 2017 16:19:28 -0600 Subject: [PATCH 125/281] Add pseudo code example for hip_bugs.md Change-Id: Ia2af8e6165faeb3fbb81428e20d4dc5b19b2fa9e [ROCm/hip commit: 79978182f9f858ce5a9fc94c0d9d52ec7c8833ce] --- projects/hip/docs/markdown/hip_bugs.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/projects/hip/docs/markdown/hip_bugs.md b/projects/hip/docs/markdown/hip_bugs.md index 834cd9f8ce..3274ed5b5c 100644 --- a/projects/hip/docs/markdown/hip_bugs.md +++ b/projects/hip/docs/markdown/hip_bugs.md @@ -30,4 +30,17 @@ Reason is that the hipLaunchKernel macro locks the stream. If kernel paramters are actually function calls which invoke other hip apis (i.e. memcpy) to the same stream, then deadlock occurs. To workaround, try: -Move the function calls so they occur outside the hipLaunchKernel macro, store results in temps, then use the tems inside the kernel. \ No newline at end of file +Move the function calls so they occur outside the hipLaunchKernel macro, store results in temps, then use the tems inside the kernel. + +``` +// Example pseudo code causing system hang: +// "bottom[0]->gpu_data()" calls hipMemcpy() implicitly and using the same stream, cause deadlock condition. +hipLaunchKernel(HIP_KERNEL_NAME(LRNComputeDiff),dim3(CAFFE_GET_BLOCKS(n_threads)), dim3(CAFFE_HIP_NUM_THREADS), 0, 0, n_threads, + bottom[0]->gpu_data()); + +// Move "gpu_data()" ouside of hipLaunchKernel to avoid hang. +auto bot_gpu_data = bottom[0]->gpu_data(); +hipLaunchKernel( LRNComputeDiff, dim3(CAFFE_GET_BLOCKS(n_threads)), dim3(CAFFE_HIP_NUM_THREADS), 0, 0, n_threads, + bot_gpu_data); + +``` \ No newline at end of file From d48f7e93ccd1f25aa07ef996fcded89600c96e0d Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Wed, 8 Feb 2017 19:45:32 -0600 Subject: [PATCH 126/281] added architecture specific macros 1. Added __HIP_ARCH_GFXNUM__ 2. Usage, -D__HIP_ARCH_GFX803__=1 Change-Id: I68b3a85d62cfab3a45d2b7a70cb3518ab2565236 [ROCm/hip commit: 9a1989193acf5199dcd4ac7a8259067a2f1b271e] --- projects/hip/bin/hipcc | 8 ++++++-- projects/hip/tests/src/deviceLib/hipTestHalf.cpp | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/projects/hip/bin/hipcc b/projects/hip/bin/hipcc index 2a16b5702a..944fc04135 100755 --- a/projects/hip/bin/hipcc +++ b/projects/hip/bin/hipcc @@ -266,7 +266,7 @@ foreach $arg (@ARGV) $target_gfx802 = 1; } if($arg eq '--amdgpu-target=gfx803') - { + { $target_gfx803 = 1; } if(($trimarg eq '-stdlib=libstdc++') and ($setStdLib eq 0)) @@ -337,18 +337,22 @@ if($HIP_PLATFORM eq "hcc"){ # Handle ROCm target platform if ($target_gfx701 eq 1) { $HIPLDFLAGS .= " --amdgpu-target=gfx701"; + $HIPCXXFLAGS .= " -D__HIP_ARCH_GFX701__=1 "; } if ($target_gfx801 eq 1) { $HIPLDFLAGS .= " --amdgpu-target=gfx801"; + $HIPCXXFLAGS .= " -D__HIP_ARCH_GFX801__=1 "; } if ($target_gfx802 eq 1) { $HIPLDFLAGS .= " --amdgpu-target=gfx802"; + $HIPCXXFLAGS .= " -D__HIP_ARCH_GFX802__=1 "; } if ($target_gfx803 eq 1) { $HIPLDFLAGS .= " --amdgpu-target=gfx803"; + $HIPCXXFLAGS .= " -D__HIP_ARCH_GFX803__=1 "; $ENV{HIP_HC_IR_GFX803}="$HIP_PATH/lib/hip_hc_gfx803.ll\n"; } - if ($target_gfx701 eq 0 and $target_gfx801 eq 0 and $target_gfx802 eq 0 and $target_gfx803 eq 0) + if ($target_gfx701 eq 0 and $target_gfx801 eq 0 and $target_gfx802 eq 0 and $target_gfx803 eq 0) { $HIPLDFLAGS .= " --amdgpu-target=gfx701 --amdgpu-target=gfx801 --amdgpu-target=gfx802 --amdgpu-target=gfx803"; $ENV{HIP_HC_IR_GFX803}="$HIP_PATH/lib/hip_hc_gfx803.ll\n"; diff --git a/projects/hip/tests/src/deviceLib/hipTestHalf.cpp b/projects/hip/tests/src/deviceLib/hipTestHalf.cpp index 997c445a10..94a3882eea 100644 --- a/projects/hip/tests/src/deviceLib/hipTestHalf.cpp +++ b/projects/hip/tests/src/deviceLib/hipTestHalf.cpp @@ -25,6 +25,8 @@ THE SOFTWARE. #define HALF_SIZE 64*sizeof(__half) #define HALF2_SIZE 64*sizeof(__half2) +#if __HIP_ARCH_GFX803__ > 0 + __global__ void __halfMath(hipLaunchParm lp, __half *A, __half *B, __half *C) { int tx = hipThreadIdx_x; __half a = A[tx]; @@ -56,6 +58,8 @@ __global__ void __half2Math(hipLaunchParm lp, __half2 *A, __half2 *B, __half2 *C c = __hmul2_sat(b, c); } +#endif + int main(){ __half *A, *B, *C; hipMalloc(&A, HALF_SIZE); From 4e9f1e8a66398209c033c5b0f10144cdbd5ebe3d Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Thu, 9 Feb 2017 14:38:39 +0530 Subject: [PATCH 127/281] Fix arch specific hcc extra libs env var Change-Id: I7429da2f1cb98750d6a9601e7e5bde844a098487 [ROCm/hip commit: d14b239dd3496f44d8e70da5d83e57e17b68690f] --- projects/hip/bin/hipcc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/hip/bin/hipcc b/projects/hip/bin/hipcc index 944fc04135..2b84041e50 100755 --- a/projects/hip/bin/hipcc +++ b/projects/hip/bin/hipcc @@ -350,12 +350,12 @@ if($HIP_PLATFORM eq "hcc"){ if ($target_gfx803 eq 1) { $HIPLDFLAGS .= " --amdgpu-target=gfx803"; $HIPCXXFLAGS .= " -D__HIP_ARCH_GFX803__=1 "; - $ENV{HIP_HC_IR_GFX803}="$HIP_PATH/lib/hip_hc_gfx803.ll\n"; + $ENV{HCC_EXTRA_LIBRARIES_GFX803}="$HIP_PATH/lib/hip_hc_gfx803.ll\n"; } if ($target_gfx701 eq 0 and $target_gfx801 eq 0 and $target_gfx802 eq 0 and $target_gfx803 eq 0) { $HIPLDFLAGS .= " --amdgpu-target=gfx701 --amdgpu-target=gfx801 --amdgpu-target=gfx802 --amdgpu-target=gfx803"; - $ENV{HIP_HC_IR_GFX803}="$HIP_PATH/lib/hip_hc_gfx803.ll\n"; + $ENV{HCC_EXTRA_LIBRARIES_GFX803}="$HIP_PATH/lib/hip_hc_gfx803.ll\n"; } } From 4c505556537702aa20cdd796db9f36f149b0df28 Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Thu, 9 Feb 2017 14:48:22 +0530 Subject: [PATCH 128/281] Disable failing directed tests - hipTestDeviceSymbol - hipTestConstant - hipTestMallocKernel Change-Id: Ibfe9fc0b8a59882f1de64b42e18777a7bd56ee97 [ROCm/hip commit: 5754d641e06b000000de288b75721b223d2316c1] --- projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp | 2 +- projects/hip/tests/src/kernel/hipTestConstant.cpp | 2 +- projects/hip/tests/src/kernel/hipTestMallocKernel.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp b/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp index 70fe794f67..ed4d3902c5 100644 --- a/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp +++ b/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp @@ -18,7 +18,7 @@ THE SOFTWARE. */ /* HIT_START - * BUILD: %t %s ../test_common.cpp + * BUILD: %t %s ../test_common.cpp EXCLUDE_HIP_PLATFORM all * RUN: %t * HIT_END */ diff --git a/projects/hip/tests/src/kernel/hipTestConstant.cpp b/projects/hip/tests/src/kernel/hipTestConstant.cpp index e4d187b4d6..6d630f97ff 100644 --- a/projects/hip/tests/src/kernel/hipTestConstant.cpp +++ b/projects/hip/tests/src/kernel/hipTestConstant.cpp @@ -18,7 +18,7 @@ THE SOFTWARE. */ /* HIT_START - * BUILD: %t %s ../test_common.cpp + * BUILD: %t %s ../test_common.cpp EXCLUDE_HIP_PLATFORM all * RUN: %t * HIT_END */ diff --git a/projects/hip/tests/src/kernel/hipTestMallocKernel.cpp b/projects/hip/tests/src/kernel/hipTestMallocKernel.cpp index bd0c17d898..9dd8b053a5 100644 --- a/projects/hip/tests/src/kernel/hipTestMallocKernel.cpp +++ b/projects/hip/tests/src/kernel/hipTestMallocKernel.cpp @@ -18,7 +18,7 @@ THE SOFTWARE. */ /* HIT_START - * BUILD: %t %s ../test_common.cpp + * BUILD: %t %s ../test_common.cpp EXCLUDE_HIP_PLATFORM all * RUN: %t * HIT_END */ From 35504c5348a9ccc627d3fe30292eb80da245328b Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Thu, 9 Feb 2017 20:28:28 +0530 Subject: [PATCH 129/281] Update hip_hcc packaging script Change-Id: I2dc96545c472942bcf2bc8a2e88735f3ba26d1e1 [ROCm/hip commit: 14442b3ef7484aaa08d3fb0da0621f08c4c4770d] --- projects/hip/packaging/hip_hcc.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/hip/packaging/hip_hcc.txt b/projects/hip/packaging/hip_hcc.txt index 18314a9b6d..64c0d54caf 100644 --- a/projects/hip/packaging/hip_hcc.txt +++ b/projects/hip/packaging/hip_hcc.txt @@ -5,7 +5,7 @@ install(FILES @PROJECT_BINARY_DIR@/libhip_hcc.so DESTINATION lib) install(FILES @PROJECT_BINARY_DIR@/libhip_hcc_static.a DESTINATION lib) install(FILES @PROJECT_BINARY_DIR@/libhip_device.a DESTINATION lib) install(FILES @PROJECT_BINARY_DIR@/.hipInfo DESTINATION lib) -install(FILES @hip_SOURCE_DIR@/src/hip_ir.ll DESTINATION lib) +install(FILES @hip_SOURCE_DIR@/src/hip_hc.ll @hip_SOURCE_DIR@/src/hip_hc_gfx803.ll DESTINATION lib) ############################# # Packaging steps From 76f30e96e830cc4e28988e53880361d81ab3dcdb Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Thu, 9 Feb 2017 17:22:55 -0600 Subject: [PATCH 130/281] fixed hipFunction memory management Change-Id: I7ebb323419bcd220ebd6466a8eb38e7bfdb1520a [ROCm/hip commit: 6fd3daed30a304f46f0a0822e968a0d7d52e36fe] --- .../include/hip/hcc_detail/hip_runtime_api.h | 10 +--- projects/hip/src/hip_module.cpp | 44 +++++++++++++----- projects/hip/src/trace_helper.h | 11 ----- .../tests/src/runtimeApi/module/hipModule.cpp | 24 +++++++--- .../src/runtimeApi/module/vcpy_kernel.code | Bin 0 -> 18811 bytes .../src/runtimeApi/module/vcpy_kernel.cpp | 30 ++++++++++++ 6 files changed, 82 insertions(+), 37 deletions(-) create mode 100755 projects/hip/tests/src/runtimeApi/module/vcpy_kernel.code create mode 100644 projects/hip/tests/src/runtimeApi/module/vcpy_kernel.cpp diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h index 4e5390a968..7abfffcc22 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h @@ -30,6 +30,7 @@ THE SOFTWARE. #include #include +#include #include #include @@ -72,14 +73,7 @@ typedef struct ihipIpcEventHandle_t *hipIpcEventHandle_t; typedef struct ihipModule_t *hipModule_t; -struct ihipModuleSymbol_t{ - uint64_t _object; // The kernel object. - uint32_t _groupSegmentSize; - uint32_t _privateSegmentSize; - char _name[64]; // TODO - review for performance cost. Name is just used for debug. -}; - -typedef struct ihipModuleSymbol_t hipFunction_t; +typedef struct ihipModuleSymbol_t *hipFunction_t; typedef void* hipDeviceptr_t; diff --git a/projects/hip/src/hip_module.cpp b/projects/hip/src/hip_module.cpp index 5eb3a6cf09..63a6bffa94 100644 --- a/projects/hip/src/hip_module.cpp +++ b/projects/hip/src/hip_module.cpp @@ -35,6 +35,25 @@ THE SOFTWARE. //TODO Use Pool APIs from HCC to get memory regions. + +struct ihipModuleSymbol_t{ + uint64_t _object; // The kernel object. + uint32_t _groupSegmentSize; + uint32_t _privateSegmentSize; + char _name[64]; // TODO - review for performance cost. Name is just used for debug. +}; + +std::list hipFuncTracker; + +template <> +std::string ToString(hipFunction_t v) +{ + std::ostringstream ss; + ss << "0x" << std::hex << v->_object; + return ss.str(); +}; + + #define CHECK_HSA(hsaStatus, hipStatus) \ if (hsaStatus != HSA_STATUS_SUCCESS) {\ return hipStatus;\ @@ -217,6 +236,7 @@ hipError_t ihipModuleGetSymbol(hipFunction_t *func, hipModule_t hmod, const char ret = hipErrorInvalidContext; }else{ + ihipModuleSymbol_t *sym = new ihipModuleSymbol_t; int deviceId = ctx->getDevice()->_deviceId; ihipDevice_t *currentDevice = ihipGetDevice(deviceId); hsa_agent_t gpuAgent = (hsa_agent_t)currentDevice->_hsaAgent; @@ -230,20 +250,22 @@ hipError_t ihipModuleGetSymbol(hipFunction_t *func, hipModule_t hmod, const char status = hsa_executable_symbol_get_info(symbol, HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_OBJECT, - &func->_object); + &sym->_object); CHECK_HSA(status, hipErrorNotFound); status = hsa_executable_symbol_get_info(symbol, HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_GROUP_SEGMENT_SIZE, - &func->_groupSegmentSize); + &sym->_groupSegmentSize); CHECK_HSA(status, hipErrorNotFound); status = hsa_executable_symbol_get_info(symbol, HSA_EXECUTABLE_SYMBOL_INFO_KERNEL_PRIVATE_SEGMENT_SIZE, - &func->_privateSegmentSize); + &sym->_privateSegmentSize); CHECK_HSA(status, hipErrorNotFound); - strncpy(func->_name, name, sizeof(func->_name)); + strncpy(sym->_name, name, sizeof(sym->_name)); + *func = sym; + hipFuncTracker.push_back(*func); } return ihipLogStatus(ret); } @@ -297,9 +319,9 @@ hipError_t hipModuleLaunchKernel(hipFunction_t f, /* Kernel argument preparation. */ - grid_launch_parm lp; + grid_launch_parm lp; lp.dynamic_group_mem_bytes = sharedMemBytes; // TODO - this should be part of preLaunchKernel. - hStream = ihipPreLaunchKernel(hStream, dim3(gridDimX, gridDimY, gridDimZ), dim3(blockDimX, blockDimY, blockDimZ), &lp, f._name); + hStream = ihipPreLaunchKernel(hStream, dim3(gridDimX, gridDimY, gridDimZ), dim3(blockDimX, blockDimY, blockDimZ), &lp, f->_name); hsa_kernel_dispatch_packet_t aql; @@ -315,9 +337,9 @@ hipError_t hipModuleLaunchKernel(hipFunction_t f, aql.grid_size_x = blockDimX * gridDimX; aql.grid_size_y = blockDimY * gridDimY; aql.grid_size_z = blockDimZ * gridDimZ; - aql.group_segment_size = f._groupSegmentSize + sharedMemBytes; - aql.private_segment_size = f._privateSegmentSize; - aql.kernel_object = f._object; + aql.group_segment_size = f->_groupSegmentSize + sharedMemBytes; + aql.private_segment_size = f->_privateSegmentSize; + aql.kernel_object = f->_object; aql.setup = 3 << HSA_KERNEL_DISPATCH_PACKET_SETUP_DIMENSIONS; aql.header = (HSA_PACKET_TYPE_KERNEL_DISPATCH << HSA_PACKET_HEADER_TYPE) | (1 << HSA_PACKET_HEADER_BARRIER); // TODO - honor queue setting for execute_in_order @@ -333,7 +355,7 @@ hipError_t hipModuleLaunchKernel(hipFunction_t f, lp.av->dispatch_hsa_kernel(&aql, config[1] /* kernarg*/, kernArgSize, nullptr/*completion_future*/); - ihipPostLaunchKernel(f._name, hStream, lp); + ihipPostLaunchKernel(f->_name, hStream, lp); } return ihipLogStatus(ret); @@ -355,7 +377,7 @@ hipError_t hipModuleGetGlobal(hipDeviceptr_t *dptr, size_t *bytes, hipFunction_t func; ihipModuleGetSymbol(&func, hmod, name); *bytes = PrintSymbolSizes(hmod->ptr, name) + sizeof(amd_kernel_code_t); - *dptr = reinterpret_cast(func._object); + *dptr = reinterpret_cast(func->_object); return ihipLogStatus(ret); } } diff --git a/projects/hip/src/trace_helper.h b/projects/hip/src/trace_helper.h index f58f81fbff..3bf2857c3a 100644 --- a/projects/hip/src/trace_helper.h +++ b/projects/hip/src/trace_helper.h @@ -72,17 +72,6 @@ inline std::string ToString(hipEvent_t v) return ss.str(); }; -// hipEvent_t specialization. TODO - maybe add an event ID for debug? -template <> -inline std::string ToString(hipFunction_t v) -{ - std::ostringstream ss; - ss << "0x" << std::hex << v._object; - return ss.str(); -}; - - - // hipStream_t template <> inline std::string ToString(hipStream_t v) diff --git a/projects/hip/tests/src/runtimeApi/module/hipModule.cpp b/projects/hip/tests/src/runtimeApi/module/hipModule.cpp index d9193cd87f..d7552ee1e6 100644 --- a/projects/hip/tests/src/runtimeApi/module/hipModule.cpp +++ b/projects/hip/tests/src/runtimeApi/module/hipModule.cpp @@ -22,13 +22,15 @@ THE SOFTWARE. #include #include #include +#include +#include #include "test_common.h" #define LEN 64 #define SIZE LEN<<2 -#define fileName "vcpy_isa.co" +#define fileName "vcpy_kernel.code" #define kernel_name "hello_world" __global__ void Cpy(hipLaunchParm lp, float *Ad, float* Bd){ @@ -59,11 +61,11 @@ int main(){ hipStream_t stream; HIPCHECK(hipStreamCreate(&stream)); void *args[2] = {&Ad, &Bd}; + std::cout<argBuffer(2); - memcpy(&argBuffer[0], &Ad, sizeof(void*)); - memcpy(&argBuffer[1], &Bd, sizeof(void*)); + std::vectorargBuffer(5); + memcpy(&argBuffer[3], &Ad, sizeof(void*)); + memcpy(&argBuffer[4], &Bd, sizeof(void*)); size_t size = argBuffer.size()*sizeof(void*); @@ -73,7 +75,7 @@ int main(){ HIP_LAUNCH_PARAM_END }; - hipModuleLaunchKernel(Function, 1, 1, 1, LEN, 1, 1, 0, stream, NULL, (void**)&config); + hipModuleLaunchKernel(Function, 1, 1, 1, LEN, 1, 1, 0, stream, NULL, (void**)&config); HIPCHECK(hipStreamDestroy(stream)); @@ -82,7 +84,15 @@ int main(){ for(uint32_t i=0;i vec(1024*1024*64); + for(unsigned i=0;i<1024*1024*64;i++) { + hipFunction_t func; + hipModuleGetFunction(&func, Module, kernel_name); + vec[i] = func; + } + std::cout<<"Starting sleep"<!|TyJEXSpxJp$K3RyD-7nQWZaI>aj^(hg-HsJefl%aEHtUM6q;d-2|D+t< z-^}lh$?vZyD)z})0h1JFVvj&M-kwOmR)KBt_OQbkeDYJFlO)@t#6DyDqm$#j7{(Fb z0srU^h{xGRo)6S62Kd40$K1S!p#F^_@4&!7?`9GeMzZ{G=gyt#p|LS_=CP@xhbIrH2WDoD%siP-tM_$O!%-`> zx&<02^;(n1%qN?B`qe$@Ro9SNbq(27*D$o|8gi?yA;0Px3ahI@eM&vun@lEq(brZA z=%d?lCJ^($v=~4p;9C*j<(5GQNZGtc<4#&&l{hgx}@j{h(u*CH!tz9~bxu!c`Zi{O1Y3SH`~}e5;G^67^gl z{0o$x#5{8tFy?&4Wd&o)r;9|O)SxA7QbHwcN{!FfwG!_gbzDjpkL zzX`5ec#JW0rd!~jrbPiuLNv|iH%thchxxMy($MX2j=UNEdC-qfrPBJri6i?*Cv<&E zPi1rZ@l>j6)$1+&`IcQbQ@J_2X6kigzFDs7ZNqL%S02@Ly#l(^vQxvlUOsu!XtZ_5 zhHDFFxC1pFrXQ|MSD3C>Yi+$+)@!z2O_!}&U58oJ54So2sCBZP4uC85R?7~+>#ez< z>~^^wklF4$XFCCSr`8NYgEKoeSYdf~!!!drQfU|gXk)$}fOh6f%TdglUDg_))!H(2 zJ~%VNLAg7I$*Um0h-74e$O4fCA`3(o_zzlu);v9YH3gsc2w0)7J?txX9?~}R71dHE zv3%yhCifG1H!&WM2Q8(#>DM!&u*4!RNk3x>tbE`7T9wo8R zvoTR%Z2BUsAL9yOF@-Jk^dt&xo~M0L!NnkZ8S<~MKy+U#|7->RaV<_E;ag?@xA|8V zvETcdvWOIN&XHS1S%41$@R4Huafz50`Y#M7`Y`)I zH2$wL{@H60|MK7mEqMInyEh7n?i(~0Sx?V@SpO~JT;^Q|C`x>Rv5P;mST8IQ!u34( zcg8<{YqS*B6aQY`SuDQqvJ&6NwrzmdzTx7X*jX$77}rq_+M%K$Jify{9jfQ zQvQp;e=(Z>iF=g6{Cj8o_4xjW zp8M==W#RH$@a|{Z26$%~&S$=t&9$2UL&N_^!2gF4|6U)F;~^jauK@q&BK~F0y;{im ze-rqBBjVr7xEv2T|1SgoXCwY)&b?a5`9B5xzZmiFWn7Mjoc}Yx|3bvS%(+(!IsYF3 z|L;fqdl{GGA?N=z@c&Z8zs$K;3pxMq0RQLzKm2={jpC67A`3(oh%69UAhN*!!vgff z{LjS~IJCb~Y}4%ilK&8H!h}GZa<_<$l=QvNCsdJ}ZRv`exyyBNxGr$l%~y z&8g0plI2!oaKPYL2xU?Rm!<D;`Q&W+`P^rcuhK$^~;clh0MnHa=pk=Y_%mj{1dIHrM@ z*L+#2{C&Oxq>{va)ZM;&>Uee3Ri5@>7^QLqqfWLb4CSS9SNlmMqL1JlL-$Yo zd`7r%OltRA!hPo>{6M(xe1zW!_nnV$g>c{b2wUO)xE*}wBj7m(99N+r1UesKAK~}P z_))@r=Oa8rxbJ*~vxNK3NBEd<;qY{x!qePX$&UR1 literal 0 HcmV?d00001 diff --git a/projects/hip/tests/src/runtimeApi/module/vcpy_kernel.cpp b/projects/hip/tests/src/runtimeApi/module/vcpy_kernel.cpp new file mode 100644 index 0000000000..0375eee342 --- /dev/null +++ b/projects/hip/tests/src/runtimeApi/module/vcpy_kernel.cpp @@ -0,0 +1,30 @@ +/* +Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#include "hip/hip_runtime.h" + +extern "C" __global__ void hello_world(hipLaunchParm lp, float *a, float *b) +{ + int tx = hipThreadIdx_x; + b[tx] = a[tx]; +} + From 21d09049cbff617b552aa2b65b2d1d2c1c10d906 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Thu, 9 Feb 2017 18:07:48 -0600 Subject: [PATCH 131/281] added new dynamic shared mem test Change-Id: Ic2a12fc9bc5b67e85f1e6c6008f10c7c66388377 [ROCm/hip commit: 2a064cfcc59cd9f164c6e295c8ab76fcf27ea6ce] --- .../tests/src/kernel/hipDynamicShared2.cpp | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 projects/hip/tests/src/kernel/hipDynamicShared2.cpp diff --git a/projects/hip/tests/src/kernel/hipDynamicShared2.cpp b/projects/hip/tests/src/kernel/hipDynamicShared2.cpp new file mode 100644 index 0000000000..f4dcf0d1e8 --- /dev/null +++ b/projects/hip/tests/src/kernel/hipDynamicShared2.cpp @@ -0,0 +1,62 @@ +/* +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +/* HIT_START + * BUILD: %t %s ../test_common.cpp + * RUN: %t EXCLUDE_HIP_PLATFORM nvcc + * HIT_END + */ + + #include "hip/hip_runtime.h" + #include "test_common.h" + +#define LEN 16*1024 +#define SIZE LEN*4 + +__global__ void vectorAdd(hipLaunchParm lp, float *Ad, float *Bd) { + HIP_DYNAMIC_SHARED(float, sBd); + int tx = hipThreadIdx_x; + for(int i=0;i 1.0f); + } + passed(); +} From e48175e40495ae3b9b943d5e4cc20de356e0ed8d Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Thu, 9 Feb 2017 18:17:42 -0600 Subject: [PATCH 132/281] fixed shared memory usage implementation for hipDynamicShared2.cpp test Change-Id: I34c72cb905f78de0f37e94174382e8be5c532028 [ROCm/hip commit: 28871ddd5b51b44981d166fe3caadd8b5a174663] --- projects/hip/tests/src/kernel/hipDynamicShared2.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/projects/hip/tests/src/kernel/hipDynamicShared2.cpp b/projects/hip/tests/src/kernel/hipDynamicShared2.cpp index f4dcf0d1e8..0f6ebb4927 100644 --- a/projects/hip/tests/src/kernel/hipDynamicShared2.cpp +++ b/projects/hip/tests/src/kernel/hipDynamicShared2.cpp @@ -36,8 +36,8 @@ __global__ void vectorAdd(hipLaunchParm lp, float *Ad, float *Bd) { HIP_DYNAMIC_SHARED(float, sBd); int tx = hipThreadIdx_x; for(int i=0;i 1.0f); + assert(B[i] > 1.0f && B[i] < 3.0f); } passed(); } From 60acbdb8345206e8ff9fe19f263c16bd13de8f17 Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Fri, 10 Feb 2017 10:32:04 +0530 Subject: [PATCH 133/281] Build libhip_hcc.so as a fat binary Change-Id: Ie4f334d8f9576edf5df0f917f72083d7842eb193 [ROCm/hip commit: 75133e88b6887932cf3c1dfed93a95973751e12c] --- projects/hip/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/projects/hip/CMakeLists.txt b/projects/hip/CMakeLists.txt index 9c469afbc1..a4dc040e40 100644 --- a/projects/hip/CMakeLists.txt +++ b/projects/hip/CMakeLists.txt @@ -186,6 +186,7 @@ if(HIP_PLATFORM STREQUAL "hcc") src/math_functions.cpp) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -L${HCC_HOME}/lib -lmcwamp -Wl,-Bsymbolic -Wl,-rpath ${HCC_HOME}/lib") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --amdgpu-target=gfx701 --amdgpu-target=gfx801 --amdgpu-target=gfx802 --amdgpu-target=gfx803") add_library(hip_hcc SHARED ${SOURCE_FILES_RUNTIME}) target_link_libraries(hip_hcc c++ c++abi hc_am) add_library(hip_hcc_static STATIC ${SOURCE_FILES_RUNTIME}) From e09697c1cfbdfcaf7c5349002100bf98f0c1597d Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Fri, 10 Feb 2017 22:02:41 +0300 Subject: [PATCH 134/281] [HIPIFY] 'CHANGED LOC', 'TOTAL LOC' and 'CODE CHANGED (in lines)' are added to statistics. [ROCm/hip commit: 751db030c23d2af0069a8e3f6c4917c02459de7b] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 153 +++++++++++++++------ 1 file changed, 111 insertions(+), 42 deletions(-) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index 543d527d58..468b42297c 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -1698,11 +1698,20 @@ public: uint64_t countApiRepsUnsupported[API_LAST] = { 0 }; std::map cuda2hipConverted; std::map cuda2hipUnconverted; + std::set LOCs; protected: struct cuda2hipMap N; Replacements *Replace; + virtual void insertReplacement(const Replacement &rep, const FullSourceLoc &fullSL) { + Replace->insert(rep); + if (PrintStats) { + LOCs.insert(fullSL.getExpansionLineNumber()); + // llvm::outs() << " [HIPIFY] expansion line num: " << fullSL.getExpansionLineNumber() << " for replacement '" << rep.getReplacementText() << "'\n"; + } + } + void updateCountersExt(const hipCounter &counter, const std::string &cudaName) { std::map *map = &cuda2hipConverted; std::map *mapTotal = &cuda2hipConvertedTotal; @@ -1755,7 +1764,8 @@ protected: if (!counter.unsupported) { SourceLocation sl = start.getLocWithOffset(begin + 1); Replacement Rep(SM, sl, name.size(), repName); - Replace->insert(Rep); + FullSourceLoc fullSL(sl, SM); + insertReplacement(Rep, fullSL); } } else { // llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [string literal].\n"; @@ -1811,7 +1821,8 @@ public: const char *E = _sm->getCharacterData(sle); SmallString<128> tmpData; Replacement Rep(*_sm, sl, E - B, Twine("<" + repName + ">").toStringRef(tmpData)); - Replace->insert(Rep); + FullSourceLoc fullSL(sl, *_sm); + insertReplacement(Rep, fullSL); } } else { // llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << file_name << "' [inclusion directive].\n"; @@ -1838,7 +1849,8 @@ public: << "will be replaced with: " << repName << "\n" << "SourceLocation: " << sl.printToString(*_sm) << "\n"); Replacement Rep(*_sm, sl, name.size(), repName); - Replace->insert(Rep); + FullSourceLoc fullSL(sl, *_sm); + insertReplacement(Rep, fullSL); } } else { // llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [macro].\n"; @@ -1893,7 +1905,8 @@ public: sl = sl_macro; } Replacement Rep(*_sm, sl, length, repName); - Replace->insert(Rep); + FullSourceLoc fullSL(sl, *_sm); + insertReplacement(Rep, fullSL); } } else { // llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [macro expansion].\n"; @@ -1913,7 +1926,8 @@ public: StringRef repName = found->second.hipName; sl = sl_macro; Replacement Rep(*_sm, sl, length, repName); - Replace->insert(Rep); + FullSourceLoc fullSL(sl, *_sm); + insertReplacement(Rep, fullSL); } } else { // llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [literal macro expansion].\n"; @@ -1968,7 +1982,8 @@ private: } DEBUG(dbgs() << "initial paramlist: " << initialParamList << "\n" << "new paramlist: " << OS.str() << "\n"); Replacement Rep0(*(Result.SourceManager), kernelArgListStart, repLength, OS.str()); - Replace->insert(Rep0); + FullSourceLoc fullSL(sl, *(Result.SourceManager)); + insertReplacement(Rep0, fullSL); } bool cudaCall(const MatchFinder::MatchResult &Result) { @@ -2000,7 +2015,8 @@ private: if (bReplace) { updateCounters(found->second, name.str()); Replacement Rep(*SM, sl, length, repName); - Replace->insert(Rep); + FullSourceLoc fullSL(sl, *SM); + insertReplacement(Rep, fullSL); } } else { updateCounters(found->second, name.str()); @@ -2075,8 +2091,9 @@ private: launchKernel->getLocEnd(), 0, *SM, DefaultLangOptions)) - SM->getCharacterData(launchKernel->getLocStart()); Replacement Rep(*SM, launchKernel->getLocStart(), length, OS.str()); - Replace->insert(Rep); - hipCounter counter = {"hipLaunchKernel", CONV_KERN, API_RUNTIME}; + FullSourceLoc fullSL(launchKernel->getLocStart(), *SM); + insertReplacement(Rep, fullSL); + hipCounter counter = {"hipLaunchKernel", CONV_KERN, API_RUNTIME}; updateCounters(counter, refName.str()); return true; } @@ -2103,7 +2120,8 @@ private: SourceLocation sl = threadIdx->getLocStart(); SourceManager *SM = Result.SourceManager; Replacement Rep(*SM, sl, name.size(), repName); - Replace->insert(Rep); + FullSourceLoc fullSL(sl, *SM); + insertReplacement(Rep, fullSL); } } else { llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [builtin].\n"; @@ -2126,7 +2144,8 @@ private: SourceLocation sl = enumConstantRef->getLocStart(); SourceManager *SM = Result.SourceManager; Replacement Rep(*SM, sl, name.size(), repName); - Replace->insert(Rep); + FullSourceLoc fullSL(sl, *SM); + insertReplacement(Rep, fullSL); } } else { llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [enum constant ref].\n"; @@ -2153,7 +2172,8 @@ private: SourceLocation sl = enumConstantDecl->getLocStart(); SourceManager *SM = Result.SourceManager; Replacement Rep(*SM, sl, name.size(), repName); - Replace->insert(Rep); + FullSourceLoc fullSL(sl, *SM); + insertReplacement(Rep, fullSL); } } else { llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [enum constant decl].\n"; @@ -2179,7 +2199,8 @@ private: SourceLocation sl = typedefVar->getLocStart(); SourceManager *SM = Result.SourceManager; Replacement Rep(*SM, sl, name.size(), repName); - Replace->insert(Rep); + FullSourceLoc fullSL(sl, *SM); + insertReplacement(Rep, fullSL); } } else { llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [typedef var].\n"; @@ -2205,7 +2226,8 @@ private: SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); SourceManager *SM = Result.SourceManager; Replacement Rep(*SM, sl, name.size(), repName); - Replace->insert(Rep); + FullSourceLoc fullSL(sl, *SM); + insertReplacement(Rep, fullSL); } } else { @@ -2232,7 +2254,8 @@ private: SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); SourceManager *SM = Result.SourceManager; Replacement Rep(*SM, sl, name.size(), repName); - Replace->insert(Rep); + FullSourceLoc fullSL(sl, *SM); + insertReplacement(Rep, fullSL); } } else { llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [struct var].\n"; @@ -2256,7 +2279,8 @@ private: SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); SourceManager *SM = Result.SourceManager; Replacement Rep(*SM, sl, name.size(), repName); - Replace->insert(Rep); + FullSourceLoc fullSL(sl, *SM); + insertReplacement(Rep, fullSL); } } else { llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [struct var ptr].\n"; @@ -2282,7 +2306,8 @@ private: SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); SourceManager *SM = Result.SourceManager; Replacement Rep(*SM, sl, name.size(), repName); - Replace->insert(Rep); + FullSourceLoc fullSL(sl, *SM); + insertReplacement(Rep, fullSL); } } else { llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [struct sizeof].\n"; @@ -2324,8 +2349,9 @@ private: StringRef varName = sharedVar->getNameAsString(); StringRef repName = Twine("HIP_DYNAMIC_SHARED(" + typeName + ", " + varName + ")").toStringRef(tmpData); Replacement Rep(*SM, slStart, repLength, repName); - Replace->insert(Rep); - hipCounter counter = {"HIP_DYNAMIC_SHARED", CONV_MEM, API_RUNTIME}; + FullSourceLoc fullSL(slStart, *SM); + insertReplacement(Rep, fullSL); + hipCounter counter = { "HIP_DYNAMIC_SHARED", CONV_MEM, API_RUNTIME }; updateCounters(counter, refName.str()); } } @@ -2351,7 +2377,8 @@ private: SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); SourceManager *SM = Result.SourceManager; Replacement Rep(*SM, sl, name.size(), repName); - Replace->insert(Rep); + FullSourceLoc fullSL(sl, *SM); + insertReplacement(Rep, fullSL); } } else { llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [param decl].\n"; @@ -2379,7 +2406,8 @@ private: SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); SourceManager *SM = Result.SourceManager; Replacement Rep(*SM, sl, name.size(), repName); - Replace->insert(Rep); + FullSourceLoc fullSL(sl, *SM); + insertReplacement(Rep, fullSL); } } else { llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [param decl ptr].\n"; @@ -2440,8 +2468,10 @@ public: countReps[CONV_INCLUDE_CUDA_MAIN_H] == 0 && Replace->size() > 0) { StringRef repName = "#include \n"; SourceManager *SM = Result.SourceManager; - Replacement Rep(*SM, SM->getLocForStartOfFile(SM->getMainFileID()), 0, repName); - Replace->insert(Rep); + SourceLocation sl = SM->getLocForStartOfFile(SM->getMainFileID()); + Replacement Rep(*SM, sl, 0, repName); + FullSourceLoc fullSL(sl, *SM); + insertReplacement(Rep, fullSL); hipCounter counter = { repName, CONV_INCLUDE_CUDA_MAIN_H, API_RUNTIME }; updateCounters(counter, repName); } @@ -2456,8 +2486,10 @@ void HipifyPPCallbacks::handleEndSource() { if (Match->countReps[CONV_INCLUDE_CUDA_MAIN_H] == 0 && countReps[CONV_INCLUDE_CUDA_MAIN_H] == 0 && Replace->size() > 0) { StringRef repName = "#include \n"; - Replacement Rep(*_sm, _sm->getLocForStartOfFile(_sm->getMainFileID()), 0, repName); - Replace->insert(Rep); + SourceLocation sl = _sm->getLocForStartOfFile(_sm->getMainFileID()); + Replacement Rep(*_sm, sl, 0, repName); + FullSourceLoc fullSL(sl, *_sm); + insertReplacement(Rep, fullSL); hipCounter counter = { repName, CONV_INCLUDE_CUDA_MAIN_H, API_RUNTIME }; updateCounters(counter, repName); } @@ -2542,7 +2574,7 @@ void addAllMatchers(ast_matchers::MatchFinder &Finder, Cuda2HipCallback *Callbac int64_t printStats(const std::string &csvFile, const std::string &srcFile, HipifyPPCallbacks &PPCallbacks, Cuda2HipCallback &Callback, - uint64_t replacedBytes, uint64_t totalBytes, + uint64_t replacedBytes, uint64_t totalBytes, unsigned totalLines, const std::chrono::steady_clock::time_point &start) { std::ofstream csv(csvFile, std::ios::app); int64_t sum = 0, sum_interm = 0; @@ -2575,10 +2607,25 @@ int64_t printStats(const std::string &csvFile, const std::string &srcFile, str = "TOTAL bytes"; llvm::outs() << " " << str << ": " << totalBytes << "\n"; csv << str << separator << totalBytes << "\n"; - str = "CODE CHANGED %"; - conv = std::lround(double(replacedBytes * 100) / double(totalBytes)); - llvm::outs() << " " << str << ": " << conv << "%\n"; - csv << str << separator << conv << "%\n"; + str = "CHANGED lines of code"; + unsigned changedLines = Callback.LOCs.size() + PPCallbacks.LOCs.size(); + llvm::outs() << " " << str << ": " << changedLines << "\n"; + csv << str << separator << changedLines << "\n"; + str = "TOTAL lines of code"; + llvm::outs() << " " << str << ": " << totalLines << "\n"; + csv << str << separator << totalLines << "\n"; + if (totalBytes > 0) { + str = "CODE CHANGED (in bytes) %"; + conv = std::lround(double(replacedBytes * 100) / double(totalBytes)); + llvm::outs() << " " << str << ": " << conv << "%\n"; + csv << str << separator << conv << "%\n"; + } + if (totalLines > 0) { + str = "CODE CHANGED (in lines) %"; + conv = std::lround(double(changedLines * 100) / double(totalLines)); + llvm::outs() << " " << str << ": " << conv << "%\n"; + csv << str << separator << conv << "%\n"; + } typedef std::chrono::duration duration; duration elapsed = std::chrono::steady_clock::now() - start; str = "TIME ELAPSED s"; @@ -2657,7 +2704,7 @@ int64_t printStats(const std::string &csvFile, const std::string &srcFile, } void printAllStats(const std::string &csvFile, int64_t totalFiles, int64_t convertedFiles, - uint64_t replacedBytes, uint64_t totalBytes, + uint64_t replacedBytes, uint64_t totalBytes, unsigned changedLines, unsigned totalLines, const std::chrono::steady_clock::time_point &start) { std::ofstream csv(csvFile, std::ios::app); int64_t sum = 0, sum_interm = 0; @@ -2696,10 +2743,24 @@ void printAllStats(const std::string &csvFile, int64_t totalFiles, int64_t conve str = "TOTAL bytes"; llvm::outs() << " " << str << ": " << totalBytes << "\n"; csv << str << separator << totalBytes << "\n"; - str = "CODE CHANGED %"; - conv = std::lround(double(replacedBytes * 100) / double(totalBytes)); - llvm::outs() << " " << str << ": " << conv << "%\n"; - csv << str << separator << conv << "%\n"; + str = "CHANGED lines of code"; + llvm::outs() << " " << str << ": " << changedLines << "\n"; + csv << str << separator << changedLines << "\n"; + str = "TOTAL lines of code"; + llvm::outs() << " " << str << ": " << totalLines << "\n"; + csv << str << separator << totalLines << "\n"; + if (totalBytes > 0) { + str = "CODE CHANGED (in bytes) %"; + conv = std::lround(double(replacedBytes * 100) / double(totalBytes)); + llvm::outs() << " " << str << ": " << conv << "%\n"; + csv << str << separator << conv << "%\n"; + } + if (totalLines > 0) { + str = "CODE CHANGED (in lines) %"; + conv = std::lround(double(changedLines * 100) / double(totalLines)); + llvm::outs() << " " << str << ": " << conv << "%\n"; + csv << str << separator << conv << "%\n"; + } typedef std::chrono::duration duration; duration elapsed = std::chrono::steady_clock::now() - start; str = "TIME ELAPSED s"; @@ -2791,10 +2852,12 @@ int main(int argc, const char **argv) { } else { csv = "hipify_stats.csv"; } - size_t filesTransleted = fileSources.size(); + size_t filesTranslated = fileSources.size(); uint64_t repBytesTotal = 0; uint64_t bytesTotal = 0; - if (PrintStats && filesTransleted > 1) { + unsigned changedLinesTotal = 0; + unsigned linesTotal = 0; + if (PrintStats && filesTranslated > 1) { std::remove(csv.c_str()); } for (const auto & src : fileSources) { @@ -2850,6 +2913,8 @@ int main(int argc, const char **argv) { uint64_t repBytes = 0; uint64_t bytes = 0; + unsigned lines = 0; + SourceManager SM(Diagnostics, Tool.getFiles()); if (PrintStats) { DEBUG(dbgs() << "Replacements collected by the tool:\n"); for (const auto &r : Tool.getReplacements()) { @@ -2857,10 +2922,12 @@ int main(int argc, const char **argv) { repBytes += r.getLength(); } std::ifstream src_file(dst, std::ios::binary | std::ios::ate); + src_file.clear(); + src_file.seekg(0); + lines = std::count(std::istreambuf_iterator(src_file), std::istreambuf_iterator(), '\n'); bytes = src_file.tellg(); } - SourceManager Sources(Diagnostics, Tool.getFiles()); - Rewriter Rewrite(Sources, DefaultLangOptions); + Rewriter Rewrite(SM, DefaultLangOptions); if (!Tool.applyAllReplacements(Rewrite)) { DEBUG(dbgs() << "Skipped some replacements.\n"); } @@ -2883,17 +2950,19 @@ int main(int argc, const char **argv) { } std::remove(csv.c_str()); } - if (0 == printStats(csv, src, PPCallbacks, Callback, repBytes, bytes, start)) { - filesTransleted--; + if (0 == printStats(csv, src, PPCallbacks, Callback, repBytes, bytes, lines, start)) { + filesTranslated--; } start = std::chrono::steady_clock::now(); repBytesTotal += repBytes; bytesTotal += bytes; + changedLinesTotal += PPCallbacks.LOCs.size() + Callback.LOCs.size(); + linesTotal += lines; } dst.clear(); } if (PrintStats && fileSources.size() > 1) { - printAllStats(csv, fileSources.size(), filesTransleted, repBytesTotal, bytesTotal, begin); + printAllStats(csv, fileSources.size(), filesTranslated, repBytesTotal, bytesTotal, changedLinesTotal, linesTotal, begin); } return Result; } From 37e317ddb41426aa9db5f39ad79a72bd40f58528 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Fri, 10 Feb 2017 13:32:13 -0600 Subject: [PATCH 135/281] v2: Fixed hipModule memory management 1. Changed test to assert for same hipFunction values 2. Added better memory management for hipModule Change-Id: I10d7aef13c215a2211e262f3c79017f26a17d9a7 [ROCm/hip commit: 378eb3fa5544e745cb06e62c100e2d2e12c2645d] --- projects/hip/src/hip_hcc.h | 2 +- projects/hip/src/hip_module.cpp | 19 +++++++----- .../tests/src/runtimeApi/module/hipModule.cpp | 29 +++++++++---------- 3 files changed, 27 insertions(+), 23 deletions(-) diff --git a/projects/hip/src/hip_hcc.h b/projects/hip/src/hip_hcc.h index 28ae6a2e8e..5509e4aa10 100644 --- a/projects/hip/src/hip_hcc.h +++ b/projects/hip/src/hip_hcc.h @@ -343,7 +343,7 @@ public: std::string fileName; void *ptr; size_t size; - + std::list funcTrack; ihipModule_t() : executable(), object(), fileName(), ptr(nullptr), size(0) {} }; diff --git a/projects/hip/src/hip_module.cpp b/projects/hip/src/hip_module.cpp index 63a6bffa94..1672dbf5d3 100644 --- a/projects/hip/src/hip_module.cpp +++ b/projects/hip/src/hip_module.cpp @@ -40,11 +40,9 @@ struct ihipModuleSymbol_t{ uint64_t _object; // The kernel object. uint32_t _groupSegmentSize; uint32_t _privateSegmentSize; - char _name[64]; // TODO - review for performance cost. Name is just used for debug. + std::string _name; // TODO - review for performance cost. Name is just used for debug. }; -std::list hipFuncTracker; - template <> std::string ToString(hipFunction_t v) { @@ -236,6 +234,13 @@ hipError_t ihipModuleGetSymbol(hipFunction_t *func, hipModule_t hmod, const char ret = hipErrorInvalidContext; }else{ + std::string str(name); + for(std::list::iterator f = hmod->funcTrack.begin(); f != hmod->funcTrack.end(); ++f) { + if((*f)->_name == str) { + *func = *f; + } + return ret; + } ihipModuleSymbol_t *sym = new ihipModuleSymbol_t; int deviceId = ctx->getDevice()->_deviceId; ihipDevice_t *currentDevice = ihipGetDevice(deviceId); @@ -263,9 +268,9 @@ hipError_t ihipModuleGetSymbol(hipFunction_t *func, hipModule_t hmod, const char &sym->_privateSegmentSize); CHECK_HSA(status, hipErrorNotFound); - strncpy(sym->_name, name, sizeof(sym->_name)); + sym->_name = name; *func = sym; - hipFuncTracker.push_back(*func); + hmod->funcTrack.push_back(*func); } return ihipLogStatus(ret); } @@ -321,7 +326,7 @@ hipError_t hipModuleLaunchKernel(hipFunction_t f, */ grid_launch_parm lp; lp.dynamic_group_mem_bytes = sharedMemBytes; // TODO - this should be part of preLaunchKernel. - hStream = ihipPreLaunchKernel(hStream, dim3(gridDimX, gridDimY, gridDimZ), dim3(blockDimX, blockDimY, blockDimZ), &lp, f->_name); + hStream = ihipPreLaunchKernel(hStream, dim3(gridDimX, gridDimY, gridDimZ), dim3(blockDimX, blockDimY, blockDimZ), &lp, f->_name.c_str()); hsa_kernel_dispatch_packet_t aql; @@ -355,7 +360,7 @@ hipError_t hipModuleLaunchKernel(hipFunction_t f, lp.av->dispatch_hsa_kernel(&aql, config[1] /* kernarg*/, kernArgSize, nullptr/*completion_future*/); - ihipPostLaunchKernel(f->_name, hStream, lp); + ihipPostLaunchKernel(f->_name.c_str(), hStream, lp); } return ihipLogStatus(ret); diff --git a/projects/hip/tests/src/runtimeApi/module/hipModule.cpp b/projects/hip/tests/src/runtimeApi/module/hipModule.cpp index d7552ee1e6..1b7b62cff2 100644 --- a/projects/hip/tests/src/runtimeApi/module/hipModule.cpp +++ b/projects/hip/tests/src/runtimeApi/module/hipModule.cpp @@ -46,7 +46,6 @@ int main(){ for(uint32_t i=0;iargBuffer(5); - memcpy(&argBuffer[3], &Ad, sizeof(void*)); - memcpy(&argBuffer[4], &Bd, sizeof(void*)); + std::vectorargBuffer(5); + memcpy(&argBuffer[3], &Ad, sizeof(void*)); + memcpy(&argBuffer[4], &Bd, sizeof(void*)); - size_t size = argBuffer.size()*sizeof(void*); + size_t size = argBuffer.size()*sizeof(void*); - void *config[] = { + void *config[] = { HIP_LAUNCH_PARAM_BUFFER_POINTER, &argBuffer[0], HIP_LAUNCH_PARAM_BUFFER_SIZE, &size, HIP_LAUNCH_PARAM_END - }; + }; - hipModuleLaunchKernel(Function, 1, 1, 1, LEN, 1, 1, 0, stream, NULL, (void**)&config); + hipModuleLaunchKernel(Function, 1, 1, 1, LEN, 1, 1, 0, stream, NULL, (void**)&config); - HIPCHECK(hipStreamDestroy(stream)); + HIPCHECK(hipStreamDestroy(stream)); HIPCHECK(hipMemcpy(B, Bd, SIZE, hipMemcpyDeviceToHost)); for(uint32_t i=0;i vec(1024*1024*64); for(unsigned i=0;i<1024*1024*64;i++) { hipFunction_t func; hipModuleGetFunction(&func, Module, kernel_name); vec[i] = func; } - - std::cout<<"Starting sleep"< Date: Fri, 10 Feb 2017 13:42:10 -0600 Subject: [PATCH 136/281] v3: added free for ihipModuleSymbol_t structures inside tracker Change-Id: Ib8041a05312c08cbdf2d4fee5e7cbae17df6efff [ROCm/hip commit: d03fe5a40dc70b0451ce6bbb8f394f95f0e85104] --- projects/hip/src/hip_module.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/projects/hip/src/hip_module.cpp b/projects/hip/src/hip_module.cpp index 1672dbf5d3..f21adf9691 100644 --- a/projects/hip/src/hip_module.cpp +++ b/projects/hip/src/hip_module.cpp @@ -218,6 +218,9 @@ hipError_t hipModuleUnload(hipModule_t hmod) { ret = hipErrorInvalidValue; } + for(std::list::iterator f = hmod->funcTrack.begin(); f != hmod->funcTrack.end(); ++f) { + delete *f; + } delete hmod; return ihipLogStatus(ret); } From 5df62556da3747fc976ca88abc1954d3a7150d51 Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 19 Jan 2017 11:09:33 -0600 Subject: [PATCH 137/281] Set hip version correctly [ROCm/hip commit: bae7356b4299af25519184ea0126daea0de8eef8] --- projects/hip/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/hip/CMakeLists.txt b/projects/hip/CMakeLists.txt index a4dc040e40..9af405b836 100644 --- a/projects/hip/CMakeLists.txt +++ b/projects/hip/CMakeLists.txt @@ -33,7 +33,7 @@ execute_process(COMMAND git show -s --format=@%ct OUTPUT_VARIABLE HIP_VERSION_PATCH OUTPUT_STRIP_TRAILING_WHITESPACE) -set(HIP_VERSION $HIP_VERSION_MAJOR.$HIP_VERSION_MINOR.$HIP_VERSION_PATCH) +set(HIP_VERSION ${HIP_VERSION_MAJOR}.${HIP_VERSION_MINOR}.${HIP_VERSION_PATCH}) add_to_config(_versionInfo HIP_VERSION_MAJOR) add_to_config(_versionInfo HIP_VERSION_MINOR) add_to_config(_versionInfo HIP_VERSION_PATCH) From 9f5ab73c4efffba44fc76d911e725010ec6dc479 Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Mon, 13 Feb 2017 16:01:50 +0530 Subject: [PATCH 138/281] Generate package config for cmake Change-Id: I73a0b21361bbe29e095dc515bdc70588ec722d57 [ROCm/hip commit: db36676f5de7ce9d84e022f86dc418e8bbc9c432] --- projects/hip/CMakeLists.txt | 33 +++++++++++++++++ projects/hip/hip-config.cmake.in | 62 ++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 projects/hip/hip-config.cmake.in diff --git a/projects/hip/CMakeLists.txt b/projects/hip/CMakeLists.txt index 9af405b836..5bc31a2bd7 100644 --- a/projects/hip/CMakeLists.txt +++ b/projects/hip/CMakeLists.txt @@ -238,6 +238,39 @@ if(NOT ${INSTALL_SOURCE} EQUAL 0) install(DIRECTORY cmake DESTINATION .) endif() +############################# +# hip-config +############################# +set(LIB_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib) +set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include) +set(BIN_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/bin) +set(CONFIG_PACKAGE_INSTALL_DIR ${LIB_INSTALL_DIR}/cmake/hip) + +if(HIP_PLATFORM STREQUAL "hcc") + install(TARGETS hip_hcc_static hip_hcc hip_device EXPORT hip-targets DESTINATION ${LIB_INSTALL_DIR}) + install(EXPORT hip-targets DESTINATION ${CONFIG_PACKAGE_INSTALL_DIR} NAMESPACE hip::) + include(CMakePackageConfigHelpers) + + configure_package_config_file( + hip-config.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/hip-config.cmake + INSTALL_DESTINATION ${CONFIG_PACKAGE_INSTALL_DIR} + PATH_VARS LIB_INSTALL_DIR INCLUDE_INSTALL_DIR BIN_INSTALL_DIR + ) + write_basic_package_version_file( + ${CMAKE_CURRENT_BINARY_DIR}/hip-config-version.cmake + VERSION "${HIP_VERSION}" + COMPATIBILITY SameMajorVersion + ) + install( + FILES + ${CMAKE_CURRENT_BINARY_DIR}/hip-config.cmake + ${CMAKE_CURRENT_BINARY_DIR}/hip-config-version.cmake + DESTINATION + ${CONFIG_PACKAGE_INSTALL_DIR} + ) +endif() + ############################# # Packaging steps ############################# diff --git a/projects/hip/hip-config.cmake.in b/projects/hip/hip-config.cmake.in new file mode 100644 index 0000000000..bcdaf0671d --- /dev/null +++ b/projects/hip/hip-config.cmake.in @@ -0,0 +1,62 @@ +@PACKAGE_INIT@ + +include(CMakeFindDependencyMacro OPTIONAL RESULT_VARIABLE _CMakeFindDependencyMacro_FOUND) +if (NOT _CMakeFindDependencyMacro_FOUND) + macro(find_dependency dep) + if (NOT ${dep}_FOUND) + set(cmake_fd_version) + if (${ARGC} GREATER 1) + set(cmake_fd_version ${ARGV1}) + endif() + set(cmake_fd_exact_arg) + if(${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION_EXACT) + set(cmake_fd_exact_arg EXACT) + endif() + set(cmake_fd_quiet_arg) + if(${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY) + set(cmake_fd_quiet_arg QUIET) + endif() + set(cmake_fd_required_arg) + if(${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED) + set(cmake_fd_required_arg REQUIRED) + endif() + find_package(${dep} ${cmake_fd_version} + ${cmake_fd_exact_arg} + ${cmake_fd_quiet_arg} + ${cmake_fd_required_arg} + ) + string(TOUPPER ${dep} cmake_dep_upper) + if (NOT ${dep}_FOUND AND NOT ${cmake_dep_upper}_FOUND) + set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "${CMAKE_FIND_PACKAGE_NAME} could not be found because dependency ${dep} could not be found.") + set(${CMAKE_FIND_PACKAGE_NAME}_FOUND False) + return() + endif() + set(cmake_fd_version) + set(cmake_fd_required_arg) + set(cmake_fd_quiet_arg) + set(cmake_fd_exact_arg) + endif() + endmacro() +endif() + +find_dependency(hcc) + +set_and_check( hip_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@" ) +set_and_check( hip_INCLUDE_DIRS "${hip_INCLUDE_DIR}" ) +set_and_check( hip_LIB_INSTALL_DIR "@PACKAGE_LIB_INSTALL_DIR@" ) +set_and_check( hip_BIN_INSTALL_DIR "@PACKAGE_BIN_INSTALL_DIR@" ) + +include( "${CMAKE_CURRENT_LIST_DIR}/hip-targets.cmake" ) + +set( hip_LIBRARIES hip::hip_hcc) +set( hip_LIBRARY ${hip_LIBRARIES}) + +set(HIP_INCLUDE_DIR ${hip_INCLUDE_DIR}) +set(HIP_INCLUDE_DIRS ${hip_INCLUDE_DIRS}) +set(HIP_LIB_INSTALL_DIR ${hip_LIB_INSTALL_DIR}) +set(HIP_BIN_INSTALL_DIR ${hip_BIN_INSTALL_DIR}) +set(HIP_LIBRARIES ${hip_LIBRARIES}) +set(HIP_LIBRARY ${hip_LIBRARY}) + +set_and_check(HIP_HIPCC_EXECUTABLE "${hip_BIN_INSTALL_DIR}/hipcc") +set_and_check(HIP_HIPCONFIG_EXECUTABLE "${hip_BIN_INSTALL_DIR}/hipconfig") From 31dfd8bb1fdfd66a56119feeb79ba75b077349ff Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Mon, 13 Feb 2017 18:13:49 +0300 Subject: [PATCH 139/281] [HIPIFY] Minor refactoring + insertHipHeaders function is added to Cuda2Hip class; + fix replacement ending for hip header. [ROCm/hip commit: c3ab4d5c5eb0ba90171154d4972b8be1737c6a27] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 34 +++++++++------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index 468b42297c..cf9eae51b7 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -1711,6 +1711,17 @@ protected: // llvm::outs() << " [HIPIFY] expansion line num: " << fullSL.getExpansionLineNumber() << " for replacement '" << rep.getReplacementText() << "'\n"; } } + void insertHipHeaders(Cuda2Hip *owner, const SourceManager &SM) { + if (owner->countReps[CONV_INCLUDE_CUDA_MAIN_H] == 0 && countReps[CONV_INCLUDE_CUDA_MAIN_H] == 0 && Replace->size() > 0) { + std::string repName = "#include "; + hipCounter counter = { repName, CONV_INCLUDE_CUDA_MAIN_H, API_RUNTIME }; + updateCounters(counter, repName); + SourceLocation sl = SM.getLocForStartOfFile(SM.getMainFileID()); + FullSourceLoc fullSL(sl, SM); + Replacement Rep(SM, sl, 0, repName + "\n"); + insertReplacement(Rep, fullSL); + } + } void updateCountersExt(const hipCounter &counter, const std::string &cudaName) { std::map *map = &cuda2hipConverted; @@ -2464,17 +2475,7 @@ public: if (unresolvedTemplateName(Result)) break; break; } while (false); - if (PP->countReps[CONV_INCLUDE_CUDA_MAIN_H] == 0 && - countReps[CONV_INCLUDE_CUDA_MAIN_H] == 0 && Replace->size() > 0) { - StringRef repName = "#include \n"; - SourceManager *SM = Result.SourceManager; - SourceLocation sl = SM->getLocForStartOfFile(SM->getMainFileID()); - Replacement Rep(*SM, sl, 0, repName); - FullSourceLoc fullSL(sl, *SM); - insertReplacement(Rep, fullSL); - hipCounter counter = { repName, CONV_INCLUDE_CUDA_MAIN_H, API_RUNTIME }; - updateCounters(counter, repName); - } + insertHipHeaders(PP, *Result.SourceManager); } private: @@ -2483,16 +2484,7 @@ private: }; void HipifyPPCallbacks::handleEndSource() { - if (Match->countReps[CONV_INCLUDE_CUDA_MAIN_H] == 0 && - countReps[CONV_INCLUDE_CUDA_MAIN_H] == 0 && Replace->size() > 0) { - StringRef repName = "#include \n"; - SourceLocation sl = _sm->getLocForStartOfFile(_sm->getMainFileID()); - Replacement Rep(*_sm, sl, 0, repName); - FullSourceLoc fullSL(sl, *_sm); - insertReplacement(Rep, fullSL); - hipCounter counter = { repName, CONV_INCLUDE_CUDA_MAIN_H, API_RUNTIME }; - updateCounters(counter, repName); - } + insertHipHeaders(Match, *_sm); } } // end anonymous namespace From af7455bd64a15fcdb3969766139af93d9a8a0077 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Tue, 14 Feb 2017 16:28:05 +0300 Subject: [PATCH 140/281] [HIPIFY] Narrow cudaKernelCallExpr matcher. [Explanation] Narrow cudaKernelCallExpr matcher to isExpansionInMainFile() - to the file being actually converted (without system includes). But as for Thrust, there are *.inl files, which are nevertheless being expanded in main file. These files contain cuda kernel launches, which are not converted successfully by hipify, for instance: thrust/system/cuda/detail/detail/launch_closure.inl:98:23. [ToDo] File a bug on cudaKernelCallExpr matcher for conversion error (thrust\examples\cuda\). [ROCm/hip commit: d1cfcf55f19e919176b108b3c98d53bd29d7205f] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index cf9eae51b7..ec6a2dacff 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -2494,7 +2494,7 @@ void addAllMatchers(ast_matchers::MatchFinder &Finder, Cuda2HipCallback *Callbac callee(functionDecl(matchesName("cu.*")))) .bind("cudaCall"), Callback); - Finder.addMatcher(cudaKernelCallExpr().bind("cudaLaunchKernel"), Callback); + Finder.addMatcher(cudaKernelCallExpr(isExpansionInMainFile()).bind("cudaLaunchKernel"), Callback); Finder.addMatcher(memberExpr(isExpansionInMainFile(), hasObjectExpression(hasType(cxxRecordDecl( matchesName("__cuda_builtin_"))))) From f6483f36a1d5f64c7a0ffdc0afb6e2401eb73f9e Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Tue, 14 Feb 2017 17:23:09 +0300 Subject: [PATCH 141/281] [HIPIFY] Fix warnings on unhandled refs. CUstream_st -> hipStream_t * CUevent_st -> hipEvent_t * (fixed, was -> hipEvent_t) Warning: [HIPIFY] warning: the following reference is not handled: 'CUstream_st' [struct var ptr]. (thrust/examples/cuda/async_reduce.cu) [ROCm/hip commit: a6db38c337f96f747547aae51ef7579cfa4ee83d] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index ec6a2dacff..e8caaf1af1 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -450,6 +450,7 @@ struct cuda2hipMap { cuda2hipRename["CUcontext"] = {"hipCtx_t", CONV_TYPE, API_DRIVER}; cuda2hipRename["CUmodule"] = {"hipModule_t", CONV_TYPE, API_DRIVER}; cuda2hipRename["CUstream"] = {"hipStream_t", CONV_TYPE, API_DRIVER}; + cuda2hipRename["CUstream_st"] = {"hipStream_t *", CONV_TYPE, API_DRIVER}; // Stream Flags cuda2hipRename["CU_STREAM_DEFAULT"] = {"hipStreamDefault", CONV_STREAM, API_DRIVER}; cuda2hipRename["CU_STREAM_NON_BLOCKING"] = {"hipStreamNonBlocking", CONV_STREAM, API_DRIVER}; @@ -497,7 +498,7 @@ struct cuda2hipMap { // Events cuda2hipRename["CUevent"] = {"hipEvent_t", CONV_TYPE, API_DRIVER}; - cuda2hipRename["CUevent_st"] = {"hipEvent_t", CONV_TYPE, API_DRIVER}; + cuda2hipRename["CUevent_st"] = {"hipEvent_t *", CONV_TYPE, API_DRIVER}; // Event Flags cuda2hipRename["CU_EVENT_DEFAULT"] = {"hipEventDefault", CONV_EVENT, API_DRIVER}; cuda2hipRename["CU_EVENT_BLOCKING_SYNC"] = {"hipEventBlockingSync", CONV_EVENT, API_DRIVER}; From ffedb9388ff77414633411ed1ec85623a7d56f82 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Tue, 14 Feb 2017 17:34:10 +0300 Subject: [PATCH 142/281] [HIPIFY] Add more unhandled refs for opaque pointers. CUfunc_st -> hipFunction_t * CUctx_st -> hipCtx_t * CUmod_st -> hipModule_t * [ROCm/hip commit: b3941dd54645dbf5922c0ea82ed65425295caada] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index e8caaf1af1..46f8d48b0f 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -429,6 +429,7 @@ struct cuda2hipMap { // cuda2hipRename["CUpointer_attribute"] = {"hipPointerAttribute_t", CONV_TYPE, API_DRIVER}; cuda2hipRename["CUfunction"] = {"hipFunction_t", CONV_TYPE, API_DRIVER}; + cuda2hipRename["CUfunc_st"] = {"hipFunction_t *", CONV_TYPE, API_DRIVER}; // unsupported yet by HIP cuda2hipRename["CUfunction_attribute_enum"] = {"hipFuncAttribute_t", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; @@ -448,7 +449,9 @@ struct cuda2hipMap { cuda2hipRename["CU_SHARED_MEM_CONFIG_EIGHT_BYTE_BANK_SIZE"] = {"hipSharedMemBankSizeEightByte", CONV_DEV, API_DRIVER}; cuda2hipRename["CUcontext"] = {"hipCtx_t", CONV_TYPE, API_DRIVER}; + cuda2hipRename["CUctx_st"] = {"hipCtx_t *", CONV_TYPE, API_DRIVER}; cuda2hipRename["CUmodule"] = {"hipModule_t", CONV_TYPE, API_DRIVER}; + cuda2hipRename["CUmod_st"] = {"hipModule_t *", CONV_TYPE, API_DRIVER}; cuda2hipRename["CUstream"] = {"hipStream_t", CONV_TYPE, API_DRIVER}; cuda2hipRename["CUstream_st"] = {"hipStream_t *", CONV_TYPE, API_DRIVER}; // Stream Flags From f8ad2028a4ed74d95a42a86677d5bc3414bf1fc0 Mon Sep 17 00:00:00 2001 From: scchan Date: Tue, 14 Feb 2017 11:52:09 -0500 Subject: [PATCH 143/281] calls isfinite,isinf,isnan from the std namespace on the host Change-Id: Ica2370075b89713eecfd96102e2f4e0ab9961ce4 [ROCm/hip commit: ad9d9b25c1b378a570d80fcfad6f680905b5466d] --- .../tests/src/deviceLib/hipDoublePrecisionMathHost.cpp | 8 ++++---- .../tests/src/deviceLib/hipSinglePrecisionMathHost.cpp | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathHost.cpp b/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathHost.cpp index 7f63d32e3d..33f4010a2b 100644 --- a/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathHost.cpp +++ b/projects/hip/tests/src/deviceLib/hipDoublePrecisionMathHost.cpp @@ -73,9 +73,9 @@ __host__ void double_precision_math_functions() frexp(0.0, &iX); hypot(1.0, 0.0); ilogb(1.0); - isfinite(0.0); - isinf(0.0); - isnan(0.0); + std::isfinite(0.0); + std::isinf(0.0); + std::isnan(0.0); j0(0.0); j1(0.0); jn(-1.0, 1.0); @@ -119,7 +119,7 @@ __host__ void double_precision_math_functions() //rsqrt(1.0); scalbln(0.0, 1); scalbn(0.0, 1); - signbit(1.0); + std::signbit(1.0); sin(0.0); sincos(0.0, &fX, &fY); //sincospi(0.0, &fX, &fY); diff --git a/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathHost.cpp b/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathHost.cpp index 83bc740e9e..cc554a5c36 100644 --- a/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathHost.cpp +++ b/projects/hip/tests/src/deviceLib/hipSinglePrecisionMathHost.cpp @@ -76,9 +76,9 @@ __host__ void single_precision_math_functions() frexpf(0.0f, &iX); hypotf(1.0f, 0.0f); ilogbf(1.0f); - isfinite(0.0f); - isinf(0.0f); - isnan(0.0f); + std::isfinite(0.0f); + std::isinf(0.0f); + std::isnan(0.0f); j0f(0.0f); j1f(0.0f); jnf(-1.0f, 1.0f); @@ -121,7 +121,7 @@ __host__ void single_precision_math_functions() ///rsqrtf(1.0f); scalblnf(0.0f, 1); scalbnf(0.0f, 1); - signbit(1.0f); + std::signbit(1.0f); sincosf(0.0f, &fX, &fY); //sincospif(0.0f, &fX, &fY); sinf(0.0f); From 8a8a7bc84343a10ff18d5700a0936b94b41d5ada Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Tue, 14 Feb 2017 21:36:49 +0300 Subject: [PATCH 144/281] [HIPIFY] Add file:line:col info to [HIPIFY] warnings/errors. [ROCm/hip commit: e39ed24a5080741532a499e3c95bf9a9bc182c9e] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 127 +++++++++++++-------- 1 file changed, 79 insertions(+), 48 deletions(-) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index 46f8d48b0f..1bcd03feca 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -1695,7 +1695,8 @@ StringRef unquoteStr(StringRef s) { class Cuda2Hip { public: - Cuda2Hip(Replacements *R): Replace(R) {} + Cuda2Hip(Replacements *R, const std::string &srcFileName) : + Replace(R), mainFileName(srcFileName) {} uint64_t countReps[CONV_LAST] = { 0 }; uint64_t countApiReps[API_LAST] = { 0 }; uint64_t countRepsUnsupported[CONV_LAST] = { 0 }; @@ -1704,15 +1705,28 @@ public: std::map cuda2hipUnconverted; std::set LOCs; + enum msgTypes { + HIPIFY_ERROR = 0, + HIPIFY_WARNING + }; + + std::string getMsgType(msgTypes type) { + switch (type) { + case HIPIFY_ERROR: return "error"; + default: + case HIPIFY_WARNING: return "warning"; + } + } + protected: struct cuda2hipMap N; Replacements *Replace; + std::string mainFileName; virtual void insertReplacement(const Replacement &rep, const FullSourceLoc &fullSL) { Replace->insert(rep); if (PrintStats) { LOCs.insert(fullSL.getExpansionLineNumber()); - // llvm::outs() << " [HIPIFY] expansion line num: " << fullSL.getExpansionLineNumber() << " for replacement '" << rep.getReplacementText() << "'\n"; } } void insertHipHeaders(Cuda2Hip *owner, const SourceManager &SM) { @@ -1727,6 +1741,11 @@ protected: } } + void printHipifyMessage(const SourceManager &SM, const SourceLocation &sl, const std::string &message, msgTypes msgType = HIPIFY_WARNING) { + FullSourceLoc fullSL(sl, SM); + llvm::errs() << "[HIPIFY] " << getMsgType(msgType) << ": " << mainFileName << ":" << fullSL.getExpansionLineNumber() << ":" << fullSL.getExpansionColumnNumber() << ": " << message << "\n"; + } + void updateCountersExt(const hipCounter &counter, const std::string &cudaName) { std::map *map = &cuda2hipConverted; std::map *mapTotal = &cuda2hipConvertedTotal; @@ -1783,7 +1802,8 @@ protected: insertReplacement(Rep, fullSL); } } else { - // llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [string literal].\n"; + // std::string msg = "the following reference is not handled: '" + name.str() + "' [string literal]."; + // printHipifyMessage(SM, start, msg); } if (end == StringRef::npos) { break; @@ -1797,8 +1817,8 @@ class Cuda2HipCallback; class HipifyPPCallbacks : public PPCallbacks, public SourceFileCallbacks, public Cuda2Hip { public: - HipifyPPCallbacks(Replacements *R) - : Cuda2Hip(R), SeenEnd(false), _sm(nullptr), _pp(nullptr) {} + HipifyPPCallbacks(Replacements *R, const std::string &mainFileName) + : Cuda2Hip(R, mainFileName), SeenEnd(false), _sm(nullptr), _pp(nullptr) {} virtual bool handleBeginSource(CompilerInstance &CI, StringRef Filename) override { Preprocessor &PP = CI.getPreprocessor(); @@ -2005,12 +2025,12 @@ private: if (const CallExpr *call = Result.Nodes.getNodeAs("cudaCall")) { const FunctionDecl *funcDcl = call->getDirectCallee(); StringRef name = funcDcl->getDeclName().getAsString(); + SourceManager *SM = Result.SourceManager; + SourceLocation sl = call->getLocStart(); const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { if (!found->second.unsupported) { - SourceManager *SM = Result.SourceManager; StringRef repName = found->second.hipName; - SourceLocation sl = call->getLocStart(); size_t length = name.size(); bool bReplace = true; if (SM->isMacroArgExpansion(sl)) { @@ -2037,7 +2057,8 @@ private: updateCounters(found->second, name.str()); } } else { - llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [function call].\n"; + std::string msg = "the following reference is not handled: '" + name.str() + "' [function call]."; + printHipifyMessage(*SM, sl, msg); } return true; } @@ -2121,6 +2142,8 @@ private: dyn_cast(threadIdx->getBase())) { if (const DeclRefExpr *declRef = dyn_cast(refBase->getSourceExpr())) { + SourceLocation sl = threadIdx->getLocStart(); + SourceManager *SM = Result.SourceManager; StringRef name = declRef->getDecl()->getName(); StringRef memberName = threadIdx->getMemberDecl()->getName(); size_t pos = memberName.find_first_not_of("__fetch_builtin_"); @@ -2132,14 +2155,13 @@ private: updateCounters(found->second, name.str()); if (!found->second.unsupported) { StringRef repName = found->second.hipName; - SourceLocation sl = threadIdx->getLocStart(); - SourceManager *SM = Result.SourceManager; Replacement Rep(*SM, sl, name.size(), repName); FullSourceLoc fullSL(sl, *SM); insertReplacement(Rep, fullSL); } } else { - llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [builtin].\n"; + std::string msg = "the following reference is not handled: '" + name.str() + "' [builtin]."; + printHipifyMessage(*SM, sl, msg); } } } @@ -2151,19 +2173,20 @@ private: bool cudaEnumConstantRef(const MatchFinder::MatchResult &Result) { if (const DeclRefExpr *enumConstantRef = Result.Nodes.getNodeAs("cudaEnumConstantRef")) { StringRef name = enumConstantRef->getDecl()->getNameAsString(); + SourceLocation sl = enumConstantRef->getLocStart(); + SourceManager *SM = Result.SourceManager; const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { updateCounters(found->second, name.str()); if (!found->second.unsupported) { StringRef repName = found->second.hipName; - SourceLocation sl = enumConstantRef->getLocStart(); - SourceManager *SM = Result.SourceManager; Replacement Rep(*SM, sl, name.size(), repName); FullSourceLoc fullSL(sl, *SM); insertReplacement(Rep, fullSL); } } else { - llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [enum constant ref].\n"; + std::string msg = "the following reference is not handled: '" + name.str() + "' [enum constant ref]."; + printHipifyMessage(*SM, sl, msg); } return true; } @@ -2179,19 +2202,20 @@ private: QualType QT = enumConstantDecl->getType().getUnqualifiedType(); name = QT.getAsString(); } + SourceLocation sl = enumConstantDecl->getLocStart(); + SourceManager *SM = Result.SourceManager; const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { updateCounters(found->second, name.str()); if (!found->second.unsupported) { StringRef repName = found->second.hipName; - SourceLocation sl = enumConstantDecl->getLocStart(); - SourceManager *SM = Result.SourceManager; Replacement Rep(*SM, sl, name.size(), repName); FullSourceLoc fullSL(sl, *SM); insertReplacement(Rep, fullSL); } } else { - llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [enum constant decl].\n"; + std::string msg = "the following reference is not handled: '" + name.str() + "' [enum constant decl]."; + printHipifyMessage(*SM, sl, msg); } return true; } @@ -2206,19 +2230,20 @@ private: } QT = QT.getUnqualifiedType(); StringRef name = QT.getAsString(); + SourceLocation sl = typedefVar->getLocStart(); + SourceManager *SM = Result.SourceManager; const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { updateCounters(found->second, name.str()); if (!found->second.unsupported) { StringRef repName = found->second.hipName; - SourceLocation sl = typedefVar->getLocStart(); - SourceManager *SM = Result.SourceManager; Replacement Rep(*SM, sl, name.size(), repName); FullSourceLoc fullSL(sl, *SM); insertReplacement(Rep, fullSL); } } else { - llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [typedef var].\n"; + std::string msg = "the following reference is not handled: '" + name.str() + "' [typedef var]."; + printHipifyMessage(*SM, sl, msg); } return true; } @@ -2229,6 +2254,9 @@ private: if (const VarDecl *typedefVarPtr = Result.Nodes.getNodeAs("cudaTypedefVarPtr")) { const Type *t = typedefVarPtr->getType().getTypePtrOrNull(); if (t) { + SourceManager *SM = Result.SourceManager; + TypeLoc TL = typedefVarPtr->getTypeSourceInfo()->getTypeLoc(); + SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); QualType QT = t->getPointeeType(); QT = QT.getUnqualifiedType(); StringRef name = QT.getAsString(); @@ -2237,16 +2265,14 @@ private: updateCounters(found->second, name.str()); if (!found->second.unsupported) { StringRef repName = found->second.hipName; - TypeLoc TL = typedefVarPtr->getTypeSourceInfo()->getTypeLoc(); - SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); - SourceManager *SM = Result.SourceManager; Replacement Rep(*SM, sl, name.size(), repName); FullSourceLoc fullSL(sl, *SM); insertReplacement(Rep, fullSL); } } else { - llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [typedef var ptr].\n"; + std::string msg = "the following reference is not handled: '" + name.str() + "' [typedef var ptr]."; + printHipifyMessage(*SM, sl, msg); } } return true; @@ -2260,20 +2286,21 @@ private: ->getAsStructureType() ->getDecl() ->getNameAsString(); + TypeLoc TL = structVar->getTypeSourceInfo()->getTypeLoc(); + SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); + SourceManager *SM = Result.SourceManager; const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { updateCounters(found->second, name.str()); if (!found->second.unsupported) { StringRef repName = found->second.hipName; - TypeLoc TL = structVar->getTypeSourceInfo()->getTypeLoc(); - SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); - SourceManager *SM = Result.SourceManager; Replacement Rep(*SM, sl, name.size(), repName); FullSourceLoc fullSL(sl, *SM); insertReplacement(Rep, fullSL); } } else { - llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [struct var].\n"; + std::string msg = "the following reference is not handled: '" + name.str() + "' [struct var]."; + printHipifyMessage(*SM, sl, msg); } return true; } @@ -2284,21 +2311,22 @@ private: if (const VarDecl *structVarPtr = Result.Nodes.getNodeAs("cudaStructVarPtr")) { const Type *t = structVarPtr->getType().getTypePtrOrNull(); if (t) { + TypeLoc TL = structVarPtr->getTypeSourceInfo()->getTypeLoc(); + SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); + SourceManager *SM = Result.SourceManager; StringRef name = t->getPointeeCXXRecordDecl()->getName(); const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { updateCounters(found->second, name.str()); if (!found->second.unsupported) { StringRef repName = found->second.hipName; - TypeLoc TL = structVarPtr->getTypeSourceInfo()->getTypeLoc(); - SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); - SourceManager *SM = Result.SourceManager; Replacement Rep(*SM, sl, name.size(), repName); FullSourceLoc fullSL(sl, *SM); insertReplacement(Rep, fullSL); } } else { - llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [struct var ptr].\n"; + std::string msg = "the following reference is not handled: '" + name.str() + "' [struct var ptr]."; + printHipifyMessage(*SM, sl, msg); } } return true; @@ -2309,6 +2337,9 @@ private: bool cudaStructSizeOf(const MatchFinder::MatchResult &Result) { if (const UnaryExprOrTypeTraitExpr *expr = Result.Nodes.getNodeAs("cudaStructSizeOf")) { TypeSourceInfo *typeInfo = expr->getArgumentTypeInfo(); + TypeLoc TL = typeInfo->getTypeLoc(); + SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); + SourceManager *SM = Result.SourceManager; QualType QT = typeInfo->getType().getUnqualifiedType(); const Type *type = QT.getTypePtr(); StringRef name = type->getAsCXXRecordDecl()->getName(); @@ -2317,15 +2348,13 @@ private: updateCounters(found->second, name.str()); if (!found->second.unsupported) { StringRef repName = found->second.hipName; - TypeLoc TL = typeInfo->getTypeLoc(); - SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); - SourceManager *SM = Result.SourceManager; Replacement Rep(*SM, sl, name.size(), repName); FullSourceLoc fullSL(sl, *SM); insertReplacement(Rep, fullSL); } } else { - llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [struct sizeof].\n"; + std::string msg = "the following reference is not handled: '" + name.str() + "' [struct sizeof]."; + printHipifyMessage(*SM, sl, msg); } return true; } @@ -2383,20 +2412,21 @@ private: if (t->isStructureOrClassType()) { name = t->getAsCXXRecordDecl()->getName(); } + TypeLoc TL = paramDecl->getTypeSourceInfo()->getTypeLoc(); + SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); + SourceManager *SM = Result.SourceManager; const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { updateCounters(found->second, name.str()); if (!found->second.unsupported) { StringRef repName = found->second.hipName; - TypeLoc TL = paramDecl->getTypeSourceInfo()->getTypeLoc(); - SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); - SourceManager *SM = Result.SourceManager; Replacement Rep(*SM, sl, name.size(), repName); FullSourceLoc fullSL(sl, *SM); insertReplacement(Rep, fullSL); } } else { - llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [param decl].\n"; + std::string msg = "the following reference is not handled: '" + name.str() + "' [param decl]."; + printHipifyMessage(*SM, sl, msg); } return true; } @@ -2407,6 +2437,9 @@ private: if (const ParmVarDecl *paramDeclPtr = Result.Nodes.getNodeAs("cudaParamDeclPtr")) { const Type *pt = paramDeclPtr->getType().getTypePtrOrNull(); if (pt) { + TypeLoc TL = paramDeclPtr->getTypeSourceInfo()->getTypeLoc(); + SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); + SourceManager *SM = Result.SourceManager; QualType QT = pt->getPointeeType(); const Type *t = QT.getTypePtr(); StringRef name = t->isStructureOrClassType() @@ -2417,15 +2450,13 @@ private: updateCounters(found->second, name.str()); if (!found->second.unsupported) { StringRef repName = found->second.hipName; - TypeLoc TL = paramDeclPtr->getTypeSourceInfo()->getTypeLoc(); - SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); - SourceManager *SM = Result.SourceManager; Replacement Rep(*SM, sl, name.size(), repName); FullSourceLoc fullSL(sl, *SM); insertReplacement(Rep, fullSL); } } else { - llvm::outs() << "[HIPIFY] warning: the following reference is not handled: '" << name << "' [param decl ptr].\n"; + std::string msg = "the following reference is not handled: '" + name.str() + "' [param decl ptr]."; + printHipifyMessage(*SM, sl, msg); } } return true; @@ -2455,8 +2486,8 @@ private: } public: - Cuda2HipCallback(Replacements *Replace, ast_matchers::MatchFinder *parent, HipifyPPCallbacks *PPCallbacks) - : Cuda2Hip(Replace), owner(parent), PP(PPCallbacks) { + Cuda2HipCallback(Replacements *Replace, ast_matchers::MatchFinder *parent, HipifyPPCallbacks *PPCallbacks, const std::string &mainFileName) + : Cuda2Hip(Replace, mainFileName), owner(parent), PP(PPCallbacks) { PP->setMatch(this); } @@ -2884,8 +2915,8 @@ int main(int argc, const char **argv) { } RefactoringTool Tool(OptionsParser.getCompilations(), dst); ast_matchers::MatchFinder Finder; - HipifyPPCallbacks PPCallbacks(&Tool.getReplacements()); - Cuda2HipCallback Callback(&Tool.getReplacements(), &Finder, &PPCallbacks); + HipifyPPCallbacks PPCallbacks(&Tool.getReplacements(), src); + Cuda2HipCallback Callback(&Tool.getReplacements(), &Finder, &PPCallbacks, src); addAllMatchers(Finder, &Callback); From 6f5ad4e7e66876271c4f80ace6af8e9495d365df Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Wed, 15 Feb 2017 19:48:31 +0300 Subject: [PATCH 145/281] [HIPIFY] [Fix] Crash on thrust example fallback_allocator.cu. https://github.com/GPUOpen-ProfessionalCompute-Tools/HIP/issues/65 [Bug] Access violation in cudaStructVar matcher. StringRef name = structVar->getType() ->getAsStructureType() ->getDecl() // <--- Access Violation ->getNameAsString(); [Solution] Add isStructureType() check before getting type as Struct. [ToDo] Find case-studies for that StructVar matcher with types other than Struct. [ROCm/hip commit: 950434f4af34387993f5d92c0a39a4179de82932] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 38 ++++++++++++---------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index 1bcd03feca..3ed9af148c 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -2282,25 +2282,27 @@ private: bool cudaStructVar(const MatchFinder::MatchResult &Result) { if (const VarDecl *structVar = Result.Nodes.getNodeAs("cudaStructVar")) { - StringRef name = structVar->getType() - ->getAsStructureType() - ->getDecl() - ->getNameAsString(); - TypeLoc TL = structVar->getTypeSourceInfo()->getTypeLoc(); - SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); - SourceManager *SM = Result.SourceManager; - const auto found = N.cuda2hipRename.find(name); - if (found != N.cuda2hipRename.end()) { - updateCounters(found->second, name.str()); - if (!found->second.unsupported) { - StringRef repName = found->second.hipName; - Replacement Rep(*SM, sl, name.size(), repName); - FullSourceLoc fullSL(sl, *SM); - insertReplacement(Rep, fullSL); + QualType QT = structVar->getType(); + // ToDo: find case-studies with types other than Struct. + if (QT->isStructureType()) { + StringRef name = QT.getTypePtr()->getAsStructureType()->getDecl()->getNameAsString(); + TypeLoc TL = structVar->getTypeSourceInfo()->getTypeLoc(); + SourceLocation sl = TL.getUnqualifiedLoc().getLocStart(); + SourceManager *SM = Result.SourceManager; + const auto found = N.cuda2hipRename.find(name); + if (found != N.cuda2hipRename.end()) { + updateCounters(found->second, name.str()); + if (!found->second.unsupported) { + StringRef repName = found->second.hipName; + Replacement Rep(*SM, sl, name.size(), repName); + FullSourceLoc fullSL(sl, *SM); + insertReplacement(Rep, fullSL); + } + } + else { + std::string msg = "the following reference is not handled: '" + name.str() + "' [struct var]."; + printHipifyMessage(*SM, sl, msg); } - } else { - std::string msg = "the following reference is not handled: '" + name.str() + "' [struct var]."; - printHipifyMessage(*SM, sl, msg); } return true; } From 3cd2b00059c3d8cb562f7ec14dc414e15a5f3eb1 Mon Sep 17 00:00:00 2001 From: Siu Chi Chan Date: Mon, 13 Feb 2017 11:50:45 -0500 Subject: [PATCH 146/281] Squashed commit of the following: commit 931d3de6c1c903cfd47842bc5026a9294ac492b4 Author: Siu Chi Chan Date: Mon Feb 13 10:54:06 2017 -0500 only force to libstdc++ if the g++ is older than version 5 since hcc already defaults to libstdc++ with newer g++ commit 1ef8d71aa788de7b9eead4906fe56186f06d7d3f Author: scchan Date: Sun Feb 12 14:44:11 2017 -0500 remove hardcoded -lc++ in tests commit 5d99ef338eb3a66523cc9ddd139e86c6fd707b9c Author: scchan Date: Sun Feb 12 14:35:46 2017 -0500 force include libstdc++ headers and stdc++ only if g++ version < 5 since hcc uses libstdc++ by default if g++ > 5 is present commit a2bc21b24d100feefe91cd3cb2271238bda0738a Author: scchan Date: Fri Feb 10 04:36:27 2017 -0500 use hcc-config to generate compiler and linker flags Change-Id: I13a79629c0adfd75439a47d0488ff4fd619c55ba (cherry picked from commit 866e744e40cf1378af8a679b54959bf5226c340f) [ROCm/hip commit: 806deeb476e4cfce239552ac623ff6254f887a0a] --- projects/hip/CMakeLists.txt | 10 +++-- projects/hip/bin/hipcc | 37 ++++++------------- .../hip/tests/src/context/hipCtx_simple.cpp | 2 +- projects/hip/tests/src/hipHcc.cpp | 4 +- .../src/kernel/hipLanguageExtensions.cpp | 2 +- 5 files changed, 22 insertions(+), 33 deletions(-) diff --git a/projects/hip/CMakeLists.txt b/projects/hip/CMakeLists.txt index 5bc31a2bd7..42926ad53d 100644 --- a/projects/hip/CMakeLists.txt +++ b/projects/hip/CMakeLists.txt @@ -158,7 +158,8 @@ if(HIP_PLATFORM STREQUAL "hcc") set(HIP_HCC_BUILD_FLAGS "${HIP_HCC_BUILD_FLAGS} -DHIP_VERSION_MAJOR=${HIP_VERSION_MAJOR} -DHIP_VERSION_MINOR=${HIP_VERSION_MINOR} -DHIP_VERSION_PATCH=${HIP_VERSION_PATCH}") # Add remaining flags - set(HIP_HCC_BUILD_FLAGS "${HIP_HCC_BUILD_FLAGS} -fPIC -hc -I${HCC_HOME}/include -I${HSA_PATH}/include -I/opt/rocm/libhsakmt/include -I/usr/local/include/c++/v1 -stdlib=libc++") + execute_process(COMMAND ${HCC_HOME}/bin/hcc-config --cxxflags OUTPUT_VARIABLE HCC_CXX_FLAGS) + set(HIP_HCC_BUILD_FLAGS "${HIP_HCC_BUILD_FLAGS} -fPIC ${HCC_CXX_FLAGS} -I${HSA_PATH}/include -I/opt/rocm/libhsakmt/include") # Set compiler and compiler flags set(CMAKE_CXX_COMPILER "${HCC_HOME}/bin/hcc") @@ -185,12 +186,13 @@ if(HIP_PLATFORM STREQUAL "hcc") src/device_functions.cpp src/math_functions.cpp) - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -L${HCC_HOME}/lib -lmcwamp -Wl,-Bsymbolic -Wl,-rpath ${HCC_HOME}/lib") + execute_process(COMMAND ${HCC_HOME}/bin/hcc-config --ldflags OUTPUT_VARIABLE HCC_LD_FLAGS) + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${HCC_LD_FLAGS} -Wl,-Bsymbolic") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --amdgpu-target=gfx701 --amdgpu-target=gfx801 --amdgpu-target=gfx802 --amdgpu-target=gfx803") add_library(hip_hcc SHARED ${SOURCE_FILES_RUNTIME}) - target_link_libraries(hip_hcc c++ c++abi hc_am) + target_link_libraries(hip_hcc hc_am) add_library(hip_hcc_static STATIC ${SOURCE_FILES_RUNTIME}) - target_link_libraries(hip_hcc_static c++ c++abi hc_am) + target_link_libraries(hip_hcc_static hc_am) add_dependencies(hip_hcc_static hip_hcc) add_library(hip_device STATIC ${SOURCE_FILES_DEVICE}) add_dependencies(hip_device hip_hcc) diff --git a/projects/hip/bin/hipcc b/projects/hip/bin/hipcc index 2b84041e50..0dccb9bbc1 100755 --- a/projects/hip/bin/hipcc +++ b/projects/hip/bin/hipcc @@ -97,6 +97,8 @@ if ($HIP_PLATFORM eq "hcc") { $HIPCC=$HCC; $HIPCXXFLAGS = $HCCFLAGS; + $HIPLDFLAGS = `${HCC_HOME}/bin/hcc-config --ldflags`; + #### GCC system includes workaround #### $HCC_WA_FLAGS = " "; if ($HCC_VERSION_MAJOR eq 1) { @@ -104,34 +106,23 @@ if ($HIP_PLATFORM eq "hcc") { my $GPP_CUR_VER = `g++ -dumpversion`; $GCC_CUR_VER =~ s/\R//g; $GPP_CUR_VER =~ s/\R//g; - if (${GCC_CUR_VER} eq ${GPP_CUR_VER}) { - $HCC_WA_FLAGS .= " -I/usr/include/x86_64-linux-gnu -I/usr/include/x86_64-linux-gnu/c++/${GCC_CUR_VER} -I/usr/include/c++/${GCC_CUR_VER} "; + + my @GPP_VER_FIELDS = split('\.', $GPP_CUR_VER); + + # Only include the libstdc++ headers and libraries flags explicitly if the g++ is older than version 5. + # That's because HCC already uses libstdc++ by default if a newer g++/libstdc++ is available + if (${GCC_CUR_VER} eq ${GPP_CUR_VER} and $GPP_VER_FIELDS[0] < 5) { + $HCC_WA_FLAGS .= " -stdlib=libstdc++ -I/usr/include/x86_64-linux-gnu -I/usr/include/x86_64-linux-gnu/c++/${GCC_CUR_VER} -I/usr/include/c++/${GCC_CUR_VER} "; + # Add C++ libs for GCC. + $HIPLDFLAGS .= " -lstdc++"; } } $HIPCXXFLAGS .= " -I$HIP_PATH/include/hip/hcc_detail/cuda"; $HIPCXXFLAGS .= " -I$HSA_PATH/include"; $HIPCXXFLAGS .= " -Wno-deprecated-register"; - $HIPLDFLAGS = "-hc -L$HCC_HOME/lib -Wl,--rpath=$HCC_HOME/lib -lc++ -ldl -lpthread -Wl,--whole-archive -lmcwamp -Wl,--no-whole-archive"; - # Suppress linker warnings in case HCC distribution contains OpenCL/SPIR symbols - $HOST_OSNAME= `cat /etc/os-release | grep "^ID\=" | cut -d= -f2 | tr -d '\n'`; - $HOST_OSVER= `cat /etc/os-release | grep "^VERSION_ID\=" | cut -d= -f2 | tr -d '\n'`; - if ($HOST_OSNAME eq "ubuntu" and $HOST_OSVER eq "\"16.04\"") { - # No additional flags required - } else { - $HIPLDFLAGS .= " -Wl,--defsym=_binary_kernel_spir_end=1 -Wl,--defsym=_binary_kernel_spir_start=1 -Wl,--defsym=_binary_kernel_cl_start=1 -Wl,--defsym=_binary_kernel_cl_end=1"; - } - if ($HOST_OSNAME eq "fedora") { - $HIPCXXFLAGS .= " -I/usr/local/include/c++/v1"; - } - - # Satisfy HCC dependencies - if ($HOST_OSNAME eq "fedora") { - $HIPLDFLAGS .= " -lc++abi"; - } else { - $HIPLDFLAGS .= " -lc++abi -lsupc++"; - } + $HIPLDFLAGS .= " -lsupc++"; $HIPLDFLAGS .= " -L$HSA_PATH/lib -L$ROCM_PATH/lib -lhsa-runtime64 -lhc_am -lhsakmt"; # Add trace marker library: @@ -148,8 +139,6 @@ if ($HIP_PLATFORM eq "hcc") { $HIPLDFLAGS .= " -L$marker_lib_path -lCXLActivityLogger -Wl,--rpath=$marker_lib_path"; } - # Add C++ libs for GCC. - $HIPLDFLAGS .= " -lstdc++"; $HIPLDFLAGS .= " -lm"; if ($verbose & 0x2) { @@ -271,7 +260,6 @@ foreach $arg (@ARGV) } if(($trimarg eq '-stdlib=libstdc++') and ($setStdLib eq 0)) { - $HIPCXXFLAGS .= " -stdlib=libstdc++"; $HIPCXXFLAGS .= $HCC_WA_FLAGS; $setStdLib = 1; } @@ -372,7 +360,6 @@ if ($buildDeps and $HIP_PLATFORM eq 'nvcc') { if ($setStdLib eq 0 and $HIP_PLATFORM eq 'hcc') { - $HIPCXXFLAGS .= " -stdlib=libstdc++"; $HIPCXXFLAGS .= $HCC_WA_FLAGS; } diff --git a/projects/hip/tests/src/context/hipCtx_simple.cpp b/projects/hip/tests/src/context/hipCtx_simple.cpp index bb2b32a56b..7bfd7d76d9 100644 --- a/projects/hip/tests/src/context/hipCtx_simple.cpp +++ b/projects/hip/tests/src/context/hipCtx_simple.cpp @@ -21,7 +21,7 @@ THE SOFTWARE. */ /* HIT_START - * BUILD: %t %s ../test_common.cpp HCC_OPTIONS -stdlib=libc++ + * BUILD: %t %s ../test_common.cpp * RUN: %t * HIT_END */ diff --git a/projects/hip/tests/src/hipHcc.cpp b/projects/hip/tests/src/hipHcc.cpp index b09898309e..9357e5211a 100644 --- a/projects/hip/tests/src/hipHcc.cpp +++ b/projects/hip/tests/src/hipHcc.cpp @@ -22,8 +22,8 @@ THE SOFTWARE. // Test the HCC-specific API extensions for HIP: /* HIT_START - * BUILD: %t %s HCC_OPTIONS -stdlib=libc++ - * RUN: %t + * BUILD: %t %s + * RUN: %t EXCLUDE_HIP_PLATFORM all * HIT_END */ diff --git a/projects/hip/tests/src/kernel/hipLanguageExtensions.cpp b/projects/hip/tests/src/kernel/hipLanguageExtensions.cpp index e519a1c2a8..ebb93a8e0d 100644 --- a/projects/hip/tests/src/kernel/hipLanguageExtensions.cpp +++ b/projects/hip/tests/src/kernel/hipLanguageExtensions.cpp @@ -22,7 +22,7 @@ THE SOFTWARE. // Collection of code to make sure that various features in the hip kernel language compile. /* HIT_START - * BUILD: %t %s ../test_common.cpp HCC_OPTIONS -stdlib=libc++ + * BUILD: %t %s ../test_common.cpp * RUN: %t * HIT_END */ From c98017e48380745d9905eab4f2286119975f4c63 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Thu, 16 Feb 2017 19:38:35 +0300 Subject: [PATCH 147/281] [HIPIFY] Add safe type check for cudaChooseDevice matcher. [ROCm/hip commit: 93c1e31b36c4600054260a1d9d148996474704f2] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index 3ed9af148c..b03731e56a 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -2344,7 +2344,11 @@ private: SourceManager *SM = Result.SourceManager; QualType QT = typeInfo->getType().getUnqualifiedType(); const Type *type = QT.getTypePtr(); - StringRef name = type->getAsCXXRecordDecl()->getName(); + CXXRecordDecl *rec = type->getAsCXXRecordDecl(); + if (!rec) { + return false; + } + StringRef name = rec->getName(); const auto found = N.cuda2hipRename.find(name); if (found != N.cuda2hipRename.end()) { updateCounters(found->second, name.str()); From 2951f80caf71e98e8610293ae5e6d60ff06e4d53 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Thu, 16 Feb 2017 20:00:36 +0300 Subject: [PATCH 148/281] [HIPIFY] Add CUDA Driver LAUNCH_PARAM defines. [ROCm/hip commit: bbbe5814c18ba27fa0ce32f30f2b7b642dbd4525] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index b03731e56a..dcc4b0f010 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -312,6 +312,11 @@ struct cuda2hipMap { cuda2hipRename["cudaErrorProfilerAlreadyStopped"] = {"hipErrorProfilerAlreadyStopped", CONV_ERR, API_RUNTIME}; ///////////////////////////// CUDA DRIVER API ///////////////////////////// + // Defines + cuda2hipRename["CU_LAUNCH_PARAM_BUFFER_POINTER"] = {"HIP_LAUNCH_PARAM_BUFFER_POINTER", CONV_DEV, API_DRIVER}; + cuda2hipRename["CU_LAUNCH_PARAM_BUFFER_SIZE"] = {"HIP_LAUNCH_PARAM_BUFFER_SIZE", CONV_DEV, API_DRIVER}; + cuda2hipRename["CU_LAUNCH_PARAM_END"] = {"HIP_LAUNCH_PARAM_END", CONV_DEV, API_DRIVER}; + // Types // NOTE: CUdevice might be changed to typedef int in the future. cuda2hipRename["CUdevice"] = {"hipDevice_t", CONV_TYPE, API_DRIVER}; From 07ffedbbf3e6e27d36982dda406627ccf18d8d6f Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Thu, 16 Feb 2017 20:24:53 +0300 Subject: [PATCH 149/281] [HIPIFY] Add Inter-Process Communications (IPC) support. [ROCm/hip commit: ea95f3166a79ecd574e4994ddb3ac00d9af4ff23] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index dcc4b0f010..c9e6e9fc96 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -886,6 +886,7 @@ struct cuda2hipMap { cuda2hipRename["cudaDeviceEnablePeerAccess"] = {"hipDeviceEnablePeerAccess", CONV_DEV, API_RUNTIME}; cuda2hipRename["cudaMemcpyPeerAsync"] = {"hipMemcpyPeerAsync", CONV_MEM, API_RUNTIME}; cuda2hipRename["cudaMemcpyPeer"] = {"hipMemcpyPeer", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaIpcMemLazyEnablePeerAccess"] = {"hipIpcMemLazyEnablePeerAccess", CONV_ERR, API_RUNTIME}; // Shared memory cuda2hipRename["cudaDeviceSetSharedMemConfig"] = {"hipDeviceSetSharedMemConfig", CONV_DEV, API_RUNTIME}; @@ -928,6 +929,20 @@ struct cuda2hipMap { cuda2hipRename["cudaBindTexture"] = {"hipBindTexture", CONV_TEX, API_RUNTIME}; cuda2hipRename["cudaUnbindTexture"] = {"hipUnbindTexture", CONV_TEX, API_RUNTIME}; + // Inter-Process Communications (IPC) + // IPC types + cuda2hipRename["cudaIpcEventHandle_t"] = {"hipIpcEventHandle_t", CONV_TYPE, API_RUNTIME}; + cuda2hipRename["cudaIpcEventHandle_st"] = {"hipIpcEventHandle_t", CONV_TYPE, API_RUNTIME}; + cuda2hipRename["cudaIpcMemHandle_t"] = {"hipIpcMemHandle_t", CONV_TYPE, API_RUNTIME}; + cuda2hipRename["cudaIpcMemHandle_st"] = {"hipIpcMemHandle_t", CONV_TYPE, API_RUNTIME}; + + // IPC functions + cuda2hipRename["cudaIpcCloseMemHandle"] = {"hipIpcCloseMemHandle", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaIpcGetEventHandle"] = {"hipIpcGetEventHandle", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaIpcGetMemHandle"] = {"hipIpcGetMemHandle", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaIpcOpenEventHandle"] = {"hipIpcOpenEventHandle", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaIpcOpenMemHandle"] = {"hipIpcOpenMemHandle", CONV_DEV, API_RUNTIME}; + //---------------------------------------BLAS-------------------------------------// // Blas types cuda2hipRename["cublasHandle_t"] = {"hipblasHandle_t", CONV_TYPE, API_BLAS}; From e97beff540020ff376d16fffb4dec862ea367e2b Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Thu, 16 Feb 2017 21:10:10 +0300 Subject: [PATCH 150/281] [HIPIFY] Add Channel (Textures) support. [ROCm/hip commit: b135b24200b7d05452d5ff82b7a0d37c38141cc5] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 27 ++++++++++++++-------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index c9e6e9fc96..7070eaca04 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -916,18 +916,25 @@ struct cuda2hipMap { // Profiler // unsupported yet by HIP - cuda2hipRename["cudaProfilerInitialize"] = {"hipProfilerInitialize", CONV_OTHER, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaProfilerInitialize"] = {"hipProfilerInitialize", CONV_OTHER, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaProfilerStart"] = {"hipProfilerStart", CONV_OTHER, API_RUNTIME}; - cuda2hipRename["cudaProfilerStop"] = {"hipProfilerStop", CONV_OTHER, API_RUNTIME}; - cuda2hipRename["cudaChannelFormatDesc"] = {"hipChannelFormatDesc", CONV_TEX, API_RUNTIME}; - cuda2hipRename["cudaFilterModePoint"] = {"hipFilterModePoint", CONV_TEX, API_RUNTIME}; - cuda2hipRename["cudaReadModeElementType"] = {"hipReadModeElementType", CONV_TEX, API_RUNTIME}; + cuda2hipRename["cudaProfilerStart"] = {"hipProfilerStart", CONV_OTHER, API_RUNTIME}; + cuda2hipRename["cudaProfilerStop"] = {"hipProfilerStop", CONV_OTHER, API_RUNTIME}; + cuda2hipRename["cudaFilterModePoint"] = {"hipFilterModePoint", CONV_TEX, API_RUNTIME}; - // Channel descriptor - cuda2hipRename["cudaCreateChannelDesc"] = {"hipCreateChannelDesc", CONV_TEX, API_RUNTIME}; - cuda2hipRename["cudaBindTexture"] = {"hipBindTexture", CONV_TEX, API_RUNTIME}; - cuda2hipRename["cudaUnbindTexture"] = {"hipUnbindTexture", CONV_TEX, API_RUNTIME}; + cuda2hipRename["cudaReadModeElementType"] = {"hipReadModeElementType", CONV_TEX, API_RUNTIME}; + + // Textures + cuda2hipRename["cudaBindTexture"] = {"hipBindTexture", CONV_TEX, API_RUNTIME}; + cuda2hipRename["cudaUnbindTexture"] = {"hipUnbindTexture", CONV_TEX, API_RUNTIME}; + // Channel + cuda2hipRename["cudaChannelFormatKind"] = {"hipChannelFormatKind", CONV_TEX, API_RUNTIME}; + cuda2hipRename["cudaChannelFormatKindSigned"] = {"hipChannelFormatKindSigned", CONV_TEX, API_RUNTIME}; + cuda2hipRename["cudaChannelFormatKindUnsigned"] = {"hipChannelFormatKindUnsigned", CONV_TEX, API_RUNTIME}; + cuda2hipRename["cudaChannelFormatKindFloat"] = {"hipChannelFormatKindFloat", CONV_TEX, API_RUNTIME}; + cuda2hipRename["cudaChannelFormatKindNone"] = {"hipChannelFormatKindNone", CONV_TEX, API_RUNTIME}; + cuda2hipRename["cudaChannelFormatDesc"] = {"hipChannelFormatDesc", CONV_TEX, API_RUNTIME}; + cuda2hipRename["cudaCreateChannelDesc"] = {"hipCreateChannelDesc", CONV_TEX, API_RUNTIME}; // Inter-Process Communications (IPC) // IPC types From 4883e82185a0a03375111b393d4928ba38099e4e Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Thu, 16 Feb 2017 21:26:44 +0300 Subject: [PATCH 151/281] [HIPIFY] Add more Memory Management functions [ROCm/hip commit: 7b44dbbe37586af4ac5b286f516f26f897985185] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 72 ++++++++++++---------- 1 file changed, 38 insertions(+), 34 deletions(-) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index 7070eaca04..cb71a24ef0 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -614,51 +614,55 @@ struct cuda2hipMap { cuda2hipRename["PATCH_LEVEL"] = {"hipLibraryPatchVersion", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; // Error API - cuda2hipRename["cudaGetLastError"] = {"hipGetLastError", CONV_ERR, API_RUNTIME}; - cuda2hipRename["cudaPeekAtLastError"] = {"hipPeekAtLastError", CONV_ERR, API_RUNTIME}; - cuda2hipRename["cudaGetErrorName"] = {"hipGetErrorName", CONV_ERR, API_RUNTIME}; - cuda2hipRename["cudaGetErrorString"] = {"hipGetErrorString", CONV_ERR, API_RUNTIME}; + cuda2hipRename["cudaGetLastError"] = {"hipGetLastError", CONV_ERR, API_RUNTIME}; + cuda2hipRename["cudaPeekAtLastError"] = {"hipPeekAtLastError", CONV_ERR, API_RUNTIME}; + cuda2hipRename["cudaGetErrorName"] = {"hipGetErrorName", CONV_ERR, API_RUNTIME}; + cuda2hipRename["cudaGetErrorString"] = {"hipGetErrorString", CONV_ERR, API_RUNTIME}; // Memcpy - cuda2hipRename["cudaMemcpy"] = {"hipMemcpy", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaMemcpyToSymbol"] = {"hipMemcpyToSymbol", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaMemset"] = {"hipMemset", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaMemsetAsync"] = {"hipMemsetAsync", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaMemcpyAsync"] = {"hipMemcpyAsync", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaMemGetInfo"] = {"hipMemGetInfo", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaMemcpy"] = {"hipMemcpy", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaMemcpyToSymbol"] = {"hipMemcpyToSymbol", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaMemset"] = {"hipMemset", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaMemsetAsync"] = {"hipMemsetAsync", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaMemcpyAsync"] = {"hipMemcpyAsync", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaMemGetInfo"] = {"hipMemGetInfo", CONV_MEM, API_RUNTIME}; // Memcpy kind - cuda2hipRename["cudaMemcpyKind"] = {"hipMemcpyKind", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaMemcpyHostToHost"] = {"hipMemcpyHostToHost", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaMemcpyHostToDevice"] = {"hipMemcpyHostToDevice", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaMemcpyDeviceToHost"] = {"hipMemcpyDeviceToHost", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaMemcpyDeviceToDevice"] = {"hipMemcpyDeviceToDevice", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaMemcpyDefault"] = {"hipMemcpyDefault", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaMemcpyKind"] = {"hipMemcpyKind", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaMemcpyHostToHost"] = {"hipMemcpyHostToHost", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaMemcpyHostToDevice"] = {"hipMemcpyHostToDevice", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaMemcpyDeviceToHost"] = {"hipMemcpyDeviceToHost", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaMemcpyDeviceToDevice"] = {"hipMemcpyDeviceToDevice", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaMemcpyDefault"] = {"hipMemcpyDefault", CONV_MEM, API_RUNTIME}; // Memory management - cuda2hipRename["cudaMalloc"] = {"hipMalloc", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaMallocHost"] = {"hipHostMalloc", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaFree"] = {"hipFree", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaFreeHost"] = {"hipHostFree", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaHostRegister"] = {"hipHostRegister", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaHostUnregister"] = {"hipHostUnregister", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaMalloc"] = {"hipMalloc", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaMallocHost"] = {"hipHostMalloc", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaMallocArray"] = {"hipMallocArray", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaFree"] = {"hipFree", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaFreeHost"] = {"hipHostFree", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaFreeArray"] = {"hipFreeArray", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaHostRegister"] = {"hipHostRegister", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaHostUnregister"] = {"hipHostUnregister", CONV_MEM, API_RUNTIME}; + // hipHostAlloc deprecated - use hipHostMalloc instead + cuda2hipRename["cudaHostAlloc"] = {"hipHostMalloc", CONV_MEM, API_RUNTIME}; // Memory types - cuda2hipRename["cudaMemoryType"] = {"hipMemoryType", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaMemoryTypeHost"] = {"hipMemoryTypeHost", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaMemoryTypeDevice"] = {"hipMemoryTypeDevice", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaMemoryType"] = {"hipMemoryType", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaMemoryTypeHost"] = {"hipMemoryTypeHost", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaMemoryTypeDevice"] = {"hipMemoryTypeDevice", CONV_MEM, API_RUNTIME}; // Host Malloc Flags - cuda2hipRename["cudaHostAllocDefault"] = {"hipHostMallocDefault", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaHostAllocPortable"] = {"hipHostMallocPortable", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaHostAllocMapped"] = {"hipHostMallocMapped", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaHostAllocWriteCombined"] = {"hipHostMallocWriteCombined", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaHostAllocDefault"] = {"hipHostMallocDefault", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaHostAllocPortable"] = {"hipHostMallocPortable", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaHostAllocMapped"] = {"hipHostMallocMapped", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaHostAllocWriteCombined"] = {"hipHostMallocWriteCombined", CONV_MEM, API_RUNTIME}; // Host Register Flags - cuda2hipRename["cudaHostGetFlags"] = {"hipHostGetFlags", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaHostRegisterDefault"] = {"hipHostRegisterDefault", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaHostRegisterPortable"] = {"hipHostRegisterPortable", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaHostRegisterMapped"] = {"hipHostRegisterMapped", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaHostRegisterIoMemory"] = {"hipHostRegisterIoMemory", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaHostGetFlags"] = {"hipHostGetFlags", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaHostRegisterDefault"] = {"hipHostRegisterDefault", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaHostRegisterPortable"] = {"hipHostRegisterPortable", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaHostRegisterMapped"] = {"hipHostRegisterMapped", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaHostRegisterIoMemory"] = {"hipHostRegisterIoMemory", CONV_MEM, API_RUNTIME}; // Coordinate Indexing and Dimensions cuda2hipRename["threadIdx.x"] = {"hipThreadIdx_x", CONV_COORD_FUNC, API_RUNTIME}; From 451704189ec0079f15a713e6671808eba2f3db4b Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Thu, 16 Feb 2017 23:03:01 +0300 Subject: [PATCH 152/281] [HIPIFY] Add missing Memcpy functions. + cudaChooseDevice [ROCm/hip commit: 3b6990c8d6235195523048020ac9615e0f095ed6] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index cb71a24ef0..9818683010 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -621,11 +621,17 @@ struct cuda2hipMap { // Memcpy cuda2hipRename["cudaMemcpy"] = {"hipMemcpy", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaMemcpyToArray"] = {"hipMemcpyToArray", CONV_MEM, API_RUNTIME}; cuda2hipRename["cudaMemcpyToSymbol"] = {"hipMemcpyToSymbol", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaMemcpyToSymbolAsync"] = {"hipMemcpyToSymbolAsync", CONV_MEM, API_RUNTIME}; cuda2hipRename["cudaMemset"] = {"hipMemset", CONV_MEM, API_RUNTIME}; cuda2hipRename["cudaMemsetAsync"] = {"hipMemsetAsync", CONV_MEM, API_RUNTIME}; cuda2hipRename["cudaMemcpyAsync"] = {"hipMemcpyAsync", CONV_MEM, API_RUNTIME}; cuda2hipRename["cudaMemGetInfo"] = {"hipMemGetInfo", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaMemcpy2D"] = {"hipMemcpy2D", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaMemcpy2DToArray"] = {"hipMemcpy2DToArray", CONV_MEM, API_RUNTIME}; + + // Memcpy kind cuda2hipRename["cudaMemcpyKind"] = {"hipMemcpyKind", CONV_MEM, API_RUNTIME}; cuda2hipRename["cudaMemcpyHostToHost"] = {"hipMemcpyHostToHost", CONV_MEM, API_RUNTIME}; @@ -732,6 +738,7 @@ struct cuda2hipMap { cuda2hipRename["cudaSetDevice"] = {"hipSetDevice", CONV_DEV, API_RUNTIME}; cuda2hipRename["cudaGetDevice"] = {"hipGetDevice", CONV_DEV, API_RUNTIME}; cuda2hipRename["cudaGetDeviceCount"] = {"hipGetDeviceCount", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaChooseDevice"] = {"hipChooseDevice", CONV_DEV, API_RUNTIME}; // Attributes cuda2hipRename["cudaDeviceAttr"] = {"hipDeviceAttribute_t", CONV_TYPE, API_RUNTIME}; From 3c7eb4ba4ed5db14adcb0511834e6fbbf673c5d4 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Fri, 17 Feb 2017 15:04:15 +0300 Subject: [PATCH 153/281] [HIPIFY] Add more Stream and Occupancy functions. [ROCm/hip commit: dc8e8caf4127491b0b49037fa0152b354bcab47e] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index 9818683010..f26719cd48 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -724,6 +724,9 @@ struct cuda2hipMap { cuda2hipRename["cudaStreamWaitEvent"] = {"hipStreamWaitEvent", CONV_STREAM, API_RUNTIME}; cuda2hipRename["cudaStreamSynchronize"] = {"hipStreamSynchronize", CONV_STREAM, API_RUNTIME}; cuda2hipRename["cudaStreamGetFlags"] = {"hipStreamGetFlags", CONV_STREAM, API_RUNTIME}; + cuda2hipRename["cudaStreamQuery"] = {"hipStreamQuery", CONV_STREAM, API_RUNTIME}; + cuda2hipRename["cudaStreamAddCallback"] = {"hipStreamAddCallback", CONV_STREAM, API_RUNTIME}; + // Stream Flags cuda2hipRename["cudaStreamDefault"] = {"hipStreamDefault", CONV_STREAM, API_RUNTIME}; cuda2hipRename["cudaStreamNonBlocking"] = {"hipStreamNonBlocking", CONV_STREAM, API_RUNTIME}; @@ -846,6 +849,7 @@ struct cuda2hipMap { // Device cuda2hipRename["cudaDeviceProp"] = {"hipDeviceProp_t", CONV_TYPE, API_RUNTIME}; cuda2hipRename["cudaGetDeviceProperties"] = {"hipGetDeviceProperties", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDeviceGetByPCIBusId"] = {"hipDeviceGetByPCIBusId", CONV_DEV, API_RUNTIME}; // Device Flags cuda2hipRename["cudaSetDeviceFlags"] = {"hipSetDeviceFlags", CONV_DEV, API_RUNTIME}; @@ -883,10 +887,11 @@ struct cuda2hipMap { cuda2hipRename["cudaRuntimeGetVersion"] = {"hipRuntimeGetVersion", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // Occupancy + cuda2hipRename["cudaOccupancyMaxPotentialBlockSize"] = {"hipOccupancyMaxPotentialBlockSize", CONV_OCCUPANCY, API_DRIVER}; // unsupported yet by HIP - cuda2hipRename["cudaOccupancyMaxPotentialBlockSize"] = {"hipOccupancyMaxPotentialBlockSize", CONV_OCCUPANCY, API_DRIVER, HIP_UNSUPPORTED}; cuda2hipRename["cudaOccupancyMaxPotentialBlockSizeWithFlags"] = {"hipOccupancyMaxPotentialBlockSizeWithFlags", CONV_OCCUPANCY, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["cudaOccupancyMaxActiveBlocksPerMultiprocessor"] = {"hipOccupancyMaxActiveBlocksPerMultiprocessor", CONV_OCCUPANCY, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["cudaOccupancyMaxActiveBlocksPerMultiprocessor"] = {"hipOccupancyMaxActiveBlocksPerMultiprocessor", CONV_OCCUPANCY, API_DRIVER}; + // unsupported yet by HIP cuda2hipRename["cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags"] = {"hipOccupancyMaxActiveBlocksPerMultiprocessorWithFlags", CONV_OCCUPANCY, API_DRIVER, HIP_UNSUPPORTED}; cuda2hipRename["cudaOccupancyMaxPotentialBlockSizeVariableSMem"] = {"hipOccupancyMaxPotentialBlockSizeVariableSMem", CONV_OCCUPANCY, API_DRIVER, HIP_UNSUPPORTED}; cuda2hipRename["cudaOccupancyMaxPotentialBlockSizeVariableSMemWithFlags"] = {"hipOccupancyMaxPotentialBlockSizeVariableSMemWithFlags", CONV_OCCUPANCY, API_DRIVER, HIP_UNSUPPORTED}; From 6cd3764009827329b2df08e4c8e34a251468c812 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Fri, 17 Feb 2017 08:51:02 -0600 Subject: [PATCH 154/281] removed hipblas samples as it is not yet supported Change-Id: I354b710e652ce0d0413d670530ceb8b70f4993d5 [ROCm/hip commit: 39548fb02395ab84378950acfbb1043355699feb] --- .../samples/7_Advanced/hipblas_saxpy/Makefile | 34 ------- .../7_Advanced/hipblas_saxpy/saxpy.cublas.cpp | 94 ------------------- .../hipblas_saxpy/saxpy.hipblasref.cpp | 94 ------------------- 3 files changed, 222 deletions(-) delete mode 100644 projects/hip/samples/7_Advanced/hipblas_saxpy/Makefile delete mode 100644 projects/hip/samples/7_Advanced/hipblas_saxpy/saxpy.cublas.cpp delete mode 100644 projects/hip/samples/7_Advanced/hipblas_saxpy/saxpy.hipblasref.cpp diff --git a/projects/hip/samples/7_Advanced/hipblas_saxpy/Makefile b/projects/hip/samples/7_Advanced/hipblas_saxpy/Makefile deleted file mode 100644 index 8586e75d25..0000000000 --- a/projects/hip/samples/7_Advanced/hipblas_saxpy/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -HIP_PATH?= $(wildcard /opt/rocm/hip) -ifeq (,$(HIP_PATH)) - HIP_PATH=../../.. -endif -HIPCC=$(HIP_PATH)/bin/hipcc - -HIPCC_FLAGS += -std=c++11 -HIP_PLATFORM=$(shell $(HIP_PATH)/bin/hipconfig --platform) -ifeq (${HIP_PLATFORM}, nvcc) - LIBS = -lcublas -endif -ifeq (${HIP_PLATFORM}, hcc) - HCBLAS_ROOT?= $(wildcard /opt/rocm/hcblas) - HIPCC_FLAGS += -stdlib=libc++ -I$(HCBLAS_ROOT)/include - LIBS = -L$(HCBLAS_ROOT)/lib -lhipblas -rpath $(HIP_PATH)/lib -endif - - -all: saxpy.hipblas.out - -saxpy.cublas.out : saxpy.cublas.cpp - nvcc -std=c++11 -I$(CUDA_HOME)/include saxpy.cublas.cpp -o $@ -L$(CUDA_HOME)/lib64 -lcublas - -# $HIPBLAS_ROOT/bin/hipifyblas ./saxpy.cublas.cpp > ./saxpy.hipblas.cpp -# Then review & finish port in saxpy.hipblas.cpp - -saxpy.hipblasref.o: saxpy.hipblasref.cpp - $(HIPCC) $(HIPCC_FLAGS) -c $< -o $@ - -saxpy.hipblas.out: saxpy.hipblasref.o - $(HIPCC) $< -o $@ $(LIBS) - -clean: - rm -f *.o *.out diff --git a/projects/hip/samples/7_Advanced/hipblas_saxpy/saxpy.cublas.cpp b/projects/hip/samples/7_Advanced/hipblas_saxpy/saxpy.cublas.cpp deleted file mode 100644 index 03a38f3fb1..0000000000 --- a/projects/hip/samples/7_Advanced/hipblas_saxpy/saxpy.cublas.cpp +++ /dev/null @@ -1,94 +0,0 @@ - -#include -#include -#include -#include - -// header file for the GPU API -#include -#include - -#define N (1024 * 500) - -#define CHECK(cmd) \ -{\ - cudaError_t error = cmd; \ - if (error != cudaSuccess) { \ - fprintf(stderr, "error: '%s'(%d) at %s:%d\n", cudaGetErrorString(error), error,__FILE__, __LINE__); \ - exit(EXIT_FAILURE);\ - }\ -} - -#define CHECK_BLAS(cmd) \ -{\ - cublasStatus_t error = cmd;\ - if (error != CUBLAS_STATUS_SUCCESS) { \ - fprintf(stderr, "error: (%d) at %s:%d\n", error,__FILE__, __LINE__); \ - exit(EXIT_FAILURE);\ - }\ -} - -int main() { - - const float a = 100.0f; - float x[N]; - float y[N], y_cpu_res[N], y_gpu_res[N]; - - // initialize the input data - std::default_random_engine random_gen; - std::uniform_real_distribution distribution(-N, N); - std::generate_n(x, N, [&]() { return distribution(random_gen); }); - std::generate_n(y, N, [&]() { return distribution(random_gen); }); - std::copy_n(y, N, y_cpu_res); - - // Explicit GPU code: - - size_t Nbytes = N*sizeof(float); - float *x_gpu, *y_gpu; - - cublasHandle_t handle; - - cudaDeviceProp props; - CHECK(cudaGetDeviceProperties(&props, 0/*deviceID*/)); - printf ("info: running on device %s\n", props.name); - - printf ("info: allocate host mem (%6.2f MB)\n", 2*Nbytes/1024.0/1024.0); - printf ("info: allocate device mem (%6.2f MB)\n", 2*Nbytes/1024.0/1024.0); - CHECK(cudaMalloc(&x_gpu, Nbytes)); - CHECK(cudaMalloc(&y_gpu, Nbytes)); - - // Initialize the blas library - CHECK_BLAS ( cublasCreate(&handle)); - - // copy n elements from a vector in host memory space to a vector in GPU memory space - printf ("info: copy Host2Device\n"); - CHECK_BLAS ( cublasSetVector(N, sizeof(*x), x, 1, x_gpu, 1)); - CHECK_BLAS ( cublasSetVector(N, sizeof(*y), y, 1, y_gpu, 1)); - - printf ("info: launch 'saxpy' kernel\n"); - CHECK_BLAS ( cublasSaxpy(handle, N, &a, x_gpu, 1, y_gpu, 1)); - - cudaDeviceSynchronize(); - - printf ("info: copy Device2Host\n"); - CHECK_BLAS ( cublasGetVector(N, sizeof(*y_gpu_res), y_gpu, 1, y_gpu_res, 1)); - - // CPU implementation of saxpy - for (int i = 0; i < N; i++) { - y_cpu_res[i] = a * x[i] + y[i]; - } - - // verify the results - int errors = 0; - for (int i = 0; i < N; i++) { - if (fabs(y_cpu_res[i] - y_gpu_res[i]) > fabs(y_cpu_res[i] * 0.0001f)) - errors++; - } - std::cout << errors << " errors" << std::endl; - - CHECK( cudaFree(x_gpu)); - CHECK( cudaFree(y_gpu)); - CHECK_BLAS( cublasDestroy(handle)); - - return errors; -} diff --git a/projects/hip/samples/7_Advanced/hipblas_saxpy/saxpy.hipblasref.cpp b/projects/hip/samples/7_Advanced/hipblas_saxpy/saxpy.hipblasref.cpp deleted file mode 100644 index 4610a612d4..0000000000 --- a/projects/hip/samples/7_Advanced/hipblas_saxpy/saxpy.hipblasref.cpp +++ /dev/null @@ -1,94 +0,0 @@ - -#include -#include -#include -#include - -// header file for the GPU API -#include "hip/hip_runtime.h" -#include - -#define N (1024 * 500) - -#define CHECK(cmd) \ -{\ - hipError_t error = cmd; \ - if (error != hipSuccess) { \ - fprintf(stderr, "error: '%s'(%d) at %s:%d\n", hipGetErrorString(error), error,__FILE__, __LINE__); \ - exit(EXIT_FAILURE);\ - }\ -} - -#define CHECK_BLAS(cmd) \ -{\ - hipblasStatus_t error = cmd;\ - if (error != HIPBLAS_STATUS_SUCCESS) { \ - fprintf(stderr, "error: (%d) at %s:%d\n", error,__FILE__, __LINE__); \ - exit(EXIT_FAILURE);\ - }\ -} - -int main() { - - const float a = 100.0f; - float x[N]; - float y[N], y_cpu_res[N], y_gpu_res[N]; - - // initialize the input data - std::default_random_engine random_gen; - std::uniform_real_distribution distribution(-N, N); - std::generate_n(x, N, [&]() { return distribution(random_gen); }); - std::generate_n(y, N, [&]() { return distribution(random_gen); }); - std::copy_n(y, N, y_cpu_res); - - // Explicit GPU code: - - size_t Nbytes = N*sizeof(float); - float *x_gpu, *y_gpu; - - hipblasHandle_t handle; - - hipDeviceProp_t props; - CHECK(hipGetDeviceProperties(&props, 0/*deviceID*/)); - printf ("info: running on device %s\n", props.name); - - printf ("info: allocate host mem (%6.2f MB)\n", 2*Nbytes/1024.0/1024.0); - printf ("info: allocate device mem (%6.2f MB)\n", 2*Nbytes/1024.0/1024.0); - CHECK(hipMalloc(&x_gpu, Nbytes)); - CHECK(hipMalloc(&y_gpu, Nbytes)); - - // Initialize the blas library - CHECK_BLAS ( hipblasCreate(&handle)); - - // copy n elements from a vector in host memory space to a vector in GPU memory space - printf ("info: copy Host2Device\n"); - CHECK_BLAS ( hipblasSetVector(N, sizeof(*x), x, 1, x_gpu, 1)); - CHECK_BLAS ( hipblasSetVector(N, sizeof(*y), y, 1, y_gpu, 1)); - - printf ("info: launch 'saxpy' kernel\n"); - CHECK_BLAS ( hipblasSaxpy(handle, N, &a, x_gpu, 1, y_gpu, 1)); - - hipDeviceSynchronize(); - - printf ("info: copy Device2Host\n"); - CHECK_BLAS ( hipblasGetVector(N, sizeof(*y_gpu_res), y_gpu, 1, y_gpu_res, 1)); - - // CPU implementation of saxpy - for (int i = 0; i < N; i++) { - y_cpu_res[i] = a * x[i] + y[i]; - } - - // verify the results - int errors = 0; - for (int i = 0; i < N; i++) { - if (fabs(y_cpu_res[i] - y_gpu_res[i]) > fabs(y_cpu_res[i] * 0.0001f)) - errors++; - } - std::cout << errors << " errors" << std::endl; - - CHECK( hipFree(x_gpu)); - CHECK( hipFree(y_gpu)); - CHECK_BLAS( hipblasDestroy(handle)); - - return errors; -} From a1c15ab0fb90243baf28743a95bfb3f0517adb76 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Fri, 17 Feb 2017 18:06:47 +0300 Subject: [PATCH 155/281] [HIP] [DOC] Update CUDA_Runtime_API_functions_supported_by_HIP + 21 supported functions - 99 at least to support All the supported functions are also supported by hipify-clang (synced). [ROCm/hip commit: a35d4b75c5ccf1c7ab733a702b5643448d9cfad4] --- ..._Runtime_API_functions_supported_by_HIP.md | 96 ++++++++++--------- 1 file changed, 52 insertions(+), 44 deletions(-) diff --git a/projects/hip/docs/markdown/CUDA_Runtime_API_functions_supported_by_HIP.md b/projects/hip/docs/markdown/CUDA_Runtime_API_functions_supported_by_HIP.md index 350ddd4e32..2df95177a0 100644 --- a/projects/hip/docs/markdown/CUDA_Runtime_API_functions_supported_by_HIP.md +++ b/projects/hip/docs/markdown/CUDA_Runtime_API_functions_supported_by_HIP.md @@ -1,32 +1,34 @@ +# CUDA Runtime API functions supported by HIP + **1. Device Management** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| -| `cudaChooseDevice` | `hipChooseDevice` | Select compute-device which best matches criteria. | +| `cudaChooseDevice` | `hipChooseDevice` | Select compute-device which best matches criteria. | | `cudaDeviceGetAttribute` | `hipDeviceGetAttribute` | Returns information about the device. | -| `cudaDeviceGetByPCIBusId` | | Returns a handle to a compute device. | +| `cudaDeviceGetByPCIBusId` | `hipDeviceGetByPCIBusId` | Returns a handle to a compute device. | | `cudaDeviceGetCacheConfig` | `hipDeviceGetCacheConfig` | Returns the preferred cache configuration for the current device. | -| `cudaDeviceGetLimit` | `hipDeviceGetLimit` | Returns resource limits. | +| `cudaDeviceGetLimit` | `hipDeviceGetLimit` | Returns resource limits. | | `cudaDeviceGetPCIBusId` | | Returns a PCI Bus Id string for the device. | | `cudaDeviceGetSharedMemConfig` | `hipDeviceGetSharedMemConfig` | Returns the shared memory configuration for the current device. | | `cudaDeviceGetStreamPriorityRange` | | Returns numerical values that correspond to the least and greatest stream priorities. | | `cudaDeviceReset` | `hipDeviceReset` | Destroy all allocations and reset all state on the current device in the current process. | | `cudaDeviceSetCacheConfig` | `hipDeviceSetCacheConfig` | Sets the preferred cache configuration for the current device. | -| `cudaDeviceSetLimit` | `hipDeviceSetLimit` | Set resource limits. | +| `cudaDeviceSetLimit` | `hipDeviceSetLimit` | Set resource limits. | | `cudaDeviceSetSharedMemConfig` | `hipDeviceSetSharedMemConfig` | Sets the shared memory configuration for the current device. | | `cudaDeviceSynchronize` | `hipDeviceSynchronize` | Wait for compute device to finish. | | `cudaGetDevice` | `hipGetDevice` | Returns which device is currently being used. | | `cudaGetDeviceCount` | `hipGetDeviceCount` | Returns the number of compute-capable devices. | | `cudaGetDeviceFlags` | | Gets the flags for the current device. | | `cudaGetDeviceProperties` | `hipGetDeviceProperties` | Returns information about the compute-device. | -| `cudaIpcCloseMemHandle` | | Close memory mapped with cudaIpcOpenMemHandle. | -| `cudaIpcGetEventHandle` | | Gets an interprocess handle for a previously allocated event. | -| `cudaIpcGetMemHandle` | | Gets an interprocess memory handle for an existing device memory allocation. | -| `cudaIpcOpenEventHandle` | | Opens an interprocess event handle for use in the current process. | -| `cudaIpcOpenMemHandle` | | Opens an interprocess memory handle exported from another process and returns a device pointer usable in the local process. | +| `cudaIpcCloseMemHandle` | `hipIpcCloseMemHandle` | Close memory mapped with cudaIpcOpenMemHandle. | +| `cudaIpcGetEventHandle` | `hipIpcGetEventHandle` | Gets an interprocess handle for a previously allocated event. | +| `cudaIpcGetMemHandle` | `hipIpcGetMemHandle` | Gets an interprocess memory handle for an existing device memory allocation. | +| `cudaIpcOpenEventHandle` | `hipIpcOpenEventHandle` | Opens an interprocess event handle for use in the current process. | +| `cudaIpcOpenMemHandle` | `hipIpcOpenMemHandle` | Opens an interprocess memory handle exported from another process and returns a device pointer usable in the local process. | | `cudaSetDevice` | `hipSetDevice` | Set device to be used for GPU executions. | | `cudaSetDeviceFlags` | `hipSetDeviceFlags` | Sets flags to be used for device executions. | -| `cudaSetValidDevices` | | Set a list of devices that can be used for CUDA. |` +| `cudaSetValidDevices` | | Set a list of devices that can be used for CUDA. | **2. Error Handling** @@ -41,8 +43,8 @@ | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| -| `cudaStreamAddCallback` | | Add a callback to a compute stream. | -| `cudaStreamAttachMemAsync` | | Attach managed memory to a stream asynchronously. | +| `cudaStreamAddCallback` | `hipStreamAddCallback` | Add a callback to a compute stream. | +| `cudaStreamAttachMemAsync` | | Attach managed memory to a stream asynchronously. | | `cudaStreamCreate` | `hipStreamCreate` | Create an asynchronous stream. | | `cudaStreamCreateWithFlags` | `hipStreamCreateWithFlags` | Create an asynchronous stream. | | `cudaStreamCreateWithPriority` | | Create an asynchronous stream with the specified priority. | @@ -82,42 +84,50 @@ | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| -| `cudaOccupancyMaxActiveBlocksPerMultiprocessor` | | Returns occupancy for a device function. | +| `cudaOccupancyMaxActiveBlocksPerMultiprocessor` | `hipOccupancyMaxActiveBlocksPerMultiprocessor`| Returns occupancy for a device function. | | `cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags` | | Returns occupancy for a device function with the specified flags. | -**7. Memory Management** +**7. Execution Control [deprecated since 7.0]** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| +| `cudaConfigureCall` | | Configure a device-launch. | +| `cudaLaunch` | | Launches a device function. | +| `cudaSetupArgument` | | Configure a device launch. | + +**8. Memory Management** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| | `cudaArrayGetInfo` | | Gets info about the specified cudaArray. | | `cudaFree` | `hipFree` | Frees memory on the device. | -| `cudaFreeArray` | | Frees an array on the device. | +| `cudaFreeArray` | `hipFreeArray` | Frees an array on the device. | | `cudaFreeHost` | `hipHostFree` | Frees page-locked memory. | | `cudaFreeMipmappedArray` | | Frees a mipmapped array on the device. | | `cudaGetMipmappedArrayLevel` | | Gets a mipmap level of a CUDA mipmapped array. | | `cudaGetSymbolAddress` | | Finds the address associated with a CUDA symbol. | | `cudaGetSymbolSize` | | Finds the size of the object associated with a CUDA symbol. | -| `cudaHostAlloc` | `hipHostMalloc` | Allocates page-locked memory on the host. | -| `cudaHostGetDevicePointer` | `hipHostGetDevicePointer` | Passes back device pointer of mapped host memory allocated by cudaHostAlloc or registered by cudaHostRegister. | -| `cudaHostGetFlags` | `hipHostGetFlags` | Passes back flags used to allocate pinned host memory allocated by cudaHostAlloc. | +| `cudaHostAlloc` | `hipHostMalloc` | Allocates page-locked memory on the host. | +| `cudaHostGetDevicePointer` | `hipHostGetDevicePointer` | Passes back device pointer of mapped host memory allocated by cudaHostAlloc or registered by cudaHostRegister. | +| `cudaHostGetFlags` | `hipHostGetFlags` | Passes back flags used to allocate pinned host memory allocated by cudaHostAlloc. | | `cudaHostRegister` | `hipHostRegister` | Registers an existing host memory range for use by CUDA. | | `cudaHostUnregister` | `hipHostUnregister` | Unregisters a memory range that was registered with cudaHostRegister. | | `cudaMalloc` | `hipMalloc` | Allocate memory on the device. | | `cudaMalloc3D` | | Allocates logical 1D, 2D, or 3D memory objects on the device. | | `cudaMalloc3DArray` | | Allocate an array on the device. | -| `cudaMallocArray` | | Allocate an array on the device. | -| `cudaMallocHost` | `hipHostMalloc` | Allocates page-locked memory on the host. | +| `cudaMallocArray` | `hipMallocArray` | Allocate an array on the device. | +| `cudaMallocHost` | `hipHostMalloc` | Allocates page-locked memory on the host. | | `cudaMallocManaged` | | Allocates memory that will be automatically managed by the Unified Memory system. | | `cudaMallocMipmappedArray` | | Allocate a mipmapped array on the device. | | `cudaMallocPitch` | | Allocates pitched memory on the device. | -| `cudaMemGetInfo` | | Gets free and total device memory. | +| `cudaMemGetInfo` | `hipMemGetInfo` | Gets free and total device memory. | | `cudaMemcpy` | `hipMemcpy` | Copies data between host and device. | -| `cudaMemcpy2D` | | Copies data between host and device. | +| `cudaMemcpy2D` | `hipMemcpy2D` | Copies data between host and device. | | `cudaMemcpy2DArrayToArray` | | Copies data between host and device. | | `cudaMemcpy2DAsync` | | Copies data between host and device. | | `cudaMemcpy2DFromArray` | | Copies data between host and device. | | `cudaMemcpy2DFromArrayAsync` | | Copies data between host and device. | -| `cudaMemcpy2DToArray` | | Copies data between host and device. | +| `cudaMemcpy2DToArray` | `hipMemcpy2DToArray` | Copies data between host and device. | | `cudaMemcpy2DToArrayAsync` | | Copies data between host and device. | | `cudaMemcpy3D` | | Copies data between 3D objects. | | `cudaMemcpy3DAsync` | | Copies data between 3D objects. | @@ -131,10 +141,10 @@ | `cudaMemcpyFromSymbolAsync` | | Copies data from the given symbol on the device. | | `cudaMemcpyPeer` | `hipMemcpyPeer` | Copies memory between two devices. | | `cudaMemcpyPeerAsync` | `hipMemcpyPeerAsync` | Copies memory between two devices asynchronously. | -| `cudaMemcpyToArray` | | Copies data between host and device. | +| `cudaMemcpyToArray` | `hipMemcpyToArray` | Copies data between host and device. | | `cudaMemcpyToArrayAsync` | | Copies data between host and device. | | `cudaMemcpyToSymbol` | `hipMemcpyToSymbol` | Copies data to the given symbol on the device. | -| `cudaMemcpyToSymbolAsync` | | Copies data to the given symbol on the device. | +| `cudaMemcpyToSymbolAsync` | `hipMemcpyToSymbolAsync` | Copies data to the given symbol on the device. | | `cudaMemset` | `hipMemset` | Initializes or sets device memory to a value. | | `cudaMemset2D` | | Initializes or sets device memory to a value. | | `cudaMemset2DAsync` | | Initializes or sets device memory to a value. | @@ -145,13 +155,13 @@ | `make\_cudaPitchedPtr` | | Returns a cudaPitchedPtr based on input parameters. | | `make\_cudaPos` | | Returns a cudaPos based on input parameters. | -**8. Unified Addressing** +**9. Unified Addressing** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| | `cudaPointerGetAttributes` | `hipPointerGetAttributes` | Returns attributes about a specified pointer. | -**9. Peer Device Memory Access** +**10. Peer Device Memory Access** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| @@ -159,7 +169,7 @@ | `cudaDeviceDisablePeerAccess` | `hipDeviceDisablePeerAccess` | Disables direct access to memory allocations on a peer device. | | `cudaDeviceEnablePeerAccess` | `hipDeviceEnablePeerAccess` | Enables direct access to memory allocations on a peer device. | -**10. OpenGL Interoperability** +**11. OpenGL Interoperability** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| @@ -168,7 +178,7 @@ | `cudaGraphicsGLRegisterImage` | | Register an OpenGL texture or renderbuffer object. | | `cudaWGLGetDevice` | | Gets the CUDA device associated with hGpu. | -**11. Graphics Interoperability** +**12. Graphics Interoperability** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| @@ -180,11 +190,11 @@ | `cudaGraphicsUnmapResources` | | Unmap graphics resources. | | `cudaGraphicsUnregisterResource` | | Unregisters a graphics resource for access by CUDA. | -**12. Texture Reference Management** +**13. Texture Reference Management** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| -| `cudaBindTexture` | | Binds a memory area to a texture. | +| `cudaBindTexture` | `hipBindTexture` | Binds a memory area to a texture. | | `cudaBindTexture2D` | | Binds a 2D memory area to a texture. | | `cudaBindTextureToArray` | | Binds an array to a texture. | | `cudaBindTextureToMipmappedArray` | | Binds a mipmapped array to a texture. | @@ -192,16 +202,16 @@ | `cudaGetChannelDesc` | | Get the channel descriptor of an array. | | `cudaGetTextureAlignmentOffset` | | Get the alignment offset of a texture. | | `cudaGetTextureReference` | | Get the texture reference associated with a symbol. | -| `cudaUnbindTexture` | | Unbinds a texture. | +| `cudaUnbindTexture` | `hipUnbindTexture` | Unbinds a texture. | -**13. Surface Reference Management** +**14. Surface Reference Management** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| | `cudaBindSurfaceToArray` | | Binds an array to a surface. | | `cudaGetSurfaceReference` | | Get the surface reference associated with a symbol. | -**14. Texture Object Management** +**15. Texture Object Management** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| @@ -211,7 +221,7 @@ | `cudaGetTextureObjectResourceViewDesc` | | Returns a texture object's resource view descriptor. | | `cudaGetTextureObjectTextureDesc` | | Returns a texture object's texture descriptor. | -**15. Surface Object Management** +**16. Surface Object Management** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| @@ -219,15 +229,14 @@ | `cudaDestroySurfaceObject` | | Destroys a surface object. | | `cudaGetSurfaceObjectResourceDesc` | | Returns a surface object's resource descriptor Returns the resource descriptor for the surface object specified by surfObject. | -**16. Version Management** +**17. Version Management** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| | `cudaDriverGetVersion` | `hipDriverGetVersion` | Returns the CUDA driver version. | -| `cudaRuntimeGetVersion` | | Returns the CUDA Runtime version. | +| `cudaRuntimeGetVersion` | `hipRuntimeGetVersion` | Returns the CUDA Runtime version. | -**17. C++ API Routines (7.0 contains, 7.5 doesn’t)** -> Will not support for HIP (probably) +**18. C++ API Routines (7.0 contains, 7.5 doesn’t)** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| @@ -236,8 +245,7 @@ | `cudaBindTexture2D` | | Binds a 2D memory area to a texture. | | `cudaBindTextureToArray` | | Binds an array to a texture. | | `cudaBindTextureToMipmappedArray` | | Binds a mipmapped array to a texture. | -| `cudaCreateChannelDesc` | | Returns a channel descriptor using the specified format. | -| `cudaEventCreate` | | Creates an event object with the specified flags. | +| `cudaCreateChannelDesc` | `hipCreateChannelDesc` | Returns a channel descriptor using the specified format. | | `cudaFuncGetAttributes` | | Find out attributes for a given function. | | `cudaFuncSetCacheConfig` | | Sets the preferred cache configuration for a device function. | | `cudaGetSymbolAddress` | | Finds the address associated with a CUDA symbol | @@ -251,9 +259,9 @@ | `cudaMemcpyFromSymbolAsync` | | Copies data from the given symbol on the device. | | `cudaMemcpyToSymbol` | | Copies data to the given symbol on the device. | | `cudaMemcpyToSymbolAsync` | | Async copies data to the given symbol on the device. | -| `cudaOccupancyMaxActiveBlocksPerMultiprocessor` | | Returns occupancy for a device function. | +| `cudaOccupancyMaxActiveBlocksPerMultiprocessor` | `hipOccupancyMaxActiveBlocksPerMultiprocessor` | Returns occupancy for a device function. | | `cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags` | | Returns occupancy for a device function with the specified flags. | -| `cudaOccupancyMaxPotentialBlockSize` | | Returns grid and block size that achieves maximum potential occupancy for a device function. | +| `cudaOccupancyMaxPotentialBlockSize` | `hipOccupancyMaxPotentialBlockSize` | Returns grid and block size that achieves maximum potential occupancy for a device function. | | `cudaOccupancyMaxPotentialBlockSizeVariableSMem` | | Returns grid and block size that achieves maximum potential occupancy for a device function. | | `cudaOccupancyMaxPotentialBlockSizeVariableSMemWithFlags` | | Returns grid and block size that achieves maximum potential occupancy for a device function. | | `cudaOccupancyMaxPotentialBlockSizeWithFlags` | | Returns grid and block size that achived maximum potential occupancy for a device function with the specified flags. | @@ -261,7 +269,7 @@ | `cudaStreamAttachMemAsync` | | Attach memory to a stream asynchronously. | | `cudaUnbindTexture` | | Unbinds a texture. | -**18. Profiler Control** +**19. Profiler Control** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| From b01385b687c98073f105512873927526fd01a1c4 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Fri, 17 Feb 2017 18:09:08 +0300 Subject: [PATCH 156/281] [HIP] [DOC] Update CUDA_Runtime_API_functions_supported_by_HIP Move hipBindTexture and hipUnbindTexture to "18. C++ API Routines" from "13. Texture Reference Management". They are C++, not C. [ROCm/hip commit: ee157678b97ad7d77759cb930b89359c79d67392] --- .../CUDA_Runtime_API_functions_supported_by_HIP.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/projects/hip/docs/markdown/CUDA_Runtime_API_functions_supported_by_HIP.md b/projects/hip/docs/markdown/CUDA_Runtime_API_functions_supported_by_HIP.md index 2df95177a0..2d77f4d82f 100644 --- a/projects/hip/docs/markdown/CUDA_Runtime_API_functions_supported_by_HIP.md +++ b/projects/hip/docs/markdown/CUDA_Runtime_API_functions_supported_by_HIP.md @@ -194,7 +194,7 @@ | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| -| `cudaBindTexture` | `hipBindTexture` | Binds a memory area to a texture. | +| `cudaBindTexture` | | Binds a memory area to a texture. | | `cudaBindTexture2D` | | Binds a 2D memory area to a texture. | | `cudaBindTextureToArray` | | Binds an array to a texture. | | `cudaBindTextureToMipmappedArray` | | Binds a mipmapped array to a texture. | @@ -202,7 +202,7 @@ | `cudaGetChannelDesc` | | Get the channel descriptor of an array. | | `cudaGetTextureAlignmentOffset` | | Get the alignment offset of a texture. | | `cudaGetTextureReference` | | Get the texture reference associated with a symbol. | -| `cudaUnbindTexture` | `hipUnbindTexture` | Unbinds a texture. | +| `cudaUnbindTexture` | | Unbinds a texture. | **14. Surface Reference Management** @@ -241,7 +241,7 @@ | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| | `cudaBindSurfaceToArray` | | Binds an array to a surface. | -| `cudaBindTexture` | | Binds a memory area to a texture. | +| `cudaBindTexture` | `hipBindTexture` | Binds a memory area to a texture. | | `cudaBindTexture2D` | | Binds a 2D memory area to a texture. | | `cudaBindTextureToArray` | | Binds an array to a texture. | | `cudaBindTextureToMipmappedArray` | | Binds a mipmapped array to a texture. | @@ -267,7 +267,7 @@ | `cudaOccupancyMaxPotentialBlockSizeWithFlags` | | Returns grid and block size that achived maximum potential occupancy for a device function with the specified flags. | | `cudaSetupArgument` | | Configure a device launch. | | `cudaStreamAttachMemAsync` | | Attach memory to a stream asynchronously. | -| `cudaUnbindTexture` | | Unbinds a texture. | +| `cudaUnbindTexture` | `hipUnbindTexture` | Unbinds a texture. | **19. Profiler Control** From 091d377ce5840d5a0ac31bd49f40f145f260fe20 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Mon, 20 Feb 2017 18:28:59 +0300 Subject: [PATCH 157/281] [HIPIFY] Sync HIPIFY with HIP by data types. [ROCm/hip commit: 0cbe335c8fd9bac0f9f5704a5465939e14636f70] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 45 +++++++++++++++++----- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index f26719cd48..218e9f47a1 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -186,7 +186,7 @@ struct cuda2hipMap { // Error codes and return types cuda2hipRename["CUresult"] = {"hipError_t", CONV_TYPE, API_DRIVER}; cuda2hipRename["cudaError_t"] = {"hipError_t", CONV_TYPE, API_RUNTIME}; - cuda2hipRename["cudaError"] = {"hipError", CONV_TYPE, API_RUNTIME}; + cuda2hipRename["cudaError"] = {"hipError_t", CONV_TYPE, API_RUNTIME}; // CUDA Driver API error code only cuda2hipRename["CUDA_ERROR_INVALID_CONTEXT"] = {"hipErrorInvalidContext", CONV_ERR, API_DRIVER}; @@ -433,8 +433,11 @@ struct cuda2hipMap { // cuda2hipRename["CUpointer_attribute_enum"] = {"hipPointerAttribute_t", CONV_TYPE, API_DRIVER}; // cuda2hipRename["CUpointer_attribute"] = {"hipPointerAttribute_t", CONV_TYPE, API_DRIVER}; + // pointer to CUfunc_st cuda2hipRename["CUfunction"] = {"hipFunction_t", CONV_TYPE, API_DRIVER}; - cuda2hipRename["CUfunc_st"] = {"hipFunction_t *", CONV_TYPE, API_DRIVER}; + // TODO: in HIP ihipModuleSymbol_t should be declared in hip_runtime_api.h, not in hcc_detail/hip_runtime_api.h, as it's analogue CUfunc_st is declared also in cuda.h + // ToDO: examples are needed with CUfunc_st + // cuda2hipRename["CUfunc_st"] = {"ihipModuleSymbol_t", CONV_TYPE, API_DRIVER}; // unsupported yet by HIP cuda2hipRename["CUfunction_attribute_enum"] = {"hipFuncAttribute_t", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; @@ -454,11 +457,14 @@ struct cuda2hipMap { cuda2hipRename["CU_SHARED_MEM_CONFIG_EIGHT_BYTE_BANK_SIZE"] = {"hipSharedMemBankSizeEightByte", CONV_DEV, API_DRIVER}; cuda2hipRename["CUcontext"] = {"hipCtx_t", CONV_TYPE, API_DRIVER}; - cuda2hipRename["CUctx_st"] = {"hipCtx_t *", CONV_TYPE, API_DRIVER}; + // TODO: + // cuda2hipRename["CUctx_st"] = {"XXXX", CONV_TYPE, API_DRIVER}; cuda2hipRename["CUmodule"] = {"hipModule_t", CONV_TYPE, API_DRIVER}; - cuda2hipRename["CUmod_st"] = {"hipModule_t *", CONV_TYPE, API_DRIVER}; + // TODO: + // cuda2hipRename["CUmod_st"] = {"XXXX", CONV_TYPE, API_DRIVER}; cuda2hipRename["CUstream"] = {"hipStream_t", CONV_TYPE, API_DRIVER}; - cuda2hipRename["CUstream_st"] = {"hipStream_t *", CONV_TYPE, API_DRIVER}; + // TODO: + // cuda2hipRename["CUstream_st"] = {"XXXX", CONV_TYPE, API_DRIVER}; // Stream Flags cuda2hipRename["CU_STREAM_DEFAULT"] = {"hipStreamDefault", CONV_STREAM, API_DRIVER}; cuda2hipRename["CU_STREAM_NON_BLOCKING"] = {"hipStreamNonBlocking", CONV_STREAM, API_DRIVER}; @@ -505,8 +511,10 @@ struct cuda2hipMap { cuda2hipRename["cuDeviceCanAccessPeer"] = {"hipDeviceCanAccessPeer", CONV_DEV, API_DRIVER}; // Events + // pointer to CUevent_st cuda2hipRename["CUevent"] = {"hipEvent_t", CONV_TYPE, API_DRIVER}; - cuda2hipRename["CUevent_st"] = {"hipEvent_t *", CONV_TYPE, API_DRIVER}; + // ToDO: + // cuda2hipRename["CUevent_st"] = {"XXXX", CONV_TYPE, API_DRIVER}; // Event Flags cuda2hipRename["CU_EVENT_DEFAULT"] = {"hipEventDefault", CONV_EVENT, API_DRIVER}; cuda2hipRename["CU_EVENT_BLOCKING_SYNC"] = {"hipEventBlockingSync", CONV_EVENT, API_DRIVER}; @@ -619,6 +627,16 @@ struct cuda2hipMap { cuda2hipRename["cudaGetErrorName"] = {"hipGetErrorName", CONV_ERR, API_RUNTIME}; cuda2hipRename["cudaGetErrorString"] = {"hipGetErrorString", CONV_ERR, API_RUNTIME}; + // Arrays + cuda2hipRename["cudaArray"] = {"hipArray", CONV_MEM, API_RUNTIME}; + // typedef struct cudaArray *cudaArray_t; + cuda2hipRename["cudaArray_t"] = {"hipArray *", CONV_MEM, API_RUNTIME}; + // typedef const struct cudaArray *cudaArray_const_t; + cuda2hipRename["cudaArray_const_t"] = {"const hipArray *", CONV_MEM, API_RUNTIME}; + // unsupported yet by HIP + cuda2hipRename["cudaMipmappedArray_t"] = {"hipMipmappedArray *", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaMipmappedArray_const_t"] = {"const hipMipmappedArray *", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + // Memcpy cuda2hipRename["cudaMemcpy"] = {"hipMemcpy", CONV_MEM, API_RUNTIME}; cuda2hipRename["cudaMemcpyToArray"] = {"hipMemcpyToArray", CONV_MEM, API_RUNTIME}; @@ -631,7 +649,6 @@ struct cuda2hipMap { cuda2hipRename["cudaMemcpy2D"] = {"hipMemcpy2D", CONV_MEM, API_RUNTIME}; cuda2hipRename["cudaMemcpy2DToArray"] = {"hipMemcpy2DToArray", CONV_MEM, API_RUNTIME}; - // Memcpy kind cuda2hipRename["cudaMemcpyKind"] = {"hipMemcpyKind", CONV_MEM, API_RUNTIME}; cuda2hipRename["cudaMemcpyHostToHost"] = {"hipMemcpyHostToHost", CONV_MEM, API_RUNTIME}; @@ -857,9 +874,9 @@ struct cuda2hipMap { cuda2hipRename["cudaDeviceScheduleSpin"] = {"hipDeviceScheduleSpin", CONV_DEV, API_RUNTIME}; cuda2hipRename["cudaDeviceScheduleYield"] = {"hipDeviceScheduleYield", CONV_DEV, API_RUNTIME}; // deprecated as of CUDA 4.0 and replaced with cudaDeviceScheduleBlockingSync - cuda2hipRename["cudaDeviceBlockingSync"] = {"hipDeviceBlockingSync", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDeviceBlockingSync"] = {"hipDeviceScheduleBlockingSync", CONV_DEV, API_RUNTIME}; // unsupported yet by HIP - cuda2hipRename["cudaDeviceScheduleBlockingSync"] = {"hipDeviceScheduleBlockingSync", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDeviceScheduleBlockingSync"] = {"hipDeviceScheduleBlockingSync", CONV_DEV, API_RUNTIME}; cuda2hipRename["cudaDeviceScheduleMask"] = {"hipDeviceScheduleMask", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; cuda2hipRename["cudaDeviceMapHost"] = {"hipDeviceMapHost", CONV_DEV, API_RUNTIME}; @@ -874,7 +891,7 @@ struct cuda2hipMap { cuda2hipRename["cudaDeviceGetCacheConfig"] = {"hipDeviceGetCacheConfig", CONV_CACHE, API_RUNTIME}; // translate deprecated cuda2hipRename["cudaThreadGetCacheConfig"] = {"hipDeviceGetCacheConfig", CONV_CACHE, API_RUNTIME}; - cuda2hipRename["cudaFuncCache"] = {"hipFuncCache", CONV_CACHE, API_RUNTIME}; + cuda2hipRename["cudaFuncCache"] = {"hipFuncCache_t", CONV_CACHE, API_RUNTIME}; cuda2hipRename["cudaFuncCachePreferNone"] = {"hipFuncCachePreferNone", CONV_CACHE, API_RUNTIME}; cuda2hipRename["cudaFuncCachePreferShared"] = {"hipFuncCachePreferShared", CONV_CACHE, API_RUNTIME}; cuda2hipRename["cudaFuncCachePreferL1"] = {"hipFuncCachePreferL1", CONV_CACHE, API_RUNTIME}; @@ -941,6 +958,14 @@ struct cuda2hipMap { cuda2hipRename["cudaReadModeElementType"] = {"hipReadModeElementType", CONV_TEX, API_RUNTIME}; // Textures + cuda2hipRename["cudaTextureReadMode"] = {"hipTextureReadMode", CONV_TEX, API_RUNTIME}; + cuda2hipRename["cudaReadModeElementType"] = {"hipReadModeElementType", CONV_TEX, API_RUNTIME}; + // unsupported yet by HIP + cuda2hipRename["cudaReadModeNormalizedFloat"] = {"hipReadModeNormalizedFloat", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaTextureFilterMode"] = {"hipTextureFilterMode", CONV_TEX, API_RUNTIME}; + cuda2hipRename["cudaFilterModePoint"] = {"hipFilterModePoint", CONV_TEX, API_RUNTIME}; + // unsupported yet by HIP + cuda2hipRename["cudaFilterModeLinear"] = {"hipFilterModeLinear", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; cuda2hipRename["cudaBindTexture"] = {"hipBindTexture", CONV_TEX, API_RUNTIME}; cuda2hipRename["cudaUnbindTexture"] = {"hipUnbindTexture", CONV_TEX, API_RUNTIME}; // Channel From 240b46d3b00d98db8b80fc6c6c88be0bd1f46f52 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Mon, 20 Feb 2017 18:32:54 +0300 Subject: [PATCH 158/281] [HIP] [DOC] Update CUDA_Runtime_API_functions_supported_by_HIP Section "20. Data types used by CUDA Runtime API and supported by HIP" is added. + 44 supported data types are added - 46 at least to support All the supported data types are also supported by hipify-clang (synced). [ROCm/hip commit: 5c11789358bbf7734b2b9f623b8c16c02207e7f2] --- ..._Runtime_API_functions_supported_by_HIP.md | 136 +++++++++++++++--- 1 file changed, 117 insertions(+), 19 deletions(-) diff --git a/projects/hip/docs/markdown/CUDA_Runtime_API_functions_supported_by_HIP.md b/projects/hip/docs/markdown/CUDA_Runtime_API_functions_supported_by_HIP.md index 2d77f4d82f..a24490d458 100644 --- a/projects/hip/docs/markdown/CUDA_Runtime_API_functions_supported_by_HIP.md +++ b/projects/hip/docs/markdown/CUDA_Runtime_API_functions_supported_by_HIP.md @@ -1,6 +1,6 @@ # CUDA Runtime API functions supported by HIP -**1. Device Management** +## **1. Device Management** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| @@ -30,7 +30,7 @@ | `cudaSetDeviceFlags` | `hipSetDeviceFlags` | Sets flags to be used for device executions. | | `cudaSetValidDevices` | | Set a list of devices that can be used for CUDA. | -**2. Error Handling** +## **2. Error Handling** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| @@ -39,7 +39,7 @@ | `cudaGetLastError` | `hipGetLastError` | Returns the last error from a runtime call. | | `cudaPeekAtLastError` | `hipPeekAtLastError` | Returns the last error from a runtime call. | -**3. Stream Management** +## **3. Stream Management** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| @@ -55,7 +55,7 @@ | `cudaStreamSynchronize` | `hipStreamSynchronize` | Waits for stream tasks to complete. | | `cudaStreamWaitEvent` | `hipStreamWaitEvent` | Make a compute stream wait on an event. | -**4. Event Management** +## **4. Event Management** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| @@ -67,7 +67,7 @@ | `cudaEventRecord` | `hipEventRecord` | Records an event. | | `cudaEventSynchronize` | `hipEventSynchronize` | Waits for an event to complete. | -**5. Execution Control** +## **5. Execution Control** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| @@ -80,14 +80,14 @@ | `cudaSetDoubleForDevice` | | Converts a double argument to be executed on a device. | | `cudaSetDoubleForHost` | | Converts a double argument after execution on a device. | -**6. Occupancy** +## **6. Occupancy** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| | `cudaOccupancyMaxActiveBlocksPerMultiprocessor` | `hipOccupancyMaxActiveBlocksPerMultiprocessor`| Returns occupancy for a device function. | | `cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags` | | Returns occupancy for a device function with the specified flags. | -**7. Execution Control [deprecated since 7.0]** +## **7. Execution Control [deprecated since 7.0]** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| @@ -95,7 +95,7 @@ | `cudaLaunch` | | Launches a device function. | | `cudaSetupArgument` | | Configure a device launch. | -**8. Memory Management** +## **8. Memory Management** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| @@ -155,13 +155,13 @@ | `make\_cudaPitchedPtr` | | Returns a cudaPitchedPtr based on input parameters. | | `make\_cudaPos` | | Returns a cudaPos based on input parameters. | -**9. Unified Addressing** +## **9. Unified Addressing** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| | `cudaPointerGetAttributes` | `hipPointerGetAttributes` | Returns attributes about a specified pointer. | -**10. Peer Device Memory Access** +## **10. Peer Device Memory Access** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| @@ -169,7 +169,7 @@ | `cudaDeviceDisablePeerAccess` | `hipDeviceDisablePeerAccess` | Disables direct access to memory allocations on a peer device. | | `cudaDeviceEnablePeerAccess` | `hipDeviceEnablePeerAccess` | Enables direct access to memory allocations on a peer device. | -**11. OpenGL Interoperability** +## **11. OpenGL Interoperability** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| @@ -178,7 +178,7 @@ | `cudaGraphicsGLRegisterImage` | | Register an OpenGL texture or renderbuffer object. | | `cudaWGLGetDevice` | | Gets the CUDA device associated with hGpu. | -**12. Graphics Interoperability** +## **12. Graphics Interoperability** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| @@ -190,7 +190,7 @@ | `cudaGraphicsUnmapResources` | | Unmap graphics resources. | | `cudaGraphicsUnregisterResource` | | Unregisters a graphics resource for access by CUDA. | -**13. Texture Reference Management** +## **13. Texture Reference Management** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| @@ -204,14 +204,14 @@ | `cudaGetTextureReference` | | Get the texture reference associated with a symbol. | | `cudaUnbindTexture` | | Unbinds a texture. | -**14. Surface Reference Management** +## **14. Surface Reference Management** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| | `cudaBindSurfaceToArray` | | Binds an array to a surface. | | `cudaGetSurfaceReference` | | Get the surface reference associated with a symbol. | -**15. Texture Object Management** +## **15. Texture Object Management** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| @@ -221,7 +221,7 @@ | `cudaGetTextureObjectResourceViewDesc` | | Returns a texture object's resource view descriptor. | | `cudaGetTextureObjectTextureDesc` | | Returns a texture object's texture descriptor. | -**16. Surface Object Management** +## **16. Surface Object Management** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| @@ -229,14 +229,15 @@ | `cudaDestroySurfaceObject` | | Destroys a surface object. | | `cudaGetSurfaceObjectResourceDesc` | | Returns a surface object's resource descriptor Returns the resource descriptor for the surface object specified by surfObject. | -**17. Version Management** +## **17. Version Management** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| | `cudaDriverGetVersion` | `hipDriverGetVersion` | Returns the CUDA driver version. | | `cudaRuntimeGetVersion` | `hipRuntimeGetVersion` | Returns the CUDA Runtime version. | -**18. C++ API Routines (7.0 contains, 7.5 doesn’t)** +## **18. C++ API Routines** +*(7.0 contains, 7.5 doesn’t)* | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| @@ -269,10 +270,107 @@ | `cudaStreamAttachMemAsync` | | Attach memory to a stream asynchronously. | | `cudaUnbindTexture` | `hipUnbindTexture` | Unbinds a texture. | -**19. Profiler Control** +## **19. Profiler Control** | **CUDA** | **HIP** | **CUDA description** | |-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| | `cudaProfilerInitialize` | | Initialize the CUDA profiler. | | `cudaProfilerStart` | `hipProfilerStart` | Enable profiling. | | `cudaProfilerStop` | `hipProfilerStop` | Disable profiling. | + +# Data types used by CUDA Runtime API and supported by HIP + +## **20. Data types** + +| **type** | **CUDA** | **HIP** | **CUDA description** | +|--------------|--------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| +| struct | `cudaChannelFormatDesc` | `hipChannelFormatDesc` | CUDA Channel format descriptor. | +| struct | `cudaDeviceProp` | `hipDeviceProp_t` | CUDA device properties. | +| struct | `cudaExtent` | | CUDA extent (width, height, depth). | +| struct | `cudaFuncAttributes` | | CUDA function attributes. | +| struct | `cudaIpcEventHandle_t` | `hipIpcEventHandle_t` | CUDA IPC event handle. | +| struct | `cudaIpcMemHandle_t` | `hipIpcMemHandle_t` | CUDA IPC memory handle. | +| struct | `cudaMemcpy3DParms` | | CUDA 3D memory copying parameters. | +| struct | `cudaMemcpy3DPeerParms` | | CUDA 3D cross-device memory copying parameters. | +| struct | `cudaPitchedPtr` | | CUDA Pitched memory pointer. | +| struct | `cudaPointerAttributes` | `hipPointerAttribute_t` | CUDA pointer attributes. | +| struct | `cudaPos` | | CUDA 3D position. | +| struct | `cudaResourceDesc` | | CUDA resource descriptor. | +| struct | `cudaResourceViewDesc` | | CUDA resource view descriptor. | +| struct | `cudaTextureDesc` | | CUDA texture descriptor. | +| struct | `surfaceReference` | | CUDA Surface reference. | +| struct | `textureReference` | `textureReference` | CUDA texture reference. | +| enum | `cudaChannelFormatKind` | `hipChannelFormatKind` | Channel format kind. | +| enum | `cudaComputeMode` | | CUDA device compute modes. | +| enum | `cudaDeviceAttr` | `hipDeviceAttribute_t` | CUDA device attributes. | +| enum | `cudaError` | `hipError_t` | CUDA Error types. | +| enum | `cudaError_t` | `hipError_t` | CUDA Error types. | +| enum | `cudaFuncCache` | `hipFuncCache_t` | CUDA function cache configurations. | +| enum | `cudaGraphicsCubeFace` | | CUDA graphics interop array indices for cube maps. | +| enum | `cudaGraphicsMapFlags` | | CUDA graphics interop map flags. | +| enum | `cudaGraphicsRegisterFlags` | | CUDA graphics interop register flags. | +| enum | `cudaMemcpyKind` | `hipMemcpyKind` | CUDA memory copy types. | +| enum | `cudaMemoryType` | `hipMemoryType` | CUDA memory types. | +| enum | `cudaOutputMode` | | CUDA Profiler Output modes. | +| enum | `cudaResourceType` | | CUDA resource types. | +| enum | `cudaResourceViewFormat` | | CUDA texture resource view formats. | +| enum | `cudaSharedMemConfig` | `hipSharedMemConfig` | CUDA shared memory configuration. | +| enum | `cudaSurfaceBoundaryMode` | | CUDA Surface boundary modes. | +| enum | `cudaSurfaceFormatMode` | | CUDA Surface format modes. | +| enum | `cudaTextureAddressMode` | | CUDA texture address modes. | +| enum | `cudaTextureFilterMode` | `hipTextureFilterMode` | CUDA texture filter modes. | +| enum | `cudaTextureReadMode` | `hipTextureReadMode` | CUDA texture read modes. | +| struct | `cudaArray` | `hipArray` | CUDA array [opaque]. | +| typedef | `cudaArray_t` | `hipArray *` | CUDA array pointer. | +| typedef | `cudaArray_const_t` | `const hipArray *` | CUDA array (as source copy argument). | +| enum | `cudaError` | `hipError_t` | CUDA Error types. | +| typedef | `cudaError_t` | `hipError_t` | CUDA Error types. | +| typedef | `cudaEvent_t` | `hipEvent_t` | CUDA event types. | +| typedef | `cudaGraphicsResource_t` | | CUDA graphics resource types. | +| typedef | `cudaMipmappedArray_t` | | CUDA mipmapped array. | +| typedef | `cudaMipmappedArray_const_t` | | CUDA mipmapped array (as source argument). | +| enum | `cudaOutputMode` | | CUDA output file modes. | +| typedef | `cudaOutputMode_t` | | CUDA output file modes. | +| typedef | `cudaStream_t` | `hipStream_t` | CUDA stream. | +| typedef | `cudaSurfaceObject_t` | | An opaque value that represents a CUDA Surface object. | +| typedef | `cudaTextureObject_t` | | An opaque value that represents a CUDA texture object. | +| typedef | `CUuuid_stcudaUUID_t` | | CUDA UUID types. | +| define | `CUDA_IPC_HANDLE_SIZE` | | CUDA IPC Handle Size. | +| define | `cudaArrayCubemap` | | Must be set in cudaMalloc3DArray to create a cubemap CUDA array. | +| define | `cudaArrayDefault` | | Default CUDA array allocation flag. | +| define | `cudaArrayLayered` | | Must be set in cudaMalloc3DArray to create a layered CUDA array. | +| define | `cudaArraySurfaceLoadStore` | | Must be set in cudaMallocArray or cudaMalloc3DArray in order to bind surfaces to the CUDA array. | +| define | `cudaArrayTextureGather` | | Must be set in cudaMallocArray or cudaMalloc3DArray in order to perform texture gather operations on the CUDA array. | +| define | `cudaDeviceBlockingSync` | `hipDeviceScheduleBlockingSync` | Device flag - Use blocking synchronization. Deprecated as of CUDA 4.0 and replaced with cudaDeviceScheduleBlockingSync. | +| define | `cudaDeviceLmemResizeToMax` | | Device flag - Keep local memory allocation after launch. | +| define | `cudaDeviceMapHost` | | Device flag - Support mapped pinned allocations. | +| define | `cudaDeviceMask` | | Device flags mask. | +| define | `cudaDevicePropDontCare` | | Empty device properties. | +| define | `cudaDeviceScheduleAuto` | `hipDeviceScheduleAuto` | Device flag - Automatic scheduling. | +| define | `cudaDeviceScheduleBlockingSync` | `hipDeviceScheduleBlockingSync` | Device flag - Use blocking synchronization. | +| define | `cudaDeviceScheduleMask` | `hipDeviceScheduleMask` | Device schedule flags mask. | +| define | `cudaDeviceScheduleSpin` | `hipDeviceScheduleSpin` | Device flag - Spin default scheduling. | +| define | `cudaDeviceScheduleYield` | `hipDeviceScheduleYield` | Device flag - Yield default scheduling. | +| define | `cudaEventBlockingSync` | `hipEventBlockingSync` | Event uses blocking synchronization. | +| define | `cudaEventDefault` | `hipEventDefault` | Default event flag. | +| define | `cudaEventDisableTiming` | `hipEventDisableTiming` | Event will not record timing data. | +| define | `cudaEventInterprocess` | `hipEventInterprocess` | Event is suitable for interprocess use. cudaEventDisableTiming must be set. | +| define | `cudaHostAllocDefault` | `hipHostMallocDefault` | Default page-locked allocation flag. | +| define | `cudaHostAllocMapped` | `hipHostMallocMapped` | Map allocation into device space. | +| define | `cudaHostAllocPortable` | `hipHostMallocPortable` | Pinned memory accessible by all CUDA contexts. | +| define | `cudaHostAllocWriteCombined` | `hipHostMallocWriteCombined` | Write-combined memory. | +| define | `cudaHostRegisterDefault` | `hipHostRegisterDefault` | Default host memory registration flag. | +| define | `cudaHostRegisterIoMemory` | `hipHostRegisterIoMemory` | Memory-mapped I/O space. | +| define | `cudaHostRegisterMapped` | `hipHostRegisterMapped` | Map registered memory into device space. | +| define | `cudaHostRegisterPortable` | `hipHostRegisterPortable` | Pinned memory accessible by all CUDA contexts. | +| define | `cudaIpcMemLazyEnablePeerAccess` | `hipIpcMemLazyEnablePeerAccess` | Automatically enable peer access between remote devices as needed. | +| define | `cudaMemAttachGlobal` | | Memory can be accessed by any stream on any device. | +| define | `cudaMemAttachHost` | | Memory cannot be accessed by any stream on any device. | +| define | `cudaMemAttachSingle` | | Memory can only be accessed by a single stream on the associated device. | +| define | `cudaOccupancyDefault` | | Default behavior. | +| define | `cudaOccupancyDisableCachingOverride` | | Assume global caching is enabled and cannot be automatically turned off. | +| define | `cudaPeerAccessDefault` | | Default peer addressing enable flag. | +| define | `cudaStreamDefault` | `hipStreamDefault` | Default stream flag. | +| define | `cudaStreamLegacy` | | Default stream flag. | +| define | `cudaStreamNonBlocking` | `hipStreamNonBlocking` | Stream does not synchronize with stream 0 (the NULL stream). | +| define | `cudaStreamPerThread` | | Per-thread stream handle. | From d52c918b47ca645fa2b85eb0b5d1eacdb39f84a8 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Mon, 20 Feb 2017 21:19:34 +0300 Subject: [PATCH 159/281] [HIPIFY] sync with HIP by HIP_UNSUPPORTED Runtime functions. [ROCm/hip commit: 6e611aa5744194cbe85f84e1d4e172ff004ddd4b] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 233 ++++++++++++++++----- 1 file changed, 175 insertions(+), 58 deletions(-) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index 218e9f47a1..fd4c35d34b 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -77,6 +77,9 @@ enum ConvTypes { CONV_ERR, CONV_DEF, CONV_TEX, + CONV_GL, + CONV_GRAPHICS, + CONV_SURFACE, CONV_OTHER, CONV_INCLUDE, CONV_INCLUDE_CUDA_MAIN_H, @@ -87,10 +90,11 @@ enum ConvTypes { }; const char *counterNames[CONV_LAST] = { - "driver", "dev", "mem", "kern", "coord_func", "math_func", - "special_func", "stream", "event", "occupancy", "ctx", "module", - "cache", "err", "def", "tex", "other", "include", - "include_cuda_main_header", "type", "literal", "numeric_literal"}; + "driver", "dev", "mem", "kern", "coord_func", "math_func", + "special_func", "stream", "event", "occupancy", "ctx", "module", + "cache", "err", "def", "tex", "gl", "graphics", + "surface", "other", "include", "include_cuda_main_header", "type", + "literal", "numeric_literal"}; enum ApiTypes { API_DRIVER = 0, @@ -503,8 +507,7 @@ struct cuda2hipMap { cuda2hipRename["cuDeviceGetAttribute"] = {"hipDeviceGetAttribute", CONV_DEV, API_DRIVER}; cuda2hipRename["cuDeviceGetProperties"] = {"hipGetDeviceProperties", CONV_DEV, API_DRIVER}; cuda2hipRename["cuDeviceGetPCIBusId"] = {"hipDeviceGetPCIBusId", CONV_DEV, API_DRIVER}; - // unsupported yet by HIP - cuda2hipRename["cuDeviceGetByPCIBusId"] = {"hipDeviceGetByPCIBusId", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["cuDeviceGetByPCIBusId"] = {"hipDeviceGetByPCIBusId", CONV_DEV, API_DRIVER}; cuda2hipRename["cuDeviceTotalMem_v2"] = {"hipDeviceTotalMem", CONV_DEV, API_DRIVER}; cuda2hipRename["cuDeviceComputeCapability"] = {"hipDeviceComputeCapability", CONV_DEV, API_DRIVER}; @@ -637,19 +640,29 @@ struct cuda2hipMap { cuda2hipRename["cudaMipmappedArray_t"] = {"hipMipmappedArray *", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; cuda2hipRename["cudaMipmappedArray_const_t"] = {"const hipMipmappedArray *", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; - // Memcpy + // memcpy cuda2hipRename["cudaMemcpy"] = {"hipMemcpy", CONV_MEM, API_RUNTIME}; cuda2hipRename["cudaMemcpyToArray"] = {"hipMemcpyToArray", CONV_MEM, API_RUNTIME}; cuda2hipRename["cudaMemcpyToSymbol"] = {"hipMemcpyToSymbol", CONV_MEM, API_RUNTIME}; cuda2hipRename["cudaMemcpyToSymbolAsync"] = {"hipMemcpyToSymbolAsync", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaMemset"] = {"hipMemset", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaMemsetAsync"] = {"hipMemsetAsync", CONV_MEM, API_RUNTIME}; cuda2hipRename["cudaMemcpyAsync"] = {"hipMemcpyAsync", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaMemGetInfo"] = {"hipMemGetInfo", CONV_MEM, API_RUNTIME}; cuda2hipRename["cudaMemcpy2D"] = {"hipMemcpy2D", CONV_MEM, API_RUNTIME}; cuda2hipRename["cudaMemcpy2DToArray"] = {"hipMemcpy2DToArray", CONV_MEM, API_RUNTIME}; + // unsupported yet by HIP + cuda2hipRename["cudaMemcpy2DArrayToArray"] = {"hipMemcpy2DArrayToArray", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaMemcpy2DAsync"] = {"hipMemcpy2DAsync", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaMemcpy2DFromArray"] = {"hipMemcpy2DFromArray", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaMemcpy2DFromArrayAsync"] = {"hipMemcpy2DFromArrayAsync", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaMemcpy2DToArrayAsync"] = {"hipMemcpy2DToArrayAsync", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaMemcpy3D"] = {"hipMemcpy3D", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaMemcpy3DAsync"] = {"hipMemcpy3DAsync", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaMemcpy3DPeer"] = {"hipMemcpy3DPeer", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaMemcpy3DPeerAsync"] = {"hipMemcpy3DPeerAsync", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaMemcpyArrayToArray"] = {"hipMemcpyArrayToArray", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaMemcpyFromArrayAsync"] = {"hipMemcpyFromArrayAsync", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaMemcpyFromSymbolAsync"] = {"hipMemcpyFromSymbolAsync", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; - // Memcpy kind + // memcpy kind cuda2hipRename["cudaMemcpyKind"] = {"hipMemcpyKind", CONV_MEM, API_RUNTIME}; cuda2hipRename["cudaMemcpyHostToHost"] = {"hipMemcpyHostToHost", CONV_MEM, API_RUNTIME}; cuda2hipRename["cudaMemcpyHostToDevice"] = {"hipMemcpyHostToDevice", CONV_MEM, API_RUNTIME}; @@ -657,10 +670,35 @@ struct cuda2hipMap { cuda2hipRename["cudaMemcpyDeviceToDevice"] = {"hipMemcpyDeviceToDevice", CONV_MEM, API_RUNTIME}; cuda2hipRename["cudaMemcpyDefault"] = {"hipMemcpyDefault", CONV_MEM, API_RUNTIME}; + // memset + cuda2hipRename["cudaMemset"] = {"hipMemset", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaMemsetAsync"] = {"hipMemsetAsync", CONV_MEM, API_RUNTIME}; + // unsupported yet by HIP + cuda2hipRename["cudaMemset2D"] = {"hipMemset2D", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaMemset2DAsync"] = {"hipMemset2DAsync", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaMemset3D"] = {"hipMemset3D", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaMemset3DAsync"] = {"hipMemset3DAsync", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + // Memory management + cuda2hipRename["cudaMemGetInfo"] = {"hipMemGetInfo", CONV_MEM, API_RUNTIME}; + // unsupported yet by HIP + cuda2hipRename["cudaArrayGetInfo"] = {"hipArrayGetInfo", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaFreeMipmappedArray"] = {"hipFreeMipmappedArray", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGetMipmappedArrayLevel"] = {"hipGetMipmappedArrayLevel", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGetSymbolAddress"] = {"hipGetSymbolAddress", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGetSymbolSize"] = {"hipGetSymbolSize", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + + // malloc cuda2hipRename["cudaMalloc"] = {"hipMalloc", CONV_MEM, API_RUNTIME}; cuda2hipRename["cudaMallocHost"] = {"hipHostMalloc", CONV_MEM, API_RUNTIME}; cuda2hipRename["cudaMallocArray"] = {"hipMallocArray", CONV_MEM, API_RUNTIME}; + // unsupported yet by HIP + cuda2hipRename["cudaMalloc3D"] = {"hipMalloc3D", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaMalloc3DArray"] = {"hipMalloc3DArray", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaMallocManaged"] = {"hipMallocManaged", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaMallocMipmappedArray"] = {"hipMallocMipmappedArray", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaMallocPitch"] = {"hipMallocPitch", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaFree"] = {"hipFree", CONV_MEM, API_RUNTIME}; cuda2hipRename["cudaFreeHost"] = {"hipHostFree", CONV_MEM, API_RUNTIME}; cuda2hipRename["cudaFreeArray"] = {"hipFreeArray", CONV_MEM, API_RUNTIME}; @@ -674,6 +712,12 @@ struct cuda2hipMap { cuda2hipRename["cudaMemoryTypeHost"] = {"hipMemoryTypeHost", CONV_MEM, API_RUNTIME}; cuda2hipRename["cudaMemoryTypeDevice"] = {"hipMemoryTypeDevice", CONV_MEM, API_RUNTIME}; + // make memory functions + // unsupported yet by HIP + cuda2hipRename["make_cudaExtent"] = {"make_hipExtent", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["make_cudaPitchedPtr"] = {"make_hipPitchedPtr", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["make_cudaPos"] = {"make_hipPos", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + // Host Malloc Flags cuda2hipRename["cudaHostAllocDefault"] = {"hipHostMallocDefault", CONV_MEM, API_RUNTIME}; cuda2hipRename["cudaHostAllocPortable"] = {"hipHostMallocPortable", CONV_MEM, API_RUNTIME}; @@ -719,50 +763,55 @@ struct cuda2hipMap { cuda2hipRename["warpSize"] = {"hipWarpSize", CONV_SPECIAL_FUNC, API_RUNTIME}; // Events - cuda2hipRename["cudaEvent_t"] = {"hipEvent_t", CONV_TYPE, API_RUNTIME}; - cuda2hipRename["cudaEventCreate"] = {"hipEventCreate", CONV_EVENT, API_RUNTIME}; - cuda2hipRename["cudaEventCreateWithFlags"] = {"hipEventCreateWithFlags", CONV_EVENT, API_RUNTIME}; - cuda2hipRename["cudaEventDestroy"] = {"hipEventDestroy", CONV_EVENT, API_RUNTIME}; - cuda2hipRename["cudaEventRecord"] = {"hipEventRecord", CONV_EVENT, API_RUNTIME}; - cuda2hipRename["cudaEventElapsedTime"] = {"hipEventElapsedTime", CONV_EVENT, API_RUNTIME}; - cuda2hipRename["cudaEventSynchronize"] = {"hipEventSynchronize", CONV_EVENT, API_RUNTIME}; - cuda2hipRename["cudaEventQuery"] = {"hipEventQuery", CONV_EVENT, API_RUNTIME}; + cuda2hipRename["cudaEvent_t"] = {"hipEvent_t", CONV_TYPE, API_RUNTIME}; + cuda2hipRename["cudaEventCreate"] = {"hipEventCreate", CONV_EVENT, API_RUNTIME}; + cuda2hipRename["cudaEventCreateWithFlags"] = {"hipEventCreateWithFlags", CONV_EVENT, API_RUNTIME}; + cuda2hipRename["cudaEventDestroy"] = {"hipEventDestroy", CONV_EVENT, API_RUNTIME}; + cuda2hipRename["cudaEventRecord"] = {"hipEventRecord", CONV_EVENT, API_RUNTIME}; + cuda2hipRename["cudaEventElapsedTime"] = {"hipEventElapsedTime", CONV_EVENT, API_RUNTIME}; + cuda2hipRename["cudaEventSynchronize"] = {"hipEventSynchronize", CONV_EVENT, API_RUNTIME}; + cuda2hipRename["cudaEventQuery"] = {"hipEventQuery", CONV_EVENT, API_RUNTIME}; // Event Flags - cuda2hipRename["cudaEventDefault"] = {"hipEventDefault", CONV_EVENT, API_RUNTIME}; - cuda2hipRename["cudaEventBlockingSync"] = {"hipEventBlockingSync", CONV_EVENT, API_RUNTIME}; - cuda2hipRename["cudaEventDisableTiming"] = {"hipEventDisableTiming", CONV_EVENT, API_RUNTIME}; - cuda2hipRename["cudaEventInterprocess"] = {"hipEventInterprocess", CONV_EVENT, API_RUNTIME}; + cuda2hipRename["cudaEventDefault"] = {"hipEventDefault", CONV_EVENT, API_RUNTIME}; + cuda2hipRename["cudaEventBlockingSync"] = {"hipEventBlockingSync", CONV_EVENT, API_RUNTIME}; + cuda2hipRename["cudaEventDisableTiming"] = {"hipEventDisableTiming", CONV_EVENT, API_RUNTIME}; + cuda2hipRename["cudaEventInterprocess"] = {"hipEventInterprocess", CONV_EVENT, API_RUNTIME}; // Streams - cuda2hipRename["cudaStream_t"] = {"hipStream_t", CONV_TYPE, API_RUNTIME}; - cuda2hipRename["cudaStreamCreate"] = {"hipStreamCreate", CONV_STREAM, API_RUNTIME}; - cuda2hipRename["cudaStreamCreateWithFlags"] = {"hipStreamCreateWithFlags", CONV_STREAM, API_RUNTIME}; - cuda2hipRename["cudaStreamDestroy"] = {"hipStreamDestroy", CONV_STREAM, API_RUNTIME}; - cuda2hipRename["cudaStreamWaitEvent"] = {"hipStreamWaitEvent", CONV_STREAM, API_RUNTIME}; - cuda2hipRename["cudaStreamSynchronize"] = {"hipStreamSynchronize", CONV_STREAM, API_RUNTIME}; - cuda2hipRename["cudaStreamGetFlags"] = {"hipStreamGetFlags", CONV_STREAM, API_RUNTIME}; - cuda2hipRename["cudaStreamQuery"] = {"hipStreamQuery", CONV_STREAM, API_RUNTIME}; - cuda2hipRename["cudaStreamAddCallback"] = {"hipStreamAddCallback", CONV_STREAM, API_RUNTIME}; + cuda2hipRename["cudaStream_t"] = {"hipStream_t", CONV_TYPE, API_RUNTIME}; + cuda2hipRename["cudaStreamCreate"] = {"hipStreamCreate", CONV_STREAM, API_RUNTIME}; + cuda2hipRename["cudaStreamCreateWithFlags"] = {"hipStreamCreateWithFlags", CONV_STREAM, API_RUNTIME}; + // unsupported yet by HIP + cuda2hipRename["cudaStreamCreateWithPriority"] = {"hipStreamCreateWithPriority", CONV_STREAM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaStreamDestroy"] = {"hipStreamDestroy", CONV_STREAM, API_RUNTIME}; + cuda2hipRename["cudaStreamWaitEvent"] = {"hipStreamWaitEvent", CONV_STREAM, API_RUNTIME}; + cuda2hipRename["cudaStreamSynchronize"] = {"hipStreamSynchronize", CONV_STREAM, API_RUNTIME}; + cuda2hipRename["cudaStreamGetFlags"] = {"hipStreamGetFlags", CONV_STREAM, API_RUNTIME}; + cuda2hipRename["cudaStreamQuery"] = {"hipStreamQuery", CONV_STREAM, API_RUNTIME}; + cuda2hipRename["cudaStreamAddCallback"] = {"hipStreamAddCallback", CONV_STREAM, API_RUNTIME}; + // unsupported yet by HIP + cuda2hipRename["cudaStreamAttachMemAsync"] = {"hipStreamAttachMemAsync", CONV_STREAM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaStreamGetPriority"] = {"hipStreamGetPriority", CONV_STREAM, API_RUNTIME, HIP_UNSUPPORTED}; // Stream Flags - cuda2hipRename["cudaStreamDefault"] = {"hipStreamDefault", CONV_STREAM, API_RUNTIME}; - cuda2hipRename["cudaStreamNonBlocking"] = {"hipStreamNonBlocking", CONV_STREAM, API_RUNTIME}; + cuda2hipRename["cudaStreamDefault"] = {"hipStreamDefault", CONV_STREAM, API_RUNTIME}; + cuda2hipRename["cudaStreamNonBlocking"] = {"hipStreamNonBlocking", CONV_STREAM, API_RUNTIME}; // Other synchronization - cuda2hipRename["cudaDeviceSynchronize"] = {"hipDeviceSynchronize", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDeviceSynchronize"] = {"hipDeviceSynchronize", CONV_DEV, API_RUNTIME}; // translate deprecated cudaThreadSynchronize - cuda2hipRename["cudaThreadSynchronize"] = {"hipDeviceSynchronize", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDeviceReset"] = {"hipDeviceReset", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaThreadSynchronize"] = {"hipDeviceSynchronize", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDeviceReset"] = {"hipDeviceReset", CONV_DEV, API_RUNTIME}; // translate deprecated cudaThreadExit - cuda2hipRename["cudaThreadExit"] = {"hipDeviceReset", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaSetDevice"] = {"hipSetDevice", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaGetDevice"] = {"hipGetDevice", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaGetDeviceCount"] = {"hipGetDeviceCount", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaChooseDevice"] = {"hipChooseDevice", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaThreadExit"] = {"hipDeviceReset", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaSetDevice"] = {"hipSetDevice", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaGetDevice"] = {"hipGetDevice", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaGetDeviceCount"] = {"hipGetDeviceCount", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaChooseDevice"] = {"hipChooseDevice", CONV_DEV, API_RUNTIME}; // Attributes - cuda2hipRename["cudaDeviceAttr"] = {"hipDeviceAttribute_t", CONV_TYPE, API_RUNTIME}; - cuda2hipRename["cudaDeviceGetAttribute"] = {"hipDeviceGetAttribute", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDeviceAttr"] = {"hipDeviceAttribute_t", CONV_TYPE, API_RUNTIME}; + cuda2hipRename["cudaDeviceGetAttribute"] = {"hipDeviceGetAttribute", CONV_DEV, API_RUNTIME}; cuda2hipRename["cudaDevAttrMaxThreadsPerBlock"] = {"hipDeviceAttributeMaxThreadsPerBlock", CONV_DEV, API_RUNTIME}; cuda2hipRename["cudaDevAttrMaxBlockDimX"] = {"hipDeviceAttributeMaxBlockDimX", CONV_DEV, API_RUNTIME}; @@ -864,11 +913,17 @@ struct cuda2hipMap { cuda2hipRename["cudaHostGetDevicePointer"] = {"hipHostGetDevicePointer", CONV_MEM, API_RUNTIME}; // Device - cuda2hipRename["cudaDeviceProp"] = {"hipDeviceProp_t", CONV_TYPE, API_RUNTIME}; - cuda2hipRename["cudaGetDeviceProperties"] = {"hipGetDeviceProperties", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDeviceGetByPCIBusId"] = {"hipDeviceGetByPCIBusId", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDeviceProp"] = {"hipDeviceProp_t", CONV_TYPE, API_RUNTIME}; + cuda2hipRename["cudaGetDeviceProperties"] = {"hipGetDeviceProperties", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDeviceGetPCIBusId"] = {"hipDeviceGetPCIBusId", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDeviceGetByPCIBusId"] = {"hipDeviceGetByPCIBusId", CONV_DEV, API_RUNTIME}; + // unsupported yet by HIP + cuda2hipRename["cudaDeviceGetStreamPriorityRange"] = {"hipDeviceGetStreamPriorityRange", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaSetValidDevices"] = {"hipSetValidDevices", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // Device Flags + // unsupported yet by HIP + cuda2hipRename["cudaGetDeviceFlags"] = {"hipGetDeviceFlags", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; cuda2hipRename["cudaSetDeviceFlags"] = {"hipSetDeviceFlags", CONV_DEV, API_RUNTIME}; cuda2hipRename["cudaDeviceScheduleAuto"] = {"hipDeviceScheduleAuto", CONV_DEV, API_RUNTIME}; cuda2hipRename["cudaDeviceScheduleSpin"] = {"hipDeviceScheduleSpin", CONV_DEV, API_RUNTIME}; @@ -885,18 +940,35 @@ struct cuda2hipMap { cuda2hipRename["cudaDeviceMask"] = {"hipDeviceMask", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // Cache config - cuda2hipRename["cudaDeviceSetCacheConfig"] = {"hipDeviceSetCacheConfig", CONV_CACHE, API_RUNTIME}; + cuda2hipRename["cudaDeviceSetCacheConfig"] = {"hipDeviceSetCacheConfig", CONV_CACHE, API_RUNTIME}; // translate deprecated - cuda2hipRename["cudaThreadSetCacheConfig"] = {"hipDeviceSetCacheConfig", CONV_CACHE, API_RUNTIME}; - cuda2hipRename["cudaDeviceGetCacheConfig"] = {"hipDeviceGetCacheConfig", CONV_CACHE, API_RUNTIME}; + cuda2hipRename["cudaThreadSetCacheConfig"] = {"hipDeviceSetCacheConfig", CONV_CACHE, API_RUNTIME}; + cuda2hipRename["cudaDeviceGetCacheConfig"] = {"hipDeviceGetCacheConfig", CONV_CACHE, API_RUNTIME}; // translate deprecated - cuda2hipRename["cudaThreadGetCacheConfig"] = {"hipDeviceGetCacheConfig", CONV_CACHE, API_RUNTIME}; - cuda2hipRename["cudaFuncCache"] = {"hipFuncCache_t", CONV_CACHE, API_RUNTIME}; - cuda2hipRename["cudaFuncCachePreferNone"] = {"hipFuncCachePreferNone", CONV_CACHE, API_RUNTIME}; - cuda2hipRename["cudaFuncCachePreferShared"] = {"hipFuncCachePreferShared", CONV_CACHE, API_RUNTIME}; - cuda2hipRename["cudaFuncCachePreferL1"] = {"hipFuncCachePreferL1", CONV_CACHE, API_RUNTIME}; - cuda2hipRename["cudaFuncCachePreferEqual"] = {"hipFuncCachePreferEqual", CONV_CACHE, API_RUNTIME}; - cuda2hipRename["cudaFuncSetCacheConfig"] = {"hipFuncSetCacheConfig", CONV_CACHE, API_RUNTIME}; + cuda2hipRename["cudaThreadGetCacheConfig"] = {"hipDeviceGetCacheConfig", CONV_CACHE, API_RUNTIME}; + + // Execution control + // CUDA function cache configurations + cuda2hipRename["cudaFuncCache"] = {"hipFuncCache_t", CONV_CACHE, API_RUNTIME}; + cuda2hipRename["cudaFuncCachePreferNone"] = {"hipFuncCachePreferNone", CONV_CACHE, API_RUNTIME}; + cuda2hipRename["cudaFuncCachePreferShared"] = {"hipFuncCachePreferShared", CONV_CACHE, API_RUNTIME}; + cuda2hipRename["cudaFuncCachePreferL1"] = {"hipFuncCachePreferL1", CONV_CACHE, API_RUNTIME}; + cuda2hipRename["cudaFuncCachePreferEqual"] = {"hipFuncCachePreferEqual", CONV_CACHE, API_RUNTIME}; + // Execution control functions + // unsupported yet by HIP + cuda2hipRename["cudaFuncGetAttributes"] = {"hipFuncGetAttributes", CONV_CACHE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaFuncSetCacheConfig"] = {"hipFuncSetCacheConfig", CONV_CACHE, API_RUNTIME}; + // unsupported yet by HIP + cuda2hipRename["cudaFuncSetSharedMemConfig"] = {"hipFuncSetSharedMemConfig", CONV_CACHE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGetParameterBuffer"] = {"hipGetParameterBuffer", CONV_CACHE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaSetDoubleForDevice"] = {"hipSetDoubleForDevice", CONV_CACHE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaSetDoubleForHost"] = {"hipSetDoubleForHost", CONV_CACHE, API_RUNTIME, HIP_UNSUPPORTED}; + + // Execution Control [deprecated since 7.0] + // unsupported yet by HIP + cuda2hipRename["cudaConfigureCall"] = {"hipConfigureCall", CONV_CACHE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaLaunch"] = {"hipLaunch", CONV_CACHE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaSetupArgument"] = {"hipSetupArgument", CONV_CACHE, API_RUNTIME, HIP_UNSUPPORTED}; // Driver/Runtime cuda2hipRename["cudaDriverGetVersion"] = {"hipDriverGetVersion", CONV_DRIVER, API_RUNTIME}; @@ -957,7 +1029,7 @@ struct cuda2hipMap { cuda2hipRename["cudaReadModeElementType"] = {"hipReadModeElementType", CONV_TEX, API_RUNTIME}; - // Textures + // Texture Reference Management cuda2hipRename["cudaTextureReadMode"] = {"hipTextureReadMode", CONV_TEX, API_RUNTIME}; cuda2hipRename["cudaReadModeElementType"] = {"hipReadModeElementType", CONV_TEX, API_RUNTIME}; // unsupported yet by HIP @@ -968,6 +1040,13 @@ struct cuda2hipMap { cuda2hipRename["cudaFilterModeLinear"] = {"hipFilterModeLinear", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; cuda2hipRename["cudaBindTexture"] = {"hipBindTexture", CONV_TEX, API_RUNTIME}; cuda2hipRename["cudaUnbindTexture"] = {"hipUnbindTexture", CONV_TEX, API_RUNTIME}; + // unsupported yet by HIP + cuda2hipRename["cudaBindTexture2D"] = {"hipBindTexture2D", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaBindTextureToArray"] = {"hipBindTextureToArray", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaBindTextureToMipmappedArray"] = {"hipBindTextureToMipmappedArray", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGetTextureAlignmentOffset"] = {"hipGetTextureAlignmentOffset", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGetTextureReference"] = {"hipGetTextureReference", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + // Channel cuda2hipRename["cudaChannelFormatKind"] = {"hipChannelFormatKind", CONV_TEX, API_RUNTIME}; cuda2hipRename["cudaChannelFormatKindSigned"] = {"hipChannelFormatKindSigned", CONV_TEX, API_RUNTIME}; @@ -976,6 +1055,27 @@ struct cuda2hipMap { cuda2hipRename["cudaChannelFormatKindNone"] = {"hipChannelFormatKindNone", CONV_TEX, API_RUNTIME}; cuda2hipRename["cudaChannelFormatDesc"] = {"hipChannelFormatDesc", CONV_TEX, API_RUNTIME}; cuda2hipRename["cudaCreateChannelDesc"] = {"hipCreateChannelDesc", CONV_TEX, API_RUNTIME}; + // unsupported yet by HIP + cuda2hipRename["cudaGetChannelDesc"] = {"hipGetChannelDesc", CONV_TEX, API_RUNTIME}; + + // Texture Object Management + // unsupported yet by HIP + cuda2hipRename["cudaCreateTextureObject"] = {"hipCreateTextureObject", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDestroyTextureObject"] = {"hipDestroyTextureObject", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGetTextureObjectResourceDesc"] = {"hipGetTextureObjectResourceDesc", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGetTextureObjectResourceViewDesc"] = {"hipGetTextureObjectResourceViewDesc", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGetTextureObjectTextureDesc"] = {"hipGetTextureObjectTextureDesc", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + + // Surface Reference Management + // unsupported yet by HIP + cuda2hipRename["cudaBindSurfaceToArray"] = {"hipBindSurfaceToArray", CONV_SURFACE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGetSurfaceReference"] = {"hipGetSurfaceReference", CONV_SURFACE, API_RUNTIME, HIP_UNSUPPORTED}; + + // Surface Object Management + // unsupported yet by HIP + cuda2hipRename["cudaCreateSurfaceObject"] = {"hipCreateSurfaceObject", CONV_SURFACE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDestroySurfaceObject"] = {"hipDestroySurfaceObject", CONV_SURFACE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGetSurfaceObjectResourceDesc"] = {"hipGetSurfaceObjectResourceDesc", CONV_SURFACE, API_RUNTIME, HIP_UNSUPPORTED}; // Inter-Process Communications (IPC) // IPC types @@ -991,6 +1091,23 @@ struct cuda2hipMap { cuda2hipRename["cudaIpcOpenEventHandle"] = {"hipIpcOpenEventHandle", CONV_DEV, API_RUNTIME}; cuda2hipRename["cudaIpcOpenMemHandle"] = {"hipIpcOpenMemHandle", CONV_DEV, API_RUNTIME}; + // OpenGL Interoperability + // unsupported yet by HIP + cuda2hipRename["cudaGLGetDevices"] = {"hipGLGetDevices", CONV_GL, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGraphicsGLRegisterBuffer"] = {"hipGraphicsGLRegisterBuffer", CONV_GL, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGraphicsGLRegisterImage"] = {"hipGraphicsGLRegisterImage", CONV_GL, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaWGLGetDevice"] = {"hipWGLGetDevice", CONV_GL, API_RUNTIME, HIP_UNSUPPORTED}; + + // Graphics Interoperability + // unsupported yet by HIP + cuda2hipRename["cudaGraphicsMapResources"] = {"hipGraphicsMapResources", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGraphicsResourceGetMappedMipmappedArray"] = {"hipGraphicsResourceGetMappedMipmappedArray", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGraphicsResourceGetMappedPointer"] = {"hipGraphicsResourceGetMappedPointer", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGraphicsResourceSetMapFlags"] = {"hipGraphicsResourceSetMapFlags", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGraphicsSubResourceGetMappedArray"] = {"hipGraphicsSubResourceGetMappedArray", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGraphicsUnmapResources"] = {"hipGraphicsUnmapResources", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGraphicsUnregisterResource"] = {"hipGraphicsUnregisterResource", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; + //---------------------------------------BLAS-------------------------------------// // Blas types cuda2hipRename["cublasHandle_t"] = {"hipblasHandle_t", CONV_TYPE, API_BLAS}; From cfb607a21dbd9f3a296e18777e16812c0b309837 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Mon, 20 Feb 2017 21:21:47 +0300 Subject: [PATCH 160/281] [HIP] [DOC] Update CUDA_Runtime_API_functions_supported_by_HIP cudaDeviceGetPCIBusId -> hipDeviceGetPCIBusId [ROCm/hip commit: bd9b674d3d55bbc23ebe7162a69342a08d701310] --- .../CUDA_Runtime_API_functions_supported_by_HIP.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/projects/hip/docs/markdown/CUDA_Runtime_API_functions_supported_by_HIP.md b/projects/hip/docs/markdown/CUDA_Runtime_API_functions_supported_by_HIP.md index a24490d458..4735f2b8dc 100644 --- a/projects/hip/docs/markdown/CUDA_Runtime_API_functions_supported_by_HIP.md +++ b/projects/hip/docs/markdown/CUDA_Runtime_API_functions_supported_by_HIP.md @@ -9,7 +9,7 @@ | `cudaDeviceGetByPCIBusId` | `hipDeviceGetByPCIBusId` | Returns a handle to a compute device. | | `cudaDeviceGetCacheConfig` | `hipDeviceGetCacheConfig` | Returns the preferred cache configuration for the current device. | | `cudaDeviceGetLimit` | `hipDeviceGetLimit` | Returns resource limits. | -| `cudaDeviceGetPCIBusId` | | Returns a PCI Bus Id string for the device. | +| `cudaDeviceGetPCIBusId` | `hipDeviceGetPCIBusId` | Returns a PCI Bus Id string for the device. | | `cudaDeviceGetSharedMemConfig` | `hipDeviceGetSharedMemConfig` | Returns the shared memory configuration for the current device. | | `cudaDeviceGetStreamPriorityRange` | | Returns numerical values that correspond to the least and greatest stream priorities. | | `cudaDeviceReset` | `hipDeviceReset` | Destroy all allocations and reset all state on the current device in the current process. | @@ -151,9 +151,9 @@ | `cudaMemset3D` | | Initializes or sets device memory to a value. | | `cudaMemset3DAsync` | | Initializes or sets device memory to a value. | | `cudaMemsetAsync` | `hipMemsetAsync` | Initializes or sets device memory to a value. | -| `make\_cudaExtent` | | Returns a cudaExtent based on input parameters. | -| `make\_cudaPitchedPtr` | | Returns a cudaPitchedPtr based on input parameters. | -| `make\_cudaPos` | | Returns a cudaPos based on input parameters. | +| `make_cudaExtent` | | Returns a cudaExtent based on input parameters. | +| `make_cudaPitchedPtr` | | Returns a cudaPitchedPtr based on input parameters. | +| `make_cudaPos` | | Returns a cudaPos based on input parameters. | ## **9. Unified Addressing** From ed1915ad97ccbcbacc894db6e6975b368ee3172e Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Mon, 20 Feb 2017 21:26:40 +0300 Subject: [PATCH 161/281] [HIP] annotation update. cudaStreamAddCallback and cudaStreamWaitEvent were excluded from unsupported. [ROCm/hip commit: 2461ddd79d2513434593d6c550f4cc25cb38f8a3] --- projects/hip/include/hip/hcc_detail/hip_runtime_api.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h index 7abfffcc22..2cf14156a2 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h @@ -511,12 +511,10 @@ const char *hipGetErrorString(hipError_t hipError); * @{ * * The following Stream APIs are not (yet) supported in HIP: - * - cudaStreamAddCallback * - cudaStreamAttachMemAsync * - cudaStreamCreateWithPriority * - cudaStreamGetPriority - * - cudaStreamWaitEvent - */ + */ /** From a89ef494545ae0c26abd534a0959212fa402f880 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Tue, 21 Feb 2017 14:44:37 -0600 Subject: [PATCH 162/281] added typedef for half and half2 Change-Id: Ic844fa31b64a0354484b418df71869c2807200cc [ROCm/hip commit: a1f39558603bee7a380c4c486fafdf18288fba28] --- projects/hip/include/hip/hcc_detail/hip_fp16.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/projects/hip/include/hip/hcc_detail/hip_fp16.h b/projects/hip/include/hip/hcc_detail/hip_fp16.h index 2c7c23440c..b28f92d451 100644 --- a/projects/hip/include/hip/hcc_detail/hip_fp16.h +++ b/projects/hip/include/hip/hcc_detail/hip_fp16.h @@ -36,6 +36,9 @@ typedef struct __attribute__((aligned(4))){ }; } __half2; +typedef __half half; +typedef __half2 half2; + /* Half Arithmetic Functions */ From 7831962f6d93d94b890684e9284eae15f5f956c9 Mon Sep 17 00:00:00 2001 From: Paul Date: Tue, 21 Feb 2017 22:03:13 -0600 Subject: [PATCH 163/281] Change order of find_dependency [ROCm/hip commit: 2e83e3a01d7118c286a55f106a0571a22b7f1d08] --- projects/hip/hip-config.cmake.in | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/projects/hip/hip-config.cmake.in b/projects/hip/hip-config.cmake.in index bcdaf0671d..2d607e605d 100644 --- a/projects/hip/hip-config.cmake.in +++ b/projects/hip/hip-config.cmake.in @@ -39,13 +39,16 @@ if (NOT _CMakeFindDependencyMacro_FOUND) endmacro() endif() -find_dependency(hcc) set_and_check( hip_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@" ) set_and_check( hip_INCLUDE_DIRS "${hip_INCLUDE_DIR}" ) set_and_check( hip_LIB_INSTALL_DIR "@PACKAGE_LIB_INSTALL_DIR@" ) set_and_check( hip_BIN_INSTALL_DIR "@PACKAGE_BIN_INSTALL_DIR@" ) +set_and_check(HIP_HIPCC_EXECUTABLE "${hip_BIN_INSTALL_DIR}/hipcc") +set_and_check(HIP_HIPCONFIG_EXECUTABLE "${hip_BIN_INSTALL_DIR}/hipconfig") + +find_dependency(hcc) include( "${CMAKE_CURRENT_LIST_DIR}/hip-targets.cmake" ) set( hip_LIBRARIES hip::hip_hcc) @@ -58,5 +61,3 @@ set(HIP_BIN_INSTALL_DIR ${hip_BIN_INSTALL_DIR}) set(HIP_LIBRARIES ${hip_LIBRARIES}) set(HIP_LIBRARY ${hip_LIBRARY}) -set_and_check(HIP_HIPCC_EXECUTABLE "${hip_BIN_INSTALL_DIR}/hipcc") -set_and_check(HIP_HIPCONFIG_EXECUTABLE "${hip_BIN_INSTALL_DIR}/hipconfig") From b98e396fc9a51a214621941f8a9993adf7950a86 Mon Sep 17 00:00:00 2001 From: Paul Date: Tue, 21 Feb 2017 22:07:04 -0600 Subject: [PATCH 164/281] Update for lower case hip [ROCm/hip commit: 5dbf7e0618913463d4708085f4662d028cb46ef1] --- projects/hip/hip-config.cmake.in | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/projects/hip/hip-config.cmake.in b/projects/hip/hip-config.cmake.in index 2d607e605d..7e4468b94a 100644 --- a/projects/hip/hip-config.cmake.in +++ b/projects/hip/hip-config.cmake.in @@ -45,8 +45,8 @@ set_and_check( hip_INCLUDE_DIRS "${hip_INCLUDE_DIR}" ) set_and_check( hip_LIB_INSTALL_DIR "@PACKAGE_LIB_INSTALL_DIR@" ) set_and_check( hip_BIN_INSTALL_DIR "@PACKAGE_BIN_INSTALL_DIR@" ) -set_and_check(HIP_HIPCC_EXECUTABLE "${hip_BIN_INSTALL_DIR}/hipcc") -set_and_check(HIP_HIPCONFIG_EXECUTABLE "${hip_BIN_INSTALL_DIR}/hipconfig") +set_and_check(hip_HIPCC_EXECUTABLE "${hip_BIN_INSTALL_DIR}/hipcc") +set_and_check(hip_HIPCONFIG_EXECUTABLE "${hip_BIN_INSTALL_DIR}/hipconfig") find_dependency(hcc) include( "${CMAKE_CURRENT_LIST_DIR}/hip-targets.cmake" ) @@ -60,4 +60,6 @@ set(HIP_LIB_INSTALL_DIR ${hip_LIB_INSTALL_DIR}) set(HIP_BIN_INSTALL_DIR ${hip_BIN_INSTALL_DIR}) set(HIP_LIBRARIES ${hip_LIBRARIES}) set(HIP_LIBRARY ${hip_LIBRARY}) +set(HIP_HIPCC_EXECUTABLE ${hip_HIPCC_EXECUTABLE}) +set(HIP_HIPCONFIG_EXECUTABLE ${hip_HIPCONFIG_EXECUTABLE}) From 9e1a6a4013c69404b6198ab8a3220000469defd3 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Wed, 22 Feb 2017 13:42:03 -0600 Subject: [PATCH 165/281] Enable symbol tests Change-Id: I6bd036bf00c8051c8ff728ee60562c4ebd222160 [ROCm/hip commit: d52c5867f2d84394c7e110c1a98135e2b04a7b3b] --- projects/hip/src/device_util.h | 2 +- projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp | 2 +- projects/hip/tests/src/kernel/hipTestConstant.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/projects/hip/src/device_util.h b/projects/hip/src/device_util.h index e302b7db8a..ad8b2607dd 100644 --- a/projects/hip/src/device_util.h +++ b/projects/hip/src/device_util.h @@ -32,7 +32,7 @@ THE SOFTWARE. #define NUM_PAGES_PER_THREAD 16 #define SIZE_OF_PAGE 64 #define NUM_THREADS_PER_CU 64 -#define NUM_CUS_PER_GPU 64 +#define NUM_CUS_PER_GPU 64 // Specific for r9 Nano #define NUM_PAGES NUM_PAGES_PER_THREAD * NUM_THREADS_PER_CU * NUM_CUS_PER_GPU #define SIZE_MALLOC NUM_PAGES * SIZE_OF_PAGE #define SIZE_OF_HEAP SIZE_MALLOC diff --git a/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp b/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp index ed4d3902c5..49a719a8d4 100644 --- a/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp +++ b/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp @@ -18,7 +18,7 @@ THE SOFTWARE. */ /* HIT_START - * BUILD: %t %s ../test_common.cpp EXCLUDE_HIP_PLATFORM all + * BUILD: %t %s * RUN: %t * HIT_END */ diff --git a/projects/hip/tests/src/kernel/hipTestConstant.cpp b/projects/hip/tests/src/kernel/hipTestConstant.cpp index 6d630f97ff..9aeaf59c00 100644 --- a/projects/hip/tests/src/kernel/hipTestConstant.cpp +++ b/projects/hip/tests/src/kernel/hipTestConstant.cpp @@ -18,7 +18,7 @@ THE SOFTWARE. */ /* HIT_START - * BUILD: %t %s ../test_common.cpp EXCLUDE_HIP_PLATFORM all + * BUILD: %t %s ../test_common.cpp * RUN: %t * HIT_END */ From d24435ea9b19f7d1f965444da172b5869950d283 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Wed, 22 Feb 2017 19:16:35 -0600 Subject: [PATCH 166/281] added runtime api hipMemcpyFromSymbolAsync Change-Id: Ibaf925faf0ba464dd0ed6c5ea74c224c2ce38889 [ROCm/hip commit: 639fd4dd5e6f3c14d4ba00c3be266230055cc038] --- .../include/hip/hcc_detail/hip_runtime_api.h | 2 +- projects/hip/src/hip_hcc.cpp | 19 ++++++--- projects/hip/src/hip_hcc.h | 4 +- projects/hip/src/hip_memory.cpp | 42 +++++++++++++++++-- .../src/deviceLib/hipTestDeviceSymbol.cpp | 28 +++++++++---- 5 files changed, 74 insertions(+), 21 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h index 2cf14156a2..2c75b584c4 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h @@ -1159,7 +1159,7 @@ hipError_t hipMemcpyToSymbol(const char* symbolName, const void *src, size_t siz */ hipError_t hipMemcpyToSymbolAsync(const char* symbolName, const void *src, size_t sizeBytes, size_t offset, hipMemcpyKind kind, hipStream_t stream); - +hipError_t hipMemcpyFromSymbolAsync(void *dst, const char* symbolName, size_t sizeBytes, size_t offset, hipMemcpyKind kind, hipStream_t stream); /** * @brief Copy data from src to dst asynchronously. diff --git a/projects/hip/src/hip_hcc.cpp b/projects/hip/src/hip_hcc.cpp index 68bf74cd21..a119ea1c54 100644 --- a/projects/hip/src/hip_hcc.cpp +++ b/projects/hip/src/hip_hcc.cpp @@ -1780,7 +1780,7 @@ void ihipStream_t::locked_copySync(void* dst, const void* src, size_t sizeBytes, } } -void ihipStream_t::lockedSymbolCopySync(hc::accelerator &acc, void* dst, const void* src, size_t sizeBytes, unsigned kind) +void ihipStream_t::lockedSymbolCopySync(hc::accelerator &acc, void* dst, void* src, size_t sizeBytes, unsigned kind) { if(kind == hipMemcpyHostToHost){ acc.memcpy_symbol(dst, (void*)src, sizeBytes, Kalmar::hcMemcpyHostToHost); @@ -1796,11 +1796,18 @@ void ihipStream_t::lockedSymbolCopySync(hc::accelerator &acc, void* dst, const v } } -void ihipStream_t::lockedSymbolCopyAsync(hc::accelerator &acc, void* dst, const void* src, size_t sizeBytes, unsigned kind) +void ihipStream_t::lockedSymbolCopyAsync(hc::accelerator &acc, void* dst, void* src, size_t sizeBytes, unsigned kind) { - hc::AmPointerInfo dstPtrInfo(NULL, dst, sizeBytes, acc, true, false); - hc::am_memtracker_add(dst, dstPtrInfo); - locked_getAv()->copy_async((void*)src, dst, sizeBytes); + if(kind == hipMemcpyHostToDevice) { + hc::AmPointerInfo dstPtrInfo(NULL, dst, sizeBytes, acc, true, false); + hc::am_memtracker_add(dst, dstPtrInfo); + locked_getAv()->copy_async((void*)src, dst, sizeBytes); + } + if(kind == hipMemcpyDeviceToHost) { + hc::AmPointerInfo srcPtrInfo(NULL, src, sizeBytes, acc, true, false); + hc::am_memtracker_add(src, srcPtrInfo); + locked_getAv()->copy_async((void*)src, dst, sizeBytes); + } } void ihipStream_t::locked_copyAsync(void* dst, const void* src, size_t sizeBytes, unsigned kind) @@ -1903,7 +1910,7 @@ void ihipStream_t::locked_copyAsync(void* dst, const void* src, size_t sizeBytes LockedAccessor_StreamCrit_t crit(_criticalData); this->ensureHaveQueue(crit); - + #if USE_COPY_EXT_V2 crit->_av.copy_ext(src, dst, sizeBytes, hcCopyDir, srcPtrInfo, dstPtrInfo, copyDevice ? ©Device->getDevice()->_acc : nullptr, forceUnpinnedCopy); #else diff --git a/projects/hip/src/hip_hcc.h b/projects/hip/src/hip_hcc.h index 5509e4aa10..d7d92a221c 100644 --- a/projects/hip/src/hip_hcc.h +++ b/projects/hip/src/hip_hcc.h @@ -494,8 +494,8 @@ public: void locked_copySync (void* dst, const void* src, size_t sizeBytes, unsigned kind, bool resolveOn = true); void locked_copyAsync(void* dst, const void* src, size_t sizeBytes, unsigned kind); - void lockedSymbolCopySync(hc::accelerator &acc, void *dst, const void* src, size_t sizeBytes, unsigned kind); - void lockedSymbolCopyAsync(hc::accelerator &acc, void *dst, const void* src, size_t sizeBytes, unsigned kind); + void lockedSymbolCopySync(hc::accelerator &acc, void *dst, void* src, size_t sizeBytes, unsigned kind); + void lockedSymbolCopyAsync(hc::accelerator &acc, void *dst, void* src, size_t sizeBytes, unsigned kind); //--- // Member functions that begin with locked_ are thread-safe accessors - these acquire / release the critical mutex. diff --git a/projects/hip/src/hip_memory.cpp b/projects/hip/src/hip_memory.cpp index df776aa707..cb265159ba 100644 --- a/projects/hip/src/hip_memory.cpp +++ b/projects/hip/src/hip_memory.cpp @@ -461,7 +461,7 @@ hipError_t hipMemcpyToSymbol(const char* symbolName, const void *src, size_t cou if(kind == hipMemcpyHostToDevice || kind == hipMemcpyDeviceToHost || kind == hipMemcpyDeviceToDevice || kind == hipMemcpyHostToHost) { - stream->lockedSymbolCopySync(acc, dst, src, count + offset, kind); + stream->lockedSymbolCopySync(acc, dst, (void*)src, count + offset, kind); // acc.memcpy_symbol(dst, (void*)src, count+offset); } else { return ihipLogStatus(hipErrorInvalidValue); @@ -493,6 +493,44 @@ hipError_t hipMemcpyToSymbolAsync(const char* symbolName, const void *src, size_ return ihipLogStatus(hipErrorInvalidSymbol); } + if (stream) { + try { + stream->lockedSymbolCopyAsync(acc, dst, (void*)src, count + offset, kind); + } + catch (ihipException ex) { + e = ex._code; + } + } else { + e = hipErrorInvalidValue; + } + + return ihipLogStatus(e); +} + + +hipError_t hipMemcpyFromSymbolAsync(void* dst, const char* symbolName, size_t count, size_t offset, hipMemcpyKind kind, hipStream_t stream) +{ + HIP_INIT_CMD_API(symbolName, dst, count, offset, kind, stream); + + if(symbolName == nullptr) + { + return ihipLogStatus(hipErrorInvalidSymbol); + } + + hipError_t e = hipSuccess; + + auto ctx = ihipGetTlsDefaultCtx(); + + hc::accelerator acc = ctx->getDevice()->_acc; + + void *src = acc.get_symbol_address(symbolName); + tprintf(DB_MEM, " symbol '%s' resolved to address:%p\n", symbolName, src); + + if(src == nullptr || dst == nullptr) + { + return ihipLogStatus(hipErrorInvalidSymbol); + } + if (stream) { try { stream->lockedSymbolCopyAsync(acc, dst, src, count + offset, kind); @@ -505,8 +543,6 @@ hipError_t hipMemcpyToSymbolAsync(const char* symbolName, const void *src, size_ } return ihipLogStatus(e); - - } //--- diff --git a/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp b/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp index 49a719a8d4..476c5e0997 100644 --- a/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp +++ b/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp @@ -18,7 +18,7 @@ THE SOFTWARE. */ /* HIT_START - * BUILD: %t %s + * BUILD: %t %s * RUN: %t * HIT_END */ @@ -32,44 +32,53 @@ THE SOFTWARE. #define SIZE 1024*4 #ifdef __HIP_PLATFORM_HCC__ -__attribute__((address_space(1))) int global[NUM]; +__attribute__((address_space(1))) int globalIn[NUM]; +__attribute__((address_space(1))) int globalOut[NUM]; #endif #ifdef __HIP_PLATFORM_NVCC__ -__device__ int global[NUM]; +__device__ int globalIn[NUM]; +__device__ int globalOut[NUM]; #endif __global__ void Assign(hipLaunchParm lp, int* Out) { int tid = hipThreadIdx_x + hipBlockIdx_x * hipBlockDim_x; - Out[tid] = global[tid]; + Out[tid] = globalIn[tid]; + globalOut[tid] = globalIn[tid]; } int main() { - int *A, *Am, *B, *Ad; + int *A, *Am, *B, *Ad, *C, *Cm; A = new int[NUM]; B = new int[NUM]; + C = new int[NUM]; for(unsigned i=0;i Date: Thu, 23 Feb 2017 11:18:06 +0530 Subject: [PATCH 167/281] Fix export interfaces in hip-config.cmake Change-Id: Ifad4661ab17d7e6edb6ab300f1e92552ed917950 [ROCm/hip commit: 270054859affc8c17fc2d3643bdf92d05b32d53b] --- projects/hip/CMakeLists.txt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/projects/hip/CMakeLists.txt b/projects/hip/CMakeLists.txt index 42926ad53d..9ebbd3325f 100644 --- a/projects/hip/CMakeLists.txt +++ b/projects/hip/CMakeLists.txt @@ -190,13 +190,19 @@ if(HIP_PLATFORM STREQUAL "hcc") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${HCC_LD_FLAGS} -Wl,-Bsymbolic") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --amdgpu-target=gfx701 --amdgpu-target=gfx801 --amdgpu-target=gfx802 --amdgpu-target=gfx803") add_library(hip_hcc SHARED ${SOURCE_FILES_RUNTIME}) - target_link_libraries(hip_hcc hc_am) + target_link_libraries(hip_hcc PRIVATE hc_am) add_library(hip_hcc_static STATIC ${SOURCE_FILES_RUNTIME}) - target_link_libraries(hip_hcc_static hc_am) + target_link_libraries(hip_hcc_static PRIVATE hc_am) add_dependencies(hip_hcc_static hip_hcc) add_library(hip_device STATIC ${SOURCE_FILES_DEVICE}) add_dependencies(hip_device hip_hcc) + string(REPLACE " " ";" HCC_CXX_FLAGS_LIST ${HCC_CXX_FLAGS}) + foreach(TARGET hip_hcc hip_hcc_static hip_device) + target_include_directories(${TARGET} SYSTEM INTERFACE $/include>;${HSA_PATH}/include) + endforeach() + target_link_libraries(hip_hcc INTERFACE hcc::hccrt;hcc::hc_am) + # Generate hcc_version.txt add_custom_target(query_hcc_version COMMAND ${HCC_HOME}/bin/hcc --version > ${PROJECT_BINARY_DIR}/hcc_version.tmp) add_custom_target(check_hcc_version COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PROJECT_BINARY_DIR}/hcc_version.tmp ${PROJECT_BINARY_DIR}/hcc_version.txt DEPENDS query_hcc_version) From c6969c157aca9b993a671413779e02aa35504bd0 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Thu, 23 Feb 2017 11:29:06 -0600 Subject: [PATCH 168/281] Added initial support for hipMemcpyFromSymbol. But not working! Change-Id: I48d8c7de4ec9f85c6c942be995fb488a3931f5d7 [ROCm/hip commit: 2e245ae58cd412fd72363326a789f1365fee4f39] --- .../include/hip/hcc_detail/hip_runtime_api.h | 2 ++ projects/hip/src/hip_hcc.cpp | 12 ++++--- projects/hip/src/hip_hcc.h | 2 ++ projects/hip/src/hip_memory.cpp | 36 +++++++++++++++++++ .../src/deviceLib/hipTestDeviceSymbol.cpp | 2 ++ 5 files changed, 49 insertions(+), 5 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h index 2c75b584c4..f156d3fdbd 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h @@ -1159,6 +1159,8 @@ hipError_t hipMemcpyToSymbol(const char* symbolName, const void *src, size_t siz */ hipError_t hipMemcpyToSymbolAsync(const char* symbolName, const void *src, size_t sizeBytes, size_t offset, hipMemcpyKind kind, hipStream_t stream); +hipError_t hipMemcpyFromSymbol(void *dst, const char* symbolName, size_t sizeBytes, size_t offset, hipMemcpyKind kind); + hipError_t hipMemcpyFromSymbolAsync(void *dst, const char* symbolName, size_t sizeBytes, size_t offset, hipMemcpyKind kind, hipStream_t stream); /** diff --git a/projects/hip/src/hip_hcc.cpp b/projects/hip/src/hip_hcc.cpp index a119ea1c54..efc0265ba8 100644 --- a/projects/hip/src/hip_hcc.cpp +++ b/projects/hip/src/hip_hcc.cpp @@ -1750,7 +1750,6 @@ void ihipStream_t::locked_copySync(void* dst, const void* src, size_t sizeBytes, bool dstTracked = (hc::am_memtracker_getinfo(&dstPtrInfo, dst) == AM_SUCCESS); bool srcTracked = (hc::am_memtracker_getinfo(&srcPtrInfo, src) == AM_SUCCESS); - hc::hcCommandKind hcCopyDir; ihipCtx_t *copyDevice; bool forceUnpinnedCopy; @@ -1780,6 +1779,11 @@ void ihipStream_t::locked_copySync(void* dst, const void* src, size_t sizeBytes, } } +void ihipStream_t::addSymbolPtrToTracker(hc::accelerator& acc, void* ptr, size_t sizeBytes) { + hc::AmPointerInfo ptrInfo(NULL, ptr, sizeBytes, acc, true, false); + hc::am_memtracker_add(ptr, ptrInfo); +} + void ihipStream_t::lockedSymbolCopySync(hc::accelerator &acc, void* dst, void* src, size_t sizeBytes, unsigned kind) { if(kind == hipMemcpyHostToHost){ @@ -1799,13 +1803,11 @@ void ihipStream_t::lockedSymbolCopySync(hc::accelerator &acc, void* dst, void* s void ihipStream_t::lockedSymbolCopyAsync(hc::accelerator &acc, void* dst, void* src, size_t sizeBytes, unsigned kind) { if(kind == hipMemcpyHostToDevice) { - hc::AmPointerInfo dstPtrInfo(NULL, dst, sizeBytes, acc, true, false); - hc::am_memtracker_add(dst, dstPtrInfo); + addSymbolPtrToTracker(acc, dst, sizeBytes); locked_getAv()->copy_async((void*)src, dst, sizeBytes); } if(kind == hipMemcpyDeviceToHost) { - hc::AmPointerInfo srcPtrInfo(NULL, src, sizeBytes, acc, true, false); - hc::am_memtracker_add(src, srcPtrInfo); + addSymbolPtrToTracker(acc, src, sizeBytes); locked_getAv()->copy_async((void*)src, dst, sizeBytes); } } diff --git a/projects/hip/src/hip_hcc.h b/projects/hip/src/hip_hcc.h index d7d92a221c..9ebac73cad 100644 --- a/projects/hip/src/hip_hcc.h +++ b/projects/hip/src/hip_hcc.h @@ -551,6 +551,8 @@ private: bool canSeeMemory(const ihipCtx_t *thisCtx, const hc::AmPointerInfo *dstInfo, const hc::AmPointerInfo *srcInfo); + void addSymbolPtrToTracker(hc::accelerator& acc, void* ptr, size_t sizeBytes); + public: // TODO - move private // Critical Data - MUST be accessed through LockedAccessor_StreamCrit_t ihipStreamCritical_t _criticalData; diff --git a/projects/hip/src/hip_memory.cpp b/projects/hip/src/hip_memory.cpp index cb265159ba..479040c099 100644 --- a/projects/hip/src/hip_memory.cpp +++ b/projects/hip/src/hip_memory.cpp @@ -470,6 +470,42 @@ hipError_t hipMemcpyToSymbol(const char* symbolName, const void *src, size_t cou return ihipLogStatus(hipSuccess); } + +hipError_t hipMemcpyFromSymbol(void* dst, const char* symbolName, size_t count, size_t offset, hipMemcpyKind kind) +{ + HIP_INIT_CMD_API(symbolName, dst, count, offset, kind); + + if(symbolName == nullptr) + { + return ihipLogStatus(hipErrorInvalidSymbol); + } + + auto ctx = ihipGetTlsDefaultCtx(); + + hc::accelerator acc = ctx->getDevice()->_acc; + + void *src = acc.get_symbol_address(symbolName); + tprintf(DB_MEM, " symbol '%s' resolved to address:%p\n", symbolName, dst); + + if(dst == nullptr) + { + return ihipLogStatus(hipErrorInvalidSymbol); + } + + hipStream_t stream = ihipSyncAndResolveStream(hipStreamNull); + + if(kind == hipMemcpyHostToDevice || kind == hipMemcpyDeviceToHost || kind == hipMemcpyDeviceToDevice || kind == hipMemcpyHostToHost) + { + stream->lockedSymbolCopySync(acc, dst, (void*)src, count + offset, kind); + } + else { + return ihipLogStatus(hipErrorInvalidValue); + } + + return ihipLogStatus(hipSuccess); +} + + hipError_t hipMemcpyToSymbolAsync(const char* symbolName, const void *src, size_t count, size_t offset, hipMemcpyKind kind, hipStream_t stream) { HIP_INIT_CMD_API(symbolName, src, count, offset, kind, stream); diff --git a/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp b/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp index 476c5e0997..00a1c52565 100644 --- a/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp +++ b/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp @@ -89,8 +89,10 @@ int main() hipMemcpyToSymbol(HIP_SYMBOL(globalIn), A, SIZE, 0, hipMemcpyHostToDevice); hipLaunchKernel(Assign, dim3(1,1,1), dim3(NUM,1,1), 0, 0, Ad); hipMemcpy(B, Ad, SIZE, hipMemcpyDeviceToHost); + hipMemcpyFromSymbol(C, HIP_SYMBOL(globalOut), SIZE, 0, hipMemcpyDeviceToHost); for(unsigned i=0;i Date: Mon, 27 Feb 2017 13:11:11 +0530 Subject: [PATCH 169/281] FindHIP: added new macro HIP_RESET_FLAGS Change-Id: I0af491f6689abf1c1b5691261fe1f3e61a5d916d [ROCm/hip commit: 470dd2fbcf5af4bc6c490648d7fc35ba18cc0992] --- projects/hip/cmake/FindHIP.cmake | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/projects/hip/cmake/FindHIP.cmake b/projects/hip/cmake/FindHIP.cmake index 5e17af72a5..ea19725a1e 100644 --- a/projects/hip/cmake/FindHIP.cmake +++ b/projects/hip/cmake/FindHIP.cmake @@ -178,6 +178,21 @@ hip_find_helper_file(run_make2cmake cmake) hip_find_helper_file(run_hipcc cmake) ############################################################################### +############################################################################### +# MACRO: Reset compiler flags +############################################################################### +macro(HIP_RESET_FLAGS) + unset(HIP_HIPCC_FLAGS) + unset(HIP_HCC_FLAGS) + unset(HIP_NVCC_FLAGS) + foreach(config ${_hip_configuration_types}) + string(TOUPPER ${config} config_upper) + unset(HIP_HIPCC_FLAGS_${config_upper}) + unset(HIP_HCC_FLAGS_${config_upper}) + unset(HIP_NVCC_FLAGS_${config_upper}) + endforeach() +endmacro() + ############################################################################### # MACRO: Separate the options from the sources ############################################################################### From dd6f21070ae1e6321d06e101a13d48e70f1e7c2d Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Mon, 27 Feb 2017 13:14:08 +0530 Subject: [PATCH 170/281] directed tests no longer run in an subdirectory - target "make test" will no longer build and run tests. It will only run the tests. - added new target "make check" which will build and run the tests. - target "make check" will build tests serially. Use -j to build tests in parallel. Change-Id: I24c7932bf9798364a59f44631fbabcf9a5da5e17 [ROCm/hip commit: 5f689cb986c6342dd3cd5f44df71bff42a21b49c] --- projects/hip/CMakeLists.txt | 33 ++++++++++++++++---------------- projects/hip/tests/hit/HIT.cmake | 20 ++++++++++++++----- 2 files changed, 31 insertions(+), 22 deletions(-) diff --git a/projects/hip/CMakeLists.txt b/projects/hip/CMakeLists.txt index 9ebbd3325f..ba58cfbf20 100644 --- a/projects/hip/CMakeLists.txt +++ b/projects/hip/CMakeLists.txt @@ -367,22 +367,21 @@ endif() # Testing steps ############################# # Target: test -set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/hip_tests) -configure_file(tests/hip_tests.txt ${BUILD_DIR}/CMakeLists.txt @ONLY) -if(POLICY CMP0037) - cmake_policy(PUSH) - cmake_policy(SET CMP0037 OLD) -endif() -add_custom_target(install_for_test COMMAND "${CMAKE_COMMAND}" --build . --target install - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) -execute_process(COMMAND getconf _NPROCESSORS_ONLN OUTPUT_VARIABLE DASH_JAY OUTPUT_STRIP_TRAILING_WHITESPACE) -add_custom_target(test COMMAND ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} . - COMMAND make -j ${DASH_JAY} - COMMAND make test - WORKING_DIRECTORY ${BUILD_DIR} - DEPENDS install_for_test) -if(POLICY CMP0037) - cmake_policy(POP) -endif() +set(HIP_PATH ${CMAKE_INSTALL_PREFIX}) +set(HIP_SRC_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +execute_process(COMMAND "${CMAKE_COMMAND}" -E copy_directory "${HIP_SRC_PATH}/cmake" "${HIP_PATH}/cmake") +execute_process(COMMAND "${CMAKE_COMMAND}" -E copy_directory "${HIP_SRC_PATH}/bin" "${HIP_PATH}/bin") +set(CMAKE_MODULE_PATH "${HIP_PATH}/cmake" ${CMAKE_MODULE_PATH}) +include(${HIP_SRC_PATH}/tests/hit/HIT.cmake) + +# Add tests +include_directories(${HIP_SRC_PATH}/tests/src) +hit_add_directory_recursive(${HIP_SRC_PATH}/tests/src "directed_tests") + +# Add top-level tests to build_tests +add_custom_target(build_tests DEPENDS directed_tests) + +# Add custom target: check +add_custom_target(check COMMAND "${CMAKE_COMMAND}" --build . --target test DEPENDS build_tests) # vim: ts=4:sw=4:expandtab:smartindent diff --git a/projects/hip/tests/hit/HIT.cmake b/projects/hip/tests/hit/HIT.cmake index 0c8f7d39c3..fd0001214e 100644 --- a/projects/hip/tests/hit/HIT.cmake +++ b/projects/hip/tests/hit/HIT.cmake @@ -131,7 +131,7 @@ endmacro() # Macro: HIT_ADD_FILES used to scan+add multiple files for testing. file(GLOB HIP_LIB_FILES ${HIP_PATH}/lib/*) -macro(HIT_ADD_FILES _dir _label) +macro(HIT_ADD_FILES _dir _label _parent) foreach (file ${ARGN}) # Build tests execute_process(COMMAND ${HIP_SRC_PATH}/tests/hit/parser --buildCMDs ${file} @@ -148,8 +148,10 @@ macro(HIT_ADD_FILES _dir _label) if(_exclude_platforms STREQUAL "all" OR _exclude_platforms STREQUAL ${HIP_PLATFORM}) else() set_source_files_properties(${_sources} PROPERTIES HIP_SOURCE_PROPERTY_FORMAT 1) - hip_add_executable(${target} ${_sources} HIPCC_OPTIONS ${_hipcc_options} HCC_OPTIONS ${_hcc_options} NVCC_OPTIONS ${_nvcc_options}) + hip_reset_flags() + hip_add_executable(${target} ${_sources} HIPCC_OPTIONS ${_hipcc_options} HCC_OPTIONS ${_hcc_options} NVCC_OPTIONS ${_nvcc_options} EXCLUDE_FROM_ALL) set_target_properties(${target} PROPERTIES OUTPUT_NAME ${_target} RUNTIME_OUTPUT_DIRECTORY ${_label} LINK_DEPENDS "${HIP_LIB_FILES}") + add_dependencies(${_parent} ${target}) endif() endforeach() @@ -196,24 +198,32 @@ endmacro() # Macro: HIT_ADD_DIRECTORY to scan+add all files in a directory for testing macro(HIT_ADD_DIRECTORY _dir _label) execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${_label} WORKING_DIRECTORY ${PROJECT_BINARY_DIR}) + string(REGEX REPLACE "/" "." _parent ${_label}) + add_custom_target(${_parent}) file(GLOB files "${_dir}/*.c*") - hit_add_files(${_dir} ${_label} ${files}) + hit_add_files(${_dir} ${_label} ${parent} ${files}) endmacro() # Macro: HIT_ADD_DIRECTORY_RECURSIVE to scan+add all files in a directory+subdirectories for testing macro(HIT_ADD_DIRECTORY_RECURSIVE _dir _label) execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${_label} WORKING_DIRECTORY ${PROJECT_BINARY_DIR}) + string(REGEX REPLACE "/" "." _parent ${_label}) + add_custom_target(${_parent}) + if(${ARGC} EQUAL 3) + add_dependencies(${ARGV2} ${_parent}) + endif() file(GLOB children RELATIVE ${_dir} ${_dir}/*) set(dirlist "") foreach(child ${children}) if(IS_DIRECTORY ${_dir}/${child}) list(APPEND dirlist ${child}) else() - hit_add_files(${_dir} ${_label} ${child}) + hit_add_files(${_dir} ${_label} ${_parent} ${child}) endif() endforeach() foreach(child ${dirlist}) - hit_add_directory_recursive(${_dir}/${child} ${_label}/${child}) + string(REGEX REPLACE "/" "." _parent ${_label}) + hit_add_directory_recursive(${_dir}/${child} ${_label}/${child} ${_parent}) endforeach() endmacro() From 2799863a547e35d7e2a97cc4c9589aaed82e6751 Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Mon, 27 Feb 2017 13:17:51 +0530 Subject: [PATCH 171/281] Fix compilation of some broken tests on nvcc path Change-Id: I92406af00c2de09d728e9b7f661c1f3873470560 [ROCm/hip commit: f1c3dd0dff3b6023ef438cf7c069733fbdb02b57] --- projects/hip/tests/src/runtimeApi/memory/hipMemcpy.cpp | 2 +- .../tests/src/runtimeApi/multiThread/hipMultiThreadDevice.cpp | 2 +- .../tests/src/runtimeApi/multiThread/hipMultiThreadStreams1.cpp | 2 +- .../tests/src/runtimeApi/multiThread/hipMultiThreadStreams2.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/projects/hip/tests/src/runtimeApi/memory/hipMemcpy.cpp b/projects/hip/tests/src/runtimeApi/memory/hipMemcpy.cpp index ac01fc4362..a320a86022 100644 --- a/projects/hip/tests/src/runtimeApi/memory/hipMemcpy.cpp +++ b/projects/hip/tests/src/runtimeApi/memory/hipMemcpy.cpp @@ -21,7 +21,7 @@ THE SOFTWARE. */ /* HIT_START - * BUILD: %t %s ../../test_common.cpp + * BUILD: %t %s ../../test_common.cpp NVCC_OPTIONS -std=c++11 * RUN_NAMED: %t hipMemcpy-modes --tests 0x1 * RUN_NAMED: %t hipMemcpy-size --tests 0x6 * RUN_NAMED: %t hipMemcpy-multithreaded --tests 0x8 diff --git a/projects/hip/tests/src/runtimeApi/multiThread/hipMultiThreadDevice.cpp b/projects/hip/tests/src/runtimeApi/multiThread/hipMultiThreadDevice.cpp index d5fc4cb20f..35b546e484 100644 --- a/projects/hip/tests/src/runtimeApi/multiThread/hipMultiThreadDevice.cpp +++ b/projects/hip/tests/src/runtimeApi/multiThread/hipMultiThreadDevice.cpp @@ -1,5 +1,5 @@ /* HIT_START - * BUILD: %t %s ../../test_common.cpp + * BUILD: %t %s ../../test_common.cpp NVCC_OPTIONS -std=c++11 * RUN_NAMED: %t hipMultiThreadDevice-serial --tests 0x1 * RUN_NAMED: %t hipMultiThreadDevice-pyramid --tests 0x4 * RUN_NAMED: %t hipMultiThreadDevice-nearzero --tests 0x10 diff --git a/projects/hip/tests/src/runtimeApi/multiThread/hipMultiThreadStreams1.cpp b/projects/hip/tests/src/runtimeApi/multiThread/hipMultiThreadStreams1.cpp index 3ea3489e20..229ceea440 100644 --- a/projects/hip/tests/src/runtimeApi/multiThread/hipMultiThreadStreams1.cpp +++ b/projects/hip/tests/src/runtimeApi/multiThread/hipMultiThreadStreams1.cpp @@ -21,7 +21,7 @@ THE SOFTWARE. */ /* HIT_START - * BUILD: %t %s ../../test_common.cpp + * BUILD: %t %s ../../test_common.cpp NVCC_OPTIONS -std=c++11 * RUN: %t * HIT_END */ diff --git a/projects/hip/tests/src/runtimeApi/multiThread/hipMultiThreadStreams2.cpp b/projects/hip/tests/src/runtimeApi/multiThread/hipMultiThreadStreams2.cpp index 6f431d0bb4..43a3e9bdea 100644 --- a/projects/hip/tests/src/runtimeApi/multiThread/hipMultiThreadStreams2.cpp +++ b/projects/hip/tests/src/runtimeApi/multiThread/hipMultiThreadStreams2.cpp @@ -21,7 +21,7 @@ THE SOFTWARE. */ /* HIT_START - * BUILD: %t %s ../../test_common.cpp + * BUILD: %t %s ../../test_common.cpp NVCC_OPTIONS -std=c++11 * RUN: %t * HIT_END */ From 3a726819e8eb1b88e199b9903f526793682a7efe Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Mon, 27 Feb 2017 13:19:06 +0530 Subject: [PATCH 172/281] Disable some tests which are broken on nvcc path Change-Id: I6f8df7687ff1798dc17f6c9b8a7f4cd029ce45d8 [ROCm/hip commit: a0b51c69a7a2d11e016dc53be72adfef6dc2f2e8] --- projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp | 2 +- projects/hip/tests/src/deviceLib/hipVectorTypes.cpp | 2 +- projects/hip/tests/src/deviceLib/hipVectorTypesDevice.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp b/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp index 00a1c52565..e58aa58877 100644 --- a/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp +++ b/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp @@ -18,7 +18,7 @@ THE SOFTWARE. */ /* HIT_START - * BUILD: %t %s + * BUILD: %t %s EXCLUDE_HIP_PLATFORM nvcc * RUN: %t * HIT_END */ diff --git a/projects/hip/tests/src/deviceLib/hipVectorTypes.cpp b/projects/hip/tests/src/deviceLib/hipVectorTypes.cpp index 12a8cc76a3..9dd0793c98 100644 --- a/projects/hip/tests/src/deviceLib/hipVectorTypes.cpp +++ b/projects/hip/tests/src/deviceLib/hipVectorTypes.cpp @@ -21,7 +21,7 @@ THE SOFTWARE. */ /* HIT_START - * BUILD: %t %s ../test_common.cpp + * BUILD: %t %s ../test_common.cpp EXCLUDE_HIP_PLATFORM nvcc * RUN: %t * HIT_END */ diff --git a/projects/hip/tests/src/deviceLib/hipVectorTypesDevice.cpp b/projects/hip/tests/src/deviceLib/hipVectorTypesDevice.cpp index 87351a1e83..285b3e889e 100644 --- a/projects/hip/tests/src/deviceLib/hipVectorTypesDevice.cpp +++ b/projects/hip/tests/src/deviceLib/hipVectorTypesDevice.cpp @@ -21,7 +21,7 @@ THE SOFTWARE. */ /* HIT_START - * BUILD: %t %s ../test_common.cpp + * BUILD: %t %s ../test_common.cpp EXCLUDE_HIP_PLATFORM nvcc * RUN: %t * HIT_END */ From 605343ecd4d146fecd63c23ad2b6ffda538f677a Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Mon, 27 Feb 2017 13:20:05 +0530 Subject: [PATCH 173/281] Fix nvcc path samples that include math_functions.h Change-Id: I94bb577b93983535178d8f0dcae57aaa72871534 [ROCm/hip commit: 4a6166cd86be96ad2eb00fb7a5da39e0352c8dfb] --- projects/hip/include/hip/math_functions.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/hip/include/hip/math_functions.h b/projects/hip/include/hip/math_functions.h index 6afe463a5d..ebcdc26749 100644 --- a/projects/hip/include/hip/math_functions.h +++ b/projects/hip/include/hip/math_functions.h @@ -30,7 +30,7 @@ THE SOFTWARE. #if defined(__HIP_PLATFORM_HCC__) && !defined (__HIP_PLATFORM_NVCC__) #include #elif defined(__HIP_PLATFORM_NVCC__) && !defined (__HIP_PLATFORM_HCC__) -#include +//#include #else #error("Must define exactly one of __HIP_PLATFORM_HCC__ or __HIP_PLATFORM_NVCC__"); #endif From 4dc60f999016e70fd47e538b44c4063d41e3f2f9 Mon Sep 17 00:00:00 2001 From: Rahul Garg Date: Mon, 27 Feb 2017 15:17:11 +0530 Subject: [PATCH 174/281] Context management related changes in HIP. - -Contexts across threads are listed under device -Device reset cleans up all contexts and re-initializes _primaryCtx Change-Id: Ie1cfbb26d43a8dc6869be3e6ebaf7344ce374643 [ROCm/hip commit: bddd6b73c07a92de79ef15ebcbfefd2660d82f59] --- projects/hip/src/hip_context.cpp | 17 +++++++-- projects/hip/src/hip_device.cpp | 7 +++- projects/hip/src/hip_hcc.cpp | 65 ++++++++++++++++++++++++++++++-- projects/hip/src/hip_hcc.h | 48 ++++++++++++++++++++++- 4 files changed, 128 insertions(+), 9 deletions(-) diff --git a/projects/hip/src/hip_context.cpp b/projects/hip/src/hip_context.cpp index 6c862b114b..835cf6e795 100644 --- a/projects/hip/src/hip_context.cpp +++ b/projects/hip/src/hip_context.cpp @@ -58,9 +58,15 @@ hipError_t hipCtxCreate(hipCtx_t *ctx, unsigned int flags, hipDevice_t device) HIP_INIT_API(ctx, flags, device); // FIXME - review if we want to init hipError_t e = hipSuccess; auto deviceHandle = ihipGetDevice(device); - *ctx = new ihipCtx_t(deviceHandle, g_deviceCnt, flags); - ihipSetTlsDefaultCtx(*ctx); - tls_ctxStack.push(*ctx); + { + // Obtain mutex access to the device critical data, release by destructor + LockedAccessor_DeviceCrit_t deviceCrit(deviceHandle->criticalData()); + auto ictx = new ihipCtx_t(deviceHandle, g_deviceCnt, flags); + *ctx = ictx; + ihipSetTlsDefaultCtx(*ctx); + tls_ctxStack.push(*ctx); + deviceCrit->addContext(ictx); + } return ihipLogStatus(e); } @@ -125,6 +131,11 @@ hipError_t hipCtxDestroy(hipCtx_t ctx) //need to destroy the ctx associated with calling thread tls_ctxStack.pop(); } + { + auto deviceHandle = ctx->getWriteableDevice(); + deviceHandle->locked_removeContext(ctx); + ctx->locked_reset(); + } delete ctx; //As per CUDA docs , attempting to access ctx from those threads which has this ctx as current, will result in the error HIP_ERROR_CONTEXT_IS_DESTROYED. } diff --git a/projects/hip/src/hip_device.cpp b/projects/hip/src/hip_device.cpp index 3cefca82e7..d3c68e6fdf 100644 --- a/projects/hip/src/hip_device.cpp +++ b/projects/hip/src/hip_device.cpp @@ -166,11 +166,16 @@ hipError_t hipDeviceReset(void) // This function currently does a user-level cleanup of known resources. // It could benefit from KFD support to perform a more "nuclear" clean that would include any associated kernel resources and page table entries. - +#if 0 if (ctx) { // Release ctx resources (streams and memory): ctx->locked_reset(); } +#endif + if (ctx) { + ihipDevice_t *deviceHandle = ctx->getWriteableDevice(); + deviceHandle->locked_reset(); + } return ihipLogStatus(hipSuccess); } diff --git a/projects/hip/src/hip_hcc.cpp b/projects/hip/src/hip_hcc.cpp index efc0265ba8..a294cc0097 100644 --- a/projects/hip/src/hip_hcc.cpp +++ b/projects/hip/src/hip_hcc.cpp @@ -522,6 +522,14 @@ void ihipCtxCriticalBase_t::addStream(ihipStream_t *stream) _streams.push_back(stream); tprintf(DB_SYNC, " addStream: %s\n", ToString(stream).c_str()); } + +template<> +void ihipDeviceCriticalBase_t::addContext(ihipCtx_t *ctx) +{ + _ctxs.push_back(ctx); + tprintf(DB_SYNC, " addContext: %s\n", ToString(ctx).c_str()); +} + //============================================================================= //================================================================================================= @@ -530,7 +538,8 @@ void ihipCtxCriticalBase_t::addStream(ihipStream_t *stream) ihipDevice_t::ihipDevice_t(unsigned deviceId, unsigned deviceCnt, hc::accelerator &acc) : _deviceId(deviceId), _acc(acc), - _state(0) + _state(0), + _criticalData(this) { hsa_agent_t *agent = static_cast (acc.get_hsa_agent()); if (agent) { @@ -557,7 +566,49 @@ ihipDevice_t::~ihipDevice_t() _primaryCtx = NULL; } +void ihipDevice_t::locked_removeContext(ihipCtx_t *c) +{ + LockedAccessor_DeviceCrit_t crit(_criticalData); + crit->ctxs().remove(c); + tprintf(DB_SYNC, " locked_removeContext: %s\n", ToString(c).c_str()); +} + + +void ihipDevice_t::locked_reset() +{ + // Obtain mutex access to the device critical data, release by destructor + LockedAccessor_DeviceCrit_t crit(_criticalData); + + + //--- + //Wait for pending activity to complete? TODO - check if this is required behavior: + tprintf(DB_SYNC, "locked_reset waiting for activity to complete.\n"); + + // Reset and remove streams: + // Delete all created streams including the default one. + for (auto ctxI=crit->const_ctxs().begin(); ctxI!=crit->const_ctxs().end(); ctxI++) { + ihipCtx_t *ctx = *ctxI; + (*ctxI)->locked_reset(); + tprintf(DB_SYNC, " ctx cleanup %s\n", ToString(ctx).c_str()); + + delete ctx; + } + // Clear the list. + crit->ctxs().clear(); + + + //reset _primaryCtx + _primaryCtx->locked_reset(); + tprintf(DB_SYNC, " _primaryCtx cleanup %s\n", ToString(_primaryCtx).c_str()); + // Reset and release all memory stored in the tracker: + // Reset will remove peer mapping so don't need to do this explicitly. + // FIXME - This is clearly a non-const action! Is this a context reset or a device reset - maybe should reference count? + + _state = 0; + am_memtracker_reset(_acc); + +}; #define ErrorCheck(x) error_check(x, __LINE__, __FILE__) @@ -861,8 +912,14 @@ ihipCtx_t::ihipCtx_t(ihipDevice_t *device, unsigned deviceCnt, unsigned flags) : _device(device), _criticalData(this, deviceCnt) { - locked_reset(); + //locked_reset(); + LockedAccessor_CtxCrit_t crit(_criticalData); + _defaultStream = new ihipStream_t(this, getDevice()->_acc.get_default_view(), hipStreamDefault); + crit->addStream(_defaultStream); + + // Reset peer list to just me: + crit->resetPeerWatchers(this); tprintf(DB_SYNC, "created ctx with defaultStream=%p (%s)\n", _defaultStream, ToString(_defaultStream).c_str()); }; @@ -905,7 +962,7 @@ void ihipCtx_t::locked_reset() _defaultStream = new ihipStream_t(this, getDevice()->_acc.get_default_view(), hipStreamDefault); crit->addStream(_defaultStream); - +#if 0 // Reset peer list to just me: crit->resetPeerWatchers(this); @@ -915,7 +972,7 @@ void ihipCtx_t::locked_reset() ihipDevice_t *device = getWriteableDevice(); device->_state = 0; am_memtracker_reset(device->_acc); - +#endif }; diff --git a/projects/hip/src/hip_hcc.h b/projects/hip/src/hip_hcc.h index 9ebac73cad..105eef6bb8 100644 --- a/projects/hip/src/hip_hcc.h +++ b/projects/hip/src/hip_hcc.h @@ -143,6 +143,8 @@ extern const char *API_COLOR_END; #define CTX_THREAD_SAFE 1 +#define DEVICE_THREAD_SAFE 1 + // Compile debug trace mode - this prints debug messages to stderr when env var HIP_DB is set. // May be set to 0 to remove debug if checks - possible code size and performance difference? @@ -371,6 +373,13 @@ typedef FakeMutex StreamMutex; typedef std::mutex CtxMutex; #else typedef FakeMutex CtxMutex; +#warning "Ctx thread-safe disabled" +#endif + +#if DEVICE_THREAD_SAFE +typedef std::mutex DeviceMutex; +#else +typedef FakeMutex DeviceMutex; #warning "Device thread-safe disabled" #endif @@ -595,7 +604,40 @@ struct ihipEvent_t { +//============================================================================= +//class ihipDeviceCriticalBase_t +template +class ihipDeviceCriticalBase_t : LockedBase +{ +public: + ihipDeviceCriticalBase_t(ihipDevice_t *parentDevice) : + _parent(parentDevice) + { + }; + ~ihipDeviceCriticalBase_t() { + + } + + // Contexts: + void addContext(ihipCtx_t *ctx); + void removeContext(ihipCtx_t *ctx); + std::list &ctxs() { return _ctxs; }; + const std::list &const_ctxs() const { return _ctxs; }; + int getcount() {return _ctxCount;}; + friend class LockedAccessor; +private: + ihipDevice_t *_parent; + + //--- Context Tracker: + std::list< ihipCtx_t* > _ctxs; // contexts associated with this device across all threads. + + int _ctxCount; +}; + +typedef ihipDeviceCriticalBase_t ihipDeviceCritical_t; + +typedef LockedAccessor LockedAccessor_DeviceCrit_t; //---- // Properties of the HIP device. @@ -608,7 +650,9 @@ public: // Accessors: ihipCtx_t *getPrimaryCtx() const { return _primaryCtx; }; - + void locked_removeContext(ihipCtx_t *c); + void locked_reset(); + ihipDeviceCritical_t &criticalData() { return _criticalData; }; public: unsigned _deviceId; // device ID @@ -628,6 +672,8 @@ public: private: hipError_t initProperties(hipDeviceProp_t* prop); +private: + ihipDeviceCritical_t _criticalData; }; //============================================================================= From d86f186d66d58fcb36de9d6fa7782617129c2388 Mon Sep 17 00:00:00 2001 From: pensun Date: Mon, 27 Feb 2017 12:55:16 -0600 Subject: [PATCH 175/281] remove extra spaces for hip_common.h platform defines Change-Id: Ie0e39256abba307429985371671cde01f5ea2cc9 [ROCm/hip commit: df9cbb6067ec5ab7dd40e05048dcdb4fc2c435c1] --- projects/hip/include/hip/hip_common.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/projects/hip/include/hip/hip_common.h b/projects/hip/include/hip/hip_common.h index f0e58f1f76..ffedac5fa3 100644 --- a/projects/hip/include/hip/hip_common.h +++ b/projects/hip/include/hip/hip_common.h @@ -39,21 +39,18 @@ THE SOFTWARE. // Auto enable __HIP_PLATFORM_NVCC__ if compiling with NVCC #if defined(__NVCC__) #define __HIP_PLATFORM_NVCC__ -# ifdef __CUDACC__ -# define __HIPCC__ -# endif +#ifdef __CUDACC__ +#define __HIPCC__ +#endif #if defined(__CUDA_ARCH__) && (__CUDA_ARCH__ != 0) #define __HIP_DEVICE_COMPILE__ 1 #else #define __HIP_DEVICE_COMPILE__ 0 #endif - #endif - - #if __HIP_DEVICE_COMPILE__ == 0 // 32-bit Atomics #define __HIP_ARCH_HAS_GLOBAL_INT32_ATOMICS__ (0) From cee901e66fe0b49ffc77ac0c1cd52a4bec67d2e1 Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Tue, 28 Feb 2017 12:02:53 +0530 Subject: [PATCH 176/281] packaging script changes for hip_hcc Change-Id: I06cce6048204315a891e3a12638a3067644cfb43 [ROCm/hip commit: 0672b192644b4b97ff811591713d3181e171cfed] --- projects/hip/packaging/hip_hcc.txt | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/projects/hip/packaging/hip_hcc.txt b/projects/hip/packaging/hip_hcc.txt index 64c0d54caf..7dd65033fd 100644 --- a/projects/hip/packaging/hip_hcc.txt +++ b/projects/hip/packaging/hip_hcc.txt @@ -12,14 +12,11 @@ install(FILES @hip_SOURCE_DIR@/src/hip_hc.ll @hip_SOURCE_DIR@/src/hip_hc_gfx803. ############################# set(CPACK_SET_DESTDIR TRUE) set(CPACK_INSTALL_PREFIX "/opt/rocm/hip") +set(CPACK_PACKAGE_NAME "hip_hcc") if(@HCC_VERSION_MAJOR@ EQUAL 0) - set(CPACK_PACKAGE_NAME "hip_hcc") set(HCC_PACKAGE_NAME "hcc_lc") - set(HIP_PACKAGE_CONFLICTS "hip_hcc_exp") else() - set(CPACK_PACKAGE_NAME "hip_hcc_exp") set(HCC_PACKAGE_NAME "hcc") - set(HIP_PACKAGE_CONFLICTS "hip_hcc") endif() set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "HIP: Heterogenous-computing Interface for Portability [HCC]") set(CPACK_PACKAGE_VENDOR "Advanced Micro Devices, Inc.") @@ -37,14 +34,11 @@ if(@COMPILE_HIP_ATP_MARKER@) else() set(CPACK_DEBIAN_PACKAGE_DEPENDS "hip_base (= ${CPACK_PACKAGE_VERSION}), ${HCC_PACKAGE_NAME} (= @HCC_PACKAGE_VERSION@)") endif() -set(CPACK_DEBIAN_PACKAGE_CONFLICTS ${HIP_PACKAGE_CONFLICTS}) -set(CPACK_DEBIAN_PACKAGE_REPLACES ${HIP_PACKAGE_CONFLICTS}) set(CPACK_BINARY_RPM "ON") set(CPACK_RPM_PACKAGE_ARCHITECTURE "x86_64") set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${PROJECT_BINARY_DIR}/postinst") set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${PROJECT_BINARY_DIR}/prerm") set(CPACK_RPM_PACKAGE_AUTOREQPROV " no") -set(CPACK_RPM_PACKAGE_REQUIRES_PREUN ${HIP_PACKAGE_CONFLICTS}) if(@COMPILE_HIP_ATP_MARKER@) set(CPACK_RPM_PACKAGE_REQUIRES "hip_base = ${CPACK_PACKAGE_VERSION}, ${HCC_PACKAGE_NAME} = @HCC_PACKAGE_VERSION@, rocm-profiler") else() From 1cdf972180f09479df70cee2bd59d88de80f60df Mon Sep 17 00:00:00 2001 From: pensun Date: Tue, 28 Feb 2017 07:33:01 -0600 Subject: [PATCH 177/281] update hip_porting_guide regarding platform depended macros Change-Id: I3029c6ae6cb280500bba294925ed6e9dc9dcc94d [ROCm/hip commit: ac4b7e3f91241f2ca9268771e0c3bb67f7049628] --- projects/hip/docs/markdown/hip_porting_guide.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/hip/docs/markdown/hip_porting_guide.md b/projects/hip/docs/markdown/hip_porting_guide.md index e34bed0cbc..0acdc246f9 100644 --- a/projects/hip/docs/markdown/hip_porting_guide.md +++ b/projects/hip/docs/markdown/hip_porting_guide.md @@ -166,7 +166,7 @@ Both nvcc and hcc make two passes over the code: one for host code and one for d ``` // #ifdef __CUDA_ARCH__ -#ifdef __HIP_DEVICE_COMPILE__ +#ifdef __HIP_DEVICE_COMPILE__ && (__HIP_DEVICE_COMPILE__ == 1) ``` Unlike `__CUDA_ARCH__`, the `__HIP_DEVICE_COMPILE__` value is 0 or 1, and it doesn’t represent the feature capability of the target device. @@ -182,7 +182,7 @@ Unlike `__CUDA_ARCH__`, the `__HIP_DEVICE_COMPILE__` value is 0 or 1, and it doe |`__HIPCC__` | Defined | Defined | Undefined |`__HIP_ARCH_*` | 0 or 1 depending on feature support (see below) | 0 or 1 depending on feature support (see below) | 0 |nvcc-related defines:| -|`__CUDACC__` | Undefined | Defined if compiling for Cuda device; undefined otherwise | Undefined +|`__CUDACC__` | Undefined | Defined if source code is compiled by nvcc; undefined otherwise | Undefined |`__NVCC__` | Undefined | Defined | Undefined |`__CUDA_ARCH__` | Undefined | Unsigned representing compute capability (e.g., "130") if in device code; 0 if in host code | Undefined |hcc-related defines:| From c019df92e394ed314d3e35be15550ef98fe618fe Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Tue, 28 Feb 2017 18:40:13 +0300 Subject: [PATCH 178/281] [HIP] Add missing Device attribute on nvcc path. + missing cudaDevAttrComputeCapabilityMinor case as added for hipDeviceGetAttribute query for hipDeviceAttributeComputeCapabilityMinor. [ROCm/hip commit: f9ad2dca7e15f6c5a715586b7aa9cb8a270fdc1c] --- projects/hip/include/hip/nvcc_detail/hip_runtime_api.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h b/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h index f5e7960d45..d2875303da 100644 --- a/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h @@ -502,6 +502,8 @@ inline static hipError_t hipDeviceGetAttribute(int* pi, hipDeviceAttribute_t att cdattr = cudaDevAttrMaxThreadsPerMultiProcessor; break; case hipDeviceAttributeComputeCapabilityMajor: cdattr = cudaDevAttrComputeCapabilityMajor; break; + case hipDeviceAttributeComputeCapabilityMinor: + cdattr = cudaDevAttrComputeCapabilityMinor; break; case hipDeviceAttributeConcurrentKernels: cdattr = cudaDevAttrConcurrentKernels; break; case hipDeviceAttributePciBusId: From 0157d13a567b5b1c9502782c8dd7730411a98611 Mon Sep 17 00:00:00 2001 From: pensun Date: Tue, 28 Feb 2017 16:20:48 -0600 Subject: [PATCH 179/281] Define __HIPCC__ flag at compile time when using HIPCC on HCC path Change-Id: I5e967e0e2327264d5d3b0ca705c2504fcd33d75e [ROCm/hip commit: fd610e497bf951506b4f6d5b18c187a22f549cce] --- projects/hip/bin/hipcc | 2 +- projects/hip/include/hip/hip_common.h | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/projects/hip/bin/hipcc b/projects/hip/bin/hipcc index 0dccb9bbc1..00018e5f04 100755 --- a/projects/hip/bin/hipcc +++ b/projects/hip/bin/hipcc @@ -92,7 +92,7 @@ if ($HIP_PLATFORM eq "hcc") { # HCC* may be used to compile src/hip_hcc.o (and also feed the HIPCXXFLAGS below) $HCC = "$HCC_HOME/bin/hcc"; - $HCCFLAGS = "-hc -I$HCC_HOME/include "; + $HCCFLAGS = "-hc -D__HIPCC__ -I$HCC_HOME/include "; $HIPCC=$HCC; $HIPCXXFLAGS = $HCCFLAGS; diff --git a/projects/hip/include/hip/hip_common.h b/projects/hip/include/hip/hip_common.h index ffedac5fa3..6223a2fe9e 100644 --- a/projects/hip/include/hip/hip_common.h +++ b/projects/hip/include/hip/hip_common.h @@ -27,14 +27,14 @@ THE SOFTWARE. // Other compiler (GCC,ICC,etc) need to set one of these macros explicitly #if defined(__HCC__) #define __HIP_PLATFORM_HCC__ -#define __HIPCC__ #if defined(__HCC_ACCELERATOR__) && (__HCC_ACCELERATOR__ != 0) #define __HIP_DEVICE_COMPILE__ 1 #else #define __HIP_DEVICE_COMPILE__ 0 #endif -#endif + +#endif //__HCC__ // Auto enable __HIP_PLATFORM_NVCC__ if compiling with NVCC #if defined(__NVCC__) @@ -48,7 +48,8 @@ THE SOFTWARE. #else #define __HIP_DEVICE_COMPILE__ 0 #endif -#endif + +#endif //__NVCC__ #if __HIP_DEVICE_COMPILE__ == 0 From 921825f7b5a42c9e37d5d51237e293d7b1f436ae Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Tue, 28 Feb 2017 17:13:29 -0600 Subject: [PATCH 180/281] changed __half enabling from 4 to >3 Change-Id: Id974c6d5326e87a4c5941f831c5bb2747cdebd2d [ROCm/hip commit: e7ccc995ee5d1bd9c8e1d2abe98248cb36b34ee3] --- projects/hip/include/hip/hcc_detail/hip_fp16.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/hip/include/hip/hcc_detail/hip_fp16.h b/projects/hip/include/hip/hcc_detail/hip_fp16.h index b28f92d451..b0276d51b3 100644 --- a/projects/hip/include/hip/hcc_detail/hip_fp16.h +++ b/projects/hip/include/hip/hcc_detail/hip_fp16.h @@ -25,7 +25,7 @@ THE SOFTWARE. #include "hip/hip_runtime.h" -#if __clang_major__ == 4 +#if __clang_major__ > 3 typedef __fp16 __half; From b8fbb0ea236db92edf21e52a24d524e45f2bf040 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Wed, 1 Mar 2017 23:04:34 +0300 Subject: [PATCH 181/281] [HIP] [FIX] Memcpy Async functions on nvcc path. + in hipMemcpyDtoDAsync: cuMemcpyDtoD -> cuMemcpyDtoDAsync + in hipMemcpyDtoHAsync: cuMemcpyDtoH -> cuMemcpyDtoHAsync P.S. "The types CUstream and cudaStream_t are identical and may be used interchangeably", thus explicit c-like type cast is not needed, aka CUstream(stream). [ROCm/hip commit: 6421a1e79eab4629959bcb5bf0f7fb2294968047] --- projects/hip/include/hip/nvcc_detail/hip_runtime_api.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h b/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h index d2875303da..dc51290167 100644 --- a/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h @@ -306,13 +306,13 @@ inline static hipError_t hipMemcpyHtoDAsync(hipDeviceptr_t dst, inline static hipError_t hipMemcpyDtoHAsync(void* dst, hipDeviceptr_t src, size_t size, hipStream_t stream) { - return hipCUResultTohipError(cuMemcpyDtoH(dst, src, size)); + return hipCUResultTohipError(cuMemcpyDtoHAsync(dst, src, size, stream)); } inline static hipError_t hipMemcpyDtoDAsync(hipDeviceptr_t dst, hipDeviceptr_t src, size_t size, hipStream_t stream) { - return hipCUResultTohipError(cuMemcpyDtoD(dst, src, size)); + return hipCUResultTohipError(cuMemcpyDtoDAsync(dst, src, size, stream)); } inline static hipError_t hipMemcpy(void* dst, const void* src, size_t sizeBytes, hipMemcpyKind copyKind) { From 5c0ec42554d7af9e8c235cb1fa6de2f3a0875345 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Fri, 3 Mar 2017 21:59:05 +0300 Subject: [PATCH 182/281] [HIPIFY] Sync HIPIFY with HIP by enum values. + all Cuda 7.5 RT API enum values are synced. + a few missing functions are added. + CONV_EXEC type is added for Execution control functions and data types. [ROCm/hip commit: 749803c84972c4cc138fd2c3c8f201921eaf745e] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 403 ++++++++++++++------- 1 file changed, 281 insertions(+), 122 deletions(-) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index fd4c35d34b..8caac787e8 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -74,6 +74,7 @@ enum ConvTypes { CONV_CONTEXT, CONV_MODULE, CONV_CACHE, + CONV_EXEC, CONV_ERR, CONV_DEF, CONV_TEX, @@ -90,11 +91,11 @@ enum ConvTypes { }; const char *counterNames[CONV_LAST] = { - "driver", "dev", "mem", "kern", "coord_func", "math_func", - "special_func", "stream", "event", "occupancy", "ctx", "module", - "cache", "err", "def", "tex", "gl", "graphics", - "surface", "other", "include", "include_cuda_main_header", "type", - "literal", "numeric_literal"}; + "driver", "dev", "mem", "kern", "coord_func", "math_func", + "special_func", "stream", "event", "occupancy", "ctx", "module", + "cache", "exec", "err", "def", "tex", "gl", + "graphics", "surface", "other", "include", "include_cuda_main_header", + "type", "literal", "numeric_literal"}; enum ApiTypes { API_DRIVER = 0, @@ -209,111 +210,162 @@ struct cuda2hipMap { cuda2hipRename["CUDA_ERROR_NOT_FOUND"] = {"hipErrorNotFound", CONV_ERR, API_DRIVER}; // CUDA RT API error code only - cuda2hipRename["cudaErrorInvalidDeviceFunction"] = {"hipErrorInvalidDeviceFunction", CONV_ERR, API_RUNTIME}; - cuda2hipRename["cudaErrorInvalidConfiguration"] = {"hipErrorInvalidConfiguration", CONV_ERR, API_RUNTIME}; - cuda2hipRename["cudaErrorPriorLaunchFailure"] = {"hipErrorPriorLaunchFailure", CONV_ERR, API_RUNTIME}; - cuda2hipRename["cudaErrorInvalidMemcpyDirection"] = {"hipErrorInvalidMemcpyDirection", CONV_ERR, API_RUNTIME}; - cuda2hipRename["cudaErrorInvalidDevicePointer"] = {"hipErrorInvalidDevicePointer", CONV_ERR, API_RUNTIME}; - cuda2hipRename["cudaErrorMissingConfiguration"] = {"hipErrorMissingConfiguration", CONV_ERR, API_RUNTIME}; + cuda2hipRename["cudaErrorMissingConfiguration"] = {"hipErrorMissingConfiguration", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 1 + cuda2hipRename["cudaErrorPriorLaunchFailure"] = {"hipErrorPriorLaunchFailure", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 5 + cuda2hipRename["cudaErrorInvalidDeviceFunction"] = {"hipErrorInvalidDeviceFunction", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 8 + cuda2hipRename["cudaErrorInvalidConfiguration"] = {"hipErrorInvalidConfiguration", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 9 + cuda2hipRename["cudaErrorInvalidPitchValue"] = {"hipErrorInvalidPitchValue", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 12 + cuda2hipRename["cudaErrorInvalidSymbol"] = {"hipErrorInvalidSymbol", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 13 + cuda2hipRename["cudaErrorMapBufferObjectFailed"] = {"hipErrorMapBufferObjectFailed", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 14 + cuda2hipRename["cudaErrorUnmapBufferObjectFailed"] = {"hipErrorUnmapBufferObjectFailed", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 15 + cuda2hipRename["cudaErrorInvalidHostPointer"] = {"hipErrorInvalidHostPointer", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 16 + cuda2hipRename["cudaErrorInvalidDevicePointer"] = {"hipErrorInvalidDevicePointer", CONV_ERR, API_RUNTIME}; // 17 + cuda2hipRename["cudaErrorInvalidTexture"] = {"hipErrorInvalidTexture", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 18 + cuda2hipRename["cudaErrorInvalidTextureBinding"] = {"hipErrorInvalidTextureBinding", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 19 + cuda2hipRename["cudaErrorInvalidChannelDescriptor"] = {"hipErrorInvalidChannelDescriptor", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 20 + cuda2hipRename["cudaErrorInvalidMemcpyDirection"] = {"hipErrorInvalidMemcpyDirection", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 21 + cuda2hipRename["cudaErrorAddressOfConstant"] = {"hipErrorAddressOfConstant", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 22 + cuda2hipRename["cudaErrorTextureFetchFailed"] = {"hipErrorTextureFetchFailed", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 23 + cuda2hipRename["cudaErrorTextureNotBound"] = {"hipErrorTextureNotBound", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 24 + cuda2hipRename["cudaErrorSynchronizationError"] = {"hipErrorSynchronizationError", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 25 + cuda2hipRename["cudaErrorInvalidFilterSetting"] = {"hipErrorInvalidFilterSetting", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 26 + cuda2hipRename["cudaErrorInvalidNormSetting"] = {"hipErrorInvalidNormSetting", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 27 + cuda2hipRename["cudaErrorMixedDeviceExecution"] = {"hipErrorMixedDeviceExecution", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 28 + // Deprecated as of CUDA 4.1 + cuda2hipRename["cudaErrorNotYetImplemented"] = {"hipErrorNotYetImplemented", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 31 + // Deprecated as of CUDA 3.1 + cuda2hipRename["cudaErrorMemoryValueTooLarge"] = {"hipErrorMemoryValueTooLarge", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 32 + cuda2hipRename["cudaErrorInsufficientDriver"] = {"hipErrorInsufficientDriver", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 35 + cuda2hipRename["cudaErrorSetOnActiveProcess"] = {"hipErrorSetOnActiveProcess", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 36 + cuda2hipRename["cudaErrorInvalidSurface"] = {"hipErrorInvalidSurface", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 37 + cuda2hipRename["cudaErrorDuplicateVariableName"] = {"hipErrorDuplicateVariableName", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 43 + cuda2hipRename["cudaErrorDuplicateTextureName"] = {"hipErrorDuplicateTextureName", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 44 + cuda2hipRename["cudaErrorDuplicateSurfaceName"] = {"hipErrorDuplicateSurfaceName", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 45 + cuda2hipRename["cudaErrorDevicesUnavailable"] = {"hipErrorDevicesUnavailable", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 46 + cuda2hipRename["cudaErrorIncompatibleDriverContext"] = {"hipErrorIncompatibleDriverContext", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 49 + cuda2hipRename["cudaErrorDeviceAlreadyInUse"] = {"hipErrorDeviceAlreadyInUse", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 54 + cuda2hipRename["cudaErrorAssert"] = {"hipErrorAssert", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 59 + cuda2hipRename["cudaErrorTooManyPeers"] = {"hipErrorTooManyPeers", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 60 + cuda2hipRename["cudaErrorLaunchMaxDepthExceeded"] = {"hipErrorLaunchMaxDepthExceeded", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 65 + cuda2hipRename["cudaErrorLaunchFileScopedTex"] = {"hipErrorLaunchFileScopedTex", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 66 + cuda2hipRename["cudaErrorLaunchFileScopedSurf"] = {"hipErrorLaunchFileScopedSurf", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 67 + cuda2hipRename["cudaErrorSyncDepthExceeded"] = {"hipErrorSyncDepthExceeded", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 68 + cuda2hipRename["cudaErrorLaunchPendingCountExceeded"] = {"hipErrorLaunchPendingCountExceeded", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 69 + cuda2hipRename["cudaErrorNotPermitted"] = {"hipErrorNotPermitted", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 70 + cuda2hipRename["cudaErrorNotSupported"] = {"hipErrorNotSupported", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 71 + cuda2hipRename["cudaErrorHardwareStackError"] = {"hipErrorHardwareStackError", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 72 + cuda2hipRename["cudaErrorIllegalInstruction"] = {"hipErrorIllegalInstruction", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 73 + cuda2hipRename["cudaErrorMisalignedAddress"] = {"hipErrorMisalignedAddress", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 74 + cuda2hipRename["cudaErrorInvalidAddressSpace"] = {"hipErrorInvalidAddressSpace", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 75 + cuda2hipRename["cudaErrorInvalidPc"] = {"hipErrorInvalidPc", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 76 + cuda2hipRename["cudaErrorStartupFailure"] = {"hipErrorStartupFailure", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 0x7f + // Deprecated as of CUDA 4.1 + cuda2hipRename["cudaErrorApiFailureBase"] = {"hipErrorApiFailureBase", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 10000 cuda2hipRename["CUDA_SUCCESS"] = {"hipSuccess", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaSuccess"] = {"hipSuccess", CONV_ERR, API_RUNTIME}; - - cuda2hipRename["CUDA_ERROR_UNKNOWN"] = {"hipErrorUnknown", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorUnknown"] = {"hipErrorUnknown", CONV_ERR, API_RUNTIME}; - - cuda2hipRename["CUDA_ERROR_NOT_INITIALIZED"] = {"hipErrorNotInitialized", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorInitializationError"] = {"hipErrorNotInitialized", CONV_ERR, API_RUNTIME}; - - cuda2hipRename["CUDA_ERROR_DEINITIALIZED"] = {"hipErrorDeinitialized", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorCudartUnloading"] = {"hipErrorDeinitialized", CONV_ERR, API_RUNTIME}; + cuda2hipRename["cudaSuccess"] = {"hipSuccess", CONV_ERR, API_RUNTIME}; // 0 cuda2hipRename["CUDA_ERROR_OUT_OF_MEMORY"] = {"hipErrorMemoryAllocation", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorMemoryAllocation"] = {"hipErrorMemoryAllocation", CONV_ERR, API_RUNTIME}; + cuda2hipRename["cudaErrorMemoryAllocation"] = {"hipErrorMemoryAllocation", CONV_ERR, API_RUNTIME}; // 2 - cuda2hipRename["CUDA_ERROR_INVALID_HANDLE"] = {"hipErrorInvalidResourceHandle", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorInvalidResourceHandle"] = {"hipErrorInvalidResourceHandle", CONV_ERR, API_RUNTIME}; - - cuda2hipRename["CUDA_ERROR_INVALID_VALUE"] = {"hipErrorInvalidValue", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorInvalidValue"] = {"hipErrorInvalidValue", CONV_ERR, API_RUNTIME}; - - cuda2hipRename["CUDA_ERROR_INVALID_DEVICE"] = {"hipErrorInvalidDevice", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorInvalidDevice"] = {"hipErrorInvalidDevice", CONV_ERR, API_RUNTIME}; - - cuda2hipRename["CUDA_ERROR_NOT_INITIALIZED"] = {"hipErrorInitializationError", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorInitializationError"] = {"hipErrorInitializationError", CONV_ERR, API_RUNTIME}; - - cuda2hipRename["CUDA_ERROR_NO_DEVICE"] = {"hipErrorNoDevice", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorNoDevice"] = {"hipErrorNoDevice", CONV_ERR, API_RUNTIME}; - - cuda2hipRename["CUDA_ERROR_NOT_READY"] = {"hipErrorNotReady", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorNotReady"] = {"hipErrorNotReady", CONV_ERR, API_RUNTIME}; - - cuda2hipRename["CUDA_ERROR_PEER_ACCESS_NOT_ENABLED"] = {"hipErrorPeerAccessNotEnabled", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorPeerAccessNotEnabled"] = {"hipErrorPeerAccessNotEnabled", CONV_ERR, API_RUNTIME}; - - cuda2hipRename["CUDA_ERROR_PEER_ACCESS_ALREADY_ENABLED"] = {"hipErrorPeerAccessAlreadyEnabled", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorPeerAccessAlreadyEnabled"] = {"hipErrorPeerAccessAlreadyEnabled", CONV_ERR, API_RUNTIME}; - - cuda2hipRename["CUDA_ERROR_PEER_ACCESS_UNSUPPORTED"] = {"hipErrorPeerAccessUnsupported", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorPeerAccessUnsupported"] = {"hipErrorPeerAccessUnsupported", CONV_ERR, API_RUNTIME}; - - cuda2hipRename["CUDA_ERROR_INVALID_PTX"] = {"hipErrorInvalidKernelFile", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorInvalidPtx"] = {"hipErrorInvalidKernelFile", CONV_ERR, API_RUNTIME}; - - cuda2hipRename["CUDA_ERROR_INVALID_GRAPHICS_CONTEXT"] = {"hipErrorInvalidGraphicsContext", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorInvalidGraphicsContext"] = {"hipErrorInvalidGraphicsContext", CONV_ERR, API_RUNTIME}; - - cuda2hipRename["CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND"] = {"hipErrorSharedObjectSymbolNotFound", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorSharedObjectSymbolNotFound"] = {"hipErrorSharedObjectSymbolNotFound", CONV_ERR, API_RUNTIME}; - - cuda2hipRename["CUDA_ERROR_SHARED_OBJECT_INIT_FAILED"] = {"hipErrorSharedObjectInitFailed", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorSharedObjectInitFailed"] = {"hipErrorSharedObjectInitFailed", CONV_ERR, API_RUNTIME}; - - cuda2hipRename["CUDA_ERROR_OPERATING_SYSTEM"] = {"hipErrorOperatingSystem", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorOperatingSystem"] = {"hipErrorOperatingSystem", CONV_ERR, API_RUNTIME}; - - cuda2hipRename["CUDA_ERROR_ILLEGAL_ADDRESS"] = {"hipErrorIllegalAddress", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorIllegalAddress"] = {"hipErrorIllegalAddress", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_NOT_INITIALIZED"] = {"hipErrorNotInitialized", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorInitializationError"] = {"hipErrorInitializationError", CONV_ERR, API_RUNTIME}; // 3 cuda2hipRename["CUDA_ERROR_LAUNCH_FAILED"] = {"hipErrorLaunchFailure", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorLaunchFailure"] = {"hipErrorLaunchFailure", CONV_ERR, API_RUNTIME}; + cuda2hipRename["cudaErrorLaunchFailure"] = {"hipErrorLaunchFailure", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 4 cuda2hipRename["CUDA_ERROR_LAUNCH_TIMEOUT"] = {"hipErrorLaunchTimeOut", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorLaunchTimeout"] = {"hipErrorLaunchTimeOut", CONV_ERR, API_RUNTIME}; + cuda2hipRename["cudaErrorLaunchTimeout"] = {"hipErrorLaunchTimeOut", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 6 cuda2hipRename["CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES"] = {"hipErrorLaunchOutOfResources", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorLaunchOutOfResources"] = {"hipErrorLaunchOutOfResources", CONV_ERR, API_RUNTIME}; + cuda2hipRename["cudaErrorLaunchOutOfResources"] = {"hipErrorLaunchOutOfResources", CONV_ERR, API_RUNTIME}; // 7 + + cuda2hipRename["CUDA_ERROR_INVALID_DEVICE"] = {"hipErrorInvalidDevice", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorInvalidDevice"] = {"hipErrorInvalidDevice", CONV_ERR, API_RUNTIME}; // 10 + + cuda2hipRename["CUDA_ERROR_INVALID_VALUE"] = {"hipErrorInvalidValue", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorInvalidValue"] = {"hipErrorInvalidValue", CONV_ERR, API_RUNTIME}; // 11 + + cuda2hipRename["CUDA_ERROR_DEINITIALIZED"] = {"hipErrorDeinitialized", CONV_ERR, API_DRIVER}; + // TODO: double check, that this error matches to hipErrorDeinitialized + cuda2hipRename["cudaErrorCudartUnloading"] = {"hipErrorDeinitialized", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 29 + + cuda2hipRename["CUDA_ERROR_UNKNOWN"] = {"hipErrorUnknown", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorUnknown"] = {"hipErrorUnknown", CONV_ERR, API_RUNTIME}; // 30 + + cuda2hipRename["CUDA_ERROR_INVALID_HANDLE"] = {"hipErrorInvalidResourceHandle", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorInvalidResourceHandle"] = {"hipErrorInvalidResourceHandle", CONV_ERR, API_RUNTIME}; // 33 + +// cuda2hipRename["CUDA_ERROR_NOT_INITIALIZED"] = {"hipErrorInitializationError", CONV_ERR, API_DRIVER}; +// cuda2hipRename["cudaErrorInitializationError"] = {"hipErrorInitializationError", CONV_ERR, API_RUNTIME}; + + cuda2hipRename["CUDA_ERROR_NOT_READY"] = {"hipErrorNotReady", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorNotReady"] = {"hipErrorNotReady", CONV_ERR, API_RUNTIME}; // 34 + + cuda2hipRename["CUDA_ERROR_NO_DEVICE"] = {"hipErrorNoDevice", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorNoDevice"] = {"hipErrorNoDevice", CONV_ERR, API_RUNTIME}; // 38 cuda2hipRename["CUDA_ERROR_ECC_UNCORRECTABLE"] = {"hipErrorECCNotCorrectable", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorECCUncorrectable"] = {"hipErrorECCNotCorrectable", CONV_ERR, API_RUNTIME}; + cuda2hipRename["cudaErrorECCUncorrectable"] = {"hipErrorECCNotCorrectable", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 39 - cuda2hipRename["CUDA_ERROR_HOST_MEMORY_ALREADY_REGISTERED"] = {"hipErrorHostMemoryAlreadyRegistered", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorHostMemoryAlreadyRegistered"] = {"hipErrorHostMemoryAlreadyRegistered", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND"] = {"hipErrorSharedObjectSymbolNotFound", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorSharedObjectSymbolNotFound"] = {"hipErrorSharedObjectSymbolNotFound", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 40 - cuda2hipRename["CUDA_ERROR_HOST_MEMORY_NOT_REGISTERED"] = {"hipErrorHostMemoryNotRegistered", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorHostMemoryNotRegistered"] = {"hipErrorHostMemoryNotRegistered", CONV_ERR, API_RUNTIME}; - - cuda2hipRename["CUDA_ERROR_NO_BINARY_FOR_GPU"] = {"hipErrorNoBinaryForGpu", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorNoKernelImageForDevice"] = {"hipErrorNoBinaryForGpu", CONV_ERR, API_RUNTIME}; + cuda2hipRename["CUDA_ERROR_SHARED_OBJECT_INIT_FAILED"] = {"hipErrorSharedObjectInitFailed", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorSharedObjectInitFailed"] = {"hipErrorSharedObjectInitFailed", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 41 cuda2hipRename["CUDA_ERROR_UNSUPPORTED_LIMIT"] = {"hipErrorUnsupportedLimit", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorUnsupportedLimit"] = {"hipErrorUnsupportedLimit", CONV_ERR, API_RUNTIME}; + cuda2hipRename["cudaErrorUnsupportedLimit"] = {"hipErrorUnsupportedLimit", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 42 cuda2hipRename["CUDA_ERROR_INVALID_IMAGE"] = {"hipErrorInvalidImage", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorInvalidKernelImage"] = {"hipErrorInvalidImage", CONV_ERR, API_RUNTIME}; + cuda2hipRename["cudaErrorInvalidKernelImage"] = {"hipErrorInvalidImage", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 47 + + cuda2hipRename["CUDA_ERROR_NO_BINARY_FOR_GPU"] = {"hipErrorNoBinaryForGpu", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorNoKernelImageForDevice"] = {"hipErrorNoBinaryForGpu", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 48 + + cuda2hipRename["CUDA_ERROR_PEER_ACCESS_ALREADY_ENABLED"] = {"hipErrorPeerAccessAlreadyEnabled", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorPeerAccessAlreadyEnabled"] = {"hipErrorPeerAccessAlreadyEnabled", CONV_ERR, API_RUNTIME}; // 50 + + cuda2hipRename["CUDA_ERROR_PEER_ACCESS_NOT_ENABLED"] = {"hipErrorPeerAccessNotEnabled", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorPeerAccessNotEnabled"] = {"hipErrorPeerAccessNotEnabled", CONV_ERR, API_RUNTIME}; // 51 cuda2hipRename["CUDA_ERROR_PROFILER_DISABLED"] = {"hipErrorProfilerDisabled", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorProfilerDisabled"] = {"hipErrorProfilerDisabled", CONV_ERR, API_RUNTIME}; + cuda2hipRename["cudaErrorProfilerDisabled"] = {"hipErrorProfilerDisabled", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 55 cuda2hipRename["CUDA_ERROR_PROFILER_NOT_INITIALIZED"] = {"hipErrorProfilerNotInitialized", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorProfilerNotInitialized"] = {"hipErrorProfilerNotInitialized", CONV_ERR, API_RUNTIME}; + // Deprecated as of CUDA 5.0 + cuda2hipRename["cudaErrorProfilerNotInitialized"] = {"hipErrorProfilerNotInitialized", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 56 cuda2hipRename["CUDA_ERROR_PROFILER_ALREADY_STARTED"] = {"hipErrorProfilerAlreadyStarted", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorProfilerAlreadyStarted"] = {"hipErrorProfilerAlreadyStarted", CONV_ERR, API_RUNTIME}; + // Deprecated as of CUDA 5.0 + cuda2hipRename["cudaErrorProfilerAlreadyStarted"] = {"hipErrorProfilerAlreadyStarted", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 57 cuda2hipRename["CUDA_ERROR_PROFILER_ALREADY_STOPPED"] = {"hipErrorProfilerAlreadyStopped", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorProfilerAlreadyStopped"] = {"hipErrorProfilerAlreadyStopped", CONV_ERR, API_RUNTIME}; + // Deprecated as of CUDA 5.0 + cuda2hipRename["cudaErrorProfilerAlreadyStopped"] = {"hipErrorProfilerAlreadyStopped", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 58 + + cuda2hipRename["CUDA_ERROR_HOST_MEMORY_ALREADY_REGISTERED"] = {"hipErrorHostMemoryAlreadyRegistered", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorHostMemoryAlreadyRegistered"] = {"hipErrorHostMemoryAlreadyRegistered", CONV_ERR, API_RUNTIME}; // 61 + + cuda2hipRename["CUDA_ERROR_HOST_MEMORY_NOT_REGISTERED"] = {"hipErrorHostMemoryNotRegistered", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorHostMemoryNotRegistered"] = {"hipErrorHostMemoryNotRegistered", CONV_ERR, API_RUNTIME}; // 62 + + cuda2hipRename["CUDA_ERROR_OPERATING_SYSTEM"] = {"hipErrorOperatingSystem", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorOperatingSystem"] = {"hipErrorOperatingSystem", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 63 + + cuda2hipRename["CUDA_ERROR_PEER_ACCESS_UNSUPPORTED"] = {"hipErrorPeerAccessUnsupported", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorPeerAccessUnsupported"] = {"hipErrorPeerAccessUnsupported", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 64 + + cuda2hipRename["CUDA_ERROR_ILLEGAL_ADDRESS"] = {"hipErrorIllegalAddress", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorIllegalAddress"] = {"hipErrorIllegalAddress", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 77 + + cuda2hipRename["CUDA_ERROR_INVALID_PTX"] = {"hipErrorInvalidKernelFile", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorInvalidPtx"] = {"hipErrorInvalidKernelFile", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 78 + + cuda2hipRename["CUDA_ERROR_INVALID_GRAPHICS_CONTEXT"] = {"hipErrorInvalidGraphicsContext", CONV_ERR, API_DRIVER}; + cuda2hipRename["cudaErrorInvalidGraphicsContext"] = {"hipErrorInvalidGraphicsContext", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 79 + + ///////////////////////////// CUDA DRIVER API ///////////////////////////// // Defines @@ -641,6 +693,12 @@ struct cuda2hipMap { cuda2hipRename["cudaMipmappedArray_const_t"] = {"const hipMipmappedArray *", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; // memcpy + // memcpy structs + // unsupported yet by HIP + cuda2hipRename["cudaMemcpy3DParms"] = {"hipMemcpy3DParms", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaMemcpy3DPeerParms"] = {"hipMemcpy3DPeerParms", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + + // memcpy functions cuda2hipRename["cudaMemcpy"] = {"hipMemcpy", CONV_MEM, API_RUNTIME}; cuda2hipRename["cudaMemcpyToArray"] = {"hipMemcpyToArray", CONV_MEM, API_RUNTIME}; cuda2hipRename["cudaMemcpyToSymbol"] = {"hipMemcpyToSymbol", CONV_MEM, API_RUNTIME}; @@ -718,6 +776,10 @@ struct cuda2hipMap { cuda2hipRename["make_cudaPitchedPtr"] = {"make_hipPitchedPtr", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; cuda2hipRename["make_cudaPos"] = {"make_hipPos", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaExtent"] = {"hipExtent", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaPitchedPtr"] = {"hipPitchedPtr", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaPos"] = {"hipPos", CONV_MEM, API_RUNTIME, HIP_UNSUPPORTED}; + // Host Malloc Flags cuda2hipRename["cudaHostAllocDefault"] = {"hipHostMallocDefault", CONV_MEM, API_RUNTIME}; cuda2hipRename["cudaHostAllocPortable"] = {"hipHostMallocPortable", CONV_MEM, API_RUNTIME}; @@ -810,9 +872,9 @@ struct cuda2hipMap { cuda2hipRename["cudaChooseDevice"] = {"hipChooseDevice", CONV_DEV, API_RUNTIME}; // Attributes - cuda2hipRename["cudaDeviceAttr"] = {"hipDeviceAttribute_t", CONV_TYPE, API_RUNTIME}; - cuda2hipRename["cudaDeviceGetAttribute"] = {"hipDeviceGetAttribute", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDeviceGetAttribute"] = {"hipDeviceGetAttribute", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaDeviceAttr"] = {"hipDeviceAttribute_t", CONV_TYPE, API_RUNTIME}; cuda2hipRename["cudaDevAttrMaxThreadsPerBlock"] = {"hipDeviceAttributeMaxThreadsPerBlock", CONV_DEV, API_RUNTIME}; cuda2hipRename["cudaDevAttrMaxBlockDimX"] = {"hipDeviceAttributeMaxBlockDimX", CONV_DEV, API_RUNTIME}; cuda2hipRename["cudaDevAttrMaxBlockDimY"] = {"hipDeviceAttributeMaxBlockDimY", CONV_DEV, API_RUNTIME}; @@ -858,6 +920,7 @@ struct cuda2hipMap { cuda2hipRename["cudaDevAttrSurfaceAlignment"] = {"hipDeviceAttributeSurfaceAlignment", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; cuda2hipRename["cudaDevAttrEccEnabled"] = {"hipDeviceAttributeEccEnabled", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; cuda2hipRename["cudaDevAttrTccDriver"] = {"hipDeviceAttributeTccDriver", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrAsyncEngineCount"] = {"hipDevAttrAsyncEngineCount", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; cuda2hipRename["cudaDevAttrUnifiedAddressing"] = {"hipDeviceAttributeUnifiedAddressing", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; cuda2hipRename["cudaDevAttrMaxTexture1DLayeredWidth"] = {"hipDeviceAttributeMaxTexture1DLayeredWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; cuda2hipRename["cudaDevAttrMaxTexture1DLayeredLayers"] = {"hipDeviceAttributeMaxTexture1DLayeredLayers", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; @@ -921,6 +984,13 @@ struct cuda2hipMap { cuda2hipRename["cudaDeviceGetStreamPriorityRange"] = {"hipDeviceGetStreamPriorityRange", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; cuda2hipRename["cudaSetValidDevices"] = {"hipSetValidDevices", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + // Compute mode + cuda2hipRename["cudaComputeMode"] = {"hipComputeMode", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaComputeModeDefault"] = {"hipComputeModeDefault", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaComputeModeExclusive"] = {"hipComputeModeExclusive", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaComputeModeProhibited"] = {"hipComputeModeProhibited", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaComputeModeExclusiveProcess"] = {"hipComputeModeExclusiveProcess", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + // Device Flags // unsupported yet by HIP cuda2hipRename["cudaGetDeviceFlags"] = {"hipGetDeviceFlags", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; @@ -946,6 +1016,7 @@ struct cuda2hipMap { cuda2hipRename["cudaDeviceGetCacheConfig"] = {"hipDeviceGetCacheConfig", CONV_CACHE, API_RUNTIME}; // translate deprecated cuda2hipRename["cudaThreadGetCacheConfig"] = {"hipDeviceGetCacheConfig", CONV_CACHE, API_RUNTIME}; + cuda2hipRename["cudaFuncSetCacheConfig"] = {"hipFuncSetCacheConfig", CONV_CACHE, API_RUNTIME}; // Execution control // CUDA function cache configurations @@ -954,21 +1025,21 @@ struct cuda2hipMap { cuda2hipRename["cudaFuncCachePreferShared"] = {"hipFuncCachePreferShared", CONV_CACHE, API_RUNTIME}; cuda2hipRename["cudaFuncCachePreferL1"] = {"hipFuncCachePreferL1", CONV_CACHE, API_RUNTIME}; cuda2hipRename["cudaFuncCachePreferEqual"] = {"hipFuncCachePreferEqual", CONV_CACHE, API_RUNTIME}; + // Execution control functions // unsupported yet by HIP - cuda2hipRename["cudaFuncGetAttributes"] = {"hipFuncGetAttributes", CONV_CACHE, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaFuncSetCacheConfig"] = {"hipFuncSetCacheConfig", CONV_CACHE, API_RUNTIME}; - // unsupported yet by HIP - cuda2hipRename["cudaFuncSetSharedMemConfig"] = {"hipFuncSetSharedMemConfig", CONV_CACHE, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaGetParameterBuffer"] = {"hipGetParameterBuffer", CONV_CACHE, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaSetDoubleForDevice"] = {"hipSetDoubleForDevice", CONV_CACHE, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaSetDoubleForHost"] = {"hipSetDoubleForHost", CONV_CACHE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaFuncAttributes"] = {"hipFuncAttributes", CONV_EXEC, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaFuncGetAttributes"] = {"hipFuncGetAttributes", CONV_EXEC, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaFuncSetSharedMemConfig"] = {"hipFuncSetSharedMemConfig", CONV_EXEC, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGetParameterBuffer"] = {"hipGetParameterBuffer", CONV_EXEC, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaSetDoubleForDevice"] = {"hipSetDoubleForDevice", CONV_EXEC, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaSetDoubleForHost"] = {"hipSetDoubleForHost", CONV_EXEC, API_RUNTIME, HIP_UNSUPPORTED}; // Execution Control [deprecated since 7.0] // unsupported yet by HIP - cuda2hipRename["cudaConfigureCall"] = {"hipConfigureCall", CONV_CACHE, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaLaunch"] = {"hipLaunch", CONV_CACHE, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaSetupArgument"] = {"hipSetupArgument", CONV_CACHE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaConfigureCall"] = {"hipConfigureCall", CONV_EXEC, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaLaunch"] = {"hipLaunch", CONV_EXEC, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaSetupArgument"] = {"hipSetupArgument", CONV_EXEC, API_RUNTIME, HIP_UNSUPPORTED}; // Driver/Runtime cuda2hipRename["cudaDriverGetVersion"] = {"hipDriverGetVersion", CONV_DRIVER, API_RUNTIME}; @@ -1000,6 +1071,7 @@ struct cuda2hipMap { cuda2hipRename["cudaDeviceGetSharedMemConfig"] = {"hipDeviceGetSharedMemConfig", CONV_DEV, API_RUNTIME}; // translate deprecated cuda2hipRename["cudaThreadGetSharedMemConfig"] = {"hipDeviceGetSharedMemConfig", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaSharedMemConfig"] = {"hipSharedMemConfig", CONV_DEV, API_RUNTIME}; cuda2hipRename["cudaSharedMemBankSizeDefault"] = {"hipSharedMemBankSizeDefault", CONV_DEV, API_RUNTIME}; cuda2hipRename["cudaSharedMemBankSizeFourByte"] = {"hipSharedMemBankSizeFourByte", CONV_DEV, API_RUNTIME}; @@ -1010,9 +1082,7 @@ struct cuda2hipMap { // unsupported yet by HIP cuda2hipRename["cudaLimitStackSize"] = {"hipLimitStackSize", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; cuda2hipRename["cudaLimitPrintfFifoSize"] = {"hipLimitPrintfFifoSize", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaLimitMallocHeapSize"] = {"hipLimitMallocHeapSize", CONV_DEV, API_RUNTIME}; - // unsupported yet by HIP cuda2hipRename["cudaLimitDevRuntimeSyncDepth"] = {"hipLimitPrintfFifoSize", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; cuda2hipRename["cudaLimitDevRuntimePendingLaunchCount"] = {"hipLimitMallocHeapSize", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; @@ -1025,19 +1095,24 @@ struct cuda2hipMap { cuda2hipRename["cudaProfilerStart"] = {"hipProfilerStart", CONV_OTHER, API_RUNTIME}; cuda2hipRename["cudaProfilerStop"] = {"hipProfilerStop", CONV_OTHER, API_RUNTIME}; - cuda2hipRename["cudaFilterModePoint"] = {"hipFilterModePoint", CONV_TEX, API_RUNTIME}; - cuda2hipRename["cudaReadModeElementType"] = {"hipReadModeElementType", CONV_TEX, API_RUNTIME}; + // unsupported yet by HIP + cuda2hipRename["cudaOutputMode"] = {"hipOutputMode", CONV_OTHER, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaKeyValuePair"] = {"hipKeyValuePair", CONV_OTHER, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaCSV"] = {"hipCSV", CONV_OTHER, API_RUNTIME, HIP_UNSUPPORTED}; // Texture Reference Management + // enums cuda2hipRename["cudaTextureReadMode"] = {"hipTextureReadMode", CONV_TEX, API_RUNTIME}; cuda2hipRename["cudaReadModeElementType"] = {"hipReadModeElementType", CONV_TEX, API_RUNTIME}; // unsupported yet by HIP cuda2hipRename["cudaReadModeNormalizedFloat"] = {"hipReadModeNormalizedFloat", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaTextureFilterMode"] = {"hipTextureFilterMode", CONV_TEX, API_RUNTIME}; cuda2hipRename["cudaFilterModePoint"] = {"hipFilterModePoint", CONV_TEX, API_RUNTIME}; // unsupported yet by HIP cuda2hipRename["cudaFilterModeLinear"] = {"hipFilterModeLinear", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaBindTexture"] = {"hipBindTexture", CONV_TEX, API_RUNTIME}; cuda2hipRename["cudaUnbindTexture"] = {"hipUnbindTexture", CONV_TEX, API_RUNTIME}; // unsupported yet by HIP @@ -1059,44 +1134,108 @@ struct cuda2hipMap { cuda2hipRename["cudaGetChannelDesc"] = {"hipGetChannelDesc", CONV_TEX, API_RUNTIME}; // Texture Object Management + // structs // unsupported yet by HIP - cuda2hipRename["cudaCreateTextureObject"] = {"hipCreateTextureObject", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDestroyTextureObject"] = {"hipDestroyTextureObject", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaGetTextureObjectResourceDesc"] = {"hipGetTextureObjectResourceDesc", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaGetTextureObjectResourceViewDesc"] = {"hipGetTextureObjectResourceViewDesc", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaGetTextureObjectTextureDesc"] = {"hipGetTextureObjectTextureDesc", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaResourceDesc"] = {"hipResourceDesc", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaResourceViewDesc"] = {"hipResourceViewDesc", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaTextureDesc"] = {"hipTextureDesc", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + // enums + // unsupported yet by HIP + cuda2hipRename["cudaResourceType"] = {"hipResourceType", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaResourceTypeArray"] = {"hipResourceTypeArray", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaResourceTypeMipmappedArray"] = {"hipResourceTypeMipmappedArray", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaResourceTypeLinear"] = {"hipResourceTypeLinear", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaResourceTypePitch2D"] = {"hipResourceTypePitch2D", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + + cuda2hipRename["cudaResourceViewFormat"] = {"hipResourceViewFormat", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaResViewFormatNone"] = {"hipResViewFormatNone", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaResViewFormatUnsignedChar1"] = {"hipResViewFormatUnsignedChar1", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaResViewFormatUnsignedChar2"] = {"hipResViewFormatUnsignedChar2", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaResViewFormatUnsignedChar4"] = {"hipResViewFormatUnsignedChar4", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaResViewFormatSignedChar1"] = {"hipResViewFormatSignedChar1", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaResViewFormatSignedChar2"] = {"hipResViewFormatSignedChar2", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaResViewFormatSignedChar4"] = {"hipResViewFormatSignedChar4", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaResViewFormatUnsignedShort1"] = {"hipResViewFormatUnsignedShort1", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaResViewFormatUnsignedShort2"] = {"hipResViewFormatUnsignedShort2", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaResViewFormatUnsignedShort4"] = {"hipResViewFormatUnsignedShort4", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaResViewFormatSignedShort1"] = {"hipResViewFormatSignedShort1", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaResViewFormatSignedShort2"] = {"hipResViewFormatSignedShort2", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaResViewFormatSignedShort4"] = {"hipResViewFormatSignedShort4", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaResViewFormatUnsignedInt1"] = {"hipResViewFormatUnsignedInt1", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaResViewFormatUnsignedInt2"] = {"hipResViewFormatUnsignedInt2", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaResViewFormatUnsignedInt4"] = {"hipResViewFormatUnsignedInt4", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaResViewFormatSignedInt1"] = {"hipResViewFormatSignedInt1", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaResViewFormatSignedInt2"] = {"hipResViewFormatSignedInt2", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaResViewFormatSignedInt4"] = {"hipResViewFormatSignedInt4", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaResViewFormatHalf1"] = {"hipResViewFormatHalf1", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaResViewFormatHalf2"] = {"hipResViewFormatHalf2", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaResViewFormatHalf4"] = {"hipResViewFormatHalf4", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaResViewFormatFloat1"] = {"hipResViewFormatFloat1", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaResViewFormatFloat2"] = {"hipResViewFormatFloat2", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaResViewFormatFloat4"] = {"hipResViewFormatFloat4", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaResViewFormatUnsignedBlockCompressed1"] = {"hipResViewFormatUnsignedBlockCompressed1", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaResViewFormatUnsignedBlockCompressed2"] = {"hipResViewFormatUnsignedBlockCompressed2", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaResViewFormatUnsignedBlockCompressed3"] = {"hipResViewFormatUnsignedBlockCompressed3", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaResViewFormatUnsignedBlockCompressed4"] = {"hipResViewFormatUnsignedBlockCompressed4", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaResViewFormatSignedBlockCompressed4"] = {"hipResViewFormatSignedBlockCompressed4", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaResViewFormatUnsignedBlockCompressed5"] = {"hipResViewFormatUnsignedBlockCompressed5", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaResViewFormatSignedBlockCompressed5"] = {"hipResViewFormatSignedBlockCompressed5", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaResViewFormatSignedBlockCompressed6H"] = {"hipResViewFormatSignedBlockCompressed6H", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaResViewFormatUnsignedBlockCompressed7"] = {"hipResViewFormatUnsignedBlockCompressed7", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + + cuda2hipRename["cudaTextureAddressMode"] = {"hipTextureAddressMode", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaAddressModeWrap"] = {"hipAddressModeWrap", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaAddressModeClamp"] = {"hipAddressModeClamp", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaAddressModeMirror"] = {"hipAddressModeMirror", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaAddressModeBorder"] = {"hipAddressModeBorder", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + + // functions + cuda2hipRename["cudaCreateTextureObject"] = {"hipCreateTextureObject", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDestroyTextureObject"] = {"hipDestroyTextureObject", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGetTextureObjectResourceDesc"] = {"hipGetTextureObjectResourceDesc", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGetTextureObjectResourceViewDesc"] = {"hipGetTextureObjectResourceViewDesc", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGetTextureObjectTextureDesc"] = {"hipGetTextureObjectTextureDesc", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // Surface Reference Management // unsupported yet by HIP - cuda2hipRename["cudaBindSurfaceToArray"] = {"hipBindSurfaceToArray", CONV_SURFACE, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaGetSurfaceReference"] = {"hipGetSurfaceReference", CONV_SURFACE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaBindSurfaceToArray"] = {"hipBindSurfaceToArray", CONV_SURFACE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGetSurfaceReference"] = {"hipGetSurfaceReference", CONV_SURFACE, API_RUNTIME, HIP_UNSUPPORTED}; + + cuda2hipRename["cudaSurfaceBoundaryMode"] = {"hipSurfaceBoundaryMode", CONV_SURFACE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaBoundaryModeZero"] = {"hipBoundaryModeZero", CONV_SURFACE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaBoundaryModeClamp"] = {"hipBoundaryModeClamp", CONV_SURFACE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaBoundaryModeTrap"] = {"hipBoundaryModeTrap", CONV_SURFACE, API_RUNTIME, HIP_UNSUPPORTED}; + + cuda2hipRename["cudaSurfaceFormatMode"] = {"hipSurfaceFormatMode", CONV_SURFACE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaFormatModeForced"] = {"hipFormatModeForced", CONV_SURFACE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaFormatModeAuto"] = {"hipFormatModeAuto", CONV_SURFACE, API_RUNTIME, HIP_UNSUPPORTED}; // Surface Object Management // unsupported yet by HIP - cuda2hipRename["cudaCreateSurfaceObject"] = {"hipCreateSurfaceObject", CONV_SURFACE, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDestroySurfaceObject"] = {"hipDestroySurfaceObject", CONV_SURFACE, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaGetSurfaceObjectResourceDesc"] = {"hipGetSurfaceObjectResourceDesc", CONV_SURFACE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaCreateSurfaceObject"] = {"hipCreateSurfaceObject", CONV_SURFACE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDestroySurfaceObject"] = {"hipDestroySurfaceObject", CONV_SURFACE, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGetSurfaceObjectResourceDesc"] = {"hipGetSurfaceObjectResourceDesc", CONV_SURFACE, API_RUNTIME, HIP_UNSUPPORTED}; // Inter-Process Communications (IPC) // IPC types - cuda2hipRename["cudaIpcEventHandle_t"] = {"hipIpcEventHandle_t", CONV_TYPE, API_RUNTIME}; - cuda2hipRename["cudaIpcEventHandle_st"] = {"hipIpcEventHandle_t", CONV_TYPE, API_RUNTIME}; - cuda2hipRename["cudaIpcMemHandle_t"] = {"hipIpcMemHandle_t", CONV_TYPE, API_RUNTIME}; - cuda2hipRename["cudaIpcMemHandle_st"] = {"hipIpcMemHandle_t", CONV_TYPE, API_RUNTIME}; + cuda2hipRename["cudaIpcEventHandle_t"] = {"hipIpcEventHandle_t", CONV_TYPE, API_RUNTIME}; + cuda2hipRename["cudaIpcEventHandle_st"] = {"hipIpcEventHandle_t", CONV_TYPE, API_RUNTIME}; + cuda2hipRename["cudaIpcMemHandle_t"] = {"hipIpcMemHandle_t", CONV_TYPE, API_RUNTIME}; + cuda2hipRename["cudaIpcMemHandle_st"] = {"hipIpcMemHandle_t", CONV_TYPE, API_RUNTIME}; // IPC functions - cuda2hipRename["cudaIpcCloseMemHandle"] = {"hipIpcCloseMemHandle", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaIpcGetEventHandle"] = {"hipIpcGetEventHandle", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaIpcGetMemHandle"] = {"hipIpcGetMemHandle", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaIpcOpenEventHandle"] = {"hipIpcOpenEventHandle", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaIpcOpenMemHandle"] = {"hipIpcOpenMemHandle", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaIpcCloseMemHandle"] = {"hipIpcCloseMemHandle", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaIpcGetEventHandle"] = {"hipIpcGetEventHandle", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaIpcGetMemHandle"] = {"hipIpcGetMemHandle", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaIpcOpenEventHandle"] = {"hipIpcOpenEventHandle", CONV_DEV, API_RUNTIME}; + cuda2hipRename["cudaIpcOpenMemHandle"] = {"hipIpcOpenMemHandle", CONV_DEV, API_RUNTIME}; // OpenGL Interoperability // unsupported yet by HIP - cuda2hipRename["cudaGLGetDevices"] = {"hipGLGetDevices", CONV_GL, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaGraphicsGLRegisterBuffer"] = {"hipGraphicsGLRegisterBuffer", CONV_GL, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaGraphicsGLRegisterImage"] = {"hipGraphicsGLRegisterImage", CONV_GL, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaWGLGetDevice"] = {"hipWGLGetDevice", CONV_GL, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGLGetDevices"] = {"hipGLGetDevices", CONV_GL, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGraphicsGLRegisterBuffer"] = {"hipGraphicsGLRegisterBuffer", CONV_GL, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGraphicsGLRegisterImage"] = {"hipGraphicsGLRegisterImage", CONV_GL, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaWGLGetDevice"] = {"hipWGLGetDevice", CONV_GL, API_RUNTIME, HIP_UNSUPPORTED}; // Graphics Interoperability // unsupported yet by HIP @@ -1108,6 +1247,26 @@ struct cuda2hipMap { cuda2hipRename["cudaGraphicsUnmapResources"] = {"hipGraphicsUnmapResources", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; cuda2hipRename["cudaGraphicsUnregisterResource"] = {"hipGraphicsUnregisterResource", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGraphicsCubeFace"] = {"hipGraphicsCubeFace", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGraphicsCubeFacePositiveX"] = {"hipGraphicsCubeFacePositiveX", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGraphicsCubeFaceNegativeX"] = {"hipGraphicsCubeFaceNegativeX", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGraphicsCubeFacePositiveY"] = {"hipGraphicsCubeFacePositiveY", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGraphicsCubeFaceNegativeY"] = {"hipGraphicsCubeFaceNegativeY", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGraphicsCubeFacePositiveZ"] = {"hipGraphicsCubeFacePositiveZ", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGraphicsCubeFaceNegativeZ"] = {"hipGraphicsCubeFaceNegativeZ", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; + + cuda2hipRename["cudaGraphicsMapFlags"] = {"hipGraphicsMapFlags", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGraphicsMapFlagsNone"] = {"hipGraphicsMapFlagsNone", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGraphicsMapFlagsReadOnly"] = {"hipGraphicsMapFlagsReadOnly", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGraphicsMapFlagsWriteDiscard"] = {"hipGraphicsMapFlagsWriteDiscard", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; + + cuda2hipRename["cudaGraphicsRegisterFlags"] = {"hipGraphicsRegisterFlags", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGraphicsRegisterFlagsNone"] = {"hipGraphicsRegisterFlagsNone", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGraphicsRegisterFlagsReadOnly"] = {"hipGraphicsRegisterFlagsReadOnly", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGraphicsRegisterFlagsWriteDiscard"] = {"hipGraphicsRegisterFlagsWriteDiscard", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGraphicsRegisterFlagsSurfaceLoadStore"] = {"hipGraphicsRegisterFlagsSurfaceLoadStore", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaGraphicsRegisterFlagsTextureGather"] = {"hipGraphicsRegisterFlagsTextureGather", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; + //---------------------------------------BLAS-------------------------------------// // Blas types cuda2hipRename["cublasHandle_t"] = {"hipblasHandle_t", CONV_TYPE, API_BLAS}; From 3223473f95dbf6071a7a61b2067a923a34b20aed Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Fri, 3 Mar 2017 22:05:23 +0300 Subject: [PATCH 183/281] [HIP] [DOC] Update CUDA_Runtime_API_functions_supported_by_HIP + update all Cuda 7.5 RT API enum values. [ROCm/hip commit: aa2fc24482da805b64a678a2a325f0ea1bb45e69] --- ..._Runtime_API_functions_supported_by_HIP.md | 445 ++++++++++++++---- 1 file changed, 353 insertions(+), 92 deletions(-) diff --git a/projects/hip/docs/markdown/CUDA_Runtime_API_functions_supported_by_HIP.md b/projects/hip/docs/markdown/CUDA_Runtime_API_functions_supported_by_HIP.md index 4735f2b8dc..c5df7f6bcd 100644 --- a/projects/hip/docs/markdown/CUDA_Runtime_API_functions_supported_by_HIP.md +++ b/projects/hip/docs/markdown/CUDA_Runtime_API_functions_supported_by_HIP.md @@ -282,95 +282,356 @@ ## **20. Data types** -| **type** | **CUDA** | **HIP** | **CUDA description** | -|--------------|--------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| -| struct | `cudaChannelFormatDesc` | `hipChannelFormatDesc` | CUDA Channel format descriptor. | -| struct | `cudaDeviceProp` | `hipDeviceProp_t` | CUDA device properties. | -| struct | `cudaExtent` | | CUDA extent (width, height, depth). | -| struct | `cudaFuncAttributes` | | CUDA function attributes. | -| struct | `cudaIpcEventHandle_t` | `hipIpcEventHandle_t` | CUDA IPC event handle. | -| struct | `cudaIpcMemHandle_t` | `hipIpcMemHandle_t` | CUDA IPC memory handle. | -| struct | `cudaMemcpy3DParms` | | CUDA 3D memory copying parameters. | -| struct | `cudaMemcpy3DPeerParms` | | CUDA 3D cross-device memory copying parameters. | -| struct | `cudaPitchedPtr` | | CUDA Pitched memory pointer. | -| struct | `cudaPointerAttributes` | `hipPointerAttribute_t` | CUDA pointer attributes. | -| struct | `cudaPos` | | CUDA 3D position. | -| struct | `cudaResourceDesc` | | CUDA resource descriptor. | -| struct | `cudaResourceViewDesc` | | CUDA resource view descriptor. | -| struct | `cudaTextureDesc` | | CUDA texture descriptor. | -| struct | `surfaceReference` | | CUDA Surface reference. | -| struct | `textureReference` | `textureReference` | CUDA texture reference. | -| enum | `cudaChannelFormatKind` | `hipChannelFormatKind` | Channel format kind. | -| enum | `cudaComputeMode` | | CUDA device compute modes. | -| enum | `cudaDeviceAttr` | `hipDeviceAttribute_t` | CUDA device attributes. | -| enum | `cudaError` | `hipError_t` | CUDA Error types. | -| enum | `cudaError_t` | `hipError_t` | CUDA Error types. | -| enum | `cudaFuncCache` | `hipFuncCache_t` | CUDA function cache configurations. | -| enum | `cudaGraphicsCubeFace` | | CUDA graphics interop array indices for cube maps. | -| enum | `cudaGraphicsMapFlags` | | CUDA graphics interop map flags. | -| enum | `cudaGraphicsRegisterFlags` | | CUDA graphics interop register flags. | -| enum | `cudaMemcpyKind` | `hipMemcpyKind` | CUDA memory copy types. | -| enum | `cudaMemoryType` | `hipMemoryType` | CUDA memory types. | -| enum | `cudaOutputMode` | | CUDA Profiler Output modes. | -| enum | `cudaResourceType` | | CUDA resource types. | -| enum | `cudaResourceViewFormat` | | CUDA texture resource view formats. | -| enum | `cudaSharedMemConfig` | `hipSharedMemConfig` | CUDA shared memory configuration. | -| enum | `cudaSurfaceBoundaryMode` | | CUDA Surface boundary modes. | -| enum | `cudaSurfaceFormatMode` | | CUDA Surface format modes. | -| enum | `cudaTextureAddressMode` | | CUDA texture address modes. | -| enum | `cudaTextureFilterMode` | `hipTextureFilterMode` | CUDA texture filter modes. | -| enum | `cudaTextureReadMode` | `hipTextureReadMode` | CUDA texture read modes. | -| struct | `cudaArray` | `hipArray` | CUDA array [opaque]. | -| typedef | `cudaArray_t` | `hipArray *` | CUDA array pointer. | -| typedef | `cudaArray_const_t` | `const hipArray *` | CUDA array (as source copy argument). | -| enum | `cudaError` | `hipError_t` | CUDA Error types. | -| typedef | `cudaError_t` | `hipError_t` | CUDA Error types. | -| typedef | `cudaEvent_t` | `hipEvent_t` | CUDA event types. | -| typedef | `cudaGraphicsResource_t` | | CUDA graphics resource types. | -| typedef | `cudaMipmappedArray_t` | | CUDA mipmapped array. | -| typedef | `cudaMipmappedArray_const_t` | | CUDA mipmapped array (as source argument). | -| enum | `cudaOutputMode` | | CUDA output file modes. | -| typedef | `cudaOutputMode_t` | | CUDA output file modes. | -| typedef | `cudaStream_t` | `hipStream_t` | CUDA stream. | -| typedef | `cudaSurfaceObject_t` | | An opaque value that represents a CUDA Surface object. | -| typedef | `cudaTextureObject_t` | | An opaque value that represents a CUDA texture object. | -| typedef | `CUuuid_stcudaUUID_t` | | CUDA UUID types. | -| define | `CUDA_IPC_HANDLE_SIZE` | | CUDA IPC Handle Size. | -| define | `cudaArrayCubemap` | | Must be set in cudaMalloc3DArray to create a cubemap CUDA array. | -| define | `cudaArrayDefault` | | Default CUDA array allocation flag. | -| define | `cudaArrayLayered` | | Must be set in cudaMalloc3DArray to create a layered CUDA array. | -| define | `cudaArraySurfaceLoadStore` | | Must be set in cudaMallocArray or cudaMalloc3DArray in order to bind surfaces to the CUDA array. | -| define | `cudaArrayTextureGather` | | Must be set in cudaMallocArray or cudaMalloc3DArray in order to perform texture gather operations on the CUDA array. | -| define | `cudaDeviceBlockingSync` | `hipDeviceScheduleBlockingSync` | Device flag - Use blocking synchronization. Deprecated as of CUDA 4.0 and replaced with cudaDeviceScheduleBlockingSync. | -| define | `cudaDeviceLmemResizeToMax` | | Device flag - Keep local memory allocation after launch. | -| define | `cudaDeviceMapHost` | | Device flag - Support mapped pinned allocations. | -| define | `cudaDeviceMask` | | Device flags mask. | -| define | `cudaDevicePropDontCare` | | Empty device properties. | -| define | `cudaDeviceScheduleAuto` | `hipDeviceScheduleAuto` | Device flag - Automatic scheduling. | -| define | `cudaDeviceScheduleBlockingSync` | `hipDeviceScheduleBlockingSync` | Device flag - Use blocking synchronization. | -| define | `cudaDeviceScheduleMask` | `hipDeviceScheduleMask` | Device schedule flags mask. | -| define | `cudaDeviceScheduleSpin` | `hipDeviceScheduleSpin` | Device flag - Spin default scheduling. | -| define | `cudaDeviceScheduleYield` | `hipDeviceScheduleYield` | Device flag - Yield default scheduling. | -| define | `cudaEventBlockingSync` | `hipEventBlockingSync` | Event uses blocking synchronization. | -| define | `cudaEventDefault` | `hipEventDefault` | Default event flag. | -| define | `cudaEventDisableTiming` | `hipEventDisableTiming` | Event will not record timing data. | -| define | `cudaEventInterprocess` | `hipEventInterprocess` | Event is suitable for interprocess use. cudaEventDisableTiming must be set. | -| define | `cudaHostAllocDefault` | `hipHostMallocDefault` | Default page-locked allocation flag. | -| define | `cudaHostAllocMapped` | `hipHostMallocMapped` | Map allocation into device space. | -| define | `cudaHostAllocPortable` | `hipHostMallocPortable` | Pinned memory accessible by all CUDA contexts. | -| define | `cudaHostAllocWriteCombined` | `hipHostMallocWriteCombined` | Write-combined memory. | -| define | `cudaHostRegisterDefault` | `hipHostRegisterDefault` | Default host memory registration flag. | -| define | `cudaHostRegisterIoMemory` | `hipHostRegisterIoMemory` | Memory-mapped I/O space. | -| define | `cudaHostRegisterMapped` | `hipHostRegisterMapped` | Map registered memory into device space. | -| define | `cudaHostRegisterPortable` | `hipHostRegisterPortable` | Pinned memory accessible by all CUDA contexts. | -| define | `cudaIpcMemLazyEnablePeerAccess` | `hipIpcMemLazyEnablePeerAccess` | Automatically enable peer access between remote devices as needed. | -| define | `cudaMemAttachGlobal` | | Memory can be accessed by any stream on any device. | -| define | `cudaMemAttachHost` | | Memory cannot be accessed by any stream on any device. | -| define | `cudaMemAttachSingle` | | Memory can only be accessed by a single stream on the associated device. | -| define | `cudaOccupancyDefault` | | Default behavior. | -| define | `cudaOccupancyDisableCachingOverride` | | Assume global caching is enabled and cannot be automatically turned off. | -| define | `cudaPeerAccessDefault` | | Default peer addressing enable flag. | -| define | `cudaStreamDefault` | `hipStreamDefault` | Default stream flag. | -| define | `cudaStreamLegacy` | | Default stream flag. | -| define | `cudaStreamNonBlocking` | `hipStreamNonBlocking` | Stream does not synchronize with stream 0 (the NULL stream). | -| define | `cudaStreamPerThread` | | Per-thread stream handle. | +| **type** | **CUDA** | **HIP** | **CUDA description** | +|-------------:|-----------------------------------------------|------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------| +| struct | `cudaChannelFormatDesc` | `hipChannelFormatDesc` | CUDA Channel format descriptor. | +| struct | `cudaDeviceProp` | `hipDeviceProp_t` | CUDA device properties. | +| struct | `cudaExtent` | | CUDA extent (width, height, depth). | +| struct | `cudaFuncAttributes` | | CUDA function attributes. | +| struct | `cudaIpcEventHandle_t` | `hipIpcEventHandle_t` | CUDA IPC event handle. | +| struct | `cudaIpcMemHandle_t` | `hipIpcMemHandle_t` | CUDA IPC memory handle. | +| struct | `cudaMemcpy3DParms` | | CUDA 3D memory copying parameters. | +| struct | `cudaMemcpy3DPeerParms` | | CUDA 3D cross-device memory copying parameters. | +| struct | `cudaPitchedPtr` | | CUDA Pitched memory pointer. | +| struct | `cudaPointerAttributes` | `hipPointerAttribute_t` | CUDA pointer attributes. | +| struct | `cudaPos` | | CUDA 3D position. | +| struct | `cudaResourceDesc` | | CUDA resource descriptor. | +| struct | `cudaResourceViewDesc` | | CUDA resource view descriptor. | +| struct | `cudaTextureDesc` | | CUDA texture descriptor. | +| struct | `surfaceReference` | | CUDA Surface reference. | +| struct | `textureReference` | `textureReference` | CUDA texture reference. | +| enum |***`cudaChannelFormatKind`*** |***`hipChannelFormatKind`*** | Channel format kind. | +| 0 |*`cudaChannelFormatKindSigned`* |*`hipChannelFormatKindSigned`* | Signed channel format. | +| 1 |*`cudaChannelFormatKindUnsigned`* |*`hipChannelFormatKindUnsigned`* | Unsigned channel format. | +| 2 |*`cudaChannelFormatKindFloat`* |*`hipChannelFormatKindFloat`* | Float channel format. | +| 3 |*`cudaChannelFormatKindNone`* |*`hipChannelFormatKindNone`* | No channel format. | +| enum |***`cudaComputeMode`*** | | CUDA device compute modes. | +| 0 |*`cudaComputeModeDefault`* | | Default compute mode (Multiple threads can use ::cudaSetDevice() with this device). | +| 1 |*`cudaComputeModeExclusive`* | | Compute-exclusive-thread mode (Only one thread in one process will be able to use ::cudaSetDevice() with this device). | +| 2 |*`cudaComputeModeProhibited`* | | Compute-prohibited mode (No threads can use ::cudaSetDevice() with this device). | +| 3 |*`cudaComputeModeExclusiveProcess`* | | Compute-exclusive-process mode (Many threads in one process will be able to use ::cudaSetDevice() with this device). | +| enum |***`cudaDeviceAttr`*** |***`hipDeviceAttribute_t`*** | CUDA device attributes. | +| 1 |*`cudaDevAttrMaxThreadsPerBlock`* |*`hipDeviceAttributeMaxThreadsPerBlock`* | Maximum number of threads per block. | +| 2 |*`cudaDevAttrMaxBlockDimX`* |*`hipDeviceAttributeMaxBlockDimX`* | Maximum block dimension X. | +| 3 |*`cudaDevAttrMaxBlockDimY`* |*`hipDeviceAttributeMaxBlockDimY`* | Maximum block dimension Y. | +| 4 |*`cudaDevAttrMaxBlockDimZ`* |*`hipDeviceAttributeMaxBlockDimZ`* | Maximum block dimension Y. | +| 5 |*`cudaDevAttrMaxGridDimX`* |*`hipDeviceAttributeMaxGridDimX`* | Maximum grid dimension X. | +| 6 |*`cudaDevAttrMaxGridDimY`* |*`hipDeviceAttributeMaxGridDimY`* | Maximum grid dimension Y. | +| 7 |*`cudaDevAttrMaxGridDimZ`* |*`hipDeviceAttributeMaxGridDimZ`* | Maximum grid dimension Y. | +| 8 |*`cudaDevAttrMaxSharedMemoryPerBlock`* |*`hipDeviceAttributeMaxSharedMemoryPerBlock`* | Maximum shared memory available per block in bytes. | +| 9 |*`cudaDevAttrTotalConstantMemory`* |*`hipDeviceAttributeTotalConstantMemory`* | Memory available on device for \__constant__ variables in a CUDA C kernel in bytes. | +| 10 |*`cudaDevAttrWarpSize`* |*`hipDeviceAttributeWarpSize`* | Warp size in threads. | +| 11 |*`cudaDevAttrMaxPitch`* | | Maximum pitch in bytes allowed by memory copies. | +| 12 |*`cudaDevAttrMaxRegistersPerBlock`* |*`hipDeviceAttributeMaxRegistersPerBlock`* | Maximum number of 32-bit registers available per block. | +| 13 |*`cudaDevAttrClockRate`* |*`hipDeviceAttributeClockRate`* | Peak clock frequency in kilohertz. | +| 14 |*`cudaDevAttrTextureAlignment`* | | Alignment requirement for textures. | +| 15 |*`cudaDevAttrGpuOverlap`* | | Device can possibly copy memory and execute a kernel concurrently. | +| 16 |*`cudaDevAttrMultiProcessorCount`* |*`hipDeviceAttributeMultiprocessorCount`* | Number of multiprocessors on device. | +| 17 |*`cudaDevAttrKernelExecTimeout`* | | Specifies whether there is a run time limit on kernels. | +| 18 |*`cudaDevAttrIntegrated`* | | Device is integrated with host memory. | +| 19 |*`cudaDevAttrCanMapHostMemory`* | | Device can map host memory into CUDA address space. | +| 20 |*`cudaDevAttrComputeMode`* |*`hipDeviceAttributeComputeMode`* | Compute mode (See cudaComputeMode for details). | +| 21 |*`cudaDevAttrMaxTexture1DWidth`* | | Maximum 1D texture width. | +| 22 |*`cudaDevAttrMaxTexture2DWidth`* | | Maximum 2D texture width. | +| 23 |*`cudaDevAttrMaxTexture2DHeight`* | | Maximum 2D texture height. | +| 24 |*`cudaDevAttrMaxTexture3DWidth`* | | Maximum 3D texture width. | +| 25 |*`cudaDevAttrMaxTexture3DHeight`* | | Maximum 3D texture height. | +| 26 |*`cudaDevAttrMaxTexture3DDepth`* | | Maximum 3D texture depth. | +| 27 |*`cudaDevAttrMaxTexture2DLayeredWidth`* | | Maximum 2D layered texture width. | +| 28 |*`cudaDevAttrMaxTexture2DLayeredHeight`* | | Maximum 2D layered texture height. | +| 29 |*`cudaDevAttrMaxTexture2DLayeredLayers`* | | Maximum layers in a 2D layered texture. | +| 30 |*`cudaDevAttrSurfaceAlignment`* | | Alignment requirement for surfaces. | +| 31 |*`cudaDevAttrConcurrentKernels`* |*`hipDeviceAttributeConcurrentKernels`* | Device can possibly execute multiple kernels concurrently. | +| 32 |*`cudaDevAttrEccEnabled`* | | Device has ECC support enabled. | +| 33 |*`cudaDevAttrPciBusId`* |*`hipDeviceAttributePciBusId`* | PCI bus ID of the device. | +| 34 |*`cudaDevAttrPciDeviceId`* |*`hipDeviceAttributePciDeviceId`* | PCI device ID of the device. | +| 35 |*`cudaDevAttrTccDriver`* | | Device is using TCC driver model. | +| 36 |*`cudaDevAttrMemoryClockRate`* |*`hipDeviceAttributeMemoryClockRate`* | Peak memory clock frequency in kilohertz. | +| 37 |*`cudaDevAttrGlobalMemoryBusWidth`* |*`hipDeviceAttributeMemoryBusWidth`* | Global memory bus width in bits. | +| 38 |*`cudaDevAttrL2CacheSize`* |*`hipDeviceAttributeL2CacheSize`* | Size of L2 cache in bytes. | +| 39 |*`cudaDevAttrMaxThreadsPerMultiProcessor`* |*`hipDeviceAttributeMaxThreadsPerMultiProcessor`* | Maximum resident threads per multiprocessor. | +| 40 |*`cudaDevAttrAsyncEngineCount`* | | Number of asynchronous engines. | +| 41 |*`cudaDevAttrUnifiedAddressing`* | | Device shares a unified address space with the host. | +| 42 |*`cudaDevAttrMaxTexture1DLayeredWidth`* | | Maximum 1D layered texture width. | +| 43 |*`cudaDevAttrMaxTexture1DLayeredLayers`* | | Maximum layers in a 1D layered texture. | +| 44 | | | *reserved* | +| 45 |*`cudaDevAttrMaxTexture2DGatherWidth`* | | Maximum 2D texture width if cudaArrayTextureGather is set. | +| 46 |*`cudaDevAttrMaxTexture2DGatherHeight`* | | Maximum 2D texture height if cudaArrayTextureGather is set. | +| 47 |*`cudaDevAttrMaxTexture3DWidthAlt`* | | Alternate maximum 3D texture width. | +| 48 |*`cudaDevAttrMaxTexture3DHeightAlt`* | | Alternate maximum 3D texture height. | +| 49 |*`cudaDevAttrMaxTexture3DDepthAlt`* | | Alternate maximum 3D texture depth. | +| 50 |*`cudaDevAttrPciDomainId`* | | PCI domain ID of the device. | +| 51 |*`cudaDevAttrTexturePitchAlignment`* | | Pitch alignment requirement for textures. | +| 52 |*`cudaDevAttrMaxTextureCubemapWidth`* | | Maximum cubemap texture width/height. | +| 53 |*`cudaDevAttrMaxTextureCubemapLayeredWidth`* | | Maximum cubemap layered texture width/height. | +| 54 |*`cudaDevAttrMaxTextureCubemapLayeredLayers`* | | Maximum layers in a cubemap layered texture. | +| 55 |*`cudaDevAttrMaxSurface1DWidth`* | | Maximum 1D surface width. | +| 56 |*`cudaDevAttrMaxSurface2DWidth`* | | Maximum 2D surface width. | +| 57 |*`cudaDevAttrMaxSurface2DHeight`* | | Maximum 2D surface height. | +| 58 |*`cudaDevAttrMaxSurface3DWidth`* | | Maximum 3D surface width. | +| 59 |*`cudaDevAttrMaxSurface3DHeight`* | | Maximum 3D surface height. | +| 60 |*`cudaDevAttrMaxSurface3DDepth`* | | Maximum 3D surface depth. | +| 61 |*`cudaDevAttrMaxSurface1DLayeredWidth`* | | Maximum 1D layered surface width. | +| 62 |*`cudaDevAttrMaxSurface1DLayeredLayers`* | | Maximum layers in a 1D layered surface. | +| 63 |*`cudaDevAttrMaxSurface2DLayeredWidth`* | | Maximum 2D layered surface width. | +| 64 |*`cudaDevAttrMaxSurface2DLayeredHeight`* | | Maximum 2D layered surface height. | +| 65 |*`cudaDevAttrMaxSurface2DLayeredLayers`* | | Maximum layers in a 2D layered surface. | +| 66 |*`cudaDevAttrMaxSurfaceCubemapWidth`* | | Maximum cubemap surface width. | +| 67 |*`cudaDevAttrMaxSurfaceCubemapLayeredWidth`* | | Maximum cubemap layered surface width. | +| 68 |*`cudaDevAttrMaxSurfaceCubemapLayeredLayers`* | | Maximum layers in a cubemap layered surface. | +| 69 |*`cudaDevAttrMaxTexture1DLinearWidth`* | | Maximum 1D linear texture width. | +| 70 |*`cudaDevAttrMaxTexture2DLinearWidth`* | | Maximum 2D linear texture width. | +| 71 |*`cudaDevAttrMaxTexture2DLinearHeight`* | | Maximum 2D linear texture height. | +| 72 |*`cudaDevAttrMaxTexture2DLinearPitch`* | | Maximum 2D linear texture pitch in bytes. | +| 73 |*`cudaDevAttrMaxTexture2DMipmappedWidth`* | | Maximum mipmapped 2D texture width. | +| 74 |*`cudaDevAttrMaxTexture2DMipmappedHeight`* | | Maximum mipmapped 2D texture height. | +| 75 |*`cudaDevAttrComputeCapabilityMajor`* |*`hipDeviceAttributeComputeCapabilityMajor`* | Major compute capability version number. | +| 76 |*`cudaDevAttrComputeCapabilityMinor`* |*`hipDeviceAttributeComputeCapabilityMinor`* | Minor compute capability version number. | +| 77 |*`cudaDevAttrMaxTexture1DMipmappedWidth`* | | Maximum mipmapped 1D texture width. | +| 78 |*`cudaDevAttrStreamPrioritiesSupported`* | | Device supports stream priorities. | +| 79 |*`cudaDevAttrGlobalL1CacheSupported`* | | Device supports caching globals in L1. | +| 80 |*`cudaDevAttrLocalL1CacheSupported`* | | Device supports caching locals in L1. | +| 81 |*`cudaDevAttrMaxSharedMemoryPerMultiprocessor`*|*`hipDeviceAttributeMaxSharedMemoryPerMultiprocessor`*| Maximum shared memory available per multiprocessor in bytes. | +| 82 |*`cudaDevAttrMaxRegistersPerMultiprocessor`* | | Maximum number of 32-bit registers available per multiprocessor. | +| 83 |*`cudaDevAttrManagedMemory`* | | Device can allocate managed memory on this system. | +| 84 |*`cudaDevAttrIsMultiGpuBoard`* |*`hipDeviceAttributeIsMultiGpuBoard`* | Device is on a multi-GPU board. | +| 85 |*`cudaDevAttrMultiGpuBoardGroupID`* | | Unique identifier for a group of devices on the same multi-GPU board. | +| enum |***`cudaError`*** |***`hipError_t`*** | CUDA Error types. | +| enum |***`cudaError_t`*** |***`hipError_t`*** | CUDA Error types. | +| 0 |*`cudaSuccess`* |*`hipSuccess`* | The API call returned with no errors. In the case of query calls, this can also mean that the operation being queried is complete.| +| 1 |*`cudaErrorMissingConfiguration`* | | The device function being invoked (usually via cudaLaunchKernel()) was not previously configured via the cudaConfigureCall() function.| +| 2 |*`cudaErrorMemoryAllocation`* |*`hipErrorMemoryAllocation`* | The API call failed because it was unable to allocate enough memory to perform the requested operation. | +| 3 |*`cudaErrorInitializationError`* |*`hipErrorInitializationError`* | The API call failed because the CUDA driver and runtime could not be initialized. | +| 4 |*`cudaErrorLaunchFailure`* | | An exception occurred on the device while executing a kernel. Common causes include dereferencing an invalid device pointer and accessing out of bounds shared memory. The device cannot be used until cudaThreadExit() is called. All existing device memory allocations are invalid and must be reconstructed if the program is to continue using CUDA. | +| 5 |*`cudaErrorPriorLaunchFailure`* | | This indicated that a previous kernel launch failed. This was previously used for device emulation of kernel launches. Deprecated This error return is deprecated as of CUDA 3.1. Device emulation mode was removed with the CUDA 3.1 release.| +| 6 |*`cudaErrorLaunchTimeout`* | | This indicates that the device kernel took too long to execute. This can only occur if timeouts are enabled - see the device property kernelExecTimeoutEnabled for more information. The device cannot be used until cudaThreadExit() is called. All existing device memory allocations are invalid and must be reconstructed if the program is to continue using CUDA.| +| 7 |*`cudaErrorLaunchOutOfResources`* |*`hipErrorLaunchOutOfResources`* | This indicates that a launch did not occur because it did not have appropriate resources. Although this error is similar to cudaErrorInvalidConfiguration, this error usually indicates that the user has attempted to pass too many arguments to the device kernel, or the kernel launch specifies too many threads for the kernel's register count.| +| 8 |*`cudaErrorInvalidDeviceFunction`* | | The requested device function does not exist or is not compiled for the proper device architecture. | +| 9 |*`cudaErrorInvalidConfiguration`* | | This indicates that a kernel launch is requesting resources that can never be satisfied by the current device. Requesting more shared memory per block than the device supports will trigger this error, as will requesting too many threads or blocks. See cudaDeviceProp for more device limitations.| +| 10 |*`cudaErrorInvalidDevice`* |*`hipErrorInvalidDevice`* | This indicates that the device ordinal supplied by the user does not correspond to a valid CUDA device. | +| 11 |*`cudaErrorInvalidValue`* |*`hipErrorInvalidValue`* | This indicates that one or more of the parameters passed to the API call is not within an acceptable range of values. | +| 12 |*`cudaErrorInvalidPitchValue`* | | This indicates that one or more of the pitch-related parameters passed to the API call is not within the acceptable range for pitch.| +| 13 |*`cudaErrorInvalidSymbol`* | | This indicates that the symbol name/identifier passed to the API call is not a valid name or identifier. | +| 14 |*`cudaErrorMapBufferObjectFailed`* | | This indicates that the buffer object could not be mapped. | +| 15 |*`cudaErrorUnmapBufferObjectFailed`* | | This indicates that the buffer object could not be unmapped. | +| 16 |*`cudaErrorInvalidHostPointer`* | | This indicates that at least one host pointer passed to the API call is not a valid host pointer. | +| 17 |*`cudaErrorInvalidDevicePointer`* |*`hipErrorInvalidDevicePointer`* | This indicates that at least one host pointer passed to the API call is not a valid host pointer. | +| 18 |*`cudaErrorInvalidTexture`* | | This indicates that the texture passed to the API call is not a valid texture. | +| 19 |*`cudaErrorInvalidTextureBinding`* | | This indicates that the texture binding is not valid. This occurs if you call cudaGetTextureAlignmentOffset() with an unbound texture.| +| 20 |*`cudaErrorInvalidChannelDescriptor`* | | This indicates that the channel descriptor passed to the API call is not valid. This occurs if the format is not one of the formats specified by cudaChannelFormatKind, or if one of the dimensions is invalid.| +| 21 |*`cudaErrorInvalidMemcpyDirection`* | | This indicates that the direction of the memcpy passed to the API call is not one of the types specified by cudaMemcpyKind. | +| 22 |*`cudaErrorAddressOfConstant`* | | This indicated that the user has taken the address of a constant variable, which was forbidden up until the CUDA 3.1 release. Deprecated This error return is deprecated as of CUDA 3.1. Variables in constant memory may now have their address taken by the runtime via cudaGetSymbolAddress().| +| 23 |*`cudaErrorTextureFetchFailed`* | | This indicated that a texture fetch was not able to be performed. This was previously used for device emulation of texture operations. Deprecated This error return is deprecated as of CUDA 3.1. Device emulation mode was removed with the CUDA 3.1 release.| +| 24 |*`cudaErrorTextureNotBound`* | | This indicated that a texture was not bound for access. This was previously used for device emulation of texture operations. Deprecated This error return is deprecated as of CUDA 3.1. Device emulation mode was removed with the CUDA 3.1 release.| +| 25 |*`cudaErrorSynchronizationError`* | | This indicated that a synchronization operation had failed. This was previously used for some device emulation functions. Deprecated This error return is deprecated as of CUDA 3.1. Device emulation mode was removed with the CUDA 3.1 release.| +| 26 |*`cudaErrorInvalidFilterSetting`* | | This indicates that a non-float texture was being accessed with linear filtering. This is not supported by CUDA. | +| 27 |*`cudaErrorInvalidNormSetting`* | | This indicates that an attempt was made to read a non-float texture as a normalized float. This is not supported by CUDA. | +| 28 |*`cudaErrorMixedDeviceExecution`* | | Mixing of device and device emulation code was not allowed. Deprecated This error return is deprecated as of CUDA 3.1. Device emulation mode was removed with the CUDA 3.1 release.| +| 29 |*`cudaErrorCudartUnloading`* | | This indicates that a CUDA Runtime API call cannot be executed because it is being called during process shut down, at a point in time after CUDA driver has been unloaded.| +| 30 |*`cudaErrorUnknown`* |*`hipErrorUnknown`* | This indicates that an unknown internal error has occurred. | +| 31 |*`cudaErrorNotYetImplemented`* | | This indicates that the API call is not yet implemented. Production releases of CUDA will never return this error. Deprecated This error return is deprecated as of CUDA 4.1.| +| 32 |*`cudaErrorMemoryValueTooLarge`* | | This indicated that an emulated device pointer exceeded the 32-bit address range. Deprecated This error return is deprecated as of CUDA 3.1. Device emulation mode was removed with the CUDA 3.1 release.| +| 33 |*`cudaErrorInvalidResourceHandle`* |*`hipErrorInvalidResourceHandle`* | This indicates that a resource handle passed to the API call was not valid. Resource handles are opaque types like cudaStream_t and cudaEvent_t.| +| 34 |*`cudaErrorNotReady`* |*`hipErrorNotReady`* | This indicates that asynchronous operations issued previously have not completed yet. This result is not actually an error, but must be indicated differently than cudaSuccess (which indicates completion). Calls that may return this value include cudaEventQuery() and cudaStreamQuery().| +| 35 |*`cudaErrorInsufficientDriver`* | | This indicates that the installed NVIDIA CUDA driver is older than the CUDA runtime library. This is not a supported configuration. Users should install an updated NVIDIA display driver to allow the application to run.| +| 36 |*`cudaErrorSetOnActiveProcess`* | | This indicates that the user has called cudaSetValidDevices(), cudaSetDeviceFlags(), cudaD3D9SetDirect3DDevice(), cudaD3D10SetDirect3DDevice, cudaD3D11SetDirect3DDevice(), or cudaVDPAUSetVDPAUDevice() after initializing the CUDA runtime by calling non-device management operations (allocating memory and launching kernels are examples of non-device management operations). This error can also be returned if using runtime/driver interoperability and there is an existing CUcontext active on the host thread.| +| 37 |*`cudaErrorInvalidSurface`* | | This indicates that the surface passed to the API call is not a valid surface. | +| 38 |*`cudaErrorNoDevice`* |*`hipErrorNoDevice`* | This indicates that no CUDA-capable devices were detected by the installed CUDA driver. | +| 39 |*`cudaErrorECCUncorrectable`* | | This indicates that an uncorrectable ECC error was detected during execution. | +| 40 |*`cudaErrorSharedObjectSymbolNotFound`* | | This indicates that a link to a shared object failed to resolve. | +| 41 |*`cudaErrorSharedObjectInitFailed`* | | This indicates that initialization of a shared object failed. | +| 42 |*`cudaErrorUnsupportedLimit`* |*`hipErrorUnsupportedLimit`* | This indicates that the cudaLimit passed to the API call is not supported by the active device. | +| 43 |*`cudaErrorDuplicateVariableName`* | | This indicates that multiple global or constant variables (across separate CUDA source files in the application) share the same string name.| +| 44 |*`cudaErrorDuplicateTextureName`* | | This indicates that multiple textures (across separate CUDA source files in the application) share the same string name. | +| 45 |*`cudaErrorDuplicateSurfaceName`* | | This indicates that multiple surfaces (across separate CUDA source files in the application) share the same string name. | +| 46 |*`cudaErrorDevicesUnavailable`* | | This indicates that all CUDA devices are busy or unavailable at the current time. Devices are often busy/unavailable due to use of cudaComputeModeExclusive, cudaComputeModeProhibited or when long running CUDA kernels have filled up the GPU and are blocking new work from starting. They can also be unavailable due to memory constraints on a device that already has active CUDA work being performed.| +| 47 |*`cudaErrorInvalidKernelImage`* | | This indicates that the device kernel image is invalid. | +| 48 |*`cudaErrorNoKernelImageForDevice`* | | This indicates that there is no kernel image available that is suitable for the device. This can occur when a user specifies code generation options for a particular CUDA source file that do not include the corresponding device configuration.| +| 49 |*`cudaErrorIncompatibleDriverContext`* | | This indicates that the current context is not compatible with this the CUDA Runtime. This can only occur if you are using CUDA Runtime/Driver interoperability and have created an existing Driver context using the driver API. The Driver context may be incompatible either because the Driver context was created using an older version of the API, because the Runtime API call expects a primary driver context and the Driver context is not primary, or because the Driver context has been destroyed. Please see Interactions with the CUDA Driver API" for more information.| +| 50 |*`cudaErrorPeerAccessAlreadyEnabled`* |*`hipErrorPeerAccessAlreadyEnabled`* | This error indicates that a call to cudaDeviceEnablePeerAccess() is trying to re-enable peer addressing on from a context which has already had peer addressing enabled.| +| 51 |*`cudaErrorPeerAccessNotEnabled`* |*`hipErrorPeerAccessNotEnabled`* | This error indicates that a call to cudaDeviceEnablePeerAccess() is trying to re-enable peer addressing on from a context which has already had peer addressing enabled.| +| 52 | | | *reserved* | +| 53 | | | *reserved* | +| 54 |*`cudaErrorDeviceAlreadyInUse`* | | This indicates that a call tried to access an exclusive-thread device that is already in use by a different thread. | +| 55 |*`cudaErrorProfilerDisabled`* | | This indicates profiler is not initialized for this run. This can happen when the application is running with external profiling tools like visual profiler.| +| 56 |*`cudaErrorProfilerNotInitialized`* | | Deprecated This error return is deprecated as of CUDA 5.0. It is no longer an error to attempt to enable/disable the profiling via cudaProfilerStart or cudaProfilerStop without initialization.| +| 57 |*`cudaErrorProfilerAlreadyStarted`* | | Deprecated This error return is deprecated as of CUDA 5.0. It is no longer an error to call cudaProfilerStart() when profiling is already enabled.| +| 58 |*`cudaErrorProfilerAlreadyStopped`* | | Deprecated This error return is deprecated as of CUDA 5.0. It is no longer an error to call cudaProfilerStop() when profiling is already disabled.| +| 59 |*`cudaErrorAssert`* | | An assert triggered in device code during kernel execution. The device cannot be used again until cudaThreadExit() is called. All existing allocations are invalid and must be reconstructed if the program is to continue using CUDA.| +| 60 |*`cudaErrorTooManyPeers`* | | This error indicates that the hardware resources required to enable peer access have been exhausted for one or more of the devices passed to cudaEnablePeerAccess().| +| 61 |*`cudaErrorHostMemoryAlreadyRegistered`* | *`hipErrorHostMemoryAlreadyRegistered`* | This error indicates that the memory range passed to cudaHostRegister() has already been registered. | +| 62 |*`cudaErrorHostMemoryNotRegistered`* | *`hipErrorHostMemoryNotRegistered`* | This error indicates that the pointer passed to cudaHostUnregister() does not correspond to any currently registered memory region.| +| 63 |*`cudaErrorOperatingSystem`* | | This error indicates that an OS call failed. | +| 64 |*`cudaErrorPeerAccessUnsupported`* | | This error indicates that P2P access is not supported across the given devices. | +| 65 |*`cudaErrorLaunchMaxDepthExceeded`* | | This error indicates that a device runtime grid launch did not occur because the depth of the child grid would exceed the maximum supported number of nested grid launches.| +| 66 |*`cudaErrorLaunchFileScopedTex`* | | This error indicates that a grid launch did not occur because the kernel uses filescoped textures which are unsupported by the device runtime. Kernels launched via the device runtime only support textures created with the Texture Object API's.| +| 67 |*`cudaErrorLaunchFileScopedSurf`* | | This error indicates that a grid launch did not occur because the kernel uses filescoped surfaces which are unsupported by the device runtime. Kernels launched via the device runtime only support surfaces created with the Surface Object API's.| +| 68 |*`cudaErrorSyncDepthExceeded`* | | This error indicates that a call to cudaDeviceSynchronize made from the device runtime failed because the call was made at grid depth greater than than either the default (2 levels of grids) or user specified device limit cudaLimitDevRuntimeSyncDepth. To be able to synchronize on launched grids at a greater depth successfully, the maximum nested depth at which cudaDeviceSynchronize will be called must be specified with the cudaLimitDevRuntimeSyncDepth limit to the cudaDeviceSetLimit api before the host-side launch of a kernel using the device runtime. Keep in mind that additional levels of sync depth require the runtime to reserve large amounts of device memory that cannot be used for user allocations.| +| 69 |*`cudaErrorLaunchPendingCountExceeded`* | | This error indicates that a device runtime grid launch failed because the launch would exceed the limit cudaLimitDevRuntimePendingLaunchCount. For this launch to proceed successfully, cudaDeviceSetLimit must be called to set the cudaLimitDevRuntimePendingLaunchCount to be higher than the upper bound of outstanding launches that can be issued to the device runtime. Keep in mind that raising the limit of pending device runtime launches will require the runtime to reserve device memory that cannot be used for user allocations.| +| 70 |*`cudaErrorNotPermitted`* | | This error indicates the attempted operation is not permitted. | +| 71 |*`cudaErrorNotSupported`* | | This error indicates the attempted operation is not supported on the current system or device. | +| 72 |*`cudaErrorHardwareStackError`* | | Device encountered an error in the call stack during kernel execution, possibly due to stack corruption or exceeding the stack size limit. The context cannot be used, so it must be destroyed (and a new one should be created). All existing device memory allocations from this context are invalid and must be reconstructed if the program is to continue using CUDA.| +| 73 |*`cudaErrorIllegalInstruction`* | | The device encountered an illegal instruction during kernel execution The context cannot be used, so it must be destroyed (and a new one should be created). All existing device memory allocations from this context are invalid and must be reconstructed if the program is to continue using CUDA.| +| 74 |*`cudaErrorMisalignedAddress`* | | The device encountered a load or store instruction on a memory address which is not aligned. The context cannot be used, so it must be destroyed (and a new one should be created). All existing device memory allocations from this context are invalid and must be reconstructed if the program is to continue using CUDA.| +| 75 |*`cudaErrorInvalidAddressSpace`* | | While executing a kernel, the device encountered an instruction which can only operate on memory locations in certain address spaces (global, shared, or local), but was supplied a memory address not belonging to an allowed address space. The context cannot be used, so it must be destroyed (and a new one should be created). All existing device memory allocations from this context are invalid and must be reconstructed if the program is to continue using CUDA.| +| 76 |*`cudaErrorInvalidPc`* | | The device encountered an invalid program counter. The context cannot be used, so it must be destroyed (and a new one should be created). All existing device memory allocations from this context are invalid and must be reconstructed if the program is to continue using CUDA.| +| 77 |*`cudaErrorIllegalAddress`* | | The device encountered a load or store instruction on an invalid memory address. The context cannot be used, so it must be destroyed (and a new one should be created). All existing device memory allocations from this context are invalid and must be reconstructed if the program is to continue using CUDA.| +| 78 |*`cudaErrorInvalidPtx`* | | A PTX compilation failed. The runtime may fall back to compiling PTX if an application does not contain a suitable binary for the current device.| +| 79 |*`cudaErrorInvalidGraphicsContext`* | | This indicates an error with the OpenGL or DirectX context. | +| 0x7f |*`cudaErrorStartupFailure`* | | This indicates an internal startup failure in the CUDA runtime. | +| 1000 |*`cudaErrorApiFailureBase`* | | Any unhandled CUDA driver error is added to this value and returned via the runtime. Production releases of CUDA should not return such errors. Deprecated This error return is deprecated as of CUDA 4.1.| +| enum |***`cudaFuncCache`*** |***`hipFuncCache_t`*** | CUDA function cache configurations. | +| 0 |*`cudaFuncCachePreferNone`* |*`hipFuncCachePreferNone`* | Default function cache configuration, no preference. | +| 1 |*`cudaFuncCachePreferShared`* |*`hipFuncCachePreferShared`* | Prefer larger shared memory and smaller L1 cache. | +| 2 |*`cudaFuncCachePreferL1`* |*`hipFuncCachePreferL1`* | Prefer larger L1 cache and smaller shared memory. | +| 3 |*`cudaFuncCachePreferEqual`* |*`hipFuncCachePreferEqual`* | Prefer equal size L1 cache and shared memory. | +| enum |***`cudaGraphicsCubeFace`*** | | CUDA graphics interop array indices for cube maps. | +| 0x00 |*`cudaGraphicsCubeFacePositiveX`* | | Positive X face of cubemap. | +| 0x01 |*`cudaGraphicsCubeFaceNegativeX`* | | Negative X face of cubemap. | +| 0x02 |*`cudaGraphicsCubeFacePositiveY`* | | Positive Y face of cubemap. | +| 0x03 |*`cudaGraphicsCubeFaceNegativeY`* | | Negative Y face of cubemap. | +| 0x04 |*`cudaGraphicsCubeFacePositiveZ`* | | Positive Z face of cubemap. | +| 0x05 |*`cudaGraphicsCubeFaceNegativeZ`* | | Negative Z face of cubemap. | +| enum |***`cudaGraphicsMapFlags`*** | | CUDA graphics interop map flags. | +| 0 |*`cudaGraphicsMapFlagsNone`* | | Default; Assume resource can be read/written. | +| 1 |*`cudaGraphicsMapFlagsReadOnly`* | | CUDA will not write to this resource. | +| 2 |*`cudaGraphicsMapFlagsWriteDiscard`* | | CUDA will only write to and will not read from this resource. | +| enum |***`cudaGraphicsRegisterFlags`*** | | CUDA graphics interop register flags. | +| 0 |*`cudaGraphicsRegisterFlagsNone`* | | Default. | +| 1 |*`cudaGraphicsRegisterFlagsReadOnly`* | | CUDA will not write to this resource. | +| 2 |*`cudaGraphicsRegisterFlagsWriteDiscard`* | | CUDA will only write to and will not read from this resource. | +| 4 |*`cudaGraphicsRegisterFlagsSurfaceLoadStore`* | | CUDA will bind this resource to a surface reference. | +| 8 |*`cudaGraphicsRegisterFlagsTextureGather`* | | CUDA will perform texture gather operations on this resource. | +| enum |***`cudaLimit`*** |***`hipLimit_t`*** | CUDA Limits. | +| 0x00 |*`cudaLimitStackSize`* | | GPU thread stack size. | +| 0x01 |*`cudaLimitPrintfFifoSize`* | | GPU printf/fprintf FIFO size. | +| 0x02 |*`cudaLimitMallocHeapSize`* |*`hipLimitMallocHeapSize`* | GPU malloc heap size. | +| 0x03 |*`cudaLimitDevRuntimeSyncDepth`* | | GPU device runtime synchronize depth. | +| 0x04 |*`cudaLimitDevRuntimePendingLaunchCount`* | | GPU device runtime pending launch count. | +| enum |***`cudaMemcpyKind`*** |***`hipMemcpyKind`*** | CUDA memory copy types. | +| 0 |*`cudaMemcpyHostToHost`* |*`hipMemcpyHostToHost`* | Host -> Host. | +| 1 |*`cudaMemcpyHostToDevice`* |*`hipMemcpyHostToDevice`* | Host -> Device. | +| 2 |*`cudaMemcpyDeviceToHost`* |*`hipMemcpyDeviceToHost`* | Device -> Host. | +| 3 |*`cudaMemcpyDeviceToDevice`* |*`hipMemcpyDeviceToDevice`* | Device -> Device. | +| 4 |*`cudaMemcpyDefault`* |*`hipMemcpyDefault`* | Default based unified virtual address space. | +| enum |***`cudaMemoryType`*** |***`hipMemoryType`*** | CUDA memory types. | +| 1 |*`cudaMemoryTypeHost`* |*`hipMemoryTypeHost`* | Host memory. | +| 2 |*`cudaMemoryTypeDevice`* |*`hipMemoryTypeDevice`* | Device memory. | +| enum |***`cudaResourceType`*** | | CUDA resource types. | +| 0 |*`cudaResourceTypeArray`* | | Array resource. | +| 1 |*`cudaResourceTypeMipmappedArray`* | | Mipmapped array resource. | +| 2 |*`cudaResourceTypeLinear`* | | Linear resource. | +| 3 |*`cudaResourceTypePitch2D`* | | Pitch 2D resource. | +| enum |***`cudaResourceViewFormat`*** | | CUDA texture resource view formats. | +| 0x00 |*`cudaResViewFormatNone`* | | No resource view format (use underlying resource format). | +| 0x01 |*`cudaResViewFormatUnsignedChar1`* | | 1 channel unsigned 8-bit integers. | +| 0x02 |*`cudaResViewFormatUnsignedChar2`* | | 2 channel unsigned 8-bit integers. | +| 0x03 |*`cudaResViewFormatUnsignedChar4`* | | 4 channel unsigned 8-bit integers. | +| 0x04 |*`cudaResViewFormatSignedChar1`* | | 1 channel signed 8-bit integers. | +| 0x05 |*`cudaResViewFormatSignedChar2`* | | 2 channel signed 8-bit integers. | +| 0x06 |*`cudaResViewFormatSignedChar4`* | | 4 channel signed 8-bit integers. | +| 0x07 |*`cudaResViewFormatUnsignedShort1`* | | 1 channel unsigned 16-bit integers. | +| 0x08 |*`cudaResViewFormatUnsignedShort2`* | | 2 channel unsigned 16-bit integers. | +| 0x09 |*`cudaResViewFormatUnsignedShort4`* | | 4 channel unsigned 16-bit integers. | +| 0x0a |*`cudaResViewFormatSignedShort1`* | | 1 channel signed 16-bit integers. | +| 0x0b |*`cudaResViewFormatSignedShort2`* | | 2 channel signed 16-bit integers. | +| 0x0c |*`cudaResViewFormatSignedShort4`* | | 4 channel signed 16-bit integers. | +| 0x0d |*`cudaResViewFormatUnsignedInt1`* | | 1 channel unsigned 32-bit integers. | +| 0x0e |*`cudaResViewFormatUnsignedInt2`* | | 2 channel unsigned 32-bit integers. | +| 0x0f |*`cudaResViewFormatUnsignedInt4`* | | 4 channel unsigned 32-bit integers. | +| 0x10 |*`cudaResViewFormatSignedInt1`* | | 1 channel signed 32-bit integers. | +| 0x11 |*`cudaResViewFormatSignedInt2`* | | 2 channel signed 32-bit integers. | +| 0x12 |*`cudaResViewFormatSignedInt4`* | | 4 channel signed 32-bit integers. | +| 0x13 |*`cudaResViewFormatHalf1`* | | 1 channel 16-bit floating point. | +| 0x14 |*`cudaResViewFormatHalf2`* | | 2 channel 16-bit floating point. | +| 0x15 |*`cudaResViewFormatHalf4`* | | 4 channel 16-bit floating point. | +| 0x16 |*`cudaResViewFormatFloat1`* | | 1 channel 32-bit floating point. | +| 0x17 |*`cudaResViewFormatFloat2`* | | 2 channel 32-bit floating point. | +| 0x18 |*`cudaResViewFormatFloat4`* | | 4 channel 32-bit floating point. | +| 0x19 |*`cudaResViewFormatUnsignedBlockCompressed1`* | | Block compressed 1. | +| 0x1a |*`cudaResViewFormatUnsignedBlockCompressed2`* | | Block compressed 2. | +| 0x1b |*`cudaResViewFormatUnsignedBlockCompressed3`* | | Block compressed 3. | +| 0x1c |*`cudaResViewFormatUnsignedBlockCompressed4`* | | Block compressed 4 unsigned. | +| 0x1d |*`cudaResViewFormatSignedBlockCompressed4`* | | Block compressed 4 signed. | +| 0x1e |*`cudaResViewFormatUnsignedBlockCompressed5`* | | Block compressed 5 unsigned. | +| 0x1f |*`cudaResViewFormatSignedBlockCompressed5`* | | Block compressed 5 signed. | +| 0x20 |*`cudaResViewFormatUnsignedBlockCompressed6H`* | | Block compressed 6 unsigned half-float. | +| 0x21 |*`cudaResViewFormatSignedBlockCompressed6H`* | | Block compressed 6 signed half-float. | +| 0x22 |*`cudaResViewFormatUnsignedBlockCompressed7`* | | Block compressed 7. | +| enum |***`cudaSharedMemConfig`*** |***`hipSharedMemConfig`*** | CUDA shared memory configuration. | +| 0 |*`cudaSharedMemBankSizeDefault`* |*`hipSharedMemBankSizeDefault`* | | +| 1 |*`cudaSharedMemBankSizeFourByte`* |*`hipSharedMemBankSizeFourByte`* | | +| 2 |*`cudaSharedMemBankSizeEightByte`* |*`hipSharedMemBankSizeEightByte`* | | +| enum |***`cudaSurfaceBoundaryMode`*** | | CUDA Surface boundary modes. | +| 0 |*`cudaBoundaryModeZero`* | | Zero boundary mode. | +| 1 |*`cudaBoundaryModeClamp`* | | Clamp boundary mode. | +| 2 |*`cudaBoundaryModeTrap`* | | Trap boundary mode. | +| enum |***`cudaSurfaceFormatMode`*** | | CUDA Surface format modes. | +| 0 |*`cudaFormatModeForced`* | | Forced format mode. | +| 1 |*`cudaFormatModeAuto`* | | Auto format mode. | +| enum |***`cudaTextureAddressMode`*** | | CUDA texture address modes. | +| 0 |*`cudaAddressModeWrap`* | | Wrapping address mode. | +| 1 |*`cudaAddressModeClamp`* | | Clamp to edge address mode. | +| 2 |*`cudaAddressModeMirror`* | | Mirror address mode. | +| 3 |*`cudaAddressModeBorder`* | | Border address mode. | +| enum |***`cudaTextureFilterMode`*** |***`hipTextureFilterMode`*** | Point filter mode. | +| 0 |*`cudaFilterModePoint`* |*`hipFilterModePoint`* | Linear filter mode. | +| 1 |*`cudaFilterModeLinear`* | | Clamp to edge address mode. | +| enum |***`cudaTextureReadMode`*** |***`hipTextureReadMode`*** | CUDA texture read modes. | +| 0 |*`cudaReadModeElementType`* |*`hipReadModeElementType`* | Read texture as specified element type. | +| 1 |*`cudaReadModeNormalizedFloat`* | | Read texture as normalized float. | +| struct | `cudaArray` | `hipArray` | CUDA array [opaque]. | +| typedef | `cudaArray_t` | `hipArray *` | CUDA array pointer. | +| typedef | `cudaArray_const_t` | `const hipArray *` | CUDA array (as source copy argument). | +| enum | `cudaError` | `hipError_t` | CUDA Error types. | +| typedef | `cudaError_t` | `hipError_t` | CUDA Error types. | +| typedef | `cudaEvent_t` | `hipEvent_t` | CUDA event types. | +| typedef | `cudaGraphicsResource_t` | | CUDA graphics resource types. | +| typedef | `cudaMipmappedArray_t` | | CUDA mipmapped array. | +| typedef | `cudaMipmappedArray_const_t` | | CUDA mipmapped array (as source argument). | +| enum |***`cudaOutputMode`*** | | CUDA Profiler Output modes. | +| 0x00 |*`cudaKeyValuePair`* | | Output mode Key-Value pair format. | +| 0x01 |*`cudaCSV`* | | Output mode Comma separated values format. | +| typedef | `cudaOutputMode_t` | | CUDA output file modes. | +| typedef | `cudaStream_t` | `hipStream_t` | CUDA stream. | +| typedef | `cudaSurfaceObject_t` | | An opaque value that represents a CUDA Surface object. | +| typedef | `cudaTextureObject_t` | | An opaque value that represents a CUDA texture object. | +| typedef | `CUuuid_stcudaUUID_t` | | CUDA UUID types. | +| define | `CUDA_IPC_HANDLE_SIZE` | | CUDA IPC Handle Size. | +| define | `cudaArrayCubemap` | | Must be set in cudaMalloc3DArray to create a cubemap CUDA array. | +| define | `cudaArrayDefault` | | Default CUDA array allocation flag. | +| define | `cudaArrayLayered` | | Must be set in cudaMalloc3DArray to create a layered CUDA array. | +| define | `cudaArraySurfaceLoadStore` | | Must be set in cudaMallocArray or cudaMalloc3DArray in order to bind surfaces to the CUDA array. | +| define | `cudaArrayTextureGather` | | Must be set in cudaMallocArray or cudaMalloc3DArray in order to perform texture gather operations on the CUDA array. | +| define | `cudaDeviceBlockingSync` | `hipDeviceScheduleBlockingSync` | Device flag - Use blocking synchronization. Deprecated as of CUDA 4.0 and replaced with cudaDeviceScheduleBlockingSync. | +| define | `cudaDeviceLmemResizeToMax` | | Device flag - Keep local memory allocation after launch. | +| define | `cudaDeviceMapHost` | | Device flag - Support mapped pinned allocations. | +| define | `cudaDeviceMask` | | Device flags mask. | +| define | `cudaDevicePropDontCare` | | Empty device properties. | +| define | `cudaDeviceScheduleAuto` | `hipDeviceScheduleAuto` | Device flag - Automatic scheduling. | +| define | `cudaDeviceScheduleBlockingSync` | `hipDeviceScheduleBlockingSync` | Device flag - Use blocking synchronization. | +| define | `cudaDeviceScheduleMask` | `hipDeviceScheduleMask` | Device schedule flags mask. | +| define | `cudaDeviceScheduleSpin` | `hipDeviceScheduleSpin` | Device flag - Spin default scheduling. | +| define | `cudaDeviceScheduleYield` | `hipDeviceScheduleYield` | Device flag - Yield default scheduling. | +| define | `cudaEventDefault` | `hipEventDefault` | Default event flag. | +| define | `cudaEventDisableTiming` | `hipEventDisableTiming` | Event will not record timing data. | +| define | `cudaEventInterprocess` | `hipEventInterprocess` | Event is suitable for interprocess use. cudaEventDisableTiming must be set. | +| define | `cudaHostAllocDefault` | `hipHostMallocDefault` | Default page-locked allocation flag. | +| define | `cudaHostAllocMapped` | `hipHostMallocMapped` | Map allocation into device space. | +| define | `cudaHostAllocPortable` | `hipHostMallocPortable` | Pinned memory accessible by all CUDA contexts. | +| define | `cudaHostAllocWriteCombined` | `hipHostMallocWriteCombined` | Write-combined memory. | +| define | `cudaHostRegisterDefault` | `hipHostRegisterDefault` | Default host memory registration flag. | +| define | `cudaHostRegisterIoMemory` | `hipHostRegisterIoMemory` | Memory-mapped I/O space. | +| define | `cudaHostRegisterMapped` | `hipHostRegisterMapped` | Map registered memory into device space. | +| define | `cudaHostRegisterPortable` | `hipHostRegisterPortable` | Pinned memory accessible by all CUDA contexts. | +| define | `cudaIpcMemLazyEnablePeerAccess` | `hipIpcMemLazyEnablePeerAccess` | Automatically enable peer access between remote devices as needed. | +| define | `cudaMemAttachGlobal` | | Memory can be accessed by any stream on any device. | +| define | `cudaMemAttachHost` | | Memory cannot be accessed by any stream on any device. | +| define | `cudaMemAttachSingle` | | Memory can only be accessed by a single stream on the associated device. | +| define | `cudaOccupancyDefault` | | Default behavior. | +| define | `cudaOccupancyDisableCachingOverride` | | Assume global caching is enabled and cannot be automatically turned off. | +| define | `cudaPeerAccessDefault` | | Default peer addressing enable flag. | +| define | `cudaStreamDefault` | `hipStreamDefault` | Default stream flag. | +| define | `cudaStreamLegacy` | | Default stream flag. | +| define | `cudaStreamNonBlocking` | `hipStreamNonBlocking` | Stream does not synchronize with stream 0 (the NULL stream). | +| define | `cudaStreamPerThread` | | Per-thread stream handle. | From 6d72290788b0c9edcbee2b84c8dea623f0736249 Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Mon, 6 Mar 2017 15:32:21 +0530 Subject: [PATCH 184/281] CMakeLists: Create test targets only if HIP install location is writable Change-Id: I79f28884b0f117f2824ca8877c25b586bce62e5b [ROCm/hip commit: aca015c47de4e124af181988a7605027562873f1] --- projects/hip/CMakeLists.txt | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/projects/hip/CMakeLists.txt b/projects/hip/CMakeLists.txt index ba58cfbf20..20d0f1ff31 100644 --- a/projects/hip/CMakeLists.txt +++ b/projects/hip/CMakeLists.txt @@ -369,19 +369,26 @@ endif() # Target: test set(HIP_PATH ${CMAKE_INSTALL_PREFIX}) set(HIP_SRC_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -execute_process(COMMAND "${CMAKE_COMMAND}" -E copy_directory "${HIP_SRC_PATH}/cmake" "${HIP_PATH}/cmake") -execute_process(COMMAND "${CMAKE_COMMAND}" -E copy_directory "${HIP_SRC_PATH}/bin" "${HIP_PATH}/bin") -set(CMAKE_MODULE_PATH "${HIP_PATH}/cmake" ${CMAKE_MODULE_PATH}) -include(${HIP_SRC_PATH}/tests/hit/HIT.cmake) +execute_process(COMMAND "${CMAKE_COMMAND}" -E copy_directory "${HIP_SRC_PATH}/cmake" "${HIP_PATH}/cmake" RESULT_VARIABLE RUN_HIT ERROR_QUIET) +if(${RUN_HIT} EQUAL 0) + execute_process(COMMAND "${CMAKE_COMMAND}" -E copy_directory "${HIP_SRC_PATH}/bin" "${HIP_PATH}/bin" RESULT_VARIABLE RUN_HIT ERROR_QUIET) +endif() +if(${RUN_HIT} EQUAL 0) + set(CMAKE_MODULE_PATH "${HIP_PATH}/cmake" ${CMAKE_MODULE_PATH}) + include(${HIP_SRC_PATH}/tests/hit/HIT.cmake) -# Add tests -include_directories(${HIP_SRC_PATH}/tests/src) -hit_add_directory_recursive(${HIP_SRC_PATH}/tests/src "directed_tests") + # Add tests + include_directories(${HIP_SRC_PATH}/tests/src) + hit_add_directory_recursive(${HIP_SRC_PATH}/tests/src "directed_tests") -# Add top-level tests to build_tests -add_custom_target(build_tests DEPENDS directed_tests) + # Add top-level tests to build_tests + add_custom_target(build_tests DEPENDS directed_tests) + + # Add custom target: check + add_custom_target(check COMMAND "${CMAKE_COMMAND}" --build . --target test DEPENDS build_tests) +else() + message(STATUS "Testing targets will not be available. To enable them please ensure that the HIP installation directory is writeable. Use -DCMAKE_INSTALL_PREFIX to specify a suitable location") +endif() -# Add custom target: check -add_custom_target(check COMMAND "${CMAKE_COMMAND}" --build . --target test DEPENDS build_tests) # vim: ts=4:sw=4:expandtab:smartindent From 7d91578dcd67c8db1d1cd9df3f115abe23f8e6ce Mon Sep 17 00:00:00 2001 From: Siu Chi Chan Date: Fri, 3 Mar 2017 03:11:41 -0500 Subject: [PATCH 185/281] fix hcc version string extraction Change-Id: Ie209b6deae55c779a577aaccb1bc21f969f69e14 [ROCm/hip commit: c3126bab8a36cf282ba327a09ca0352c0512331d] --- projects/hip/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/projects/hip/CMakeLists.txt b/projects/hip/CMakeLists.txt index 20d0f1ff31..72cc2469e8 100644 --- a/projects/hip/CMakeLists.txt +++ b/projects/hip/CMakeLists.txt @@ -68,9 +68,10 @@ if(HIP_PLATFORM STREQUAL "hcc") endif() if(IS_ABSOLUTE ${HCC_HOME} AND EXISTS ${HCC_HOME} AND IS_DIRECTORY ${HCC_HOME}) execute_process(COMMAND ${HCC_HOME}/bin/hcc --version - COMMAND cut -d\ -f9 OUTPUT_VARIABLE HCC_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) + string(REGEX REPLACE ".*based on HCC " "" HCC_VERSION ${HCC_VERSION}) + string(REGEX REPLACE " .*" "" HCC_VERSION ${HCC_VERSION}) message(STATUS "Looking for HCC in: " ${HCC_HOME} ". Found version: " ${HCC_VERSION}) else() message(FATAL_ERROR "Don't know where to find HCC. Please specify abolute path using -DHCC_HOME") From c441371fefbad4775f39c971fb43ad4bcd562976 Mon Sep 17 00:00:00 2001 From: Siu Chi Chan Date: Fri, 3 Mar 2017 04:27:54 -0500 Subject: [PATCH 186/281] fix hcc version detection in hipcc Change-Id: I880be03ad67e99280a259369bfe25488bf53f0bd [ROCm/hip commit: 910df3d80f7ddf84b4a352a80caeaed024d4cb2f] --- projects/hip/bin/hipcc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/projects/hip/bin/hipcc b/projects/hip/bin/hipcc index 00018e5f04..7e15d6b2e6 100755 --- a/projects/hip/bin/hipcc +++ b/projects/hip/bin/hipcc @@ -80,8 +80,11 @@ if ($HIP_PLATFORM eq "hcc") { $HCC_HOME=$ENV{'HCC_HOME'} // $hipConfig{'HCC_HOME'} // "/opt/rocm/hcc"; - $HCC_VERSION=`${HCC_HOME}/bin/hcc --version | cut -d" " -f9 | tr -d "\n"`; - $HCC_VERSION_MAJOR=`${HCC_HOME}/bin/hcc --version | cut -d" " -f9 | cut -d"." -f1 | tr -d "\n"`; + $HCC_VERSION=`${HCC_HOME}/bin/hcc --version`; + $HCC_VERSION=~/.*based on HCC ([^ ]+).*/; + $HCC_VERSION=$1; + $HCC_VERSION_MAJOR=$HCC_VERSION; + $HCC_VERSION_MAJOR=~s/\..*//; $ROCM_PATH=$ENV{'ROCM_PATH'} // "/opt/rocm"; From 6e13b64b35eb39dced0d8e4152440b3b3d4d6147 Mon Sep 17 00:00:00 2001 From: Rahul Garg Date: Mon, 6 Mar 2017 22:37:05 +0530 Subject: [PATCH 187/281] Removed hsakmt headers Change-Id: I4ffc95d5823489195ebc5638226b49ea2995f603 [ROCm/hip commit: c8e985f83cf703bf94db6b3f86b5583e4eb74830] --- projects/hip/CMakeLists.txt | 2 +- projects/hip/src/hip_hcc.cpp | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/projects/hip/CMakeLists.txt b/projects/hip/CMakeLists.txt index 72cc2469e8..ce0eeb362d 100644 --- a/projects/hip/CMakeLists.txt +++ b/projects/hip/CMakeLists.txt @@ -160,7 +160,7 @@ if(HIP_PLATFORM STREQUAL "hcc") # Add remaining flags execute_process(COMMAND ${HCC_HOME}/bin/hcc-config --cxxflags OUTPUT_VARIABLE HCC_CXX_FLAGS) - set(HIP_HCC_BUILD_FLAGS "${HIP_HCC_BUILD_FLAGS} -fPIC ${HCC_CXX_FLAGS} -I${HSA_PATH}/include -I/opt/rocm/libhsakmt/include") + set(HIP_HCC_BUILD_FLAGS "${HIP_HCC_BUILD_FLAGS} -fPIC ${HCC_CXX_FLAGS} -I${HSA_PATH}/include") # Set compiler and compiler flags set(CMAKE_CXX_COMPILER "${HCC_HOME}/bin/hcc") diff --git a/projects/hip/src/hip_hcc.cpp b/projects/hip/src/hip_hcc.cpp index a294cc0097..f0a94ea9ca 100644 --- a/projects/hip/src/hip_hcc.cpp +++ b/projects/hip/src/hip_hcc.cpp @@ -41,7 +41,6 @@ THE SOFTWARE. #include #include #include "hsa/hsa_ext_amd.h" -#include "libhsakmt/hsakmt.h" #include "hip/hip_runtime.h" #include "hip_hcc.h" From 0dd1393f976a7dc664ca40bc037d8a5bab7b7cd7 Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Mon, 6 Mar 2017 16:38:22 -0600 Subject: [PATCH 188/281] Modify memcpy and memset to follow C/C++ standard: - memcpy src is const - memset val is int [ROCm/hip commit: d572e0616eebb3e1e455333158b71ac1f1e4a7dc] --- projects/hip/include/hip/hcc_detail/hip_runtime.h | 9 +++++---- projects/hip/src/device_util.cpp | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime.h b/projects/hip/include/hip/hcc_detail/hip_runtime.h index 98c3ada969..67c63103d3 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime.h @@ -353,7 +353,7 @@ __device__ int __hip_move_dpp(int src, int dpp_ctrl, int row_mask, int bank_mask #define hipGridDim_y (hc_get_num_groups(1)) #define hipGridDim_z (hc_get_num_groups(2)) -extern "C" __device__ void* __hip_hc_memcpy(void* dst, void* src, size_t size); +extern "C" __device__ void* __hip_hc_memcpy(void* dst, const void* src, size_t size); extern "C" __device__ void* __hip_hc_memset(void* ptr, uint8_t val, size_t size); extern "C" __device__ void* __hip_hc_malloc(size_t); extern "C" __device__ void* __hip_hc_free(void *ptr); @@ -368,14 +368,15 @@ static inline __device__ void* free(void *ptr) return __hip_hc_free(ptr); } -static inline __device__ void* memcpy(void* dst, void* src, size_t size) +static inline __device__ void* memcpy(void* dst, const void* src, size_t size) { return __hip_hc_memcpy(dst, src, size); } -static inline __device__ void* memset(void* ptr, uint8_t val, size_t size) +static inline __device__ void* memset(void* ptr, int val, size_t size) { - return __hip_hc_memset(ptr, val, size); + uint8_t val8 = static_cast (val); + return __hip_hc_memset(ptr, val8, size); } diff --git a/projects/hip/src/device_util.cpp b/projects/hip/src/device_util.cpp index fb207e3996..4b0e7efefd 100644 --- a/projects/hip/src/device_util.cpp +++ b/projects/hip/src/device_util.cpp @@ -99,7 +99,7 @@ __device__ void* __hip_hc_free(void *ptr) // loop unrolling -__device__ void* __hip_hc_memcpy(void* dst, void* src, size_t size) +__device__ void* __hip_hc_memcpy(void* dst, const void* src, size_t size) { uint8_t *dstPtr, *srcPtr; dstPtr = (uint8_t*)dst; From d898444c44c539f1b43e15399b486e6a09a38871 Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Tue, 7 Mar 2017 14:40:04 +0530 Subject: [PATCH 189/281] FindHIP: better handling for custom HCC_HOME Change-Id: Ica267de11cde58d1e759cd1fd053b699649ea76a [ROCm/hip commit: 12e8d635aa9590e6142f1b9735c7fb0b12a36c22] --- projects/hip/bin/hipcc_cmake_linker_helper | 5 +++++ projects/hip/cmake/FindHIP.cmake | 24 +++++++++++++++++++++- projects/hip/cmake/FindHIP/run_hipcc.cmake | 4 ++++ 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100755 projects/hip/bin/hipcc_cmake_linker_helper diff --git a/projects/hip/bin/hipcc_cmake_linker_helper b/projects/hip/bin/hipcc_cmake_linker_helper new file mode 100755 index 0000000000..bd4f6c118d --- /dev/null +++ b/projects/hip/bin/hipcc_cmake_linker_helper @@ -0,0 +1,5 @@ +#!/bin/bash + +SOURCE="${BASH_SOURCE[0]}" +HIP_PATH="$( command cd -P "$( dirname "$SOURCE" )/.." && pwd )" +HCC_HOME=$1 $HIP_PATH/bin/hipcc "${@:2}" diff --git a/projects/hip/cmake/FindHIP.cmake b/projects/hip/cmake/FindHIP.cmake index ea19725a1e..0001436fee 100644 --- a/projects/hip/cmake/FindHIP.cmake +++ b/projects/hip/cmake/FindHIP.cmake @@ -105,6 +105,25 @@ if(UNIX AND NOT APPLE AND NOT CYGWIN) endif() mark_as_advanced(HIP_HIPCONFIG_EXECUTABLE) + # Find HIPCC_CMAKE_LINKER_HELPER executable + find_program( + HIP_HIPCC_CMAKE_LINKER_HELPER + NAMES hipcc_cmake_linker_helper + PATHS + "${HIP_ROOT_DIR}" + ENV ROCM_PATH + ENV HIP_PATH + /opt/rocm + /opt/rocm/hip + PATH_SUFFIXES bin + NO_DEFAULT_PATH + ) + if(NOT HIP_HIPCC_CMAKE_LINKER_HELPER) + # Now search in default paths + find_program(HIP_HIPCC_CMAKE_LINKER_HELPER hipcc_cmake_linker_helper) + endif() + mark_as_advanced(HIP_HIPCC_CMAKE_LINKER_HELPER) + if(HIP_HIPCONFIG_EXECUTABLE AND NOT HIP_VERSION) # Compute the version execute_process( @@ -496,7 +515,10 @@ macro(HIP_ADD_EXECUTABLE hip_target) HIP_GET_SOURCES_AND_OPTIONS(_sources _cmake_options _hipcc_options _hcc_options _nvcc_options ${ARGN}) HIP_PREPARE_TARGET_COMMANDS(${hip_target} OBJ _generated_files _source_files ${_sources} HIPCC_OPTIONS ${_hipcc_options} HCC_OPTIONS ${_hcc_options} NVCC_OPTIONS ${_nvcc_options}) list(REMOVE_ITEM _sources ${_source_files}) - set(CMAKE_HIP_LINK_EXECUTABLE "${HIP_HIPCC_EXECUTABLE} -o ") + if("x${HCC_HOME}" STREQUAL "x") + set(HCC_HOME "/opt/rocm/hcc") + endif() + set(CMAKE_HIP_LINK_EXECUTABLE "${HIP_HIPCC_CMAKE_LINKER_HELPER} ${HCC_HOME} -o ") add_executable(${hip_target} ${_cmake_options} ${_generated_files} ${_sources}) set_target_properties(${hip_target} PROPERTIES LINKER_LANGUAGE HIP) endmacro() diff --git a/projects/hip/cmake/FindHIP/run_hipcc.cmake b/projects/hip/cmake/FindHIP/run_hipcc.cmake index 6027cb9b0d..4dc2572e98 100644 --- a/projects/hip/cmake/FindHIP/run_hipcc.cmake +++ b/projects/hip/cmake/FindHIP/run_hipcc.cmake @@ -26,6 +26,7 @@ set(HIP_HIPCONFIG_EXECUTABLE "@HIP_HIPCONFIG_EXECUTABLE@") #path set(HIP_HOST_COMPILER "@HIP_HOST_COMPILER@") # path set(CMAKE_COMMAND "@CMAKE_COMMAND@") # path set(HIP_run_make2cmake "@HIP_run_make2cmake@") # path +set(HCC_HOME "@HCC_HOME@") #path @HIP_HOST_FLAGS@ @_HIP_HIPCC_FLAGS@ @@ -42,6 +43,9 @@ execute_process(COMMAND ${HIP_HIPCONFIG_EXECUTABLE} --platform OUTPUT_VARIABLE H if(NOT host_flag) set(__CC ${HIP_HIPCC_EXECUTABLE}) if(HIP_PLATFORM STREQUAL "hcc") + if(NOT "x${HCC_HOME}" STREQUAL "x") + set(ENV{HCC_HOME} ${HCC_HOME}) + endif() set(__CC_FLAGS ${HIP_HIPCC_FLAGS} ${HIP_HCC_FLAGS} ${HIP_HIPCC_FLAGS_${build_configuration}} ${HIP_HCC_FLAGS_${build_configuration}}) else() set(__CC_FLAGS ${HIP_HIPCC_FLAGS} ${HIP_NVCC_FLAGS} ${HIP_HIPCC_FLAGS_${build_configuration}} ${HIP_NVCC_FLAGS_${build_configuration}}) From 6cbeeb8e59cb3107cb46cf8fc6f467de97f7a857 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Tue, 7 Mar 2017 11:24:32 -0600 Subject: [PATCH 190/281] added new field to hipDeviceProp_t structure gcnArch. 1. It is an integer containing gfx values 701, 801, 802, 803 2. On NV path, it is zero Change-Id: I2b4c7f48981d0214d8c6b1905d2cc85b16203419 [ROCm/hip commit: f86f3b3b33ce43035ae95ad201e7409e3416259e] --- projects/hip/include/hip/hip_runtime_api.h | 1 + .../samples/0_Intro/square/square.hipref.cpp | 10 +++++---- projects/hip/src/hip_hcc.cpp | 21 +++++++++++++++---- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/projects/hip/include/hip/hip_runtime_api.h b/projects/hip/include/hip/hip_runtime_api.h index 28d67fc01a..818c0b7c34 100644 --- a/projects/hip/include/hip/hip_runtime_api.h +++ b/projects/hip/include/hip/hip_runtime_api.h @@ -106,6 +106,7 @@ typedef struct hipDeviceProp_t { size_t maxSharedMemoryPerMultiProcessor; ///< Maximum Shared Memory Per Multiprocessor. int isMultiGpuBoard; ///< 1 if device is on a multi-GPU board, 0 if not. int canMapHostMemory; ///< Check whether HIP can map host memory + int gcnArch; ///< AMD GCN Arch Value. Eg: 803, 701 } hipDeviceProp_t; diff --git a/projects/hip/samples/0_Intro/square/square.hipref.cpp b/projects/hip/samples/0_Intro/square/square.hipref.cpp index 0073c1399a..e694bfb8a4 100644 --- a/projects/hip/samples/0_Intro/square/square.hipref.cpp +++ b/projects/hip/samples/0_Intro/square/square.hipref.cpp @@ -32,7 +32,7 @@ THE SOFTWARE. }\ } -/* +/* * Square each element in the array A and write to array C. */ template @@ -58,16 +58,18 @@ int main(int argc, char *argv[]) hipDeviceProp_t props; CHECK(hipGetDeviceProperties(&props, 0/*deviceID*/)); printf ("info: running on device %s\n", props.name); - + #ifdef __HIP_PLATFORM_HCC__ + printf ("info: architecture on AMD GPU device is: %d\n",props.gcnArch); + #endif printf ("info: allocate host mem (%6.2f MB)\n", 2*Nbytes/1024.0/1024.0); A_h = (float*)malloc(Nbytes); CHECK(A_h == 0 ? hipErrorMemoryAllocation : hipSuccess ); C_h = (float*)malloc(Nbytes); CHECK(C_h == 0 ? hipErrorMemoryAllocation : hipSuccess ); // Fill with Phi + i - for (size_t i=0; iisMultiGpuBoard = 0 ? gpuAgentsCount < 2 : 1; // Get agent name -#if HIP_USE_PRODUCT_NAME + err = hsa_agent_get_info(_hsaAgent, (hsa_agent_info_t)HSA_AMD_AGENT_INFO_PRODUCT_NAME, &(prop->name)); -#else - err = hsa_agent_get_info(_hsaAgent, HSA_AGENT_INFO_NAME, &(prop->name)); -#endif + char archName[256]; + err = hsa_agent_get_info(_hsaAgent, HSA_AGENT_INFO_NAME, &archName); + + if(strcmp(archName,"gfx701")==0){ + prop->gcnArch = 701; + } + if(strcmp(archName,"gfx801")==0){ + prop->gcnArch = 801; + } + if(strcmp(archName,"gfx802")==0){ + prop->gcnArch = 802; + } + if(strcmp(archName,"gfx803")==0){ + prop->gcnArch = 803; + } + DeviceErrorCheck(err); // Get agent node From 9043ba55db3712304bab8aa608c5a77ad4ed09ef Mon Sep 17 00:00:00 2001 From: "Wen-Heng (Jack) Chung" Date: Wed, 8 Mar 2017 01:32:59 +0800 Subject: [PATCH 191/281] Changes to HIP to cope with Promote-free HCC Squashed commit of the following: commit c111b5bd10d7c2a5b0b1ad8b07f6e81185b47b39 Author: Wen-Heng (Jack) Chung Date: Sat Mar 4 17:06:46 2017 +0800 Use __device__ for all variables and functions to be used in kernel path Abolish __device and adopt [[hc]] in HIP implementation, so __device__ can be used on all HIP applications, no matter they are variables or functions. Change-Id: I20ca25857ce3bc3e42a5ebf65cafea2c8492f4c7 commit 30c0e4e4701bbf6bd9a7182e0320a71ff73d3a83 Author: Wen-Heng (Jack) Chung Date: Thu Mar 2 12:14:11 2017 +0800 XXX FIXME get around LDS spills caused in Promote-free HCC hipDynamicShared2 uses all 64KB of LDS for computation. But in Promote-free HCC there are cases where LDS spills would occur, which would make the test case to hang. In this workaround commit we reduce the size of dynamic LDS used to get around this known issue, and will revert this commit when LDS spills are resolved in HCC. Change-Id: If648b36200a4f9143951a8129192bcb7ed0bef5e commit e803173be2d73e2f132a7ff7f61e7a20b4083d34 Author: Wen-Heng (Jack) Chung Date: Wed Mar 1 21:41:41 2017 +0800 Fix math functions which take pointer arguments Change-Id: I332c997e640edbc44824691e2a9434c6b3dadefa commit de590c469e213c42090ff83dbd060f25bb1d6047 Author: Wen-Heng (Jack) Chung Date: Wed Mar 1 18:38:54 2017 +0800 Changes to cope with Promote-free HCC - abolish usage of address_space GNU attribute - use __device in file-scope global variables which would be accessed by GPU kernels - temporarily disable some math functions which take pointer arguments Change-Id: I730311dee848e20e763e35cd3980317fce0dce0d Change-Id: I1f6b970b53b9401eeaaab08f04a7b9fed0fb8cf0 [ROCm/hip commit: efb9b9e86cefa266391e0c00ac6f004d09a83145] --- projects/hip/include/hip/hcc_detail/hip_runtime.h | 7 +++---- projects/hip/include/hip/hcc_detail/host_defines.h | 2 +- projects/hip/src/device_functions.cpp | 4 ++-- projects/hip/src/device_util.cpp | 6 +++--- projects/hip/src/hip_fp16.cpp | 2 +- projects/hip/src/math_functions.cpp | 3 ++- projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp | 7 ------- projects/hip/tests/src/kernel/hipDynamicShared2.cpp | 2 +- 8 files changed, 13 insertions(+), 20 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime.h b/projects/hip/include/hip/hcc_detail/hip_runtime.h index 67c63103d3..d256b3f32f 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime.h @@ -250,7 +250,7 @@ __device__ float __shfl_xor(float input, int lane_mask, int width); __host__ __device__ int min(int arg1, int arg2); __host__ __device__ int max(int arg1, int arg2); -__device__ __attribute__((address_space(3))) void* __get_dynamicgroupbaseptr(); +__device__ void* __get_dynamicgroupbaseptr(); /** @@ -418,10 +418,9 @@ do {\ // Macro to replace extern __shared__ declarations // to local variable definitions #define HIP_DYNAMIC_SHARED(type, var) \ - __attribute__((address_space(3))) type* var = \ - (__attribute__((address_space(3))) type*)__get_dynamicgroupbaseptr(); \ + type* var = (type*)__get_dynamicgroupbaseptr(); \ -#define HIP_DYNAMIC_SHARED_ATTRIBUTE __attribute__((address_space(3))) +#define HIP_DYNAMIC_SHARED_ATTRIBUTE #endif // __HCC__ diff --git a/projects/hip/include/hip/hcc_detail/host_defines.h b/projects/hip/include/hip/hcc_detail/host_defines.h index e401cb24f3..012d3f0346 100644 --- a/projects/hip/include/hip/hcc_detail/host_defines.h +++ b/projects/hip/include/hip/hcc_detail/host_defines.h @@ -47,7 +47,7 @@ THE SOFTWARE. */ // _restrict is supported by the compiler #define __shared__ tile_static -#define __constant__ __attribute__((address_space(1))) +#define __constant__ __attribute__((hc)) #else // Non-HCC compiler diff --git a/projects/hip/src/device_functions.cpp b/projects/hip/src/device_functions.cpp index abc9db570e..10d8d3ab89 100644 --- a/projects/hip/src/device_functions.cpp +++ b/projects/hip/src/device_functions.cpp @@ -41,8 +41,8 @@ struct holder32Bit { }; } __attribute__((aligned(4))); -struct holder64Bit hold64; -struct holder32Bit hold32; +__device__ struct holder64Bit hold64; +__device__ struct holder32Bit hold32; __device__ float __double2float_rd(double x) { diff --git a/projects/hip/src/device_util.cpp b/projects/hip/src/device_util.cpp index 4b0e7efefd..88ffa7ab4d 100644 --- a/projects/hip/src/device_util.cpp +++ b/projects/hip/src/device_util.cpp @@ -34,8 +34,8 @@ THE SOFTWARE. This is the best place to put them because the device global variables need to be initialized at the start. */ -__attribute__((address_space(1))) char gpuHeap[SIZE_OF_HEAP]; -__attribute__((address_space(1))) uint32_t gpuFlags[NUM_PAGES]; +__device__ char gpuHeap[SIZE_OF_HEAP]; +__device__ uint32_t gpuFlags[NUM_PAGES]; __device__ void *__hip_hc_malloc(size_t size) { @@ -1083,7 +1083,7 @@ __host__ __device__ int max(int arg1, int arg2) return (int)(hc::precise_math::fmax((float)arg1, (float)arg2)); } -__device__ __attribute__((address_space(3))) void* __get_dynamicgroupbaseptr() +__device__ void* __get_dynamicgroupbaseptr() { return hc::get_dynamic_group_segment_base_pointer(); } diff --git a/projects/hip/src/hip_fp16.cpp b/projects/hip/src/hip_fp16.cpp index b306a9d3de..e7f75844ff 100644 --- a/projects/hip/src/hip_fp16.cpp +++ b/projects/hip/src/hip_fp16.cpp @@ -31,7 +31,7 @@ struct hipHalfHolder{ #define HINF 65504 -static struct hipHalfHolder __hInfValue = {HINF}; +__device__ static struct hipHalfHolder __hInfValue = {HINF}; __device__ __half __hadd(__half a, __half b) { return a + b; diff --git a/projects/hip/src/math_functions.cpp b/projects/hip/src/math_functions.cpp index a1ee9d3ce5..ff876def5f 100644 --- a/projects/hip/src/math_functions.cpp +++ b/projects/hip/src/math_functions.cpp @@ -202,7 +202,8 @@ __device__ long long int llroundf(float x) int y = hc::precise_math::roundf(x); long long int z = y; return z; -}__device__ float log10f(float x) +} +__device__ float log10f(float x) { return hc::precise_math::log10f(x); } diff --git a/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp b/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp index e58aa58877..429c1d69ef 100644 --- a/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp +++ b/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp @@ -31,15 +31,8 @@ THE SOFTWARE. #define NUM 1024 #define SIZE 1024*4 -#ifdef __HIP_PLATFORM_HCC__ -__attribute__((address_space(1))) int globalIn[NUM]; -__attribute__((address_space(1))) int globalOut[NUM]; -#endif - -#ifdef __HIP_PLATFORM_NVCC__ __device__ int globalIn[NUM]; __device__ int globalOut[NUM]; -#endif __global__ void Assign(hipLaunchParm lp, int* Out) { diff --git a/projects/hip/tests/src/kernel/hipDynamicShared2.cpp b/projects/hip/tests/src/kernel/hipDynamicShared2.cpp index 0f6ebb4927..ea24e9341f 100644 --- a/projects/hip/tests/src/kernel/hipDynamicShared2.cpp +++ b/projects/hip/tests/src/kernel/hipDynamicShared2.cpp @@ -29,7 +29,7 @@ THE SOFTWARE. #include "hip/hip_runtime.h" #include "test_common.h" -#define LEN 16*1024 +#define LEN 8*1024 #define SIZE LEN*4 __global__ void vectorAdd(hipLaunchParm lp, float *Ad, float *Bd) { From fe81d08987127d7c8caa0b5c8b55cef275ff8361 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Tue, 7 Mar 2017 13:46:29 -0600 Subject: [PATCH 192/281] Added new API, hipMemPtrGetInfo 1. This API returns memory allocation size of pointer 2. Added test to check its functionality Change-Id: I87976d817b5a6ca5530336c09e7cb0420601cb2c [ROCm/hip commit: 1546732604c021c48954f4384a46a83c3ea5eb90] --- .../include/hip/hcc_detail/hip_runtime_api.h | 3 ++ projects/hip/src/hip_memory.cpp | 21 ++++++++ .../src/runtimeApi/memory/hipHostGetFlags.cpp | 2 +- .../runtimeApi/memory/hipMemPtrGetInfo.cpp | 52 +++++++++++++++++++ 4 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 projects/hip/tests/src/runtimeApi/memory/hipMemPtrGetInfo.cpp diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h index f156d3fdbd..fb8535cfec 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h @@ -1236,6 +1236,9 @@ hipError_t hipMemsetAsync(void* dst, int value, size_t sizeBytes, hipStream_t st hipError_t hipMemGetInfo (size_t * free, size_t * total) ; +hipError_t hipMemPtrGetInfo(void *ptr, size_t *size); + + /** * @brief Allocate an array on the device. * diff --git a/projects/hip/src/hip_memory.cpp b/projects/hip/src/hip_memory.cpp index 479040c099..29315fa09d 100644 --- a/projects/hip/src/hip_memory.cpp +++ b/projects/hip/src/hip_memory.cpp @@ -1024,6 +1024,27 @@ hipError_t hipMemGetInfo (size_t *free, size_t *total) return ihipLogStatus(e); } +hipError_t hipMemPtrGetInfo(void *ptr, size_t *size) +{ + HIP_INIT_API(ptr, size); + + hipError_t e = hipSuccess; + + if(ptr != nullptr && size != nullptr){ + hc::accelerator acc; + hc::AmPointerInfo amPointerInfo(NULL, NULL, 0, acc, 0, 0); + am_status_t status = hc::am_memtracker_getinfo(&amPointerInfo, ptr); + if(status == AM_SUCCESS){ + *size = amPointerInfo._sizeBytes; + }else{ + e = hipErrorInvalidValue; + } + }else{ + e = hipErrorInvalidValue; + } + return ihipLogStatus(e); +} + hipError_t hipFree(void* ptr) { HIP_INIT_API(ptr); diff --git a/projects/hip/tests/src/runtimeApi/memory/hipHostGetFlags.cpp b/projects/hip/tests/src/runtimeApi/memory/hipHostGetFlags.cpp index a989b879ac..9fad60aec8 100644 --- a/projects/hip/tests/src/runtimeApi/memory/hipHostGetFlags.cpp +++ b/projects/hip/tests/src/runtimeApi/memory/hipHostGetFlags.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/projects/hip/tests/src/runtimeApi/memory/hipMemPtrGetInfo.cpp b/projects/hip/tests/src/runtimeApi/memory/hipMemPtrGetInfo.cpp new file mode 100644 index 0000000000..5aa0072199 --- /dev/null +++ b/projects/hip/tests/src/runtimeApi/memory/hipMemPtrGetInfo.cpp @@ -0,0 +1,52 @@ +/* +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +/* HIT_START + * BUILD: %t %s ../../test_common.cpp + * RUN: %t + * HIT_END + */ + +#include"test_common.h" + +struct { + float a; + int b; + void *c; +} Struct ; + +int main(){ + int *iPtr; + float *fPtr; + struct Struct *sPtr; + size_t sSetSize = 1024, sGetSize; + hipMalloc(&iPtr, sSetSize); + hipMalloc(&fPtr, sSetSize); + hipMalloc(&sPtr, sSetSize); + hipMemPtrGetInfo(iPtr, &sGetSize); + assert(sGetSize == sSetSize); + hipMemPtrGetInfo(fPtr, &sGetSize); + assert(sGetSize == sSetSize); + hipMemPtrGetInfo(sPtr, &sGetSize); + assert(sGetSize == sSetSize); + passed(); +} From fafd8d0f0a04720f32fa7e91fe9acc5686a52950 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Tue, 7 Mar 2017 14:06:03 -0600 Subject: [PATCH 193/281] fixed atan2f arguments Change-Id: I0bb621e94d57594c3899e51d0c34ef43306cead0 [ROCm/hip commit: 5009bfb2dfdf1dcbc8fe56190b73415d08e1e70c] --- projects/hip/src/math_functions.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/hip/src/math_functions.cpp b/projects/hip/src/math_functions.cpp index a1ee9d3ce5..230eb2aacc 100644 --- a/projects/hip/src/math_functions.cpp +++ b/projects/hip/src/math_functions.cpp @@ -46,7 +46,7 @@ __device__ float asinhf(float x) } __device__ float atan2f(float y, float x) { - return hc::precise_math::atan2f(x, y); + return hc::precise_math::atan2f(y, x); } __device__ float atanf(float x) { From a1ecc551aaea935dc26cc88b7bf2e364775c5098 Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Wed, 8 Mar 2017 16:16:08 +0530 Subject: [PATCH 194/281] Disable hipMemPtrGetInfo test on nvcc path Change-Id: I864e571314abfe5ae614e6792c86d7b457c920ee [ROCm/hip commit: 7a59103cea9addf434a05768e27ec5052e336a32] --- projects/hip/tests/src/runtimeApi/memory/hipMemPtrGetInfo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/hip/tests/src/runtimeApi/memory/hipMemPtrGetInfo.cpp b/projects/hip/tests/src/runtimeApi/memory/hipMemPtrGetInfo.cpp index 5aa0072199..1f78b4afab 100644 --- a/projects/hip/tests/src/runtimeApi/memory/hipMemPtrGetInfo.cpp +++ b/projects/hip/tests/src/runtimeApi/memory/hipMemPtrGetInfo.cpp @@ -21,7 +21,7 @@ THE SOFTWARE. */ /* HIT_START - * BUILD: %t %s ../../test_common.cpp + * BUILD: %t %s ../../test_common.cpp EXCLUDE_HIP_PLATFORM nvcc * RUN: %t * HIT_END */ From 72395aecc59305d2fd8f61b98a6330c01e0a4580 Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Wed, 8 Mar 2017 13:49:50 -0600 Subject: [PATCH 195/281] Fix bug in hipModuleGetFunction. Modules with > 1 function didn't return the function correctly. Also fix coding convention issues [ROCm/hip commit: 439e37ab764bccfdec3f951e2883e285342a24b0] --- projects/hip/src/hip_module.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/projects/hip/src/hip_module.cpp b/projects/hip/src/hip_module.cpp index f21adf9691..1f20a47c13 100644 --- a/projects/hip/src/hip_module.cpp +++ b/projects/hip/src/hip_module.cpp @@ -218,31 +218,33 @@ hipError_t hipModuleUnload(hipModule_t hmod) { ret = hipErrorInvalidValue; } - for(std::list::iterator f = hmod->funcTrack.begin(); f != hmod->funcTrack.end(); ++f) { + for(auto f = hmod->funcTrack.begin(); f != hmod->funcTrack.end(); ++f) { delete *f; } delete hmod; return ihipLogStatus(ret); } -hipError_t ihipModuleGetSymbol(hipFunction_t *func, hipModule_t hmod, const char *name){ + +hipError_t ihipModuleGetSymbol(hipFunction_t *func, hipModule_t hmod, const char *name) +{ auto ctx = ihipGetTlsDefaultCtx(); hipError_t ret = hipSuccess; - if(name == nullptr){ + if (name == nullptr){ return ihipLogStatus(hipErrorInvalidValue); } - if(ctx == nullptr){ + if (ctx == nullptr){ ret = hipErrorInvalidContext; - }else{ + } else { std::string str(name); - for(std::list::iterator f = hmod->funcTrack.begin(); f != hmod->funcTrack.end(); ++f) { - if((*f)->_name == str) { - *func = *f; - } - return ret; + for(auto f = hmod->funcTrack.begin(); f != hmod->funcTrack.end(); ++f) { + if((*f)->_name == str) { + *func = *f; + return ret; + } } ihipModuleSymbol_t *sym = new ihipModuleSymbol_t; int deviceId = ctx->getDevice()->_deviceId; From e18aaa955f72979a9a5d0e6977ec5bcf17dbc4f9 Mon Sep 17 00:00:00 2001 From: pensun Date: Wed, 8 Mar 2017 14:06:09 -0600 Subject: [PATCH 196/281] add inline to all hip_complex operators Change-Id: Ifba5966c297cbc9299c39ecfc45c7296003ebb5d [ROCm/hip commit: 7488d8c7faf8d8d1f5dd8f4dfd6b3eba65318aa6] --- projects/hip/include/hip/hcc_detail/hip_complex.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/hip_complex.h b/projects/hip/include/hip/hcc_detail/hip_complex.h index d4fea7f034..f50a601b90 100644 --- a/projects/hip/include/hip/hcc_detail/hip_complex.h +++ b/projects/hip/include/hip/hcc_detail/hip_complex.h @@ -28,7 +28,7 @@ THE SOFTWARE. #if __cplusplus #define COMPLEX_ADD_OP_OVERLOAD(type) \ -__device__ __host__ static type operator + (const type& lhs, const type& rhs) { \ +__device__ __host__ static inline type operator + (const type& lhs, const type& rhs) { \ type ret; \ ret.x = lhs.x + rhs.x ; \ ret.y = lhs.y + rhs.y ; \ @@ -36,7 +36,7 @@ __device__ __host__ static type operator + (const type& lhs, const type& rhs) { } #define COMPLEX_SUB_OP_OVERLOAD(type) \ -__device__ __host__ static type operator - (const type& lhs, const type& rhs) { \ +__device__ __host__ static inline type operator - (const type& lhs, const type& rhs) { \ type ret; \ ret.x = lhs.x - rhs.x; \ ret.y = lhs.y - rhs.y; \ @@ -44,7 +44,7 @@ __device__ __host__ static type operator - (const type& lhs, const type& rhs) { } #define COMPLEX_MUL_OP_OVERLOAD(type) \ -__device__ __host__ static type operator * (const type& lhs, const type& rhs) { \ +__device__ __host__ static inline type operator * (const type& lhs, const type& rhs) { \ type ret; \ ret.x = lhs.x * rhs.x - lhs.y * rhs.y; \ ret.y = lhs.x * rhs.y + lhs.y * rhs.x; \ @@ -52,7 +52,7 @@ __device__ __host__ static type operator * (const type& lhs, const type& rhs) { } #define COMPLEX_DIV_OP_OVERLOAD(type) \ -__device__ __host__ static type operator / (const type& lhs, const type& rhs) { \ +__device__ __host__ static inline type operator / (const type& lhs, const type& rhs) { \ type ret; \ ret.x = (lhs.x * rhs.x + lhs.y * rhs.y); \ ret.y = (rhs.x * lhs.y - lhs.x * rhs.y); \ @@ -88,7 +88,7 @@ __device__ __host__ static inline type& operator /= (type& lhs, const type& rhs) } #define COMPLEX_SCALAR_PRODUCT(type, type1) \ -__device__ __host__ static type operator * (const type& lhs, type1 rhs) { \ +__device__ __host__ static inline type operator * (const type& lhs, type1 rhs) { \ type ret; \ ret.x = lhs.x * rhs; \ ret.y = lhs.y * rhs; \ From ba1f2acfc573a93109176f3aeaed1186b1c1a6e5 Mon Sep 17 00:00:00 2001 From: pensun Date: Wed, 8 Mar 2017 23:37:50 -0600 Subject: [PATCH 197/281] fix typo in hip_porting_guide Change-Id: I42553d9a4de2901dfdd57384b52a04e8fb22edde [ROCm/hip commit: 7290cb07ecc05c548b37edfac9d138d3e9e6bc4e] --- projects/hip/docs/markdown/hip_porting_guide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/hip/docs/markdown/hip_porting_guide.md b/projects/hip/docs/markdown/hip_porting_guide.md index 0acdc246f9..721a6fabd7 100644 --- a/projects/hip/docs/markdown/hip_porting_guide.md +++ b/projects/hip/docs/markdown/hip_porting_guide.md @@ -166,7 +166,7 @@ Both nvcc and hcc make two passes over the code: one for host code and one for d ``` // #ifdef __CUDA_ARCH__ -#ifdef __HIP_DEVICE_COMPILE__ && (__HIP_DEVICE_COMPILE__ == 1) +#if defined(__HIP_DEVICE_COMPILE__) && (__HIP_DEVICE_COMPILE__ == 1) ``` Unlike `__CUDA_ARCH__`, the `__HIP_DEVICE_COMPILE__` value is 0 or 1, and it doesn’t represent the feature capability of the target device. From 297f40264eb685a6a4bc0839ee4a9e3cf04dab72 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Thu, 9 Mar 2017 08:52:50 -0600 Subject: [PATCH 198/281] make 4_shfl cookbook sample only for fiji 1. __shfl is not supported on hawaii gfx701 Change-Id: Iac09f5d30ee0674b8f58a6e74ec5c49b02be32ad [ROCm/hip commit: 60f8908ad8ce8d705c244852256792324c785871] --- projects/hip/samples/2_Cookbook/4_shfl/Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/projects/hip/samples/2_Cookbook/4_shfl/Makefile b/projects/hip/samples/2_Cookbook/4_shfl/Makefile index 3383cf2bf5..21c0e93959 100644 --- a/projects/hip/samples/2_Cookbook/4_shfl/Makefile +++ b/projects/hip/samples/2_Cookbook/4_shfl/Makefile @@ -22,7 +22,7 @@ CXX=$(HIPCC) $(EXECUTABLE): $(OBJECTS) - $(HIPCC) $(OBJECTS) -o $@ + $(HIPCC) --amdgpu-target=gfx803 $(OBJECTS) -o $@ test: $(EXECUTABLE) @@ -33,4 +33,3 @@ clean: rm -f $(EXECUTABLE) rm -f $(OBJECTS) rm -f $(HIP_PATH)/src/*.o - From 87dab4f207ed53b1f263d065b401162ffb8f7678 Mon Sep 17 00:00:00 2001 From: Rahul Garg Date: Fri, 10 Mar 2017 10:29:52 +0530 Subject: [PATCH 199/281] Fix for HCSWAP-128, make 5_2dshfl cookbook sample only for fiji Change-Id: I8869c28151bca1bd47a053a2808e93a801d16d00 [ROCm/hip commit: 6d815f84d12f2407261defe3997b5318a7f7f88a] --- projects/hip/samples/2_Cookbook/5_2dshfl/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/hip/samples/2_Cookbook/5_2dshfl/Makefile b/projects/hip/samples/2_Cookbook/5_2dshfl/Makefile index b742bbf80a..6abaf658b1 100644 --- a/projects/hip/samples/2_Cookbook/5_2dshfl/Makefile +++ b/projects/hip/samples/2_Cookbook/5_2dshfl/Makefile @@ -22,7 +22,7 @@ CXX=$(HIPCC) $(EXECUTABLE): $(OBJECTS) - $(HIPCC) $(OBJECTS) -o $@ + $(HIPCC) --amdgpu-target=gfx803 $(OBJECTS) -o $@ test: $(EXECUTABLE) From b0c2ac0a909d4ff4092df8a27050674d8d2e48e2 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Fri, 10 Mar 2017 08:40:59 -0600 Subject: [PATCH 200/281] Added architecture guards around __shfl, dpp and ds_permute device functions Change-Id: I10f9b08618fbf25b61c1932278fc5759e41c0d66 [ROCm/hip commit: 1567d20aa814cb8c440b356556de1c1188b37b44] --- .../hip/include/hip/hcc_detail/hip_runtime.h | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime.h b/projects/hip/include/hip/hcc_detail/hip_runtime.h index 67c63103d3..6acc604909 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime.h @@ -226,6 +226,8 @@ __device__ int __all( int input); __device__ int __any( int input); __device__ unsigned long long int __ballot( int input); +#if __HIP_ARCH_GFX803__ == 1 + // warp shuffle functions #ifdef __cplusplus __device__ int __shfl(int input, int lane, int width=warpSize); @@ -247,6 +249,18 @@ __device__ float __shfl_down(float input, unsigned int lane_delta, int width); __device__ float __shfl_xor(float input, int lane_mask, int width); #endif +__device__ unsigned __hip_ds_bpermute(int index, unsigned src); +__device__ float __hip_ds_bpermutef(int index, float src); +__device__ unsigned __hip_ds_permute(int index, unsigned src); +__device__ float __hip_ds_permutef(int index, float src); + +__device__ unsigned __hip_ds_swizzle(unsigned int src, int pattern); +__device__ float __hip_ds_swizzlef(float src, int pattern); + +__device__ int __hip_move_dpp(int src, int dpp_ctrl, int row_mask, int bank_mask, bool bound_ctrl); + +#endif + __host__ __device__ int min(int arg1, int arg2); __host__ __device__ int max(int arg1, int arg2); @@ -321,16 +335,6 @@ __device__ static inline void __threadfence(void) { //__device__ void __threadfence_system(void) __attribute__((deprecated("Provided with workaround configuration, see hip_kernel_language.md for details"))); __device__ void __threadfence_system(void) ; -__device__ unsigned __hip_ds_bpermute(int index, unsigned src); -__device__ float __hip_ds_bpermutef(int index, float src); -__device__ unsigned __hip_ds_permute(int index, unsigned src); -__device__ float __hip_ds_permutef(int index, float src); - -__device__ unsigned __hip_ds_swizzle(unsigned int src, int pattern); -__device__ float __hip_ds_swizzlef(float src, int pattern); - -__device__ int __hip_move_dpp(int src, int dpp_ctrl, int row_mask, int bank_mask, bool bound_ctrl); - // doxygen end Fence Fence /** * @} From 4d748e3cd70265777860d69568008863edba0809 Mon Sep 17 00:00:00 2001 From: pensun Date: Thu, 9 Mar 2017 16:30:34 -0600 Subject: [PATCH 201/281] update porting guide for updated __HIP_DEVICE_COMPILE__ Change-Id: I0f025d354f76e2d728231bf112a77e8c8fcacc8c [ROCm/hip commit: 37ed319a20f006f62bdff3889b19c647730b08f6] --- projects/hip/docs/markdown/hip_porting_guide.md | 6 +++--- projects/hip/include/hip/hip_common.h | 17 ++++------------- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/projects/hip/docs/markdown/hip_porting_guide.md b/projects/hip/docs/markdown/hip_porting_guide.md index 721a6fabd7..9f20d12423 100644 --- a/projects/hip/docs/markdown/hip_porting_guide.md +++ b/projects/hip/docs/markdown/hip_porting_guide.md @@ -166,10 +166,10 @@ Both nvcc and hcc make two passes over the code: one for host code and one for d ``` // #ifdef __CUDA_ARCH__ -#if defined(__HIP_DEVICE_COMPILE__) && (__HIP_DEVICE_COMPILE__ == 1) +#if __HIP_DEVICE_COMPILE__ ``` -Unlike `__CUDA_ARCH__`, the `__HIP_DEVICE_COMPILE__` value is 0 or 1, and it doesn’t represent the feature capability of the target device. +Unlike `__CUDA_ARCH__`, the `__HIP_DEVICE_COMPILE__` value is 1 or undefined, and it doesn’t represent the feature capability of the target device. ### Compiler Defines: Summary @@ -178,7 +178,7 @@ Unlike `__CUDA_ARCH__`, the `__HIP_DEVICE_COMPILE__` value is 0 or 1, and it doe |HIP-related defines:| |`__HIP_PLATFORM_HCC___`| Defined | Undefined | Defined if targeting hcc platform; undefined otherwise | |`__HIP_PLATFORM_NVCC___`| Undefined | Defined | Defined if targeting nvcc platform; undefined otherwise | -|`__HIP_DEVICE_COMPILE__` | 1 if compiling for device; 0 if compiling for host |1 if compiling for device; 0 if compiling for host | Undefined +|`__HIP_DEVICE_COMPILE__` | 1 if compiling for device; undefined if compiling for host |1 if compiling for device; undefined if compiling for host | Undefined |`__HIPCC__` | Defined | Defined | Undefined |`__HIP_ARCH_*` | 0 or 1 depending on feature support (see below) | 0 or 1 depending on feature support (see below) | 0 |nvcc-related defines:| diff --git a/projects/hip/include/hip/hip_common.h b/projects/hip/include/hip/hip_common.h index 6223a2fe9e..6317a792ee 100644 --- a/projects/hip/include/hip/hip_common.h +++ b/projects/hip/include/hip/hip_common.h @@ -27,13 +27,6 @@ THE SOFTWARE. // Other compiler (GCC,ICC,etc) need to set one of these macros explicitly #if defined(__HCC__) #define __HIP_PLATFORM_HCC__ - -#if defined(__HCC_ACCELERATOR__) && (__HCC_ACCELERATOR__ != 0) -#define __HIP_DEVICE_COMPILE__ 1 -#else -#define __HIP_DEVICE_COMPILE__ 0 -#endif - #endif //__HCC__ // Auto enable __HIP_PLATFORM_NVCC__ if compiling with NVCC @@ -43,14 +36,12 @@ THE SOFTWARE. #define __HIPCC__ #endif -#if defined(__CUDA_ARCH__) && (__CUDA_ARCH__ != 0) -#define __HIP_DEVICE_COMPILE__ 1 -#else -#define __HIP_DEVICE_COMPILE__ 0 -#endif - #endif //__NVCC__ +// Auto enable __HIP_DEVICE_COMPILE__ if compiled in HCC or NVCC device path +#if (defined(__HCC_ACCELERATOR__) && __HCC_ACCELERATOR__ != 0) || (defined(__CUDA_ARCH__) && __CUDA_ARCH__ != 0) + #define __HIP_DEVICE_COMPILE__ 1 +#endif #if __HIP_DEVICE_COMPILE__ == 0 // 32-bit Atomics From 4954d140d4a51810fbc8685d1db536cfd4f8eff1 Mon Sep 17 00:00:00 2001 From: Rahul Garg Date: Fri, 10 Mar 2017 23:45:28 +0530 Subject: [PATCH 202/281] IPC supported using ROCR APIs Change-Id: I0a353b1240098f4b20fa266a871f5f5826290af9 [ROCm/hip commit: 32d8a58f18f8aff1967efded78b60f85d2be20c9] --- .../include/hip/hcc_detail/hip_runtime_api.h | 7 ++++++- projects/hip/src/hip_hcc.h | 6 +++--- projects/hip/src/hip_memory.cpp | 19 ++++++++++--------- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h index fb8535cfec..080f82d9ed 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h @@ -62,7 +62,12 @@ typedef struct ihipStream_t *hipStream_t; #define hipIpcMemLazyEnablePeerAccess 0 -typedef struct ihipIpcMemHandle_t *hipIpcMemHandle_t; +#define HIP_IPC_HANDLE_SIZE 64 + +typedef struct hipIpcMemHandle_st +{ + char reserved[HIP_IPC_HANDLE_SIZE]; +}hipIpcMemHandle_t; //TODO: IPC event handle currently unsupported struct ihipIpcEventHandle_t; diff --git a/projects/hip/src/hip_hcc.h b/projects/hip/src/hip_hcc.h index 105eef6bb8..b23aead072 100644 --- a/projects/hip/src/hip_hcc.h +++ b/projects/hip/src/hip_hcc.h @@ -36,7 +36,7 @@ THE SOFTWARE. #error("This version of HIP requires a newer version of HCC."); #endif -#define USE_IPC 0 +#define USE_IPC 1 //--- // Environment variables: @@ -326,15 +326,15 @@ const hipStream_t hipStreamNull = 0x0; /** * HIP IPC Handle Size */ -#define HIP_IPC_HANDLE_SIZE 64 +#define HIP_IPC_RESERVED_SIZE 24 class ihipIpcMemHandle_t { public: #if USE_IPC hsa_amd_ipc_memory_t ipc_handle; ///< ipc memory handle on ROCr #endif - char reserved[HIP_IPC_HANDLE_SIZE]; size_t psize; + char reserved[HIP_IPC_RESERVED_SIZE]; }; diff --git a/projects/hip/src/hip_memory.cpp b/projects/hip/src/hip_memory.cpp index 29315fa09d..df11205344 100644 --- a/projects/hip/src/hip_memory.cpp +++ b/projects/hip/src/hip_memory.cpp @@ -1143,7 +1143,7 @@ hipError_t hipMemGetAddressRange ( hipDeviceptr_t* pbase, size_t* psize, hipDevi } else hipStatus = hipErrorInvalidDevicePointer; - return hipStatus; + return ihipLogStatus(hipStatus); } @@ -1162,25 +1162,25 @@ hipError_t hipIpcGetMemHandle(hipIpcMemHandle_t* handle, void* devPtr){ } else hipStatus = hipErrorInvalidResourceHandle; - + ihipIpcMemHandle_t* iHandle = (ihipIpcMemHandle_t*) handle; // Save the size of the pointer to hipIpcMemHandle - (*handle)->psize = psize; + iHandle->psize = psize; #if USE_IPC // Create HSA ipc memory hsa_status_t hsa_status = - hsa_amd_ipc_memory_create(devPtr, psize, &(*handle)->ipc_handle); + hsa_amd_ipc_memory_create(devPtr, psize, (hsa_amd_ipc_memory_t*) &(iHandle->ipc_handle)); if(hsa_status!= HSA_STATUS_SUCCESS) hipStatus = hipErrorMemoryAllocation; #else hipStatus = hipErrorRuntimeOther; #endif - return hipStatus; + return ihipLogStatus(hipStatus); } hipError_t hipIpcOpenMemHandle(void** devPtr, hipIpcMemHandle_t handle, unsigned int flags){ -// HIP_INIT_API ( devPtr, handle.handle , flags); + HIP_INIT_API ( devPtr, &handle , flags); hipError_t hipStatus = hipSuccess; #if USE_IPC @@ -1190,15 +1190,16 @@ hipError_t hipIpcOpenMemHandle(void** devPtr, hipIpcMemHandle_t handle, unsigned if(!agent) return hipErrorInvalidResourceHandle; + ihipIpcMemHandle_t* iHandle = (ihipIpcMemHandle_t*) &handle; //Attach ipc memory hsa_status_t hsa_status = - hsa_amd_ipc_memory_attach(&handle->ipc_handle, handle->psize, 1, agent, devPtr); + hsa_amd_ipc_memory_attach((hsa_amd_ipc_memory_t*)&(iHandle->ipc_handle), iHandle->psize, 1, agent, devPtr); if(hsa_status != HSA_STATUS_SUCCESS) hipStatus = hipErrorMapBufferObjectFailed; #else hipStatus = hipErrorRuntimeOther; #endif - return hipStatus; + return ihipLogStatus(hipStatus); } hipError_t hipIpcCloseMemHandle(void *devPtr){ @@ -1213,7 +1214,7 @@ hipError_t hipIpcCloseMemHandle(void *devPtr){ #else hipStatus = hipErrorRuntimeOther; #endif - return hipStatus; + return ihipLogStatus(hipStatus); } // hipError_t hipIpcOpenEventHandle(hipEvent_t* event, hipIpcEventHandle_t handle){ From 7f0f1e4ae8882dd4bb85147f769eafce1960be1b Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Fri, 10 Mar 2017 15:14:26 -0600 Subject: [PATCH 203/281] fixed warning raised by g++ using hip_vector_types.h Change-Id: I9e7cdfc8b28b03b690eecd068529cf7629296d68 [ROCm/hip commit: e79dd9f9c658d62f0adc298829c9c575854351e6] --- .../include/hip/hcc_detail/hip_vector_types.h | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/hip_vector_types.h b/projects/hip/include/hip/hcc_detail/hip_vector_types.h index cd5a09215a..8e6ec49511 100644 --- a/projects/hip/include/hip/hcc_detail/hip_vector_types.h +++ b/projects/hip/include/hip/hcc_detail/hip_vector_types.h @@ -1260,7 +1260,7 @@ __device__ __host__ static inline type& operator op (type& val) { \ } #define DECLOP_1VAR_POSTOP(type, op) \ -__device__ __host__ static inline type operator op (type& val, int i) { \ +__device__ __host__ static inline type operator op (type& val, int) { \ type ret; \ ret.x = val.x; \ val.x op; \ @@ -1326,7 +1326,7 @@ __device__ __host__ static inline type& operator op (type& val) { \ } #define DECLOP_2VAR_POSTOP(type, op) \ -__device__ __host__ static inline type operator op (type& val, int i) { \ +__device__ __host__ static inline type operator op (type& val, int) { \ type ret; \ ret.x = val.x; \ ret.y = val.y; \ @@ -1337,7 +1337,7 @@ __device__ __host__ static inline type operator op (type& val, int i) { \ #define DECLOP_2VAR_COMP(type, op) \ __device__ __host__ static inline bool operator op (type& lhs, type& rhs) { \ - return lhs.x op rhs.x && lhs.y op rhs.y; \ + return (lhs.x op rhs.x) && (lhs.y op rhs.y); \ } #define DECLOP_2VAR_1IN_1OUT(type, op) \ @@ -1350,7 +1350,7 @@ __device__ __host__ static inline type operator op(type &rhs) { \ #define DECLOP_2VAR_1IN_BOOLOUT(type, op) \ __device__ __host__ static inline bool operator op (type &rhs) { \ - return op rhs.x && op rhs.y; \ + return (op rhs.x) && (op rhs.y); \ } @@ -1401,7 +1401,7 @@ __device__ __host__ static inline type& operator op (type& val) { \ } #define DECLOP_3VAR_POSTOP(type, op) \ -__device__ __host__ static inline type operator op (type& val, int i) { \ +__device__ __host__ static inline type operator op (type& val, int) { \ type ret; \ ret.x = val.x; \ ret.y = val.y; \ @@ -1414,7 +1414,7 @@ __device__ __host__ static inline type operator op (type& val, int i) { \ #define DECLOP_3VAR_COMP(type, op) \ __device__ __host__ static inline bool operator op (type& lhs, type& rhs) { \ - return lhs.x op rhs.x && lhs.y op rhs.y && lhs.z op rhs.z; \ + return (lhs.x op rhs.x) && (lhs.y op rhs.y) && (lhs.z op rhs.z); \ } #define DECLOP_3VAR_1IN_1OUT(type, op) \ @@ -1428,7 +1428,7 @@ __device__ __host__ static inline type operator op(type &rhs) { \ #define DECLOP_3VAR_1IN_BOOLOUT(type, op) \ __device__ __host__ static inline bool operator op (type &rhs) { \ - return op rhs.x && op rhs.y && op rhs.z; \ + return (op rhs.x) && (op rhs.y) && (op rhs.z); \ } @@ -1484,7 +1484,7 @@ __device__ __host__ static inline type& operator op (type& val) { \ } #define DECLOP_4VAR_POSTOP(type, op) \ -__device__ __host__ static inline type operator op (type& val, int i) { \ +__device__ __host__ static inline type operator op (type& val, int) { \ type ret; \ ret.x = val.x; \ ret.y = val.y; \ @@ -1499,7 +1499,7 @@ __device__ __host__ static inline type operator op (type& val, int i) { \ #define DECLOP_4VAR_COMP(type, op) \ __device__ __host__ static inline bool operator op (type& lhs, type& rhs) { \ - return lhs.x op rhs.x && lhs.y op rhs.y && lhs.z op rhs.z && lhs.w op rhs.w; \ + return (lhs.x op rhs.x) && (lhs.y op rhs.y) && (lhs.z op rhs.z) && (lhs.w op rhs.w); \ } #define DECLOP_4VAR_1IN_1OUT(type, op) \ @@ -1514,7 +1514,7 @@ __device__ __host__ static inline type operator op(type &rhs) { \ #define DECLOP_4VAR_1IN_BOOLOUT(type, op) \ __device__ __host__ static inline bool operator op (type &rhs) { \ - return op rhs.x && op rhs.y && op rhs.z && op rhs.w; \ + return (op rhs.x) && (op rhs.y) && (op rhs.z) && (op rhs.w); \ } From 3297a65b8f7978cba5bae9fdfa093828dddebeb2 Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Fri, 17 Feb 2017 11:53:38 -0600 Subject: [PATCH 204/281] Fix copying of registered memory. Set device properly so copying can recover context. Enhance test to catch this case. [ROCm/hip commit: 94c85fd4fc873a945868e2c764127d324c33b3ed] --- projects/hip/src/hip_memory.cpp | 2 ++ .../src/runtimeApi/memory/hipHostRegister.cpp | 21 +++++++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/projects/hip/src/hip_memory.cpp b/projects/hip/src/hip_memory.cpp index df11205344..314dee97dc 100644 --- a/projects/hip/src/hip_memory.cpp +++ b/projects/hip/src/hip_memory.cpp @@ -194,6 +194,7 @@ hipError_t hipHostMalloc(void** ptr, size_t sizeBytes, unsigned int flags) if(sizeBytes < 1 && (*ptr == NULL)){ hip_status = hipErrorMemoryAllocation; } else { + // TODO - should OR in flags here? hc::am_memtracker_update(*ptr, device->_deviceId, amHostCoherent); } tprintf(DB_MEM, " %s: finegrained system memory ptr=%p\n", __func__, *ptr); @@ -403,6 +404,7 @@ hipError_t hipHostRegister(void *hostPtr, size_t sizeBytes, unsigned int flags) vecAcc.push_back(ihipGetDevice(i)->_acc); } am_status = hc::am_memory_host_lock(device->_acc, hostPtr, sizeBytes, &vecAcc[0], vecAcc.size()); + hc::am_memtracker_update(hostPtr, device->_deviceId, flags); tprintf(DB_MEM, " %s registered ptr=%p\n", __func__, hostPtr); if(am_status == AM_SUCCESS){ diff --git a/projects/hip/tests/src/runtimeApi/memory/hipHostRegister.cpp b/projects/hip/tests/src/runtimeApi/memory/hipHostRegister.cpp index 37ee9b1b78..6c81ec0d91 100644 --- a/projects/hip/tests/src/runtimeApi/memory/hipHostRegister.cpp +++ b/projects/hip/tests/src/runtimeApi/memory/hipHostRegister.cpp @@ -39,21 +39,30 @@ int main(){ const size_t size = N * sizeof(float); A = (float*)malloc(size); HIPCHECK(hipHostRegister(A, size, 0)); + + for(int i=0;i Date: Fri, 17 Feb 2017 15:43:09 -0600 Subject: [PATCH 205/281] Update hipHostRegister debug and pointerTracker debug and notes [ROCm/hip commit: 0a554f4dc19ba6e74ce7152ca2bdad683d512496] --- projects/hip/src/hip_hcc.cpp | 40 +++++++++++------ projects/hip/src/hip_memory.cpp | 22 +++++++++- .../src/runtimeApi/memory/hipHostRegister.cpp | 43 ++++++++++++++++--- 3 files changed, 87 insertions(+), 18 deletions(-) diff --git a/projects/hip/src/hip_hcc.cpp b/projects/hip/src/hip_hcc.cpp index fec5bb6a8a..760f46046a 100644 --- a/projects/hip/src/hip_hcc.cpp +++ b/projects/hip/src/hip_hcc.cpp @@ -1803,6 +1803,20 @@ void ihipStream_t::resolveHcMemcpyDirection(unsigned hipMemKind, } +void printPointerInfo(unsigned dbFlag, const char *tag, const void *ptr, const hc::AmPointerInfo &ptrInfo) +{ + tprintf (dbFlag, " %s=%p baseHost=%p baseDev=%p sz=%zu home_dev=%d tracked=%d isDevMem=%d registered=%d\n", + tag, ptr, + ptrInfo._hostPointer, ptrInfo._devicePointer, ptrInfo._sizeBytes, + ptrInfo._appId, ptrInfo._sizeBytes != 0, ptrInfo._isInDeviceMem, !ptrInfo._isAmManaged); +} + + +// TODO : For registered and host memory, if the portable flag is set, we need to recognize that and perform appropriate copy operation. +// What can happen now is that Portable memory is mapped into multiple devices but Peer access is not enabled. i +// The peer detection logic doesn't see that the memory is already mapped and so tries to use an unpinned copy algorithm. If this is PinInPlace, then an error can occur. +// Need to track Portable flag correctly or use new RT functionality to query the peer status for the pointer. +// // TODO - remove kind parm from here or use it below? void ihipStream_t::locked_copySync(void* dst, const void* src, size_t sizeBytes, unsigned kind, bool resolveOn) { @@ -1819,6 +1833,16 @@ void ihipStream_t::locked_copySync(void* dst, const void* src, size_t sizeBytes, bool dstTracked = (hc::am_memtracker_getinfo(&dstPtrInfo, dst) == AM_SUCCESS); bool srcTracked = (hc::am_memtracker_getinfo(&srcPtrInfo, src) == AM_SUCCESS); + + // Some code in HCC and in printPointerInfo uses _sizeBytes==0 as an indication ptr is not valid, so check it here: + if (!dstTracked) { + assert (dstPtrInfo._sizeBytes == 0); + } + if (!srcTracked) { + assert (srcPtrInfo._sizeBytes == 0); + } + + hc::hcCommandKind hcCopyDir; ihipCtx_t *copyDevice; bool forceUnpinnedCopy; @@ -1831,12 +1855,8 @@ void ihipStream_t::locked_copySync(void* dst, const void* src, size_t sizeBytes, dst, dstPtrInfo._appId, dstPtrInfo._isInDeviceMem, src, srcPtrInfo._appId, srcPtrInfo._isInDeviceMem, sizeBytes, hcMemcpyStr(hcCopyDir), forceUnpinnedCopy); - tprintf (DB_COPY, " dst=%p baseHost=%p baseDev=%p sz=%zu home_dev=%d tracked=%d isDevMem=%d\n", - dst, dstPtrInfo._hostPointer, dstPtrInfo._devicePointer, dstPtrInfo._sizeBytes, - dstPtrInfo._appId, dstTracked, dstPtrInfo._isInDeviceMem); - tprintf (DB_COPY, " src=%p baseHost=%p baseDev=%p sz=%zu home_dev=%d tracked=%d isDevMem=%d\n", - src, srcPtrInfo._hostPointer, srcPtrInfo._devicePointer, srcPtrInfo._sizeBytes, - srcPtrInfo._appId, srcTracked, srcPtrInfo._isInDeviceMem); + printPointerInfo(DB_COPY, " dst", dst, dstPtrInfo); + printPointerInfo(DB_COPY, " src", src, srcPtrInfo); this->ensureHaveQueue(crit); @@ -1921,12 +1941,8 @@ void ihipStream_t::locked_copyAsync(void* dst, const void* src, size_t sizeBytes dst, dstPtrInfo._appId, dstPtrInfo._isInDeviceMem, src, srcPtrInfo._appId, srcPtrInfo._isInDeviceMem, sizeBytes, hcMemcpyStr(hcCopyDir), forceUnpinnedCopy); - tprintf (DB_COPY, " dst=%p baseHost=%p baseDev=%p sz=%zu home_dev=%d tracked=%d isDevMem=%d\n", - dst, dstPtrInfo._hostPointer, dstPtrInfo._devicePointer, dstPtrInfo._sizeBytes, - dstPtrInfo._appId, dstTracked, dstPtrInfo._isInDeviceMem); - tprintf (DB_COPY, " src=%p baseHost=%p baseDev=%p sz=%zu home_dev=%d tracked=%d isDevMem=%d\n", - src, srcPtrInfo._hostPointer, srcPtrInfo._devicePointer, srcPtrInfo._sizeBytes, - srcPtrInfo._appId, srcTracked, srcPtrInfo._isInDeviceMem); + printPointerInfo(DB_COPY, " dst", dst, dstPtrInfo); + printPointerInfo(DB_COPY, " src", src, srcPtrInfo); // "tracked" really indicates if the pointer's virtual address is available in the GPU address space. // If both pointers are not tracked, we need to fall back to a sync copy. diff --git a/projects/hip/src/hip_memory.cpp b/projects/hip/src/hip_memory.cpp index 314dee97dc..b8a1d1646a 100644 --- a/projects/hip/src/hip_memory.cpp +++ b/projects/hip/src/hip_memory.cpp @@ -35,6 +35,14 @@ THE SOFTWARE. // Memory // // +// +//HIP uses several "app*" fields HC memory tracker to track state necessary for the HIP API. +//_appId : DeviceID. For device mem, this is device where the memory is physically allocated. +// For host or registered mem, this is the current device when the memory is allocated or registered. This device will have a GPUVM mapping for the host mem. +// +//_appAllocationFlags : These are flags provided by the user when allocation is performed. They are returned to user in hipHostGetFlags and other APIs. +// TODO - add more info here when available. +// hipError_t hipPointerGetAttributes(hipPointerAttribute_t *attributes, void* ptr) { HIP_INIT_API(attributes, ptr); @@ -78,6 +86,7 @@ hipError_t hipPointerGetAttributes(hipPointerAttribute_t *attributes, void* ptr) return ihipLogStatus(e); } + hipError_t hipHostGetDevicePointer(void **devicePointer, void *hostPointer, unsigned flags) { HIP_INIT_API(devicePointer, hostPointer, flags); @@ -102,6 +111,7 @@ hipError_t hipHostGetDevicePointer(void **devicePointer, void *hostPointer, unsi return ihipLogStatus(e); } + hipError_t hipMalloc(void** ptr, size_t sizeBytes) { HIP_INIT_API(ptr, sizeBytes); @@ -227,16 +237,20 @@ hipError_t hipHostMalloc(void** ptr, size_t sizeBytes, unsigned int flags) return ihipLogStatus(hip_status); } +// Deprecated function: hipError_t hipMallocHost(void** ptr, size_t sizeBytes) { return hipHostMalloc(ptr, sizeBytes, 0); } + +// Deprecated function: hipError_t hipHostAlloc(void** ptr, size_t sizeBytes, unsigned int flags) { return hipHostMalloc(ptr, sizeBytes, flags); }; + // width in bytes hipError_t hipMallocPitch(void** ptr, size_t* pitch, size_t width, size_t height) { @@ -374,6 +388,8 @@ hipError_t hipHostGetFlags(unsigned int* flagsPtr, void* hostPtr) return ihipLogStatus(hip_status); } + +// TODO - need to fix several issues here related to P2P access, host memory fallback. hipError_t hipHostRegister(void *hostPtr, size_t sizeBytes, unsigned int flags) { HIP_INIT_API(hostPtr, sizeBytes, flags); @@ -406,7 +422,7 @@ hipError_t hipHostRegister(void *hostPtr, size_t sizeBytes, unsigned int flags) am_status = hc::am_memory_host_lock(device->_acc, hostPtr, sizeBytes, &vecAcc[0], vecAcc.size()); hc::am_memtracker_update(hostPtr, device->_deviceId, flags); - tprintf(DB_MEM, " %s registered ptr=%p\n", __func__, hostPtr); + tprintf(DB_MEM, " %s registered ptr=%p and allowed access to %zu peers\n", __func__, hostPtr, vecAcc.size()); if(am_status == AM_SUCCESS){ hip_status = hipSuccess; } else { @@ -605,6 +621,7 @@ hipError_t hipMemcpy(void* dst, const void* src, size_t sizeBytes, hipMemcpyKind return ihipLogStatus(e); } + hipError_t hipMemcpyHtoD(hipDeviceptr_t dst, void* src, size_t sizeBytes) { HIP_INIT_CMD_API(dst, src, sizeBytes); @@ -626,6 +643,7 @@ hipError_t hipMemcpyHtoD(hipDeviceptr_t dst, void* src, size_t sizeBytes) return ihipLogStatus(e); } + hipError_t hipMemcpyDtoH(void* dst, hipDeviceptr_t src, size_t sizeBytes) { HIP_INIT_CMD_API(dst, src, sizeBytes); @@ -647,6 +665,7 @@ hipError_t hipMemcpyDtoH(void* dst, hipDeviceptr_t src, size_t sizeBytes) return ihipLogStatus(e); } + hipError_t hipMemcpyDtoD(hipDeviceptr_t dst, hipDeviceptr_t src, size_t sizeBytes) { HIP_INIT_CMD_API(dst, src, sizeBytes); @@ -668,6 +687,7 @@ hipError_t hipMemcpyDtoD(hipDeviceptr_t dst, hipDeviceptr_t src, size_t sizeByte return ihipLogStatus(e); } + hipError_t hipMemcpyHtoH(void* dst, void* src, size_t sizeBytes) { HIP_INIT_CMD_API(dst, src, sizeBytes); diff --git a/projects/hip/tests/src/runtimeApi/memory/hipHostRegister.cpp b/projects/hip/tests/src/runtimeApi/memory/hipHostRegister.cpp index 6c81ec0d91..eae73e1a65 100644 --- a/projects/hip/tests/src/runtimeApi/memory/hipHostRegister.cpp +++ b/projects/hip/tests/src/runtimeApi/memory/hipHostRegister.cpp @@ -45,17 +45,13 @@ int main(){ A[i] = float(1); } - // Copy to B, this should be optimal pinned malloc copy: - float *B; - HIPCHECK(hipMalloc(&B, size)); - HIPCHECK(hipMemcpy(B, A, size, hipMemcpyHostToDevice)); - for(int i=0;i Date: Fri, 17 Feb 2017 17:14:55 -0600 Subject: [PATCH 206/281] Add first step to a "registerd" mode in hipBusBandwidth. [ROCm/hip commit: f022bd651fbb3bd1551efdbc9e7ca0598c57cbf1] --- .../hipBusBandwidth/hipBusBandwidth.cpp | 163 +++++++++++------- 1 file changed, 104 insertions(+), 59 deletions(-) diff --git a/projects/hip/samples/1_Utils/hipBusBandwidth/hipBusBandwidth.cpp b/projects/hip/samples/1_Utils/hipBusBandwidth/hipBusBandwidth.cpp index 7cb3e7908e..a1b2fd1705 100644 --- a/projects/hip/samples/1_Utils/hipBusBandwidth/hipBusBandwidth.cpp +++ b/projects/hip/samples/1_Utils/hipBusBandwidth/hipBusBandwidth.cpp @@ -6,9 +6,12 @@ #include "ResultDatabase.h" +enum MallocMode {MallocPinned, MallocUnpinned, MallocRegistered}; + // Cmdline parms: bool p_verbose = false; -bool p_pinned = true; +MallocMode p_malloc_mode = MallocPinned; +int p_numa_ctl = -1; int p_iterations = 10; int p_beatsperiteration=1; int p_device = 0; @@ -21,7 +24,7 @@ bool p_h2d = true; bool p_d2h = true; bool p_bidir = true; - +#define NO_CHECK #define CHECK_HIP_ERROR() \ @@ -36,6 +39,14 @@ bool p_bidir = true; } +std::string mallocModeString(int mallocMode) { + switch (mallocMode) { + case MallocPinned : return "pinned"; + case MallocUnpinned: return "unpinned"; + case MallocRegistered: return "registered"; + default: return "mallocmode-UNKNOWN"; + }; +}; // **************************************************************************** int sizeToBytes(int size) { @@ -106,7 +117,7 @@ void RunBenchmark_H2D(ResultDatabase &resultDB) // Create some host memory pattern float *hostMem = NULL; - if (p_pinned) + if (p_malloc_mode == MallocPinned) { hipHostMalloc((void**)&hostMem, sizeof(float) * numMaxFloats); while (hipGetLastError() != hipSuccess) @@ -116,20 +127,29 @@ void RunBenchmark_H2D(ResultDatabase &resultDB) --nSizes; if (nSizes < 1) { - std::cerr << "Error: Couldn't allocated any pinned buffer\n"; + std::cerr << "Error: Couldn't allocate any pinned buffer\n"; return; } numMaxFloats = 1024 * (sizes[nSizes-1]) / 4; hipHostMalloc((void**)&hostMem, sizeof(float) * numMaxFloats); } } - else + else if (p_malloc_mode == MallocUnpinned) { if (p_alignedhost) { hostMem = (float*)aligned_alloc(p_alignedhost, numMaxFloats*sizeof(float)); } else { hostMem = new float[numMaxFloats]; } + } + else if (p_malloc_mode == MallocRegistered) + { + if (p_numa_ctl == -1) { + hostMem = (float*)malloc(numMaxFloats*sizeof(float)); + } + + hipHostRegister(hostMem, numMaxFloats * sizeof(float), 0); + CHECK_HIP_ERROR(); } for (int i = 0; i < numMaxFloats; i++) @@ -146,7 +166,7 @@ void RunBenchmark_H2D(ResultDatabase &resultDB) --nSizes; if (nSizes < 1) { - std::cerr << "Error: Couldn't allocated any device buffer\n"; + std::cerr << "Error: Couldn't allocate any device buffer\n"; return; } numMaxFloats = 1024 * (sizes[nSizes-1]) / 4; @@ -199,8 +219,8 @@ void RunBenchmark_H2D(ResultDatabase &resultDB) } else { sprintf(sizeStr, "%9s", sizeToString(thisSize).c_str()); } - resultDB.AddResult(std::string("H2D_Bandwidth") + (p_pinned ? "_Pinned" : "_Unpinned"), sizeStr, "GB/sec", speed); - resultDB.AddResult(std::string("H2D_Time") + (p_pinned ? "_Pinned" : "_Unpinned"), sizeStr, "ms", t); + resultDB.AddResult(std::string("H2D_Bandwidth") + "_" + mallocModeString(p_malloc_mode), sizeStr, "GB/sec", speed); + resultDB.AddResult(std::string("H2D_Time") + mallocModeString(p_malloc_mode), sizeStr, "ms", t); if (p_onesize) { break; @@ -212,6 +232,8 @@ void RunBenchmark_H2D(ResultDatabase &resultDB) numMaxFloats = sizeToBytes(p_onesize) / sizeof(float); } +#ifndef NO_CHECK + // Check. First reset the host memory, then copy-back result. Then compare against original ref value. for (int i = 0; i < numMaxFloats; i++) { @@ -225,24 +247,36 @@ void RunBenchmark_H2D(ResultDatabase &resultDB) printf ("error: H2D. i=%d reference:%6.f != copyback:%6.2f\n", i, ref, hostMem[i]); } } +#endif // Cleanup hipFree((void*)device); CHECK_HIP_ERROR(); - if (p_pinned) - { + switch (p_malloc_mode) { + case MallocPinned: hipHostFree((void*)hostMem); CHECK_HIP_ERROR(); - } - else - { + break; + + case MallocUnpinned: if (p_alignedhost) { delete[] hostMem; } else { free(hostMem); } + break; + + case MallocRegistered: + hipHostUnregister(hostMem); + CHECK_HIP_ERROR(); + free(hostMem); + break; + default: + assert(0); } + + hipEventDestroy(start); hipEventDestroy(stop); } @@ -257,38 +291,40 @@ void RunBenchmark_D2H(ResultDatabase &resultDB) // Create some host memory pattern float *hostMem1; float *hostMem2; - if (p_pinned) + if (p_malloc_mode == MallocPinned) { hipHostMalloc((void**)&hostMem1, sizeof(float)*numMaxFloats); hipError_t err1 = hipGetLastError(); hipHostMalloc((void**)&hostMem2, sizeof(float)*numMaxFloats); hipError_t err2 = hipGetLastError(); - while (err1 != hipSuccess || err2 != hipSuccess) - { - // free the first buffer if only the second failed - if (err1 == hipSuccess) - hipHostFree((void*)hostMem1); + while (err1 != hipSuccess || err2 != hipSuccess) + { + // free the first buffer if only the second failed + if (err1 == hipSuccess) + hipHostFree((void*)hostMem1); - // drop the size and try again - if (p_verbose) std::cout << " - dropping size allocating pinned mem\n"; - --nSizes; - if (nSizes < 1) - { - std::cerr << "Error: Couldn't allocated any pinned buffer\n"; - return; - } - numMaxFloats = 1024 * (sizes[nSizes-1]) / 4; - hipHostMalloc((void**)&hostMem1, sizeof(float)*numMaxFloats); - err1 = hipGetLastError(); - hipHostMalloc((void**)&hostMem2, sizeof(float)*numMaxFloats); - err2 = hipGetLastError(); - } - } - else + // drop the size and try again + if (p_verbose) std::cout << " - dropping size allocating pinned mem\n"; + --nSizes; + if (nSizes < 1) + { + std::cerr << "Error: Couldn't allocate any pinned buffer\n"; + return; + } + numMaxFloats = 1024 * (sizes[nSizes-1]) / 4; + hipHostMalloc((void**)&hostMem1, sizeof(float)*numMaxFloats); + err1 = hipGetLastError(); + hipHostMalloc((void**)&hostMem2, sizeof(float)*numMaxFloats); + err2 = hipGetLastError(); + } + } + else if (p_malloc_mode == MallocUnpinned) { hostMem1 = new float[numMaxFloats]; hostMem2 = new float[numMaxFloats]; } + + for (int i=0; i Date: Fri, 10 Mar 2017 15:04:46 -0600 Subject: [PATCH 207/281] Refactor registered memory calls. [ROCm/hip commit: 524e007db54c179e52bd89b38d021452749e3ea0] --- .../include/hip/hcc_detail/hip_runtime_api.h | 11 + .../hipBusBandwidth/hipBusBandwidth.cpp | 52 +++- projects/hip/src/hip_memory.cpp | 233 +++++++++--------- 3 files changed, 176 insertions(+), 120 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h index 080f82d9ed..7f85aad28d 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h @@ -858,6 +858,8 @@ hipError_t hipPointerGetAttributes(hipPointerAttribute_t *attributes, void* ptr) * @param[out] ptr Pointer to the allocated memory * @param[in] size Requested memory size * + * If size is 0, no memory is allocated, *ptr returns nullptr, and hipSuccess is returned. + * * @return #hipSuccess * * @see hipMallocPitch, hipFree, hipMallocArray, hipFreeArray, hipMalloc3D, hipMalloc3DArray, hipHostFree, hipHostMalloc @@ -870,6 +872,8 @@ hipError_t hipMalloc(void** ptr, size_t size) ; * @param[out] ptr Pointer to the allocated host pinned memory * @param[in] size Requested memory size * + * If size is 0, no memory is allocated, *ptr returns nullptr, and hipSuccess is returned. + * * @return #hipSuccess, #hipErrorMemoryAllocation * * @deprecated use hipHostMalloc() instead @@ -883,6 +887,8 @@ hipError_t hipMallocHost(void** ptr, size_t size) __attribute__((deprecated("use * @param[in] size Requested memory size * @param[in] flags Type of host memory allocation * + * If size is 0, no memory is allocated, *ptr returns nullptr, and hipSuccess is returned. + * * @return #hipSuccess, #hipErrorMemoryAllocation * * @see hipSetDeviceFlags, hipHostFree @@ -896,6 +902,8 @@ hipError_t hipHostMalloc(void** ptr, size_t size, unsigned int flags) ; * @param[in] size Requested memory size * @param[in] flags Type of host memory allocation * + * If size is 0, no memory is allocated, *ptr returns nullptr, and hipSuccess is returned. + * * @return #hipSuccess, #hipErrorMemoryAllocation * * @deprecated use hipHostMalloc() instead @@ -980,6 +988,9 @@ hipError_t hipHostUnregister(void* hostPtr) ; * @param[out] pitch Pitch for allocation (in bytes) * @param[in] width Requested pitched allocation width (in bytes) * @param[in] height Requested pitched allocation height + * + * If size is 0, no memory is allocated, *ptr returns nullptr, and hipSuccess is returned. + * * @return Error code * * @see hipMalloc, hipFree, hipMallocArray, hipFreeArray, hipHostFree, hipMalloc3D, hipMalloc3DArray, hipHostMalloc diff --git a/projects/hip/samples/1_Utils/hipBusBandwidth/hipBusBandwidth.cpp b/projects/hip/samples/1_Utils/hipBusBandwidth/hipBusBandwidth.cpp index a1b2fd1705..09f78543c9 100644 --- a/projects/hip/samples/1_Utils/hipBusBandwidth/hipBusBandwidth.cpp +++ b/projects/hip/samples/1_Utils/hipBusBandwidth/hipBusBandwidth.cpp @@ -24,7 +24,7 @@ bool p_h2d = true; bool p_d2h = true; bool p_bidir = true; -#define NO_CHECK +//#define NO_CHECK #define CHECK_HIP_ERROR() \ @@ -151,6 +151,10 @@ void RunBenchmark_H2D(ResultDatabase &resultDB) hipHostRegister(hostMem, numMaxFloats * sizeof(float), 0); CHECK_HIP_ERROR(); } + else + { + assert(0); + } for (int i = 0; i < numMaxFloats; i++) { @@ -323,6 +327,22 @@ void RunBenchmark_D2H(ResultDatabase &resultDB) hostMem1 = new float[numMaxFloats]; hostMem2 = new float[numMaxFloats]; } + else if (p_malloc_mode == MallocRegistered) + { + if (p_numa_ctl == -1) { + hostMem1 = (float*)malloc(numMaxFloats*sizeof(float)); + hostMem2 = (float*)malloc(numMaxFloats*sizeof(float)); + } + + hipHostRegister(hostMem1, numMaxFloats * sizeof(float), 0); + CHECK_HIP_ERROR(); + hipHostRegister(hostMem2, numMaxFloats * sizeof(float), 0); + CHECK_HIP_ERROR(); + } + else + { + assert(0); + } for (int i=0; i + + +// Internal HIP APIS: +namespace hip_internal { + +hipError_t memcpyAsync (void* dst, const void* src, size_t sizeBytes, hipMemcpyKind kind, hipStream_t stream) +{ + hipError_t e = hipSuccess; + + stream = ihipSyncAndResolveStream(stream); + + + if ((dst == NULL) || (src == NULL)) { + e= hipErrorInvalidValue; + } else if (stream) { + try { + stream->locked_copyAsync(dst, src, sizeBytes, kind); + } + catch (ihipException ex) { + e = ex._code; + } + } else { + e = hipErrorInvalidValue; + } + + return e; +} + +// return 0 on success or -1 on error: +int sharePtr(void *ptr, ihipCtx_t *ctx, unsigned hipFlags) +{ + int ret = 0; + + auto device = ctx->getWriteableDevice(); + + hc::am_memtracker_update(ptr, device->_deviceId, hipFlags); + int peerCnt=0; + { + LockedAccessor_CtxCrit_t crit(ctx->criticalData()); + // the peerCnt always stores self so make sure the trace actually + peerCnt = crit->peerCnt(); + tprintf(DB_MEM, " allow access to %d other peer(s)\n", peerCnt-1); + if (peerCnt > 1) { + + //printf ("peer self access\n"); + + // TODOD - remove me: + for (auto iter = crit->_peers.begin(); iter!=crit->_peers.end(); iter++) { + tprintf (DB_MEM, " allow access to peer: %s%s\n", (*iter)->toString().c_str(), (iter == crit->_peers.begin()) ? " (self)":""); + }; + + hsa_status_t s = hsa_amd_agents_allow_access(crit->peerCnt(), crit->peerAgents(), NULL, ptr); + if (s != HSA_STATUS_SUCCESS) { + ret = -1; + } + } + } + + return ret; +} + + + + +// Allocate a new pointer with am_alloc and share with all valid peers. +// Returns null-ptr if a memory error occurs (either allocation or sharing) +void * allocAndSharePtr(const char *msg, size_t sizeBytes, ihipCtx_t *ctx, unsigned amFlags, unsigned hipFlags) +{ + + void *ptr = nullptr; + + auto device = ctx->getWriteableDevice(); + + ptr = hc::am_alloc(sizeBytes, device->_acc, amFlags); + tprintf(DB_MEM, " alloc %s ptr:%p size:%zu on dev:%d\n", + msg, ptr, sizeBytes, device->_deviceId); + + if (ptr != nullptr) { + int r = sharePtr(ptr, ctx, hipFlags); + if (r != 0) { + ptr = nullptr; + } + } + + return ptr; +} + + +} // end namespace hip_internal + //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- // Memory @@ -128,37 +218,8 @@ hipError_t hipMalloc(void** ptr, size_t sizeBytes) if (ctx) { auto device = ctx->getWriteableDevice(); - const unsigned am_flags = 0; - *ptr = hc::am_alloc(sizeBytes, device->_acc, am_flags); + *ptr = hip_internal::allocAndSharePtr("device_mem", sizeBytes, ctx, 0/*amFlags*/, 0/*hipFlags*/); - - if (sizeBytes && (*ptr == NULL)) { - hip_status = hipErrorMemoryAllocation; - } else { - hc::am_memtracker_update(*ptr, device->_deviceId, 0); - int peerCnt=0; - { - LockedAccessor_CtxCrit_t crit(ctx->criticalData()); - // the peerCnt always stores self so make sure the trace actually - peerCnt = crit->peerCnt(); - tprintf(DB_MEM, " allocated device_mem ptr:%p size:%zu on dev:%d and allow access to %d other peer(s)\n", - *ptr, sizeBytes, device->_deviceId, peerCnt-1); - if (peerCnt > 1) { - - //printf ("peer self access\n"); - - // TODOD - remove me: - for (auto iter = crit->_peers.begin(); iter!=crit->_peers.end(); iter++) { - tprintf (DB_MEM, " allow access to peer: %s%s\n", (*iter)->toString().c_str(), (iter == crit->_peers.begin()) ? " (self)":""); - }; - - hsa_status_t e = hsa_amd_agents_allow_access(crit->peerCnt(), crit->peerAgents(), NULL, *ptr); - if (e != HSA_STATUS_SUCCESS) { - hip_status = hipErrorMemoryAllocation; - } - } - } - } } else { hip_status = hipErrorMemoryAllocation; } @@ -198,39 +259,16 @@ hipError_t hipHostMalloc(void** ptr, size_t sizeBytes, unsigned int flags) } else { auto device = ctx->getWriteableDevice(); - if(HIP_COHERENT_HOST_ALLOC){ - // Force to allocate finedgrained system memory - *ptr = hc::am_alloc(sizeBytes, device->_acc, amHostPinned); - if(sizeBytes < 1 && (*ptr == NULL)){ - hip_status = hipErrorMemoryAllocation; - } else { - // TODO - should OR in flags here? - hc::am_memtracker_update(*ptr, device->_deviceId, amHostCoherent); - } - tprintf(DB_MEM, " %s: finegrained system memory ptr=%p\n", __func__, *ptr); - } - else{ - // TODO - am_alloc requires writeable __acc, perhaps could be refactored? - // TODO - hipHostMallocMapped is be ignored on ROCM - all memory is mapped to host address space as WC. - *ptr = hc::am_alloc(sizeBytes, device->_acc, amHostPinned); - if (*ptr == NULL) { - hip_status = hipErrorMemoryAllocation; - } else { - hc::am_memtracker_update(*ptr, device->_deviceId, flags); - // TODO-hipHostMallocPortable should map the host memory into all contexts, regardless of peer status. - int peerCnt=0; - { - LockedAccessor_CtxCrit_t crit(ctx->criticalData()); - peerCnt = crit->peerCnt(); - if (peerCnt > 1) { - hsa_amd_agents_allow_access(crit->peerCnt(), crit->peerAgents(), NULL, *ptr); - } - } - tprintf(DB_MEM, "allocated pinned_host ptr:%p size:%zu on dev:%d and allow access to %d other peer(s)\n", *ptr, sizeBytes, device->_deviceId, peerCnt-1); - } - } + unsigned amFlags = HIP_COHERENT_HOST_ALLOC ? amHostCoherent : amHostPinned; + + *ptr = hip_internal::allocAndSharePtr(HIP_COHERENT_HOST_ALLOC ? "finegrained_host":"pinned_host", + sizeBytes, ctx, amFlags, flags); + if(sizeBytes && (*ptr == NULL)){ + hip_status = hipErrorMemoryAllocation; + } } } + if (HIP_SYNC_HOST_ALLOC) { hipDeviceSynchronize(); } @@ -272,22 +310,11 @@ hipError_t hipMallocPitch(void** ptr, size_t* pitch, size_t width, size_t height auto device = ctx->getWriteableDevice(); const unsigned am_flags = 0; - *ptr = hc::am_alloc(sizeBytes, device->_acc, am_flags); + *ptr = hip_internal::allocAndSharePtr("device_pitch", sizeBytes, ctx, am_flags, 0); if (sizeBytes && (*ptr == NULL)) { hip_status = hipErrorMemoryAllocation; - } else { - hc::am_memtracker_update(*ptr, device->_deviceId, 0); - { - LockedAccessor_CtxCrit_t crit(ctx->criticalData()); - if (crit->peerCnt() > 1) { // peerCnt includes self so only call allow_access if other peers involved: - hsa_status_t hsa_status = hsa_amd_agents_allow_access(crit->peerCnt(), crit->peerAgents(), NULL, *ptr); - if (hsa_status != HSA_STATUS_SUCCESS) { - hip_status = hipErrorMemoryAllocation; - } - } - } - } + } } else { hip_status = hipErrorMemoryAllocation; } @@ -321,41 +348,31 @@ hipError_t hipMallocArray(hipArray** array, const hipChannelFormatDesc* desc, void ** ptr = &array[0]->data; if (ctx) { - auto device = ctx->getWriteableDevice(); const unsigned am_flags = 0; const size_t size = width*height; + size_t allocSize = 0; switch(desc->f) { case hipChannelFormatKindSigned: - *ptr = hc::am_alloc(size*sizeof(int), device->_acc, am_flags); + allocSize = size * sizeof(int); break; case hipChannelFormatKindUnsigned: - *ptr = hc::am_alloc(size*sizeof(unsigned int), device->_acc, am_flags); + allocSize = size * sizeof(unsigned int); break; case hipChannelFormatKindFloat: - *ptr = hc::am_alloc(size*sizeof(float), device->_acc, am_flags); + allocSize = size * sizeof(float); break; case hipChannelFormatKindNone: - *ptr = hc::am_alloc(size*sizeof(size_t), device->_acc, am_flags); + allocSize = size * sizeof(size_t); break; default: hip_status = hipErrorUnknown; break; } + *ptr = hip_internal::allocAndSharePtr("device_array", allocSize, ctx, am_flags, 0); if (size && (*ptr == NULL)) { hip_status = hipErrorMemoryAllocation; - } else { - hc::am_memtracker_update(*ptr, device->_deviceId, 0); - { - LockedAccessor_CtxCrit_t crit(ctx->criticalData()); - if (crit->peerCnt() > 1) { // peerCnt includes self so only call allow_access if other peers involved: - hsa_status_t hsa_status = hsa_amd_agents_allow_access(crit->peerCnt(), crit->peerAgents(), NULL, *ptr); - if (hsa_status != HSA_STATUS_SUCCESS) { - hip_status = hipErrorMemoryAllocation; - } - } - } - } + } } else { hip_status = hipErrorMemoryAllocation; @@ -409,12 +426,13 @@ hipError_t hipHostRegister(void *hostPtr, size_t sizeBytes, unsigned int flags) hip_status = hipErrorHostMemoryAlreadyRegistered; } else { auto ctx = ihipGetTlsDefaultCtx(); - if(hostPtr == NULL){ + if (hostPtr == NULL) { return ihipLogStatus(hipErrorInvalidValue); } + //TODO-test : multi-gpu access to registered host memory. if (ctx) { - auto device = ctx->getWriteableDevice(); if(flags == hipHostRegisterDefault || flags == hipHostRegisterPortable || flags == hipHostRegisterMapped){ + auto device = ctx->getWriteableDevice(); std::vectorvecAcc; for(int i=0;i_acc); @@ -711,32 +729,6 @@ hipError_t hipMemcpyHtoH(void* dst, void* src, size_t sizeBytes) -// Internal copy sync: -namespace hip_internal { - -hipError_t memcpyAsync (void* dst, const void* src, size_t sizeBytes, hipMemcpyKind kind, hipStream_t stream) -{ - hipError_t e = hipSuccess; - - stream = ihipSyncAndResolveStream(stream); - - - if ((dst == NULL) || (src == NULL)) { - e= hipErrorInvalidValue; - } else if (stream) { - try { - stream->locked_copyAsync(dst, src, sizeBytes, kind); - } - catch (ihipException ex) { - e = ex._code; - } - } else { - e = hipErrorInvalidValue; - } - - return e; -} -} // end namespace hip_internal hipError_t hipMemcpyAsync(void* dst, const void* src, size_t sizeBytes, hipMemcpyKind kind, hipStream_t stream) @@ -1012,6 +1004,7 @@ hipError_t hipMemset(void* dst, int value, size_t sizeBytes ) return ihipLogStatus(e); } + hipError_t hipMemGetInfo (size_t *free, size_t *total) { HIP_INIT_API(free, total); @@ -1067,6 +1060,7 @@ hipError_t hipMemPtrGetInfo(void *ptr, size_t *size) return ihipLogStatus(e); } + hipError_t hipFree(void* ptr) { HIP_INIT_API(ptr); @@ -1094,6 +1088,7 @@ hipError_t hipFree(void* ptr) return ihipLogStatus(hipStatus); } + hipError_t hipHostFree(void* ptr) { HIP_INIT_API(ptr); From 3b768fb36cdcb086e59af06994d80d739df8708a Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Sun, 12 Mar 2017 09:51:33 -0500 Subject: [PATCH 208/281] Update hiphostregister test. Move check to correct place. [ROCm/hip commit: e7d6a3432772b81753e91aedb2fd396f3a85765c] --- .../tests/src/runtimeApi/memory/hipHostRegister.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/projects/hip/tests/src/runtimeApi/memory/hipHostRegister.cpp b/projects/hip/tests/src/runtimeApi/memory/hipHostRegister.cpp index eae73e1a65..1a1319c500 100644 --- a/projects/hip/tests/src/runtimeApi/memory/hipHostRegister.cpp +++ b/projects/hip/tests/src/runtimeApi/memory/hipHostRegister.cpp @@ -51,24 +51,28 @@ int main(){ HIPCHECK(hipHostGetDevicePointer((void**)&Ad[i], A, 0)); } - // Use device pointer inside a kernel: + // Reference the registered device pointer Ad from inside the kernel: for(int i=0;i Date: Mon, 13 Mar 2017 11:16:05 -0500 Subject: [PATCH 209/281] make sure the inter-thread intrinsics are working post hawaii Change-Id: I30ea5284c2160276f5bc0f937dfd386ca8640ce8 [ROCm/hip commit: c8969811db8e6315796cd4a9e07a8360d50ba8a8] --- projects/hip/include/hip/hcc_detail/hip_runtime.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime.h b/projects/hip/include/hip/hcc_detail/hip_runtime.h index 6acc604909..332e9bab46 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime.h @@ -226,7 +226,7 @@ __device__ int __all( int input); __device__ int __any( int input); __device__ unsigned long long int __ballot( int input); -#if __HIP_ARCH_GFX803__ == 1 +#if __HIP_ARCH_GFX701__ == 0 // warp shuffle functions #ifdef __cplusplus From 4a21f2f768b2133b8240c4d7f04b259de56c14d2 Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Tue, 14 Mar 2017 13:51:38 +0530 Subject: [PATCH 210/281] Add gfx900 support Change-Id: I3be2fbdcb6d3fa776c4fe668586c67245a1323f2 [ROCm/hip commit: db1bd201cdf23e247b1a181b2ae936df290ef97f] --- projects/hip/CMakeLists.txt | 2 +- projects/hip/bin/hipcc | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/projects/hip/CMakeLists.txt b/projects/hip/CMakeLists.txt index ce0eeb362d..1ba58496f4 100644 --- a/projects/hip/CMakeLists.txt +++ b/projects/hip/CMakeLists.txt @@ -189,7 +189,7 @@ if(HIP_PLATFORM STREQUAL "hcc") execute_process(COMMAND ${HCC_HOME}/bin/hcc-config --ldflags OUTPUT_VARIABLE HCC_LD_FLAGS) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${HCC_LD_FLAGS} -Wl,-Bsymbolic") - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --amdgpu-target=gfx701 --amdgpu-target=gfx801 --amdgpu-target=gfx802 --amdgpu-target=gfx803") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --amdgpu-target=gfx701 --amdgpu-target=gfx801 --amdgpu-target=gfx802 --amdgpu-target=gfx803 --amdgpu-target=gfx900") add_library(hip_hcc SHARED ${SOURCE_FILES_RUNTIME}) target_link_libraries(hip_hcc PRIVATE hc_am) add_library(hip_hcc_static STATIC ${SOURCE_FILES_RUNTIME}) diff --git a/projects/hip/bin/hipcc b/projects/hip/bin/hipcc index 7e15d6b2e6..bd6ce9b4e4 100755 --- a/projects/hip/bin/hipcc +++ b/projects/hip/bin/hipcc @@ -74,6 +74,7 @@ $target_gfx701 = 0; $target_gfx801 = 0; $target_gfx802 = 0; $target_gfx803 = 0; +$target_gfx900 = 0; if ($HIP_PLATFORM eq "hcc") { $HSA_PATH=$ENV{'HSA_PATH'} // "/opt/rocm/hsa"; @@ -261,6 +262,10 @@ foreach $arg (@ARGV) { $target_gfx803 = 1; } + if($arg eq '--amdgpu-target=gfx900') + { + $target_gfx900 = 1; + } if(($trimarg eq '-stdlib=libstdc++') and ($setStdLib eq 0)) { $HIPCXXFLAGS .= $HCC_WA_FLAGS; @@ -343,9 +348,13 @@ if($HIP_PLATFORM eq "hcc"){ $HIPCXXFLAGS .= " -D__HIP_ARCH_GFX803__=1 "; $ENV{HCC_EXTRA_LIBRARIES_GFX803}="$HIP_PATH/lib/hip_hc_gfx803.ll\n"; } - if ($target_gfx701 eq 0 and $target_gfx801 eq 0 and $target_gfx802 eq 0 and $target_gfx803 eq 0) + if ($target_gfx900 eq 1) { + $HIPLDFLAGS .= " --amdgpu-target=gfx900"; + $HIPCXXFLAGS .= " -D__HIP_ARCH_GFX900__=1 "; + } + if ($target_gfx701 eq 0 and $target_gfx801 eq 0 and $target_gfx802 eq 0 and $target_gfx803 eq 0 and $target_gfx900 eq 0) { - $HIPLDFLAGS .= " --amdgpu-target=gfx701 --amdgpu-target=gfx801 --amdgpu-target=gfx802 --amdgpu-target=gfx803"; + $HIPLDFLAGS .= " --amdgpu-target=gfx701 --amdgpu-target=gfx801 --amdgpu-target=gfx802 --amdgpu-target=gfx803 --amdgpu-target=gfx900"; $ENV{HCC_EXTRA_LIBRARIES_GFX803}="$HIP_PATH/lib/hip_hc_gfx803.ll\n"; } From 26bd86e76f87d0a1d1055ac03589fbe26526b51c Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Tue, 14 Mar 2017 14:25:34 +0530 Subject: [PATCH 211/281] hipcc: Support targets specified via HCC_AMDGPU_TARGET Change-Id: I69fda40d9f666325d377f4b4335e7ee693069214 [ROCm/hip commit: 13ab31ba346b44891810e324d9da750f40157ad0] --- projects/hip/bin/hipcc | 84 +++++++++++++++++++++++++++--------------- 1 file changed, 55 insertions(+), 29 deletions(-) diff --git a/projects/hip/bin/hipcc b/projects/hip/bin/hipcc index bd6ce9b4e4..7179517f7b 100755 --- a/projects/hip/bin/hipcc +++ b/projects/hip/bin/hipcc @@ -23,8 +23,8 @@ use File::Basename; # HSA_PATH : Path to HSA dir (default /opt/rocm/hsa). Used on AMD platforms only. if(scalar @ARGV == 0){ -print "No Arguments passed, exiting ...\n"; -exit(-1); + print "No Arguments passed, exiting ...\n"; + exit(-1); } #--- @@ -190,18 +190,18 @@ if ($verbose & 0x4) { # Handle code object generation my $ISACMD=""; if($HIP_PLATFORM eq "hcc"){ - $ISACMD .= "set ROCM_PATH=$ROCM_PATH && set ROCM_TARGET=$ROCM_TARGET && $HIP_PATH/bin/hccgenco.sh "; - if($ARGV[0] eq "--genco"){ - foreach $isaarg (@ARGV[1..$#ARGV]){ - $ISACMD .= " "; - $ISACMD .= $isaarg; + $ISACMD .= "set ROCM_PATH=$ROCM_PATH && set ROCM_TARGET=$ROCM_TARGET && $HIP_PATH/bin/hccgenco.sh "; + if($ARGV[0] eq "--genco"){ + foreach $isaarg (@ARGV[1..$#ARGV]){ + $ISACMD .= " "; + $ISACMD .= $isaarg; + } + if ($verbose & 0x1) { + print "hipcc-cmd: ", $ISACMD, "\n"; + } + system($ISACMD) and die(); + exit(0); } - if ($verbose & 0x1) { - print "hipcc-cmd: ", $ISACMD, "\n"; - } - system($ISACMD) and die(); - exit(0); - } } if(($HIP_PLATFORM eq "hcc")){ @@ -211,18 +211,18 @@ if(($HIP_PLATFORM eq "hcc")){ } if($HIP_PLATFORM eq "nvcc"){ - $ISACMD .= "$HIP_PATH/bin/hipcc -ptx "; - if($ARGV[0] eq "--genco"){ - foreach $isaarg (@ARGV[1..$#ARGV]){ - $ISACMD .= " "; - $ISACMD .= $isaarg; + $ISACMD .= "$HIP_PATH/bin/hipcc -ptx "; + if($ARGV[0] eq "--genco"){ + foreach $isaarg (@ARGV[1..$#ARGV]){ + $ISACMD .= " "; + $ISACMD .= $isaarg; + } + if ($verbose & 0x1) { + print "hipcc-cmd: ", $ISACMD, "\n"; + } + system($ISACMD) and die(); + exit(0); } - if ($verbose & 0x1) { - print "hipcc-cmd: ", $ISACMD, "\n"; - } - system($ISACMD) and die(); - exit(0); - } } my $toolArgs = ""; # arguments to pass to the hcc or nvcc tool @@ -248,24 +248,25 @@ foreach $arg (@ARGV) } if($arg eq '--amdgpu-target=gfx701') { - $target_gfx701 = 1; + $target_gfx701 = 1; } if($arg eq '--amdgpu-target=gfx801') { - $target_gfx801 = 1; + $target_gfx801 = 1; } if($arg eq '--amdgpu-target=gfx802') { - $target_gfx802 = 1; + $target_gfx802 = 1; } if($arg eq '--amdgpu-target=gfx803') { - $target_gfx803 = 1; + $target_gfx803 = 1; } if($arg eq '--amdgpu-target=gfx900') { - $target_gfx900 = 1; + $target_gfx900 = 1; } + if(($trimarg eq '-stdlib=libstdc++') and ($setStdLib eq 0)) { $HIPCXXFLAGS .= $HCC_WA_FLAGS; @@ -325,6 +326,29 @@ foreach $arg (@ARGV) } $toolArgs .= " $arg" unless $swallowArg; } +foreach my $target (split(/,/, $ENV{HCC_AMDGPU_TARGET})) +{ + if($target eq 'gfx701') + { + $target_gfx701 = 1; + } + if($target eq 'gfx801') + { + $target_gfx801 = 1; + } + if($target eq 'gfx802') + { + $target_gfx802 = 1; + } + if($target eq 'gfx803') + { + $target_gfx803 = 1; + } + if($target eq 'gfx900') + { + $target_gfx900 = 1; + } +} if($HIP_PLATFORM eq "hcc"){ @@ -416,3 +440,5 @@ if ($runCmd) { } system ("$CMD") and die (); } + +# vim: ts=4:sw=4:expandtab:smartindent From aeacc966aecdf088b58cd75c2231a57d0156deb5 Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Tue, 14 Mar 2017 14:34:25 +0530 Subject: [PATCH 212/281] default to gfx803 instead of fatbin if no arch specified Change-Id: I83d56c6ede11c356d383b09d7eb3a5f08c8d8c84 [ROCm/hip commit: 63074e24d9e6b43aedae6003908561c823349d82] --- projects/hip/bin/hipcc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/projects/hip/bin/hipcc b/projects/hip/bin/hipcc index 7179517f7b..d2822fd0da 100755 --- a/projects/hip/bin/hipcc +++ b/projects/hip/bin/hipcc @@ -349,6 +349,10 @@ foreach my $target (split(/,/, $ENV{HCC_AMDGPU_TARGET})) $target_gfx900 = 1; } } +if ($target_gfx701 eq 0 and $target_gfx801 eq 0 and $target_gfx802 eq 0 and $target_gfx803 eq 0 and $target_gfx900 eq 0) +{ + $target_gfx803 = 1; +} if($HIP_PLATFORM eq "hcc"){ @@ -376,12 +380,6 @@ if($HIP_PLATFORM eq "hcc"){ $HIPLDFLAGS .= " --amdgpu-target=gfx900"; $HIPCXXFLAGS .= " -D__HIP_ARCH_GFX900__=1 "; } - if ($target_gfx701 eq 0 and $target_gfx801 eq 0 and $target_gfx802 eq 0 and $target_gfx803 eq 0 and $target_gfx900 eq 0) - { - $HIPLDFLAGS .= " --amdgpu-target=gfx701 --amdgpu-target=gfx801 --amdgpu-target=gfx802 --amdgpu-target=gfx803 --amdgpu-target=gfx900"; - $ENV{HCC_EXTRA_LIBRARIES_GFX803}="$HIP_PATH/lib/hip_hc_gfx803.ll\n"; - } - } if ($hasC and $HIP_PLATFORM eq 'nvcc') { From 88f720d9f3e45302354fd7ad5f36b13010150e1b Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Tue, 14 Mar 2017 15:56:18 +0530 Subject: [PATCH 213/281] 4_shfl and 5_2dshfl samples are unsupported on gfx701 Change-Id: I81eb880350f25e89573ba14c62b549c6c43f8c91 [ROCm/hip commit: 9f5a11a3fbbdcae0663e1d5b7c5cd8ad2d40ae40] --- projects/hip/samples/2_Cookbook/4_shfl/Makefile | 6 +++++- projects/hip/samples/2_Cookbook/5_2dshfl/Makefile | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/projects/hip/samples/2_Cookbook/4_shfl/Makefile b/projects/hip/samples/2_Cookbook/4_shfl/Makefile index 21c0e93959..56f54d9518 100644 --- a/projects/hip/samples/2_Cookbook/4_shfl/Makefile +++ b/projects/hip/samples/2_Cookbook/4_shfl/Makefile @@ -3,6 +3,10 @@ ifeq (,$(HIP_PATH)) HIP_PATH=../../.. endif +ifeq (gfx701, $(findstring gfx701,$(HCC_AMDGPU_TARGET))) + $(error gfx701 is not a supported device for this sample) +endif + HIPCC=$(HIP_PATH)/bin/hipcc TARGET=hcc @@ -22,7 +26,7 @@ CXX=$(HIPCC) $(EXECUTABLE): $(OBJECTS) - $(HIPCC) --amdgpu-target=gfx803 $(OBJECTS) -o $@ + $(HIPCC) $(OBJECTS) -o $@ test: $(EXECUTABLE) diff --git a/projects/hip/samples/2_Cookbook/5_2dshfl/Makefile b/projects/hip/samples/2_Cookbook/5_2dshfl/Makefile index 6abaf658b1..cfadb1a311 100644 --- a/projects/hip/samples/2_Cookbook/5_2dshfl/Makefile +++ b/projects/hip/samples/2_Cookbook/5_2dshfl/Makefile @@ -3,6 +3,10 @@ ifeq (,$(HIP_PATH)) HIP_PATH=../../.. endif +ifeq (gfx701, $(findstring gfx701,$(HCC_AMDGPU_TARGET))) + $(error gfx701 is not a supported device for this sample) +endif + HIPCC=$(HIP_PATH)/bin/hipcc TARGET=hcc @@ -22,7 +26,7 @@ CXX=$(HIPCC) $(EXECUTABLE): $(OBJECTS) - $(HIPCC) --amdgpu-target=gfx803 $(OBJECTS) -o $@ + $(HIPCC) $(OBJECTS) -o $@ test: $(EXECUTABLE) From 508ad44c7c7b86d0f5bf48d4305daa4dce75467e Mon Sep 17 00:00:00 2001 From: "Wen-Heng (Jack) Chung" Date: Tue, 14 Mar 2017 22:58:41 +0800 Subject: [PATCH 214/281] Revert "Changes to HIP to cope with Promote-free HCC" This reverts commit 9043ba55db3712304bab8aa608c5a77ad4ed09ef. Change-Id: I20a9bab3883ad09913b320210344d37599cb8fcd [ROCm/hip commit: 77e21dc09f39f37cc00b55083cb60150568f73cb] --- projects/hip/include/hip/hcc_detail/hip_runtime.h | 7 ++++--- projects/hip/include/hip/hcc_detail/host_defines.h | 2 +- projects/hip/src/device_functions.cpp | 4 ++-- projects/hip/src/device_util.cpp | 6 +++--- projects/hip/src/hip_fp16.cpp | 2 +- projects/hip/src/math_functions.cpp | 3 +-- projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp | 7 +++++++ projects/hip/tests/src/kernel/hipDynamicShared2.cpp | 2 +- 8 files changed, 20 insertions(+), 13 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime.h b/projects/hip/include/hip/hcc_detail/hip_runtime.h index eb0f7bf61a..332e9bab46 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime.h @@ -264,7 +264,7 @@ __device__ int __hip_move_dpp(int src, int dpp_ctrl, int row_mask, int bank_mask __host__ __device__ int min(int arg1, int arg2); __host__ __device__ int max(int arg1, int arg2); -__device__ void* __get_dynamicgroupbaseptr(); +__device__ __attribute__((address_space(3))) void* __get_dynamicgroupbaseptr(); /** @@ -422,9 +422,10 @@ do {\ // Macro to replace extern __shared__ declarations // to local variable definitions #define HIP_DYNAMIC_SHARED(type, var) \ - type* var = (type*)__get_dynamicgroupbaseptr(); \ + __attribute__((address_space(3))) type* var = \ + (__attribute__((address_space(3))) type*)__get_dynamicgroupbaseptr(); \ -#define HIP_DYNAMIC_SHARED_ATTRIBUTE +#define HIP_DYNAMIC_SHARED_ATTRIBUTE __attribute__((address_space(3))) #endif // __HCC__ diff --git a/projects/hip/include/hip/hcc_detail/host_defines.h b/projects/hip/include/hip/hcc_detail/host_defines.h index 012d3f0346..e401cb24f3 100644 --- a/projects/hip/include/hip/hcc_detail/host_defines.h +++ b/projects/hip/include/hip/hcc_detail/host_defines.h @@ -47,7 +47,7 @@ THE SOFTWARE. */ // _restrict is supported by the compiler #define __shared__ tile_static -#define __constant__ __attribute__((hc)) +#define __constant__ __attribute__((address_space(1))) #else // Non-HCC compiler diff --git a/projects/hip/src/device_functions.cpp b/projects/hip/src/device_functions.cpp index 10d8d3ab89..abc9db570e 100644 --- a/projects/hip/src/device_functions.cpp +++ b/projects/hip/src/device_functions.cpp @@ -41,8 +41,8 @@ struct holder32Bit { }; } __attribute__((aligned(4))); -__device__ struct holder64Bit hold64; -__device__ struct holder32Bit hold32; +struct holder64Bit hold64; +struct holder32Bit hold32; __device__ float __double2float_rd(double x) { diff --git a/projects/hip/src/device_util.cpp b/projects/hip/src/device_util.cpp index 88ffa7ab4d..4b0e7efefd 100644 --- a/projects/hip/src/device_util.cpp +++ b/projects/hip/src/device_util.cpp @@ -34,8 +34,8 @@ THE SOFTWARE. This is the best place to put them because the device global variables need to be initialized at the start. */ -__device__ char gpuHeap[SIZE_OF_HEAP]; -__device__ uint32_t gpuFlags[NUM_PAGES]; +__attribute__((address_space(1))) char gpuHeap[SIZE_OF_HEAP]; +__attribute__((address_space(1))) uint32_t gpuFlags[NUM_PAGES]; __device__ void *__hip_hc_malloc(size_t size) { @@ -1083,7 +1083,7 @@ __host__ __device__ int max(int arg1, int arg2) return (int)(hc::precise_math::fmax((float)arg1, (float)arg2)); } -__device__ void* __get_dynamicgroupbaseptr() +__device__ __attribute__((address_space(3))) void* __get_dynamicgroupbaseptr() { return hc::get_dynamic_group_segment_base_pointer(); } diff --git a/projects/hip/src/hip_fp16.cpp b/projects/hip/src/hip_fp16.cpp index e7f75844ff..b306a9d3de 100644 --- a/projects/hip/src/hip_fp16.cpp +++ b/projects/hip/src/hip_fp16.cpp @@ -31,7 +31,7 @@ struct hipHalfHolder{ #define HINF 65504 -__device__ static struct hipHalfHolder __hInfValue = {HINF}; +static struct hipHalfHolder __hInfValue = {HINF}; __device__ __half __hadd(__half a, __half b) { return a + b; diff --git a/projects/hip/src/math_functions.cpp b/projects/hip/src/math_functions.cpp index 6e919b3926..230eb2aacc 100644 --- a/projects/hip/src/math_functions.cpp +++ b/projects/hip/src/math_functions.cpp @@ -202,8 +202,7 @@ __device__ long long int llroundf(float x) int y = hc::precise_math::roundf(x); long long int z = y; return z; -} -__device__ float log10f(float x) +}__device__ float log10f(float x) { return hc::precise_math::log10f(x); } diff --git a/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp b/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp index 429c1d69ef..e58aa58877 100644 --- a/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp +++ b/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp @@ -31,8 +31,15 @@ THE SOFTWARE. #define NUM 1024 #define SIZE 1024*4 +#ifdef __HIP_PLATFORM_HCC__ +__attribute__((address_space(1))) int globalIn[NUM]; +__attribute__((address_space(1))) int globalOut[NUM]; +#endif + +#ifdef __HIP_PLATFORM_NVCC__ __device__ int globalIn[NUM]; __device__ int globalOut[NUM]; +#endif __global__ void Assign(hipLaunchParm lp, int* Out) { diff --git a/projects/hip/tests/src/kernel/hipDynamicShared2.cpp b/projects/hip/tests/src/kernel/hipDynamicShared2.cpp index ea24e9341f..0f6ebb4927 100644 --- a/projects/hip/tests/src/kernel/hipDynamicShared2.cpp +++ b/projects/hip/tests/src/kernel/hipDynamicShared2.cpp @@ -29,7 +29,7 @@ THE SOFTWARE. #include "hip/hip_runtime.h" #include "test_common.h" -#define LEN 8*1024 +#define LEN 16*1024 #define SIZE LEN*4 __global__ void vectorAdd(hipLaunchParm lp, float *Ad, float *Bd) { From 0bfd692b596b70538bf4b23fe8cff9881c6beb76 Mon Sep 17 00:00:00 2001 From: Rahul Garg Date: Tue, 14 Mar 2017 22:11:34 +0530 Subject: [PATCH 215/281] Added hipMemsetD8 Change-Id: I6a230a036c9c46c72a77d5f93c16ce8a00c3f837 [ROCm/hip commit: 1aba3c4375ffe483eee98a0efe8236d65be6ff93] --- .../include/hip/hcc_detail/hip_runtime_api.h | 21 +++--- projects/hip/src/hip_memory.cpp | 50 ++++++++++++++ .../hip/tests/src/context/hipMemsetD8.cpp | 67 +++++++++++++++++++ 3 files changed, 130 insertions(+), 8 deletions(-) create mode 100644 projects/hip/tests/src/context/hipMemsetD8.cpp diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h index 7f85aad28d..0d3ecc6613 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h @@ -1208,19 +1208,24 @@ hipError_t hipMemcpyAsync(void* dst, const void* src, size_t sizeBytes, hipMemcp #endif /** - * @brief Copy data from src to dst asynchronously. + * @brief Fills the first sizeBytes bytes of the memory area pointed to by dest with the constant byte value value. * - * It supports memory from host to device, - * device to host, device to device and host to host. - * - * @param[out] dst Data being copy to - * @param[in] src Data being copy from + * @param[out] dst Data being filled + * @param[in] constant value to be set * @param[in] sizeBytes Data size in bytes - * @param[in] accelerator_view Accelerator view which the copy is being enqueued - * @return #hipSuccess, #hipErrorInvalidValue, #hipErrorMemoryFree + * @return #hipSuccess, #hipErrorInvalidValue, #hipErrorNotInitialized */ hipError_t hipMemset(void* dst, int value, size_t sizeBytes ); +/** + * @brief Fills the first sizeBytes bytes of the memory area pointed to by dest with the constant byte value value. + * + * @param[out] dst Data ptr to be filled + * @param[in] constant value to be set + * @param[in] sizeBytes Data size in bytes + * @return #hipSuccess, #hipErrorInvalidValue, #hipErrorNotInitialized + */ +hipError_t hipMemsetD8(hipDeviceptr_t dest, unsigned char value, size_t sizeBytes ); /** * @brief Fills the first sizeBytes bytes of the memory area pointed to by dev with the constant byte value value. diff --git a/projects/hip/src/hip_memory.cpp b/projects/hip/src/hip_memory.cpp index c6b9406778..a92d11b847 100644 --- a/projects/hip/src/hip_memory.cpp +++ b/projects/hip/src/hip_memory.cpp @@ -1004,6 +1004,56 @@ hipError_t hipMemset(void* dst, int value, size_t sizeBytes ) return ihipLogStatus(e); } +hipError_t hipMemsetD8(hipDeviceptr_t dst, unsigned char value, size_t sizeBytes ) +{ + HIP_INIT_CMD_API(dst, value, sizeBytes); + + hipError_t e = hipSuccess; + + hipStream_t stream = hipStreamNull; + // TODO - call an ihip memset so HIP_TRACE is correct. + stream = ihipSyncAndResolveStream(stream); + + if (stream) { + auto crit = stream->lockopen_preKernelCommand(); + + stream->ensureHaveQueue(crit); + hc::completion_future cf ; + + if ((sizeBytes & 0x3) == 0) { + // use a faster dword-per-workitem copy: + try { + uint32_t value32 = (value << 24) | (value << 16) | (value << 8) | (value) ; + ihipMemsetKernel (stream, crit, static_cast (dst), value32, sizeBytes/sizeof(uint32_t), &cf); + } + catch (std::exception &ex) { + e = hipErrorInvalidValue; + } + } else { + // use a slow byte-per-workitem copy: + try { + ihipMemsetKernel (stream, crit, static_cast (dst), value, sizeBytes, &cf); + } + catch (std::exception &ex) { + e = hipErrorInvalidValue; + } + } + cf.wait(); + + stream->lockclose_postKernelCommand("hipMemsetD8", &crit->_av); + + + if (HIP_LAUNCH_BLOCKING) { + tprintf (DB_SYNC, "'%s' LAUNCH_BLOCKING wait for memset in %s.\n", __func__, ToString(stream).c_str()); + cf.wait(); + tprintf (DB_SYNC, "'%s' LAUNCH_BLOCKING memset completed in %s.\n", __func__, ToString(stream).c_str()); + } + } else { + e = hipErrorInvalidValue; + } + + return ihipLogStatus(e); +} hipError_t hipMemGetInfo (size_t *free, size_t *total) { diff --git a/projects/hip/tests/src/context/hipMemsetD8.cpp b/projects/hip/tests/src/context/hipMemsetD8.cpp new file mode 100644 index 0000000000..1cd43696aa --- /dev/null +++ b/projects/hip/tests/src/context/hipMemsetD8.cpp @@ -0,0 +1,67 @@ +/* +Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ +// Simple test for hipMemsetD8. +// Also serves as a template for other tests. + +/* HIT_START + * BUILD: %t %s ../test_common.cpp + * RUN: %t + * //Small copy + * RUN: %t -N 10 --memsetval 0x42 + * // Oddball size + * RUN: %t -N 10013 --memsetval 0x5a + * // Big copy + * RUN: %t -N 256M --memsetval 0xa6 + * HIT_END + */ + +#include "hip/hip_runtime.h" +#include "test_common.h" + +int main(int argc, char *argv[]) +{ + HipTest::parseStandardArguments(argc, argv, true); + size_t Nbytes = N*sizeof(char); + char *A_h; + hipDeviceptr_t A_d; + A_h = new char[Nbytes]; + + HIPCHECK ( hipMalloc(&A_d, Nbytes) ); + A_h = (char*)malloc(Nbytes); + + printf ("Size=%zu memsetval=%2x \n", Nbytes, memsetval); + HIPCHECK ( hipMemsetD8(A_d, memsetval, Nbytes) ); + + HIPCHECK ( hipMemcpy(A_h, A_d, Nbytes, hipMemcpyDeviceToHost)); + + for (int i=0; i Date: Tue, 14 Mar 2017 23:49:21 +0530 Subject: [PATCH 216/281] hipMemsetD8 support for HIP/NVCC path Change-Id: I48eee8266afd7b45a12d5ce2c4849b687a006c0f [ROCm/hip commit: 913867fe6a24863c286fb9debbc467af0d623ea6] --- projects/hip/include/hip/nvcc_detail/hip_runtime_api.h | 5 +++++ projects/hip/tests/src/context/hipMemsetD8.cpp | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h b/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h index dc51290167..8c3e0da639 100644 --- a/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h @@ -397,6 +397,11 @@ inline static hipError_t hipMemsetAsync(void* devPtr,int value, size_t count, hi return hipCUDAErrorTohipError(cudaMemsetAsync(devPtr, value, count, stream)); } +inline static hipError_t hipMemsetD8(hipDeviceptr_t dest, unsigned char value, size_t sizeBytes ) +{ + return hipCUResultTohipError(cuMemsetD8(dest, value, sizeBytes)); +} + inline static hipError_t hipGetDeviceProperties(hipDeviceProp_t *p_prop, int device) { cudaDeviceProp cdprop; diff --git a/projects/hip/tests/src/context/hipMemsetD8.cpp b/projects/hip/tests/src/context/hipMemsetD8.cpp index 1cd43696aa..3730fcb70b 100644 --- a/projects/hip/tests/src/context/hipMemsetD8.cpp +++ b/projects/hip/tests/src/context/hipMemsetD8.cpp @@ -45,13 +45,13 @@ int main(int argc, char *argv[]) hipDeviceptr_t A_d; A_h = new char[Nbytes]; - HIPCHECK ( hipMalloc(&A_d, Nbytes) ); + HIPCHECK ( hipMalloc((void **) &A_d, Nbytes) ); A_h = (char*)malloc(Nbytes); printf ("Size=%zu memsetval=%2x \n", Nbytes, memsetval); HIPCHECK ( hipMemsetD8(A_d, memsetval, Nbytes) ); - HIPCHECK ( hipMemcpy(A_h, A_d, Nbytes, hipMemcpyDeviceToHost)); + HIPCHECK ( hipMemcpy(A_h, (void *) A_d, Nbytes, hipMemcpyDeviceToHost)); for (int i=0; i Date: Wed, 15 Mar 2017 12:03:05 +0530 Subject: [PATCH 217/281] hipcc: Fix warning when HCC_AMDGPU_TARGET is not defined Change-Id: I5cc6b0e9fb23ec78152d8bcfe9e7511e2fe91055 [ROCm/hip commit: 4ae1ea8143615023f48ca4b6cbad30a275866c22] --- projects/hip/bin/hipcc | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/projects/hip/bin/hipcc b/projects/hip/bin/hipcc index d2822fd0da..381c774c94 100755 --- a/projects/hip/bin/hipcc +++ b/projects/hip/bin/hipcc @@ -326,27 +326,30 @@ foreach $arg (@ARGV) } $toolArgs .= " $arg" unless $swallowArg; } -foreach my $target (split(/,/, $ENV{HCC_AMDGPU_TARGET})) +if(defined $ENV{HCC_AMDGPU_TARGET}) { - if($target eq 'gfx701') + foreach my $target (split(/,/, $ENV{HCC_AMDGPU_TARGET})) { - $target_gfx701 = 1; - } - if($target eq 'gfx801') - { - $target_gfx801 = 1; - } - if($target eq 'gfx802') - { - $target_gfx802 = 1; - } - if($target eq 'gfx803') - { - $target_gfx803 = 1; - } - if($target eq 'gfx900') - { - $target_gfx900 = 1; + if($target eq 'gfx701') + { + $target_gfx701 = 1; + } + if($target eq 'gfx801') + { + $target_gfx801 = 1; + } + if($target eq 'gfx802') + { + $target_gfx802 = 1; + } + if($target eq 'gfx803') + { + $target_gfx803 = 1; + } + if($target eq 'gfx900') + { + $target_gfx900 = 1; + } } } if ($target_gfx701 eq 0 and $target_gfx801 eq 0 and $target_gfx802 eq 0 and $target_gfx803 eq 0 and $target_gfx900 eq 0) From 86e2a5d11d0c4dc32a305c1e1acc141576ce83d1 Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Wed, 15 Mar 2017 12:03:44 +0530 Subject: [PATCH 218/281] Disable broken tests on hcc path Change-Id: Id6234da576566faa32d5fdf42dca6d6267596823 [ROCm/hip commit: 65bb22eefc620392cbcdf8f03beb61690acc71d3] --- projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp | 2 +- projects/hip/tests/src/kernel/hipDynamicShared.cpp | 2 +- projects/hip/tests/src/kernel/hipDynamicShared2.cpp | 2 +- projects/hip/tests/src/runtimeApi/memory/hipArray.cpp | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp b/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp index e58aa58877..9e188e9f17 100644 --- a/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp +++ b/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp @@ -18,7 +18,7 @@ THE SOFTWARE. */ /* HIT_START - * BUILD: %t %s EXCLUDE_HIP_PLATFORM nvcc + * BUILD: %t %s EXCLUDE_HIP_PLATFORM all * RUN: %t * HIT_END */ diff --git a/projects/hip/tests/src/kernel/hipDynamicShared.cpp b/projects/hip/tests/src/kernel/hipDynamicShared.cpp index 522572a191..ba19fcaa0d 100644 --- a/projects/hip/tests/src/kernel/hipDynamicShared.cpp +++ b/projects/hip/tests/src/kernel/hipDynamicShared.cpp @@ -21,7 +21,7 @@ THE SOFTWARE. */ /* HIT_START - * BUILD: %t %s ../test_common.cpp + * BUILD: %t %s ../test_common.cpp EXCLUDE_HIP_PLATFORM hcc * RUN: %t EXCLUDE_HIP_PLATFORM nvcc * HIT_END */ diff --git a/projects/hip/tests/src/kernel/hipDynamicShared2.cpp b/projects/hip/tests/src/kernel/hipDynamicShared2.cpp index 0f6ebb4927..95e70a9956 100644 --- a/projects/hip/tests/src/kernel/hipDynamicShared2.cpp +++ b/projects/hip/tests/src/kernel/hipDynamicShared2.cpp @@ -21,7 +21,7 @@ THE SOFTWARE. */ /* HIT_START - * BUILD: %t %s ../test_common.cpp + * BUILD: %t %s ../test_common.cpp EXCLUDE_HIP_PLATFORM hcc * RUN: %t EXCLUDE_HIP_PLATFORM nvcc * HIT_END */ diff --git a/projects/hip/tests/src/runtimeApi/memory/hipArray.cpp b/projects/hip/tests/src/runtimeApi/memory/hipArray.cpp index 8f831bf5e0..b31973e3d2 100644 --- a/projects/hip/tests/src/runtimeApi/memory/hipArray.cpp +++ b/projects/hip/tests/src/runtimeApi/memory/hipArray.cpp @@ -21,8 +21,8 @@ THE SOFTWARE. */ /* HIT_START - * BUILD: %t %s ../../test_common.cpp EXCLUDE_HIP_PLATFORM nvcc - * RUN: %t EXCLUDE_HIP_PLATFORM + * BUILD: %t %s ../../test_common.cpp EXCLUDE_HIP_PLATFORM all + * RUN: %t * HIT_END */ From d17073a995eecdd32e8a44a2d0e75ac3c64cc03e Mon Sep 17 00:00:00 2001 From: Siu Chi Chan Date: Wed, 15 Mar 2017 12:26:13 -0400 Subject: [PATCH 219/281] replace code names with gfx names Change-Id: I5e0b96a0b474b16cfa92077a30a5b80b7230254b [ROCm/hip commit: a96821871fe28c489966dd8847efef9dd352a663] --- projects/hip/bin/hccgenco.sh | 7 ++++--- projects/hip/bin/hipcc | 2 +- projects/hip/docs/markdown/hip_kernel_language.md | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/projects/hip/bin/hccgenco.sh b/projects/hip/bin/hccgenco.sh index a7b4177624..7f90cce83d 100755 --- a/projects/hip/bin/hccgenco.sh +++ b/projects/hip/bin/hccgenco.sh @@ -10,7 +10,7 @@ if [ $# = 0 ]; then fi : ${ROCM_PATH:=/opt/rocm} -: ${ROCM_TARGET:=fiji} +: ${ROCM_TARGET:=gfx803} INPUT_FILES="" OUTPUT_FILE="" @@ -48,13 +48,14 @@ printf "\nint main(){}\n" >> $hipgenisa_main $HIP_PATH/bin/hipcc $hipgenisa_files -o $hipgenisa_dir/a.out mv dump* $hipgenisa_dir +hsaco_file="dump-$ROCM_TARGET.hsaco" map_sym="" -kernels=$(objdump -t $hipgenisa_dir/dump-fiji.hsaco | grep grid_launch_parm | sed 's/ \+/ /g; s/\t/ /g' | cut -d" " -f6) +kernels=$(objdump -t $hipgenisa_dir/$hsaco_file | grep grid_launch_parm | sed 's/ \+/ /g; s/\t/ /g' | cut -d" " -f6) for mangled_sym in $kernels; do real_sym=$(c++filt $(c++filt $mangled_sym | cut -d: -f3 | sed 's/_functor//g') | cut -d\( -f1) map_sym="--redefine-sym $mangled_sym=$real_sym $map_sym" done -objcopy -F elf64-little $map_sym $hipgenisa_dir/dump-fiji.hsaco $OUTPUT_FILE +objcopy -F elf64-little $map_sym $hipgenisa_dir/$hsaco_file $OUTPUT_FILE rm $hipgenisa_files rm -r $hipgenisa_dir diff --git a/projects/hip/bin/hipcc b/projects/hip/bin/hipcc index 381c774c94..361517d551 100755 --- a/projects/hip/bin/hipcc +++ b/projects/hip/bin/hipcc @@ -92,7 +92,7 @@ if ($HIP_PLATFORM eq "hcc") { $HIP_ATP_MARKER=$ENV{'HIP_ATP_MARKER'} // 1; $marker_path = "$ROCM_PATH/profiler/CXLActivityLogger"; - $ROCM_TARGET=$ENV{'ROCM_TARGET'} // "fiji"; + $ROCM_TARGET=$ENV{'ROCM_TARGET'} // "gfx803"; # HCC* may be used to compile src/hip_hcc.o (and also feed the HIPCXXFLAGS below) $HCC = "$HCC_HOME/bin/hcc"; diff --git a/projects/hip/docs/markdown/hip_kernel_language.md b/projects/hip/docs/markdown/hip_kernel_language.md index 3fd4ea9aca..0c7f3c8d25 100644 --- a/projects/hip/docs/markdown/hip_kernel_language.md +++ b/projects/hip/docs/markdown/hip_kernel_language.md @@ -680,7 +680,7 @@ The user can specify the target for which the binary can be generated. HIP/HCC d The file format for binary is `.co` which means Code Object. The following command builds the code object using `hipcc`. `hipcc --genco --target-isa=[TARGET GPU] [INPUT FILE] -o [OUTPUT FILE]` -```[TARGET GPU] = fiji/hawaii +```[TARGET GPU] = gfx803/gfx701 [INPUT FILE] = Name of the file containing kernels [OUTPUT FILE] = Name of the generated code object file``` From e4af25d2926146ecb9a9740657818676bc068cf0 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Thu, 16 Mar 2017 14:39:28 +0300 Subject: [PATCH 220/281] [HIP] [DOC] Update hip_porting_driver_api.md + Fix typos, formatting, update CUDA Driver API support. [ROCm/hip commit: 76820409a8f2f477f68226f6ad7174b44aad0659] --- .../docs/markdown/hip_porting_driver_api.md | 147 +++++++----------- 1 file changed, 57 insertions(+), 90 deletions(-) diff --git a/projects/hip/docs/markdown/hip_porting_driver_api.md b/projects/hip/docs/markdown/hip_porting_driver_api.md index f51f53a092..dd3b9c3e86 100644 --- a/projects/hip/docs/markdown/hip_porting_driver_api.md +++ b/projects/hip/docs/markdown/hip_porting_driver_api.md @@ -1,151 +1,119 @@ # Porting CUDA Driver API ## Introduction to the CUDA Driver and Runtime APIs -CUDA provides a separate CUDA Driver and Runtime APIs. The two APIs have significant overlap in functionality: +CUDA provides a separate CUDA Driver and Runtime APIs. The two APIs have significant overlap in functionality: - Both APIs support events, streams, memory management, memory copy, and error handling. -- Both APIs deliver similar performance. -- Driver APIs calls begin with the prefix `cu` while Runtime APIs begin with the prefix `cuda`. For example, the Driver API API contains `cuEventCreate` while the Runtime API contains `cudaEventCreate`, with similar functionality. -- The Driver API defines a different but largely overlapping error code code space than the Runtime API, and uses a different coding convention. For example, Driver API defines `CUDA_ERROR_INVALID_VALUE` while the Runtime API defines `cudaErrorInvalidValue` +- Both APIs deliver similar performance. +- Driver APIs calls begin with the prefix `cu` while Runtime APIs begin with the prefix `cuda`. For example, the Driver API API contains `cuEventCreate` while the Runtime API contains `cudaEventCreate`, with similar functionality. +- The Driver API defines a different but largely overlapping error code space than the Runtime API, and uses a different coding convention. For example, Driver API defines `CUDA_ERROR_INVALID_VALUE` while the Runtime API defines `cudaErrorInvalidValue` The Driver API offers two additional pieces of functionality not provided by the Runtime API: cuModule and cuCtx APIs. ### cuModule API -The Module section of the Driver API provides additional control over how and when accelerator - code objects are loaded. +The Module section of the Driver API provides additional control over how and when accelerator code objects are loaded. For example, the driver API allows code objects to be loaded from files or memory pointers. Symbols for kernels or global data can be extracted from the loaded code objects. -In contrast, the Runtime API automatically loads and (if necessary) compiles all of the -kernels from a executable binary when run. +In contrast, the Runtime API automatically loads and (if necessary) compiles all of the kernels from an executable binary when run. In this mode, NVCC must be used to compile kernel code so the automatic loading can function correctly. Both Driver and Runtime APIs define a function for launching kernels (called `cuLaunchKernel` or `cudaLaunchKernel`. The kernel arguments and the execution configuration (grid dimensions, group dimensions, dynamic shared memory, and stream) are passed as arguments to the launch function. -The Runtime additionally provides the `<<< >>>` syntax for launching kernels, which resembles -a special function call and is easier to use than explicit launch API (in particular with respect to -handling of kernel arguments). -However, this syntax is not standard C++ and is available only when NVCC is used to compile the host code. +The Runtime additionally provides the `<<< >>>` syntax for launching kernels, which resembles a special function call and is easier to use than explicit launch API (in particular with respect to handling of kernel arguments). +However, this syntax is not standard C++ and is available only when NVCC is used to compile the host code. -The Module features are useful in an environment which generate the code objects directly, such as a new -accelerator language front-end. Here, NVCC is not used. Instead, the environment may have a -different kernel language or different compilation flow. +The Module features are useful in an environment which generates the code objects directly, such as a new accelerator language front-end. +Here, NVCC is not used. Instead, the environment may have a different kernel language or different compilation flow. Other environments have many kernels and do not want them to be all loaded automatically. The Module functions can be used to load the generated code objects and launch kernels. -As we will see below, HIP defines a Module API which provides similar explicit control over code -object management. +As we will see below, HIP defines a Module API which provides similar explicit control over code object management. ### cuCtx API -The Driver API defines "Context" and "Devices" as separate entities. -Contexts contain a single device, and a device can theoretically have multiple contexts. -Each context contains a set of streams and events specific to the context. -Historically contexts also defined a unique address space for the GPU, though this may not longer be the case in Unified Memory platforms (since the CPU and all the devices in the same process share a single unified address space). -The Context APIs also provide a mechanism to switch between devices, which allowed -a single CPU thread to send commands to different GPUs. HIP as well as a recent versions -of CUDA Runtime provide other mechanisms to accomplish this feat - for example using streams or -`cudaSetDevice`. +The Driver API defines "Context" and "Devices" as separate entities. +Contexts contain a single device, and a device can theoretically have multiple contexts. +Each context contains a set of streams and events specific to the context. +Historically contexts also defined a unique address space for the GPU, though this may no longer be the case in Unified Memory platforms (since the CPU and all the devices in the same process share a single unified address space). +The Context APIs also provide a mechanism to switch between devices, which allowed a single CPU thread to send commands to different GPUs. +HIP as well as a recent versions of CUDA Runtime provide other mechanisms to accomplish this feat - for example using streams or `cudaSetDevice`. -The CUDA Runtime API unifies the Context API with the Device API. This simplifies the APIs -and has little loss of functionality since each Context can contain a single device, -and the benefits of multiple contexts has been replaced with other interfaces. HIP provides -a context API to facilitate easy porting from existing Driver codes. -In HIP, the Ctx functions largely provide an alternate syntax for changing the active device. +The CUDA Runtime API unifies the Context API with the Device API. This simplifies the APIs and has little loss of functionality since each Context can contain a single device, and the benefits of multiple contexts has been replaced with other interfaces. +HIP provides a context API to facilitate easy porting from existing Driver codes. +In HIP, the Ctx functions largely provide an alternate syntax for changing the active device. Most new applications will prefer to use `hipSetDevice` or the stream APIs. ## HIP Module and Ctx APIs -Rather than present two separate APIs, HIP extends the HIP API with new APIs for Modules -and Ctx control. +Rather than present two separate APIs, HIP extends the HIP API with new APIs for Modules and Ctx control. ### hipModule API -Like the CUDA Driver API, the Module API provides additional control -over how code is loaded, including options to load code from files or from in-memory pointers. -NVCC and HCC target different architectures and use different code object formats : NVCC -is `cubin` or `ptx` files, while the HCC path is the `hsaco` format. The external -compilers which generate these code objects are responsible for generating and loading -the correct code object for each platform. Notably, there is not a fat binary format that -can contain code for both NVCC and HCC platforms. The following table summarizes the -formats used on each platform: +Like the CUDA Driver API, the Module API provides additional control over how code is loaded, including options to load code from files or from in-memory pointers. +NVCC and HCC target different architectures and use different code object formats: NVCC is `cubin` or `ptx` files, while the HCC path is the `hsaco` format. +The external compilers which generate these code objects are responsible for generating and loading the correct code object for each platform. +Notably, there is not a fat binary format that can contain code for both NVCC and HCC platforms. The following table summarizes the formats used on each platform: -| Format | APIs | NVCC | HCC | -| --- | --- | --- | --- | +| Format | APIs | NVCC | HCC | +| --- | --- | --- | --- | | Code Object | hipModuleLoad, hipModuleLoadData | .cubin or PTX text | .hsaco | -| Fat Binary | hipModuleLoadFatBin | .fatbin | Under Development | +| Fat Binary | hipModuleLoadFatBin | .fatbin | Under Development | -hipcc uses NVCC and HCC to compile host codes. Both of these may embed code objects -into the final executable, and these code objects will be automatically loaded when -the application starts. -The hipModule API can be used to load additional code objects, and in this way -provides an extended capability to the automatically loaded code objects. HCC allows -both of these capabilities to be used together, if desired. Of course it is possible -to create a program with no kernels and thus no automatic loading. +`hipcc` uses NVCC and HCC to compile host codes. Both of these may embed code objects into the final executable, and these code objects will be automatically loaded when the application starts. +The hipModule API can be used to load additional code objects, and in this way provides an extended capability to the automatically loaded code objects. +HCC allows both of these capabilities to be used together, if desired. Of course it is possible to create a program with no kernels and thus no automatic loading. ### hipCtx API -HIP provides a `Ctx` API as a thin layer over the existing Device functions. This Ctx API -can be used to set the current context, or to query properties of the device associated with -the context. The current context is implicitly used by other APIs such as `hipStreamCreate`. +HIP provides a `Ctx` API as a thin layer over the existing Device functions. This Ctx API can be used to set the current context, or to query properties of the device associated with the context. +The current context is implicitly used by other APIs such as `hipStreamCreate`. ### hipify translation of CUDA Driver API -The hipify tool will convert CUDA Driver APIs for streams, events, memory management to -the equivalent HIP driver calls. For example, `cuEventCreate` will be translated to -`hipEventCreate`. Hipify also converts error code from the Driver namespace and coding -convention to the equivalent HIP error code. Thus, HIP unifies the APIs for these common functions. -[hipify support for translating driver API is Under Development] +The hipify tool converts CUDA Driver APIs for streams, events, modules, devices, memory management, context, profiler to the equivalent HIP driver calls. For example, `cuEventCreate` will be translated to `hipEventCreate`. +Hipify also converts error code from the Driver namespace and coding convention to the equivalent HIP error code. Thus, HIP unifies the APIs for these common functions. -The memory copy APIs require additional explanation. The CUDA driver includes the memory -direction in the name of the API (ie `cuMemcpyH2D`) while the CUDA driver API provides -a single memory copy API with a parameter that specifies the direction and additionally -supports a "default" direction where the runtime determines the direction automatically. +The memory copy API requires additional explanation. The CUDA driver includes the memory direction in the name of the API (ie `cuMemcpyH2D`) while the CUDA driver API provides a single memory copy API with a parameter that specifies the direction and additionally supports a "default" direction where the runtime determines the direction automatically. HIP provides APIs with both styles: for example, `hipMemcpyH2D` as well as `hipMemcpy`. -The first flavor may be faster in some cases since they avoid host overhead to detect the -different memory directions. +The first flavor may be faster in some cases since they avoid host overhead to detect the different memory directions. -HIP defines a single error space, and uses camel-case for all errors (i.e. `hipErrorInvalidValue`). +HIP defines a single error space, and uses camel-case for all errors (i.e. `hipErrorInvalidValue`). ### HCC Implementation Notes #### .hsaco The .hsaco format used by HCC is described in more detail [here](https://github.com/RadeonOpenCompute/ROCm-ComputeABI-Doc). -An example and blog that show how to use the format is [here](http://gpuopen.com/rocm-with-harmony-combining-opencl-hcc-hsa-in-a-single-program). hsaco can be generated by hcc + extractkernel tool, -cloc, the GCN assembler, or other tools. +An example and blog that show how to use the format is [here](http://gpuopen.com/rocm-with-harmony-combining-opencl-hcc-hsa-in-a-single-program). hsaco can be generated by hcc + extractkernel tool, cloc, the GCN assembler, or other tools. #### Address Spaces -HCC defines a process-wide address space where the CPU and all devices allocate -addresses from a single unified pool. Thus addresses may be shared between contexts, and -unlike the original CUDA definition a new context does not create a new address space for -the device. +HCC defines a process-wide address space where the CPU and all devices allocate addresses from a single unified pool. +Thus addresses may be shared between contexts, and unlike the original CUDA definition a new context does not create a new address space for the device. #### Using hipModuleLaunchKernel `hipModuleLaunchKernel` is `cuLaunchKernel` in HIP world. It takes the same arguments as `cuLaunchKernel`. The argument `kernelParams` is not fully implemented for HCC. The workaround for it is, to use platform specific macros for each target. Or, `extra` argument can be used which works on both the platforms. #### Additional Information - HCC allocates staging buffers (used for unpinned copies) on a per-device basis. -- HCC creates a primary context when the HIP API is called. So in a pure driver API code, HIP/HCC will create a primary context while HIP/NVCC will have empty context stack. HIP/HCC will push primary context to context stack when it is empty. This can have subtle differences on applications which mix the runtime and driver APIs. +- HCC creates a primary context when the HIP API is called. So in a pure driver API code, HIP/HCC will create a primary context while HIP/NVCC will have empty context stack. +HIP/HCC will push primary context to context stack when it is empty. This can have subtle differences on applications which mix the runtime and driver APIs. ### NVCC Implementation Notes #### Interoperation between HIP and CUDA Driver -CUDA applications may want to mix CUDA driver code with HIP code (see example below). This -table shows the type equivalence to enable this interaction. - -|**HIP Type** |**CU Driver Type**| **CUDA Runtime Type** | -| ---- | ---- | ---- | -| hipModule | CUmodule | | -| hipFunction | CUfunction | | -| hipCtx_t | CUcontext | | -| hipDevice_t | CUdevice | | -| hipStream_t | CUstream | cudaStream_t | -| hipEvent_t | CUevent | cudaEvent_t | -| hipArray | CUarray | cudaArray | - +CUDA applications may want to mix CUDA driver code with HIP code (see example below). This table shows the type equivalence to enable this interaction. +|**HIP Type** |**CU Driver Type**|**CUDA Runtime Type**| +| ---- | ---- | ---- | +| hipModule | CUmodule | | +| hipFunction | CUfunction | | +| hipCtx_t | CUcontext | | +| hipDevice_t | CUdevice | | +| hipStream_t | CUstream | cudaStream_t | +| hipEvent_t | CUevent | cudaEvent_t | +| hipArray | CUarray | cudaArray | #### Compilation Flags -The hipModule interface does not support the hipModuleLoadEx function, which is used to control PTX compilaton options. +The hipModule interface does not support the `cuModuleLoadDataEx` function, which is used to control PTX compilation options. HCC does not use PTX and does not support the same compilation options. In fact, HCC code objects always contain fully compiled ISA and do not require additional compilation as part of the load step. -Code which requires this functionally should use platform-specific coding, calling `cuModuleLoadEx` -on the NVCC path and hipModuleLoad on the hcc path. For example: +Code which requires this functionally should use platform-specific coding, calling `cuModuleLoadDataEx` on the NVCC path and `hipModuleLoadData` on the hcc path. +For example: ``` hipModule module; @@ -240,7 +208,7 @@ int main(){ HIP_LAUNCH_PARAM_END }; - hipModuleLaunchKernel(Function, 1, 1, 1, LEN, 1, 1, 0, 0, NULL, (void**)&con fig); + hipModuleLaunchKernel(Function, 1, 1, 1, LEN, 1, 1, 0, 0, NULL, (void**)&config); hipMemcpyDtoH(B, Bd, SIZE); for(uint32_t i=0;i Date: Fri, 17 Mar 2017 10:25:56 -0500 Subject: [PATCH 221/281] Add simple device-side assert macro Currently swallows asserts but will compile. [ROCm/hip commit: ecd8179a71218ffae5aac8ec7ce014e86571a5f7] --- projects/hip/include/hip/hcc_detail/hip_runtime.h | 11 +++++++++++ .../hip/tests/src/deviceLib/hipIntegerIntrinsics.cpp | 2 ++ 2 files changed, 13 insertions(+) diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime.h b/projects/hip/include/hip/hcc_detail/hip_runtime.h index 332e9bab46..673463635f 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime.h @@ -77,6 +77,17 @@ extern int HIP_TRACE_API; #define __HCC_ACCELERATOR__ __KALMAR_ACCELERATOR__ #endif + + + +// TODO-HCC add a dummy implementation of assert, need to replace with a proper kernel exit call. +#if __HIP_DEVICE_COMPILE__ == 1 + #undef assert + #define assert(COND) { if (COND) {} } +#endif + + + // Feature tests: #if defined(__HCC_ACCELERATOR__) && (__HCC_ACCELERATOR__ != 0) // Device compile and not host compile: diff --git a/projects/hip/tests/src/deviceLib/hipIntegerIntrinsics.cpp b/projects/hip/tests/src/deviceLib/hipIntegerIntrinsics.cpp index 6bf13a0809..27af03ced3 100644 --- a/projects/hip/tests/src/deviceLib/hipIntegerIntrinsics.cpp +++ b/projects/hip/tests/src/deviceLib/hipIntegerIntrinsics.cpp @@ -59,6 +59,8 @@ __device__ void integer_intrinsics() __umulhi((unsigned int)1, (unsigned int)2); __urhadd((unsigned int)1, (unsigned int)2); __usad((unsigned int)1, (unsigned int)2, 0); + + assert(1); } __global__ void compileIntegerIntrinsics(hipLaunchParm lp, int ignored) From a9ec705ee4f623cab323e4c971217c53f25f67c0 Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Fri, 17 Mar 2017 11:04:39 -0500 Subject: [PATCH 222/281] Add USE_PROMOTE_FREE_HCC for smooth transition to new HCC caps. ADDRESS_SPACE_1 defines [ROCm/hip commit: e85c1671716d090cfca333439dffe3e75f37d6ac] --- .../hip/include/hip/hcc_detail/hip_runtime.h | 19 ++++++++++++++----- .../hip/include/hip/hcc_detail/host_defines.h | 6 +++++- projects/hip/src/device_util.cpp | 6 +++--- .../src/deviceLib/hipTestDeviceSymbol.cpp | 5 +++-- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime.h b/projects/hip/include/hip/hcc_detail/hip_runtime.h index 673463635f..06ce7c84df 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime.h @@ -47,7 +47,16 @@ THE SOFTWARE. #include -//#include "hip/hcc_detail/hip_hcc.h" +#define USE_PROMOTE_FREE_HCC 0 + +#if USE_PROMOTE_FREE_HCC == 1 +#define ADDRESS_SPACE_1 +#define ADDRESS_SPACE_3 +#else +#define ADDRESS_SPACE_1 __attribute__((address_space(1))) +#define ADDRESS_SPACE_3 __attribute__((address_space(3))) +#endif + //--- // Remainder of this file only compiles with HCC #ifdef __HCC__ @@ -275,7 +284,7 @@ __device__ int __hip_move_dpp(int src, int dpp_ctrl, int row_mask, int bank_mask __host__ __device__ int min(int arg1, int arg2); __host__ __device__ int max(int arg1, int arg2); -__device__ __attribute__((address_space(3))) void* __get_dynamicgroupbaseptr(); +__device__ ADDRESS_SPACE_3 void* __get_dynamicgroupbaseptr(); /** @@ -433,10 +442,10 @@ do {\ // Macro to replace extern __shared__ declarations // to local variable definitions #define HIP_DYNAMIC_SHARED(type, var) \ - __attribute__((address_space(3))) type* var = \ - (__attribute__((address_space(3))) type*)__get_dynamicgroupbaseptr(); \ + ADDRESS_SPACE_3 type* var = \ + ADDRESS_SPACE_3 type*)__get_dynamicgroupbaseptr(); \ -#define HIP_DYNAMIC_SHARED_ATTRIBUTE __attribute__((address_space(3))) +#define HIP_DYNAMIC_SHARED_ATTRIBUTE ADDRESS_SPACE_3 #endif // __HCC__ diff --git a/projects/hip/include/hip/hcc_detail/host_defines.h b/projects/hip/include/hip/hcc_detail/host_defines.h index e401cb24f3..0e10d0075c 100644 --- a/projects/hip/include/hip/hcc_detail/host_defines.h +++ b/projects/hip/include/hip/hcc_detail/host_defines.h @@ -47,7 +47,11 @@ THE SOFTWARE. */ // _restrict is supported by the compiler #define __shared__ tile_static -#define __constant__ __attribute__((address_space(1))) +#if USE_PROMOTE_FREE_HCC==1 +#define __constant__ __attribute__((hc)) +#else +#define __constant__ ADDRESS_SPACE_1 +#endif #else // Non-HCC compiler diff --git a/projects/hip/src/device_util.cpp b/projects/hip/src/device_util.cpp index 4b0e7efefd..6e2652449f 100644 --- a/projects/hip/src/device_util.cpp +++ b/projects/hip/src/device_util.cpp @@ -34,8 +34,8 @@ THE SOFTWARE. This is the best place to put them because the device global variables need to be initialized at the start. */ -__attribute__((address_space(1))) char gpuHeap[SIZE_OF_HEAP]; -__attribute__((address_space(1))) uint32_t gpuFlags[NUM_PAGES]; +ADDRESS_SPACE_1 char gpuHeap[SIZE_OF_HEAP]; +ADDRESS_SPACE_1 uint32_t gpuFlags[NUM_PAGES]; __device__ void *__hip_hc_malloc(size_t size) { @@ -1083,7 +1083,7 @@ __host__ __device__ int max(int arg1, int arg2) return (int)(hc::precise_math::fmax((float)arg1, (float)arg2)); } -__device__ __attribute__((address_space(3))) void* __get_dynamicgroupbaseptr() +__device__ ADDRESS_SPACE_3 void* __get_dynamicgroupbaseptr() { return hc::get_dynamic_group_segment_base_pointer(); } diff --git a/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp b/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp index 9e188e9f17..6ffaedf659 100644 --- a/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp +++ b/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp @@ -31,9 +31,10 @@ THE SOFTWARE. #define NUM 1024 #define SIZE 1024*4 +// TODO - collapse: #ifdef __HIP_PLATFORM_HCC__ -__attribute__((address_space(1))) int globalIn[NUM]; -__attribute__((address_space(1))) int globalOut[NUM]; +__device__ ADDRESS_SPACE_1 int globalIn[NUM]; +__device__ ADDRESS_SPACE_1 int globalOut[NUM]; #endif #ifdef __HIP_PLATFORM_NVCC__ From 8d5c39fd525fd1dc684d892a750bea83ce7e8aa9 Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Fri, 17 Mar 2017 11:19:48 -0500 Subject: [PATCH 223/281] Add __device__ to needful functions for promote-free. [ROCm/hip commit: 29232ff2832154d4919f57671d9c654a98287b62] --- projects/hip/include/hip/hcc_detail/hip_runtime.h | 2 +- projects/hip/src/device_functions.cpp | 4 ++-- projects/hip/src/device_util.cpp | 4 ++-- projects/hip/src/hip_fp16.cpp | 2 +- projects/hip/src/math_functions.cpp | 3 ++- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime.h b/projects/hip/include/hip/hcc_detail/hip_runtime.h index 06ce7c84df..6fc68abb3a 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime.h @@ -443,7 +443,7 @@ do {\ // to local variable definitions #define HIP_DYNAMIC_SHARED(type, var) \ ADDRESS_SPACE_3 type* var = \ - ADDRESS_SPACE_3 type*)__get_dynamicgroupbaseptr(); \ + (ADDRESS_SPACE_3 type*)__get_dynamicgroupbaseptr(); \ #define HIP_DYNAMIC_SHARED_ATTRIBUTE ADDRESS_SPACE_3 diff --git a/projects/hip/src/device_functions.cpp b/projects/hip/src/device_functions.cpp index abc9db570e..10d8d3ab89 100644 --- a/projects/hip/src/device_functions.cpp +++ b/projects/hip/src/device_functions.cpp @@ -41,8 +41,8 @@ struct holder32Bit { }; } __attribute__((aligned(4))); -struct holder64Bit hold64; -struct holder32Bit hold32; +__device__ struct holder64Bit hold64; +__device__ struct holder32Bit hold32; __device__ float __double2float_rd(double x) { diff --git a/projects/hip/src/device_util.cpp b/projects/hip/src/device_util.cpp index 6e2652449f..b0df62f43b 100644 --- a/projects/hip/src/device_util.cpp +++ b/projects/hip/src/device_util.cpp @@ -34,8 +34,8 @@ THE SOFTWARE. This is the best place to put them because the device global variables need to be initialized at the start. */ -ADDRESS_SPACE_1 char gpuHeap[SIZE_OF_HEAP]; -ADDRESS_SPACE_1 uint32_t gpuFlags[NUM_PAGES]; +__device__ ADDRESS_SPACE_1 char gpuHeap[SIZE_OF_HEAP]; +__device__ ADDRESS_SPACE_1 uint32_t gpuFlags[NUM_PAGES]; __device__ void *__hip_hc_malloc(size_t size) { diff --git a/projects/hip/src/hip_fp16.cpp b/projects/hip/src/hip_fp16.cpp index b306a9d3de..e7f75844ff 100644 --- a/projects/hip/src/hip_fp16.cpp +++ b/projects/hip/src/hip_fp16.cpp @@ -31,7 +31,7 @@ struct hipHalfHolder{ #define HINF 65504 -static struct hipHalfHolder __hInfValue = {HINF}; +__device__ static struct hipHalfHolder __hInfValue = {HINF}; __device__ __half __hadd(__half a, __half b) { return a + b; diff --git a/projects/hip/src/math_functions.cpp b/projects/hip/src/math_functions.cpp index 230eb2aacc..6e919b3926 100644 --- a/projects/hip/src/math_functions.cpp +++ b/projects/hip/src/math_functions.cpp @@ -202,7 +202,8 @@ __device__ long long int llroundf(float x) int y = hc::precise_math::roundf(x); long long int z = y; return z; -}__device__ float log10f(float x) +} +__device__ float log10f(float x) { return hc::precise_math::log10f(x); } From e10e2bd26710d4089b046c758faa326e87011c25 Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Fri, 17 Mar 2017 12:04:13 -0500 Subject: [PATCH 224/281] Move USE_PROMOTE_FREE_HCC [ROCm/hip commit: 8cbe310870f6592e679a1f477ea0af764bcba2eb] --- projects/hip/include/hip/hcc_detail/hip_runtime.h | 1 - projects/hip/include/hip/hcc_detail/host_defines.h | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime.h b/projects/hip/include/hip/hcc_detail/hip_runtime.h index 6fc68abb3a..af294cdb53 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime.h @@ -47,7 +47,6 @@ THE SOFTWARE. #include -#define USE_PROMOTE_FREE_HCC 0 #if USE_PROMOTE_FREE_HCC == 1 #define ADDRESS_SPACE_1 diff --git a/projects/hip/include/hip/hcc_detail/host_defines.h b/projects/hip/include/hip/hcc_detail/host_defines.h index 0e10d0075c..93695a0038 100644 --- a/projects/hip/include/hip/hcc_detail/host_defines.h +++ b/projects/hip/include/hip/hcc_detail/host_defines.h @@ -28,6 +28,8 @@ THE SOFTWARE. #ifndef HOST_DEFINES_H #define HOST_DEFINES_H +#define USE_PROMOTE_FREE_HCC 0 + #ifdef __HCC__ /** * Function and kernel markers From 95c7942f5c6a0f2f300f484d09c0eb59acdf791f Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Fri, 17 Mar 2017 13:11:34 -0500 Subject: [PATCH 225/281] Added default module launch api functionality 1. As in hipModuleLaunchKernel(..., kernelParams, nullptr); works with this commit 2. Added headers AMDGPUPTNote.h, AMDGPURuntimeMetadata.h to do code object meta data parsing 3. Changed CMake to look at llvm link libraries 4. HIP developer should set env variable LLVM_HOME to remove link errors 5. HIP depends on installed LLVM (not source, not build) 6. Added sample to test out the feature 7. Right now HCC does not support embedding metadata in code object. Use clang opencl 8. Changed HIPCC to read LLVM_HOME env var 9. New argument to CMake should be given -DLLVM_HOME= Change-Id: Iba38194aa872d97cc2c90a8e5ff746c48055c868 [ROCm/hip commit: 99432cc12cfc5a9146e29a824c21db1c6630dd11] --- projects/hip/CMakeLists.txt | 10 + projects/hip/bin/hipcc | 8 +- .../hip/samples/0_Intro/module_api/Makefile | 8 +- .../0_Intro/module_api/defaultDriver.cpp | 89 ++++++ .../samples/0_Intro/module_api/runKernel.cpp | 4 +- .../hip/samples/0_Intro/module_api/test.cl | 12 + .../hip/samples/0_Intro/module_api/test.co | Bin 0 -> 9824 bytes projects/hip/src/AMDGPUPTNote.h | 45 +++ projects/hip/src/AMDGPURuntimeMetadata.h | 290 ++++++++++++++++++ projects/hip/src/hip_module.cpp | 99 +++++- 10 files changed, 553 insertions(+), 12 deletions(-) create mode 100644 projects/hip/samples/0_Intro/module_api/defaultDriver.cpp create mode 100644 projects/hip/samples/0_Intro/module_api/test.cl create mode 100755 projects/hip/samples/0_Intro/module_api/test.co create mode 100644 projects/hip/src/AMDGPUPTNote.h create mode 100644 projects/hip/src/AMDGPURuntimeMetadata.h diff --git a/projects/hip/CMakeLists.txt b/projects/hip/CMakeLists.txt index 1ba58496f4..a1887d0cb5 100644 --- a/projects/hip/CMakeLists.txt +++ b/projects/hip/CMakeLists.txt @@ -63,6 +63,14 @@ if(HIP_PLATFORM STREQUAL "hcc") set(HCC_HOME $ENV{HCC_HOME} CACHE PATH "Path to which HCC has been installed") endif() endif() + # Determine LLVM_HOME + if(NOT DEFINED LLVM_HOME) + if(NOT DEFINED ENV{LLVM_HOME}) + set(LLVM_HOME "/opt/rocm/llvm" CACHE PATH "Path to which LLVM has been installed") + else() + set(LLVM_HOME $ENV{LLVM_HOME} CACHE PATH "Path to which LLVM has been installed") + endif() + endif() if(DEFINED ENV{HIP_DEVELOPER}) add_to_config(_buildInfo HCC_HOME) endif() @@ -189,9 +197,11 @@ if(HIP_PLATFORM STREQUAL "hcc") execute_process(COMMAND ${HCC_HOME}/bin/hcc-config --ldflags OUTPUT_VARIABLE HCC_LD_FLAGS) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${HCC_LD_FLAGS} -Wl,-Bsymbolic") + find_package(LLVM HINTS ${LLVM_HOME}) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --amdgpu-target=gfx701 --amdgpu-target=gfx801 --amdgpu-target=gfx802 --amdgpu-target=gfx803 --amdgpu-target=gfx900") add_library(hip_hcc SHARED ${SOURCE_FILES_RUNTIME}) target_link_libraries(hip_hcc PRIVATE hc_am) + target_link_libraries(hip_hcc PUBLIC LLVMAMDGPUUtils) add_library(hip_hcc_static STATIC ${SOURCE_FILES_RUNTIME}) target_link_libraries(hip_hcc_static PRIVATE hc_am) add_dependencies(hip_hcc_static hip_hcc) diff --git a/projects/hip/bin/hipcc b/projects/hip/bin/hipcc index 361517d551..4c71347cf7 100755 --- a/projects/hip/bin/hipcc +++ b/projects/hip/bin/hipcc @@ -103,6 +103,8 @@ if ($HIP_PLATFORM eq "hcc") { $HIPLDFLAGS = `${HCC_HOME}/bin/hcc-config --ldflags`; + $LLVM_HOME = $ENV{'LLVM_HOME'}; + #### GCC system includes workaround #### $HCC_WA_FLAGS = " "; if ($HCC_VERSION_MAJOR eq 1) { @@ -127,7 +129,7 @@ if ($HIP_PLATFORM eq "hcc") { $HIPCXXFLAGS .= " -Wno-deprecated-register"; $HIPLDFLAGS .= " -lsupc++"; - $HIPLDFLAGS .= " -L$HSA_PATH/lib -L$ROCM_PATH/lib -lhsa-runtime64 -lhc_am -lhsakmt"; + $HIPLDFLAGS .= " -L$HSA_PATH/lib -L$ROCM_PATH/lib -lhsa-runtime64 -lhc_am -lhsakmt `${LLVM_HOME}/bin/llvm-config --ldflags --libs`"; # Add trace marker library: # TODO - once we cleanly separate the HIP API headers from HIP library headers this logic should move to CMakebuild option - apps do not need to see the marker library. @@ -402,9 +404,9 @@ if ($setStdLib eq 0 and $HIP_PLATFORM eq 'hcc') if ($needHipHcc) { if ($linkType eq 0) { - substr($HIPLDFLAGS,0,0) = " $HIP_PATH/lib/libhip_hcc_static.a $HIP_PATH/lib/libhip_device.a " ; + substr($HIPLDFLAGS,0,0) = " $HIP_PATH/lib/libhip_hcc_static.a $HIP_PATH/lib/libhip_device.a " ; } else { - substr($HIPLDFLAGS,0,0) = " -Wl,--rpath=$HIP_PATH/lib $HIP_PATH/lib/libhip_hcc.so $HIP_PATH/lib/libhip_device.a "; + substr($HIPLDFLAGS,0,0) = " -Wl,--rpath=$HIP_PATH/lib $HIP_PATH/lib/libhip_hcc.so $HIP_PATH/lib/libhip_device.a "; } } diff --git a/projects/hip/samples/0_Intro/module_api/Makefile b/projects/hip/samples/0_Intro/module_api/Makefile index f2c0ce555a..632a8d3e70 100644 --- a/projects/hip/samples/0_Intro/module_api/Makefile +++ b/projects/hip/samples/0_Intro/module_api/Makefile @@ -5,14 +5,16 @@ endif HIPCC=$(HIP_PATH)/bin/hipcc HIP_PLATFORM=$(shell $(HIP_PATH)/bin/hipconfig --compiler) -all: vcpy_kernel.code runKernel.hip.out +all: vcpy_kernel.code runKernel.hip.out defaultDriver.hip.out runKernel.hip.out: runKernel.cpp $(HIPCC) $(HIPCC_FLAGS) $< -o $@ +defaultDriver.hip.out: defaultDriver.cpp + $(HIPCC) $(HIPCC_FLAGS) $< -o $@ + vcpy_kernel.code: vcpy_kernel.cpp - $(HIPCC) --genco $(GENCO_FLAGS) $^ -o $@ + $(HIPCC) --genco $(GENCO_FLAGS) $^ -o $@ clean: rm -f *.code *.out - diff --git a/projects/hip/samples/0_Intro/module_api/defaultDriver.cpp b/projects/hip/samples/0_Intro/module_api/defaultDriver.cpp new file mode 100644 index 0000000000..a29271a0dc --- /dev/null +++ b/projects/hip/samples/0_Intro/module_api/defaultDriver.cpp @@ -0,0 +1,89 @@ +/* +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#include "hip/hip_runtime.h" +#include "hip/hip_runtime_api.h" +#include +#include +#include + +#define LEN 64 +#define SIZE LEN<<2 + +#define fileName "test.co" +#define kernel_name "vadd" + +int main(){ + float *A, *B, *C; + hipDeviceptr_t Ad, Bd, Cd; + A = new float[LEN]; + B = new float[LEN]; + C = new float[LEN]; + + for(uint32_t i=0;iH@ikcag#Q!>Xh`B3Zc@Bch`yO`hvZV z8c^LpLG*zK-~;#qzJcbkyp=xZp)W{%;2VH*c4oX@lU6MRTGTy~_spEjoHOT~nZ1l} z950_xGMPCdV1(Q!8En7E33D8g)kC5IXpY!q9IpGw1j#`^8__s_jw9f5*p3DxMB;Hl zM>6U?3@%S_j>OU*)Eh;X@NXF38R2>oOFrtMuY}?SfJWCoUKL%5rJe%xC()DhJNIko zMf0O#;32#!$kGn_hj143B7401*jKa_*+YjBhVX+iPL^249x?ii_Df3(ks7v<{wDk| zoJh}-u}BWOeHzdgmoIYJ?_qo#2W6+Hrzbw6tnTHP7FPUrr`Bu~>4#LGq8hzC6){eA z*r`UfS)^P}bT6?DzuIm#!t=FH{UWuDgmAg(vS7)tH`|+nZ<+-wA#(g;XW4JhUo6t3 z>Jqz#V6$>3okX>R~OsOZi|nutA?ErJHNPmt`r1Kcd^YH-2fcalGZOY zLl&Ir)={uiq_&zgQ}VpF-|4VQ;KxFm3Sq%ei4d&(#Yl1{(gwMRl3lQhSY$ zPXVM2Ao8e!B+eH4rJ%M3brBOz*BV}tikN}G3Jbdah0PWQy03+O?y9@a+I@1#bM>4vFQ~;}Q16q1nEP0f(G_FvEDp zdo-Z)5Dz0CW%36LY=e0o*ZEhoA|si)SgkcMk*J>)*g9D)BtEB_2fZULMh3;u?1Z9iIpA zhh6!I!6n3%-$4kj^8`KZq!CCXkVYVlz%vyA+{gJ3cYN5{#XkQqCrjiLfEcVMCSZnf+KJ%R4w0R2tOC@(z5D$wWS6@Ug44gVlun9{K%iLY{sdMXsioGy-V^ z(g>sxNF$I&AdNs8fiwbX1fJ;#$g}1LFK{;}g}3<5gAkpy16~%d`|_=Sf5a7M&d^pR zL(u!^Tf5VcuNGp1clS53#5wk_3hJ#SjG zOx18bdX(%o%#rmlY;}q=Gi$YQy<5q<&HBta=K0M=bZFVEx4NM}6KUo_glcZZa~$2Q zT2|Gr*sf{m%=dJM`F_PTD_*6l8LDBaN9p5@90VKnXkbG(w1VbY1&>twb`of+XcJoR8-Y44cjz*%hoJI_x&fHhV8hj zrMX^3ovr!>rn_pjU>H`V;5eq~!FhY7QgwYtJxa>8##O&vq~-DgPia5pyEX7T16EV{ zUlPV(!lv(9^Ao8&|P zS{U_Mz2=fU|3gFG?RYF?1Z%18H$VV1LskL2-U-{h#W6W{OuM2*SDg%=d|X-h;7n=h z)O^zUztO|EVT_`$N2o6w0?Yq%APWKiw=oE)i)&h{$#pLANg<4SXbZn>A;|TA0NS_* zNPW4^C8oebkbG%h;#Yx(=S7k)_YsNZK7wN)@H*jbydD%ZxlhS+DvA65^N}h;0~`W6 z>Y@)3&?H_JUFol!zxLu>A%ch8EE~v3t2?>h5knaG;9vrUjf=~`tM<20mLx81J_~wKLJkil%fCt literal 0 HcmV?d00001 diff --git a/projects/hip/src/AMDGPUPTNote.h b/projects/hip/src/AMDGPUPTNote.h new file mode 100644 index 0000000000..8f8c855a52 --- /dev/null +++ b/projects/hip/src/AMDGPUPTNote.h @@ -0,0 +1,45 @@ +//===-- AMDGPUNoteType.h - AMDGPU ELF PT_NOTE section info-------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +/// \file +/// +/// Enums and constants for AMDGPU PT_NOTE sections. +/// +// +//===----------------------------------------------------------------------===// +// +#ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPUPTNOTE_H +#define LLVM_LIB_TARGET_AMDGPU_AMDGPUPTNOTE_H + +namespace AMDGPU { + +namespace ElfNote { + +const char SectionName[] = ".note"; + +const char NoteName[] = "AMD"; + +// TODO: Move this enum to include/llvm/Support so it can be used in tools? +enum NoteType{ + NT_AMDGPU_HSA_CODE_OBJECT_VERSION = 1, + NT_AMDGPU_HSA_HSAIL = 2, + NT_AMDGPU_HSA_ISA = 3, + NT_AMDGPU_HSA_PRODUCER = 4, + NT_AMDGPU_HSA_PRODUCER_OPTIONS = 5, + NT_AMDGPU_HSA_EXTENSION = 6, + NT_AMDGPU_HSA_RUNTIME_METADATA_V_1 = 7, // deprecated since 12/14/16. + NT_AMDGPU_HSA_RUNTIME_METADATA_V_2 = 8, + NT_AMDGPU_HSA_RUNTIME_METADATA = NT_AMDGPU_HSA_RUNTIME_METADATA_V_2, + NT_AMDGPU_HSA_HLDEBUG_DEBUG = 101, + NT_AMDGPU_HSA_HLDEBUG_TARGET = 102 +}; +} +} + +#endif // LLVM_LIB_TARGET_AMDGPU_AMDGPUNOTETYPE_H diff --git a/projects/hip/src/AMDGPURuntimeMetadata.h b/projects/hip/src/AMDGPURuntimeMetadata.h new file mode 100644 index 0000000000..ed147ff4c4 --- /dev/null +++ b/projects/hip/src/AMDGPURuntimeMetadata.h @@ -0,0 +1,290 @@ +//===-- AMDGPURuntimeMetadata.h - AMDGPU Runtime Metadata -------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +/// \file +/// +/// Enums and structure types used by runtime metadata. +/// +/// Runtime requests certain information (metadata) about kernels to be able +/// to execute the kernels and answer the queries about the kernels. +/// The metadata is represented as a note element in the .note ELF section of a +/// binary (code object). The desc field of the note element is a YAML string +/// consisting of key-value pairs. Each key is a string. Each value can be +/// an integer, a string, or an YAML sequence. There are 3 levels of YAML maps. +/// At the beginning of the YAML string is the module level YAML map. A +/// kernel-level YAML map is in the amd.Kernels sequence. A +/// kernel-argument-level map is in the amd.Args sequence. +/// +/// The format should be kept backward compatible. New enum values and bit +/// fields should be appended at the end. It is suggested to bump up the +/// revision number whenever the format changes and document the change +/// in the revision in this header. +/// +// +//===----------------------------------------------------------------------===// +// +#ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPURUNTIMEMETADATA_H +#define LLVM_LIB_TARGET_AMDGPU_AMDGPURUNTIMEMETADATA_H + +#include +#include +#include + +namespace AMDGPU { +namespace RuntimeMD { + + // Version and revision of runtime metadata + const unsigned char MDVersion = 2; + const unsigned char MDRevision = 1; + + // Name of keys for runtime metadata. + namespace KeyName { + + // Runtime metadata version + const char MDVersion[] = "amd.MDVersion"; + + // Instruction set architecture information + const char IsaInfo[] = "amd.IsaInfo"; + // Wavefront size + const char IsaInfoWavefrontSize[] = "amd.IsaInfoWavefrontSize"; + // Local memory size in bytes + const char IsaInfoLocalMemorySize[] = "amd.IsaInfoLocalMemorySize"; + // Number of execution units per compute unit + const char IsaInfoEUsPerCU[] = "amd.IsaInfoEUsPerCU"; + // Maximum number of waves per execution unit + const char IsaInfoMaxWavesPerEU[] = "amd.IsaInfoMaxWavesPerEU"; + // Maximum flat work group size + const char IsaInfoMaxFlatWorkGroupSize[] = "amd.IsaInfoMaxFlatWorkGroupSize"; + // SGPR allocation granularity + const char IsaInfoSGPRAllocGranule[] = "amd.IsaInfoSGPRAllocGranule"; + // Total number of SGPRs + const char IsaInfoTotalNumSGPRs[] = "amd.IsaInfoTotalNumSGPRs"; + // Addressable number of SGPRs + const char IsaInfoAddressableNumSGPRs[] = "amd.IsaInfoAddressableNumSGPRs"; + // VGPR allocation granularity + const char IsaInfoVGPRAllocGranule[] = "amd.IsaInfoVGPRAllocGranule"; + // Total number of VGPRs + const char IsaInfoTotalNumVGPRs[] = "amd.IsaInfoTotalNumVGPRs"; + // Addressable number of VGPRs + const char IsaInfoAddressableNumVGPRs[] = "amd.IsaInfoAddressableNumVGPRs"; + + // Language + const char Language[] = "amd.Language"; + // Language version + const char LanguageVersion[] = "amd.LanguageVersion"; + + // Kernels + const char Kernels[] = "amd.Kernels"; + // Kernel name + const char KernelName[] = "amd.KernelName"; + // Kernel arguments + const char Args[] = "amd.Args"; + // Kernel argument size in bytes + const char ArgSize[] = "amd.ArgSize"; + // Kernel argument alignment + const char ArgAlign[] = "amd.ArgAlign"; + // Kernel argument type name + const char ArgTypeName[] = "amd.ArgTypeName"; + // Kernel argument name + const char ArgName[] = "amd.ArgName"; + // Kernel argument kind + const char ArgKind[] = "amd.ArgKind"; + // Kernel argument value type + const char ArgValueType[] = "amd.ArgValueType"; + // Kernel argument address qualifier + const char ArgAddrQual[] = "amd.ArgAddrQual"; + // Kernel argument access qualifier + const char ArgAccQual[] = "amd.ArgAccQual"; + // Kernel argument is const qualified + const char ArgIsConst[] = "amd.ArgIsConst"; + // Kernel argument is restrict qualified + const char ArgIsRestrict[] = "amd.ArgIsRestrict"; + // Kernel argument is volatile qualified + const char ArgIsVolatile[] = "amd.ArgIsVolatile"; + // Kernel argument is pipe qualified + const char ArgIsPipe[] = "amd.ArgIsPipe"; + // Required work group size + const char ReqdWorkGroupSize[] = "amd.ReqdWorkGroupSize"; + // Work group size hint + const char WorkGroupSizeHint[] = "amd.WorkGroupSizeHint"; + // Vector type hint + const char VecTypeHint[] = "amd.VecTypeHint"; + // Kernel index for device enqueue + const char KernelIndex[] = "amd.KernelIndex"; + // No partial work groups + const char NoPartialWorkGroups[] = "amd.NoPartialWorkGroups"; + // Prinf function call information + const char PrintfInfo[] = "amd.PrintfInfo"; + // The actual kernel argument access qualifier + const char ArgActualAcc[] = "amd.ArgActualAcc"; + // Alignment of pointee type + const char ArgPointeeAlign[] = "amd.ArgPointeeAlign"; + + } // end namespace KeyName + + namespace KernelArg { + + enum Kind : uint8_t { + ByValue = 0, + GlobalBuffer = 1, + DynamicSharedPointer = 2, + Sampler = 3, + Image = 4, + Pipe = 5, + Queue = 6, + HiddenGlobalOffsetX = 7, + HiddenGlobalOffsetY = 8, + HiddenGlobalOffsetZ = 9, + HiddenNone = 10, + HiddenPrintfBuffer = 11, + HiddenDefaultQueue = 12, + HiddenCompletionAction = 13, + }; + + enum ValueType : uint16_t { + Struct = 0, + I8 = 1, + U8 = 2, + I16 = 3, + U16 = 4, + F16 = 5, + I32 = 6, + U32 = 7, + F32 = 8, + I64 = 9, + U64 = 10, + F64 = 11, + }; + + // Avoid using 'None' since it conflicts with a macro in X11 header file. + enum AccessQualifer : uint8_t { + AccNone = 0, + ReadOnly = 1, + WriteOnly = 2, + ReadWrite = 3, + }; + + enum AddressSpaceQualifer : uint8_t { + Private = 0, + Global = 1, + Constant = 2, + Local = 3, + Generic = 4, + Region = 5, + }; + + } // end namespace KernelArg + + // Invalid values are used to indicate an optional key should not be emitted. + const uint8_t INVALID_ADDR_QUAL = 0xff; + const uint8_t INVALID_ACC_QUAL = 0xff; + const uint32_t INVALID_KERNEL_INDEX = ~0U; + + namespace KernelArg { + + // In-memory representation of kernel argument information. + struct Metadata { + uint32_t Size = 0; + uint32_t Align = 0; + uint32_t PointeeAlign = 0; + uint8_t Kind = 0; + uint16_t ValueType = 0; + std::string TypeName; + std::string Name; + uint8_t AddrQual = INVALID_ADDR_QUAL; + uint8_t AccQual = INVALID_ACC_QUAL; + uint8_t IsVolatile = 0; + uint8_t IsConst = 0; + uint8_t IsRestrict = 0; + uint8_t IsPipe = 0; + + Metadata() = default; + }; + + } // end namespace KernelArg + + namespace Kernel { + + // In-memory representation of kernel information. + struct Metadata { + std::string Name; + std::string Language; + std::vector LanguageVersion; + std::vector ReqdWorkGroupSize; + std::vector WorkGroupSizeHint; + std::string VecTypeHint; + uint32_t KernelIndex = INVALID_KERNEL_INDEX; + uint8_t NoPartialWorkGroups = 0; + std::vector Args; + + Metadata() = default; + }; + + } // end namespace Kernel + + namespace IsaInfo { + + /// \brief In-memory representation of instruction set architecture + /// information. + struct Metadata { + /// \brief Wavefront size. + unsigned WavefrontSize = 0; + /// \brief Local memory size in bytes. + unsigned LocalMemorySize = 0; + /// \brief Number of execution units per compute unit. + unsigned EUsPerCU = 0; + /// \brief Maximum number of waves per execution unit. + unsigned MaxWavesPerEU = 0; + /// \brief Maximum flat work group size. + unsigned MaxFlatWorkGroupSize = 0; + /// \brief SGPR allocation granularity. + unsigned SGPRAllocGranule = 0; + /// \brief Total number of SGPRs. + unsigned TotalNumSGPRs = 0; + /// \brief Addressable number of SGPRs. + unsigned AddressableNumSGPRs = 0; + /// \brief VGPR allocation granularity. + unsigned VGPRAllocGranule = 0; + /// \brief Total number of VGPRs. + unsigned TotalNumVGPRs = 0; + /// \brief Addressable number of VGPRs. + unsigned AddressableNumVGPRs = 0; + + Metadata() = default; + }; + + } // end namespace IsaInfo + + namespace Program { + + // In-memory representation of program information. + struct Metadata { + std::vector MDVersionSeq; + IsaInfo::Metadata IsaInfo; + std::vector PrintfInfo; + std::vector Kernels; + + explicit Metadata() = default; + + // Construct from an YAML string. + explicit Metadata(const std::string &YAML); + + // Convert to YAML string. + std::string toYAML(); + + // Convert from YAML string. + static Metadata fromYAML(const std::string &S); + }; + + } //end namespace Program + +} // end namespace RuntimeMD +} // end namespace AMDGPU + +#endif // LLVM_LIB_TARGET_AMDGPU_AMDGPURUNTIMEMETADATA_H diff --git a/projects/hip/src/hip_module.cpp b/projects/hip/src/hip_module.cpp index 1f20a47c13..dc0a681c6d 100644 --- a/projects/hip/src/hip_module.cpp +++ b/projects/hip/src/hip_module.cpp @@ -23,7 +23,12 @@ THE SOFTWARE. #include #include #include +#include #include +#include +#include +#include "AMDGPUPTNote.h" +#include "AMDGPURuntimeMetadata.h" #include "hsa/hsa.h" #include "hsa/hsa_ext_amd.h" @@ -35,6 +40,30 @@ THE SOFTWARE. //TODO Use Pool APIs from HCC to get memory regions. +#include +inline uint64_t alignTo(uint64_t Value, uint64_t Align, uint64_t Skew = 0) { + assert(Align != 0u && "Align can't be 0."); + Skew %= Align; + return (Value + Align - 1 - Skew) / Align * Align + Skew; +} + +struct ihipKernArgInfo{ + std::vector Size; + std::vector Align; + std::vector ArgType; + std::vector ArgName; + uint32_t totalSize; +}; + +std::map kernelArguments; + +struct MyElfNote { + uint32_t n_namesz = 0; + uint32_t n_descsz = 0; + uint32_t n_type = 0; + + MyElfNote() = default; +}; struct ihipModuleSymbol_t{ uint64_t _object; // The kernel object. @@ -172,8 +201,56 @@ hipError_t hipModuleLoad(hipModule_t *module, const char *fname){ (*module)->ptr = p; (*module)->size = size; in.seekg(0, std::ios::beg); - std::copy(std::istreambuf_iterator(in), - std::istreambuf_iterator(), ptr); + std::copy(std::istreambuf_iterator(in), std::istreambuf_iterator(), ptr); + + Elf *e = elf_memory((char*)p, size); + if(elf_kind(e) != ELF_K_ELF){ + return ihipLogStatus(hipErrorInvalidValue); + } + size_t numpHdrs; + if(elf_getphdrnum(e, &numpHdrs) != 0){ + return ihipLogStatus(hipErrorInvalidValue); + } + for(size_t i=0;i= sizeof(int)){ + char* ptr = (char*) p + pHdr.p_offset; + char* segmentEnd = ptr + pHdr.p_filesz; + while(ptr < segmentEnd){ + MyElfNote *note = (MyElfNote*) ptr; + char *name = (char*) ¬e[1]; + char *desc = name + alignTo(note->n_namesz, sizeof(int)); + if (note->n_type == 8) { + std::string metadatastr((const char*)desc, (size_t)note->n_descsz); + AMDGPU::RuntimeMD::Program::Metadata meta; + meta = meta.fromYAML(metadatastr); + for(int i=0;in_namesz, sizeof(int)) + + alignTo(note->n_descsz, sizeof(int)); + } + } + } status = hsa_code_object_deserialize(ptr, size, NULL, &(*module)->object); @@ -313,7 +390,19 @@ hipError_t hipModuleLaunchKernel(hipFunction_t f, void *config[5] = {0}; size_t kernArgSize; - if(extra != NULL){ + if(kernelParams != NULL){ + std::string name = f->_name; + struct ihipKernArgInfo pl = kernelArguments[name]; + char* argBuf = (char*)malloc(pl.totalSize); + memset(argBuf, 0, pl.totalSize); + int index = 0; + for(int i=0;idispatch_hsa_kernel(&aql, config[1] /* kernarg*/, kernArgSize, nullptr/*completion_future*/); - + if(kernelParams != NULL){ + free(config[1]); + } ihipPostLaunchKernel(f->_name.c_str(), hStream, lp); } From 762090f564b5f989bba97f5d4d8163cc6464cd9a Mon Sep 17 00:00:00 2001 From: pensun Date: Fri, 17 Mar 2017 17:17:12 +0000 Subject: [PATCH 226/281] Initial integration with Alex' Generic Grid Launch Change-Id: I559afb80e9e39ec0d119bb3bf3b85ef9e448caf6 [ROCm/hip commit: 33c38de4078cbfaadc97c2197603be83e71c283b] --- .../hip/include/hip/hcc_detail/concepts.hpp | 11 + .../include/hip/hcc_detail/grid_launch_v2.hpp | 227 ++++++++++++++++++ .../hip/include/hip/hcc_detail/helpers.hpp | 96 ++++++++ projects/hip/include/hip/hcc_detail/hip_ldg.h | 4 +- .../hip/include/hip/hcc_detail/hip_runtime.h | 46 ++-- .../include/hip/hcc_detail/hip_runtime_api.h | 3 +- .../hip/include/hip/hcc_detail/host_defines.h | 7 + .../samples/0_Intro/square/square.hipref.cpp | 2 +- projects/hip/src/hip_hcc.cpp | 1 - projects/hip/src/trace_helper.h | 4 +- 10 files changed, 376 insertions(+), 25 deletions(-) create mode 100644 projects/hip/include/hip/hcc_detail/concepts.hpp create mode 100644 projects/hip/include/hip/hcc_detail/grid_launch_v2.hpp create mode 100644 projects/hip/include/hip/hcc_detail/helpers.hpp diff --git a/projects/hip/include/hip/hcc_detail/concepts.hpp b/projects/hip/include/hip/hcc_detail/concepts.hpp new file mode 100644 index 0000000000..373ec15411 --- /dev/null +++ b/projects/hip/include/hip/hcc_detail/concepts.hpp @@ -0,0 +1,11 @@ +// +// Created by alexv on 25/10/16. +// +#pragma once + +namespace glo_tests // Documentation only. +{ + #define requires(...) + + #define FunctionalProcedure typename +} diff --git a/projects/hip/include/hip/hcc_detail/grid_launch_v2.hpp b/projects/hip/include/hip/hcc_detail/grid_launch_v2.hpp new file mode 100644 index 0000000000..ab11433a5b --- /dev/null +++ b/projects/hip/include/hip/hcc_detail/grid_launch_v2.hpp @@ -0,0 +1,227 @@ +// +// Created by alexv on 25/10/16. +// +#pragma once + +#include "concepts.hpp" +#include "helpers.hpp" + +#include "hc.hpp" +#include "hcc_acc.h" + +//#include +//#include + +#include +#include +#include + + +namespace glo_tests +{ + namespace + { + struct New_grid_launch_tag {}; + struct Old_grid_launch_tag {}; + } + + template + using is_new_grid_launch_t = typename std::conditional< + std::is_callable{}, + New_grid_launch_tag, + Old_grid_launch_tag>::type; + + // TODO: - dispatch rank should be derived from the domain dimensions passed + // in, and not always assumed to be 3; + + template + requires(Domain == {Ts...}) + static + inline + void grid_launch_impl( + New_grid_launch_tag, + dim3 num_blocks, + dim3 dim_blocks, + int group_mem_bytes, + hipStream_t stream, + K k, + Ts&&... args) + { + const auto d = hc::extent<3>{ + num_blocks.z * dim_blocks.z, + num_blocks.y * dim_blocks.y, + num_blocks.x * dim_blocks.x}.tile_with_dynamic( + dim_blocks.z, + dim_blocks.y, + dim_blocks.x, + group_mem_bytes); + hc::accelerator_view* av = nullptr; + + if (hipHccGetAcceleratorView(stream, &av) != HIP_SUCCESS) { + throw std::runtime_error{"Failed to retrieve accelerator_view!"}; + } + + hc::parallel_for_each(*av, d, [=](hc::tiled_index<3> idx) [[hc]] { + k(args...); + }); + } + + template + requires(Domain == {hipLaunchParm, Ts...}) + static + inline + void grid_launch_impl( + Old_grid_launch_tag, + dim3 num_blocks, + dim3 dim_blocks, + int group_mem_bytes, + hipStream_t stream, + K k, + Ts&&... args) + { + grid_launch_impl( + New_grid_launch_tag{}, + std::move(num_blocks), + std::move(dim_blocks), + group_mem_bytes, + std::move(stream), + std::move(k), + hipLaunchParm{}, + std::forward(args)...); + } + + template + requires(Domain == {Ts...}) + static + inline + std::enable_if_t::value> grid_launch( + dim3 num_blocks, + dim3 dim_blocks, + int group_mem_bytes, + hipStream_t stream, + K k, + Ts&& ... args) + { + grid_launch_impl( + is_new_grid_launch_t{}, + std::move(num_blocks), + std::move(dim_blocks), + group_mem_bytes, + std::move(stream), + std::move(k), + std::forward(args)...); + } + + template + requires(Domain == {Ts...}) + static + inline + void grid_launch( + New_grid_launch_tag, + dim3 num_blocks, + dim3 dim_blocks, + int group_mem_bytes, + hipStream_t stream, + Ts&&... args) + { + grid_launch( + std::move(num_blocks), + std::move(dim_blocks), + group_mem_bytes, + std::move(stream), + [](decltype(std::decay_t(args))... f_args) [[hc]] { + k(f_args...); + }, + std::forward(args)...); + } + + template + requires(Domain == {Ts...}) + static + inline + void grid_launch( + Old_grid_launch_tag, + dim3 num_blocks, + dim3 dim_blocks, + int group_mem_bytes, + hipStream_t stream, + Ts&&... args) + { + grid_launch( + New_grid_launch_tag{}, + std::move(num_blocks), + std::move(dim_blocks), + group_mem_bytes, + std::move(stream), + hipLaunchParm{}, + std::forward(args)...); + } + + template + requires(Domain == {Ts...}) + static + inline + std::enable_if_t::value> grid_launch( + dim3 num_blocks, + dim3 dim_blocks, + int group_mem_bytes, + hipStream_t stream, + Ts&&... args) + { + grid_launch( + is_new_grid_launch_t{}, + std::move(num_blocks), + std::move(dim_blocks), + group_mem_bytes, + std::move(stream), + std::forward(args)...); + } + + template struct Wrapper; + + template + struct Wrapper::value>> { + template + requires(Domain == {Ts...}) + void operator()(Ts&&... args) const + { + grid_launch_impl( + is_new_grid_launch_t{}, + std::forward(args)...); + } + }; + + template + struct Wrapper::value>> { + template + void operator()(Ts&&...) const {} + }; +#warning "GGL hipLaunchKernel defined" + #define hipLaunchKernel( \ + kernel_name, \ + num_blocks, \ + dim_blocks, \ + group_mem_bytes, \ + stream, \ + ...) \ + { \ + using F = decltype(kernel_name); \ + if (!std::is_function::value) { \ + glo_tests::Wrapper{}( \ + num_blocks, \ + dim_blocks, \ + group_mem_bytes, \ + stream, \ + kernel_name, \ + ##__VA_ARGS__); \ + } \ + else { \ + glo_tests::grid_launch( \ + num_blocks, \ + dim_blocks, \ + group_mem_bytes, \ + stream, \ + ##__VA_ARGS__); \ + } \ + } +} diff --git a/projects/hip/include/hip/hcc_detail/helpers.hpp b/projects/hip/include/hip/hcc_detail/helpers.hpp new file mode 100644 index 0000000000..ca3864911f --- /dev/null +++ b/projects/hip/include/hip/hcc_detail/helpers.hpp @@ -0,0 +1,96 @@ +// +// Created by alexv on 08/11/16. +// +#pragma once + +#include // For std::conditional, std::decay, std::enable_if, + // std::false_type, std result_of and std::true_type. +#include // For std::declval. + +namespace std +{ + #if (__cplusplus < 201406L) + template + using void_t = void; + + #if (__cplusplus < 201402L) + template + using enable_if_t = typename enable_if::type; + template + using conditional_t = typename conditional::type; + template + using decay_t = typename decay::type; + template + using result_of_t = typename result_of::type; + + template< + FunctionalProcedure F, + unsigned int n = 0u, + typename = void> + struct is_callable_impl : is_callable_impl {}; + + // Pointer to member function, call through non-pointer. + template + struct is_callable_impl< + F(C, Ts...), + 0u, + void_t().*declval())(declval()...))> + > : true_type { + }; + + // Pointer to member function, call through pointer. + template + struct is_callable_impl< + F(C, Ts...), + 1u, + void_t()).*declval())(declval()...))> + > : std::true_type { + }; + + // Pointer to member data, call through non-pointer, no args. + template + struct is_callable_impl< + F(C), + 2u, + void_t().*declval())> + > : true_type { + }; + + // Pointer to member data, call through pointer, no args. + template + struct is_callable_impl< + F(C), + 3u, + void_t().*declval())> + > : true_type { + }; + + // General call, n args. + template + struct is_callable_impl< + F(Ts...), + 4u, + void_t()(declval()...))> + > : true_type { + }; + + // Not callable. + template + struct is_callable_impl : false_type {}; + + template + struct is_callable : is_callable_impl {}; + #else + template + struct is_callable_impl : false_type {}; + + template + struct is_callable_impl< + F(Ts...), + void_t>> : true_type {}; + + template + struct is_callable : is_callable_impl {}; + #endif + #endif +} diff --git a/projects/hip/include/hip/hcc_detail/hip_ldg.h b/projects/hip/include/hip/hcc_detail/hip_ldg.h index 65292951f0..6bf7a618d0 100644 --- a/projects/hip/include/hip/hcc_detail/hip_ldg.h +++ b/projects/hip/include/hip/hcc_detail/hip_ldg.h @@ -23,11 +23,11 @@ THE SOFTWARE. #ifndef HIP_LDG_H #define HIP_LDG_H -#if __HCC__ +#if defined __HCC__ #if __hcc_workweek__ >= 16164 #include "hip_vector_types.h" #include "host_defines.h" - +#warning "LDG header included" __device__ char __ldg(const char* ); __device__ char2 __ldg(const char2* ); diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime.h b/projects/hip/include/hip/hcc_detail/hip_runtime.h index af294cdb53..9d0a43b1df 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime.h @@ -32,7 +32,6 @@ THE SOFTWARE. //--- // Top part of file can be compiled with any compiler - //#include #if __cplusplus #include @@ -40,7 +39,8 @@ THE SOFTWARE. #include #include #include -#endif +#endif//__cplusplus + // Define NVCC_COMPAT for CUDA compatibility #define NVCC_COMPAT #define CUDA_SUCCESS hipSuccess @@ -58,20 +58,30 @@ THE SOFTWARE. //--- // Remainder of this file only compiles with HCC -#ifdef __HCC__ +#if defined __HCC__ #include - -#if defined (GRID_LAUNCH_VERSION) and (GRID_LAUNCH_VERSION >= 20) -// Use field names for grid_launch 2.0 structure, if HCC supports GL 2.0. +//TODO-HCC-GL - change this to typedef. +//typedef grid_launch_parm hipLaunchParm ; +struct EmptyLaunchParm{}; +#ifndef GENERIC_GRID_LAUNCH + #define hipLaunchParm grid_launch_parm #else + #define hipLaunchParm EmptyLaunchParm +#endif //GENERIC_GRID_LAUNCH + +#if defined (GRID_LAUNCH_VERSION) and (GRID_LAUNCH_VERSION >= 20) || defined GENERIC_GRID_LAUNCH +#else // Use field names for grid_launch 2.0 structure, if HCC supports GL 2.0. #error (HCC must support GRID_LAUNCH_20) -#endif +#endif //GRID_LAUNCH_VERSION + +#endif //HCC + +#if defined GENERIC_GRID_LAUNCH && defined __HCC__ +#include "grid_launch_v2.hpp" +#endif//GENERIC_GRID_LAUNCH extern int HIP_TRACE_API; -//TODO-HCC-GL - change this to typedef. -//typedef grid_launch_parm hipLaunchParm ; -#define hipLaunchParm grid_launch_parm #ifdef __cplusplus //#include #include @@ -266,7 +276,7 @@ __device__ float __shfl(float input, int lane, int width); __device__ float __shfl_up(float input, unsigned int lane_delta, int width); __device__ float __shfl_down(float input, unsigned int lane_delta, int width); __device__ float __shfl_xor(float input, int lane_mask, int width); -#endif +#endif //__cplusplus __device__ unsigned __hip_ds_bpermute(int index, unsigned src); __device__ float __hip_ds_bpermutef(int index, float src); @@ -278,7 +288,7 @@ __device__ float __hip_ds_swizzlef(float src, int pattern); __device__ int __hip_move_dpp(int src, int dpp_ctrl, int row_mask, int bank_mask, bool bound_ctrl); -#endif +#endif //__HIP_ARCH_GFX803__ == 1 __host__ __device__ int min(int arg1, int arg2); __host__ __device__ int max(int arg1, int arg2); @@ -409,14 +419,15 @@ static inline __device__ void* memset(void* ptr, int val, size_t size) #define HIP_KERNEL_NAME(...) __VA_ARGS__ #define HIP_SYMBOL(X) #X -#ifdef __HCC_CPP__ +#if defined __HCC_CPP__ extern hipStream_t ihipPreLaunchKernel(hipStream_t stream, dim3 grid, dim3 block, grid_launch_parm *lp, const char *kernelNameStr); extern hipStream_t ihipPreLaunchKernel(hipStream_t stream, dim3 grid, size_t block, grid_launch_parm *lp, const char *kernelNameStr); extern hipStream_t ihipPreLaunchKernel(hipStream_t stream, size_t grid, dim3 block, grid_launch_parm *lp, const char *kernelNameStr); extern hipStream_t ihipPreLaunchKernel(hipStream_t stream, size_t grid, size_t block, grid_launch_parm *lp, const char *kernelNameStr); extern void ihipPostLaunchKernel(const char *kernelName, hipStream_t stream, grid_launch_parm &lp); - +#ifndef GENERIC_GRID_LAUNCH +#warning "Original hipLaunchKernel defined" // Due to multiple overloaded versions of ihipPreLaunchKernel, the numBlocks3D and blockDim3D can be either size_t or dim3 types #define hipLaunchKernel(_kernelName, _numBlocks3D, _blockDim3D, _groupMemBytes, _stream, ...) \ do {\ @@ -426,13 +437,13 @@ do {\ _kernelName (lp, ##__VA_ARGS__);\ ihipPostLaunchKernel(#_kernelName, trueStream, lp);\ } while(0) - +#endif //GENERIC_GRID_LAUNCH #elif defined (__HCC_C__) //TODO - develop C interface. -#endif +#endif //__HCC_CPP__ /** * extern __shared__ @@ -446,7 +457,6 @@ do {\ #define HIP_DYNAMIC_SHARED_ATTRIBUTE ADDRESS_SPACE_3 -#endif // __HCC__ /** @@ -470,4 +480,4 @@ do {\ -#endif +#endif//HIP_HCC_DETAIL_RUNTIME_H diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h index 0d3ecc6613..c769548214 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h @@ -27,7 +27,8 @@ THE SOFTWARE. * @file hcc_detail/hip_runtime_api.h * @brief Contains C function APIs for HIP runtime. This file does not use any HCC builtin or special language extensions (-hc mode) ; those functions in hip_runtime.h. */ - +// guard for grid_launch_v2 +#define GENERIC_GRID_LAUNCH #include #include #include diff --git a/projects/hip/include/hip/hcc_detail/host_defines.h b/projects/hip/include/hip/hcc_detail/host_defines.h index 93695a0038..d7128d6fab 100644 --- a/projects/hip/include/hip/hcc_detail/host_defines.h +++ b/projects/hip/include/hip/hcc_detail/host_defines.h @@ -37,7 +37,14 @@ THE SOFTWARE. #define __host__ __attribute__((cpu)) #define __device__ __attribute__((hc)) +#warning "HOST DEFINE header included" +#ifndef GENERIC_GRID_LAUNCH +#warning "original global define reached" #define __global__ __attribute__((hc_grid_launch)) __attribute__((used)) +#else +#warning "GGL global define reached" +#define __global__ [[hc]] __attribute__((weak)) +#endif //GENERIC_GRID_LAUNCH #define __noinline__ __attribute__((noinline)) #define __forceinline__ __attribute__((always_inline)) diff --git a/projects/hip/samples/0_Intro/square/square.hipref.cpp b/projects/hip/samples/0_Intro/square/square.hipref.cpp index e694bfb8a4..118f8acf13 100644 --- a/projects/hip/samples/0_Intro/square/square.hipref.cpp +++ b/projects/hip/samples/0_Intro/square/square.hipref.cpp @@ -83,7 +83,7 @@ int main(int argc, char *argv[]) const unsigned threadsPerBlock = 256; printf ("info: launch 'vector_square' kernel\n"); - hipLaunchKernel(vector_square, dim3(blocks), dim3(threadsPerBlock), 0, 0, C_d, A_d, N); + hipLaunchKernel(vector_square, dim3(blocks), dim3(threadsPerBlock), 0, nullptr, C_d, A_d, N); printf ("info: copy Device2Host\n"); CHECK ( hipMemcpy(C_h, C_d, Nbytes, hipMemcpyDeviceToHost)); diff --git a/projects/hip/src/hip_hcc.cpp b/projects/hip/src/hip_hcc.cpp index 760f46046a..4d922e65e7 100644 --- a/projects/hip/src/hip_hcc.cpp +++ b/projects/hip/src/hip_hcc.cpp @@ -1556,7 +1556,6 @@ void ihipPostLaunchKernel(const char *kernelName, hipStream_t stream, grid_launc MARKER_END(); } - //================================================================================================= // HIP API Implementation // diff --git a/projects/hip/src/trace_helper.h b/projects/hip/src/trace_helper.h index 3bf2857c3a..abff491916 100644 --- a/projects/hip/src/trace_helper.h +++ b/projects/hip/src/trace_helper.h @@ -28,7 +28,6 @@ THE SOFTWARE. #include #include #include - //--- // Helper functions to convert HIP function arguments into strings. // Handles POD data types as well as enumerations (ie hipMemcpyKind). @@ -71,7 +70,7 @@ inline std::string ToString(hipEvent_t v) ss << v; return ss.str(); }; - +#ifndef GENERIC_GRID_LAUNCH // hipStream_t template <> inline std::string ToString(hipStream_t v) @@ -85,6 +84,7 @@ inline std::string ToString(hipStream_t v) return ss.str(); }; +#endif //GENERIC_GRID_LAUNCH // hipMemcpyKind specialization template <> From 81622d12636bf18815abd6db1e64625391a71f52 Mon Sep 17 00:00:00 2001 From: pensun Date: Fri, 17 Mar 2017 19:57:20 +0000 Subject: [PATCH 227/281] Change the #define of GENERIC_GRID_LAUNCH to take valueat compilation, disable warning messages Change-Id: Ic6c011529e26de359bcda1e7083727e7ee52887b [ROCm/hip commit: 30d5f4ea100edb0fd1a023159a43878475d6d2ca] --- .../hip/include/hip/hcc_detail/grid_launch_v2.hpp | 2 +- projects/hip/include/hip/hcc_detail/hip_ldg.h | 1 - projects/hip/include/hip/hcc_detail/hip_runtime.h | 8 ++++---- .../hip/include/hip/hcc_detail/hip_runtime_api.h | 6 ++++-- projects/hip/include/hip/hcc_detail/host_defines.h | 13 +++++++++---- projects/hip/src/trace_helper.h | 2 -- 6 files changed, 18 insertions(+), 14 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/grid_launch_v2.hpp b/projects/hip/include/hip/hcc_detail/grid_launch_v2.hpp index ab11433a5b..9f7492b4d5 100644 --- a/projects/hip/include/hip/hcc_detail/grid_launch_v2.hpp +++ b/projects/hip/include/hip/hcc_detail/grid_launch_v2.hpp @@ -196,7 +196,7 @@ namespace glo_tests template void operator()(Ts&&...) const {} }; -#warning "GGL hipLaunchKernel defined" +//#warning "GGL hipLaunchKernel defined" #define hipLaunchKernel( \ kernel_name, \ num_blocks, \ diff --git a/projects/hip/include/hip/hcc_detail/hip_ldg.h b/projects/hip/include/hip/hcc_detail/hip_ldg.h index 6bf7a618d0..5c33ee773f 100644 --- a/projects/hip/include/hip/hcc_detail/hip_ldg.h +++ b/projects/hip/include/hip/hcc_detail/hip_ldg.h @@ -27,7 +27,6 @@ THE SOFTWARE. #if __hcc_workweek__ >= 16164 #include "hip_vector_types.h" #include "host_defines.h" -#warning "LDG header included" __device__ char __ldg(const char* ); __device__ char2 __ldg(const char2* ); diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime.h b/projects/hip/include/hip/hcc_detail/hip_runtime.h index 9d0a43b1df..673807fcd2 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime.h @@ -63,20 +63,20 @@ THE SOFTWARE. //TODO-HCC-GL - change this to typedef. //typedef grid_launch_parm hipLaunchParm ; struct EmptyLaunchParm{}; -#ifndef GENERIC_GRID_LAUNCH +#if GENERIC_GRID_LAUNCH == 0 #define hipLaunchParm grid_launch_parm #else #define hipLaunchParm EmptyLaunchParm #endif //GENERIC_GRID_LAUNCH -#if defined (GRID_LAUNCH_VERSION) and (GRID_LAUNCH_VERSION >= 20) || defined GENERIC_GRID_LAUNCH +#if defined (GRID_LAUNCH_VERSION) and (GRID_LAUNCH_VERSION >= 20) || GENERIC_GRID_LAUNCH == 1 #else // Use field names for grid_launch 2.0 structure, if HCC supports GL 2.0. #error (HCC must support GRID_LAUNCH_20) #endif //GRID_LAUNCH_VERSION #endif //HCC -#if defined GENERIC_GRID_LAUNCH && defined __HCC__ +#if GENERIC_GRID_LAUNCH==1 && defined __HCC__ #include "grid_launch_v2.hpp" #endif//GENERIC_GRID_LAUNCH @@ -426,7 +426,7 @@ extern hipStream_t ihipPreLaunchKernel(hipStream_t stream, size_t grid, dim3 blo extern hipStream_t ihipPreLaunchKernel(hipStream_t stream, size_t grid, size_t block, grid_launch_parm *lp, const char *kernelNameStr); extern void ihipPostLaunchKernel(const char *kernelName, hipStream_t stream, grid_launch_parm &lp); -#ifndef GENERIC_GRID_LAUNCH +#if GENERIC_GRID_LAUNCH == 0 #warning "Original hipLaunchKernel defined" // Due to multiple overloaded versions of ihipPreLaunchKernel, the numBlocks3D and blockDim3D can be either size_t or dim3 types #define hipLaunchKernel(_kernelName, _numBlocks3D, _blockDim3D, _groupMemBytes, _stream, ...) \ diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h index c769548214..01fea548b8 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h @@ -27,12 +27,14 @@ THE SOFTWARE. * @file hcc_detail/hip_runtime_api.h * @brief Contains C function APIs for HIP runtime. This file does not use any HCC builtin or special language extensions (-hc mode) ; those functions in hip_runtime.h. */ -// guard for grid_launch_v2 -#define GENERIC_GRID_LAUNCH #include #include #include +#ifndef GENERIC_GRID_LAUNCH +#define GENERIC_GRID_LAUNCH 0 +#endif + #include #include #include diff --git a/projects/hip/include/hip/hcc_detail/host_defines.h b/projects/hip/include/hip/hcc_detail/host_defines.h index d7128d6fab..6804ba464b 100644 --- a/projects/hip/include/hip/hcc_detail/host_defines.h +++ b/projects/hip/include/hip/hcc_detail/host_defines.h @@ -30,6 +30,11 @@ THE SOFTWARE. #define USE_PROMOTE_FREE_HCC 0 +// Add guard to Generic Grid Launch method +#ifndef GENERIC_GRID_LAUNCH +#define GENERIC_GRID_LAUNCH 0 +#endif + #ifdef __HCC__ /** * Function and kernel markers @@ -37,12 +42,12 @@ THE SOFTWARE. #define __host__ __attribute__((cpu)) #define __device__ __attribute__((hc)) -#warning "HOST DEFINE header included" -#ifndef GENERIC_GRID_LAUNCH -#warning "original global define reached" +//#warning "HOST DEFINE header included" +#if GENERIC_GRID_LAUNCH == 0 +//#warning "original global define reached" #define __global__ __attribute__((hc_grid_launch)) __attribute__((used)) #else -#warning "GGL global define reached" +//#warning "GGL global define reached" #define __global__ [[hc]] __attribute__((weak)) #endif //GENERIC_GRID_LAUNCH diff --git a/projects/hip/src/trace_helper.h b/projects/hip/src/trace_helper.h index abff491916..d49cb67be0 100644 --- a/projects/hip/src/trace_helper.h +++ b/projects/hip/src/trace_helper.h @@ -70,7 +70,6 @@ inline std::string ToString(hipEvent_t v) ss << v; return ss.str(); }; -#ifndef GENERIC_GRID_LAUNCH // hipStream_t template <> inline std::string ToString(hipStream_t v) @@ -84,7 +83,6 @@ inline std::string ToString(hipStream_t v) return ss.str(); }; -#endif //GENERIC_GRID_LAUNCH // hipMemcpyKind specialization template <> From 90e79afc246d5eec06d497ae92f77abb81412b1e Mon Sep 17 00:00:00 2001 From: "Sun, Peng" Date: Fri, 17 Mar 2017 15:03:03 -0500 Subject: [PATCH 228/281] Disable additional debug warning message Change-Id: Ic5c374589bfad387a7c4c5346430a490e2c6e2a7 [ROCm/hip commit: e7689e9e6e65db444ca035fafeaf7c4b43ae9849] --- .../hip/include/hip/hcc_detail/hip_runtime.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime.h b/projects/hip/include/hip/hcc_detail/hip_runtime.h index 673807fcd2..870dcd0b34 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime.h @@ -49,8 +49,8 @@ THE SOFTWARE. #if USE_PROMOTE_FREE_HCC == 1 -#define ADDRESS_SPACE_1 -#define ADDRESS_SPACE_3 +#define ADDRESS_SPACE_1 +#define ADDRESS_SPACE_3 #else #define ADDRESS_SPACE_1 __attribute__((address_space(1))) #define ADDRESS_SPACE_3 __attribute__((address_space(3))) @@ -58,7 +58,7 @@ THE SOFTWARE. //--- // Remainder of this file only compiles with HCC -#if defined __HCC__ +#if defined __HCC__ #include //TODO-HCC-GL - change this to typedef. //typedef grid_launch_parm hipLaunchParm ; @@ -74,7 +74,7 @@ struct EmptyLaunchParm{}; #error (HCC must support GRID_LAUNCH_20) #endif //GRID_LAUNCH_VERSION -#endif //HCC +#endif //HCC #if GENERIC_GRID_LAUNCH==1 && defined __HCC__ #include "grid_launch_v2.hpp" @@ -419,7 +419,7 @@ static inline __device__ void* memset(void* ptr, int val, size_t size) #define HIP_KERNEL_NAME(...) __VA_ARGS__ #define HIP_SYMBOL(X) #X -#if defined __HCC_CPP__ +#if defined __HCC_CPP__ extern hipStream_t ihipPreLaunchKernel(hipStream_t stream, dim3 grid, dim3 block, grid_launch_parm *lp, const char *kernelNameStr); extern hipStream_t ihipPreLaunchKernel(hipStream_t stream, dim3 grid, size_t block, grid_launch_parm *lp, const char *kernelNameStr); extern hipStream_t ihipPreLaunchKernel(hipStream_t stream, size_t grid, dim3 block, grid_launch_parm *lp, const char *kernelNameStr); @@ -427,7 +427,7 @@ extern hipStream_t ihipPreLaunchKernel(hipStream_t stream, size_t grid, size_t b extern void ihipPostLaunchKernel(const char *kernelName, hipStream_t stream, grid_launch_parm &lp); #if GENERIC_GRID_LAUNCH == 0 -#warning "Original hipLaunchKernel defined" +//#warning "Original hipLaunchKernel defined" // Due to multiple overloaded versions of ihipPreLaunchKernel, the numBlocks3D and blockDim3D can be either size_t or dim3 types #define hipLaunchKernel(_kernelName, _numBlocks3D, _blockDim3D, _groupMemBytes, _stream, ...) \ do {\ @@ -437,13 +437,13 @@ do {\ _kernelName (lp, ##__VA_ARGS__);\ ihipPostLaunchKernel(#_kernelName, trueStream, lp);\ } while(0) -#endif //GENERIC_GRID_LAUNCH +#endif //GENERIC_GRID_LAUNCH #elif defined (__HCC_C__) //TODO - develop C interface. -#endif //__HCC_CPP__ +#endif //__HCC_CPP__ /** * extern __shared__ From 5d1ae81def1a7baa084c050f203b01b8d933040d Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Fri, 17 Mar 2017 18:26:10 -0500 Subject: [PATCH 229/281] added support for lgammaf and lgamma 1. Implementation inside HIP Change-Id: I657263b7276a57c56081d3336fef816b5f204eff [ROCm/hip commit: d9f0bd25beba064b43aaa711653bddae019ca128] --- .../hip/include/hip/hcc_detail/math_functions.h | 2 +- projects/hip/src/math_functions.cpp | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/math_functions.h b/projects/hip/include/hip/hcc_detail/math_functions.h index 2cc4ef81bd..8455509732 100644 --- a/projects/hip/include/hip/hcc_detail/math_functions.h +++ b/projects/hip/include/hip/hcc_detail/math_functions.h @@ -66,7 +66,7 @@ __device__ float j0f(float x); __device__ float j1f(float x); __device__ float jnf(int n, float x); __device__ float ldexpf(float x, int exp); -//__device__ float lgammaf(float x); +__device__ float lgammaf(float x); __device__ long long int llrintf(float x); __device__ long long int llroundf(float x); __device__ float log10f(float x); diff --git a/projects/hip/src/math_functions.cpp b/projects/hip/src/math_functions.cpp index 6e919b3926..92cc8689fc 100644 --- a/projects/hip/src/math_functions.cpp +++ b/projects/hip/src/math_functions.cpp @@ -188,8 +188,12 @@ __device__ float ldexpf(float x, int exp) } __device__ float lgammaf(float x) { - int sign; - return hc::precise_math::lgammaf(x, &sign); + float val = 0.0f; + float y = x - 1; + while(y > 0){ + val += logf(y--); + } + return val; } __device__ long long int llrintf(float x) { @@ -570,8 +574,12 @@ __device__ double ldexp(double x, int exp) } __device__ double lgamma(double x) { - int sign; - return hc::precise_math::lgamma(x, &sign); + double val = 0.0; + double y = x - 1; + while(y > 0){ + val += log(y--); + } + return val; } __device__ long long int llrint(double x) { From e4c4da05fd3eb141cd49ebd687c3d0fe8a14af58 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Mon, 20 Mar 2017 21:03:18 +0300 Subject: [PATCH 230/281] [HIP] [FIX] Fix GCC build. [ROCm/hip commit: e34e5ef885d998501171654b684242fde0964a8d] --- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index 8caac787e8..6c24fbf288 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -2271,7 +2271,7 @@ public: StringRef repName = found->second.hipName; DEBUG(dbgs() << "Identifier " << name << " found as an actual argument in expansion of macro " - << macroName << "\n" + << MacroNameTok.getIdentifierInfo()->getName() << "\n" << "will be replaced with: " << repName << "\n"); size_t length = name.size(); SourceLocation sl = tok.getLocation(); From 83bb70b649934d56ebfca0be038c9cd015bea565 Mon Sep 17 00:00:00 2001 From: "Sun, Peng" Date: Mon, 20 Mar 2017 15:44:28 -0500 Subject: [PATCH 231/281] Add document for switching to GGL in hip_faq.md Change-Id: I83d9fd3e76d21ab572949c3a446ac3898acb3ded [ROCm/hip commit: be7466ff67e6d20658470714144749ea83ce89b2] --- projects/hip/docs/markdown/hip_faq.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/projects/hip/docs/markdown/hip_faq.md b/projects/hip/docs/markdown/hip_faq.md index d7235c4ebc..1543241f6d 100644 --- a/projects/hip/docs/markdown/hip_faq.md +++ b/projects/hip/docs/markdown/hip_faq.md @@ -235,3 +235,18 @@ Unlike CUDA, in HCC, for functions defined in the header files, the keyword of " Thus, if failed to define "static" keyword, you might see a lot of "symbol multiply defined!" errors at compilation. The workaround is to explicitly add the keyword of "static" before any functions that were defined as "__forceinline__". + +### How do I enable HIP Generic Grid Launch option? +Generic Grid Launch(GGL) provide a second choice for kernel launch. +To enable it, either change the default value of GENERIC_GRID_LAUNCH to 1 in the following to header files and rebuild HIP: +$HIP/include/hip/hcc_detail/hip_runtime_api.h +$HIP/include/hip/hcc_detail/host_defines.h +Or pass "-DGENERIC_GRID_LAUNCH=1" to hipcc at application compilation time. + +There are some limitation/assumptions of GGL implementation right now: +1. GGL was only tested with Ubuntu16.04, assuming HCC and HIP only link against libstdc++ but not libc++. +2. GGL currently requires templated kernel fucntions passed to hipLaunchKernel to be specialized. e.g.: + +``` +hipLaunchKernel(vector_square, dim3(blocks), dim3(threadsPerBlock), 0, nullptr, C_d, A_d, N); +``` From 54d331c4570731b688ed398054e344f8a0ad0f62 Mon Sep 17 00:00:00 2001 From: "Sun, Peng" Date: Mon, 20 Mar 2017 15:50:10 -0500 Subject: [PATCH 232/281] Add link to GGL document in hip_faq.md Change-Id: I9f7f0200a06976d580be334c21640c816f812ebb [ROCm/hip commit: 384a350f40c16ef8f6f2278da85782663e70799a] --- projects/hip/docs/markdown/hip_faq.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/hip/docs/markdown/hip_faq.md b/projects/hip/docs/markdown/hip_faq.md index 1543241f6d..01b05ed223 100644 --- a/projects/hip/docs/markdown/hip_faq.md +++ b/projects/hip/docs/markdown/hip_faq.md @@ -26,6 +26,7 @@ - [How do I trace HIP application flow?](#how-do-i-trace-hip-application-flow) * [Using CodeXL markers for HIP Functions](#using-codexl-markers-for-hip-functions) * [Using HIP_TRACE_API](#using-hip_trace_api) +- [How do I enable HIP Generic Grid Launch option?](#how-do-i-enable-hip-generic-grid-launch-option) @@ -235,7 +236,6 @@ Unlike CUDA, in HCC, for functions defined in the header files, the keyword of " Thus, if failed to define "static" keyword, you might see a lot of "symbol multiply defined!" errors at compilation. The workaround is to explicitly add the keyword of "static" before any functions that were defined as "__forceinline__". - ### How do I enable HIP Generic Grid Launch option? Generic Grid Launch(GGL) provide a second choice for kernel launch. To enable it, either change the default value of GENERIC_GRID_LAUNCH to 1 in the following to header files and rebuild HIP: From b5e6670807519b3dbb55aaa490c91cb850749f45 Mon Sep 17 00:00:00 2001 From: "Sun, Peng" Date: Mon, 20 Mar 2017 16:34:24 -0500 Subject: [PATCH 233/281] merge Alex' GGL fix for non-specialized kernel function launch Change-Id: Idbf7ca669c38ee5c0f654bcabdd1b498abb29f69 [ROCm/hip commit: d09afd23b8225a0c1cbcd971a8fe1e68d07adfba] --- .../hip/include/hip/hcc_detail/concepts.hpp | 22 ++ .../include/hip/hcc_detail/grid_launch_v2.hpp | 203 ++++++++++++++---- .../hip/include/hip/hcc_detail/helpers.hpp | 46 +++- 3 files changed, 227 insertions(+), 44 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/concepts.hpp b/projects/hip/include/hip/hcc_detail/concepts.hpp index 373ec15411..c746c1cfe6 100644 --- a/projects/hip/include/hip/hcc_detail/concepts.hpp +++ b/projects/hip/include/hip/hcc_detail/concepts.hpp @@ -1,3 +1,25 @@ +/* +Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + // // Created by alexv on 25/10/16. // diff --git a/projects/hip/include/hip/hcc_detail/grid_launch_v2.hpp b/projects/hip/include/hip/hcc_detail/grid_launch_v2.hpp index 9f7492b4d5..02f214bd67 100644 --- a/projects/hip/include/hip/hcc_detail/grid_launch_v2.hpp +++ b/projects/hip/include/hip/hcc_detail/grid_launch_v2.hpp @@ -1,3 +1,25 @@ +/* +Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + // // Created by alexv on 25/10/16. // @@ -9,14 +31,10 @@ #include "hc.hpp" #include "hcc_acc.h" -//#include -//#include - #include #include #include - namespace glo_tests { namespace @@ -112,6 +130,26 @@ namespace glo_tests std::forward(args)...); } + namespace + { + template + constexpr + inline + T&& forward(std::remove_reference_t& x) [[hc]] + { + return static_cast(x); + } + + template + struct Forwarder { + template + void operator()(Ts&&...args) const [[hc]] + { + k(forward(args)...); + } + }; + } + template requires(Domain == {Ts...}) static @@ -124,14 +162,13 @@ namespace glo_tests hipStream_t stream, Ts&&... args) { - grid_launch( + grid_launch_impl( + New_grid_launch_tag{}, std::move(num_blocks), std::move(dim_blocks), group_mem_bytes, std::move(stream), - [](decltype(std::decay_t(args))... f_args) [[hc]] { - k(f_args...); - }, + Forwarder{}, std::forward(args)...); } @@ -177,26 +214,116 @@ namespace glo_tests std::forward(args)...); } - template struct Wrapper; + namespace + { + template struct Wrapper; - template - struct Wrapper::value>> { - template - requires(Domain == {Ts...}) - void operator()(Ts&&... args) const - { - grid_launch_impl( - is_new_grid_launch_t{}, - std::forward(args)...); + template + struct Wrapper::value>> { + template + requires(Domain == {Ts...}) + void operator()(Ts&&... args) const + { + grid_launch(std::forward(args)...); + } + }; + + template + struct Wrapper::value>> { + template + void operator()(Ts&&...) const {} + }; + } + + #define make_lambda_wrapper9(kernel_name, p0, p1, p2, p3, p4, p5, p6, p7) \ + []( \ + std::decay_t _p0_, \ + std::decay_t _p1_, \ + std::decay_t _p2_, \ + std::decay_t _p3_, \ + std::decay_t _p4_, \ + std::decay_t _p5_, \ + std::decay_t _p6_, \ + std::decay_t _p7_) [[hc]] { \ + kernel_name(_p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_); \ } - }; + #define make_lambda_wrapper8(kernel_name, p0, p1, p2, p3, p4, p5, p6) \ + []( \ + std::decay_t _p0_, \ + std::decay_t _p1_, \ + std::decay_t _p2_, \ + std::decay_t _p3_, \ + std::decay_t _p4_, \ + std::decay_t _p5_, \ + std::decay_t _p6_) [[hc]] { \ + kernel_name(_p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_); \ + } + #define make_lambda_wrapper7(kernel_name, p0, p1, p2, p3, p4, p5) \ + []( \ + std::decay_t _p0_, \ + std::decay_t _p1_, \ + std::decay_t _p2_, \ + std::decay_t _p3_, \ + std::decay_t _p4_, \ + std::decay_t _p5_) [[hc]] { \ + kernel_name(_p0_, _p1_, _p2_, _p3_, _p4_, _p5_); \ + } + #define make_lambda_wrapper6(kernel_name, p0, p1, p2, p3, p4) \ + []( \ + std::decay_t _p0_, \ + std::decay_t _p1_, \ + std::decay_t _p2_, \ + std::decay_t _p3_, \ + std::decay_t _p4_) [[hc]] { \ + kernel_name(_p0_, _p1_, _p2_, _p3_, _p4_); \ + } + #define make_lambda_wrapper5(kernel_name, p0, p1, p2, p3) \ + [](std::decay_t _p0_, \ + std::decay_t _p1_, \ + std::decay_t _p2_, \ + std::decay_t _p3_) [[hc]] { \ + kernel_name(_p0_, _p1_, _p2_, _p3_); \ + } + #define make_lambda_wrapper4(kernel_name, p0, p1, p2) \ + []( \ + std::decay_t _p0_, \ + std::decay_t _p1_, \ + std::decay_t _p2_) [[hc]] { \ + kernel_name(_p0_, _p1_, _p2_); \ + } + #define make_lambda_wrapper3(kernel_name, p0, p1) \ + []( \ + std::decay_t _p0_, \ + std::decay_t _p1_) [[hc]] { \ + kernel_name(_p0_, _p1_); \ + } + #define make_lambda_wrapper2(kernel_name, p0) \ + [](std::decay_t _p0_) [[hc]] { \ + kernel_name(_p0_); \ + } + #define make_lambda_wrapper1(kernel_name) \ + []() [[hc]] { kernel_name(lp); } - template - struct Wrapper::value>> { - template - void operator()(Ts&&...) const {} - }; -//#warning "GGL hipLaunchKernel defined" + #define make_lambda_wrapper(...) \ + overload_macro(make_lambda_wrapper, __VA_ARGS__) + + #define hipLaunchKernelV3( \ + kernel_name, \ + num_blocks, \ + dim_blocks, \ + group_mem_bytes, \ + stream, \ + ...) \ + { \ + glo_tests::grid_launch( \ + num_blocks, \ + dim_blocks, \ + group_mem_bytes, \ + stream, \ + make_lambda_wrapper(kernel_name, __VA_ARGS__), \ + ##__VA_ARGS__); \ + } +#warning "GGL hipLaunchKernel Reached" #define hipLaunchKernel( \ kernel_name, \ num_blocks, \ @@ -205,23 +332,13 @@ namespace glo_tests stream, \ ...) \ { \ - using F = decltype(kernel_name); \ - if (!std::is_function::value) { \ - glo_tests::Wrapper{}( \ - num_blocks, \ - dim_blocks, \ - group_mem_bytes, \ - stream, \ - kernel_name, \ - ##__VA_ARGS__); \ - } \ - else { \ - glo_tests::grid_launch( \ - num_blocks, \ - dim_blocks, \ - group_mem_bytes, \ - stream, \ - ##__VA_ARGS__); \ - } \ + hipLaunchKernelV3( \ + kernel_name, \ + num_blocks, \ + dim_blocks, \ + group_mem_bytes, \ + stream, \ + hipLaunchParm{}, \ + ##__VA_ARGS__); \ } } diff --git a/projects/hip/include/hip/hcc_detail/helpers.hpp b/projects/hip/include/hip/hcc_detail/helpers.hpp index ca3864911f..ea9217977b 100644 --- a/projects/hip/include/hip/hcc_detail/helpers.hpp +++ b/projects/hip/include/hip/hcc_detail/helpers.hpp @@ -1,3 +1,25 @@ +/* +Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + // // Created by alexv on 08/11/16. // @@ -22,7 +44,8 @@ namespace std using decay_t = typename decay::type; template using result_of_t = typename result_of::type; - + template + using remove_reference_t = typename remove_reference::type; template< FunctionalProcedure F, unsigned int n = 0u, @@ -92,5 +115,26 @@ namespace std template struct is_callable : is_callable_impl {}; #endif + template + struct disjunction : false_type {}; + template + struct disjunction : B1 {}; + template + struct disjunction + : conditional_t> + {}; #endif } + +namespace glo_tests // Only for documentation, macros ignore namespaces. +{ + #define count_macro_args_impl(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _n, ...) _n + #define count_macro_args(...) \ + count_macro_args_impl(,##__VA_ARGS__, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) + + #define overloaded_macro_expand(macro, arg_cnt) macro##arg_cnt + #define overload_macro_impl(macro, arg_cnt) \ + overloaded_macro_expand(macro, arg_cnt) + #define overload_macro(macro, ...) \ + overload_macro_impl(macro, count_macro_args(__VA_ARGS__)) (__VA_ARGS__) +} From c5b6222d62e3fb4979093e47b252e14d08fa64e4 Mon Sep 17 00:00:00 2001 From: "Sun, Peng" Date: Mon, 20 Mar 2017 17:03:21 -0500 Subject: [PATCH 234/281] revert workaround for square sample and update doc on GGL Change-Id: I731c68ca4111e7dc2e45bef51c4cad2c23fc81f8 [ROCm/hip commit: 329e2182d6e1f05ae4fe292c164ee4599bb764b8] --- projects/hip/docs/markdown/hip_faq.md | 8 +------- projects/hip/include/hip/hcc_detail/grid_launch_v2.hpp | 1 - projects/hip/include/hip/hcc_detail/hip_runtime_api.h | 2 +- projects/hip/include/hip/hcc_detail/host_defines.h | 2 +- projects/hip/samples/0_Intro/square/square.hipref.cpp | 2 +- 5 files changed, 4 insertions(+), 11 deletions(-) diff --git a/projects/hip/docs/markdown/hip_faq.md b/projects/hip/docs/markdown/hip_faq.md index 01b05ed223..5ad8d9e8a9 100644 --- a/projects/hip/docs/markdown/hip_faq.md +++ b/projects/hip/docs/markdown/hip_faq.md @@ -243,10 +243,4 @@ $HIP/include/hip/hcc_detail/hip_runtime_api.h $HIP/include/hip/hcc_detail/host_defines.h Or pass "-DGENERIC_GRID_LAUNCH=1" to hipcc at application compilation time. -There are some limitation/assumptions of GGL implementation right now: -1. GGL was only tested with Ubuntu16.04, assuming HCC and HIP only link against libstdc++ but not libc++. -2. GGL currently requires templated kernel fucntions passed to hipLaunchKernel to be specialized. e.g.: - -``` -hipLaunchKernel(vector_square, dim3(blocks), dim3(threadsPerBlock), 0, nullptr, C_d, A_d, N); -``` +GGL was only tested with Ubuntu16.04, assuming HCC and HIP only link against libstdc++ but not libc++. diff --git a/projects/hip/include/hip/hcc_detail/grid_launch_v2.hpp b/projects/hip/include/hip/hcc_detail/grid_launch_v2.hpp index 02f214bd67..9ce0722496 100644 --- a/projects/hip/include/hip/hcc_detail/grid_launch_v2.hpp +++ b/projects/hip/include/hip/hcc_detail/grid_launch_v2.hpp @@ -323,7 +323,6 @@ namespace glo_tests make_lambda_wrapper(kernel_name, __VA_ARGS__), \ ##__VA_ARGS__); \ } -#warning "GGL hipLaunchKernel Reached" #define hipLaunchKernel( \ kernel_name, \ num_blocks, \ diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h index 01fea548b8..2ff4a70802 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h @@ -32,7 +32,7 @@ THE SOFTWARE. #include #ifndef GENERIC_GRID_LAUNCH -#define GENERIC_GRID_LAUNCH 0 +#define GENERIC_GRID_LAUNCH 0 #endif #include diff --git a/projects/hip/include/hip/hcc_detail/host_defines.h b/projects/hip/include/hip/hcc_detail/host_defines.h index 6804ba464b..28c9268f59 100644 --- a/projects/hip/include/hip/hcc_detail/host_defines.h +++ b/projects/hip/include/hip/hcc_detail/host_defines.h @@ -32,7 +32,7 @@ THE SOFTWARE. // Add guard to Generic Grid Launch method #ifndef GENERIC_GRID_LAUNCH -#define GENERIC_GRID_LAUNCH 0 +#define GENERIC_GRID_LAUNCH 0 #endif #ifdef __HCC__ diff --git a/projects/hip/samples/0_Intro/square/square.hipref.cpp b/projects/hip/samples/0_Intro/square/square.hipref.cpp index 118f8acf13..963ab63260 100644 --- a/projects/hip/samples/0_Intro/square/square.hipref.cpp +++ b/projects/hip/samples/0_Intro/square/square.hipref.cpp @@ -83,7 +83,7 @@ int main(int argc, char *argv[]) const unsigned threadsPerBlock = 256; printf ("info: launch 'vector_square' kernel\n"); - hipLaunchKernel(vector_square, dim3(blocks), dim3(threadsPerBlock), 0, nullptr, C_d, A_d, N); + hipLaunchKernel(vector_square, dim3(blocks), dim3(threadsPerBlock), 0, nullptr, C_d, A_d, N); printf ("info: copy Device2Host\n"); CHECK ( hipMemcpy(C_h, C_d, Nbytes, hipMemcpyDeviceToHost)); From c539990ee53f5bfcb98c07bab3685a558d9f49d0 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Tue, 21 Mar 2017 21:01:05 +0300 Subject: [PATCH 235/281] [HIPIFY] Switch building from gcc to clang 3.8. [ROCm/hip commit: 116a5de98ead02c335adc8ca14678a13b9aaf4b3] --- projects/hip/hipify-clang/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/projects/hip/hipify-clang/CMakeLists.txt b/projects/hip/hipify-clang/CMakeLists.txt index 14dc9c5d17..a02b91407f 100644 --- a/projects/hip/hipify-clang/CMakeLists.txt +++ b/projects/hip/hipify-clang/CMakeLists.txt @@ -19,6 +19,9 @@ else() add_llvm_executable(hipify-clang src/Cuda2Hip.cpp) find_program(LIT_COMMAND lit) + set(CMAKE_CXX_COMPILER ${LLVM_TOOLS_BINARY_DIR}/clang++) + set(CMAKE_C_COMPILER ${LLVM_TOOLS_BINARY_DIR}/clang) + # Link against LLVM and CLANG tools libraries target_link_libraries(hipify-clang clangASTMatchers From aa59d4d5801fc114ac86a17105c1735169d7688a Mon Sep 17 00:00:00 2001 From: Rahul Garg Date: Tue, 21 Mar 2017 23:48:04 +0530 Subject: [PATCH 236/281] Fix for hipMemcpyFromSymbol (sync) Change-Id: I66afec5443ce904a63ced1fafece5144ca59393e [ROCm/hip commit: 4395582810a594d3314ab99ffe05ccb2aa3d11de] --- projects/hip/src/hip_hcc.cpp | 10 +++++----- projects/hip/src/hip_hcc.h | 2 +- projects/hip/src/hip_memory.cpp | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/projects/hip/src/hip_hcc.cpp b/projects/hip/src/hip_hcc.cpp index 4d922e65e7..17cffbc013 100644 --- a/projects/hip/src/hip_hcc.cpp +++ b/projects/hip/src/hip_hcc.cpp @@ -1872,19 +1872,19 @@ void ihipStream_t::addSymbolPtrToTracker(hc::accelerator& acc, void* ptr, size_t hc::am_memtracker_add(ptr, ptrInfo); } -void ihipStream_t::lockedSymbolCopySync(hc::accelerator &acc, void* dst, void* src, size_t sizeBytes, unsigned kind) +void ihipStream_t::lockedSymbolCopySync(hc::accelerator &acc, void* dst, void* src, size_t sizeBytes, size_t offset, unsigned kind) { if(kind == hipMemcpyHostToHost){ - acc.memcpy_symbol(dst, (void*)src, sizeBytes, Kalmar::hcMemcpyHostToHost); + acc.memcpy_symbol(dst, (void*)src, sizeBytes, offset, Kalmar::hcMemcpyHostToHost); } if(kind == hipMemcpyHostToDevice){ - acc.memcpy_symbol(dst, (void*)src, sizeBytes); + acc.memcpy_symbol(dst, (void*)src, sizeBytes, offset); } if(kind == hipMemcpyDeviceToDevice){ - acc.memcpy_symbol(dst, (void*)src, sizeBytes, Kalmar::hcMemcpyDeviceToDevice); + acc.memcpy_symbol(dst, (void*)src, sizeBytes, offset, Kalmar::hcMemcpyDeviceToDevice); } if(kind == hipMemcpyDeviceToHost){ - acc.memcpy_symbol(dst, (void*)src, sizeBytes, Kalmar::hcMemcpyDeviceToHost); + acc.memcpy_symbol((void*) src, (void*)dst, sizeBytes, offset, Kalmar::hcMemcpyDeviceToHost); } } diff --git a/projects/hip/src/hip_hcc.h b/projects/hip/src/hip_hcc.h index b23aead072..1c287bfc44 100644 --- a/projects/hip/src/hip_hcc.h +++ b/projects/hip/src/hip_hcc.h @@ -503,7 +503,7 @@ public: void locked_copySync (void* dst, const void* src, size_t sizeBytes, unsigned kind, bool resolveOn = true); void locked_copyAsync(void* dst, const void* src, size_t sizeBytes, unsigned kind); - void lockedSymbolCopySync(hc::accelerator &acc, void *dst, void* src, size_t sizeBytes, unsigned kind); + void lockedSymbolCopySync(hc::accelerator &acc, void *dst, void* src, size_t sizeBytes, size_t offset, unsigned kind); void lockedSymbolCopyAsync(hc::accelerator &acc, void *dst, void* src, size_t sizeBytes, unsigned kind); //--- diff --git a/projects/hip/src/hip_memory.cpp b/projects/hip/src/hip_memory.cpp index a92d11b847..b888c5054c 100644 --- a/projects/hip/src/hip_memory.cpp +++ b/projects/hip/src/hip_memory.cpp @@ -497,7 +497,7 @@ hipError_t hipMemcpyToSymbol(const char* symbolName, const void *src, size_t cou if(kind == hipMemcpyHostToDevice || kind == hipMemcpyDeviceToHost || kind == hipMemcpyDeviceToDevice || kind == hipMemcpyHostToHost) { - stream->lockedSymbolCopySync(acc, dst, (void*)src, count + offset, kind); + stream->lockedSymbolCopySync(acc, dst, (void*)src, count, offset, kind); // acc.memcpy_symbol(dst, (void*)src, count+offset); } else { return ihipLogStatus(hipErrorInvalidValue); @@ -532,7 +532,7 @@ hipError_t hipMemcpyFromSymbol(void* dst, const char* symbolName, size_t count, if(kind == hipMemcpyHostToDevice || kind == hipMemcpyDeviceToHost || kind == hipMemcpyDeviceToDevice || kind == hipMemcpyHostToHost) { - stream->lockedSymbolCopySync(acc, dst, (void*)src, count + offset, kind); + stream->lockedSymbolCopySync(acc, dst, (void*)src, count, offset, kind); } else { return ihipLogStatus(hipErrorInvalidValue); From b5e95a834e930c509348f84d7d7ccde16e79db72 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Tue, 21 Mar 2017 14:22:49 -0500 Subject: [PATCH 237/281] fixed paths to find llvm Change-Id: I0a4af8cea2f44fea011d09fc300e382984746d17 [ROCm/hip commit: 9d7bfbc14b2b59a5c59bab3ce33bf1721109b711] --- projects/hip/CMakeLists.txt | 11 ++--------- projects/hip/bin/hipcc | 2 +- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/projects/hip/CMakeLists.txt b/projects/hip/CMakeLists.txt index a1887d0cb5..93f36d97f1 100644 --- a/projects/hip/CMakeLists.txt +++ b/projects/hip/CMakeLists.txt @@ -63,14 +63,7 @@ if(HIP_PLATFORM STREQUAL "hcc") set(HCC_HOME $ENV{HCC_HOME} CACHE PATH "Path to which HCC has been installed") endif() endif() - # Determine LLVM_HOME - if(NOT DEFINED LLVM_HOME) - if(NOT DEFINED ENV{LLVM_HOME}) - set(LLVM_HOME "/opt/rocm/llvm" CACHE PATH "Path to which LLVM has been installed") - else() - set(LLVM_HOME $ENV{LLVM_HOME} CACHE PATH "Path to which LLVM has been installed") - endif() - endif() + if(DEFINED ENV{HIP_DEVELOPER}) add_to_config(_buildInfo HCC_HOME) endif() @@ -197,7 +190,7 @@ if(HIP_PLATFORM STREQUAL "hcc") execute_process(COMMAND ${HCC_HOME}/bin/hcc-config --ldflags OUTPUT_VARIABLE HCC_LD_FLAGS) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${HCC_LD_FLAGS} -Wl,-Bsymbolic") - find_package(LLVM HINTS ${LLVM_HOME}) + find_package(LLVM HINTS "/opt/rocm/llvm") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --amdgpu-target=gfx701 --amdgpu-target=gfx801 --amdgpu-target=gfx802 --amdgpu-target=gfx803 --amdgpu-target=gfx900") add_library(hip_hcc SHARED ${SOURCE_FILES_RUNTIME}) target_link_libraries(hip_hcc PRIVATE hc_am) diff --git a/projects/hip/bin/hipcc b/projects/hip/bin/hipcc index 4c71347cf7..e99be07ffd 100755 --- a/projects/hip/bin/hipcc +++ b/projects/hip/bin/hipcc @@ -103,7 +103,7 @@ if ($HIP_PLATFORM eq "hcc") { $HIPLDFLAGS = `${HCC_HOME}/bin/hcc-config --ldflags`; - $LLVM_HOME = $ENV{'LLVM_HOME'}; + $LLVM_HOME = "/opt/rocm/llvm"; #### GCC system includes workaround #### $HCC_WA_FLAGS = " "; From 38feccc1d2fca4522578039fea7ff3e4201f5418 Mon Sep 17 00:00:00 2001 From: "Sun, Peng" Date: Tue, 21 Mar 2017 12:26:57 -0500 Subject: [PATCH 238/281] Update GGL implementation to extended overload set for make_lambda_wrapper Change-Id: I949f113671ddf155db8689e8a7f23d415839a7b5 [ROCm/hip commit: ec04521617e7d0ee17c69f019edd80f4c737dbd7] --- .../include/hip/hcc_detail/grid_launch_v2.hpp | 332 ++++++++++++++++-- .../hip/include/hip/hcc_detail/helpers.hpp | 9 +- .../hip/include/hip/hcc_detail/hip_runtime.h | 2 +- 3 files changed, 310 insertions(+), 33 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/grid_launch_v2.hpp b/projects/hip/include/hip/hcc_detail/grid_launch_v2.hpp index 9ce0722496..b1134ee9cc 100644 --- a/projects/hip/include/hip/hcc_detail/grid_launch_v2.hpp +++ b/projects/hip/include/hip/hcc_detail/grid_launch_v2.hpp @@ -235,7 +235,248 @@ namespace glo_tests }; } - #define make_lambda_wrapper9(kernel_name, p0, p1, p2, p3, p4, p5, p6, p7) \ + // TODO: these are temporary, they need to be uglified and them completely + // removed once we enable C++14 support and can have proper generic, + // variadic lambdas. + #define make_lambda_wrapper21( \ + kernel_name, \ + p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, \ + p16, p17, p18, p19) \ + []( \ + std::decay_t _p0_, \ + std::decay_t _p1_, \ + std::decay_t _p2_, \ + std::decay_t _p3_, \ + std::decay_t _p4_, \ + std::decay_t _p5_, \ + std::decay_t _p6_, \ + std::decay_t _p7_, \ + std::decay_t _p8_, \ + std::decay_t _p9_, \ + std::decay_t _p10_, \ + std::decay_t _p11_, \ + std::decay_t _p12_, \ + std::decay_t _p13_, \ + std::decay_t _p14_, \ + std::decay_t _p15_, \ + std::decay_t _p16_, \ + std::decay_t _p17_, \ + std::decay_t _p18_, \ + std::decay_t _p19_) [[hc]] { \ + kernel_name( \ + _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_, \ + _p9_, _p10_, _p11_, _p12_, _p13_, _p14_, _p15_, _p16_, _p17_, \ + _p18_, _p19_); \ + } + #define make_lambda_wrapper20( \ + kernel_name, \ + p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, \ + p16, p17, p18) \ + []( \ + std::decay_t _p0_, \ + std::decay_t _p1_, \ + std::decay_t _p2_, \ + std::decay_t _p3_, \ + std::decay_t _p4_, \ + std::decay_t _p5_, \ + std::decay_t _p6_, \ + std::decay_t _p7_, \ + std::decay_t _p8_, \ + std::decay_t _p9_, \ + std::decay_t _p10_, \ + std::decay_t _p11_, \ + std::decay_t _p12_, \ + std::decay_t _p13_, \ + std::decay_t _p14_, \ + std::decay_t _p15_, \ + std::decay_t _p16_, \ + std::decay_t _p17_, \ + std::decay_t _p18_) [[hc]] { \ + kernel_name( \ + _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_, \ + _p9_, _p10_, _p11_, _p12_, _p13_, _p14_, _p15_, _p16_, _p17_, \ + _p18_); \ + } + #define make_lambda_wrapper19( \ + kernel_name, \ + p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, \ + p16, p17) \ + []( \ + std::decay_t _p0_, \ + std::decay_t _p1_, \ + std::decay_t _p2_, \ + std::decay_t _p3_, \ + std::decay_t _p4_, \ + std::decay_t _p5_, \ + std::decay_t _p6_, \ + std::decay_t _p7_, \ + std::decay_t _p8_, \ + std::decay_t _p9_, \ + std::decay_t _p10_, \ + std::decay_t _p11_, \ + std::decay_t _p12_, \ + std::decay_t _p13_, \ + std::decay_t _p14_, \ + std::decay_t _p15_, \ + std::decay_t _p16_, \ + std::decay_t _p17_) [[hc]] { \ + kernel_name( \ + _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_, \ + _p9_, _p10_, _p11_, _p12_, _p13_, _p14_, _p15_, _p16_, _p17_); \ + } + #define make_lambda_wrapper18( \ + kernel_name, \ + p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, \ + p16) \ + []( \ + std::decay_t _p0_, \ + std::decay_t _p1_, \ + std::decay_t _p2_, \ + std::decay_t _p3_, \ + std::decay_t _p4_, \ + std::decay_t _p5_, \ + std::decay_t _p6_, \ + std::decay_t _p7_, \ + std::decay_t _p8_, \ + std::decay_t _p9_, \ + std::decay_t _p10_, \ + std::decay_t _p11_, \ + std::decay_t _p12_, \ + std::decay_t _p13_, \ + std::decay_t _p14_, \ + std::decay_t _p15_, \ + std::decay_t _p16_) [[hc]] { \ + kernel_name( \ + _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_, \ + _p9_, _p10_, _p11_, _p12_, _p13_, _p14_, _p15_, _p16_); \ + } + #define make_lambda_wrapper17( \ + kernel_name, \ + p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15) \ + []( \ + std::decay_t _p0_, \ + std::decay_t _p1_, \ + std::decay_t _p2_, \ + std::decay_t _p3_, \ + std::decay_t _p4_, \ + std::decay_t _p5_, \ + std::decay_t _p6_, \ + std::decay_t _p7_, \ + std::decay_t _p8_, \ + std::decay_t _p9_, \ + std::decay_t _p10_, \ + std::decay_t _p11_, \ + std::decay_t _p12_, \ + std::decay_t _p13_, \ + std::decay_t _p14_, \ + std::decay_t _p15_) [[hc]] { \ + kernel_name( \ + _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_, \ + _p9_, _p10_, _p11_, _p12_, _p13_, _p14_, _p15_); \ + } + #define make_lambda_wrapper16( \ + kernel_name, \ + p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14) \ + []( \ + std::decay_t _p0_, \ + std::decay_t _p1_, \ + std::decay_t _p2_, \ + std::decay_t _p3_, \ + std::decay_t _p4_, \ + std::decay_t _p5_, \ + std::decay_t _p6_, \ + std::decay_t _p7_, \ + std::decay_t _p8_, \ + std::decay_t _p9_, \ + std::decay_t _p10_, \ + std::decay_t _p11_, \ + std::decay_t _p12_, \ + std::decay_t _p13_, \ + std::decay_t _p14_) [[hc]] { \ + kernel_name( \ + _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_, \ + _p9_, _p10_, _p11_, _p12_, _p13_, _p14_); \ + } + #define make_lambda_wrapper15( \ + kernel_name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13)\ + []( \ + std::decay_t _p0_, \ + std::decay_t _p1_, \ + std::decay_t _p2_, \ + std::decay_t _p3_, \ + std::decay_t _p4_, \ + std::decay_t _p5_, \ + std::decay_t _p6_, \ + std::decay_t _p7_, \ + std::decay_t _p8_, \ + std::decay_t _p9_, \ + std::decay_t _p10_, \ + std::decay_t _p11_, \ + std::decay_t _p12_, \ + std::decay_t _p13_) [[hc]] { \ + kernel_name( \ + _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_, \ + _p9_, _p10_, _p11_, _p12_, _p13_); \ + } + #define make_lambda_wrapper14( \ + kernel_name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12) \ + []( \ + std::decay_t _p0_, \ + std::decay_t _p1_, \ + std::decay_t _p2_, \ + std::decay_t _p3_, \ + std::decay_t _p4_, \ + std::decay_t _p5_, \ + std::decay_t _p6_, \ + std::decay_t _p7_, \ + std::decay_t _p8_, \ + std::decay_t _p9_, \ + std::decay_t _p10_, \ + std::decay_t _p11_, \ + std::decay_t _p12_) [[hc]] { \ + kernel_name( \ + _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_, \ + _p9_, _p10_, _p11_, _p12_); \ + } + #define make_lambda_wrapper13( \ + kernel_name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11) \ + []( \ + std::decay_t _p0_, \ + std::decay_t _p1_, \ + std::decay_t _p2_, \ + std::decay_t _p3_, \ + std::decay_t _p4_, \ + std::decay_t _p5_, \ + std::decay_t _p6_, \ + std::decay_t _p7_, \ + std::decay_t _p8_, \ + std::decay_t _p9_, \ + std::decay_t _p10_, \ + std::decay_t _p11_) [[hc]] { \ + kernel_name( \ + _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_, \ + _p9_, _p10_, _p11_); \ + } + #define make_lambda_wrapper12( \ + kernel_name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) \ + []( \ + std::decay_t _p0_, \ + std::decay_t _p1_, \ + std::decay_t _p2_, \ + std::decay_t _p3_, \ + std::decay_t _p4_, \ + std::decay_t _p5_, \ + std::decay_t _p6_, \ + std::decay_t _p7_, \ + std::decay_t _p8_, \ + std::decay_t _p9_, \ + std::decay_t _p10_) [[hc]] { \ + kernel_name( \ + _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_, _p9_, \ + _p10_); \ + } + #define make_lambda_wrapper11( \ + kernel_name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9) \ []( \ std::decay_t _p0_, \ std::decay_t _p1_, \ @@ -244,57 +485,87 @@ namespace glo_tests std::decay_t _p4_, \ std::decay_t _p5_, \ std::decay_t _p6_, \ - std::decay_t _p7_) [[hc]] { \ + std::decay_t _p7_, \ + std::decay_t _p8_, \ + std::decay_t _p9_) [[hc]] { \ + kernel_name( \ + _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_, _p9_); \ + } + #define make_lambda_wrapper10( \ + kernel_name, p0, p1, p2, p3, p4, p5, p6, p7, p8) \ + []( \ + std::decay_t _p0_, \ + std::decay_t _p1_, \ + std::decay_t _p2_, \ + std::decay_t _p3_, \ + std::decay_t _p4_, \ + std::decay_t _p5_, \ + std::decay_t _p6_, \ + std::decay_t _p7_, \ + std::decay_t _p8_) [[hc]] { \ + kernel_name(_p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_); \ + } + #define make_lambda_wrapper9(kernel_name, p0, p1, p2, p3, p4, p5, p6, p7) \ + []( \ + std::decay_t _p0_, \ + std::decay_t _p1_, \ + std::decay_t _p2_, \ + std::decay_t _p3_, \ + std::decay_t _p4_, \ + std::decay_t _p5_, \ + std::decay_t _p6_, \ + std::decay_t _p7_) [[hc]] { \ kernel_name(_p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_); \ } #define make_lambda_wrapper8(kernel_name, p0, p1, p2, p3, p4, p5, p6) \ []( \ - std::decay_t _p0_, \ - std::decay_t _p1_, \ - std::decay_t _p2_, \ - std::decay_t _p3_, \ - std::decay_t _p4_, \ - std::decay_t _p5_, \ - std::decay_t _p6_) [[hc]] { \ + std::decay_t _p0_, \ + std::decay_t _p1_, \ + std::decay_t _p2_, \ + std::decay_t _p3_, \ + std::decay_t _p4_, \ + std::decay_t _p5_, \ + std::decay_t _p6_) [[hc]] { \ kernel_name(_p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_); \ } #define make_lambda_wrapper7(kernel_name, p0, p1, p2, p3, p4, p5) \ []( \ - std::decay_t _p0_, \ - std::decay_t _p1_, \ - std::decay_t _p2_, \ - std::decay_t _p3_, \ - std::decay_t _p4_, \ - std::decay_t _p5_) [[hc]] { \ + std::decay_t _p0_, \ + std::decay_t _p1_, \ + std::decay_t _p2_, \ + std::decay_t _p3_, \ + std::decay_t _p4_, \ + std::decay_t _p5_) [[hc]] { \ kernel_name(_p0_, _p1_, _p2_, _p3_, _p4_, _p5_); \ } #define make_lambda_wrapper6(kernel_name, p0, p1, p2, p3, p4) \ []( \ - std::decay_t _p0_, \ - std::decay_t _p1_, \ - std::decay_t _p2_, \ - std::decay_t _p3_, \ - std::decay_t _p4_) [[hc]] { \ + std::decay_t _p0_, \ + std::decay_t _p1_, \ + std::decay_t _p2_, \ + std::decay_t _p3_, \ + std::decay_t _p4_) [[hc]] { \ kernel_name(_p0_, _p1_, _p2_, _p3_, _p4_); \ } #define make_lambda_wrapper5(kernel_name, p0, p1, p2, p3) \ - [](std::decay_t _p0_, \ - std::decay_t _p1_, \ - std::decay_t _p2_, \ - std::decay_t _p3_) [[hc]] { \ + []( \ + std::decay_t _p0_, \ + std::decay_t _p1_, \ + std::decay_t _p2_, \ + std::decay_t _p3_) [[hc]] { \ kernel_name(_p0_, _p1_, _p2_, _p3_); \ } #define make_lambda_wrapper4(kernel_name, p0, p1, p2) \ []( \ - std::decay_t _p0_, \ - std::decay_t _p1_, \ - std::decay_t _p2_) [[hc]] { \ + std::decay_t _p0_, \ + std::decay_t _p1_, \ + std::decay_t _p2_) [[hc]] { \ kernel_name(_p0_, _p1_, _p2_); \ } #define make_lambda_wrapper3(kernel_name, p0, p1) \ []( \ - std::decay_t _p0_, \ - std::decay_t _p1_) [[hc]] { \ + std::decay_t _p0_, \ + std::decay_t _p1_) [[hc]] { \ kernel_name(_p0_, _p1_); \ } #define make_lambda_wrapper2(kernel_name, p0) \ @@ -323,7 +594,8 @@ namespace glo_tests make_lambda_wrapper(kernel_name, __VA_ARGS__), \ ##__VA_ARGS__); \ } - #define hipLaunchKernel( \ + + #define hipLaunchKernelV2( \ kernel_name, \ num_blocks, \ dim_blocks, \ diff --git a/projects/hip/include/hip/hcc_detail/helpers.hpp b/projects/hip/include/hip/hcc_detail/helpers.hpp index ea9217977b..301d740066 100644 --- a/projects/hip/include/hip/hcc_detail/helpers.hpp +++ b/projects/hip/include/hip/hcc_detail/helpers.hpp @@ -128,9 +128,14 @@ namespace std namespace glo_tests // Only for documentation, macros ignore namespaces. { - #define count_macro_args_impl(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _n, ...) _n + #define count_macro_args_impl( \ + _0, _1, _2, _3, _4, _5, _6, _7, \ + _8, _9, _10, _11, _12, _13, _14, _15, \ + _16, _17, _18, _19, _20, _21, _n, ...) _n #define count_macro_args(...) \ - count_macro_args_impl(,##__VA_ARGS__, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) + count_macro_args_impl( \ + , ##__VA_ARGS__, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9,\ + 8, 7, 6, 5, 4, 3, 2, 1, 0) #define overloaded_macro_expand(macro, arg_cnt) macro##arg_cnt #define overload_macro_impl(macro, arg_cnt) \ diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime.h b/projects/hip/include/hip/hcc_detail/hip_runtime.h index 870dcd0b34..590cc33bd1 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime.h @@ -416,7 +416,7 @@ static inline __device__ void* memset(void* ptr, int val, size_t size) #define __syncthreads() hc_barrier(CLK_LOCAL_MEM_FENCE) -#define HIP_KERNEL_NAME(...) __VA_ARGS__ +#define HIP_KERNEL_NAME(...) (__VA_ARGS__) #define HIP_SYMBOL(X) #X #if defined __HCC_CPP__ From 0215445fa0f0b064724728876ca9b93a2861b1be Mon Sep 17 00:00:00 2001 From: "Sun, Peng" Date: Tue, 21 Mar 2017 12:38:40 -0500 Subject: [PATCH 239/281] update GGL implementation to use hipLaunchKernel Change-Id: Ibc08185c814bb07d54f3e68016b10eb7b9f2bf4b [ROCm/hip commit: 91274394dc29fc46056b0e4c90c72ad52efd2508] --- projects/hip/include/hip/hcc_detail/grid_launch_v2.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/hip/include/hip/hcc_detail/grid_launch_v2.hpp b/projects/hip/include/hip/hcc_detail/grid_launch_v2.hpp index b1134ee9cc..c59c69ffd9 100644 --- a/projects/hip/include/hip/hcc_detail/grid_launch_v2.hpp +++ b/projects/hip/include/hip/hcc_detail/grid_launch_v2.hpp @@ -595,7 +595,7 @@ namespace glo_tests ##__VA_ARGS__); \ } - #define hipLaunchKernelV2( \ + #define hipLaunchKernel( \ kernel_name, \ num_blocks, \ dim_blocks, \ From 5d5651771ff0ba4ee24e50d36e026e4c194e19a6 Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Thu, 23 Mar 2017 16:25:53 +0530 Subject: [PATCH 240/281] Mark hcc_LIBRARIES as PRIVATE Change-Id: Ia0f8f12148b69c9de78378d117e3561ce20cd827 [ROCm/hip commit: f1d4756f6ca2ca980a4e9e426d23f84c91df3c4f] --- projects/hip/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/hip/CMakeLists.txt b/projects/hip/CMakeLists.txt index 93f36d97f1..369b6528a6 100644 --- a/projects/hip/CMakeLists.txt +++ b/projects/hip/CMakeLists.txt @@ -205,7 +205,7 @@ if(HIP_PLATFORM STREQUAL "hcc") foreach(TARGET hip_hcc hip_hcc_static hip_device) target_include_directories(${TARGET} SYSTEM INTERFACE $/include>;${HSA_PATH}/include) endforeach() - target_link_libraries(hip_hcc INTERFACE hcc::hccrt;hcc::hc_am) + target_link_libraries(hip_hcc PRIVATE hcc::hccrt;hcc::hc_am) # Generate hcc_version.txt add_custom_target(query_hcc_version COMMAND ${HCC_HOME}/bin/hcc --version > ${PROJECT_BINARY_DIR}/hcc_version.tmp) From e60749f3f0512876c6374d9c8cf24b714bdbdca2 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Thu, 23 Mar 2017 10:16:37 -0500 Subject: [PATCH 241/281] removed llvm dependency and metadata functionality Change-Id: Ib9783b75d326559ed29c5aa2218aed40d20ad0fb [ROCm/hip commit: 4f4a44c736cc285b61ee66558b1f77bd4ac2242b] --- projects/hip/CMakeLists.txt | 4 ++-- projects/hip/bin/hipcc | 2 +- projects/hip/src/hip_module.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/projects/hip/CMakeLists.txt b/projects/hip/CMakeLists.txt index 369b6528a6..cb950fe5b0 100644 --- a/projects/hip/CMakeLists.txt +++ b/projects/hip/CMakeLists.txt @@ -190,11 +190,11 @@ if(HIP_PLATFORM STREQUAL "hcc") execute_process(COMMAND ${HCC_HOME}/bin/hcc-config --ldflags OUTPUT_VARIABLE HCC_LD_FLAGS) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${HCC_LD_FLAGS} -Wl,-Bsymbolic") - find_package(LLVM HINTS "/opt/rocm/llvm") +# find_package(LLVM HINTS "/opt/rocm/llvm") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --amdgpu-target=gfx701 --amdgpu-target=gfx801 --amdgpu-target=gfx802 --amdgpu-target=gfx803 --amdgpu-target=gfx900") add_library(hip_hcc SHARED ${SOURCE_FILES_RUNTIME}) target_link_libraries(hip_hcc PRIVATE hc_am) - target_link_libraries(hip_hcc PUBLIC LLVMAMDGPUUtils) +# target_link_libraries(hip_hcc PUBLIC LLVMAMDGPUUtils) add_library(hip_hcc_static STATIC ${SOURCE_FILES_RUNTIME}) target_link_libraries(hip_hcc_static PRIVATE hc_am) add_dependencies(hip_hcc_static hip_hcc) diff --git a/projects/hip/bin/hipcc b/projects/hip/bin/hipcc index e99be07ffd..34ea6f8a8e 100755 --- a/projects/hip/bin/hipcc +++ b/projects/hip/bin/hipcc @@ -129,7 +129,7 @@ if ($HIP_PLATFORM eq "hcc") { $HIPCXXFLAGS .= " -Wno-deprecated-register"; $HIPLDFLAGS .= " -lsupc++"; - $HIPLDFLAGS .= " -L$HSA_PATH/lib -L$ROCM_PATH/lib -lhsa-runtime64 -lhc_am -lhsakmt `${LLVM_HOME}/bin/llvm-config --ldflags --libs`"; + $HIPLDFLAGS .= " -L$HSA_PATH/lib -L$ROCM_PATH/lib -lhsa-runtime64 -lhc_am -lhsakmt";# `${LLVM_HOME}/bin/llvm-config --ldflags --libs`"; # Add trace marker library: # TODO - once we cleanly separate the HIP API headers from HIP library headers this logic should move to CMakebuild option - apps do not need to see the marker library. diff --git a/projects/hip/src/hip_module.cpp b/projects/hip/src/hip_module.cpp index dc0a681c6d..3bca2090ff 100644 --- a/projects/hip/src/hip_module.cpp +++ b/projects/hip/src/hip_module.cpp @@ -202,7 +202,7 @@ hipError_t hipModuleLoad(hipModule_t *module, const char *fname){ (*module)->size = size; in.seekg(0, std::ios::beg); std::copy(std::istreambuf_iterator(in), std::istreambuf_iterator(), ptr); - +/* Enable for metadata implementation Elf *e = elf_memory((char*)p, size); if(elf_kind(e) != ELF_K_ELF){ return ihipLogStatus(hipErrorInvalidValue); @@ -251,7 +251,7 @@ hipError_t hipModuleLoad(hipModule_t *module, const char *fname){ } } } - +*/ status = hsa_code_object_deserialize(ptr, size, NULL, &(*module)->object); if(status != HSA_STATUS_SUCCESS){ From 2ec42a004a10060a3065b03ead93364e737e2c11 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Thu, 23 Mar 2017 11:08:19 -0500 Subject: [PATCH 242/281] removed LLVM_HOME from hipcc Change-Id: Ic3dfdde9d28f08bf54b12dfc38ab1f25884bcfab [ROCm/hip commit: d99d5f4bbe3f285a701a536fc342a71a51f4c5d7] --- projects/hip/bin/hipcc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/hip/bin/hipcc b/projects/hip/bin/hipcc index 34ea6f8a8e..a08d5c952b 100755 --- a/projects/hip/bin/hipcc +++ b/projects/hip/bin/hipcc @@ -103,7 +103,7 @@ if ($HIP_PLATFORM eq "hcc") { $HIPLDFLAGS = `${HCC_HOME}/bin/hcc-config --ldflags`; - $LLVM_HOME = "/opt/rocm/llvm"; +# $LLVM_HOME = "/opt/rocm/llvm"; #### GCC system includes workaround #### $HCC_WA_FLAGS = " "; From 0e3798ded450fdc7f72df159d9eb2408039b2950 Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Thu, 23 Mar 2017 22:02:52 +0530 Subject: [PATCH 243/281] Revert "Mark hcc_LIBRARIES as PRIVATE" This reverts commit 5d5651771ff0ba4ee24e50d36e026e4c194e19a6. [ROCm/hip commit: cc433014ec79af709b6b835432b3b3ebf8861128] --- projects/hip/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/hip/CMakeLists.txt b/projects/hip/CMakeLists.txt index cb950fe5b0..16f43d38c5 100644 --- a/projects/hip/CMakeLists.txt +++ b/projects/hip/CMakeLists.txt @@ -205,7 +205,7 @@ if(HIP_PLATFORM STREQUAL "hcc") foreach(TARGET hip_hcc hip_hcc_static hip_device) target_include_directories(${TARGET} SYSTEM INTERFACE $/include>;${HSA_PATH}/include) endforeach() - target_link_libraries(hip_hcc PRIVATE hcc::hccrt;hcc::hc_am) + target_link_libraries(hip_hcc INTERFACE hcc::hccrt;hcc::hc_am) # Generate hcc_version.txt add_custom_target(query_hcc_version COMMAND ${HCC_HOME}/bin/hcc --version > ${PROJECT_BINARY_DIR}/hcc_version.tmp) From 1494cb9339983a230a003a0ffec0b6310b6c976a Mon Sep 17 00:00:00 2001 From: Rahul Garg Date: Fri, 24 Mar 2017 10:30:33 +0530 Subject: [PATCH 244/281] Fix for hipMemcpyFromSymbolAsync Change-Id: I449c669c8f0ef041deaf0a1bc812a71b2f0cc5a6 [ROCm/hip commit: f649c225a75d45910705fd9411371cf1dd9154ab] --- projects/hip/src/hip_hcc.cpp | 26 +++++++++++++++++++++----- projects/hip/src/hip_hcc.h | 2 +- projects/hip/src/hip_memory.cpp | 5 +++-- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/projects/hip/src/hip_hcc.cpp b/projects/hip/src/hip_hcc.cpp index 17cffbc013..e422a6d4db 100644 --- a/projects/hip/src/hip_hcc.cpp +++ b/projects/hip/src/hip_hcc.cpp @@ -1888,15 +1888,31 @@ void ihipStream_t::lockedSymbolCopySync(hc::accelerator &acc, void* dst, void* s } } -void ihipStream_t::lockedSymbolCopyAsync(hc::accelerator &acc, void* dst, void* src, size_t sizeBytes, unsigned kind) +void ihipStream_t::lockedSymbolCopyAsync(hc::accelerator &acc, void* dst, void* src, size_t sizeBytes, size_t offset, unsigned kind) { if(kind == hipMemcpyHostToDevice) { - addSymbolPtrToTracker(acc, dst, sizeBytes); - locked_getAv()->copy_async((void*)src, dst, sizeBytes); + hc::AmPointerInfo srcPtrInfo(NULL, NULL, 0, acc, 0, 0); + bool srcTracked = (hc::am_memtracker_getinfo(&srcPtrInfo, src) == AM_SUCCESS); + if(srcTracked) { + addSymbolPtrToTracker(acc, dst, sizeBytes); + locked_getAv()->copy_async((void*)src, dst, sizeBytes); + } else { + LockedAccessor_StreamCrit_t crit(_criticalData); + this->wait(crit); + acc.memcpy_symbol(dst, (void*)src, sizeBytes, offset); + } } if(kind == hipMemcpyDeviceToHost) { - addSymbolPtrToTracker(acc, src, sizeBytes); - locked_getAv()->copy_async((void*)src, dst, sizeBytes); + hc::AmPointerInfo dstPtrInfo(NULL, NULL, 0, acc, 0, 0); + bool dstTracked = (hc::am_memtracker_getinfo(&dstPtrInfo, dst) == AM_SUCCESS); + if(dstTracked) { + addSymbolPtrToTracker(acc, src, sizeBytes); + locked_getAv()->copy_async((void*)src, dst, sizeBytes); + } else { + LockedAccessor_StreamCrit_t crit(_criticalData); + this->wait(crit); + acc.memcpy_symbol((void*)src, (void*)dst, sizeBytes, offset, Kalmar::hcMemcpyDeviceToHost); + } } } diff --git a/projects/hip/src/hip_hcc.h b/projects/hip/src/hip_hcc.h index 1c287bfc44..245f154305 100644 --- a/projects/hip/src/hip_hcc.h +++ b/projects/hip/src/hip_hcc.h @@ -504,7 +504,7 @@ public: void locked_copyAsync(void* dst, const void* src, size_t sizeBytes, unsigned kind); void lockedSymbolCopySync(hc::accelerator &acc, void *dst, void* src, size_t sizeBytes, size_t offset, unsigned kind); - void lockedSymbolCopyAsync(hc::accelerator &acc, void *dst, void* src, size_t sizeBytes, unsigned kind); + void lockedSymbolCopyAsync(hc::accelerator &acc, void *dst, void* src, size_t sizeBytes, size_t offset, unsigned kind); //--- // Member functions that begin with locked_ are thread-safe accessors - these acquire / release the critical mutex. diff --git a/projects/hip/src/hip_memory.cpp b/projects/hip/src/hip_memory.cpp index b888c5054c..94121838fd 100644 --- a/projects/hip/src/hip_memory.cpp +++ b/projects/hip/src/hip_memory.cpp @@ -567,7 +567,7 @@ hipError_t hipMemcpyToSymbolAsync(const char* symbolName, const void *src, size_ if (stream) { try { - stream->lockedSymbolCopyAsync(acc, dst, (void*)src, count + offset, kind); + stream->lockedSymbolCopyAsync(acc, dst, (void*)src, count, offset, kind); } catch (ihipException ex) { e = ex._code; @@ -603,9 +603,10 @@ hipError_t hipMemcpyFromSymbolAsync(void* dst, const char* symbolName, size_t co return ihipLogStatus(hipErrorInvalidSymbol); } + stream = ihipSyncAndResolveStream(stream); if (stream) { try { - stream->lockedSymbolCopyAsync(acc, dst, src, count + offset, kind); + stream->lockedSymbolCopyAsync(acc, dst, src, count, offset, kind); } catch (ihipException ex) { e = ex._code; From 83ce6f48a960f3b74dc398860ebe2ee147c9b730 Mon Sep 17 00:00:00 2001 From: Rahul Garg Date: Fri, 24 Mar 2017 10:39:11 +0530 Subject: [PATCH 245/281] Update hipTestDeviceSymbol sample Change-Id: If5ba99c60cd30c4491ca3a4856764224163d3ddf [ROCm/hip commit: ec0d334354738cd2edeb0b4d19a8e3e9873fe033] --- .../src/deviceLib/hipTestDeviceSymbol.cpp | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp b/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp index 6ffaedf659..c2ffb5ce7d 100644 --- a/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp +++ b/projects/hip/tests/src/deviceLib/hipTestDeviceSymbol.cpp @@ -93,8 +93,29 @@ int main() hipMemcpyFromSymbol(C, HIP_SYMBOL(globalOut), SIZE, 0, hipMemcpyDeviceToHost); for(unsigned i=0;i Date: Sun, 26 Mar 2017 23:45:54 +0530 Subject: [PATCH 246/281] Added support for Primary Context Management APIs Change-Id: I70f91b4492e112dd8e12ecf511fdc18a27944a06 [ROCm/hip commit: ecc0e14cf75092801550cd328e991a6bfb21db3d] --- .../include/hip/hcc_detail/hip_runtime_api.h | 60 +++++++++++++++ .../include/hip/nvcc_detail/hip_runtime_api.h | 25 ++++++ projects/hip/src/hip_context.cpp | 76 +++++++++++++++++++ 3 files changed, 161 insertions(+) diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h index 2ff4a70802..da94ad5e5e 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h @@ -1696,6 +1696,66 @@ hipError_t hipCtxEnablePeerAccess (hipCtx_t peerCtx, unsigned int flags); */ hipError_t hipCtxDisablePeerAccess (hipCtx_t peerCtx); +/** + * @brief Get the state of the primary context. + * + * @param [in] Device to get primary context flags for + * @param [out] Pointer to store flags + * @param [out] Pointer to store context state; 0 = inactive, 1 = active + * + * @returns #hipSuccess + * + * @see hipCtxCreate, hipCtxDestroy, hipCtxGetFlags, hipCtxPopCurrent, hipCtxGetCurrent, hipCtxSetCurrent, hipCtxPushCurrent, hipCtxSetCacheConfig, hipCtxSynchronize, hipCtxGetDevice + */ +hipError_t hipDevicePrimaryCtxGetState ( hipDevice_t dev, unsigned int* flags, int* active ); + +/** + * @brief Release the primary context on the GPU. + * + * @param [in] Device which primary context is released + * + * @returns #hipSuccess + * + * @see hipCtxCreate, hipCtxDestroy, hipCtxGetFlags, hipCtxPopCurrent, hipCtxGetCurrent, hipCtxSetCurrent, hipCtxPushCurrent, hipCtxSetCacheConfig, hipCtxSynchronize, hipCtxGetDevice + * @warning This function return #hipSuccess though doesn't release the primaryCtx by design on HIP/HCC path. + */ +hipError_t hipDevicePrimaryCtxRelease ( hipDevice_t dev); + +/** + * @brief Retain the primary context on the GPU. + * + * @param [out] Returned context handle of the new context + * @param [in] Device which primary context is released + * + * @returns #hipSuccess + * + * @see hipCtxCreate, hipCtxDestroy, hipCtxGetFlags, hipCtxPopCurrent, hipCtxGetCurrent, hipCtxSetCurrent, hipCtxPushCurrent, hipCtxSetCacheConfig, hipCtxSynchronize, hipCtxGetDevice + */ +hipError_t hipDevicePrimaryCtxRetain ( hipCtx_t* pctx, hipDevice_t dev ); + +/** + * @brief Resets the primary context on the GPU. + * + * @param [in] Device which primary context is reset + * + * @returns #hipSuccess + * + * @see hipCtxCreate, hipCtxDestroy, hipCtxGetFlags, hipCtxPopCurrent, hipCtxGetCurrent, hipCtxSetCurrent, hipCtxPushCurrent, hipCtxSetCacheConfig, hipCtxSynchronize, hipCtxGetDevice + */ +hipError_t hipDevicePrimaryCtxReset ( hipDevice_t dev ); + +/** + * @brief Set flags for the primary context. + * + * @param [in] Device for which the primary context flags are set + * @param [in] New flags for the device + * + * @returns #hipSuccess, #hipErrorContextAlreadyInUse + * + * @see hipCtxCreate, hipCtxDestroy, hipCtxGetFlags, hipCtxPopCurrent, hipCtxGetCurrent, hipCtxSetCurrent, hipCtxPushCurrent, hipCtxSetCacheConfig, hipCtxSynchronize, hipCtxGetDevice + */ +hipError_t hipDevicePrimaryCtxSetFlags ( hipDevice_t dev, unsigned int flags ); + // doxygen end Context Management /** * @} diff --git a/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h b/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h index 8c3e0da639..a9963fdfe3 100644 --- a/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h @@ -670,6 +670,31 @@ inline static hipError_t hipCtxEnablePeerAccess ( hipCtx_t peerCtx, unsigned in return hipCUResultTohipError(cuCtxEnablePeerAccess(peerCtx, flags)); } +inline static hipError_t hipDevicePrimaryCtxGetState ( hipDevice_t dev, unsigned int* flags, int* active ) +{ + return hipCUResultTohipError(cuDevicePrimaryCtxGetState(dev, flags, active)); +} + +inline static hipError_t hipDevicePrimaryCtxRelease ( hipDevice_t dev) +{ + return hipCUResultTohipError(cuDevicePrimaryCtxRelease(dev)); +} + +inline static hipError_t hipDevicePrimaryCtxRetain ( hipCtx_t* pctx, hipDevice_t dev ) +{ + return hipCUResultTohipError(cuDevicePrimaryCtxRetain(pctx, dev)); +} + +inline static hipError_t hipDevicePrimaryCtxReset ( hipDevice_t dev ) +{ + return hipCUResultTohipError(cuDevicePrimaryCtxReset(dev)); +} + +inline static hipError_t hipDevicePrimaryCtxSetFlags ( hipDevice_t dev, unsigned int flags ) +{ + return hipCUResultTohipError(cuDevicePrimaryCtxSetFlags(dev, flags)); +} + inline static hipError_t hipMemGetAddressRange ( hipDeviceptr_t* pbase, size_t* psize, hipDeviceptr_t dptr ) { return hipCUResultTohipError(cuMemGetAddressRange( pbase , psize , dptr)); diff --git a/projects/hip/src/hip_context.cpp b/projects/hip/src/hip_context.cpp index 835cf6e795..4c39abb738 100644 --- a/projects/hip/src/hip_context.cpp +++ b/projects/hip/src/hip_context.cpp @@ -283,3 +283,79 @@ hipError_t hipCtxGetFlags ( unsigned int* flags ) *flags = tempCtx->_ctxFlags; return ihipLogStatus(e); } + +hipError_t hipDevicePrimaryCtxGetState ( hipDevice_t dev, unsigned int* flags, int* active ) +{ + HIP_INIT_API(dev, flags, active); + hipError_t e = hipSuccess; + auto deviceHandle = ihipGetDevice(dev); + + if (deviceHandle == NULL) { + e = hipErrorInvalidDevice; + } + + ihipCtx_t* tempCtx; + tempCtx = ihipGetTlsDefaultCtx(); + ihipCtx_t* primaryCtx = deviceHandle->_primaryCtx; + if(tempCtx == primaryCtx) { + *active = 1; + *flags = tempCtx->_ctxFlags; + } else { + *active = 0; + *flags = primaryCtx->_ctxFlags; + } + return ihipLogStatus(e); +} + +hipError_t hipDevicePrimaryCtxRelease ( hipDevice_t dev) +{ + HIP_INIT_API(dev); + hipError_t e = hipSuccess; + auto deviceHandle = ihipGetDevice(dev); + + if (deviceHandle == NULL) { + e = hipErrorInvalidDevice; + } + return ihipLogStatus(e); +} + +hipError_t hipDevicePrimaryCtxRetain ( hipCtx_t* pctx, hipDevice_t dev ) +{ + HIP_INIT_API(pctx, dev); + hipError_t e = hipSuccess; + auto deviceHandle = ihipGetDevice(dev); + + if (deviceHandle == NULL) { + e = hipErrorInvalidDevice; + } + *pctx = deviceHandle->_primaryCtx; + return ihipLogStatus(e); +} + +hipError_t hipDevicePrimaryCtxReset ( hipDevice_t dev ) +{ + HIP_INIT_API(dev); + hipError_t e = hipSuccess; + auto deviceHandle = ihipGetDevice(dev); + + if (deviceHandle == NULL) { + e = hipErrorInvalidDevice; + } + ihipCtx_t* primaryCtx = deviceHandle->_primaryCtx; + primaryCtx->locked_reset(); + return ihipLogStatus(e); +} + +hipError_t hipDevicePrimaryCtxSetFlags ( hipDevice_t dev, unsigned int flags ) +{ + HIP_INIT_API(dev, flags); + hipError_t e = hipSuccess; + auto deviceHandle = ihipGetDevice(dev); + + if (deviceHandle == NULL) { + e = hipErrorInvalidDevice; + } else { + e = hipErrorContextAlreadyInUse; + } + return ihipLogStatus(e); +} From be8d979d08656c92964876eae0c32cba4faf168c Mon Sep 17 00:00:00 2001 From: Rahul Garg Date: Mon, 27 Mar 2017 00:35:10 +0530 Subject: [PATCH 247/281] Fix for MemcpyFromSymbol on HIP/NVCC path Change-Id: Ice38307f72870ae468cbf0861e104f0fa46dfd56 [ROCm/hip commit: 1d18006ab4661c5505ccbf20794ed4979041ac42] --- .../hip/include/hip/hcc_detail/hip_runtime_api.h | 8 ++++---- .../include/hip/nvcc_detail/hip_runtime_api.h | 10 ++++++++++ projects/hip/src/hip_memory.cpp | 16 ++++++++-------- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h index da94ad5e5e..cba6f01d49 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h @@ -1156,7 +1156,7 @@ hipError_t hipMemcpyDtoDAsync(hipDeviceptr_t dst, hipDeviceptr_t src, size_t siz * * @see hipMemcpy, hipMemcpy2D, hipMemcpyToArray, hipMemcpy2DToArray, hipMemcpyFromArray, hipMemcpy2DFromArray, hipMemcpyArrayToArray, hipMemcpy2DArrayToArray, hipMemcpyFromSymbol, hipMemcpyAsync, hipMemcpy2DAsync, hipMemcpyToArrayAsync, hipMemcpy2DToArrayAsync, hipMemcpyFromArrayAsync, hipMemcpy2DFromArrayAsync, hipMemcpyToSymbolAsync, hipMemcpyFromSymbolAsync */ -hipError_t hipMemcpyToSymbol(const char* symbolName, const void *src, size_t sizeBytes, size_t offset, hipMemcpyKind kind); +hipError_t hipMemcpyToSymbol(const void* symbolName, const void *src, size_t sizeBytes, size_t offset, hipMemcpyKind kind); /** @@ -1176,11 +1176,11 @@ hipError_t hipMemcpyToSymbol(const char* symbolName, const void *src, size_t siz * * @see hipMemcpy, hipMemcpy2D, hipMemcpyToArray, hipMemcpy2DToArray, hipMemcpyFromArray, hipMemcpy2DFromArray, hipMemcpyArrayToArray, hipMemcpy2DArrayToArray, hipMemcpyFromSymbol, hipMemcpyAsync, hipMemcpy2DAsync, hipMemcpyToArrayAsync, hipMemcpy2DToArrayAsync, hipMemcpyFromArrayAsync, hipMemcpy2DFromArrayAsync, hipMemcpyToSymbolAsync, hipMemcpyFromSymbolAsync */ -hipError_t hipMemcpyToSymbolAsync(const char* symbolName, const void *src, size_t sizeBytes, size_t offset, hipMemcpyKind kind, hipStream_t stream); +hipError_t hipMemcpyToSymbolAsync(const void* symbolName, const void *src, size_t sizeBytes, size_t offset, hipMemcpyKind kind, hipStream_t stream); -hipError_t hipMemcpyFromSymbol(void *dst, const char* symbolName, size_t sizeBytes, size_t offset, hipMemcpyKind kind); +hipError_t hipMemcpyFromSymbol(void *dst, const void* symbolName, size_t sizeBytes, size_t offset, hipMemcpyKind kind); -hipError_t hipMemcpyFromSymbolAsync(void *dst, const char* symbolName, size_t sizeBytes, size_t offset, hipMemcpyKind kind, hipStream_t stream); +hipError_t hipMemcpyFromSymbolAsync(void *dst, const void* symbolName, size_t sizeBytes, size_t offset, hipMemcpyKind kind, hipStream_t stream); /** * @brief Copy data from src to dst asynchronously. diff --git a/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h b/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h index a9963fdfe3..758ef064bd 100644 --- a/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h @@ -333,6 +333,16 @@ inline static hipError_t hipMemcpyToSymbolAsync(const void* symbol, const void* return hipCUDAErrorTohipError(cudaMemcpyToSymbolAsync(symbol, src, sizeBytes, offset, hipMemcpyKindToCudaMemcpyKind(copyType))); } +inline static hipError_t hipMemcpyFromSymbol(void *dst, const void* symbolName, size_t sizeBytes, size_t offset, hipMemcpyKind kind) +{ + return hipCUDAErrorTohipError(cudaMemcpyFromSymbol(dst, symbolName, sizeBytes, offset, hipMemcpyKindToCudaMemcpyKind(kind))); +} + +inline static hipError_t hipMemcpyFromSymbolAsync(void *dst, const void* symbolName, size_t sizeBytes, size_t offset, hipMemcpyKind kind, hipStream_t stream) +{ + return hipCUDAErrorTohipError(cudaMemcpyFromSymbolAsync(dst, symbolName, sizeBytes, offset, hipMemcpyKindToCudaMemcpyKind(kind), stream)); +} + inline static hipError_t hipMemcpy2D(void* dst, size_t dpitch, const void* src, size_t spitch, size_t width, size_t height, hipMemcpyKind kind){ return hipCUDAErrorTohipError(cudaMemcpy2D(dst, dpitch, src, spitch, width, height, hipMemcpyKindToCudaMemcpyKind(kind))); } diff --git a/projects/hip/src/hip_memory.cpp b/projects/hip/src/hip_memory.cpp index 94121838fd..4684287076 100644 --- a/projects/hip/src/hip_memory.cpp +++ b/projects/hip/src/hip_memory.cpp @@ -472,7 +472,7 @@ hipError_t hipHostUnregister(void *hostPtr) return ihipLogStatus(hip_status); } -hipError_t hipMemcpyToSymbol(const char* symbolName, const void *src, size_t count, size_t offset, hipMemcpyKind kind) +hipError_t hipMemcpyToSymbol(const void* symbolName, const void *src, size_t count, size_t offset, hipMemcpyKind kind) { HIP_INIT_CMD_API(symbolName, src, count, offset, kind); @@ -485,7 +485,7 @@ hipError_t hipMemcpyToSymbol(const char* symbolName, const void *src, size_t cou hc::accelerator acc = ctx->getDevice()->_acc; - void *dst = acc.get_symbol_address(symbolName); + void *dst = acc.get_symbol_address((const char*) symbolName); tprintf(DB_MEM, " symbol '%s' resolved to address:%p\n", symbolName, dst); if(dst == nullptr) @@ -507,7 +507,7 @@ hipError_t hipMemcpyToSymbol(const char* symbolName, const void *src, size_t cou } -hipError_t hipMemcpyFromSymbol(void* dst, const char* symbolName, size_t count, size_t offset, hipMemcpyKind kind) +hipError_t hipMemcpyFromSymbol(void* dst, const void* symbolName, size_t count, size_t offset, hipMemcpyKind kind) { HIP_INIT_CMD_API(symbolName, dst, count, offset, kind); @@ -520,7 +520,7 @@ hipError_t hipMemcpyFromSymbol(void* dst, const char* symbolName, size_t count, hc::accelerator acc = ctx->getDevice()->_acc; - void *src = acc.get_symbol_address(symbolName); + void *src = acc.get_symbol_address((const char*) symbolName); tprintf(DB_MEM, " symbol '%s' resolved to address:%p\n", symbolName, dst); if(dst == nullptr) @@ -542,7 +542,7 @@ hipError_t hipMemcpyFromSymbol(void* dst, const char* symbolName, size_t count, } -hipError_t hipMemcpyToSymbolAsync(const char* symbolName, const void *src, size_t count, size_t offset, hipMemcpyKind kind, hipStream_t stream) +hipError_t hipMemcpyToSymbolAsync(const void* symbolName, const void *src, size_t count, size_t offset, hipMemcpyKind kind, hipStream_t stream) { HIP_INIT_CMD_API(symbolName, src, count, offset, kind, stream); @@ -557,7 +557,7 @@ hipError_t hipMemcpyToSymbolAsync(const char* symbolName, const void *src, size_ hc::accelerator acc = ctx->getDevice()->_acc; - void *dst = acc.get_symbol_address(symbolName); + void *dst = acc.get_symbol_address((const char*) symbolName); tprintf(DB_MEM, " symbol '%s' resolved to address:%p\n", symbolName, dst); if(dst == nullptr) @@ -580,7 +580,7 @@ hipError_t hipMemcpyToSymbolAsync(const char* symbolName, const void *src, size_ } -hipError_t hipMemcpyFromSymbolAsync(void* dst, const char* symbolName, size_t count, size_t offset, hipMemcpyKind kind, hipStream_t stream) +hipError_t hipMemcpyFromSymbolAsync(void* dst, const void* symbolName, size_t count, size_t offset, hipMemcpyKind kind, hipStream_t stream) { HIP_INIT_CMD_API(symbolName, dst, count, offset, kind, stream); @@ -595,7 +595,7 @@ hipError_t hipMemcpyFromSymbolAsync(void* dst, const char* symbolName, size_t co hc::accelerator acc = ctx->getDevice()->_acc; - void *src = acc.get_symbol_address(symbolName); + void *src = acc.get_symbol_address((const char*) symbolName); tprintf(DB_MEM, " symbol '%s' resolved to address:%p\n", symbolName, src); if(src == nullptr || dst == nullptr) From 3623535fdf5eb9f613c6003d752ee93cbcc24028 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Mon, 27 Mar 2017 11:00:39 -0500 Subject: [PATCH 248/281] Re-enabled metadata parsing in HIP Change-Id: If8caa844571cb8581450df9ffdb76e2445c75f13 [ROCm/hip commit: 7d49dcc03006f93728e53d4e02f1d46a9cafcb15] --- projects/hip/CMakeLists.txt | 4 ++-- projects/hip/bin/hipcc | 3 ++- projects/hip/src/hip_module.cpp | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/projects/hip/CMakeLists.txt b/projects/hip/CMakeLists.txt index 16f43d38c5..dcecaa8d2f 100644 --- a/projects/hip/CMakeLists.txt +++ b/projects/hip/CMakeLists.txt @@ -190,11 +190,11 @@ if(HIP_PLATFORM STREQUAL "hcc") execute_process(COMMAND ${HCC_HOME}/bin/hcc-config --ldflags OUTPUT_VARIABLE HCC_LD_FLAGS) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${HCC_LD_FLAGS} -Wl,-Bsymbolic") -# find_package(LLVM HINTS "/opt/rocm/llvm") + find_package(LLVM HINTS ${HCC_HOME}/compiler/lib/cmake) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --amdgpu-target=gfx701 --amdgpu-target=gfx801 --amdgpu-target=gfx802 --amdgpu-target=gfx803 --amdgpu-target=gfx900") add_library(hip_hcc SHARED ${SOURCE_FILES_RUNTIME}) target_link_libraries(hip_hcc PRIVATE hc_am) -# target_link_libraries(hip_hcc PUBLIC LLVMAMDGPUUtils) + target_link_libraries(hip_hcc PUBLIC LLVMAMDGPUUtils) add_library(hip_hcc_static STATIC ${SOURCE_FILES_RUNTIME}) target_link_libraries(hip_hcc_static PRIVATE hc_am) add_dependencies(hip_hcc_static hip_hcc) diff --git a/projects/hip/bin/hipcc b/projects/hip/bin/hipcc index a08d5c952b..3dd8c2d60b 100755 --- a/projects/hip/bin/hipcc +++ b/projects/hip/bin/hipcc @@ -129,7 +129,8 @@ if ($HIP_PLATFORM eq "hcc") { $HIPCXXFLAGS .= " -Wno-deprecated-register"; $HIPLDFLAGS .= " -lsupc++"; - $HIPLDFLAGS .= " -L$HSA_PATH/lib -L$ROCM_PATH/lib -lhsa-runtime64 -lhc_am -lhsakmt";# `${LLVM_HOME}/bin/llvm-config --ldflags --libs`"; + $HIPLDFLAGS .= " -L$HSA_PATH/lib -L$ROCM_PATH/lib -lhsa-runtime64 -lhc_am -lhsakmt "; + $HIPLDFLAGS .= " -L$HCC_HOME/compiler/lib -lLLVMAMDGPUDesc -lLLVMAMDGPUUtils -lLLVMMC -lLLVMCore -lLLVMSupport "; # Add trace marker library: # TODO - once we cleanly separate the HIP API headers from HIP library headers this logic should move to CMakebuild option - apps do not need to see the marker library. diff --git a/projects/hip/src/hip_module.cpp b/projects/hip/src/hip_module.cpp index 3bca2090ff..dc0a681c6d 100644 --- a/projects/hip/src/hip_module.cpp +++ b/projects/hip/src/hip_module.cpp @@ -202,7 +202,7 @@ hipError_t hipModuleLoad(hipModule_t *module, const char *fname){ (*module)->size = size; in.seekg(0, std::ios::beg); std::copy(std::istreambuf_iterator(in), std::istreambuf_iterator(), ptr); -/* Enable for metadata implementation + Elf *e = elf_memory((char*)p, size); if(elf_kind(e) != ELF_K_ELF){ return ihipLogStatus(hipErrorInvalidValue); @@ -251,7 +251,7 @@ hipError_t hipModuleLoad(hipModule_t *module, const char *fname){ } } } -*/ + status = hsa_code_object_deserialize(ptr, size, NULL, &(*module)->object); if(status != HSA_STATUS_SUCCESS){ From 6e01fb345bf7fee43c4891b0fcb8c04c20ad4dfa Mon Sep 17 00:00:00 2001 From: sunway513 Date: Mon, 27 Mar 2017 17:19:09 +0000 Subject: [PATCH 249/281] resolve GGL merge conflicts Change-Id: I7a5ec3696cf2dd1a77b1686536a1cb84cbfed66e [ROCm/hip commit: 43f76be76e4f63d7a120416627e6442c75f2abb7] --- .../include/hip/hcc_detail/grid_launch_v2.hpp | 715 ++++++++---------- .../hip/include/hip/hcc_detail/helpers.hpp | 29 +- .../hip/include/hip/hcc_detail/hip_runtime.h | 8 +- .../include/hip/hcc_detail/hip_runtime_api.h | 2 +- .../hip/include/hip/hcc_detail/host_defines.h | 4 +- 5 files changed, 357 insertions(+), 401 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/grid_launch_v2.hpp b/projects/hip/include/hip/hcc_detail/grid_launch_v2.hpp index c59c69ffd9..dfce53bd26 100644 --- a/projects/hip/include/hip/hcc_detail/grid_launch_v2.hpp +++ b/projects/hip/include/hip/hcc_detail/grid_launch_v2.hpp @@ -35,7 +35,7 @@ THE SOFTWARE. #include #include -namespace glo_tests +namespace hip_impl { namespace { @@ -54,7 +54,6 @@ namespace glo_tests template requires(Domain == {Ts...}) - static inline void grid_launch_impl( New_grid_launch_tag, @@ -79,14 +78,13 @@ namespace glo_tests throw std::runtime_error{"Failed to retrieve accelerator_view!"}; } - hc::parallel_for_each(*av, d, [=](hc::tiled_index<3> idx) [[hc]] { + hc::parallel_for_each(*av, d, [=](const hc::tiled_index<3>& idx) [[hc]] { k(args...); }); } template requires(Domain == {hipLaunchParm, Ts...}) - static inline void grid_launch_impl( Old_grid_launch_tag, @@ -110,7 +108,6 @@ namespace glo_tests template requires(Domain == {Ts...}) - static inline std::enable_if_t::value> grid_launch( dim3 num_blocks, @@ -152,7 +149,6 @@ namespace glo_tests template requires(Domain == {Ts...}) - static inline void grid_launch( New_grid_launch_tag, @@ -174,7 +170,6 @@ namespace glo_tests template requires(Domain == {Ts...}) - static inline void grid_launch( Old_grid_launch_tag, @@ -196,7 +191,6 @@ namespace glo_tests template requires(Domain == {Ts...}) - static inline std::enable_if_t::value> grid_launch( dim3 num_blocks, @@ -214,402 +208,363 @@ namespace glo_tests std::forward(args)...); } - namespace - { - template struct Wrapper; - - template - struct Wrapper::value>> { - template - requires(Domain == {Ts...}) - void operator()(Ts&&... args) const - { - grid_launch(std::forward(args)...); - } - }; - - template - struct Wrapper::value>> { - template - void operator()(Ts&&...) const {} - }; - } - - // TODO: these are temporary, they need to be uglified and them completely - // removed once we enable C++14 support and can have proper generic, - // variadic lambdas. - #define make_lambda_wrapper21( \ - kernel_name, \ - p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, \ - p16, p17, p18, p19) \ - []( \ - std::decay_t _p0_, \ - std::decay_t _p1_, \ - std::decay_t _p2_, \ - std::decay_t _p3_, \ - std::decay_t _p4_, \ - std::decay_t _p5_, \ - std::decay_t _p6_, \ - std::decay_t _p7_, \ - std::decay_t _p8_, \ - std::decay_t _p9_, \ - std::decay_t _p10_, \ - std::decay_t _p11_, \ - std::decay_t _p12_, \ - std::decay_t _p13_, \ - std::decay_t _p14_, \ - std::decay_t _p15_, \ - std::decay_t _p16_, \ - std::decay_t _p17_, \ - std::decay_t _p18_, \ - std::decay_t _p19_) [[hc]] { \ - kernel_name( \ - _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_, \ - _p9_, _p10_, _p11_, _p12_, _p13_, _p14_, _p15_, _p16_, _p17_, \ - _p18_, _p19_); \ + // TODO: these are temporary, they need to be completely removed once we + // enable C++14 support and can have proper generic, variadic lambdas. + #define make_kernel_lambda_hip_21(\ + kernel_name,\ + p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15,\ + p16, p17, p18, p19)\ + [](const std::decay_t& _p0_,\ + const std::decay_t& _p1_,\ + const std::decay_t& _p2_,\ + const std::decay_t& _p3_,\ + const std::decay_t& _p4_,\ + const std::decay_t& _p5_,\ + const std::decay_t& _p6_,\ + const std::decay_t& _p7_,\ + const std::decay_t& _p8_,\ + const std::decay_t& _p9_,\ + const std::decay_t& _p10_,\ + const std::decay_t& _p11_,\ + const std::decay_t& _p12_,\ + const std::decay_t& _p13_,\ + const std::decay_t& _p14_,\ + const std::decay_t& _p15_,\ + const std::decay_t& _p16_,\ + const std::decay_t& _p17_,\ + const std::decay_t& _p18_,\ + const std::decay_t& _p19_) [[hc]] {\ + kernel_name(\ + _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_,\ + _p9_, _p10_, _p11_, _p12_, _p13_, _p14_, _p15_, _p16_, _p17_,\ + _p18_, _p19_);\ } - #define make_lambda_wrapper20( \ - kernel_name, \ - p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, \ - p16, p17, p18) \ - []( \ - std::decay_t _p0_, \ - std::decay_t _p1_, \ - std::decay_t _p2_, \ - std::decay_t _p3_, \ - std::decay_t _p4_, \ - std::decay_t _p5_, \ - std::decay_t _p6_, \ - std::decay_t _p7_, \ - std::decay_t _p8_, \ - std::decay_t _p9_, \ - std::decay_t _p10_, \ - std::decay_t _p11_, \ - std::decay_t _p12_, \ - std::decay_t _p13_, \ - std::decay_t _p14_, \ - std::decay_t _p15_, \ - std::decay_t _p16_, \ - std::decay_t _p17_, \ - std::decay_t _p18_) [[hc]] { \ - kernel_name( \ - _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_, \ - _p9_, _p10_, _p11_, _p12_, _p13_, _p14_, _p15_, _p16_, _p17_, \ - _p18_); \ + #define make_kernel_lambda_hip_20(\ + kernel_name,\ + p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15,\ + p16, p17, p18)\ + [](const std::decay_t& _p0_,\ + const std::decay_t& _p1_,\ + const std::decay_t& _p2_,\ + const std::decay_t& _p3_,\ + const std::decay_t& _p4_,\ + const std::decay_t& _p5_,\ + const std::decay_t& _p6_,\ + const std::decay_t& _p7_,\ + const std::decay_t& _p8_,\ + const std::decay_t& _p9_,\ + const std::decay_t& _p10_,\ + const std::decay_t& _p11_,\ + const std::decay_t& _p12_,\ + const std::decay_t& _p13_,\ + const std::decay_t& _p14_,\ + const std::decay_t& _p15_,\ + const std::decay_t& _p16_,\ + const std::decay_t& _p17_,\ + const std::decay_t& _p18_) [[hc]] {\ + kernel_name(\ + _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_,\ + _p9_, _p10_, _p11_, _p12_, _p13_, _p14_, _p15_, _p16_, _p17_,\ + _p18_);\ } - #define make_lambda_wrapper19( \ - kernel_name, \ - p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, \ - p16, p17) \ - []( \ - std::decay_t _p0_, \ - std::decay_t _p1_, \ - std::decay_t _p2_, \ - std::decay_t _p3_, \ - std::decay_t _p4_, \ - std::decay_t _p5_, \ - std::decay_t _p6_, \ - std::decay_t _p7_, \ - std::decay_t _p8_, \ - std::decay_t _p9_, \ - std::decay_t _p10_, \ - std::decay_t _p11_, \ - std::decay_t _p12_, \ - std::decay_t _p13_, \ - std::decay_t _p14_, \ - std::decay_t _p15_, \ - std::decay_t _p16_, \ - std::decay_t _p17_) [[hc]] { \ - kernel_name( \ - _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_, \ - _p9_, _p10_, _p11_, _p12_, _p13_, _p14_, _p15_, _p16_, _p17_); \ + #define make_kernel_lambda_hip_19(\ + kernel_name,\ + p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15,\ + p16, p17)\ + [](const std::decay_t& _p0_,\ + const std::decay_t& _p1_,\ + const std::decay_t& _p2_,\ + const std::decay_t& _p3_,\ + const std::decay_t& _p4_,\ + const std::decay_t& _p5_,\ + const std::decay_t& _p6_,\ + const std::decay_t& _p7_,\ + const std::decay_t& _p8_,\ + const std::decay_t& _p9_,\ + const std::decay_t& _p10_,\ + const std::decay_t& _p11_,\ + const std::decay_t& _p12_,\ + const std::decay_t& _p13_,\ + const std::decay_t& _p14_,\ + const std::decay_t& _p15_,\ + const std::decay_t& _p16_,\ + const std::decay_t& _p17_) [[hc]] {\ + kernel_name(\ + _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_,\ + _p9_, _p10_, _p11_, _p12_, _p13_, _p14_, _p15_, _p16_, _p17_);\ } - #define make_lambda_wrapper18( \ - kernel_name, \ - p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, \ - p16) \ - []( \ - std::decay_t _p0_, \ - std::decay_t _p1_, \ - std::decay_t _p2_, \ - std::decay_t _p3_, \ - std::decay_t _p4_, \ - std::decay_t _p5_, \ - std::decay_t _p6_, \ - std::decay_t _p7_, \ - std::decay_t _p8_, \ - std::decay_t _p9_, \ - std::decay_t _p10_, \ - std::decay_t _p11_, \ - std::decay_t _p12_, \ - std::decay_t _p13_, \ - std::decay_t _p14_, \ - std::decay_t _p15_, \ - std::decay_t _p16_) [[hc]] { \ - kernel_name( \ - _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_, \ - _p9_, _p10_, _p11_, _p12_, _p13_, _p14_, _p15_, _p16_); \ + #define make_kernel_lambda_hip_18(\ + kernel_name,\ + p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15,\ + p16)\ + [](const std::decay_t& _p0_,\ + const std::decay_t& _p1_,\ + const std::decay_t& _p2_,\ + const std::decay_t& _p3_,\ + const std::decay_t& _p4_,\ + const std::decay_t& _p5_,\ + const std::decay_t& _p6_,\ + const std::decay_t& _p7_,\ + const std::decay_t& _p8_,\ + const std::decay_t& _p9_,\ + const std::decay_t& _p10_,\ + const std::decay_t& _p11_,\ + const std::decay_t& _p12_,\ + const std::decay_t& _p13_,\ + const std::decay_t& _p14_,\ + const std::decay_t& _p15_,\ + const std::decay_t& _p16_) [[hc]] {\ + kernel_name(\ + _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_,\ + _p9_, _p10_, _p11_, _p12_, _p13_, _p14_, _p15_, _p16_);\ } - #define make_lambda_wrapper17( \ - kernel_name, \ - p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15) \ - []( \ - std::decay_t _p0_, \ - std::decay_t _p1_, \ - std::decay_t _p2_, \ - std::decay_t _p3_, \ - std::decay_t _p4_, \ - std::decay_t _p5_, \ - std::decay_t _p6_, \ - std::decay_t _p7_, \ - std::decay_t _p8_, \ - std::decay_t _p9_, \ - std::decay_t _p10_, \ - std::decay_t _p11_, \ - std::decay_t _p12_, \ - std::decay_t _p13_, \ - std::decay_t _p14_, \ - std::decay_t _p15_) [[hc]] { \ - kernel_name( \ - _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_, \ - _p9_, _p10_, _p11_, _p12_, _p13_, _p14_, _p15_); \ + #define make_kernel_lambda_hip_17(\ + kernel_name,\ + p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15)\ + [](const std::decay_t& _p0_,\ + const std::decay_t& _p1_,\ + const std::decay_t& _p2_,\ + const std::decay_t& _p3_,\ + const std::decay_t& _p4_,\ + const std::decay_t& _p5_,\ + const std::decay_t& _p6_,\ + const std::decay_t& _p7_,\ + const std::decay_t& _p8_,\ + const std::decay_t& _p9_,\ + const std::decay_t& _p10_,\ + const std::decay_t& _p11_,\ + const std::decay_t& _p12_,\ + const std::decay_t& _p13_,\ + const std::decay_t& _p14_,\ + const std::decay_t& _p15_) [[hc]] {\ + kernel_name(\ + _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_,\ + _p9_, _p10_, _p11_, _p12_, _p13_, _p14_, _p15_);\ } - #define make_lambda_wrapper16( \ - kernel_name, \ - p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14) \ - []( \ - std::decay_t _p0_, \ - std::decay_t _p1_, \ - std::decay_t _p2_, \ - std::decay_t _p3_, \ - std::decay_t _p4_, \ - std::decay_t _p5_, \ - std::decay_t _p6_, \ - std::decay_t _p7_, \ - std::decay_t _p8_, \ - std::decay_t _p9_, \ - std::decay_t _p10_, \ - std::decay_t _p11_, \ - std::decay_t _p12_, \ - std::decay_t _p13_, \ - std::decay_t _p14_) [[hc]] { \ - kernel_name( \ - _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_, \ - _p9_, _p10_, _p11_, _p12_, _p13_, _p14_); \ + #define make_kernel_lambda_hip_16(\ + kernel_name,\ + p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14)\ + [](const std::decay_t& _p0_,\ + const std::decay_t& _p1_,\ + const std::decay_t& _p2_,\ + const std::decay_t& _p3_,\ + const std::decay_t& _p4_,\ + const std::decay_t& _p5_,\ + const std::decay_t& _p6_,\ + const std::decay_t& _p7_,\ + const std::decay_t& _p8_,\ + const std::decay_t& _p9_,\ + const std::decay_t& _p10_,\ + const std::decay_t& _p11_,\ + const std::decay_t& _p12_,\ + const std::decay_t& _p13_,\ + const std::decay_t& _p14_) [[hc]] {\ + kernel_name(\ + _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_,\ + _p9_, _p10_, _p11_, _p12_, _p13_, _p14_);\ } - #define make_lambda_wrapper15( \ - kernel_name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13)\ - []( \ - std::decay_t _p0_, \ - std::decay_t _p1_, \ - std::decay_t _p2_, \ - std::decay_t _p3_, \ - std::decay_t _p4_, \ - std::decay_t _p5_, \ - std::decay_t _p6_, \ - std::decay_t _p7_, \ - std::decay_t _p8_, \ - std::decay_t _p9_, \ - std::decay_t _p10_, \ - std::decay_t _p11_, \ - std::decay_t _p12_, \ - std::decay_t _p13_) [[hc]] { \ - kernel_name( \ - _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_, \ - _p9_, _p10_, _p11_, _p12_, _p13_); \ + #define make_kernel_lambda_hip_15(\ + kernel_name,\ + p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13)\ + [](const std::decay_t& _p0_,\ + const std::decay_t& _p1_,\ + const std::decay_t& _p2_,\ + const std::decay_t& _p3_,\ + const std::decay_t& _p4_,\ + const std::decay_t& _p5_,\ + const std::decay_t& _p6_,\ + const std::decay_t& _p7_,\ + const std::decay_t& _p8_,\ + const std::decay_t& _p9_,\ + const std::decay_t& _p10_,\ + const std::decay_t& _p11_,\ + const std::decay_t& _p12_,\ + const std::decay_t& _p13_) [[hc]] {\ + kernel_name(\ + _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_,\ + _p9_, _p10_, _p11_, _p12_, _p13_);\ } - #define make_lambda_wrapper14( \ - kernel_name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12) \ - []( \ - std::decay_t _p0_, \ - std::decay_t _p1_, \ - std::decay_t _p2_, \ - std::decay_t _p3_, \ - std::decay_t _p4_, \ - std::decay_t _p5_, \ - std::decay_t _p6_, \ - std::decay_t _p7_, \ - std::decay_t _p8_, \ - std::decay_t _p9_, \ - std::decay_t _p10_, \ - std::decay_t _p11_, \ - std::decay_t _p12_) [[hc]] { \ - kernel_name( \ - _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_, \ - _p9_, _p10_, _p11_, _p12_); \ + #define make_kernel_lambda_hip_14(\ + kernel_name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12)\ + [](const std::decay_t& _p0_,\ + const std::decay_t& _p1_,\ + const std::decay_t& _p2_,\ + const std::decay_t& _p3_,\ + const std::decay_t& _p4_,\ + const std::decay_t& _p5_,\ + const std::decay_t& _p6_,\ + const std::decay_t& _p7_,\ + const std::decay_t& _p8_,\ + const std::decay_t& _p9_,\ + const std::decay_t& _p10_,\ + const std::decay_t& _p11_,\ + const std::decay_t& _p12_) [[hc]] {\ + kernel_name(\ + _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_,\ + _p9_, _p10_, _p11_, _p12_);\ } - #define make_lambda_wrapper13( \ - kernel_name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11) \ - []( \ - std::decay_t _p0_, \ - std::decay_t _p1_, \ - std::decay_t _p2_, \ - std::decay_t _p3_, \ - std::decay_t _p4_, \ - std::decay_t _p5_, \ - std::decay_t _p6_, \ - std::decay_t _p7_, \ - std::decay_t _p8_, \ - std::decay_t _p9_, \ - std::decay_t _p10_, \ - std::decay_t _p11_) [[hc]] { \ - kernel_name( \ - _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_, \ - _p9_, _p10_, _p11_); \ + #define make_kernel_lambda_hip_13(\ + kernel_name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11)\ + [](const std::decay_t& _p0_,\ + const std::decay_t& _p1_,\ + const std::decay_t& _p2_,\ + const std::decay_t& _p3_,\ + const std::decay_t& _p4_,\ + const std::decay_t& _p5_,\ + const std::decay_t& _p6_,\ + const std::decay_t& _p7_,\ + const std::decay_t& _p8_,\ + const std::decay_t& _p9_,\ + const std::decay_t& _p10_,\ + const std::decay_t& _p11_) [[hc]] {\ + kernel_name(\ + _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_,\ + _p9_, _p10_, _p11_);\ } - #define make_lambda_wrapper12( \ - kernel_name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) \ - []( \ - std::decay_t _p0_, \ - std::decay_t _p1_, \ - std::decay_t _p2_, \ - std::decay_t _p3_, \ - std::decay_t _p4_, \ - std::decay_t _p5_, \ - std::decay_t _p6_, \ - std::decay_t _p7_, \ - std::decay_t _p8_, \ - std::decay_t _p9_, \ - std::decay_t _p10_) [[hc]] { \ - kernel_name( \ - _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_, _p9_, \ - _p10_); \ + #define make_kernel_lambda_hip_12(\ + kernel_name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10)\ + [](const std::decay_t& _p0_,\ + const std::decay_t& _p1_,\ + const std::decay_t& _p2_,\ + const std::decay_t& _p3_,\ + const std::decay_t& _p4_,\ + const std::decay_t& _p5_,\ + const std::decay_t& _p6_,\ + const std::decay_t& _p7_,\ + const std::decay_t& _p8_,\ + const std::decay_t& _p9_,\ + const std::decay_t& _p10_) [[hc]] {\ + kernel_name(\ + _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_, _p9_,\ + _p10_);\ } - #define make_lambda_wrapper11( \ - kernel_name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9) \ - []( \ - std::decay_t _p0_, \ - std::decay_t _p1_, \ - std::decay_t _p2_, \ - std::decay_t _p3_, \ - std::decay_t _p4_, \ - std::decay_t _p5_, \ - std::decay_t _p6_, \ - std::decay_t _p7_, \ - std::decay_t _p8_, \ - std::decay_t _p9_) [[hc]] { \ - kernel_name( \ - _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_, _p9_); \ + #define make_kernel_lambda_hip_11(\ + kernel_name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)\ + [](const std::decay_t& _p0_,\ + const std::decay_t& _p1_,\ + const std::decay_t& _p2_,\ + const std::decay_t& _p3_,\ + const std::decay_t& _p4_,\ + const std::decay_t& _p5_,\ + const std::decay_t& _p6_,\ + const std::decay_t& _p7_,\ + const std::decay_t& _p8_,\ + const std::decay_t& _p9_) [[hc]] {\ + kernel_name(\ + _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_, _p9_);\ } - #define make_lambda_wrapper10( \ - kernel_name, p0, p1, p2, p3, p4, p5, p6, p7, p8) \ - []( \ - std::decay_t _p0_, \ - std::decay_t _p1_, \ - std::decay_t _p2_, \ - std::decay_t _p3_, \ - std::decay_t _p4_, \ - std::decay_t _p5_, \ - std::decay_t _p6_, \ - std::decay_t _p7_, \ - std::decay_t _p8_) [[hc]] { \ - kernel_name(_p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_); \ + #define make_kernel_lambda_hip_10(\ + kernel_name, p0, p1, p2, p3, p4, p5, p6, p7, p8)\ + [](const std::decay_t& _p0_,\ + const std::decay_t& _p1_,\ + const std::decay_t& _p2_,\ + const std::decay_t& _p3_,\ + const std::decay_t& _p4_,\ + const std::decay_t& _p5_,\ + const std::decay_t& _p6_,\ + const std::decay_t& _p7_,\ + const std::decay_t& _p8_) [[hc]] {\ + kernel_name(_p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_);\ } - #define make_lambda_wrapper9(kernel_name, p0, p1, p2, p3, p4, p5, p6, p7) \ - []( \ - std::decay_t _p0_, \ - std::decay_t _p1_, \ - std::decay_t _p2_, \ - std::decay_t _p3_, \ - std::decay_t _p4_, \ - std::decay_t _p5_, \ - std::decay_t _p6_, \ - std::decay_t _p7_) [[hc]] { \ - kernel_name(_p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_); \ + #define make_kernel_lambda_hip_9(\ + kernel_name, p0, p1, p2, p3, p4, p5, p6, p7)\ + [](const std::decay_t& _p0_,\ + const std::decay_t& _p1_,\ + const std::decay_t& _p2_,\ + const std::decay_t& _p3_,\ + const std::decay_t& _p4_,\ + const std::decay_t& _p5_,\ + const std::decay_t& _p6_,\ + const std::decay_t& _p7_) [[hc]] {\ + kernel_name(_p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_);\ } - #define make_lambda_wrapper8(kernel_name, p0, p1, p2, p3, p4, p5, p6) \ - []( \ - std::decay_t _p0_, \ - std::decay_t _p1_, \ - std::decay_t _p2_, \ - std::decay_t _p3_, \ - std::decay_t _p4_, \ - std::decay_t _p5_, \ - std::decay_t _p6_) [[hc]] { \ - kernel_name(_p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_); \ + #define make_kernel_lambda_hip_8(kernel_name, p0, p1, p2, p3, p4, p5, p6)\ + [](const std::decay_t& _p0_,\ + const std::decay_t& _p1_,\ + const std::decay_t& _p2_,\ + const std::decay_t& _p3_,\ + const std::decay_t& _p4_,\ + const std::decay_t& _p5_,\ + const std::decay_t& _p6_) [[hc]] {\ + kernel_name(_p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_);\ } - #define make_lambda_wrapper7(kernel_name, p0, p1, p2, p3, p4, p5) \ - []( \ - std::decay_t _p0_, \ - std::decay_t _p1_, \ - std::decay_t _p2_, \ - std::decay_t _p3_, \ - std::decay_t _p4_, \ - std::decay_t _p5_) [[hc]] { \ - kernel_name(_p0_, _p1_, _p2_, _p3_, _p4_, _p5_); \ + #define make_kernel_lambda_hip_7(kernel_name, p0, p1, p2, p3, p4, p5)\ + [](const std::decay_t& _p0_,\ + const std::decay_t& _p1_,\ + const std::decay_t& _p2_,\ + const std::decay_t& _p3_,\ + const std::decay_t& _p4_,\ + const std::decay_t& _p5_) [[hc]] {\ + kernel_name(_p0_, _p1_, _p2_, _p3_, _p4_, _p5_);\ } - #define make_lambda_wrapper6(kernel_name, p0, p1, p2, p3, p4) \ - []( \ - std::decay_t _p0_, \ - std::decay_t _p1_, \ - std::decay_t _p2_, \ - std::decay_t _p3_, \ - std::decay_t _p4_) [[hc]] { \ - kernel_name(_p0_, _p1_, _p2_, _p3_, _p4_); \ + #define make_kernel_lambda_hip_6(kernel_name, p0, p1, p2, p3, p4)\ + [](const std::decay_t& _p0_,\ + const std::decay_t& _p1_,\ + const std::decay_t& _p2_,\ + const std::decay_t& _p3_,\ + const std::decay_t& _p4_) [[hc]] {\ + kernel_name(_p0_, _p1_, _p2_, _p3_, _p4_);\ } - #define make_lambda_wrapper5(kernel_name, p0, p1, p2, p3) \ - []( \ - std::decay_t _p0_, \ - std::decay_t _p1_, \ - std::decay_t _p2_, \ - std::decay_t _p3_) [[hc]] { \ - kernel_name(_p0_, _p1_, _p2_, _p3_); \ + #define make_kernel_lambda_hip_5(kernel_name, p0, p1, p2, p3)\ + [](const std::decay_t& _p0_,\ + const std::decay_t& _p1_,\ + const std::decay_t& _p2_,\ + const std::decay_t& _p3_) [[hc]] {\ + kernel_name(_p0_, _p1_, _p2_, _p3_);\ } - #define make_lambda_wrapper4(kernel_name, p0, p1, p2) \ - []( \ - std::decay_t _p0_, \ - std::decay_t _p1_, \ - std::decay_t _p2_) [[hc]] { \ - kernel_name(_p0_, _p1_, _p2_); \ + #define make_kernel_lambda_hip_4(kernel_name, p0, p1, p2)\ + [](const std::decay_t& _p0_,\ + const std::decay_t& _p1_,\ + const std::decay_t& _p2_) [[hc]] {\ + kernel_name(_p0_, _p1_, _p2_);\ } - #define make_lambda_wrapper3(kernel_name, p0, p1) \ - []( \ - std::decay_t _p0_, \ - std::decay_t _p1_) [[hc]] { \ - kernel_name(_p0_, _p1_); \ + #define make_kernel_lambda_hip_3(kernel_name, p0, p1)\ + [](const std::decay_t& _p0_,\ + const std::decay_t& _p1_) [[hc]] {\ + kernel_name(_p0_, _p1_);\ } - #define make_lambda_wrapper2(kernel_name, p0) \ - [](std::decay_t _p0_) [[hc]] { \ - kernel_name(_p0_); \ + #define make_kernel_lambda_hip_2(kernel_name, p0)\ + [](const std::decay_t& _p0_) [[hc]] {\ + kernel_name(_p0_);\ } - #define make_lambda_wrapper1(kernel_name) \ + #define make_kernel_lambda_hip_1(kernel_name)\ []() [[hc]] { kernel_name(lp); } - #define make_lambda_wrapper(...) \ - overload_macro(make_lambda_wrapper, __VA_ARGS__) + #define make_kernel_lambda_hip_(...)\ + overload_macro_hip_(make_kernel_lambda_hip_, __VA_ARGS__) - #define hipLaunchKernelV3( \ - kernel_name, \ - num_blocks, \ - dim_blocks, \ - group_mem_bytes, \ - stream, \ - ...) \ - { \ - glo_tests::grid_launch( \ - num_blocks, \ - dim_blocks, \ - group_mem_bytes, \ - stream, \ - make_lambda_wrapper(kernel_name, __VA_ARGS__), \ - ##__VA_ARGS__); \ + #define hipLaunchKernelV3(\ + kernel_name,\ + num_blocks,\ + dim_blocks,\ + group_mem_bytes,\ + stream,\ + ...)\ + {\ + hip_impl::grid_launch(\ + num_blocks,\ + dim_blocks,\ + group_mem_bytes,\ + stream,\ + make_kernel_lambda_hip_(kernel_name, __VA_ARGS__),\ + ##__VA_ARGS__);\ } - #define hipLaunchKernel( \ - kernel_name, \ - num_blocks, \ - dim_blocks, \ - group_mem_bytes, \ - stream, \ - ...) \ - { \ - hipLaunchKernelV3( \ - kernel_name, \ - num_blocks, \ - dim_blocks, \ - group_mem_bytes, \ - stream, \ - hipLaunchParm{}, \ - ##__VA_ARGS__); \ + #define hipLaunchKernel(\ + kernel_name,\ + num_blocks,\ + dim_blocks,\ + group_mem_bytes,\ + stream,\ + ...)\ + {\ + hipLaunchKernelV3(\ + kernel_name,\ + num_blocks,\ + dim_blocks,\ + group_mem_bytes,\ + stream,\ + hipLaunchParm{},\ + ##__VA_ARGS__);\ } } diff --git a/projects/hip/include/hip/hcc_detail/helpers.hpp b/projects/hip/include/hip/hcc_detail/helpers.hpp index 301d740066..566612dce4 100644 --- a/projects/hip/include/hip/hcc_detail/helpers.hpp +++ b/projects/hip/include/hip/hcc_detail/helpers.hpp @@ -20,9 +20,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -// -// Created by alexv on 08/11/16. -// #pragma once #include // For std::conditional, std::decay, std::enable_if, @@ -30,7 +27,7 @@ THE SOFTWARE. #include // For std::declval. namespace std -{ +{ // TODO: these should be removed as soon as possible. #if (__cplusplus < 201406L) template using void_t = void; @@ -126,20 +123,20 @@ namespace std #endif } -namespace glo_tests // Only for documentation, macros ignore namespaces. +namespace // Only for documentation, macros ignore namespaces. { - #define count_macro_args_impl( \ - _0, _1, _2, _3, _4, _5, _6, _7, \ - _8, _9, _10, _11, _12, _13, _14, _15, \ - _16, _17, _18, _19, _20, _21, _n, ...) _n - #define count_macro_args(...) \ - count_macro_args_impl( \ + #define count_macro_args_impl_hip_(\ + _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15,\ + _16, _17, _18, _19, _20, _21, _n, ...) _n + #define count_macro_args_hip_(...)\ + count_macro_args_impl_hip_(\ , ##__VA_ARGS__, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9,\ 8, 7, 6, 5, 4, 3, 2, 1, 0) - #define overloaded_macro_expand(macro, arg_cnt) macro##arg_cnt - #define overload_macro_impl(macro, arg_cnt) \ - overloaded_macro_expand(macro, arg_cnt) - #define overload_macro(macro, ...) \ - overload_macro_impl(macro, count_macro_args(__VA_ARGS__)) (__VA_ARGS__) + #define overloaded_macro_expand_hip_(macro, arg_cnt) macro##arg_cnt + #define overload_macro_impl_hip_(macro, arg_cnt)\ + overloaded_macro_expand_hip_(macro, arg_cnt) + #define overload_macro_hip_(macro, ...)\ + overload_macro_impl_hip_(macro, count_macro_args_hip_(__VA_ARGS__))\ + (__VA_ARGS__) } diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime.h b/projects/hip/include/hip/hcc_detail/hip_runtime.h index 590cc33bd1..42d80ecb0e 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime.h @@ -62,11 +62,15 @@ THE SOFTWARE. #include //TODO-HCC-GL - change this to typedef. //typedef grid_launch_parm hipLaunchParm ; -struct EmptyLaunchParm{}; + #if GENERIC_GRID_LAUNCH == 0 #define hipLaunchParm grid_launch_parm #else - #define hipLaunchParm EmptyLaunchParm +namespace hip_impl +{ + struct Empty_launch_parm{}; +} +#define hipLaunchParm hip_impl::Empty_launch_parm #endif //GENERIC_GRID_LAUNCH #if defined (GRID_LAUNCH_VERSION) and (GRID_LAUNCH_VERSION >= 20) || GENERIC_GRID_LAUNCH == 1 diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h index cba6f01d49..658e3d2f97 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h @@ -32,7 +32,7 @@ THE SOFTWARE. #include #ifndef GENERIC_GRID_LAUNCH -#define GENERIC_GRID_LAUNCH 0 +#define GENERIC_GRID_LAUNCH 0 #endif #include diff --git a/projects/hip/include/hip/hcc_detail/host_defines.h b/projects/hip/include/hip/hcc_detail/host_defines.h index 28c9268f59..ab975dbb2c 100644 --- a/projects/hip/include/hip/hcc_detail/host_defines.h +++ b/projects/hip/include/hip/hcc_detail/host_defines.h @@ -32,7 +32,7 @@ THE SOFTWARE. // Add guard to Generic Grid Launch method #ifndef GENERIC_GRID_LAUNCH -#define GENERIC_GRID_LAUNCH 0 +#define GENERIC_GRID_LAUNCH 0 #endif #ifdef __HCC__ @@ -46,7 +46,7 @@ THE SOFTWARE. #if GENERIC_GRID_LAUNCH == 0 //#warning "original global define reached" #define __global__ __attribute__((hc_grid_launch)) __attribute__((used)) -#else +#else //#warning "GGL global define reached" #define __global__ [[hc]] __attribute__((weak)) #endif //GENERIC_GRID_LAUNCH From d7b6039544c8be65776420dbfd889341c7aa3465 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Tue, 28 Mar 2017 10:46:31 -0500 Subject: [PATCH 250/281] disabled metadata apis Change-Id: Ifb8839c581644cccc2afcd18c38a866f649a4144 [ROCm/hip commit: 7ac438ed021a9f3f7e466c686f5b5f05591c09f9] --- projects/hip/bin/hipcc | 3 +-- projects/hip/src/hip_module.cpp | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/projects/hip/bin/hipcc b/projects/hip/bin/hipcc index 3dd8c2d60b..de4883fea3 100755 --- a/projects/hip/bin/hipcc +++ b/projects/hip/bin/hipcc @@ -103,7 +103,6 @@ if ($HIP_PLATFORM eq "hcc") { $HIPLDFLAGS = `${HCC_HOME}/bin/hcc-config --ldflags`; -# $LLVM_HOME = "/opt/rocm/llvm"; #### GCC system includes workaround #### $HCC_WA_FLAGS = " "; @@ -130,7 +129,7 @@ if ($HIP_PLATFORM eq "hcc") { $HIPLDFLAGS .= " -lsupc++"; $HIPLDFLAGS .= " -L$HSA_PATH/lib -L$ROCM_PATH/lib -lhsa-runtime64 -lhc_am -lhsakmt "; - $HIPLDFLAGS .= " -L$HCC_HOME/compiler/lib -lLLVMAMDGPUDesc -lLLVMAMDGPUUtils -lLLVMMC -lLLVMCore -lLLVMSupport "; +# $HIPLDFLAGS .= " -L$HCC_HOME/compiler/lib -lLLVMAMDGPUDesc -lLLVMAMDGPUUtils -lLLVMMC -lLLVMCore -lLLVMSupport "; # Add trace marker library: # TODO - once we cleanly separate the HIP API headers from HIP library headers this logic should move to CMakebuild option - apps do not need to see the marker library. diff --git a/projects/hip/src/hip_module.cpp b/projects/hip/src/hip_module.cpp index dc0a681c6d..c4b6cb8e08 100644 --- a/projects/hip/src/hip_module.cpp +++ b/projects/hip/src/hip_module.cpp @@ -202,7 +202,7 @@ hipError_t hipModuleLoad(hipModule_t *module, const char *fname){ (*module)->size = size; in.seekg(0, std::ios::beg); std::copy(std::istreambuf_iterator(in), std::istreambuf_iterator(), ptr); - +/* Elf *e = elf_memory((char*)p, size); if(elf_kind(e) != ELF_K_ELF){ return ihipLogStatus(hipErrorInvalidValue); @@ -251,7 +251,7 @@ hipError_t hipModuleLoad(hipModule_t *module, const char *fname){ } } } - +*/ status = hsa_code_object_deserialize(ptr, size, NULL, &(*module)->object); if(status != HSA_STATUS_SUCCESS){ From 72bf251f1afa893020d2c8fbe1d292da3ed9e244 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Wed, 29 Mar 2017 16:36:46 +0300 Subject: [PATCH 251/281] [HIPIFY] Rename bash scripts. [ROCm/hip commit: ca09afcaab960820b2271a409c5fe750e09c8d48] --- projects/hip/bin/hipconvertinplace-perl.sh | 18 +++++++++++++++ projects/hip/bin/hipconvertinplace.sh | 26 +++++++++++++--------- projects/hip/bin/hipconvertinplace2.sh | 24 -------------------- projects/hip/bin/hipexamine-perl.sh | 12 ++++++++++ projects/hip/bin/hipexamine.sh | 22 +++++++++++++----- projects/hip/bin/hipexamine2.sh | 22 ------------------ 6 files changed, 62 insertions(+), 62 deletions(-) create mode 100755 projects/hip/bin/hipconvertinplace-perl.sh mode change 100755 => 100644 projects/hip/bin/hipconvertinplace.sh delete mode 100644 projects/hip/bin/hipconvertinplace2.sh create mode 100755 projects/hip/bin/hipexamine-perl.sh mode change 100755 => 100644 projects/hip/bin/hipexamine.sh delete mode 100644 projects/hip/bin/hipexamine2.sh diff --git a/projects/hip/bin/hipconvertinplace-perl.sh b/projects/hip/bin/hipconvertinplace-perl.sh new file mode 100755 index 0000000000..a8c8d6d9e8 --- /dev/null +++ b/projects/hip/bin/hipconvertinplace-perl.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +#usage : hipconvertinplace.sh [DIRNAME] [HIPIFY_OPTIONS] + +#hipify "inplace" all code files in specified directory. +# This can be quite handy when dealing with an existing CUDA code base since the script +# preserves the existing directory structure. + +# For each code file, this script will: +# - If ".prehip file does not exist, copy the original code to a new file with extension ".prehip". Then Hipify the code file. +# - If ".prehip" file exists, this is used as input to hipify. +# (this is useful for testing improvements to the hipify toolset). + + +SCRIPT_DIR=`dirname $0` +SEARCH_DIR=$1 +shift +$SCRIPT_DIR/hipify -inplace -print-stats "$@" `$SCRIPT_DIR/findcode.sh $SEARCH_DIR` diff --git a/projects/hip/bin/hipconvertinplace.sh b/projects/hip/bin/hipconvertinplace.sh old mode 100755 new mode 100644 index a8c8d6d9e8..a765ab39fa --- a/projects/hip/bin/hipconvertinplace.sh +++ b/projects/hip/bin/hipconvertinplace.sh @@ -1,18 +1,24 @@ #!/bin/bash -#usage : hipconvertinplace.sh [DIRNAME] [HIPIFY_OPTIONS] +#usage : hipconvertinplace.sh DIRNAME [hipify options] [--] [clang options] -#hipify "inplace" all code files in specified directory. +#hipify "inplace" all code files in specified directory. # This can be quite handy when dealing with an existing CUDA code base since the script # preserves the existing directory structure. -# For each code file, this script will: -# - If ".prehip file does not exist, copy the original code to a new file with extension ".prehip". Then Hipify the code file. -# - If ".prehip" file exists, this is used as input to hipify. -# (this is useful for testing improvements to the hipify toolset). - - SCRIPT_DIR=`dirname $0` SEARCH_DIR=$1 -shift -$SCRIPT_DIR/hipify -inplace -print-stats "$@" `$SCRIPT_DIR/findcode.sh $SEARCH_DIR` + +hipify_args='' +while (( "$#" )); do + shift + if [ "$1" != "--" ]; then + hipify_args="$hipify_args $1" + else + shift + break + fi +done +clang_args="$@" + +$SCRIPT_DIR/hipify-clang -inplace -print-stats $hipify_args `$SCRIPT_DIR/findcode.sh $SEARCH_DIR` -- -x cuda $clang_args diff --git a/projects/hip/bin/hipconvertinplace2.sh b/projects/hip/bin/hipconvertinplace2.sh deleted file mode 100644 index a765ab39fa..0000000000 --- a/projects/hip/bin/hipconvertinplace2.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -#usage : hipconvertinplace.sh DIRNAME [hipify options] [--] [clang options] - -#hipify "inplace" all code files in specified directory. -# This can be quite handy when dealing with an existing CUDA code base since the script -# preserves the existing directory structure. - -SCRIPT_DIR=`dirname $0` -SEARCH_DIR=$1 - -hipify_args='' -while (( "$#" )); do - shift - if [ "$1" != "--" ]; then - hipify_args="$hipify_args $1" - else - shift - break - fi -done -clang_args="$@" - -$SCRIPT_DIR/hipify-clang -inplace -print-stats $hipify_args `$SCRIPT_DIR/findcode.sh $SEARCH_DIR` -- -x cuda $clang_args diff --git a/projects/hip/bin/hipexamine-perl.sh b/projects/hip/bin/hipexamine-perl.sh new file mode 100755 index 0000000000..40c1bf466d --- /dev/null +++ b/projects/hip/bin/hipexamine-perl.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +#usage : hipexamine.sh DIRNAME [hipify.pl options] + +# Generate HIP stats (LOC, CUDA->API conversions, missing functionality) for all the code files +# in the specified directory. + + +SCRIPT_DIR=`dirname $0` +SEARCH_DIR=$1 +shift +$SCRIPT_DIR/hipify -no-output -print-stats "$@" `$SCRIPT_DIR/findcode.sh $SEARCH_DIR` diff --git a/projects/hip/bin/hipexamine.sh b/projects/hip/bin/hipexamine.sh old mode 100755 new mode 100644 index 40c1bf466d..2a6fab7110 --- a/projects/hip/bin/hipexamine.sh +++ b/projects/hip/bin/hipexamine.sh @@ -1,12 +1,22 @@ #!/bin/bash -#usage : hipexamine.sh DIRNAME [hipify.pl options] - -# Generate HIP stats (LOC, CUDA->API conversions, missing functionality) for all the code files -# in the specified directory. +#usage : hipexamine2.sh DIRNAME [hipify options] [--] [clang options] +# Generate CUDA->HIP conversion statistics for all the code files in the specified directory. SCRIPT_DIR=`dirname $0` SEARCH_DIR=$1 -shift -$SCRIPT_DIR/hipify -no-output -print-stats "$@" `$SCRIPT_DIR/findcode.sh $SEARCH_DIR` + +hipify_args='' +while (( "$#" )); do + shift + if [ "$1" != "--" ]; then + hipify_args="$hipify_args $1" + else + shift + break + fi +done +clang_args="$@" + +$SCRIPT_DIR/hipify-clang -examine $hipify_args `$SCRIPT_DIR/findcode.sh $SEARCH_DIR` -- -x cuda $clang_args diff --git a/projects/hip/bin/hipexamine2.sh b/projects/hip/bin/hipexamine2.sh deleted file mode 100644 index 2a6fab7110..0000000000 --- a/projects/hip/bin/hipexamine2.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -#usage : hipexamine2.sh DIRNAME [hipify options] [--] [clang options] - -# Generate CUDA->HIP conversion statistics for all the code files in the specified directory. - -SCRIPT_DIR=`dirname $0` -SEARCH_DIR=$1 - -hipify_args='' -while (( "$#" )); do - shift - if [ "$1" != "--" ]; then - hipify_args="$hipify_args $1" - else - shift - break - fi -done -clang_args="$@" - -$SCRIPT_DIR/hipify-clang -examine $hipify_args `$SCRIPT_DIR/findcode.sh $SEARCH_DIR` -- -x cuda $clang_args From 381a67f2560b60e96e4edee680a0701d5b7a86c7 Mon Sep 17 00:00:00 2001 From: "Sun, Peng" Date: Wed, 29 Mar 2017 09:02:39 -0500 Subject: [PATCH 252/281] Update GGL to fix one Torch build issue Change-Id: I95a2a335902e3c368ed29f075ac72eabbb64c97e [ROCm/hip commit: d067c884bebf767d01a4d5b07eb0d09a2ab2cb35] --- .../include/hip/hcc_detail/grid_launch_v2.hpp | 164 +++++++++++++++++- .../hip/include/hip/hcc_detail/helpers.hpp | 8 +- 2 files changed, 167 insertions(+), 5 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/grid_launch_v2.hpp b/projects/hip/include/hip/hcc_detail/grid_launch_v2.hpp index dfce53bd26..3d5d5c1ffe 100644 --- a/projects/hip/include/hip/hcc_detail/grid_launch_v2.hpp +++ b/projects/hip/include/hip/hcc_detail/grid_launch_v2.hpp @@ -210,6 +210,166 @@ namespace hip_impl // TODO: these are temporary, they need to be completely removed once we // enable C++14 support and can have proper generic, variadic lambdas. + #define make_kernel_lambda_hip_26(\ + kernel_name,\ + p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15,\ + p16, p17, p18, p19, p20, p21, p22, p23, p24)\ + [](const std::decay_t& _p0_,\ + const std::decay_t& _p1_,\ + const std::decay_t& _p2_,\ + const std::decay_t& _p3_,\ + const std::decay_t& _p4_,\ + const std::decay_t& _p5_,\ + const std::decay_t& _p6_,\ + const std::decay_t& _p7_,\ + const std::decay_t& _p8_,\ + const std::decay_t& _p9_,\ + const std::decay_t& _p10_,\ + const std::decay_t& _p11_,\ + const std::decay_t& _p12_,\ + const std::decay_t& _p13_,\ + const std::decay_t& _p14_,\ + const std::decay_t& _p15_,\ + const std::decay_t& _p16_,\ + const std::decay_t& _p17_,\ + const std::decay_t& _p18_,\ + const std::decay_t& _p19_,\ + const std::decay_t& _p20_,\ + const std::decay_t& _p21_,\ + const std::decay_t& _p22_,\ + const std::decay_t& _p23_,\ + const std::decay_t& _p24_) [[hc]] {\ + kernel_name(\ + _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_,\ + _p9_, _p10_, _p11_, _p12_, _p13_, _p14_, _p15_, _p16_, _p17_,\ + _p18_, _p19_, _p20_, _p21_, _p22_, _p23_, _p24_);\ + } + #define make_kernel_lambda_hip_25(\ + kernel_name,\ + p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15,\ + p16, p17, p18, p19, p20, p21, p22, p23)\ + [](const std::decay_t& _p0_,\ + const std::decay_t& _p1_,\ + const std::decay_t& _p2_,\ + const std::decay_t& _p3_,\ + const std::decay_t& _p4_,\ + const std::decay_t& _p5_,\ + const std::decay_t& _p6_,\ + const std::decay_t& _p7_,\ + const std::decay_t& _p8_,\ + const std::decay_t& _p9_,\ + const std::decay_t& _p10_,\ + const std::decay_t& _p11_,\ + const std::decay_t& _p12_,\ + const std::decay_t& _p13_,\ + const std::decay_t& _p14_,\ + const std::decay_t& _p15_,\ + const std::decay_t& _p16_,\ + const std::decay_t& _p17_,\ + const std::decay_t& _p18_,\ + const std::decay_t& _p19_,\ + const std::decay_t& _p20_,\ + const std::decay_t& _p21_,\ + const std::decay_t& _p22_,\ + const std::decay_t& _p23_) [[hc]] {\ + kernel_name(\ + _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_,\ + _p9_, _p10_, _p11_, _p12_, _p13_, _p14_, _p15_, _p16_, _p17_,\ + _p18_, _p19_, _p20_, _p21_, _p22_, _p23_);\ + } + #define make_kernel_lambda_hip_24(\ + kernel_name,\ + p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15,\ + p16, p17, p18, p19, p20, p21, p22)\ + [](const std::decay_t& _p0_,\ + const std::decay_t& _p1_,\ + const std::decay_t& _p2_,\ + const std::decay_t& _p3_,\ + const std::decay_t& _p4_,\ + const std::decay_t& _p5_,\ + const std::decay_t& _p6_,\ + const std::decay_t& _p7_,\ + const std::decay_t& _p8_,\ + const std::decay_t& _p9_,\ + const std::decay_t& _p10_,\ + const std::decay_t& _p11_,\ + const std::decay_t& _p12_,\ + const std::decay_t& _p13_,\ + const std::decay_t& _p14_,\ + const std::decay_t& _p15_,\ + const std::decay_t& _p16_,\ + const std::decay_t& _p17_,\ + const std::decay_t& _p18_,\ + const std::decay_t& _p19_,\ + const std::decay_t& _p20_,\ + const std::decay_t& _p21_,\ + const std::decay_t& _p22_) [[hc]] {\ + kernel_name(\ + _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_,\ + _p9_, _p10_, _p11_, _p12_, _p13_, _p14_, _p15_, _p16_, _p17_,\ + _p18_, _p19_, _p20_, _p21_, _p22_);\ + } + #define make_kernel_lambda_hip_23(\ + kernel_name,\ + p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15,\ + p16, p17, p18, p19, p20, p21)\ + [](const std::decay_t& _p0_,\ + const std::decay_t& _p1_,\ + const std::decay_t& _p2_,\ + const std::decay_t& _p3_,\ + const std::decay_t& _p4_,\ + const std::decay_t& _p5_,\ + const std::decay_t& _p6_,\ + const std::decay_t& _p7_,\ + const std::decay_t& _p8_,\ + const std::decay_t& _p9_,\ + const std::decay_t& _p10_,\ + const std::decay_t& _p11_,\ + const std::decay_t& _p12_,\ + const std::decay_t& _p13_,\ + const std::decay_t& _p14_,\ + const std::decay_t& _p15_,\ + const std::decay_t& _p16_,\ + const std::decay_t& _p17_,\ + const std::decay_t& _p18_,\ + const std::decay_t& _p19_,\ + const std::decay_t& _p20_,\ + const std::decay_t& _p21_) [[hc]] {\ + kernel_name(\ + _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_,\ + _p9_, _p10_, _p11_, _p12_, _p13_, _p14_, _p15_, _p16_, _p17_,\ + _p18_, _p19_, _p20_, _p21_);\ + } + #define make_kernel_lambda_hip_22(\ + kernel_name,\ + p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15,\ + p16, p17, p18, p19, p20)\ + [](const std::decay_t& _p0_,\ + const std::decay_t& _p1_,\ + const std::decay_t& _p2_,\ + const std::decay_t& _p3_,\ + const std::decay_t& _p4_,\ + const std::decay_t& _p5_,\ + const std::decay_t& _p6_,\ + const std::decay_t& _p7_,\ + const std::decay_t& _p8_,\ + const std::decay_t& _p9_,\ + const std::decay_t& _p10_,\ + const std::decay_t& _p11_,\ + const std::decay_t& _p12_,\ + const std::decay_t& _p13_,\ + const std::decay_t& _p14_,\ + const std::decay_t& _p15_,\ + const std::decay_t& _p16_,\ + const std::decay_t& _p17_,\ + const std::decay_t& _p18_,\ + const std::decay_t& _p19_,\ + const std::decay_t& _p20_) [[hc]] {\ + kernel_name(\ + _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_,\ + _p9_, _p10_, _p11_, _p12_, _p13_, _p14_, _p15_, _p16_, _p17_,\ + _p18_, _p19_, _p20_);\ + } #define make_kernel_lambda_hip_21(\ kernel_name,\ p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15,\ @@ -237,7 +397,7 @@ namespace hip_impl kernel_name(\ _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_,\ _p9_, _p10_, _p11_, _p12_, _p13_, _p14_, _p15_, _p16_, _p17_,\ - _p18_, _p19_);\ + _p18_, _p19_);\ } #define make_kernel_lambda_hip_20(\ kernel_name,\ @@ -265,7 +425,7 @@ namespace hip_impl kernel_name(\ _p0_, _p1_, _p2_, _p3_, _p4_, _p5_, _p6_, _p7_, _p8_,\ _p9_, _p10_, _p11_, _p12_, _p13_, _p14_, _p15_, _p16_, _p17_,\ - _p18_);\ + _p18_);\ } #define make_kernel_lambda_hip_19(\ kernel_name,\ diff --git a/projects/hip/include/hip/hcc_detail/helpers.hpp b/projects/hip/include/hip/hcc_detail/helpers.hpp index 566612dce4..f12087faa9 100644 --- a/projects/hip/include/hip/hcc_detail/helpers.hpp +++ b/projects/hip/include/hip/hcc_detail/helpers.hpp @@ -127,11 +127,13 @@ namespace // Only for documentation, macros ignore namespaces. { #define count_macro_args_impl_hip_(\ _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15,\ - _16, _17, _18, _19, _20, _21, _n, ...) _n + _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29,\ + _30, _31, _n, ...)\ + _n #define count_macro_args_hip_(...)\ count_macro_args_impl_hip_(\ - , ##__VA_ARGS__, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9,\ - 8, 7, 6, 5, 4, 3, 2, 1, 0) + , ##__VA_ARGS__, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19,\ + 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) #define overloaded_macro_expand_hip_(macro, arg_cnt) macro##arg_cnt #define overload_macro_impl_hip_(macro, arg_cnt)\ From 4ea7a521e280c6078770086c15bab5089e3f55ba Mon Sep 17 00:00:00 2001 From: emankov Date: Wed, 29 Mar 2017 17:23:41 +0300 Subject: [PATCH 253/281] [HIPIFY] set execute mode for bash scripts [ROCm/hip commit: ec744797ddd9fc054b32243fbde52a25bf82528a] --- projects/hip/bin/hipconvertinplace.sh | 0 projects/hip/bin/hipexamine.sh | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 projects/hip/bin/hipconvertinplace.sh mode change 100644 => 100755 projects/hip/bin/hipexamine.sh diff --git a/projects/hip/bin/hipconvertinplace.sh b/projects/hip/bin/hipconvertinplace.sh old mode 100644 new mode 100755 diff --git a/projects/hip/bin/hipexamine.sh b/projects/hip/bin/hipexamine.sh old mode 100644 new mode 100755 From 7a0c077800f9deb1ae85eda02e89a1f6a818bc42 Mon Sep 17 00:00:00 2001 From: "Sun, Peng" Date: Thu, 30 Mar 2017 13:36:46 -0500 Subject: [PATCH 254/281] Enable GGL as the default kernel launch method Change-Id: I8022d126ee28ff7e4d9a96209e399d4243d39d8b [ROCm/hip commit: cfc2d455e129e1d3a7e17efd0a95ab901247a3c1] --- projects/hip/include/hip/hcc_detail/hip_runtime_api.h | 2 +- projects/hip/include/hip/hcc_detail/host_defines.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h index 658e3d2f97..87e552a6cf 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h @@ -32,7 +32,7 @@ THE SOFTWARE. #include #ifndef GENERIC_GRID_LAUNCH -#define GENERIC_GRID_LAUNCH 0 +#define GENERIC_GRID_LAUNCH 1 #endif #include diff --git a/projects/hip/include/hip/hcc_detail/host_defines.h b/projects/hip/include/hip/hcc_detail/host_defines.h index ab975dbb2c..d077873797 100644 --- a/projects/hip/include/hip/hcc_detail/host_defines.h +++ b/projects/hip/include/hip/hcc_detail/host_defines.h @@ -32,7 +32,7 @@ THE SOFTWARE. // Add guard to Generic Grid Launch method #ifndef GENERIC_GRID_LAUNCH -#define GENERIC_GRID_LAUNCH 0 +#define GENERIC_GRID_LAUNCH 1 #endif #ifdef __HCC__ From a68e89d29b96b4e766e9f1c2590de87af6478197 Mon Sep 17 00:00:00 2001 From: "Sun, Peng" Date: Thu, 30 Mar 2017 15:03:09 -0500 Subject: [PATCH 255/281] update hip_faq.md on using GGL as default Change-Id: I6ce1112eedeac3b377fe55ad8445f3c465c2eed4 [ROCm/hip commit: 8ca0d37a67720d38d1c4ed54b58130691b6c3e25] --- projects/hip/docs/markdown/hip_faq.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/projects/hip/docs/markdown/hip_faq.md b/projects/hip/docs/markdown/hip_faq.md index 5ad8d9e8a9..ee7e5dd347 100644 --- a/projects/hip/docs/markdown/hip_faq.md +++ b/projects/hip/docs/markdown/hip_faq.md @@ -27,6 +27,7 @@ * [Using CodeXL markers for HIP Functions](#using-codexl-markers-for-hip-functions) * [Using HIP_TRACE_API](#using-hip_trace_api) - [How do I enable HIP Generic Grid Launch option?](#how-do-i-enable-hip-generic-grid-launch-option) +- [What is the current limitation of HIP Generic Grid Launch method?](#what-is-the-current-limitation-of-hip-generic-grid-launch-method) @@ -236,11 +237,13 @@ Unlike CUDA, in HCC, for functions defined in the header files, the keyword of " Thus, if failed to define "static" keyword, you might see a lot of "symbol multiply defined!" errors at compilation. The workaround is to explicitly add the keyword of "static" before any functions that were defined as "__forceinline__". -### How do I enable HIP Generic Grid Launch option? -Generic Grid Launch(GGL) provide a second choice for kernel launch. -To enable it, either change the default value of GENERIC_GRID_LAUNCH to 1 in the following to header files and rebuild HIP: +### How do I disable HIP Generic Grid Launch option? +Generic Grid Launch(GGL) is currently the default method for hip kernel launch. +To disable it and use the legancy grid launch method, please either change the default value of GENERIC_GRID_LAUNCH to 0 in the following to header files and rebuild HIP: $HIP/include/hip/hcc_detail/hip_runtime_api.h $HIP/include/hip/hcc_detail/host_defines.h -Or pass "-DGENERIC_GRID_LAUNCH=1" to hipcc at application compilation time. +Or pass "-DGENERIC_GRID_LAUNCH=0" to hipcc at application compilation time. -GGL was only tested with Ubuntu16.04, assuming HCC and HIP only link against libstdc++ but not libc++. +### What is the current limitation of HIP Generic Grid Launch method? +1. __global__ functions cannot be marked as static or put in an unnamed namespace i.e. they cannot be given internal linkage (this would clash with __attribute__((weak))); +2. using the macro based dispatch mechanism i.e. hipLaunchKernel* only works for functions that take no more than 20 arguments (this limit can be increased up to 126, and is temporary until we can enable C++14 mode and use variadic generic lambdas); no such limitation applies do dispatching directly through grid_launch. \ No newline at end of file From 39550b0f4c5e85813aec8defa92bec8ab71fbaaf Mon Sep 17 00:00:00 2001 From: "Sun, Peng" Date: Thu, 30 Mar 2017 17:14:55 -0500 Subject: [PATCH 256/281] fix hipVectorTypesDevice direct test with GGL enabled Change-Id: I7a63b87348f08f094cd709e87397d9e0fc24e4c2 [ROCm/hip commit: c865151e50a6bea5ffab0c1ca4b3fc40f6b99307] --- .../src/deviceLib/hipVectorTypesDevice.cpp | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/projects/hip/tests/src/deviceLib/hipVectorTypesDevice.cpp b/projects/hip/tests/src/deviceLib/hipVectorTypesDevice.cpp index 285b3e889e..265cd00b22 100644 --- a/projects/hip/tests/src/deviceLib/hipVectorTypesDevice.cpp +++ b/projects/hip/tests/src/deviceLib/hipVectorTypesDevice.cpp @@ -3874,7 +3874,22 @@ int main() { assert(sizeof(float2) == 8); assert(sizeof(float3) == 12); assert(sizeof(float4) == 16); - bool *ptr; - hipLaunchKernel(CheckVectorTypes, dim3(1,1,1), dim3(1,1,1), 0, 0, ptr); - passed(); + + bool* ptr = nullptr; + if (hipMalloc(&ptr, sizeof(bool)) != HIP_SUCCESS) return EXIT_FAILURE; + std::unique_ptr correct{ptr, hipFree}; + hipLaunchKernel( + CheckVectorTypes, dim3(1,1,1), dim3(1,1,1), 0, 0, correct.get()); + bool passed = false; + if (hipMemcpyDtoH(&passed, correct.get(), sizeof(bool)) != HIP_SUCCESS) { + return EXIT_FAILURE; + } + + if (passed == true){ + std::cout << "PASSED" << std::endl; + return 0; + } + else + return EXIT_FAILURE; } + From c9dc0cf0105869686a1958d26be81bb0f82a3702 Mon Sep 17 00:00:00 2001 From: "Sun, Peng" Date: Thu, 30 Mar 2017 18:10:17 -0500 Subject: [PATCH 257/281] Rename hipLaunchKernelV3 to hipLaunchKernelGGL Change-Id: I303daae006db41e9b04eb591e0b09b2717a7cf66 [ROCm/hip commit: f4efa422bf668b965315899e61ecd64e835cadf3] --- projects/hip/include/hip/hcc_detail/grid_launch_v2.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/grid_launch_v2.hpp b/projects/hip/include/hip/hcc_detail/grid_launch_v2.hpp index 3d5d5c1ffe..b59cbd01aa 100644 --- a/projects/hip/include/hip/hcc_detail/grid_launch_v2.hpp +++ b/projects/hip/include/hip/hcc_detail/grid_launch_v2.hpp @@ -693,7 +693,7 @@ namespace hip_impl #define make_kernel_lambda_hip_(...)\ overload_macro_hip_(make_kernel_lambda_hip_, __VA_ARGS__) - #define hipLaunchKernelV3(\ + #define hipLaunchKernelGGL(\ kernel_name,\ num_blocks,\ dim_blocks,\ @@ -718,7 +718,7 @@ namespace hip_impl stream,\ ...)\ {\ - hipLaunchKernelV3(\ + hipLaunchKernelGGL(\ kernel_name,\ num_blocks,\ dim_blocks,\ From 799a81029c8224dc984baec6e08800dc60a5bdb0 Mon Sep 17 00:00:00 2001 From: "Sun, Peng" Date: Thu, 30 Mar 2017 18:16:56 -0500 Subject: [PATCH 258/281] remove extra GGL header info Change-Id: I09f0d1b64a7a31eb2e926f19b69b7bafbacc7787 [ROCm/hip commit: 071f19521cea41bca8ecf7ec52c9081054317c01] --- projects/hip/include/hip/hcc_detail/concepts.hpp | 3 --- projects/hip/include/hip/hcc_detail/grid_launch_v2.hpp | 3 --- 2 files changed, 6 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/concepts.hpp b/projects/hip/include/hip/hcc_detail/concepts.hpp index c746c1cfe6..6824ad9bdf 100644 --- a/projects/hip/include/hip/hcc_detail/concepts.hpp +++ b/projects/hip/include/hip/hcc_detail/concepts.hpp @@ -20,9 +20,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -// -// Created by alexv on 25/10/16. -// #pragma once namespace glo_tests // Documentation only. diff --git a/projects/hip/include/hip/hcc_detail/grid_launch_v2.hpp b/projects/hip/include/hip/hcc_detail/grid_launch_v2.hpp index b59cbd01aa..b360d4c19d 100644 --- a/projects/hip/include/hip/hcc_detail/grid_launch_v2.hpp +++ b/projects/hip/include/hip/hcc_detail/grid_launch_v2.hpp @@ -20,9 +20,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -// -// Created by alexv on 25/10/16. -// #pragma once #include "concepts.hpp" From ccf799c453f6253639b07958c80d06406de39735 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Fri, 31 Mar 2017 12:11:34 -0500 Subject: [PATCH 259/281] added new api hipHccModuleLaunchKernel 1. hipHccModuleLaunchKernel is same as hipModuleLaunchKernel with OpenCL workitem model 2. Added copy right 3. Fixed header naming Change-Id: I6a7c35a3566e2f8d3f5056613e34193775d4b236 [ROCm/hip commit: b9091ba8189b245acc936fca403114c1bfb30b37] --- projects/hip/include/hip/channel_descriptor.h | 7 +- projects/hip/include/hip/device_functions.h | 9 +- projects/hip/include/hip/driver_types.h | 13 +- .../hip/hcc_detail/channel_descriptor.h | 6 +- projects/hip/include/hip/hcc_detail/hcc_acc.h | 13 + projects/hip/include/hip/hcc_detail/hip_hcc.h | 62 ++ projects/hip/include/hip/hip_common.h | 7 +- projects/hip/include/hip/hip_complex.h | 7 +- projects/hip/include/hip/hip_fp16.h | 7 +- projects/hip/include/hip/{hcc.h => hip_hcc.h} | 8 +- projects/hip/include/hip/hip_profile.h | 7 +- projects/hip/include/hip/hip_runtime.h | 7 +- projects/hip/include/hip/hip_runtime_api.h | 5 +- projects/hip/include/hip/hip_texture.h | 8 +- projects/hip/include/hip/hip_vector_types.h | 7 +- projects/hip/include/hip/math_functions.h | 7 +- projects/hip/include/hip/texture_types.h | 10 +- .../samples/0_Intro/module_api/runKernel.cpp | 18 +- .../0_Intro/module_api/vcpy_kernel.cpp | 3 +- projects/hip/src/env.cpp | 24 +- projects/hip/src/hip_context.cpp | 4 +- projects/hip/src/hip_device.cpp | 4 +- projects/hip/src/hip_error.cpp | 4 +- projects/hip/src/hip_event.cpp | 4 +- projects/hip/src/hip_hcc.cpp | 8 +- projects/hip/src/hip_hcc_internal.h | 885 ++++++++++++++++++ projects/hip/src/hip_memory.cpp | 12 +- projects/hip/src/hip_module.cpp | 65 +- projects/hip/src/hip_peer.cpp | 4 +- projects/hip/src/hip_stream.cpp | 4 +- 30 files changed, 1138 insertions(+), 91 deletions(-) create mode 100644 projects/hip/include/hip/hcc_detail/hip_hcc.h rename projects/hip/include/hip/{hcc.h => hip_hcc.h} (85%) create mode 100644 projects/hip/src/hip_hcc_internal.h diff --git a/projects/hip/include/hip/channel_descriptor.h b/projects/hip/include/hip/channel_descriptor.h index af8875e256..b8e750b079 100644 --- a/projects/hip/include/hip/channel_descriptor.h +++ b/projects/hip/include/hip/channel_descriptor.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,7 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#pragma once +#ifndef HIP_INCLUDE_HIP_CHANNEL_DESCRIPTOR_H +#define HIP_INCLUDE_HIP_CHANNEL_DESCRIPTOR_H // Some standard header files, these are included by hc.hpp and so want to make them avail on both // paths to provide a consistent include env and avoid "missing symbol" errors that only appears @@ -34,3 +35,5 @@ THE SOFTWARE. #else #error("Must define exactly one of __HIP_PLATFORM_HCC__ or __HIP_PLATFORM_NVCC__"); #endif + +#endif diff --git a/projects/hip/include/hip/device_functions.h b/projects/hip/include/hip/device_functions.h index 24211b7d2d..aae6775d48 100644 --- a/projects/hip/include/hip/device_functions.h +++ b/projects/hip/include/hip/device_functions.h @@ -1,13 +1,16 @@ /* -Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -17,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef HIP_DEVICE_FUNCTIONS_H -#define HIP_DEVICE_FUNCTIONS_H +#ifndef HIP_INCLUDE_HIP_DEVICE_FUNCTIONS_H +#define HIP_INCLUDE_HIP_DEVICE_FUNCTIONS_H #include diff --git a/projects/hip/include/hip/driver_types.h b/projects/hip/include/hip/driver_types.h index a4010d6b4e..5d06457dd5 100644 --- a/projects/hip/include/hip/driver_types.h +++ b/projects/hip/include/hip/driver_types.h @@ -1,22 +1,27 @@ /* -Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#pragma once +#ifndef HIP_INCLUDE_HIP_DRIVER_TYPES_H +#define HIP_INCLUDE_HIP_DRIVER_TYPES_H #include @@ -27,3 +32,5 @@ THE SOFTWARE. #else #error("Must define exactly one of __HIP_PLATFORM_HCC__ or __HIP_PLATFORM_NVCC__"); #endif + +#endif diff --git a/projects/hip/include/hip/hcc_detail/channel_descriptor.h b/projects/hip/include/hip/hcc_detail/channel_descriptor.h index 85689438e2..4be023f6ca 100644 --- a/projects/hip/include/hip/hcc_detail/channel_descriptor.h +++ b/projects/hip/include/hip/hcc_detail/channel_descriptor.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef HIP_HCC_DETAIL_CHANNEL_DESCRIPTOR_H -#define HIP_HCC_DETAIL_CHANNEL_DESCRIPTOR_H +#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_CHANNEL_DESCRIPTOR_H +#define HIP_INCLUDE_HIP_HCC_DETAIL_CHANNEL_DESCRIPTOR_H #include #include diff --git a/projects/hip/include/hip/hcc_detail/hcc_acc.h b/projects/hip/include/hip/hcc_detail/hcc_acc.h index c36acc52f5..962f795d6f 100644 --- a/projects/hip/include/hip/hcc_detail/hcc_acc.h +++ b/projects/hip/include/hip/hcc_detail/hcc_acc.h @@ -40,6 +40,19 @@ hipError_t hipHccGetAccelerator(int deviceId, hc::accelerator *acc); * @return #hipSuccess */ hipError_t hipHccGetAcceleratorView(hipStream_t stream, hc::accelerator_view **av); + + +hipError_t hipHccModuleLaunchKernel(hipFunction_t f, + uint32_t globalWorkSizeX, + uint32_t globalWorkSizeY, + uint32_t globalWorkSizeZ, + uint32_t localWorkSizeX, + uint32_t localWorkSizeY, + uint32_t localWorkSizeZ, + size_t sharedMemBytes, + hipStream_t hStream, + void **kernelParams, + void **extra); #endif #endif diff --git a/projects/hip/include/hip/hcc_detail/hip_hcc.h b/projects/hip/include/hip/hcc_detail/hip_hcc.h new file mode 100644 index 0000000000..645e980376 --- /dev/null +++ b/projects/hip/include/hip/hcc_detail/hip_hcc.h @@ -0,0 +1,62 @@ +/* +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_HIP_HCC_H +#define HIP_INCLUDE_HIP_HCC_DETAIL_HIP_HCC_H + +#include "hip/hip_runtime_api.h" + +#if __cplusplus +#ifdef __HCC__ +#include +/** + * @brief Return hc::accelerator associated with the specified deviceId + * @return #hipSuccess, #hipErrorInvalidDevice + */ +hipError_t hipHccGetAccelerator(int deviceId, hc::accelerator *acc); + +/** + * @brief Return hc::accelerator_view associated with the specified stream + * + * If stream is 0, the accelerator_view for the default stream is returned. + * @return #hipSuccess + */ +hipError_t hipHccGetAcceleratorView(hipStream_t stream, hc::accelerator_view **av); + + +#endif // #ifdef __HCC__ + +hipError_t hipHccModuleLaunchKernel(hipFunction_t f, + uint32_t globalWorkSizeX, + uint32_t globalWorkSizeY, + uint32_t globalWorkSizeZ, + uint32_t localWorkSizeX, + uint32_t localWorkSizeY, + uint32_t localWorkSizeZ, + size_t sharedMemBytes, + hipStream_t hStream, + void **kernelParams, + void **extra); + +#endif // #if __cplusplus + +#endif // diff --git a/projects/hip/include/hip/hip_common.h b/projects/hip/include/hip/hip_common.h index 6317a792ee..da8ec4a55d 100644 --- a/projects/hip/include/hip/hip_common.h +++ b/projects/hip/include/hip/hip_common.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,7 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#pragma once +#ifndef HIP_INCLUDE_HIP_HIP_COMMON_H +#define HIP_INCLUDE_HIP_HIP_COMMON_H // Common code included at start of every hip file. // Auto enable __HIP_PLATFORM_HCC__ if compiling with HCC @@ -73,3 +74,5 @@ THE SOFTWARE. #define __HIP_ARCH_HAS_3DGRID__ (0) #define __HIP_ARCH_HAS_DYNAMIC_PARALLEL__ (0) #endif + +#endif diff --git a/projects/hip/include/hip/hip_complex.h b/projects/hip/include/hip/hip_complex.h index ea15137894..dc691be480 100644 --- a/projects/hip/include/hip/hip_complex.h +++ b/projects/hip/include/hip/hip_complex.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,7 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#pragma once +#ifndef HIP_INCLUDE_HIP_HIP_COMPLEX_H +#define HIP_INCLUDE_HIP_HIP_COMPLEX_H #include @@ -31,3 +32,5 @@ THE SOFTWARE. #else #error("Must define exactly one of __HIP_PLATFORM_HCC__ or __HIP_PLATFORM_NVCC__"); #endif + +#endif diff --git a/projects/hip/include/hip/hip_fp16.h b/projects/hip/include/hip/hip_fp16.h index 2f64c1a143..0e002d9396 100644 --- a/projects/hip/include/hip/hip_fp16.h +++ b/projects/hip/include/hip/hip_fp16.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,7 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#pragma once +#ifdef HIP_INCLUDE_HIP_HIP_FP16_H +#define HIP_INCLUDE_HIP_HIP_FP16_H #include @@ -31,3 +32,5 @@ THE SOFTWARE. #else #error("Must define exactly one of __HIP_PLATFORM_HCC__ or __HIP_PLATFORM_NVCC__"); #endif + +#endif diff --git a/projects/hip/include/hip/hcc.h b/projects/hip/include/hip/hip_hcc.h similarity index 85% rename from projects/hip/include/hip/hcc.h rename to projects/hip/include/hip/hip_hcc.h index 9b8a649412..3407a311bd 100644 --- a/projects/hip/include/hip/hcc.h +++ b/projects/hip/include/hip/hip_hcc.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,11 +20,11 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef HIP_HCC_H -#define HIP_HCC_H +#ifndef HIP_INCLUDE_HIP_HIP_HCC_H +#define HIP_INCLUDE_HIP_HIP_HCC_H #if defined(__HIP_PLATFORM_HCC__) && !defined (__HIP_PLATFORM_NVCC__) -#include "hip/hcc_detail/hcc_acc.h" +#include "hip/hcc_detail/hip_hcc.h" #endif #endif diff --git a/projects/hip/include/hip/hip_profile.h b/projects/hip/include/hip/hip_profile.h index e621ae8c79..389f334c74 100644 --- a/projects/hip/include/hip/hip_profile.h +++ b/projects/hip/include/hip/hip_profile.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,7 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#pragma once +#ifndef HIP_INCLUDE_HIP_HIP_PROFILE_H +#define HIP_INCLUDE_HIP_HIP_PROFILE_H #if not defined (ENABLE_HIP_PROFILE) #define ENABLE_HIP_PROFILE 1 @@ -36,3 +37,5 @@ THE SOFTWARE. #define HIP_BEGIN_MARKER(markerName, group) #define HIP_END_MARKER() #endif + +#endif diff --git a/projects/hip/include/hip/hip_runtime.h b/projects/hip/include/hip/hip_runtime.h index 9bc45f300d..fba4d46d8f 100644 --- a/projects/hip/include/hip/hip_runtime.h +++ b/projects/hip/include/hip/hip_runtime.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -33,7 +33,8 @@ THE SOFTWARE. //! hip_runtime.h : includes everything in hip_api.h, plus math builtins and kernel launch macros. //! hip_runtime_api.h : Defines HIP API. This is a C header file and does not use any C++ features. -#pragma once +#ifndef HIP_INCLUDE_HIP_HIP_RUNTIME_H +#define HIP_INCLUDE_HIP_HIP_RUNTIME_H // Some standard header files, these are included by hc.hpp and so want to make them avail on both // paths to provide a consistent include env and avoid "missing symbol" errors that only appears @@ -61,3 +62,5 @@ THE SOFTWARE. #include #include + +#endif diff --git a/projects/hip/include/hip/hip_runtime_api.h b/projects/hip/include/hip/hip_runtime_api.h index 818c0b7c34..5715be0599 100644 --- a/projects/hip/include/hip/hip_runtime_api.h +++ b/projects/hip/include/hip/hip_runtime_api.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -27,7 +27,8 @@ THE SOFTWARE. * This file can be compiled with a standard compiler. */ -#pragma once +#ifndef HIP_INCLUDE_HIP_HIP_RUNTIME_API_H +#define HIP_INCLUDE_HIP_HIP_RUNTIME_API_H #include // for getDeviceProp diff --git a/projects/hip/include/hip/hip_texture.h b/projects/hip/include/hip/hip_texture.h index 66ec4a6ca1..a15c5a1016 100644 --- a/projects/hip/include/hip/hip_texture.h +++ b/projects/hip/include/hip/hip_texture.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,10 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - - -#ifndef HIP_HIP_TEXTURE_H -#define HIP_HIP_TEXTURE_H +#ifndef HIP_INCLUDE_HIP_HIP_TEXTURE_H +#define HIP_INCLUDE_HIP_HIP_TEXTURE_H #if defined(__HIP_PLATFORM_HCC__) && !defined (__HIP_PLATFORM_NVCC__) #include diff --git a/projects/hip/include/hip/hip_vector_types.h b/projects/hip/include/hip/hip_vector_types.h index 33827e4d96..1d3d6b92f6 100644 --- a/projects/hip/include/hip/hip_vector_types.h +++ b/projects/hip/include/hip/hip_vector_types.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -22,7 +22,8 @@ THE SOFTWARE. //! hip_vector_types.h : Defines the HIP vector types. -#pragma once +#ifndef HIP_INCLUDE_HIP_HIP_VECTOR_TYPES_H +#define HIP_INCLUDE_HIP_HIP_VECTOR_TYPES_H #include @@ -36,3 +37,5 @@ THE SOFTWARE. #else #error("Must define exactly one of __HIP_PLATFORM_HCC__ or __HIP_PLATFORM_NVCC__"); #endif + +#endif diff --git a/projects/hip/include/hip/math_functions.h b/projects/hip/include/hip/math_functions.h index ebcdc26749..6f47b5e0e2 100644 --- a/projects/hip/include/hip/math_functions.h +++ b/projects/hip/include/hip/math_functions.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,7 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#pragma once +#ifndef HIP_INCLUDE_HIP_MATH_FUNCTIONS_H +#define HIP_INCLUDE_HIP_MATH_FUNCTIONS_H // Some standard header files, these are included by hc.hpp and so want to make them avail on both // paths to provide a consistent include env and avoid "missing symbol" errors that only appears @@ -34,3 +35,5 @@ THE SOFTWARE. #else #error("Must define exactly one of __HIP_PLATFORM_HCC__ or __HIP_PLATFORM_NVCC__"); #endif + +#endif diff --git a/projects/hip/include/hip/texture_types.h b/projects/hip/include/hip/texture_types.h index 2561e12eb5..ca6101cf79 100644 --- a/projects/hip/include/hip/texture_types.h +++ b/projects/hip/include/hip/texture_types.h @@ -1,13 +1,16 @@ /* -Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -17,7 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#pragma once +#ifndef HIP_INCLUDE_HIP_TEXTURE_TYPES_H +#define HIP_INCLUDE_HIP_TEXTURE_TYPES_H #include @@ -28,3 +32,5 @@ THE SOFTWARE. #else #error("Must define exactly one of __HIP_PLATFORM_HCC__ or __HIP_PLATFORM_NVCC__"); #endif + +#endif diff --git a/projects/hip/samples/0_Intro/module_api/runKernel.cpp b/projects/hip/samples/0_Intro/module_api/runKernel.cpp index 201892a4a1..e7d54beb54 100644 --- a/projects/hip/samples/0_Intro/module_api/runKernel.cpp +++ b/projects/hip/samples/0_Intro/module_api/runKernel.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -22,9 +22,10 @@ THE SOFTWARE. #include "hip/hip_runtime.h" #include "hip/hip_runtime_api.h" -#include -#include -#include +#include +#include +#include +#include #define LEN 64 #define SIZE LEN<<2 @@ -43,10 +44,10 @@ int main(){ B[i] = 0.0f; } - hipInit(0); - hipDevice_t device; - hipCtx_t context; - hipDeviceGet(&device, 0); + hipInit(0); + hipDevice_t device; + hipCtx_t context; + hipDeviceGet(&device, 0); hipCtxCreate(&context, 0, device); hipMalloc((void**)&Ad, SIZE); @@ -101,6 +102,7 @@ int main(){ hipModuleLaunchKernel(Function, 1, 1, 1, LEN, 1, 1, 0, 0, NULL, (void**)&config); hipMemcpyDtoH(B, Bd, SIZE); + int mismatchCount = 0; for(uint32_t i=0;i #include "hip/hip_runtime.h" -#include "hip_hcc.h" +#include "hip_hcc_internal.h" #include "trace_helper.h" // Stack of contexts diff --git a/projects/hip/src/hip_device.cpp b/projects/hip/src/hip_device.cpp index d3c68e6fdf..88d94411e8 100644 --- a/projects/hip/src/hip_device.cpp +++ b/projects/hip/src/hip_device.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -21,7 +21,7 @@ THE SOFTWARE. */ #include "hip/hip_runtime.h" -#include "hip_hcc.h" +#include "hip_hcc_internal.h" #include "trace_helper.h" #include "device_util.h" diff --git a/projects/hip/src/hip_error.cpp b/projects/hip/src/hip_error.cpp index 4c14ba4156..21d5b6aa85 100644 --- a/projects/hip/src/hip_error.cpp +++ b/projects/hip/src/hip_error.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -21,7 +21,7 @@ THE SOFTWARE. */ #include "hip/hip_runtime.h" -#include "hip_hcc.h" +#include "hip_hcc_internal.h" #include "trace_helper.h" //------------------------------------------------------------------------------------------------- diff --git a/projects/hip/src/hip_event.cpp b/projects/hip/src/hip_event.cpp index 5a0ed9d8f8..d44f201db5 100644 --- a/projects/hip/src/hip_event.cpp +++ b/projects/hip/src/hip_event.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -21,7 +21,7 @@ THE SOFTWARE. */ #include "hip/hip_runtime.h" -#include "hip_hcc.h" +#include "hip_hcc_internal.h" #include "trace_helper.h" //------------------------------------------------------------------------------------------------- diff --git a/projects/hip/src/hip_hcc.cpp b/projects/hip/src/hip_hcc.cpp index e422a6d4db..374840f91f 100644 --- a/projects/hip/src/hip_hcc.cpp +++ b/projects/hip/src/hip_hcc.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -43,7 +43,7 @@ THE SOFTWARE. #include "hsa/hsa_ext_amd.h" #include "hip/hip_runtime.h" -#include "hip_hcc.h" +#include "hip_hcc_internal.h" #include "trace_helper.h" #include "env.h" @@ -762,7 +762,7 @@ hipError_t ihipDevice_t::initProperties(hipDeviceProp_t* prop) err = hsa_agent_get_info(_hsaAgent, (hsa_agent_info_t)HSA_AMD_AGENT_INFO_PRODUCT_NAME, &(prop->name)); char archName[256]; err = hsa_agent_get_info(_hsaAgent, HSA_AGENT_INFO_NAME, &archName); - + if(strcmp(archName,"gfx701")==0){ prop->gcnArch = 701; } @@ -1805,7 +1805,7 @@ void ihipStream_t::resolveHcMemcpyDirection(unsigned hipMemKind, void printPointerInfo(unsigned dbFlag, const char *tag, const void *ptr, const hc::AmPointerInfo &ptrInfo) { tprintf (dbFlag, " %s=%p baseHost=%p baseDev=%p sz=%zu home_dev=%d tracked=%d isDevMem=%d registered=%d\n", - tag, ptr, + tag, ptr, ptrInfo._hostPointer, ptrInfo._devicePointer, ptrInfo._sizeBytes, ptrInfo._appId, ptrInfo._sizeBytes != 0, ptrInfo._isInDeviceMem, !ptrInfo._isAmManaged); } diff --git a/projects/hip/src/hip_hcc_internal.h b/projects/hip/src/hip_hcc_internal.h new file mode 100644 index 0000000000..245f154305 --- /dev/null +++ b/projects/hip/src/hip_hcc_internal.h @@ -0,0 +1,885 @@ +/* +Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#ifndef HIP_HCC_H +#define HIP_HCC_H + +#include +#include +#include "hsa/hsa_ext_amd.h" + +#include "hip/hip_runtime.h" +#include "hip_util.h" +#include "env.h" + + +#if defined(__HCC__) && (__hcc_workweek__ < 16354) +#error("This version of HIP requires a newer version of HCC."); +#endif + +#define USE_IPC 1 + +//--- +// Environment variables: + +// Intended to distinguish whether an environment variable should be visible only in debug mode, or in debug+release. +//static const int debug = 0; +extern const int release; + +// TODO - this blocks both kernels and memory ops. Perhaps should have separate env var for kernels? +extern int HIP_LAUNCH_BLOCKING; +extern int HIP_API_BLOCKING; + +extern int HIP_PRINT_ENV; +extern int HIP_PROFILE_API; +//extern int HIP_TRACE_API; +extern int HIP_ATP; +extern int HIP_DB; +extern int HIP_STAGING_SIZE; /* size of staging buffers, in KB */ +extern int HIP_STREAM_SIGNALS; /* number of signals to allocate at stream creation */ +extern int HIP_VISIBLE_DEVICES; /* Contains a comma-separated sequence of GPU identifiers */ +extern int HIP_FORCE_P2P_HOST; + +extern int HIP_COHERENT_HOST_ALLOC; + + +//--- +// Chicken bits for disabling functionality to work around potential issues: +extern int HIP_SYNC_HOST_ALLOC; + +// TODO - remove when this is standard behavior. +extern int HCC_OPT_FLUSH; + + +// Class to assign a short TID to each new thread, for HIP debugging purposes. +class TidInfo { +public: + + TidInfo() ; + + int tid() const { return _shortTid; }; + uint64_t incApiSeqNum() { return ++_apiSeqNum; }; + uint64_t apiSeqNum() const { return _apiSeqNum; }; + +private: + int _shortTid; + + // monotonically increasing API sequence number for this threa. + uint64_t _apiSeqNum; +}; + +struct ProfTrigger { + + static const uint64_t MAX_TRIGGER = std::numeric_limits::max(); + + void print (int tid) { + std::cout << "Enabling tracing for "; + for (auto iter=_profTrigger.begin(); iter != _profTrigger.end(); iter++) { + std::cout << "tid:" << tid << "." << *iter << ","; + } + std::cout << "\n"; + }; + + uint64_t nextTrigger() { return _profTrigger.empty() ? MAX_TRIGGER : _profTrigger.back(); }; + void add(uint64_t trigger) { _profTrigger.push_back(trigger); }; + void sort() { std::sort (_profTrigger.begin(), _profTrigger.end(), std::greater()); }; +private: + std::vector _profTrigger; +}; + + + +//--- +//Extern tls +extern thread_local hipError_t tls_lastHipError; +extern thread_local TidInfo tls_tidInfo; + +extern std::vector g_dbStartTriggers; +extern std::vector g_dbStopTriggers; + +//--- +//Forward defs: +class ihipStream_t; +class ihipDevice_t; +class ihipCtx_t; + +// Color defs for debug messages: +#define KNRM "\x1B[0m" +#define KRED "\x1B[31m" +#define KGRN "\x1B[32m" +#define KYEL "\x1B[33m" +#define KBLU "\x1B[34m" +#define KMAG "\x1B[35m" +#define KCYN "\x1B[36m" +#define KWHT "\x1B[37m" + +extern const char *API_COLOR; +extern const char *API_COLOR_END; + + +// If set, thread-safety is enforced on all stream functions. +// Stream functions will acquire a mutex before entering critical sections. +#define STREAM_THREAD_SAFE 1 + + +#define CTX_THREAD_SAFE 1 + +#define DEVICE_THREAD_SAFE 1 + + +// Compile debug trace mode - this prints debug messages to stderr when env var HIP_DB is set. +// May be set to 0 to remove debug if checks - possible code size and performance difference? +#define COMPILE_HIP_DB 1 + + +// Compile HIP tracing capability. +// 0x1 = print a string at function entry with arguments. +// 0x2 = prints a simple message with function name + return code when function exits. +// 0x3 = print both. +// Must be enabled at runtime with HIP_TRACE_API +#define COMPILE_HIP_TRACE_API 0x3 + + +// Compile code that generates trace markers for CodeXL ATP at HIP function begin/end. +// ATP is standard CodeXL format that includes timestamps for kernels, HSA RT APIs, and HIP APIs. +#ifndef COMPILE_HIP_ATP_MARKER +#define COMPILE_HIP_ATP_MARKER 0 +#endif + + + + +// Compile support for trace markers that are displayed on CodeXL GUI at start/stop of each function boundary. +// TODO - currently we print the trace message at the beginning. if we waited, we could also tls_tidInfo return codes, and any values returned +// through ptr-to-args (ie the pointers allocated by hipMalloc). +#if COMPILE_HIP_ATP_MARKER +#include "CXLActivityLogger.h" +#define MARKER_BEGIN(markerName,group) amdtBeginMarker(markerName, group, nullptr); +#define MARKER_END() amdtEndMarker(); +#define RESUME_PROFILING amdtResumeProfiling(AMDT_ALL_PROFILING); +#define STOP_PROFILING amdtStopProfiling(AMDT_ALL_PROFILING); +#else +// Swallow scoped markers: +#define MARKER_BEGIN(markerName,group) +#define MARKER_END() +#define RESUME_PROFILING +#define STOP_PROFILING +#endif + + +//--- +//HIP Trace modes +#define TRACE_ALL 0 // 0x1 +#define TRACE_CMD 1 // 0x2 +#define TRACE_MEM 2 // 0x4 + + +//--- +//HIP_DB Debug flags: +#define DB_API 0 /* 0x01 - shortcut to enable HIP_TRACE_API on single switch */ +#define DB_SYNC 1 /* 0x02 - trace synchronization pieces */ +#define DB_MEM 2 /* 0x04 - trace memory allocation / deallocation */ +#define DB_COPY 3 /* 0x08 - trace memory copy and peer commands. . */ +#define DB_MAX_FLAG 4 +// When adding a new debug flag, also add to the char name table below. +// +// + +struct DbName { + const char *_color; + const char *_shortName; +}; + +// This table must be kept in-sync with the defines above. +static const DbName dbName [] = +{ + {KGRN, "api"}, // not used, + {KYEL, "sync"}, + {KCYN, "mem"}, + {KMAG, "copy"}, +}; + + + +#if COMPILE_HIP_DB +#define tprintf(trace_level, ...) {\ + if (HIP_DB & (1<<(trace_level))) {\ + char msgStr[1000];\ + snprintf(msgStr, 2000, __VA_ARGS__);\ + fprintf (stderr, " %ship-%s tid:%d:%s%s", dbName[trace_level]._color, dbName[trace_level]._shortName, tls_tidInfo.tid(), msgStr, KNRM); \ + }\ +} +#else +/* Compile to empty code */ +#define tprintf(trace_level, ...) +#endif + + + + +//--- +extern void recordApiTrace(std::string *fullStr, const std::string &apiStr); + +#if COMPILE_HIP_ATP_MARKER || (COMPILE_HIP_TRACE_API & 0x1) +#define API_TRACE(forceTrace, ...)\ +{\ + tls_tidInfo.incApiSeqNum();\ + if (forceTrace || (HIP_PROFILE_API || (COMPILE_HIP_DB && (HIP_TRACE_API & (1<>%s\n", (localHipStatus == 0) ? API_COLOR:KRED, tls_tidInfo.tid(),tls_tidInfo.apiSeqNum(), __func__, localHipStatus, ihipErrorString(localHipStatus), API_COLOR_END);\ + }\ + if (HIP_PROFILE_API) { MARKER_END(); }\ + localHipStatus;\ + }) + + + + + + +class ihipException : public std::exception +{ +public: + ihipException(hipError_t e) : _code(e) {}; + + hipError_t _code; +}; + + +#ifdef __cplusplus +extern "C" { +#endif + + +#ifdef __cplusplus +} +#endif + +const hipStream_t hipStreamNull = 0x0; + + +/** + * HIP IPC Handle Size + */ +#define HIP_IPC_RESERVED_SIZE 24 +class ihipIpcMemHandle_t +{ +public: +#if USE_IPC + hsa_amd_ipc_memory_t ipc_handle; ///< ipc memory handle on ROCr +#endif + size_t psize; + char reserved[HIP_IPC_RESERVED_SIZE]; +}; + + +class ihipModule_t { +public: + hsa_executable_t executable; + hsa_code_object_t object; + std::string fileName; + void *ptr; + size_t size; + std::list funcTrack; + ihipModule_t() : executable(), object(), fileName(), ptr(nullptr), size(0) {} +}; + + +//--- +// Used to remove lock, for performance or stimulating bugs. +class FakeMutex +{ + public: + void lock() { } + bool try_lock() {return true; } + void unlock() { } +}; + + +#if STREAM_THREAD_SAFE +typedef std::mutex StreamMutex; +#else +#warning "Stream thread-safe disabled" +typedef FakeMutex StreamMutex; +#endif + +// Pair Device and Ctx together, these could also be toggled separately if desired. +#if CTX_THREAD_SAFE +typedef std::mutex CtxMutex; +#else +typedef FakeMutex CtxMutex; +#warning "Ctx thread-safe disabled" +#endif + +#if DEVICE_THREAD_SAFE +typedef std::mutex DeviceMutex; +#else +typedef FakeMutex DeviceMutex; +#warning "Device thread-safe disabled" +#endif + +// +//--- +// Protects access to the member _data with a lock acquired on contruction/destruction. +// T must contain a _mutex field which meets the BasicLockable requirements (lock/unlock) +template +class LockedAccessor +{ +public: + LockedAccessor(T &criticalData, bool autoUnlock=true) : + _criticalData(&criticalData), + _autoUnlock(autoUnlock) + + { + tprintf(DB_SYNC, "locking criticalData=%p for %s..\n", _criticalData, ToString(_criticalData->_parent).c_str()); + _criticalData->_mutex.lock(); + }; + + ~LockedAccessor() + { + if (_autoUnlock) { + tprintf(DB_SYNC, "auto-unlocking criticalData=%p for %s...\n", _criticalData, ToString(_criticalData->_parent).c_str()); + _criticalData->_mutex.unlock(); + } + } + + void unlock() + { + tprintf(DB_SYNC, "unlocking criticalData=%p for %s...\n", _criticalData, ToString(_criticalData->_parent).c_str()); + _criticalData->_mutex.unlock(); + } + + // Syntactic sugar so -> can be used to get the underlying type. + T *operator->() { return _criticalData; }; + +private: + T *_criticalData; + bool _autoUnlock; +}; + + +template +struct LockedBase { + + // Experts-only interface for explicit locking. + // Most uses should use the lock-accessor. + void lock() { _mutex.lock(); } + void unlock() { _mutex.unlock(); } + bool try_lock() { return _mutex.try_lock(); } + + MUTEX_TYPE _mutex; +}; + + +template +class ihipStreamCriticalBase_t : public LockedBase +{ +public: + ihipStreamCriticalBase_t(ihipStream_t *parentStream, hc::accelerator_view av) : + _kernelCnt(0), + _av(av), + _hasQueue(true), + _parent(parentStream) + { + }; + + ~ihipStreamCriticalBase_t() { + } + + ihipStreamCriticalBase_t * mlock() { LockedBase::lock(); return this;}; + + void munlock() { + tprintf(DB_SYNC, "munlocking criticalData=%p for %s...\n", this, ToString(this->_parent).c_str()); + LockedBase::unlock(); + }; + + ihipStreamCriticalBase_t * mtry_lock() { + bool gotLock = LockedBase::try_lock() ; + tprintf(DB_SYNC, "mtry_locking=%d criticalData=%p for %s...\n", gotLock, this, ToString(this->_parent).c_str()); + return gotLock ? this: nullptr; + }; + +public: + ihipStream_t * _parent; + uint32_t _kernelCnt; // Count of inflight kernels in this stream. Reset at ::wait(). + + hc::accelerator_view _av; + + // True if the stream has an allocated queue (accelerato_view) for its use: + // Always true at ihipStream creation but queue may later be stolen. + // This acts as a valid bit for the _av. + bool _hasQueue; +private: +}; + + +// if HIP code needs to acquire locks for both ihipCtx_t and ihipStream_t, it should first acquire the lock +// for the ihipCtx_t and then for the individual streams. The locks should not be acquired in reverse order +// or deadlock may occur. In some cases, it may be possible to reduce the range where the locks must be held. +// HIP routines should avoid acquiring and releasing the same lock during the execution of a single HIP API. +// Another option is to use try_lock in the innermost lock query. + + +typedef ihipStreamCriticalBase_t ihipStreamCritical_t; +typedef LockedAccessor LockedAccessor_StreamCrit_t; + +//--- +// Internal stream structure. +class ihipStream_t { +public: + enum ScheduleMode {Auto, Spin, Yield}; + typedef uint64_t SeqNum_t ; + + // TODOD -make av a reference to avoid shared_ptr overhead? + ihipStream_t(ihipCtx_t *ctx, hc::accelerator_view av, unsigned int flags); + ~ihipStream_t(); + + // kind is hipMemcpyKind + void locked_copySync (void* dst, const void* src, size_t sizeBytes, unsigned kind, bool resolveOn = true); + void locked_copyAsync(void* dst, const void* src, size_t sizeBytes, unsigned kind); + + void lockedSymbolCopySync(hc::accelerator &acc, void *dst, void* src, size_t sizeBytes, size_t offset, unsigned kind); + void lockedSymbolCopyAsync(hc::accelerator &acc, void *dst, void* src, size_t sizeBytes, size_t offset, unsigned kind); + + //--- + // Member functions that begin with locked_ are thread-safe accessors - these acquire / release the critical mutex. + LockedAccessor_StreamCrit_t lockopen_preKernelCommand(); + void lockclose_postKernelCommand(const char *kernelName, hc::accelerator_view *av); + + + void locked_wait(); + + hc::accelerator_view* locked_getAv() { LockedAccessor_StreamCrit_t crit(_criticalData); return &(crit->_av); }; + + void locked_waitEvent(hipEvent_t event); + void locked_recordEvent(hipEvent_t event); + + + //--- + + // Use this if we already have the stream critical data mutex: + void wait(LockedAccessor_StreamCrit_t &crit); + + void launchModuleKernel(hc::accelerator_view av, hsa_signal_t signal, + uint32_t blockDimX, uint32_t blockDimY, uint32_t blockDimZ, + uint32_t gridDimX, uint32_t gridDimY, uint32_t gridDimZ, + uint32_t groupSegmentSize, uint32_t sharedMemBytes, + void *kernarg, size_t kernSize, uint64_t kernel); + + + + //-- Non-racy accessors: + // These functions access fields set at initialization time and are non-racy (so do not acquire mutex) + const ihipDevice_t * getDevice() const; + ihipCtx_t * getCtx() const; + + void ensureHaveQueue(LockedAccessor_StreamCrit_t &streamCrit); + +public: + //--- + //Public member vars - these are set at initialization and never change: + SeqNum_t _id; // monotonic sequence ID + unsigned _flags; + + +private: + + + // The unsigned return is hipMemcpyKind + unsigned resolveMemcpyDirection(bool srcInDeviceMem, bool dstInDeviceMem); + void resolveHcMemcpyDirection(unsigned hipMemKind, + const hc::AmPointerInfo *dstPtrInfo, const hc::AmPointerInfo *srcPtrInfo, + hc::hcCommandKind *hcCopyDir, + ihipCtx_t **copyDevice, + bool *forceUnpinnedCopy); + + bool canSeeMemory(const ihipCtx_t *thisCtx, const hc::AmPointerInfo *dstInfo, const hc::AmPointerInfo *srcInfo); + + void addSymbolPtrToTracker(hc::accelerator& acc, void* ptr, size_t sizeBytes); + +public: // TODO - move private + // Critical Data - MUST be accessed through LockedAccessor_StreamCrit_t + ihipStreamCritical_t _criticalData; + +private: // Data + + std::mutex _hasQueueLock; + + ihipCtx_t *_ctx; // parent context that owns this stream. + + // Friends: + friend std::ostream& operator<<(std::ostream& os, const ihipStream_t& s); + friend hipError_t hipStreamQuery(hipStream_t); + + ScheduleMode _scheduleMode; +}; + + + +//---- +// Internal event structure: +enum hipEventStatus_t { + hipEventStatusUnitialized = 0, // event is unutilized, must be "Created" before use. + hipEventStatusCreated = 1, + hipEventStatusRecording = 2, // event has been enqueued to record something. + hipEventStatusRecorded = 3, // event has been recorded - timestamps are valid. +} ; + + +// internal hip event structure. +struct ihipEvent_t { + hipEventStatus_t _state; + + hipStream_t _stream; // Stream where the event is recorded, or NULL if all streams. + unsigned _flags; + + hc::completion_future _marker; + uint64_t _timestamp; // store timestamp, may be set on host or by marker. +} ; + + + +//============================================================================= +//class ihipDeviceCriticalBase_t +template +class ihipDeviceCriticalBase_t : LockedBase +{ +public: + ihipDeviceCriticalBase_t(ihipDevice_t *parentDevice) : + _parent(parentDevice) + { + }; + + ~ihipDeviceCriticalBase_t() { + + } + + // Contexts: + void addContext(ihipCtx_t *ctx); + void removeContext(ihipCtx_t *ctx); + std::list &ctxs() { return _ctxs; }; + const std::list &const_ctxs() const { return _ctxs; }; + int getcount() {return _ctxCount;}; + friend class LockedAccessor; +private: + ihipDevice_t *_parent; + + //--- Context Tracker: + std::list< ihipCtx_t* > _ctxs; // contexts associated with this device across all threads. + + int _ctxCount; +}; + +typedef ihipDeviceCriticalBase_t ihipDeviceCritical_t; + +typedef LockedAccessor LockedAccessor_DeviceCrit_t; + +//---- +// Properties of the HIP device. +// Multiple contexts can point to same device. +class ihipDevice_t +{ +public: + ihipDevice_t(unsigned deviceId, unsigned deviceCnt, hc::accelerator &acc); + ~ihipDevice_t(); + + // Accessors: + ihipCtx_t *getPrimaryCtx() const { return _primaryCtx; }; + void locked_removeContext(ihipCtx_t *c); + void locked_reset(); + ihipDeviceCritical_t &criticalData() { return _criticalData; }; +public: + unsigned _deviceId; // device ID + + hc::accelerator _acc; + hsa_agent_t _hsaAgent; // hsa agent handle + + //! Number of compute units supported by the device: + unsigned _computeUnits; + hipDeviceProp_t _props; // saved device properties. + + // TODO - report this through device properties, base on HCC API call. + int _isLargeBar; + + ihipCtx_t *_primaryCtx; + + int _state; //1 if device is set otherwise 0 + +private: + hipError_t initProperties(hipDeviceProp_t* prop); +private: + ihipDeviceCritical_t _criticalData; +}; +//============================================================================= + + + +//============================================================================= +//class ihipCtxCriticalBase_t +template +class ihipCtxCriticalBase_t : LockedBase +{ +public: + ihipCtxCriticalBase_t(ihipCtx_t *parentCtx, unsigned deviceCnt) : + _parent(parentCtx), + _peerCnt(0) + { + _peerAgents = new hsa_agent_t[deviceCnt]; + }; + + ~ihipCtxCriticalBase_t() { + if (_peerAgents != nullptr) { + delete _peerAgents; + _peerAgents = nullptr; + } + _peerCnt = 0; + } + + // Streams: + void addStream(ihipStream_t *stream); + std::list &streams() { return _streams; }; + const std::list &const_streams() const { return _streams; }; + + + + // Peer Accessor classes: + bool isPeerWatcher(const ihipCtx_t *peer); // returns True if peer has access to memory physically located on this device. + bool addPeerWatcher(const ihipCtx_t *thisCtx, ihipCtx_t *peer); + bool removePeerWatcher(const ihipCtx_t *thisCtx, ihipCtx_t *peer); + void resetPeerWatchers(ihipCtx_t *thisDevice); + void printPeerWatchers(FILE *f) const; + + uint32_t peerCnt() const { return _peerCnt; }; + hsa_agent_t *peerAgents() const { return _peerAgents; }; + + + // TODO - move private + std::list _peers; // list of enabled peer devices. + + friend class LockedAccessor; +private: + ihipCtx_t * _parent; + + //--- Stream Tracker: + std::list< ihipStream_t* > _streams; // streams associated with this device. + + + //--- Peer Tracker: + // These reflect the currently Enabled set of peers for this GPU: + // Enabled peers have permissions to access the memory physically allocated on this device. + // Note the peers always contain the self agent for easy interfacing with HSA APIs. + uint32_t _peerCnt; // number of enabled peers + hsa_agent_t *_peerAgents; // efficient packed array of enabled agents (to use for allocations.) +private: + void recomputePeerAgents(); +}; +// Note Mutex type Real/Fake selected based on CtxMutex +typedef ihipCtxCriticalBase_t ihipCtxCritical_t; + +// This type is used by functions that need access to the critical device structures. +typedef LockedAccessor LockedAccessor_CtxCrit_t; +//============================================================================= + + +//============================================================================= +//class ihipCtx_t: +// A HIP CTX (context) points at one of the existing devices and contains the streams, +// peer-to-peer mappings, creation flags. Multiple contexts can point to the same +// device. +// +class ihipCtx_t +{ +public: // Functions: + ihipCtx_t(ihipDevice_t *device, unsigned deviceCnt, unsigned flags); // note: calls constructor for _criticalData + ~ihipCtx_t(); + + // Functions which read or write the critical data are named locked_. + // (might be better called "locking_" + // ihipCtx_t does not use recursive locks so the ihip implementation must avoid calling a locked_ function from within a locked_ function. + // External functions which call several locked_ functions will acquire and release the lock for each function. if this occurs in + // performance-sensitive code we may want to refactor by adding non-locked functions and creating a new locked_ member function to call them all. + void locked_removeStream(ihipStream_t *s); + void locked_reset(); + void locked_waitAllStreams(); + void locked_syncDefaultStream(bool waitOnSelf); + + // Will allocate a queue and assign it to the needyStream: + hc::accelerator_view stealActiveQueue(LockedAccessor_CtxCrit_t &ctxCrit, ihipStream_t *needyStream); + hc::accelerator_view createOrStealQueue(LockedAccessor_CtxCrit_t &ctxCrit); + + ihipCtxCritical_t &criticalData() { return _criticalData; }; + + const ihipDevice_t *getDevice() const { return _device; }; + int getDeviceNum() const { return _device->_deviceId; }; + + // TODO - review uses of getWriteableDevice(), can these be converted to getDevice() + ihipDevice_t *getWriteableDevice() const { return _device; }; + + std::string toString() const; + +public: // Data + // The NULL stream is used if no other stream is specified. + // Default stream has special synchronization properties with other streams. + ihipStream_t *_defaultStream; + + // Flags specified when the context is created: + unsigned _ctxFlags; + +private: + ihipDevice_t *_device; + + +private: // Critical data, protected with locked access: + // Members of _protected data MUST be accessed through the LockedAccessor. + // Search for LockedAccessor for examples; do not access _criticalData directly. + ihipCtxCritical_t _criticalData; + +}; + + + +//================================================================================================= +// Global variable definition: +extern std::once_flag hip_initialized; +extern unsigned g_deviceCnt; +extern hsa_agent_t g_cpu_agent ; // the CPU agent. + +//================================================================================================= +// Extern functions: +extern void ihipInit(); +extern const char *ihipErrorString(hipError_t); +extern ihipCtx_t *ihipGetTlsDefaultCtx(); +extern void ihipSetTlsDefaultCtx(ihipCtx_t *ctx); +extern hipError_t ihipSynchronize(void); +extern void ihipCtxStackUpdate(); +extern hipError_t ihipDeviceSetState(); + +extern ihipDevice_t *ihipGetDevice(int); +ihipCtx_t * ihipGetPrimaryCtx(unsigned deviceIndex); + +extern void ihipSetTs(hipEvent_t e); + + +hipStream_t ihipSyncAndResolveStream(hipStream_t); + +// Stream printf functions: +inline std::ostream& operator<<(std::ostream& os, const ihipStream_t& s) +{ + os << "stream:"; + os << s.getDevice()->_deviceId;; + os << '.'; + os << s._id; + return os; +} + +inline std::ostream & operator<<(std::ostream& os, const dim3& s) +{ + os << '{'; + os << s.x; + os << ','; + os << s.y; + os << ','; + os << s.z; + os << '}'; + return os; +} + +inline std::ostream & operator<<(std::ostream& os, const gl_dim3& s) +{ + os << '{'; + os << s.x; + os << ','; + os << s.y; + os << ','; + os << s.z; + os << '}'; + return os; +} + +// Stream printf functions: +inline std::ostream& operator<<(std::ostream& os, const hipEvent_t& e) +{ + os << "event:" << std::hex << static_cast (e); + return os; +} + +inline std::ostream& operator<<(std::ostream& os, const ihipCtx_t* c) +{ + os << "ctx:" << static_cast (c) + << ".dev:" << c->getDevice()->_deviceId; + return os; +} + + +// Helper functions that are used across src files: +namespace hip_internal { + hipError_t memcpyAsync (void* dst, const void* src, size_t sizeBytes, hipMemcpyKind kind, hipStream_t stream); +}; + + +#endif diff --git a/projects/hip/src/hip_memory.cpp b/projects/hip/src/hip_memory.cpp index 4684287076..805fc9efc0 100644 --- a/projects/hip/src/hip_memory.cpp +++ b/projects/hip/src/hip_memory.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -25,7 +25,7 @@ THE SOFTWARE. #include "hsa/hsa_ext_amd.h" #include "hip/hip_runtime.h" -#include "hip_hcc.h" +#include "hip_hcc_internal.h" #include "trace_helper.h" #include "hip/hcc_detail/hip_texture.h" #include @@ -261,11 +261,11 @@ hipError_t hipHostMalloc(void** ptr, size_t sizeBytes, unsigned int flags) auto device = ctx->getWriteableDevice(); unsigned amFlags = HIP_COHERENT_HOST_ALLOC ? amHostCoherent : amHostPinned; - *ptr = hip_internal::allocAndSharePtr(HIP_COHERENT_HOST_ALLOC ? "finegrained_host":"pinned_host", + *ptr = hip_internal::allocAndSharePtr(HIP_COHERENT_HOST_ALLOC ? "finegrained_host":"pinned_host", sizeBytes, ctx, amFlags, flags); if(sizeBytes && (*ptr == NULL)){ hip_status = hipErrorMemoryAllocation; - } + } } } @@ -314,7 +314,7 @@ hipError_t hipMallocPitch(void** ptr, size_t* pitch, size_t width, size_t height if (sizeBytes && (*ptr == NULL)) { hip_status = hipErrorMemoryAllocation; - } + } } else { hip_status = hipErrorMemoryAllocation; } @@ -372,7 +372,7 @@ hipError_t hipMallocArray(hipArray** array, const hipChannelFormatDesc* desc, *ptr = hip_internal::allocAndSharePtr("device_array", allocSize, ctx, am_flags, 0); if (size && (*ptr == NULL)) { hip_status = hipErrorMemoryAllocation; - } + } } else { hip_status = hipErrorMemoryAllocation; diff --git a/projects/hip/src/hip_module.cpp b/projects/hip/src/hip_module.cpp index c4b6cb8e08..554e13387a 100644 --- a/projects/hip/src/hip_module.cpp +++ b/projects/hip/src/hip_module.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -27,15 +27,13 @@ THE SOFTWARE. #include #include #include -#include "AMDGPUPTNote.h" -#include "AMDGPURuntimeMetadata.h" #include "hsa/hsa.h" #include "hsa/hsa_ext_amd.h" #include "hsa/amd_hsa_kernel_code.h" #include "hip/hip_runtime.h" -#include "hip_hcc.h" +#include "hip_hcc_internal.h" #include "trace_helper.h" //TODO Use Pool APIs from HCC to get memory regions. @@ -365,16 +363,12 @@ hipError_t hipModuleGetFunction(hipFunction_t *hfunc, hipModule_t hmod, } -hipError_t hipModuleLaunchKernel(hipFunction_t f, - uint32_t gridDimX, uint32_t gridDimY, uint32_t gridDimZ, - uint32_t blockDimX, uint32_t blockDimY, uint32_t blockDimZ, - uint32_t sharedMemBytes, hipStream_t hStream, +hipError_t ihipModuleLaunchKernel(hipFunction_t f, + uint32_t globalWorkSizeX, uint32_t globalWorkSizeY, uint32_t globalWorkSizeZ, + uint32_t localWorkSizeX, uint32_t localWorkSizeY, uint32_t localWorkSizeZ, + size_t sharedMemBytes, hipStream_t hStream, void **kernelParams, void **extra) { - HIP_INIT_API(f, gridDimX, gridDimY, gridDimZ, - blockDimX, blockDimY, blockDimZ, - sharedMemBytes, hStream, - kernelParams, extra); auto ctx = ihipGetTlsDefaultCtx(); hipError_t ret = hipSuccess; @@ -420,7 +414,7 @@ hipError_t hipModuleLaunchKernel(hipFunction_t f, */ grid_launch_parm lp; lp.dynamic_group_mem_bytes = sharedMemBytes; // TODO - this should be part of preLaunchKernel. - hStream = ihipPreLaunchKernel(hStream, dim3(gridDimX, gridDimY, gridDimZ), dim3(blockDimX, blockDimY, blockDimZ), &lp, f->_name.c_str()); + hStream = ihipPreLaunchKernel(hStream, dim3(globalWorkSizeX, globalWorkSizeY, globalWorkSizeZ), dim3(localWorkSizeX, localWorkSizeY, localWorkSizeZ), &lp, f->_name.c_str()); hsa_kernel_dispatch_packet_t aql; @@ -430,12 +424,12 @@ hipError_t hipModuleLaunchKernel(hipFunction_t f, //aql.completion_signal._handle = 0; //aql.kernarg_address = 0; - aql.workgroup_size_x = blockDimX; - aql.workgroup_size_y = blockDimY; - aql.workgroup_size_z = blockDimZ; - aql.grid_size_x = blockDimX * gridDimX; - aql.grid_size_y = blockDimY * gridDimY; - aql.grid_size_z = blockDimZ * gridDimZ; + aql.workgroup_size_x = localWorkSizeX; + aql.workgroup_size_y = localWorkSizeY; + aql.workgroup_size_z = localWorkSizeZ; + aql.grid_size_x = globalWorkSizeX; + aql.grid_size_y = globalWorkSizeY; + aql.grid_size_z = globalWorkSizeZ; aql.group_segment_size = f->_groupSegmentSize + sharedMemBytes; aql.private_segment_size = f->_privateSegmentSize; aql.kernel_object = f->_object; @@ -459,9 +453,40 @@ hipError_t hipModuleLaunchKernel(hipFunction_t f, ihipPostLaunchKernel(f->_name.c_str(), hStream, lp); } - return ihipLogStatus(ret); + return ret; } +hipError_t hipModuleLaunchKernel(hipFunction_t f, + uint32_t gridDimX, uint32_t gridDimY, uint32_t gridDimZ, + uint32_t blockDimX, uint32_t blockDimY, uint32_t blockDimZ, + uint32_t sharedMemBytes, hipStream_t hStream, + void **kernelParams, void **extra) +{ + HIP_INIT_API(f, gridDimX, gridDimY, gridDimZ, + blockDimX, blockDimY, blockDimZ, + sharedMemBytes, hStream, + kernelParams, extra); + return ihipLogStatus(ihipModuleLaunchKernel(f, + blockDimX * gridDimX, blockDimY * gridDimY, gridDimZ * blockDimZ, + blockDimX, blockDimY, blockDimZ, + sharedMemBytes, hStream, kernelParams, extra)); +} + + +hipError_t hipHccModuleLaunchKernel(hipFunction_t f, + uint32_t globalWorkSizeX, uint32_t globalWorkSizeY, uint32_t globalWorkSizeZ, + uint32_t localWorkSizeX, uint32_t localWorkSizeY, uint32_t localWorkSizeZ, + size_t sharedMemBytes, hipStream_t hStream, + void **kernelParams, void **extra) +{ + HIP_INIT_API(f, globalWorkSizeX, globalWorkSizeY, globalWorkSizeZ, + localWorkSizeX, localWorkSizeY, localWorkSizeZ, + sharedMemBytes, hStream, + kernelParams, extra); + return ihipLogStatus(ihipModuleLaunchKernel(f, globalWorkSizeX, globalWorkSizeY, globalWorkSizeZ, + localWorkSizeX, localWorkSizeY, localWorkSizeZ, + sharedMemBytes, hStream, kernelParams, extra)); +} hipError_t hipModuleGetGlobal(hipDeviceptr_t *dptr, size_t *bytes, hipModule_t hmod, const char* name) diff --git a/projects/hip/src/hip_peer.cpp b/projects/hip/src/hip_peer.cpp index e57665be0c..984110a6b5 100644 --- a/projects/hip/src/hip_peer.cpp +++ b/projects/hip/src/hip_peer.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -23,7 +23,7 @@ THE SOFTWARE. #include #include "hip/hip_runtime.h" -#include "hip_hcc.h" +#include "hip_hcc_internal.h" #include "trace_helper.h" diff --git a/projects/hip/src/hip_stream.cpp b/projects/hip/src/hip_stream.cpp index 594fb6e860..d7f8717725 100644 --- a/projects/hip/src/hip_stream.cpp +++ b/projects/hip/src/hip_stream.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -21,7 +21,7 @@ THE SOFTWARE. */ #include "hip/hip_runtime.h" -#include "hip_hcc.h" +#include "hip_hcc_internal.h" #include "trace_helper.h" From 7635e0a57e02e7fe205ac7085741896e8857fd4d Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Fri, 31 Mar 2017 12:18:55 -0500 Subject: [PATCH 260/281] fixed header names Change-Id: I21650d6398187d3767b28e8ac81b2642d3b89a0e [ROCm/hip commit: e0133e627d5a834a1281b288f002d295a722edd9] --- .../include/hip/hcc_detail/device_functions.h | 9 ++- .../hip/include/hip/hcc_detail/driver_types.h | 9 ++- projects/hip/include/hip/hcc_detail/hcc_acc.h | 59 ------------------- .../hip/include/hip/hcc_detail/helpers.hpp | 2 +- .../hip/include/hip/hcc_detail/hip_complex.h | 6 +- .../hip/include/hip/hcc_detail/hip_fp16.h | 6 +- projects/hip/include/hip/hcc_detail/hip_ldg.h | 6 +- .../hip/include/hip/hcc_detail/hip_runtime.h | 6 +- .../include/hip/hcc_detail/hip_runtime_api.h | 8 +-- .../hip/include/hip/hcc_detail/hip_texture.h | 6 +- .../include/hip/hcc_detail/hip_vector_types.h | 6 +- .../hip/include/hip/hcc_detail/host_defines.h | 8 +-- .../include/hip/hcc_detail/math_functions.h | 9 ++- .../include/hip/hcc_detail/texture_types.h | 9 ++- 14 files changed, 51 insertions(+), 98 deletions(-) delete mode 100644 projects/hip/include/hip/hcc_detail/hcc_acc.h diff --git a/projects/hip/include/hip/hcc_detail/device_functions.h b/projects/hip/include/hip/hcc_detail/device_functions.h index 212f22d5dc..8073503364 100644 --- a/projects/hip/include/hip/hcc_detail/device_functions.h +++ b/projects/hip/include/hip/hcc_detail/device_functions.h @@ -1,13 +1,16 @@ /* -Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -17,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef HIP_HCC_DETAIL_DEVICE_FUNCTIONS_H -#define HIP_HCC_DETAIL_DEVICE_FUNCTIONS_H +#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_DEVICE_FUNCTIONS_H +#define HIP_INCLUDE_HIP_HCC_DETAIL_DEVICE_FUNCTIONS_H #include #include diff --git a/projects/hip/include/hip/hcc_detail/driver_types.h b/projects/hip/include/hip/hcc_detail/driver_types.h index 1fe72b0507..3578ddc609 100644 --- a/projects/hip/include/hip/hcc_detail/driver_types.h +++ b/projects/hip/include/hip/hcc_detail/driver_types.h @@ -1,13 +1,16 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -17,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef HIP_HCC_DETAIL_DRIVER_TYPES_H -#define HIP_HCC_DETAIL_DRIVER_TYPES_H +#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_DRIVER_TYPES_H +#define HIP_INCLUDE_HIP_HCC_DETAIL_DRIVER_TYPES_H enum hipChannelFormatKind { diff --git a/projects/hip/include/hip/hcc_detail/hcc_acc.h b/projects/hip/include/hip/hcc_detail/hcc_acc.h deleted file mode 100644 index 962f795d6f..0000000000 --- a/projects/hip/include/hip/hcc_detail/hcc_acc.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifndef HCC_ACC_H -#define HCC_ACC_H -#include "hip/hip_runtime_api.h" - -#if __cplusplus -#ifdef __HCC__ -#include -/** - * @brief Return hc::accelerator associated with the specified deviceId - * @return #hipSuccess, #hipErrorInvalidDevice - */ -hipError_t hipHccGetAccelerator(int deviceId, hc::accelerator *acc); - -/** - * @brief Return hc::accelerator_view associated with the specified stream - * - * If stream is 0, the accelerator_view for the default stream is returned. - * @return #hipSuccess - */ -hipError_t hipHccGetAcceleratorView(hipStream_t stream, hc::accelerator_view **av); - - -hipError_t hipHccModuleLaunchKernel(hipFunction_t f, - uint32_t globalWorkSizeX, - uint32_t globalWorkSizeY, - uint32_t globalWorkSizeZ, - uint32_t localWorkSizeX, - uint32_t localWorkSizeY, - uint32_t localWorkSizeZ, - size_t sharedMemBytes, - hipStream_t hStream, - void **kernelParams, - void **extra); -#endif -#endif - -#endif diff --git a/projects/hip/include/hip/hcc_detail/helpers.hpp b/projects/hip/include/hip/hcc_detail/helpers.hpp index f12087faa9..5ab866dc66 100644 --- a/projects/hip/include/hip/hcc_detail/helpers.hpp +++ b/projects/hip/include/hip/hcc_detail/helpers.hpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/projects/hip/include/hip/hcc_detail/hip_complex.h b/projects/hip/include/hip/hcc_detail/hip_complex.h index f50a601b90..9ff75d381a 100644 --- a/projects/hip/include/hip/hcc_detail/hip_complex.h +++ b/projects/hip/include/hip/hcc_detail/hip_complex.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef INCLUDE_HIP_HCC_DETAIL_HIP_COMPLEX_H -#define INCLUDE_HIP_HCC_DETAIL_HIP_COMPLEX_H +#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_HIP_COMPLEX_H +#define HIP_INCLUDE_HIP_HCC_DETAIL_HIP_COMPLEX_H #include "./hip_fp16.h" #include "./hip_vector_types.h" diff --git a/projects/hip/include/hip/hcc_detail/hip_fp16.h b/projects/hip/include/hip/hcc_detail/hip_fp16.h index b0276d51b3..a3766fb053 100644 --- a/projects/hip/include/hip/hcc_detail/hip_fp16.h +++ b/projects/hip/include/hip/hcc_detail/hip_fp16.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef HIP_HCC_DETAIL_FP16_H -#define HIP_HCC_DETAIL_FP16_H +#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_HIP_FP16_H +#define HIP_INCLUDE_HIP_HCC_DETAIL_HIP_FP16_H #include "hip/hip_runtime.h" diff --git a/projects/hip/include/hip/hcc_detail/hip_ldg.h b/projects/hip/include/hip/hcc_detail/hip_ldg.h index 5c33ee773f..473e70b4cb 100644 --- a/projects/hip/include/hip/hcc_detail/hip_ldg.h +++ b/projects/hip/include/hip/hcc_detail/hip_ldg.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef HIP_LDG_H -#define HIP_LDG_H +#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_HIP_LDG_H +#define HIP_INCLUDE_HIP_HCC_DETAIL_HIP_LDG_H #if defined __HCC__ #if __hcc_workweek__ >= 16164 diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime.h b/projects/hip/include/hip/hcc_detail/hip_runtime.h index 42d80ecb0e..9692b16a4c 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -26,8 +26,8 @@ THE SOFTWARE. */ //#pragma once -#ifndef HIP_HCC_DETAIL_RUNTIME_H -#define HIP_HCC_DETAIL_RUNTIME_H +#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_HIP_RUNTIME_H +#define HIP_INCLUDE_HIP_HCC_DETAIL_HIP_RUNTIME_H //--- // Top part of file can be compiled with any compiler diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h index 87e552a6cf..0daca7a53b 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -21,8 +21,8 @@ THE SOFTWARE. */ //#pragma once -#ifndef HIP_HCC_DETAIL_HIP_RUNTIME_API_H -#define HIP_HCC_DETAIL_HIP_RUNTIME_API_H +#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_HIP_RUNTIME_API_H +#define HIP_INCLUDE_HIP_HCC_DETAIL_HIP_RUNTIME_API_H /** * @file hcc_detail/hip_runtime_api.h * @brief Contains C function APIs for HIP runtime. This file does not use any HCC builtin or special language extensions (-hc mode) ; those functions in hip_runtime.h. @@ -32,7 +32,7 @@ THE SOFTWARE. #include #ifndef GENERIC_GRID_LAUNCH -#define GENERIC_GRID_LAUNCH 1 +#define GENERIC_GRID_LAUNCH 1 #endif #include diff --git a/projects/hip/include/hip/hcc_detail/hip_texture.h b/projects/hip/include/hip/hcc_detail/hip_texture.h index d60f66ddc2..c6f5a1cfb2 100644 --- a/projects/hip/include/hip/hcc_detail/hip_texture.h +++ b/projects/hip/include/hip/hcc_detail/hip_texture.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -22,8 +22,8 @@ THE SOFTWARE. //#pragma once -#ifndef HIP_HCC_DETAIL_TEXTURE_H -#define HIP_HCC_DETAIL_TEXTURE_H +#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_HIP_TEXTURE_H +#define HIP_INCLUDE_HIP_HCC_DETAIL_HIP_TEXTURE_H /** * @file hcc_detail/hip_texture.h diff --git a/projects/hip/include/hip/hcc_detail/hip_vector_types.h b/projects/hip/include/hip/hcc_detail/hip_vector_types.h index 8e6ec49511..42e1d6663c 100644 --- a/projects/hip/include/hip/hcc_detail/hip_vector_types.h +++ b/projects/hip/include/hip/hcc_detail/hip_vector_types.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -25,8 +25,8 @@ THE SOFTWARE. * @brief Defines the different newt vector types for HIP runtime. */ -#ifndef HIP_VECTOR_TYPES_H -#define HIP_VECTOR_TYPES_H +#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_HIP_VECTOR_TYPES_H +#define HIP_INCLUDE_HIP_HCC_DETAIL_HIP_VECTOR_TYPES_H #if defined (__HCC__) && (__hcc_workweek__ < 16032) #error("This version of HIP requires a newer version of HCC."); diff --git a/projects/hip/include/hip/hcc_detail/host_defines.h b/projects/hip/include/hip/hcc_detail/host_defines.h index d077873797..4f44774700 100644 --- a/projects/hip/include/hip/hcc_detail/host_defines.h +++ b/projects/hip/include/hip/hcc_detail/host_defines.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -25,14 +25,14 @@ THE SOFTWARE. * @brief TODO-doc */ -#ifndef HOST_DEFINES_H -#define HOST_DEFINES_H +#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_HOST_DEFINES_H +#define HIP_INCLUDE_HIP_HCC_DETAIL_HOST_DEFINES_H #define USE_PROMOTE_FREE_HCC 0 // Add guard to Generic Grid Launch method #ifndef GENERIC_GRID_LAUNCH -#define GENERIC_GRID_LAUNCH 1 +#define GENERIC_GRID_LAUNCH 1 #endif #ifdef __HCC__ diff --git a/projects/hip/include/hip/hcc_detail/math_functions.h b/projects/hip/include/hip/hcc_detail/math_functions.h index 8455509732..c3b8186fd3 100644 --- a/projects/hip/include/hip/hcc_detail/math_functions.h +++ b/projects/hip/include/hip/hcc_detail/math_functions.h @@ -1,13 +1,16 @@ /* -Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -17,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef HIP_HCC_DETAIL_MATH_FUNCTIONS_H -#define HIP_HCC_DETAIL_MATH_FUNCTIONS_H +#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_MATH_FUNCTIONS_H +#define HIP_INCLUDE_HIP_HCC_DETAIL_MATH_FUNCTIONS_H #include #include diff --git a/projects/hip/include/hip/hcc_detail/texture_types.h b/projects/hip/include/hip/hcc_detail/texture_types.h index 107b5d26c1..74680bbc76 100644 --- a/projects/hip/include/hip/hcc_detail/texture_types.h +++ b/projects/hip/include/hip/hcc_detail/texture_types.h @@ -1,13 +1,16 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -18,8 +21,8 @@ THE SOFTWARE. */ -#ifndef HIP_HCC_DETAIL_TEXTURE_TYPES_H -#define HIP_HCC_DETAIL_TEXTURE_TYPES_H +#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_TEXTURE_TYPES_H +#define HIP_INCLUDE_HIP_HCC_DETAIL_TEXTURE_TYPES_H #include From fcb4331a6a758e693258988fe2c25fb1cd1cf66e Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Fri, 31 Mar 2017 12:40:29 -0500 Subject: [PATCH 261/281] Fixed copyright and header names Change-Id: Id595c65ea3b7289e87be4c42db5d8a31905a4fdd [ROCm/hip commit: 1ef7222c3a88cacc25b4759cecf3cae820ddd6b6] --- .../include/hip/hcc_detail/grid_launch_v2.hpp | 4 +- .../hip/include/hip/hcc_detail/hip_fp16.h | 3 - projects/hip/include/hip/hip_runtime_api.h | 2 + .../hip/nvcc_detail/channel_descriptor.h | 7 +- .../hip/include/hip/nvcc_detail/hip_complex.h | 6 +- .../hip/include/hip/nvcc_detail/hip_runtime.h | 7 +- .../include/hip/nvcc_detail/hip_runtime_api.h | 5 +- .../hip/include/hip/nvcc_detail/hip_texture.h | 26 +- projects/hip/src/hip_fp16.cpp | 4 +- projects/hip/src/hip_hcc.h | 885 ------------------ projects/hip/src/hip_hcc_internal.h | 6 +- projects/hip/src/hip_ldg.cpp | 2 +- projects/hip/src/hip_util.h | 6 +- projects/hip/tests/src/hipHcc.cpp | 3 +- 14 files changed, 54 insertions(+), 912 deletions(-) delete mode 100644 projects/hip/src/hip_hcc.h diff --git a/projects/hip/include/hip/hcc_detail/grid_launch_v2.hpp b/projects/hip/include/hip/hcc_detail/grid_launch_v2.hpp index b360d4c19d..8b1eded2f3 100644 --- a/projects/hip/include/hip/hcc_detail/grid_launch_v2.hpp +++ b/projects/hip/include/hip/hcc_detail/grid_launch_v2.hpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -26,7 +26,7 @@ THE SOFTWARE. #include "helpers.hpp" #include "hc.hpp" -#include "hcc_acc.h" +#include "hip_hcc.h" #include #include diff --git a/projects/hip/include/hip/hcc_detail/hip_fp16.h b/projects/hip/include/hip/hcc_detail/hip_fp16.h index a3766fb053..febc1b4fce 100644 --- a/projects/hip/include/hip/hcc_detail/hip_fp16.h +++ b/projects/hip/include/hip/hcc_detail/hip_fp16.h @@ -464,9 +464,6 @@ __device__ static inline __half2 h2trunc(const __half2 h) { return a; } - - - #endif #if __clang_major__ == 3 diff --git a/projects/hip/include/hip/hip_runtime_api.h b/projects/hip/include/hip/hip_runtime_api.h index 5715be0599..8eae1d6a3a 100644 --- a/projects/hip/include/hip/hip_runtime_api.h +++ b/projects/hip/include/hip/hip_runtime_api.h @@ -284,3 +284,5 @@ static inline hipError_t hipHostMalloc( T** ptr, size_t size, unsigned int flags return hipHostMalloc((void**)ptr, size, flags); } #endif + +#endif diff --git a/projects/hip/include/hip/nvcc_detail/channel_descriptor.h b/projects/hip/include/hip/nvcc_detail/channel_descriptor.h index 8502745968..2e88c56268 100644 --- a/projects/hip/include/hip/nvcc_detail/channel_descriptor.h +++ b/projects/hip/include/hip/nvcc_detail/channel_descriptor.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,6 +20,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#pragma once +#ifndef HIP_INCLUDE_HIP_NVCC_DETAIL_CHANNEL_DESCRIPTOR_H +#define HIP_INCLUDE_HIP_NVCC_DETAIL_CHANNEL_DESCRIPTOR_H #include"channel_descriptor.h" + +#endif diff --git a/projects/hip/include/hip/nvcc_detail/hip_complex.h b/projects/hip/include/hip/nvcc_detail/hip_complex.h index 174cabc12c..84afb13e50 100644 --- a/projects/hip/include/hip/nvcc_detail/hip_complex.h +++ b/projects/hip/include/hip/nvcc_detail/hip_complex.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef HIPCOMPLEX_H -#define HIPCOMPLEX_H +#ifndef HIP_INCLUDE_HIP_NVCC_DETAIL_HIP_COMPLEX_H +#define HIP_INCLUDE_HIP_NVCC_DETAIL_HIP_COMPLEX_H #include"cuComplex.h" diff --git a/projects/hip/include/hip/nvcc_detail/hip_runtime.h b/projects/hip/include/hip/nvcc_detail/hip_runtime.h index 2c774bfb7d..b4fa13f48c 100644 --- a/projects/hip/include/hip/nvcc_detail/hip_runtime.h +++ b/projects/hip/include/hip/nvcc_detail/hip_runtime.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,7 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#pragma once +#ifndef HIP_INCLUDE_HIP_NVCC_DETAIL_HIP_RUNTIME_H +#define HIP_INCLUDE_HIP_NVCC_DETAIL_HIP_RUNTIME_H #include @@ -105,3 +106,5 @@ kernelName<<>>(0, ##__VA_ARGS__);\ #define HIP_DYNAMIC_SHARED_ATTRIBUTE #endif + +#endif diff --git a/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h b/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h index 758ef064bd..7e881df3ab 100644 --- a/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,7 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#pragma once +#ifndef HIP_INCLUDE_HIP_NVCC_DETAIL_HIP_RUNTIME_API_H +#define HIP_INCLUDE_HIP_NVCC_DETAIL_HIP_RUNTIME_API_H #include #include diff --git a/projects/hip/include/hip/nvcc_detail/hip_texture.h b/projects/hip/include/hip/nvcc_detail/hip_texture.h index 388733e492..c669d62192 100644 --- a/projects/hip/include/hip/nvcc_detail/hip_texture.h +++ b/projects/hip/include/hip/nvcc_detail/hip_texture.h @@ -1,5 +1,27 @@ -#ifndef HIP_TEXTURE_H -#define HIP_TEXTURE_H +/* +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#ifndef HIP_INCLUDE_HIP_NVCC_DETAIL_HIP_TEXTURE_H +#define HIP_INCLUDE_HIP_NVCC_DETAIL_HIP_TEXTURE_H #include diff --git a/projects/hip/src/hip_fp16.cpp b/projects/hip/src/hip_fp16.cpp index e7f75844ff..c2b7b47597 100644 --- a/projects/hip/src/hip_fp16.cpp +++ b/projects/hip/src/hip_fp16.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,7 +20,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include"hip/hip_fp16.h" +#include"hip/hcc_detail/hip_fp16.h" struct hipHalfHolder{ union { diff --git a/projects/hip/src/hip_hcc.h b/projects/hip/src/hip_hcc.h deleted file mode 100644 index 245f154305..0000000000 --- a/projects/hip/src/hip_hcc.h +++ /dev/null @@ -1,885 +0,0 @@ -/* -Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifndef HIP_HCC_H -#define HIP_HCC_H - -#include -#include -#include "hsa/hsa_ext_amd.h" - -#include "hip/hip_runtime.h" -#include "hip_util.h" -#include "env.h" - - -#if defined(__HCC__) && (__hcc_workweek__ < 16354) -#error("This version of HIP requires a newer version of HCC."); -#endif - -#define USE_IPC 1 - -//--- -// Environment variables: - -// Intended to distinguish whether an environment variable should be visible only in debug mode, or in debug+release. -//static const int debug = 0; -extern const int release; - -// TODO - this blocks both kernels and memory ops. Perhaps should have separate env var for kernels? -extern int HIP_LAUNCH_BLOCKING; -extern int HIP_API_BLOCKING; - -extern int HIP_PRINT_ENV; -extern int HIP_PROFILE_API; -//extern int HIP_TRACE_API; -extern int HIP_ATP; -extern int HIP_DB; -extern int HIP_STAGING_SIZE; /* size of staging buffers, in KB */ -extern int HIP_STREAM_SIGNALS; /* number of signals to allocate at stream creation */ -extern int HIP_VISIBLE_DEVICES; /* Contains a comma-separated sequence of GPU identifiers */ -extern int HIP_FORCE_P2P_HOST; - -extern int HIP_COHERENT_HOST_ALLOC; - - -//--- -// Chicken bits for disabling functionality to work around potential issues: -extern int HIP_SYNC_HOST_ALLOC; - -// TODO - remove when this is standard behavior. -extern int HCC_OPT_FLUSH; - - -// Class to assign a short TID to each new thread, for HIP debugging purposes. -class TidInfo { -public: - - TidInfo() ; - - int tid() const { return _shortTid; }; - uint64_t incApiSeqNum() { return ++_apiSeqNum; }; - uint64_t apiSeqNum() const { return _apiSeqNum; }; - -private: - int _shortTid; - - // monotonically increasing API sequence number for this threa. - uint64_t _apiSeqNum; -}; - -struct ProfTrigger { - - static const uint64_t MAX_TRIGGER = std::numeric_limits::max(); - - void print (int tid) { - std::cout << "Enabling tracing for "; - for (auto iter=_profTrigger.begin(); iter != _profTrigger.end(); iter++) { - std::cout << "tid:" << tid << "." << *iter << ","; - } - std::cout << "\n"; - }; - - uint64_t nextTrigger() { return _profTrigger.empty() ? MAX_TRIGGER : _profTrigger.back(); }; - void add(uint64_t trigger) { _profTrigger.push_back(trigger); }; - void sort() { std::sort (_profTrigger.begin(), _profTrigger.end(), std::greater()); }; -private: - std::vector _profTrigger; -}; - - - -//--- -//Extern tls -extern thread_local hipError_t tls_lastHipError; -extern thread_local TidInfo tls_tidInfo; - -extern std::vector g_dbStartTriggers; -extern std::vector g_dbStopTriggers; - -//--- -//Forward defs: -class ihipStream_t; -class ihipDevice_t; -class ihipCtx_t; - -// Color defs for debug messages: -#define KNRM "\x1B[0m" -#define KRED "\x1B[31m" -#define KGRN "\x1B[32m" -#define KYEL "\x1B[33m" -#define KBLU "\x1B[34m" -#define KMAG "\x1B[35m" -#define KCYN "\x1B[36m" -#define KWHT "\x1B[37m" - -extern const char *API_COLOR; -extern const char *API_COLOR_END; - - -// If set, thread-safety is enforced on all stream functions. -// Stream functions will acquire a mutex before entering critical sections. -#define STREAM_THREAD_SAFE 1 - - -#define CTX_THREAD_SAFE 1 - -#define DEVICE_THREAD_SAFE 1 - - -// Compile debug trace mode - this prints debug messages to stderr when env var HIP_DB is set. -// May be set to 0 to remove debug if checks - possible code size and performance difference? -#define COMPILE_HIP_DB 1 - - -// Compile HIP tracing capability. -// 0x1 = print a string at function entry with arguments. -// 0x2 = prints a simple message with function name + return code when function exits. -// 0x3 = print both. -// Must be enabled at runtime with HIP_TRACE_API -#define COMPILE_HIP_TRACE_API 0x3 - - -// Compile code that generates trace markers for CodeXL ATP at HIP function begin/end. -// ATP is standard CodeXL format that includes timestamps for kernels, HSA RT APIs, and HIP APIs. -#ifndef COMPILE_HIP_ATP_MARKER -#define COMPILE_HIP_ATP_MARKER 0 -#endif - - - - -// Compile support for trace markers that are displayed on CodeXL GUI at start/stop of each function boundary. -// TODO - currently we print the trace message at the beginning. if we waited, we could also tls_tidInfo return codes, and any values returned -// through ptr-to-args (ie the pointers allocated by hipMalloc). -#if COMPILE_HIP_ATP_MARKER -#include "CXLActivityLogger.h" -#define MARKER_BEGIN(markerName,group) amdtBeginMarker(markerName, group, nullptr); -#define MARKER_END() amdtEndMarker(); -#define RESUME_PROFILING amdtResumeProfiling(AMDT_ALL_PROFILING); -#define STOP_PROFILING amdtStopProfiling(AMDT_ALL_PROFILING); -#else -// Swallow scoped markers: -#define MARKER_BEGIN(markerName,group) -#define MARKER_END() -#define RESUME_PROFILING -#define STOP_PROFILING -#endif - - -//--- -//HIP Trace modes -#define TRACE_ALL 0 // 0x1 -#define TRACE_CMD 1 // 0x2 -#define TRACE_MEM 2 // 0x4 - - -//--- -//HIP_DB Debug flags: -#define DB_API 0 /* 0x01 - shortcut to enable HIP_TRACE_API on single switch */ -#define DB_SYNC 1 /* 0x02 - trace synchronization pieces */ -#define DB_MEM 2 /* 0x04 - trace memory allocation / deallocation */ -#define DB_COPY 3 /* 0x08 - trace memory copy and peer commands. . */ -#define DB_MAX_FLAG 4 -// When adding a new debug flag, also add to the char name table below. -// -// - -struct DbName { - const char *_color; - const char *_shortName; -}; - -// This table must be kept in-sync with the defines above. -static const DbName dbName [] = -{ - {KGRN, "api"}, // not used, - {KYEL, "sync"}, - {KCYN, "mem"}, - {KMAG, "copy"}, -}; - - - -#if COMPILE_HIP_DB -#define tprintf(trace_level, ...) {\ - if (HIP_DB & (1<<(trace_level))) {\ - char msgStr[1000];\ - snprintf(msgStr, 2000, __VA_ARGS__);\ - fprintf (stderr, " %ship-%s tid:%d:%s%s", dbName[trace_level]._color, dbName[trace_level]._shortName, tls_tidInfo.tid(), msgStr, KNRM); \ - }\ -} -#else -/* Compile to empty code */ -#define tprintf(trace_level, ...) -#endif - - - - -//--- -extern void recordApiTrace(std::string *fullStr, const std::string &apiStr); - -#if COMPILE_HIP_ATP_MARKER || (COMPILE_HIP_TRACE_API & 0x1) -#define API_TRACE(forceTrace, ...)\ -{\ - tls_tidInfo.incApiSeqNum();\ - if (forceTrace || (HIP_PROFILE_API || (COMPILE_HIP_DB && (HIP_TRACE_API & (1<>%s\n", (localHipStatus == 0) ? API_COLOR:KRED, tls_tidInfo.tid(),tls_tidInfo.apiSeqNum(), __func__, localHipStatus, ihipErrorString(localHipStatus), API_COLOR_END);\ - }\ - if (HIP_PROFILE_API) { MARKER_END(); }\ - localHipStatus;\ - }) - - - - - - -class ihipException : public std::exception -{ -public: - ihipException(hipError_t e) : _code(e) {}; - - hipError_t _code; -}; - - -#ifdef __cplusplus -extern "C" { -#endif - - -#ifdef __cplusplus -} -#endif - -const hipStream_t hipStreamNull = 0x0; - - -/** - * HIP IPC Handle Size - */ -#define HIP_IPC_RESERVED_SIZE 24 -class ihipIpcMemHandle_t -{ -public: -#if USE_IPC - hsa_amd_ipc_memory_t ipc_handle; ///< ipc memory handle on ROCr -#endif - size_t psize; - char reserved[HIP_IPC_RESERVED_SIZE]; -}; - - -class ihipModule_t { -public: - hsa_executable_t executable; - hsa_code_object_t object; - std::string fileName; - void *ptr; - size_t size; - std::list funcTrack; - ihipModule_t() : executable(), object(), fileName(), ptr(nullptr), size(0) {} -}; - - -//--- -// Used to remove lock, for performance or stimulating bugs. -class FakeMutex -{ - public: - void lock() { } - bool try_lock() {return true; } - void unlock() { } -}; - - -#if STREAM_THREAD_SAFE -typedef std::mutex StreamMutex; -#else -#warning "Stream thread-safe disabled" -typedef FakeMutex StreamMutex; -#endif - -// Pair Device and Ctx together, these could also be toggled separately if desired. -#if CTX_THREAD_SAFE -typedef std::mutex CtxMutex; -#else -typedef FakeMutex CtxMutex; -#warning "Ctx thread-safe disabled" -#endif - -#if DEVICE_THREAD_SAFE -typedef std::mutex DeviceMutex; -#else -typedef FakeMutex DeviceMutex; -#warning "Device thread-safe disabled" -#endif - -// -//--- -// Protects access to the member _data with a lock acquired on contruction/destruction. -// T must contain a _mutex field which meets the BasicLockable requirements (lock/unlock) -template -class LockedAccessor -{ -public: - LockedAccessor(T &criticalData, bool autoUnlock=true) : - _criticalData(&criticalData), - _autoUnlock(autoUnlock) - - { - tprintf(DB_SYNC, "locking criticalData=%p for %s..\n", _criticalData, ToString(_criticalData->_parent).c_str()); - _criticalData->_mutex.lock(); - }; - - ~LockedAccessor() - { - if (_autoUnlock) { - tprintf(DB_SYNC, "auto-unlocking criticalData=%p for %s...\n", _criticalData, ToString(_criticalData->_parent).c_str()); - _criticalData->_mutex.unlock(); - } - } - - void unlock() - { - tprintf(DB_SYNC, "unlocking criticalData=%p for %s...\n", _criticalData, ToString(_criticalData->_parent).c_str()); - _criticalData->_mutex.unlock(); - } - - // Syntactic sugar so -> can be used to get the underlying type. - T *operator->() { return _criticalData; }; - -private: - T *_criticalData; - bool _autoUnlock; -}; - - -template -struct LockedBase { - - // Experts-only interface for explicit locking. - // Most uses should use the lock-accessor. - void lock() { _mutex.lock(); } - void unlock() { _mutex.unlock(); } - bool try_lock() { return _mutex.try_lock(); } - - MUTEX_TYPE _mutex; -}; - - -template -class ihipStreamCriticalBase_t : public LockedBase -{ -public: - ihipStreamCriticalBase_t(ihipStream_t *parentStream, hc::accelerator_view av) : - _kernelCnt(0), - _av(av), - _hasQueue(true), - _parent(parentStream) - { - }; - - ~ihipStreamCriticalBase_t() { - } - - ihipStreamCriticalBase_t * mlock() { LockedBase::lock(); return this;}; - - void munlock() { - tprintf(DB_SYNC, "munlocking criticalData=%p for %s...\n", this, ToString(this->_parent).c_str()); - LockedBase::unlock(); - }; - - ihipStreamCriticalBase_t * mtry_lock() { - bool gotLock = LockedBase::try_lock() ; - tprintf(DB_SYNC, "mtry_locking=%d criticalData=%p for %s...\n", gotLock, this, ToString(this->_parent).c_str()); - return gotLock ? this: nullptr; - }; - -public: - ihipStream_t * _parent; - uint32_t _kernelCnt; // Count of inflight kernels in this stream. Reset at ::wait(). - - hc::accelerator_view _av; - - // True if the stream has an allocated queue (accelerato_view) for its use: - // Always true at ihipStream creation but queue may later be stolen. - // This acts as a valid bit for the _av. - bool _hasQueue; -private: -}; - - -// if HIP code needs to acquire locks for both ihipCtx_t and ihipStream_t, it should first acquire the lock -// for the ihipCtx_t and then for the individual streams. The locks should not be acquired in reverse order -// or deadlock may occur. In some cases, it may be possible to reduce the range where the locks must be held. -// HIP routines should avoid acquiring and releasing the same lock during the execution of a single HIP API. -// Another option is to use try_lock in the innermost lock query. - - -typedef ihipStreamCriticalBase_t ihipStreamCritical_t; -typedef LockedAccessor LockedAccessor_StreamCrit_t; - -//--- -// Internal stream structure. -class ihipStream_t { -public: - enum ScheduleMode {Auto, Spin, Yield}; - typedef uint64_t SeqNum_t ; - - // TODOD -make av a reference to avoid shared_ptr overhead? - ihipStream_t(ihipCtx_t *ctx, hc::accelerator_view av, unsigned int flags); - ~ihipStream_t(); - - // kind is hipMemcpyKind - void locked_copySync (void* dst, const void* src, size_t sizeBytes, unsigned kind, bool resolveOn = true); - void locked_copyAsync(void* dst, const void* src, size_t sizeBytes, unsigned kind); - - void lockedSymbolCopySync(hc::accelerator &acc, void *dst, void* src, size_t sizeBytes, size_t offset, unsigned kind); - void lockedSymbolCopyAsync(hc::accelerator &acc, void *dst, void* src, size_t sizeBytes, size_t offset, unsigned kind); - - //--- - // Member functions that begin with locked_ are thread-safe accessors - these acquire / release the critical mutex. - LockedAccessor_StreamCrit_t lockopen_preKernelCommand(); - void lockclose_postKernelCommand(const char *kernelName, hc::accelerator_view *av); - - - void locked_wait(); - - hc::accelerator_view* locked_getAv() { LockedAccessor_StreamCrit_t crit(_criticalData); return &(crit->_av); }; - - void locked_waitEvent(hipEvent_t event); - void locked_recordEvent(hipEvent_t event); - - - //--- - - // Use this if we already have the stream critical data mutex: - void wait(LockedAccessor_StreamCrit_t &crit); - - void launchModuleKernel(hc::accelerator_view av, hsa_signal_t signal, - uint32_t blockDimX, uint32_t blockDimY, uint32_t blockDimZ, - uint32_t gridDimX, uint32_t gridDimY, uint32_t gridDimZ, - uint32_t groupSegmentSize, uint32_t sharedMemBytes, - void *kernarg, size_t kernSize, uint64_t kernel); - - - - //-- Non-racy accessors: - // These functions access fields set at initialization time and are non-racy (so do not acquire mutex) - const ihipDevice_t * getDevice() const; - ihipCtx_t * getCtx() const; - - void ensureHaveQueue(LockedAccessor_StreamCrit_t &streamCrit); - -public: - //--- - //Public member vars - these are set at initialization and never change: - SeqNum_t _id; // monotonic sequence ID - unsigned _flags; - - -private: - - - // The unsigned return is hipMemcpyKind - unsigned resolveMemcpyDirection(bool srcInDeviceMem, bool dstInDeviceMem); - void resolveHcMemcpyDirection(unsigned hipMemKind, - const hc::AmPointerInfo *dstPtrInfo, const hc::AmPointerInfo *srcPtrInfo, - hc::hcCommandKind *hcCopyDir, - ihipCtx_t **copyDevice, - bool *forceUnpinnedCopy); - - bool canSeeMemory(const ihipCtx_t *thisCtx, const hc::AmPointerInfo *dstInfo, const hc::AmPointerInfo *srcInfo); - - void addSymbolPtrToTracker(hc::accelerator& acc, void* ptr, size_t sizeBytes); - -public: // TODO - move private - // Critical Data - MUST be accessed through LockedAccessor_StreamCrit_t - ihipStreamCritical_t _criticalData; - -private: // Data - - std::mutex _hasQueueLock; - - ihipCtx_t *_ctx; // parent context that owns this stream. - - // Friends: - friend std::ostream& operator<<(std::ostream& os, const ihipStream_t& s); - friend hipError_t hipStreamQuery(hipStream_t); - - ScheduleMode _scheduleMode; -}; - - - -//---- -// Internal event structure: -enum hipEventStatus_t { - hipEventStatusUnitialized = 0, // event is unutilized, must be "Created" before use. - hipEventStatusCreated = 1, - hipEventStatusRecording = 2, // event has been enqueued to record something. - hipEventStatusRecorded = 3, // event has been recorded - timestamps are valid. -} ; - - -// internal hip event structure. -struct ihipEvent_t { - hipEventStatus_t _state; - - hipStream_t _stream; // Stream where the event is recorded, or NULL if all streams. - unsigned _flags; - - hc::completion_future _marker; - uint64_t _timestamp; // store timestamp, may be set on host or by marker. -} ; - - - -//============================================================================= -//class ihipDeviceCriticalBase_t -template -class ihipDeviceCriticalBase_t : LockedBase -{ -public: - ihipDeviceCriticalBase_t(ihipDevice_t *parentDevice) : - _parent(parentDevice) - { - }; - - ~ihipDeviceCriticalBase_t() { - - } - - // Contexts: - void addContext(ihipCtx_t *ctx); - void removeContext(ihipCtx_t *ctx); - std::list &ctxs() { return _ctxs; }; - const std::list &const_ctxs() const { return _ctxs; }; - int getcount() {return _ctxCount;}; - friend class LockedAccessor; -private: - ihipDevice_t *_parent; - - //--- Context Tracker: - std::list< ihipCtx_t* > _ctxs; // contexts associated with this device across all threads. - - int _ctxCount; -}; - -typedef ihipDeviceCriticalBase_t ihipDeviceCritical_t; - -typedef LockedAccessor LockedAccessor_DeviceCrit_t; - -//---- -// Properties of the HIP device. -// Multiple contexts can point to same device. -class ihipDevice_t -{ -public: - ihipDevice_t(unsigned deviceId, unsigned deviceCnt, hc::accelerator &acc); - ~ihipDevice_t(); - - // Accessors: - ihipCtx_t *getPrimaryCtx() const { return _primaryCtx; }; - void locked_removeContext(ihipCtx_t *c); - void locked_reset(); - ihipDeviceCritical_t &criticalData() { return _criticalData; }; -public: - unsigned _deviceId; // device ID - - hc::accelerator _acc; - hsa_agent_t _hsaAgent; // hsa agent handle - - //! Number of compute units supported by the device: - unsigned _computeUnits; - hipDeviceProp_t _props; // saved device properties. - - // TODO - report this through device properties, base on HCC API call. - int _isLargeBar; - - ihipCtx_t *_primaryCtx; - - int _state; //1 if device is set otherwise 0 - -private: - hipError_t initProperties(hipDeviceProp_t* prop); -private: - ihipDeviceCritical_t _criticalData; -}; -//============================================================================= - - - -//============================================================================= -//class ihipCtxCriticalBase_t -template -class ihipCtxCriticalBase_t : LockedBase -{ -public: - ihipCtxCriticalBase_t(ihipCtx_t *parentCtx, unsigned deviceCnt) : - _parent(parentCtx), - _peerCnt(0) - { - _peerAgents = new hsa_agent_t[deviceCnt]; - }; - - ~ihipCtxCriticalBase_t() { - if (_peerAgents != nullptr) { - delete _peerAgents; - _peerAgents = nullptr; - } - _peerCnt = 0; - } - - // Streams: - void addStream(ihipStream_t *stream); - std::list &streams() { return _streams; }; - const std::list &const_streams() const { return _streams; }; - - - - // Peer Accessor classes: - bool isPeerWatcher(const ihipCtx_t *peer); // returns True if peer has access to memory physically located on this device. - bool addPeerWatcher(const ihipCtx_t *thisCtx, ihipCtx_t *peer); - bool removePeerWatcher(const ihipCtx_t *thisCtx, ihipCtx_t *peer); - void resetPeerWatchers(ihipCtx_t *thisDevice); - void printPeerWatchers(FILE *f) const; - - uint32_t peerCnt() const { return _peerCnt; }; - hsa_agent_t *peerAgents() const { return _peerAgents; }; - - - // TODO - move private - std::list _peers; // list of enabled peer devices. - - friend class LockedAccessor; -private: - ihipCtx_t * _parent; - - //--- Stream Tracker: - std::list< ihipStream_t* > _streams; // streams associated with this device. - - - //--- Peer Tracker: - // These reflect the currently Enabled set of peers for this GPU: - // Enabled peers have permissions to access the memory physically allocated on this device. - // Note the peers always contain the self agent for easy interfacing with HSA APIs. - uint32_t _peerCnt; // number of enabled peers - hsa_agent_t *_peerAgents; // efficient packed array of enabled agents (to use for allocations.) -private: - void recomputePeerAgents(); -}; -// Note Mutex type Real/Fake selected based on CtxMutex -typedef ihipCtxCriticalBase_t ihipCtxCritical_t; - -// This type is used by functions that need access to the critical device structures. -typedef LockedAccessor LockedAccessor_CtxCrit_t; -//============================================================================= - - -//============================================================================= -//class ihipCtx_t: -// A HIP CTX (context) points at one of the existing devices and contains the streams, -// peer-to-peer mappings, creation flags. Multiple contexts can point to the same -// device. -// -class ihipCtx_t -{ -public: // Functions: - ihipCtx_t(ihipDevice_t *device, unsigned deviceCnt, unsigned flags); // note: calls constructor for _criticalData - ~ihipCtx_t(); - - // Functions which read or write the critical data are named locked_. - // (might be better called "locking_" - // ihipCtx_t does not use recursive locks so the ihip implementation must avoid calling a locked_ function from within a locked_ function. - // External functions which call several locked_ functions will acquire and release the lock for each function. if this occurs in - // performance-sensitive code we may want to refactor by adding non-locked functions and creating a new locked_ member function to call them all. - void locked_removeStream(ihipStream_t *s); - void locked_reset(); - void locked_waitAllStreams(); - void locked_syncDefaultStream(bool waitOnSelf); - - // Will allocate a queue and assign it to the needyStream: - hc::accelerator_view stealActiveQueue(LockedAccessor_CtxCrit_t &ctxCrit, ihipStream_t *needyStream); - hc::accelerator_view createOrStealQueue(LockedAccessor_CtxCrit_t &ctxCrit); - - ihipCtxCritical_t &criticalData() { return _criticalData; }; - - const ihipDevice_t *getDevice() const { return _device; }; - int getDeviceNum() const { return _device->_deviceId; }; - - // TODO - review uses of getWriteableDevice(), can these be converted to getDevice() - ihipDevice_t *getWriteableDevice() const { return _device; }; - - std::string toString() const; - -public: // Data - // The NULL stream is used if no other stream is specified. - // Default stream has special synchronization properties with other streams. - ihipStream_t *_defaultStream; - - // Flags specified when the context is created: - unsigned _ctxFlags; - -private: - ihipDevice_t *_device; - - -private: // Critical data, protected with locked access: - // Members of _protected data MUST be accessed through the LockedAccessor. - // Search for LockedAccessor for examples; do not access _criticalData directly. - ihipCtxCritical_t _criticalData; - -}; - - - -//================================================================================================= -// Global variable definition: -extern std::once_flag hip_initialized; -extern unsigned g_deviceCnt; -extern hsa_agent_t g_cpu_agent ; // the CPU agent. - -//================================================================================================= -// Extern functions: -extern void ihipInit(); -extern const char *ihipErrorString(hipError_t); -extern ihipCtx_t *ihipGetTlsDefaultCtx(); -extern void ihipSetTlsDefaultCtx(ihipCtx_t *ctx); -extern hipError_t ihipSynchronize(void); -extern void ihipCtxStackUpdate(); -extern hipError_t ihipDeviceSetState(); - -extern ihipDevice_t *ihipGetDevice(int); -ihipCtx_t * ihipGetPrimaryCtx(unsigned deviceIndex); - -extern void ihipSetTs(hipEvent_t e); - - -hipStream_t ihipSyncAndResolveStream(hipStream_t); - -// Stream printf functions: -inline std::ostream& operator<<(std::ostream& os, const ihipStream_t& s) -{ - os << "stream:"; - os << s.getDevice()->_deviceId;; - os << '.'; - os << s._id; - return os; -} - -inline std::ostream & operator<<(std::ostream& os, const dim3& s) -{ - os << '{'; - os << s.x; - os << ','; - os << s.y; - os << ','; - os << s.z; - os << '}'; - return os; -} - -inline std::ostream & operator<<(std::ostream& os, const gl_dim3& s) -{ - os << '{'; - os << s.x; - os << ','; - os << s.y; - os << ','; - os << s.z; - os << '}'; - return os; -} - -// Stream printf functions: -inline std::ostream& operator<<(std::ostream& os, const hipEvent_t& e) -{ - os << "event:" << std::hex << static_cast (e); - return os; -} - -inline std::ostream& operator<<(std::ostream& os, const ihipCtx_t* c) -{ - os << "ctx:" << static_cast (c) - << ".dev:" << c->getDevice()->_deviceId; - return os; -} - - -// Helper functions that are used across src files: -namespace hip_internal { - hipError_t memcpyAsync (void* dst, const void* src, size_t sizeBytes, hipMemcpyKind kind, hipStream_t stream); -}; - - -#endif diff --git a/projects/hip/src/hip_hcc_internal.h b/projects/hip/src/hip_hcc_internal.h index 245f154305..4b960e2820 100644 --- a/projects/hip/src/hip_hcc_internal.h +++ b/projects/hip/src/hip_hcc_internal.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef HIP_HCC_H -#define HIP_HCC_H +#ifndef HIP_SRC_HIP_HCC_INTERNAL_H +#define HIP_SRC_HIP_HCC_INTERNAL_H #include #include diff --git a/projects/hip/src/hip_ldg.cpp b/projects/hip/src/hip_ldg.cpp index d91f54a807..549d3ae085 100644 --- a/projects/hip/src/hip_ldg.cpp +++ b/projects/hip/src/hip_ldg.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/projects/hip/src/hip_util.h b/projects/hip/src/hip_util.h index f6817ffccb..8c4d19bb40 100644 --- a/projects/hip/src/hip_util.h +++ b/projects/hip/src/hip_util.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef HIP_UTIL_H -#define HIP_UTIL_H +#ifndef HIP_INCLUDE_HCC_DETAIL_HIP_UTIL_H +#define HIP_INCLUDE_HCC_DETAIL_HIP_UTIL_H #include #include diff --git a/projects/hip/tests/src/hipHcc.cpp b/projects/hip/tests/src/hipHcc.cpp index 9357e5211a..92d9e3e88d 100644 --- a/projects/hip/tests/src/hipHcc.cpp +++ b/projects/hip/tests/src/hipHcc.cpp @@ -30,7 +30,7 @@ THE SOFTWARE. #include #include #include "hip/hip_runtime.h" -#include "hip/hcc.h" +#include "hip/hip_hcc.h" #include "test_common.h" #define CHECK(error) \ @@ -61,4 +61,3 @@ int main(int argc, char *argv[]) passed(); }; - From 668cf3d401f678c9850dc70b9bd15a9b831323d3 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Fri, 31 Mar 2017 13:35:26 -0500 Subject: [PATCH 262/281] Fixed bit_extract Change-Id: I92d7b7a302e3fa0db84889fb5dc6b612e6a53c73 [ROCm/hip commit: 7d0a406fbac3200bba6440330aee7cf209db84ec] --- projects/hip/samples/0_Intro/bit_extract/Makefile | 1 - projects/hip/samples/0_Intro/bit_extract/bit_extract.cpp | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/projects/hip/samples/0_Intro/bit_extract/Makefile b/projects/hip/samples/0_Intro/bit_extract/Makefile index 0965ae7296..78f6a2faa8 100644 --- a/projects/hip/samples/0_Intro/bit_extract/Makefile +++ b/projects/hip/samples/0_Intro/bit_extract/Makefile @@ -24,4 +24,3 @@ $(EXE): bit_extract.cpp clean: rm -f *.o $(EXE) - diff --git a/projects/hip/samples/0_Intro/bit_extract/bit_extract.cpp b/projects/hip/samples/0_Intro/bit_extract/bit_extract.cpp index 1535d2bd98..a30f2d052d 100644 --- a/projects/hip/samples/0_Intro/bit_extract/bit_extract.cpp +++ b/projects/hip/samples/0_Intro/bit_extract/bit_extract.cpp @@ -37,7 +37,7 @@ THE SOFTWARE. }\ } -void __global__ +__global__ void bit_extract_kernel(hipLaunchParm lp, uint32_t *C_d, const uint32_t *A_d, size_t N) { size_t offset = (hipBlockIdx_x * hipBlockDim_x + hipThreadIdx_x); @@ -45,7 +45,7 @@ bit_extract_kernel(hipLaunchParm lp, uint32_t *C_d, const uint32_t *A_d, size_t for (size_t i=offset; i> 8); #endif @@ -73,7 +73,7 @@ int main(int argc, char *argv[]) C_h = (uint32_t*)malloc(Nbytes); CHECK(C_h == 0 ? hipErrorMemoryAllocation : hipSuccess ); - for (size_t i=0; i Date: Fri, 31 Mar 2017 14:13:46 -0500 Subject: [PATCH 263/281] added debug support for HIP sample Change-Id: Ia7265234082039b68114f7421f4dbcb7149d4d2b [ROCm/hip commit: 3eed9aba5d5ad65bc1ae92041b4e0dda146a0a89] --- projects/hip/samples/0_Intro/module_api/runKernel.cpp | 9 ++++++--- projects/hip/src/hip_module.cpp | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/projects/hip/samples/0_Intro/module_api/runKernel.cpp b/projects/hip/samples/0_Intro/module_api/runKernel.cpp index e7d54beb54..355f0bf5da 100644 --- a/projects/hip/samples/0_Intro/module_api/runKernel.cpp +++ b/projects/hip/samples/0_Intro/module_api/runKernel.cpp @@ -33,6 +33,9 @@ THE SOFTWARE. #define fileName "vcpy_kernel.code" #define kernel_name "hello_world" +#define HIP_CHECK(status) \ +if(status != hipSuccess) {std::cout<<"Got Status: "< Date: Fri, 31 Mar 2017 14:30:40 -0500 Subject: [PATCH 264/281] added module api sample which uses hipHccModuleLaunchKernel Change-Id: I7bce60b4480a3b5ff7ed69c3256078ded65a0945 [ROCm/hip commit: 6e1756fe23583fe14a3177f58f17a8d3a65d943a] --- .../hip/samples/0_Intro/module_api/Makefile | 3 + .../0_Intro/module_api/launchKernelHcc.cpp | 112 ++++++++++++++++++ .../samples/0_Intro/module_api/runKernel.cpp | 4 - 3 files changed, 115 insertions(+), 4 deletions(-) create mode 100644 projects/hip/samples/0_Intro/module_api/launchKernelHcc.cpp diff --git a/projects/hip/samples/0_Intro/module_api/Makefile b/projects/hip/samples/0_Intro/module_api/Makefile index 632a8d3e70..38bd00a6a6 100644 --- a/projects/hip/samples/0_Intro/module_api/Makefile +++ b/projects/hip/samples/0_Intro/module_api/Makefile @@ -10,6 +10,9 @@ all: vcpy_kernel.code runKernel.hip.out defaultDriver.hip.out runKernel.hip.out: runKernel.cpp $(HIPCC) $(HIPCC_FLAGS) $< -o $@ +launchKernelHcc.hip.out: launchKernelHcc.cpp + $(HIPCC) $(HIPCC_FLAGS) $< -o $@ + defaultDriver.hip.out: defaultDriver.cpp $(HIPCC) $(HIPCC_FLAGS) $< -o $@ diff --git a/projects/hip/samples/0_Intro/module_api/launchKernelHcc.cpp b/projects/hip/samples/0_Intro/module_api/launchKernelHcc.cpp new file mode 100644 index 0000000000..e86e44cb24 --- /dev/null +++ b/projects/hip/samples/0_Intro/module_api/launchKernelHcc.cpp @@ -0,0 +1,112 @@ +/* +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + + + +#include "hip/hip_runtime.h" +#include "hip/hip_runtime_api.h" +#include +#include +#include + +#ifdef __HIP_PLATFORM_HCC__ +#include +#endif + +#define LEN 64 +#define SIZE LEN<<2 + +#define fileName "vcpy_kernel.code" +#define kernel_name "hello_world" + +#define HIP_CHECK(status) \ +if(status != hipSuccess) {std::cout<<"Got Status: "< Date: Sat, 1 Apr 2017 08:21:06 -0500 Subject: [PATCH 265/281] Move current GGL limitations to hip_bugs.md Change-Id: I77d0eae0a67eccef7dd2bea0f402736642c96554 [ROCm/hip commit: 15de25b6d242a90cb14de81cf7c838a8f7e03023] --- projects/hip/docs/markdown/hip_bugs.md | 9 ++++++--- projects/hip/docs/markdown/hip_faq.md | 5 ----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/projects/hip/docs/markdown/hip_bugs.md b/projects/hip/docs/markdown/hip_bugs.md index 3274ed5b5c..e15c37fc54 100644 --- a/projects/hip/docs/markdown/hip_bugs.md +++ b/projects/hip/docs/markdown/hip_bugs.md @@ -4,6 +4,7 @@ - [Errors related to undefined reference to `__hcLaunchKernel__***__grid_launch_parm**](#errors-related-to-undefined-reference-to-hclaunchkernel__grid_launch_parm) - [Application hangs after a hipLaunchKernel call](#what-if-i-see-application-hangs-after-a-hiplaunchkernel-call) +- [What is the current limitation of HIP Generic Grid Launch method?](#what-is-the-current-limitation-of-hip-generic-grid-launch-method) @@ -23,8 +24,6 @@ namespace { __global__ MyKernel … - Avoid calling member functions - -### What if I see application hangs after a hipLaunchKernel call? If hipLaunchKernel takes parameters that request explicitly memcpy, then it will cause application hang. Reason is that the hipLaunchKernel macro locks the stream. If kernel paramters are actually function calls which invoke other hip apis (i.e. memcpy) to the same stream, then deadlock occurs. @@ -43,4 +42,8 @@ auto bot_gpu_data = bottom[0]->gpu_data(); hipLaunchKernel( LRNComputeDiff, dim3(CAFFE_GET_BLOCKS(n_threads)), dim3(CAFFE_HIP_NUM_THREADS), 0, 0, n_threads, bot_gpu_data); -``` \ No newline at end of file +``` + +### What is the current limitation of HIP Generic Grid Launch method? +1. __global__ functions cannot be marked as static or put in an unnamed namespace i.e. they cannot be given internal linkage (this would clash with __attribute__((weak))); +2. using the macro based dispatch mechanism i.e. hipLaunchKernel* only works for functions that take no more than 20 arguments (this limit can be increased up to 126, and is temporary until we can enable C++14 mode and use variadic generic lambdas); no such limitation applies do dispatching directly through grid_launch. \ No newline at end of file diff --git a/projects/hip/docs/markdown/hip_faq.md b/projects/hip/docs/markdown/hip_faq.md index ee7e5dd347..8ccb458103 100644 --- a/projects/hip/docs/markdown/hip_faq.md +++ b/projects/hip/docs/markdown/hip_faq.md @@ -27,7 +27,6 @@ * [Using CodeXL markers for HIP Functions](#using-codexl-markers-for-hip-functions) * [Using HIP_TRACE_API](#using-hip_trace_api) - [How do I enable HIP Generic Grid Launch option?](#how-do-i-enable-hip-generic-grid-launch-option) -- [What is the current limitation of HIP Generic Grid Launch method?](#what-is-the-current-limitation-of-hip-generic-grid-launch-method) @@ -243,7 +242,3 @@ To disable it and use the legancy grid launch method, please either change the d $HIP/include/hip/hcc_detail/hip_runtime_api.h $HIP/include/hip/hcc_detail/host_defines.h Or pass "-DGENERIC_GRID_LAUNCH=0" to hipcc at application compilation time. - -### What is the current limitation of HIP Generic Grid Launch method? -1. __global__ functions cannot be marked as static or put in an unnamed namespace i.e. they cannot be given internal linkage (this would clash with __attribute__((weak))); -2. using the macro based dispatch mechanism i.e. hipLaunchKernel* only works for functions that take no more than 20 arguments (this limit can be increased up to 126, and is temporary until we can enable C++14 mode and use variadic generic lambdas); no such limitation applies do dispatching directly through grid_launch. \ No newline at end of file From 7559427041e9932ffc24ccba65dbfb407efcf4ca Mon Sep 17 00:00:00 2001 From: "Sun, Peng" Date: Sat, 1 Apr 2017 14:50:39 -0500 Subject: [PATCH 266/281] GGL update, fix for thread-safe access to streams (accelerator_views). Change-Id: I6dd329a85b3ba7de23d52823febee0c53857a981 [ROCm/hip commit: b1ed910942d22a0503e58515655d639b0f972094] --- projects/hip/CMakeLists.txt | 1 + .../hip/include/hip/hcc_detail/concepts.hpp | 2 +- ...grid_launch_v2.hpp => grid_launch_GGL.hpp} | 181 +++++++++++++++--- .../hip/include/hip/hcc_detail/helpers.hpp | 2 +- .../hip/include/hip/hcc_detail/hip_runtime.h | 4 +- 5 files changed, 157 insertions(+), 33 deletions(-) rename projects/hip/include/hip/hcc_detail/{grid_launch_v2.hpp => grid_launch_GGL.hpp} (86%) diff --git a/projects/hip/CMakeLists.txt b/projects/hip/CMakeLists.txt index dcecaa8d2f..9d6bf26f56 100644 --- a/projects/hip/CMakeLists.txt +++ b/projects/hip/CMakeLists.txt @@ -179,6 +179,7 @@ if(HIP_PLATFORM STREQUAL "hcc") src/hip_peer.cpp src/hip_stream.cpp src/hip_module.cpp + src/grid_launch.cpp src/env.cpp) set(SOURCE_FILES_DEVICE diff --git a/projects/hip/include/hip/hcc_detail/concepts.hpp b/projects/hip/include/hip/hcc_detail/concepts.hpp index 6824ad9bdf..5c50f5d577 100644 --- a/projects/hip/include/hip/hcc_detail/concepts.hpp +++ b/projects/hip/include/hip/hcc_detail/concepts.hpp @@ -22,7 +22,7 @@ THE SOFTWARE. #pragma once -namespace glo_tests // Documentation only. +namespace hip_impl // Documentation only. { #define requires(...) diff --git a/projects/hip/include/hip/hcc_detail/grid_launch_v2.hpp b/projects/hip/include/hip/hcc_detail/grid_launch_GGL.hpp similarity index 86% rename from projects/hip/include/hip/hcc_detail/grid_launch_v2.hpp rename to projects/hip/include/hip/hcc_detail/grid_launch_GGL.hpp index 8b1eded2f3..e2965184f6 100644 --- a/projects/hip/include/hip/hcc_detail/grid_launch_v2.hpp +++ b/projects/hip/include/hip/hcc_detail/grid_launch_GGL.hpp @@ -27,7 +27,7 @@ THE SOFTWARE. #include "hc.hpp" #include "hip_hcc.h" - +#include "hip_runtime.h" #include #include #include @@ -38,13 +38,39 @@ namespace hip_impl { struct New_grid_launch_tag {}; struct Old_grid_launch_tag {}; - } - template - using is_new_grid_launch_t = typename std::conditional< - std::is_callable{}, - New_grid_launch_tag, - Old_grid_launch_tag>::type; + template + class RAII_guard { + D dtor_; + public: + RAII_guard() = default; + + RAII_guard(const C& ctor, D dtor) : dtor_{std::move(dtor)} + { + ctor(); + } + + RAII_guard(const RAII_guard&) = default; + RAII_guard(RAII_guard&&) = default; + + RAII_guard& operator=(const RAII_guard&) = default; + RAII_guard& operator=(RAII_guard&&) = default; + + ~RAII_guard() { dtor_(); } + }; + + template + RAII_guard make_RAII_guard(const C& ctor, D dtor) + { + return RAII_guard{ctor, std::move(dtor)}; + } + + template + using is_new_grid_launch_t = typename std::conditional< + std::is_callable{}, + New_grid_launch_tag, + Old_grid_launch_tag>::type; + } // TODO: - dispatch rank should be derived from the domain dimensions passed // in, and not always assumed to be 3; @@ -52,12 +78,12 @@ namespace hip_impl template requires(Domain == {Ts...}) inline - void grid_launch_impl( + void grid_launch_hip_impl_( New_grid_launch_tag, dim3 num_blocks, dim3 dim_blocks, int group_mem_bytes, - hipStream_t stream, + const hc::accelerator_view& acc_v, K k, Ts&&... args) { @@ -69,21 +95,69 @@ namespace hip_impl dim_blocks.y, dim_blocks.x, group_mem_bytes); - hc::accelerator_view* av = nullptr; - if (hipHccGetAcceleratorView(stream, &av) != HIP_SUCCESS) { - throw std::runtime_error{"Failed to retrieve accelerator_view!"}; + try { + hc::parallel_for_each( + acc_v, + d, + [=](const hc::tiled_index<3>& idx) [[hc]] { + k(args...); + }); } + catch (std::exception& ex) { + std::cerr << "Failed in " << __FUNCTION__ << ", with exception: " + << ex.what() << std::endl; + throw; + } + } - hc::parallel_for_each(*av, d, [=](const hc::tiled_index<3>& idx) [[hc]] { - k(args...); - }); + // TODO: these are workarounds, they should be removed. + + hc::accelerator_view lock_stream_hip_(hipStream_t&, void*&); + void unlock_stream_hip_( + hipStream_t, void*, const char*, hc::accelerator_view*); + + template + requires(Domain == {Ts...}) + inline + void grid_launch_hip_impl_( + New_grid_launch_tag, + dim3 num_blocks, + dim3 dim_blocks, + int group_mem_bytes, + hipStream_t stream, + const char* kernel_name, + K k, + Ts&&... args) + { + void* lck_stream = nullptr; + auto acc_v = lock_stream_hip_(stream, lck_stream); + auto stream_guard = make_RAII_guard( + [](){ /* perhaps use a slimmed down ihipPrintKernelLaunch here */ }, + std::bind( + unlock_stream_hip_, stream, lck_stream, kernel_name, &acc_v)); + + try { + grid_launch_hip_impl_( + New_grid_launch_tag{}, + std::move(num_blocks), + std::move(dim_blocks), + group_mem_bytes, + acc_v, + std::move(k), + std::forward(args)...); + } + catch (std::exception& ex) { + std::cerr << "Failed in " << __FUNCTION__ << ", with exception: " + << ex.what() << std::endl; + throw; + } } template requires(Domain == {hipLaunchParm, Ts...}) inline - void grid_launch_impl( + void grid_launch_hip_impl_( Old_grid_launch_tag, dim3 num_blocks, dim3 dim_blocks, @@ -92,7 +166,7 @@ namespace hip_impl K k, Ts&&... args) { - grid_launch_impl( + grid_launch_hip_impl_( New_grid_launch_tag{}, std::move(num_blocks), std::move(dim_blocks), @@ -103,10 +177,58 @@ namespace hip_impl std::forward(args)...); } + template + requires(Domain == {hipLaunchParm, Ts...}) + inline + void grid_launch_hip_impl_( + Old_grid_launch_tag, + dim3 num_blocks, + dim3 dim_blocks, + int group_mem_bytes, + hipStream_t stream, + const char* kernel_name, + K k, + Ts&&... args) + { + grid_launch_hip_impl_( + New_grid_launch_tag{}, + std::move(num_blocks), + std::move(dim_blocks), + group_mem_bytes, + std::move(stream), + kernel_name, + std::move(k), + hipLaunchParm{}, + std::forward(args)...); + } + template requires(Domain == {Ts...}) inline - std::enable_if_t::value> grid_launch( + std::enable_if_t::value> grid_launch_hip_( + dim3 num_blocks, + dim3 dim_blocks, + int group_mem_bytes, + hipStream_t stream, + const char* kernel_name, + K k, + Ts&& ... args) + { + grid_launch_hip_impl_( + is_new_grid_launch_t{}, + std::move(num_blocks), + std::move(dim_blocks), + group_mem_bytes, + std::move(stream), + kernel_name, + std::move(k), + std::forward(args)...); + } + + template + requires(Domain == {Ts...}) + inline + std::enable_if_t::value> grid_launch_hip_( dim3 num_blocks, dim3 dim_blocks, int group_mem_bytes, @@ -114,7 +236,7 @@ namespace hip_impl K k, Ts&& ... args) { - grid_launch_impl( + grid_launch_hip_impl_( is_new_grid_launch_t{}, std::move(num_blocks), std::move(dim_blocks), @@ -129,7 +251,7 @@ namespace hip_impl template constexpr inline - T&& forward(std::remove_reference_t& x) [[hc]] + T&& forward_(std::remove_reference_t& x) [[hc]] { return static_cast(x); } @@ -139,7 +261,7 @@ namespace hip_impl template void operator()(Ts&&...args) const [[hc]] { - k(forward(args)...); + k(forward_(args)...); } }; } @@ -155,7 +277,7 @@ namespace hip_impl hipStream_t stream, Ts&&... args) { - grid_launch_impl( + grid_launch_hip_impl_( New_grid_launch_tag{}, std::move(num_blocks), std::move(dim_blocks), @@ -176,7 +298,7 @@ namespace hip_impl hipStream_t stream, Ts&&... args) { - grid_launch( + grid_launch_hip_( New_grid_launch_tag{}, std::move(num_blocks), std::move(dim_blocks), @@ -189,14 +311,14 @@ namespace hip_impl template requires(Domain == {Ts...}) inline - std::enable_if_t::value> grid_launch( + std::enable_if_t::value> grid_launch_hip_( dim3 num_blocks, dim3 dim_blocks, int group_mem_bytes, hipStream_t stream, Ts&&... args) { - grid_launch( + grid_launch_hip_( is_new_grid_launch_t{}, std::move(num_blocks), std::move(dim_blocks), @@ -685,7 +807,7 @@ namespace hip_impl kernel_name(_p0_);\ } #define make_kernel_lambda_hip_1(kernel_name)\ - []() [[hc]] { kernel_name(lp); } + []() [[hc]] { return kernel_name(hipLaunchParm{}); } #define make_kernel_lambda_hip_(...)\ overload_macro_hip_(make_kernel_lambda_hip_, __VA_ARGS__) @@ -697,15 +819,16 @@ namespace hip_impl group_mem_bytes,\ stream,\ ...)\ - {\ - hip_impl::grid_launch(\ + do {\ + hip_impl::grid_launch_hip_(\ num_blocks,\ dim_blocks,\ group_mem_bytes,\ stream,\ + #kernel_name,\ make_kernel_lambda_hip_(kernel_name, __VA_ARGS__),\ ##__VA_ARGS__);\ - } + } while(0) #define hipLaunchKernel(\ kernel_name,\ diff --git a/projects/hip/include/hip/hcc_detail/helpers.hpp b/projects/hip/include/hip/hcc_detail/helpers.hpp index 5ab866dc66..e5a84a4678 100644 --- a/projects/hip/include/hip/hcc_detail/helpers.hpp +++ b/projects/hip/include/hip/hcc_detail/helpers.hpp @@ -123,7 +123,7 @@ namespace std #endif } -namespace // Only for documentation, macros ignore namespaces. +namespace hip_impl // Only for documentation, macros ignore namespaces. { #define count_macro_args_impl_hip_(\ _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15,\ diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime.h b/projects/hip/include/hip/hcc_detail/hip_runtime.h index 9692b16a4c..e0375269e7 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime.h @@ -68,7 +68,7 @@ THE SOFTWARE. #else namespace hip_impl { - struct Empty_launch_parm{}; + struct Empty_launch_parm {}; } #define hipLaunchParm hip_impl::Empty_launch_parm #endif //GENERIC_GRID_LAUNCH @@ -81,7 +81,7 @@ namespace hip_impl #endif //HCC #if GENERIC_GRID_LAUNCH==1 && defined __HCC__ -#include "grid_launch_v2.hpp" +#include "grid_launch_GGL.hpp" #endif//GENERIC_GRID_LAUNCH extern int HIP_TRACE_API; From 9b6b29a5350ae6eb3a93cfa671f517ce5139689d Mon Sep 17 00:00:00 2001 From: "Sun, Peng" Date: Sat, 1 Apr 2017 14:57:47 -0500 Subject: [PATCH 267/281] Add grid_launch.cpp for GGL Change-Id: I87ff9b3f1203d0909f998c96c839f7b321fc3f09 [ROCm/hip commit: 80a99350a303ad61723a601df4ea28e382766f4d] --- projects/hip/src/grid_launch.cpp | 38 ++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 projects/hip/src/grid_launch.cpp diff --git a/projects/hip/src/grid_launch.cpp b/projects/hip/src/grid_launch.cpp new file mode 100644 index 0000000000..6e2812f159 --- /dev/null +++ b/projects/hip/src/grid_launch.cpp @@ -0,0 +1,38 @@ +#include "hip/hcc_detail/grid_launch_GGL.hpp" + +// Internal header, do not percolate upwards. +#include "hip_hcc_internal.h" +#include "hc.hpp" +#include "trace_helper.h" + +namespace hip_impl +{ + hc::accelerator_view lock_stream_hip_( + hipStream_t& stream, void*& locked_stream) + { // This allocated but does not take ownership of locked_stream. If it is + // not deleted elsewhere it will leak. + using L = decltype(stream->lockopen_preKernelCommand()); + + HIP_INIT(); + + stream = ihipSyncAndResolveStream(stream); + locked_stream = new L{stream->lockopen_preKernelCommand()}; + return (*static_cast(locked_stream))->_av; + } + + void unlock_stream_hip_( + hipStream_t stream, + void* locked_stream, + const char* kernel_name, + hc::accelerator_view* acc_v) + { // Precondition: acc_v is the accelerator_view associated with stream + // which is guarded by locked_stream; + // locked_stream is deletable. + using L = decltype(stream->lockopen_preKernelCommand()); + + stream->lockclose_postKernelCommand(kernel_name, acc_v); + + delete static_cast(locked_stream); + locked_stream = nullptr; + } +} From b39b214a9886604290866b7ecb2a21dc7794e473 Mon Sep 17 00:00:00 2001 From: "Sun, Peng" Date: Sat, 1 Apr 2017 15:01:00 -0500 Subject: [PATCH 268/281] Disable LLVM related config in CMakeLists.txt Change-Id: I02e52264219d68c1ae8ea37c8df166a0edf9f7cd [ROCm/hip commit: 608bd58a3112f4455bc4d5b2ba135c762aae1f16] --- projects/hip/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/hip/CMakeLists.txt b/projects/hip/CMakeLists.txt index 9d6bf26f56..94ed2a7562 100644 --- a/projects/hip/CMakeLists.txt +++ b/projects/hip/CMakeLists.txt @@ -191,11 +191,11 @@ if(HIP_PLATFORM STREQUAL "hcc") execute_process(COMMAND ${HCC_HOME}/bin/hcc-config --ldflags OUTPUT_VARIABLE HCC_LD_FLAGS) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${HCC_LD_FLAGS} -Wl,-Bsymbolic") - find_package(LLVM HINTS ${HCC_HOME}/compiler/lib/cmake) + #find_package(LLVM HINTS ${HCC_HOME}/compiler/lib/cmake) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --amdgpu-target=gfx701 --amdgpu-target=gfx801 --amdgpu-target=gfx802 --amdgpu-target=gfx803 --amdgpu-target=gfx900") add_library(hip_hcc SHARED ${SOURCE_FILES_RUNTIME}) target_link_libraries(hip_hcc PRIVATE hc_am) - target_link_libraries(hip_hcc PUBLIC LLVMAMDGPUUtils) + #target_link_libraries(hip_hcc PUBLIC LLVMAMDGPUUtils) add_library(hip_hcc_static STATIC ${SOURCE_FILES_RUNTIME}) target_link_libraries(hip_hcc_static PRIVATE hc_am) add_dependencies(hip_hcc_static hip_hcc) From 5a6869d4501d75f4365f2802ba385a4372828cb5 Mon Sep 17 00:00:00 2001 From: "Sun, Peng" Date: Sat, 1 Apr 2017 15:12:00 -0500 Subject: [PATCH 269/281] Add copy right in grid_launch.cpp Change-Id: I7de3fc32f13182b5c41a4e44147b642ba15e8636 [ROCm/hip commit: 27bbeedabb702dc86c6714ca6acce3bdd1dda236] --- projects/hip/src/grid_launch.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/projects/hip/src/grid_launch.cpp b/projects/hip/src/grid_launch.cpp index 6e2812f159..7739995600 100644 --- a/projects/hip/src/grid_launch.cpp +++ b/projects/hip/src/grid_launch.cpp @@ -1,3 +1,25 @@ +/* +Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + #include "hip/hcc_detail/grid_launch_GGL.hpp" // Internal header, do not percolate upwards. From dd0aa2c9e3f58f922ed773e0d762a7d803f79e10 Mon Sep 17 00:00:00 2001 From: "Sun, Peng" Date: Sat, 1 Apr 2017 15:42:53 -0500 Subject: [PATCH 270/281] Fix warpSize, for related issue in hipeigen and torch Change-Id: Ic66b24923a363304dca189011869ba7a0a6f8895 [ROCm/hip commit: c82c84949cf1fe757b2dc39ce723c219cac14554] --- projects/hip/include/hip/hcc_detail/hip_runtime.h | 3 +-- projects/hip/src/device_util.cpp | 4 ---- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime.h b/projects/hip/include/hip/hcc_detail/hip_runtime.h index e0375269e7..06ce65bc9a 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime.h @@ -159,8 +159,7 @@ extern int HIP_TRACE_API; // TODO - hipify-clang - change to use the function call. //#define warpSize hc::__wavesize() -extern const int warpSize; - +static constexpr int warpSize = 64; #define clock_t long long int __device__ long long int clock64(); diff --git a/projects/hip/src/device_util.cpp b/projects/hip/src/device_util.cpp index b0df62f43b..8ce53765b5 100644 --- a/projects/hip/src/device_util.cpp +++ b/projects/hip/src/device_util.cpp @@ -835,10 +835,6 @@ __device__ float __hip_ynf(int n, float x) return b0; } - - -const int warpSize = 64; - __device__ long long int clock64() { return (long long int)hc::__cycle_u64(); }; __device__ clock_t clock() { return (clock_t)hc::__cycle_u64(); }; From fbb7b94b9ca2f361f837888fff128674761d03f5 Mon Sep 17 00:00:00 2001 From: "Sun, Peng" Date: Sun, 2 Apr 2017 11:56:15 -0500 Subject: [PATCH 271/281] Fix hip Module APIs by disabling GGL when hipcc takes -genco option Change-Id: I0a79e9c8e750f92c3d0be336d6ff709a2d1afd63 [ROCm/hip commit: 86864a29e4d863c65928677699e6e2fd8d90b2d6] --- projects/hip/bin/hccgenco.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/hip/bin/hccgenco.sh b/projects/hip/bin/hccgenco.sh index 7f90cce83d..9d7f602911 100755 --- a/projects/hip/bin/hccgenco.sh +++ b/projects/hip/bin/hccgenco.sh @@ -45,7 +45,7 @@ for inputfile in $INPUT_FILES; do done printf "\nint main(){}\n" >> $hipgenisa_main -$HIP_PATH/bin/hipcc $hipgenisa_files -o $hipgenisa_dir/a.out +$HIP_PATH/bin/hipcc -DGENERIC_GRID_LAUNCH=0 $hipgenisa_files -o $hipgenisa_dir/a.out mv dump* $hipgenisa_dir hsaco_file="dump-$ROCM_TARGET.hsaco" From c8214a5b20a7b01c666bd32cd58dbfada388f587 Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Mon, 3 Apr 2017 11:18:30 +0530 Subject: [PATCH 272/281] Enable promote free HCC by default Change-Id: I5f82a8d958dd675a8a46d9d17458c71321daab7c [ROCm/hip commit: 822fc802a0f7feabb65de347f3721135ccfd6d2f] --- projects/hip/include/hip/hcc_detail/host_defines.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/hip/include/hip/hcc_detail/host_defines.h b/projects/hip/include/hip/hcc_detail/host_defines.h index 4f44774700..b0a7421d18 100644 --- a/projects/hip/include/hip/hcc_detail/host_defines.h +++ b/projects/hip/include/hip/hcc_detail/host_defines.h @@ -28,7 +28,7 @@ THE SOFTWARE. #ifndef HIP_INCLUDE_HIP_HCC_DETAIL_HOST_DEFINES_H #define HIP_INCLUDE_HIP_HCC_DETAIL_HOST_DEFINES_H -#define USE_PROMOTE_FREE_HCC 0 +#define USE_PROMOTE_FREE_HCC 1 // Add guard to Generic Grid Launch method #ifndef GENERIC_GRID_LAUNCH From 54fe4d2d09c5cc2a8eebfcfcce3511c05617ef4e Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Mon, 3 Apr 2017 15:09:31 +0530 Subject: [PATCH 273/281] Force stdlib=libc++ on UB14.04 Change-Id: I7f24d663e57fbbee56afde12a0e61fc8bfc1e9b6 [ROCm/hip commit: 90cd2945f995f7943d55cb2e38e8942fce1b3dd2] --- projects/hip/bin/hipcc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/projects/hip/bin/hipcc b/projects/hip/bin/hipcc index de4883fea3..bcd3e3a591 100755 --- a/projects/hip/bin/hipcc +++ b/projects/hip/bin/hipcc @@ -123,6 +123,14 @@ if ($HIP_PLATFORM eq "hcc") { } } + # Force -stdlib=libc++ on UB14.04 + $HOST_OSNAME= `cat /etc/os-release | grep "^ID\=" | cut -d= -f2 | tr -d '\n'`; + $HOST_OSVER= `cat /etc/os-release | grep "^VERSION_ID\=" | cut -d= -f2 | tr -d '\n'`; + if ($HOST_OSNAME eq "ubuntu" and $HOST_OSVER eq "\"14.04\"") { + $HIPCXXFLAGS .= " -stdlib=libc++"; + $setStdLib = 1; + } + $HIPCXXFLAGS .= " -I$HIP_PATH/include/hip/hcc_detail/cuda"; $HIPCXXFLAGS .= " -I$HSA_PATH/include"; $HIPCXXFLAGS .= " -Wno-deprecated-register"; From 5c46c8920c21034eafc60c3fc1c054e550db3843 Mon Sep 17 00:00:00 2001 From: "Sun, Peng" Date: Mon, 3 Apr 2017 11:06:18 -0500 Subject: [PATCH 274/281] Add more include header file for GGL, to make it self-compilable Change-Id: I833cb194784450fb86e7961a7f9fe196ce3c7da5 [ROCm/hip commit: a92cdbaf29b413c08c32b8f71576182f69c901a3] --- projects/hip/include/hip/hcc_detail/grid_launch_GGL.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/projects/hip/include/hip/hcc_detail/grid_launch_GGL.hpp b/projects/hip/include/hip/hcc_detail/grid_launch_GGL.hpp index e2965184f6..4fd7c3ff3a 100644 --- a/projects/hip/include/hip/hcc_detail/grid_launch_GGL.hpp +++ b/projects/hip/include/hip/hcc_detail/grid_launch_GGL.hpp @@ -28,6 +28,9 @@ THE SOFTWARE. #include "hc.hpp" #include "hip_hcc.h" #include "hip_runtime.h" + +#include +#include #include #include #include From 8f4dc83926639bad651bea63593c0a8e23c91a27 Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Fri, 7 Apr 2017 15:40:09 +0530 Subject: [PATCH 275/281] Merge branch 'amd-develop' into amd-master Change-Id: I53d5a8916d769c4f0fe60d2ee3b240551da80b4f (cherry picked from commit 60093c286fc124753e5ff2dd20893f1926745c56) [ROCm/hip commit: bb8c51a12902943f193c6c1159933c5e5d8d17f7] --- projects/hip/docs/markdown/hip_bugs.md | 188 +++++++++++++++--- projects/hip/docs/markdown/hip_faq.md | 9 +- .../hip/docs/markdown/hip_kernel_language.md | 1 + .../hip/docs/markdown/hip_porting_guide.md | 9 +- projects/hip/docs/markdown/hip_profiling.md | 46 +++-- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 21 +- .../hip/hcc_detail/grid_launch_GGL.hpp | 23 ++- .../hip/include/hip/hcc_detail/hip_complex.h | 53 +++-- .../hip/include/hip/hcc_detail/hip_fp16.h | 2 +- projects/hip/include/hip/hcc_detail/hip_hcc.h | 43 +++- .../include/hip/hcc_detail/hip_runtime_api.h | 23 +-- .../include/hip/hcc_detail/hip_vector_types.h | 2 +- .../packaging/create_hip_samples_installer.sh | 23 --- projects/hip/packaging/hip_doc.txt | 15 +- .../hip/samples/0_Intro/bit_extract/Makefile | 4 - .../hip/samples/1_Utils/hipCommander/Makefile | 3 - .../1_Utils/hipCommander/hipCommander.cpp | 1 - projects/hip/src/hip_event.cpp | 60 +++++- projects/hip/src/hip_hcc.cpp | 17 -- projects/hip/src/hip_hcc_internal.h | 32 ++- projects/hip/src/hip_memory.cpp | 13 +- projects/hip/src/hip_module.cpp | 32 ++- .../tests/src/deviceLib/hipDeviceMemcpy.cpp | 45 +++-- 23 files changed, 451 insertions(+), 214 deletions(-) delete mode 100755 projects/hip/packaging/create_hip_samples_installer.sh diff --git a/projects/hip/docs/markdown/hip_bugs.md b/projects/hip/docs/markdown/hip_bugs.md index e15c37fc54..73133843bc 100644 --- a/projects/hip/docs/markdown/hip_bugs.md +++ b/projects/hip/docs/markdown/hip_bugs.md @@ -1,49 +1,177 @@ -# HIP Bugs +# HIP Bugs -- [Errors related to undefined reference to `__hcLaunchKernel__***__grid_launch_parm**](#errors-related-to-undefined-reference-to-hclaunchkernel__grid_launch_parm) -- [Application hangs after a hipLaunchKernel call](#what-if-i-see-application-hangs-after-a-hiplaunchkernel-call) +- [Errors related to undefined reference to `__hcLaunchKernel__***__grid_launch_parm**`](#errors-related-to-undefined-reference-to-__hclaunchkernel____grid_launch_parm) - [What is the current limitation of HIP Generic Grid Launch method?](#what-is-the-current-limitation-of-hip-generic-grid-launch-method) +- [Errors related to `no matching constructor`](#errors-related-to-no-matching-constructor) +- [HIP is more restrictive in enforcing restrictions](#hip-is-more-restrictive-in-enforcing-restrictions) -### Errors related to undefined reference to `__hcLaunchKernel__***__grid_launch_parm** +### Errors related to undefined reference to `__hcLaunchKernel__***__grid_launch_parm**` Some common code practices may lead to hipcc generating a error with the form : undefined reference to `__hcLaunchKernel__ZN15vecAddNamespace6vecAddIidEEv16grid_launch_parmPT0_S3_S3_T_ -To workaround, try: -- Avoid calling hcLaunchKernel from a function with the __host__ attribute -__host__ MyFunc(…) { -hipLaunchKernel(myKernel, …) +Suggested workarounds: - Avoid use of static with kernel definition: +```c++ static __global__ MyKernel -- Avoid defining kernels in anonymous namespace +``` + +- Avoid defining kernels in anonymous namespace : +```c++ namespace { -__global__ MyKernel … -- Avoid calling member functions - -If hipLaunchKernel takes parameters that request explicitly memcpy, then it will cause application hang. -Reason is that the hipLaunchKernel macro locks the stream. -If kernel paramters are actually function calls which invoke other hip apis (i.e. memcpy) to the same stream, then deadlock occurs. - -To workaround, try: -Move the function calls so they occur outside the hipLaunchKernel macro, store results in temps, then use the tems inside the kernel. - + __global__ MyKernel +} ``` -// Example pseudo code causing system hang: -// "bottom[0]->gpu_data()" calls hipMemcpy() implicitly and using the same stream, cause deadlock condition. -hipLaunchKernel(HIP_KERNEL_NAME(LRNComputeDiff),dim3(CAFFE_GET_BLOCKS(n_threads)), dim3(CAFFE_HIP_NUM_THREADS), 0, 0, n_threads, - bottom[0]->gpu_data()); - -// Move "gpu_data()" ouside of hipLaunchKernel to avoid hang. -auto bot_gpu_data = bottom[0]->gpu_data(); -hipLaunchKernel( LRNComputeDiff, dim3(CAFFE_GET_BLOCKS(n_threads)), dim3(CAFFE_HIP_NUM_THREADS), 0, 0, n_threads, - bot_gpu_data); -``` ### What is the current limitation of HIP Generic Grid Launch method? 1. __global__ functions cannot be marked as static or put in an unnamed namespace i.e. they cannot be given internal linkage (this would clash with __attribute__((weak))); -2. using the macro based dispatch mechanism i.e. hipLaunchKernel* only works for functions that take no more than 20 arguments (this limit can be increased up to 126, and is temporary until we can enable C++14 mode and use variadic generic lambdas); no such limitation applies do dispatching directly through grid_launch. \ No newline at end of file +2. using the macro based dispatch mechanism i.e. hipLaunchKernel* only works for functions that take no more than 20 arguments (this limit can be increased up to 126, and is temporary until we can enable C++14 mode and use variadic generic lambdas); no such limitation applies do dispatching directly through grid_launch. + + +### Errors related to `no matching constructor` + +The symptom is the compiler would complain about errors like `no matching constructor` for classes/structs passed as arguments into a GPU kernel. Often, this is caused by a design limitation in HCC where array-typed member variables inside a class/struct can’t be correctly passed into GPU kernels. To mitigate this issue, a custom serializer/deserializer pair is provided. + +For example, `Foo` in the code snippets below contains an array-typed member variable `table`, which would fail the compiler if used as a kernel argument. + +``` +struct Foo { + // table is an array, which makes foo + int table[3]; +}; +``` + +An workaround is to provide a custom serializer on CPU side, and append the contents of the array as kernel arguments: + +``` + +struct Foo { + int table[3]; + + // user-provided CPU serializer + // must append the contents of the array member as kernel arguments +#ifdef __HCC__ + __attribute__((annotate(“serialize”))) + void __cxxamp_serialize(Kalmar::Serialize &s) const { + for (int i = 0; i < 3; ++i) + s.Append(sizeof(int), &table[i]); + } +#endif +}; +``` + +Then, provide a custom deserializer on GPU side, to help reconstruct the array within GPU kernels. Notice that the deserializer can not be a function template, and should have scalar-typed parameters of the number equals to the length of the array-typed member variable. For example: + +``` +struct Foo { + int table[3]; + + // user-provided GPU deserializer + // table has 3 int elements, so deserializer must have 3 int parameters. +#ifdef __HCC__ + __attribute__((annotate(“user_deserialize”))) + Foo(int x0, int x1, int x2) [[cpu]][[hc]] { + table[0] = x0; + table[1] = x1; + table[2] = x2; + } +#endif + +#ifdef __HCC__ + __attribute__((annotate(“serialize”))) + void __cxxamp_serialize(Kalmar::Serialize &s) const { + s.Append(sizeof(int), &table[0]); + s.Append(sizeof(int), &table[1]); + s.Append(sizeof(int), &table[2]); + } +#endif +}; +``` + + +Rather than create serializer functions, another workaround is to pass the member fields from the structure as simple data types. + + +### HIP is more restrictive in enforcing restrictions +The language specification for HIP and CUDA forbid calling a +`__device__` function in a `__host__` context. In practice, you may observe +differences in the strictness of this restriction, with HIP exhibiting a tighter +adherence to the specification and thus less tolerant of infringing code. The +solution is to ensure that all functions which are called in a +`__device__` context are correctly annotated to reflect it. An interesting case +where these differences emerge is shown below. This relies on a the common +[C++ Member Detector idiom][1], as it would be implemented pre C++11): + +```c++ +#include +#include + +struct aye { bool a[1]; }; +struct nay { bool a[2]; }; + +// Dual restriction is necessary in HIP if the detector is to work for +// __device__ contexts as well as __host__ ones. NVCC is less strict. +template +__host__ __device__ +const T& cref_t(); + +template +struct Has_call_operator { + // Dual restriction is necessary in HIP if the detector is to work for + // __device__ contexts as well as __host__ ones. NVCC is less strict. + template + __host__ __device__ + static + aye test( + C const *, + typename std::enable_if< + (sizeof(cref_t().operator()()) > 0)>::type* = nullptr); + static + nay test(...); + + enum { value = sizeof(test(static_cast(0))) == sizeof(aye) }; +}; + +template::value> +struct Wrapper { + template + V f() const { return T{1}; } +}; + + +template +struct Wrapper { + template + V f() const { return T{10}; } +}; + +// This specialisation will yield a compile-time error, if selected. +template +struct Wrapper {}; + +template +struct Functor; + +template<> struct Functor { + __device__ + float operator()() const { return 42.0f; } +}; + +__device__ +void this_will_not_compile_if_detector_is_not_marked_device() +{ + float f = Wrapper>().f(); +} + +__host__ +void this_will_not_compile_if_detector_is_marked_device_only() +{ + float f = Wrapper>().f(); +} +``` +[1]: https://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Member_Detector diff --git a/projects/hip/docs/markdown/hip_faq.md b/projects/hip/docs/markdown/hip_faq.md index 8ccb458103..e316d449ef 100644 --- a/projects/hip/docs/markdown/hip_faq.md +++ b/projects/hip/docs/markdown/hip_faq.md @@ -4,7 +4,7 @@ - [What APIs and features does HIP support?](#what-apis-and-features-does-hip-support) - [What is not supported?](#what-is-not-supported) - * [Run-time features](#run-time-features) + * [Runtime/Driver API features](#runtimedriver-api-features) * [Kernel language features](#kernel-language-features) - [Is HIP a drop-in replacement for CUDA?](#is-hip-a-drop-in-replacement-for-cuda) - [What specific version of CUDA does HIP support?](#what-specific-version-of-cuda-does-hip-support) @@ -23,10 +23,11 @@ - [On HCC, can I link HIP code with host code compiled with another compiler such as gcc, icc, or clang ?](#on-hcc-can-i-link-hip-code-with-host-code-compiled-with-another-compiler-such-as-gcc-icc-or-clang-) - [HIP detected my platform (hcc vs nvcc) incorrectly - what should I do?](#hip-detected-my-platform-hcc-vs-nvcc-incorrectly---what-should-i-do) - [Can I install both CUDA SDK and HCC on same machine?](#can-i-install-both-cuda-sdk-and-hcc-on-same-machine) +- [On CUDA, can I mix CUDA code with HIP code?](#on-cuda-can-i-mix-cuda-code-with-hip-code) +- [On HCC, can I use HC functionality with HIP?](#on-hcc-can-i-use-hc-functionality-with-hip) - [How do I trace HIP application flow?](#how-do-i-trace-hip-application-flow) - * [Using CodeXL markers for HIP Functions](#using-codexl-markers-for-hip-functions) - * [Using HIP_TRACE_API](#using-hip_trace_api) -- [How do I enable HIP Generic Grid Launch option?](#how-do-i-enable-hip-generic-grid-launch-option) +- [What if HIP generates error of "symbol multiply defined!" only on AMD machine?](#what-if-hip-generates-error-of-symbol-multiply-defined-only-on-amd-machine) +- [How do I disable HIP Generic Grid Launch option?](#how-do-i-disable-hip-generic-grid-launch-option) diff --git a/projects/hip/docs/markdown/hip_kernel_language.md b/projects/hip/docs/markdown/hip_kernel_language.md index 0c7f3c8d25..3cb7b17a0c 100644 --- a/projects/hip/docs/markdown/hip_kernel_language.md +++ b/projects/hip/docs/markdown/hip_kernel_language.md @@ -44,6 +44,7 @@ - [Pragma Unroll](#pragma-unroll) - [In-Line Assembly](#in-line-assembly) - [C++ Support](#c-support) +- [Kernel Compilation](#kernel-compilation) diff --git a/projects/hip/docs/markdown/hip_porting_guide.md b/projects/hip/docs/markdown/hip_porting_guide.md index 9f20d12423..72f6384f6d 100644 --- a/projects/hip/docs/markdown/hip_porting_guide.md +++ b/projects/hip/docs/markdown/hip_porting_guide.md @@ -21,6 +21,7 @@ and provides practical suggestions on how to port CUDA code and work through com * [Device-Architecture Properties](#device-architecture-properties) * [Table of Architecture Properties](#table-of-architecture-properties) - [Finding HIP](#finding-hip) +- [hipLaunchKernel](#hiplaunchkernel) - [Compiler Options](#compiler-options) - [Linking Issues](#linking-issues) * [Linking With hipcc](#linking-with-hipcc) @@ -31,9 +32,11 @@ and provides practical suggestions on how to port CUDA code and work through com * [Using a Standard C++ Compiler](#using-a-standard-c-compiler) + [cuda.h](#cudah) * [Choosing HIP File Extensions](#choosing-hip-file-extensions) - * [Workarounds](#workarounds) - + [warpSize](#warpsize) - + [Textures and Cache Control](#textures-and-cache-control) +- [Workarounds](#workarounds) + * [warpSize](#warpsize) +- [memcpyToSymbol](#memcpytosymbol) +- [threadfence_system](#threadfence_system) + * [Textures and Cache Control](#textures-and-cache-control) - [More Tips](#more-tips) * [HIPTRACE Mode](#hiptrace-mode) * [Environment Variables](#environment-variables) diff --git a/projects/hip/docs/markdown/hip_profiling.md b/projects/hip/docs/markdown/hip_profiling.md index 463c9c13b3..6e5cde700d 100644 --- a/projects/hip/docs/markdown/hip_profiling.md +++ b/projects/hip/docs/markdown/hip_profiling.md @@ -4,26 +4,32 @@ This section describes the profiling and debugging capabilities that HIP provide Profiling information can viewed in the CodeXL visualization tool or printed directly to stderr as the application runs. This document starts with some of the general capabilities of CodeXL and then describes some of the additional HIP marker and debug features. - * [CodeXL Profiling](#codexl-profiling) - * [Collecting and Viewing Traces](#collecting-and-viewing-traces) - * [Using rocm-profiler timestamp profiling](#using-rocm-profiler-timestamp-profiling) - * [Using rocm-profiler performance counter collection:](#using-rocm-profiler-performance-counter-collection) - * [Using CodeXL to view profiling results:](#using-codexl-to-view-profiling-results) - * [More information on CodeXL](#more-information-on-codexl) - * [HIP Markers](#hip-markers) - * [Profiling HIP APIs](#profiling-hip-apis) - * [Adding markers to applications](#adding-markers-to-applications) - * [Additional HIP Profiling Features](#additional-hip-profiling-features) - * [Demangling C Kernel Names](#demangling-c-kernel-names) - * [Controlling when profiling starts and ends](#controlling-when-profiling-starts-and-ends) - * [Reducing timeline trace output file size](#reducing-timeline-trace-output-file-size) - * [How to enable profiling at HIP build time](#how-to-enable-profiling-at-hip-build-time) - * [Tracing and Debug](#tracing-and-debug) - * [Tracing HIP APIs](#tracing-hip-apis) - * [Color](#color) - * [Using HIP_DB](#using-hip_db) - * [Using ltrace](#using-ltrace) - * [Chicken bits](#chicken-bits) + + +- [CodeXL Profiling](#codexl-profiling) + * [Collecting and Viewing Traces](#collecting-and-viewing-traces) + + [Using rocm-profiler timestamp profiling](#using-rocm-profiler-timestamp-profiling) + + [Using rocm-profiler performance counter collection:](#using-rocm-profiler-performance-counter-collection) + + [Using CodeXL to view profiling results:](#using-codexl-to-view-profiling-results) + + [More information on CodeXL](#more-information-on-codexl) + * [HIP Markers](#hip-markers) + + [Profiling HIP APIs](#profiling-hip-apis) + + [Adding markers to applications](#adding-markers-to-applications) + * [Additional HIP Profiling Features](#additional-hip-profiling-features) + + [Demangling C++ Kernel Names](#demangling-c-kernel-names) + + [Controlling when profiling starts and ends](#controlling-when-profiling-starts-and-ends) + + [Reducing timeline trace output file size](#reducing-timeline-trace-output-file-size) + + [How to enable profiling at HIP build time](#how-to-enable-profiling-at-hip-build-time) +- [Tracing and Debug](#tracing-and-debug) + * [Tracing HIP APIs](#tracing-hip-apis) + + [Color](#color) + * [Using HIP_DB](#using-hip_db) + * [Using ltrace](#using-ltrace) + * [Chicken bits](#chicken-bits) + * [Debugging HIP Applications](#debugging-hip-applications) + * [General Debugging Tips](#general-debugging-tips) + + ## CodeXL Profiling diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index 6c24fbf288..383af0440c 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -2343,9 +2343,6 @@ private: LangOptions DefaultLangOptions; SmallString<40> XStr; raw_svector_ostream OS(XStr); - StringRef initialParamList; - OS << "hipLaunchParm lp"; - size_t repLength = OS.str().size(); SourceLocation sl = kernelDecl->getNameInfo().getEndLoc(); SourceLocation kernelArgListStart = Lexer::findLocationAfterToken(sl, tok::l_paren, *SM, DefaultLangOptions, true); DEBUG(dbgs() << kernelArgListStart.printToString(*SM)); @@ -2355,14 +2352,12 @@ private: SourceLocation kernelArgListStart(pvdFirst->getLocStart()); SourceLocation kernelArgListEnd(pvdLast->getLocEnd()); SourceLocation stop = Lexer::getLocForEndOfToken(kernelArgListEnd, 0, *SM, DefaultLangOptions); - repLength += SM->getCharacterData(stop) - SM->getCharacterData(kernelArgListStart); - initialParamList = StringRef(SM->getCharacterData(kernelArgListStart), repLength); - OS << ", " << initialParamList; + size_t repLength = SM->getCharacterData(stop) - SM->getCharacterData(kernelArgListStart); + OS << StringRef(SM->getCharacterData(kernelArgListStart), repLength); + Replacement Rep0(*(Result.SourceManager), kernelArgListStart, repLength, OS.str()); + FullSourceLoc fullSL(sl, *(Result.SourceManager)); + insertReplacement(Rep0, fullSL); } - DEBUG(dbgs() << "initial paramlist: " << initialParamList << "\n" << "new paramlist: " << OS.str() << "\n"); - Replacement Rep0(*(Result.SourceManager), kernelArgListStart, repLength, OS.str()); - FullSourceLoc fullSL(sl, *(Result.SourceManager)); - insertReplacement(Rep0, fullSL); } bool cudaCall(const MatchFinder::MatchResult &Result) { @@ -2431,9 +2426,9 @@ private: XStr.clear(); if (calleeName.find(',') != StringRef::npos) { SmallString<128> tmpData; - calleeName = Twine("HIP_KERNEL_NAME(" + calleeName + ")").toStringRef(tmpData); + calleeName = Twine("(" + calleeName + ")").toStringRef(tmpData); } - OS << "hipLaunchKernel(" << calleeName << ","; + OS << "hipLaunchKernelGGL(" << calleeName << ","; const CallExpr *config = launchKernel->getConfig(); DEBUG(dbgs() << "Kernel config arguments:" << "\n"); SourceManager *SM = Result.SourceManager; @@ -2473,7 +2468,7 @@ private: Replacement Rep(*SM, launchKernel->getLocStart(), length, OS.str()); FullSourceLoc fullSL(launchKernel->getLocStart(), *SM); insertReplacement(Rep, fullSL); - hipCounter counter = {"hipLaunchKernel", CONV_KERN, API_RUNTIME}; + hipCounter counter = {"hipLaunchKernelGGL", CONV_KERN, API_RUNTIME}; updateCounters(counter, refName.str()); return true; } diff --git a/projects/hip/include/hip/hcc_detail/grid_launch_GGL.hpp b/projects/hip/include/hip/hcc_detail/grid_launch_GGL.hpp index 4fd7c3ff3a..8f1abbb70b 100644 --- a/projects/hip/include/hip/hcc_detail/grid_launch_GGL.hpp +++ b/projects/hip/include/hip/hcc_detail/grid_launch_GGL.hpp @@ -21,6 +21,7 @@ THE SOFTWARE. */ #pragma once +#if GENERIC_GRID_LAUNCH == 1 #include "concepts.hpp" #include "helpers.hpp" @@ -840,14 +841,16 @@ namespace hip_impl group_mem_bytes,\ stream,\ ...)\ - {\ - hipLaunchKernelGGL(\ - kernel_name,\ - num_blocks,\ - dim_blocks,\ - group_mem_bytes,\ - stream,\ - hipLaunchParm{},\ - ##__VA_ARGS__);\ - } + do {\ + hipLaunchKernelGGL(\ + kernel_name,\ + num_blocks,\ + dim_blocks,\ + group_mem_bytes,\ + stream,\ + hipLaunchParm{},\ + ##__VA_ARGS__);\ + } while(0) + } +#endif //GENERIC_GRID_LAUNCH diff --git a/projects/hip/include/hip/hcc_detail/hip_complex.h b/projects/hip/include/hip/hcc_detail/hip_complex.h index 9ff75d381a..26d73a21a8 100644 --- a/projects/hip/include/hip/hcc_detail/hip_complex.h +++ b/projects/hip/include/hip/hcc_detail/hip_complex.h @@ -23,8 +23,7 @@ THE SOFTWARE. #ifndef HIP_INCLUDE_HIP_HCC_DETAIL_HIP_COMPLEX_H #define HIP_INCLUDE_HIP_HCC_DETAIL_HIP_COMPLEX_H -#include "./hip_fp16.h" -#include "./hip_vector_types.h" +#include "hip/hcc_detail/hip_vector_types.h" #if __cplusplus #define COMPLEX_ADD_OP_OVERLOAD(type) \ @@ -177,45 +176,45 @@ COMPLEX_SCALAR_PRODUCT(hipDoubleComplex, unsigned long long) #endif -__device__ static inline float hipCrealf(hipFloatComplex z){ +__device__ __host__ static inline float hipCrealf(hipFloatComplex z){ return z.x; } -__device__ static inline float hipCimagf(hipFloatComplex z){ +__device__ __host__ static inline float hipCimagf(hipFloatComplex z){ return z.y; } -__device__ static inline hipFloatComplex make_hipFloatComplex(float a, float b){ +__device__ __host__ static inline hipFloatComplex make_hipFloatComplex(float a, float b){ hipFloatComplex z; z.x = a; z.y = b; return z; } -__device__ static inline hipFloatComplex hipConjf(hipFloatComplex z){ +__device__ __host__ static inline hipFloatComplex hipConjf(hipFloatComplex z){ hipFloatComplex ret; ret.x = z.x; ret.y = -z.y; return ret; } -__device__ static inline float hipCsqabsf(hipFloatComplex z){ +__device__ __host__ static inline float hipCsqabsf(hipFloatComplex z){ return z.x * z.x + z.y * z.y; } -__device__ static inline hipFloatComplex hipCaddf(hipFloatComplex p, hipFloatComplex q){ +__device__ __host__ static inline hipFloatComplex hipCaddf(hipFloatComplex p, hipFloatComplex q){ return make_hipFloatComplex(p.x + q.x, p.y + q.y); } -__device__ static inline hipFloatComplex hipCsubf(hipFloatComplex p, hipFloatComplex q){ +__device__ __host__ static inline hipFloatComplex hipCsubf(hipFloatComplex p, hipFloatComplex q){ return make_hipFloatComplex(p.x - q.x, p.y - q.y); } -__device__ static inline hipFloatComplex hipCmulf(hipFloatComplex p, hipFloatComplex q){ +__device__ __host__ static inline hipFloatComplex hipCmulf(hipFloatComplex p, hipFloatComplex q){ return make_hipFloatComplex(p.x * q.x - p.y * q.y, p.y * q.x + p.x * q.y); } -__device__ static inline hipFloatComplex hipCdivf(hipFloatComplex p, hipFloatComplex q){ +__device__ __host__ static inline hipFloatComplex hipCdivf(hipFloatComplex p, hipFloatComplex q){ float sqabs = hipCsqabsf(q); hipFloatComplex ret; ret.x = (p.x * q.x + p.y * q.y)/sqabs; @@ -223,51 +222,51 @@ __device__ static inline hipFloatComplex hipCdivf(hipFloatComplex p, hipFloatCom return ret; } -__device__ static inline float hipCabsf(hipFloatComplex z){ +__device__ __host__ static inline float hipCabsf(hipFloatComplex z){ return sqrtf(hipCsqabsf(z)); } -__device__ static inline double hipCreal(hipDoubleComplex z){ +__device__ __host__ static inline double hipCreal(hipDoubleComplex z){ return z.x; } -__device__ static inline double hipCimag(hipDoubleComplex z){ +__device__ __host__ static inline double hipCimag(hipDoubleComplex z){ return z.y; } -__device__ static inline hipDoubleComplex make_hipDoubleComplex(double a, double b){ +__device__ __host__ static inline hipDoubleComplex make_hipDoubleComplex(double a, double b){ hipDoubleComplex z; z.x = a; z.y = b; return z; } -__device__ static inline hipDoubleComplex hipConj(hipDoubleComplex z){ +__device__ __host__ static inline hipDoubleComplex hipConj(hipDoubleComplex z){ hipDoubleComplex ret; ret.x = z.x; ret.y = z.y; return ret; } -__device__ static inline double hipCsqabs(hipDoubleComplex z){ +__device__ __host__ static inline double hipCsqabs(hipDoubleComplex z){ return z.x * z.x + z.y * z.y; } -__device__ static inline hipDoubleComplex hipCadd(hipDoubleComplex p, hipDoubleComplex q){ +__device__ __host__ static inline hipDoubleComplex hipCadd(hipDoubleComplex p, hipDoubleComplex q){ return make_hipDoubleComplex(p.x + q.x, p.y + q.y); } -__device__ static inline hipDoubleComplex hipCsub(hipDoubleComplex p, hipDoubleComplex q){ +__device__ __host__ static inline hipDoubleComplex hipCsub(hipDoubleComplex p, hipDoubleComplex q){ return make_hipDoubleComplex(p.x - q.x, p.y - q.y); } -__device__ static inline hipDoubleComplex hipCmul(hipDoubleComplex p, hipDoubleComplex q){ +__device__ __host__ static inline hipDoubleComplex hipCmul(hipDoubleComplex p, hipDoubleComplex q){ return make_hipDoubleComplex(p.x * q.x - p.y * q.y, p.y * q.x + p.x * q.y); } -__device__ static inline hipDoubleComplex hipCdiv(hipDoubleComplex p, hipDoubleComplex q){ +__device__ __host__ static inline hipDoubleComplex hipCdiv(hipDoubleComplex p, hipDoubleComplex q){ double sqabs = hipCsqabs(q); hipDoubleComplex ret; ret.x = (p.x * q.x + p.y * q.y)/sqabs; @@ -275,28 +274,28 @@ __device__ static inline hipDoubleComplex hipCdiv(hipDoubleComplex p, hipDoubleC return ret; } -__device__ static inline double hipCabs(hipDoubleComplex z){ +__device__ __host__ static inline double hipCabs(hipDoubleComplex z){ return sqrtf(hipCsqabs(z)); } typedef hipFloatComplex hipComplex; -__device__ static inline hipComplex make_hipComplex(float x, +__device__ __host__ static inline hipComplex make_hipComplex(float x, float y){ return make_hipFloatComplex(x, y); } -__device__ static inline hipFloatComplex hipComplexDoubleToFloat +__device__ __host__ static inline hipFloatComplex hipComplexDoubleToFloat (hipDoubleComplex z){ return make_hipFloatComplex((float)z.x, (float)z.y); } -__device__ static inline hipDoubleComplex hipComplexFloatToDouble +__device__ __host__ static inline hipDoubleComplex hipComplexFloatToDouble (hipFloatComplex z){ return make_hipDoubleComplex((double)z.x, (double)z.y); } -__device__ static inline hipComplex hipCfmaf(hipComplex p, hipComplex q, hipComplex r){ +__device__ __host__ static inline hipComplex hipCfmaf(hipComplex p, hipComplex q, hipComplex r){ float real = (p.x * q.x) + r.x; float imag = (q.x * p.y) + r.y; @@ -306,7 +305,7 @@ __device__ static inline hipComplex hipCfmaf(hipComplex p, hipComplex q, hipComp return make_hipComplex(real, imag); } -__device__ static inline hipDoubleComplex hipCfma(hipDoubleComplex p, hipDoubleComplex q, hipDoubleComplex r){ +__device__ __host__ static inline hipDoubleComplex hipCfma(hipDoubleComplex p, hipDoubleComplex q, hipDoubleComplex r){ float real = (p.x * q.x) + r.x; float imag = (q.x * p.y) + r.y; diff --git a/projects/hip/include/hip/hcc_detail/hip_fp16.h b/projects/hip/include/hip/hcc_detail/hip_fp16.h index febc1b4fce..0a861b64af 100644 --- a/projects/hip/include/hip/hcc_detail/hip_fp16.h +++ b/projects/hip/include/hip/hcc_detail/hip_fp16.h @@ -23,7 +23,7 @@ THE SOFTWARE. #ifndef HIP_INCLUDE_HIP_HCC_DETAIL_HIP_FP16_H #define HIP_INCLUDE_HIP_HCC_DETAIL_HIP_FP16_H -#include "hip/hip_runtime.h" +#include "hip/hcc_detail/hip_vector_types.h" #if __clang_major__ > 3 diff --git a/projects/hip/include/hip/hcc_detail/hip_hcc.h b/projects/hip/include/hip/hcc_detail/hip_hcc.h index 645e980376..fc04917931 100644 --- a/projects/hip/include/hip/hcc_detail/hip_hcc.h +++ b/projects/hip/include/hip/hcc_detail/hip_hcc.h @@ -28,6 +28,17 @@ THE SOFTWARE. #if __cplusplus #ifdef __HCC__ #include + + +/** + *------------------------------------------------------------------------------------------------- + *------------------------------------------------------------------------------------------------- + * @defgroup HCC-specific features + * @warning These APIs provide access to special features of HCC compiler and are not available through the CUDA path. + * @{ + */ + + /** * @brief Return hc::accelerator associated with the specified deviceId * @return #hipSuccess, #hipErrorInvalidDevice @@ -45,6 +56,29 @@ hipError_t hipHccGetAcceleratorView(hipStream_t stream, hc::accelerator_view **a #endif // #ifdef __HCC__ +/** + * @brief launches kernel f with launch parameters and shared memory on stream with arguments passed to kernelparams or extra + * + * @param [in[ f Kernel to launch. + * @param [in] gridDimX X grid dimension specified in work-items + * @param [in] gridDimY Y grid dimension specified in work-items + * @param [in] gridDimZ Z grid dimension specified in work-items + * @param [in] blockDimX X block dimensions specified in work-items + * @param [in] blockDimY Y grid dimension specified in work-items + * @param [in] blockDimZ Z grid dimension specified in work-items + * @param [in] sharedMemBytes Amount of dynamic shared memory to allocate for this kernel. The kernel can access this with HIP_DYNAMIC_SHARED. + * @param [in] stream Stream where the kernel should be dispatched. May be 0, in which case th default stream is used with associated synchronization rules. + * @param [in] kernelParams + * @param [in] extra Pointer to kernel arguments. These are passed directly to the kernel and must be in the memory layout and alignment expected by the kernel. + * @param [in] startEvent If non-null, specified event will be updated to track the start time of the kernel launch. The event must be created before calling this API. + * @param [in] stopEvent If non-null, specified event will be updated to track the stop time of the kernel launch. The event must be created before calling this API. + * + * @returns hipSuccess, hipInvalidDevice, hipErrorNotInitialized, hipErrorInvalidValue + * + * @warning kernellParams argument is not yet implemented in HIP. Please use extra instead. Please refer to hip_porting_driver_api.md for sample usage. + + * HIP/ROCm actually updates the start event when the associated kernel completes. + */ hipError_t hipHccModuleLaunchKernel(hipFunction_t f, uint32_t globalWorkSizeX, uint32_t globalWorkSizeY, @@ -55,8 +89,15 @@ hipError_t hipHccModuleLaunchKernel(hipFunction_t f, size_t sharedMemBytes, hipStream_t hStream, void **kernelParams, - void **extra); + void **extra, + hipEvent_t startEvent=nullptr, + hipEvent_t stopEvent=nullptr + ); +// doxygen end HCC-specific features +/** + * @} + */ #endif // #if __cplusplus #endif // diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h index 0daca7a53b..f9bfb5a310 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h @@ -1913,19 +1913,18 @@ hipError_t hipModuleLoadData(hipModule_t *module, const void *image); /** * @brief launches kernel f with launch parameters and shared memory on stream with arguments passed to kernelparams or extra * - * @param [in[ f - * @param [in] gridDimX - * @param [in] gridDimY - * @param [in] gridDimZ - * @param [in] blockDimX - * @param [in] blockDimY - * @param [in] blockDimZ - * @param [in] sharedMemBytes - * @param [in] stream - * @param [in] kernelParams - * @param [in] extraa + * @param [in[ f Kernel to launch. + * @param [in] gridDimX X grid dimension specified as multiple of blockDimX. + * @param [in] gridDimY Y grid dimension specified as multiple of blockDimY. + * @param [in] gridDimZ Z grid dimension specified as multiple of blockDimZ. + * @param [in] blockDimX X block dimensions specified in work-items + * @param [in] blockDimY Y grid dimension specified in work-items + * @param [in] blockDimZ Z grid dimension specified in work-items + * @param [in] sharedMemBytes Amount of dynamic shared memory to allocate for this kernel. The kernel can access this with HIP_DYNAMIC_SHARED. + * @param [in] stream Stream where the kernel should be dispatched. May be 0, in which case th default stream is used with associated synchronization rules. + * @param [in] kernelParams + * @param [in] extra Pointer to kernel arguments. These are passed directly to the kernel and must be in the memory layout and alignment expected by the kernel. * - * The function takes the above arguments and run the kernel in hipFunction_t f. with launch parameters specified in gridDimX, gridDimY, gridDimZ, blockDimX, blockDimY and blockDimmZ. The amount of shared memory is specificed and can be used with HIP_DYNAMIC_SHARED. The arguemt extra is used to pass in the arguments for the kernel. * @returns hipSuccess, hipInvalidDevice, hipErrorNotInitialized, hipErrorInvalidValue * * @warning kernellParams argument is not yet implemented in HIP. Please use extra instead. Please refer to hip_porting_driver_api.md for sample usage. diff --git a/projects/hip/include/hip/hcc_detail/hip_vector_types.h b/projects/hip/include/hip/hcc_detail/hip_vector_types.h index 42e1d6663c..82bd3b2d6f 100644 --- a/projects/hip/include/hip/hcc_detail/hip_vector_types.h +++ b/projects/hip/include/hip/hcc_detail/hip_vector_types.h @@ -32,7 +32,7 @@ THE SOFTWARE. #error("This version of HIP requires a newer version of HCC."); #endif -#include "host_defines.h" +#include "hip/hcc_detail/host_defines.h" #define MAKE_DEFAULT_CONSTRUCTOR_ONE_COMPONENT(type) \ __device__ __host__ type() {} \ diff --git a/projects/hip/packaging/create_hip_samples_installer.sh b/projects/hip/packaging/create_hip_samples_installer.sh deleted file mode 100755 index 91789d2524..0000000000 --- a/projects/hip/packaging/create_hip_samples_installer.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -function die { - echo "${1-Died}." >&2 - exit 1 -} - -payload=$1 -script=$2 -[ "$payload" != "" ] || [ "$script" != "" ] || die "Invalid arguments!" -tmp=__extract__$RANDOM - -printf "#!/bin/bash -samples_dir=\$1 -[ \"\$samples_dir\" != \"\" ] || read -e -p \"Enter the path to extract the HIP samples: \" samples_dir -mkdir -p \$samples_dir -PAYLOAD=\`awk '/^__PAYLOAD_BELOW__/ {print NR + 1; exit 0; }' \$0\` -tail -n+\$PAYLOAD \$0 | tar -xz -C \$samples_dir -echo \"HIP samples installed in \$samples_dir\" -exit 0 -__PAYLOAD_BELOW__\n" > "$tmp" - -cat "$tmp" "$payload" > "$script" && rm "$tmp" -chmod +x "$script" diff --git a/projects/hip/packaging/hip_doc.txt b/projects/hip/packaging/hip_doc.txt index bbcaf54ec8..d5a0c471b1 100644 --- a/projects/hip/packaging/hip_doc.txt +++ b/projects/hip/packaging/hip_doc.txt @@ -1,12 +1,19 @@ cmake_minimum_required(VERSION 2.8.3) project(hip_doc) -add_custom_target(build_doxygen ALL +find_program(DOXYGEN_EXE doxygen) +if(DOXYGEN_EXE) + add_custom_target(build_doxygen ALL COMMAND HIP_PATH=@hip_SOURCE_DIR@ doxygen @hip_SOURCE_DIR@/docs/doxygen-input/doxy.cfg) -add_custom_target(convert_md_to_html ALL + install(DIRECTORY RuntimeAPI/html DESTINATION docs/docs/RuntimeAPI) +endif() + +find_program(GRIP_EXE grip) +if(GRIP_EXE) + add_custom_target(convert_md_to_html ALL COMMAND @hip_SOURCE_DIR@/packaging/convert_md_to_html.sh @hip_SOURCE_DIR@ ${PROJECT_BINARY_DIR}/md2html) -install(DIRECTORY RuntimeAPI/html DESTINATION docs/docs/RuntimeAPI) -install(DIRECTORY md2html/ DESTINATION docs) + install(DIRECTORY md2html/ DESTINATION docs) +endif() ############################# # Packaging steps diff --git a/projects/hip/samples/0_Intro/bit_extract/Makefile b/projects/hip/samples/0_Intro/bit_extract/Makefile index 78f6a2faa8..08bca6e642 100644 --- a/projects/hip/samples/0_Intro/bit_extract/Makefile +++ b/projects/hip/samples/0_Intro/bit_extract/Makefile @@ -11,10 +11,6 @@ HIPCC=$(HIP_PATH)/bin/hipcc ifeq (${HIP_PLATFORM}, nvcc) HIPCC_FLAGS = -gencode=arch=compute_20,code=sm_20 endif -ifeq (${HIP_PLATFORM}, hcc) - HIPCC_FLAGS = -stdlib=libc++ -endif - EXE=bit_extract diff --git a/projects/hip/samples/1_Utils/hipCommander/Makefile b/projects/hip/samples/1_Utils/hipCommander/Makefile index e770c636a4..a411763b7f 100644 --- a/projects/hip/samples/1_Utils/hipCommander/Makefile +++ b/projects/hip/samples/1_Utils/hipCommander/Makefile @@ -10,9 +10,6 @@ OPT=-O3 CXXFLAGS = $(OPT) --std=c++11 HIP_PLATFORM=$(shell $(HIP_PATH)/bin/hipconfig --platform) -ifeq (${HIP_PLATFORM}, hcc) - CXXFLAGS += " -stdlib=libc++" -endif CODE_OBJECTS=nullkernel.hsaco diff --git a/projects/hip/samples/1_Utils/hipCommander/hipCommander.cpp b/projects/hip/samples/1_Utils/hipCommander/hipCommander.cpp index 0add1ce3e3..4b93180b18 100644 --- a/projects/hip/samples/1_Utils/hipCommander/hipCommander.cpp +++ b/projects/hip/samples/1_Utils/hipCommander/hipCommander.cpp @@ -11,7 +11,6 @@ #include #include #include -#include #endif #include diff --git a/projects/hip/src/hip_event.cpp b/projects/hip/src/hip_event.cpp index d44f201db5..61ac5cd3ab 100644 --- a/projects/hip/src/hip_event.cpp +++ b/projects/hip/src/hip_event.cpp @@ -30,6 +30,54 @@ THE SOFTWARE. //--- +ihipEvent_t::ihipEvent_t(unsigned flags) +{ + _state = hipEventStatusCreated; + _stream = NULL; + _flags = flags; + _timestamp = 0; + _type = hipEventTypeIndependent; +}; + + + +// Attach to an existing completion future: +void ihipEvent_t::attachToCompletionFuture(const hc::completion_future *cf, ihipEventType_t eventType) +{ + _state = hipEventStatusRecording; + _marker = *cf; + _type = eventType; +} + + + +void ihipEvent_t::setTimestamp() +{ + if (_state == hipEventStatusRecorded) { + // already recorded, done: + return; + } else { + // TODO - use completion-future functions to obtain ticks and timestamps: + hsa_signal_t *sig = static_cast (_marker.get_native_handle()); + if (sig) { + if (hsa_signal_load_acquire(*sig) == 0) { + + if ((_type == hipEventTypeIndependent) || (_type == hipEventTypeStopCommand)) { + _timestamp = _marker.get_end_tick(); + } else if (_type == hipEventTypeStartCommand) { + _timestamp = _marker.get_begin_tick(); + } else { + assert(0); // TODO - move to debug assert + _timestamp = 0; + } + + _state = hipEventStatusRecorded; + } + } + } +} + + hipError_t ihipEventCreate(hipEvent_t* event, unsigned flags) { hipError_t e = hipSuccess; @@ -37,12 +85,8 @@ hipError_t ihipEventCreate(hipEvent_t* event, unsigned flags) // TODO-IPC - support hipEventInterprocess. unsigned supportedFlags = hipEventDefault | hipEventBlockingSync | hipEventDisableTiming; if ((flags & ~supportedFlags) == 0) { - ihipEvent_t *eh = new ihipEvent_t(); + ihipEvent_t *eh = new ihipEvent_t(flags); - eh->_state = hipEventStatusCreated; - eh->_stream = NULL; - eh->_flags = flags; - eh->_timestamp = 0; *event = eh; } else { e = hipErrorInvalidValue; @@ -141,8 +185,8 @@ hipError_t hipEventElapsedTime(float *ms, hipEvent_t start, hipEvent_t stop) ihipEvent_t *start_eh = start; ihipEvent_t *stop_eh = stop; - ihipSetTs(start); - ihipSetTs(stop); + start->setTimestamp(); + stop->setTimestamp(); hipError_t status = hipSuccess; *ms = 0.0f; @@ -151,7 +195,7 @@ hipError_t hipEventElapsedTime(float *ms, hipEvent_t start, hipEvent_t stop) if ((start_eh->_state == hipEventStatusRecorded) && (stop_eh->_state == hipEventStatusRecorded)) { // Common case, we have good information for both events. - int64_t tickDiff = (stop_eh->_timestamp - start_eh->_timestamp); + int64_t tickDiff = (stop_eh->timestamp() - start_eh->timestamp()); uint64_t freqHz; hsa_system_get_info(HSA_SYSTEM_INFO_TIMESTAMP_FREQUENCY, &freqHz); diff --git a/projects/hip/src/hip_hcc.cpp b/projects/hip/src/hip_hcc.cpp index 374840f91f..35a3e11e71 100644 --- a/projects/hip/src/hip_hcc.cpp +++ b/projects/hip/src/hip_hcc.cpp @@ -1641,23 +1641,6 @@ const char *ihipErrorString(hipError_t hip_error) }; -void ihipSetTs(hipEvent_t e) -{ - ihipEvent_t *eh = e; - if (eh->_state == hipEventStatusRecorded) { - // already recorded, done: - return; - } else { - // TODO - use completion-future functions to obtain ticks and timestamps: - hsa_signal_t *sig = static_cast (eh->_marker.get_native_handle()); - if (sig) { - if (hsa_signal_load_acquire(*sig) == 0) { - eh->_timestamp = eh->_marker.get_end_tick(); - eh->_state = hipEventStatusRecorded; - } - } - } -} // Returns true if copyEngineCtx can see the memory allocated on dstCtx and srcCtx. diff --git a/projects/hip/src/hip_hcc_internal.h b/projects/hip/src/hip_hcc_internal.h index 4b960e2820..9c17c6e98c 100644 --- a/projects/hip/src/hip_hcc_internal.h +++ b/projects/hip/src/hip_hcc_internal.h @@ -584,22 +584,40 @@ private: // Data //---- // Internal event structure: enum hipEventStatus_t { - hipEventStatusUnitialized = 0, // event is unutilized, must be "Created" before use. - hipEventStatusCreated = 1, - hipEventStatusRecording = 2, // event has been enqueued to record something. - hipEventStatusRecorded = 3, // event has been recorded - timestamps are valid. + hipEventStatusUnitialized = 0, // event is unutilized, must be "Created" before use. + hipEventStatusCreated = 1, + hipEventStatusRecording = 2, // event has been enqueued to record something. + hipEventStatusRecorded = 3, // event has been recorded - timestamps are valid. } ; +// TODO - rename to ihip type of some kind +enum ihipEventType_t { + hipEventTypeIndependent, + hipEventTypeStartCommand, + hipEventTypeStopCommand, +}; // internal hip event structure. -struct ihipEvent_t { - hipEventStatus_t _state; +class ihipEvent_t { +public: + ihipEvent_t(unsigned flags); + void attachToCompletionFuture(const hc::completion_future *cf, ihipEventType_t eventType); + void setTimestamp(); + uint64_t timestamp() const { return _timestamp; } ; + ihipEventType_t type() const { return _type; }; + +public: + hipEventStatus_t _state; hipStream_t _stream; // Stream where the event is recorded, or NULL if all streams. unsigned _flags; hc::completion_future _marker; + +private: + ihipEventType_t _type; uint64_t _timestamp; // store timestamp, may be set on host or by marker. +friend hipError_t hipEventRecord(hipEvent_t event, hipStream_t stream); } ; @@ -822,8 +840,6 @@ extern hipError_t ihipDeviceSetState(); extern ihipDevice_t *ihipGetDevice(int); ihipCtx_t * ihipGetPrimaryCtx(unsigned deviceIndex); -extern void ihipSetTs(hipEvent_t e); - hipStream_t ihipSyncAndResolveStream(hipStream_t); diff --git a/projects/hip/src/hip_memory.cpp b/projects/hip/src/hip_memory.cpp index 805fc9efc0..da5530349f 100644 --- a/projects/hip/src/hip_memory.cpp +++ b/projects/hip/src/hip_memory.cpp @@ -1260,10 +1260,15 @@ hipError_t hipIpcOpenMemHandle(void** devPtr, hipIpcMemHandle_t handle, unsigned ihipIpcMemHandle_t* iHandle = (ihipIpcMemHandle_t*) &handle; //Attach ipc memory - hsa_status_t hsa_status = - hsa_amd_ipc_memory_attach((hsa_amd_ipc_memory_t*)&(iHandle->ipc_handle), iHandle->psize, 1, agent, devPtr); - if(hsa_status != HSA_STATUS_SUCCESS) - hipStatus = hipErrorMapBufferObjectFailed; + auto ctx= ihipGetTlsDefaultCtx(); + { + LockedAccessor_CtxCrit_t crit(ctx->criticalData()); + // the peerCnt always stores self so make sure the trace actually + hsa_status_t hsa_status = + hsa_amd_ipc_memory_attach((hsa_amd_ipc_memory_t*)&(iHandle->ipc_handle), iHandle->psize, crit->peerCnt(), crit->peerAgents(), devPtr); + if(hsa_status != HSA_STATUS_SUCCESS) + hipStatus = hipErrorMapBufferObjectFailed; + } #else hipStatus = hipErrorRuntimeOther; #endif diff --git a/projects/hip/src/hip_module.cpp b/projects/hip/src/hip_module.cpp index 67bba5f935..b359e7a63c 100644 --- a/projects/hip/src/hip_module.cpp +++ b/projects/hip/src/hip_module.cpp @@ -364,10 +364,11 @@ hipError_t hipModuleGetFunction(hipFunction_t *hfunc, hipModule_t hmod, hipError_t ihipModuleLaunchKernel(hipFunction_t f, - uint32_t globalWorkSizeX, uint32_t globalWorkSizeY, uint32_t globalWorkSizeZ, - uint32_t localWorkSizeX, uint32_t localWorkSizeY, uint32_t localWorkSizeZ, - size_t sharedMemBytes, hipStream_t hStream, - void **kernelParams, void **extra) + uint32_t globalWorkSizeX, uint32_t globalWorkSizeY, uint32_t globalWorkSizeZ, + uint32_t localWorkSizeX, uint32_t localWorkSizeY, uint32_t localWorkSizeZ, + size_t sharedMemBytes, hipStream_t hStream, + void **kernelParams, void **extra, + hipEvent_t startEvent, hipEvent_t stopEvent) { auto ctx = ihipGetTlsDefaultCtx(); @@ -446,7 +447,20 @@ hipError_t ihipModuleLaunchKernel(hipFunction_t f, (HSA_FENCE_SCOPE_SYSTEM << HSA_PACKET_HEADER_RELEASE_FENCE_SCOPE); }; - lp.av->dispatch_hsa_kernel(&aql, config[1] /* kernarg*/, kernArgSize, nullptr/*completion_future*/); + + hc::completion_future cf; + + lp.av->dispatch_hsa_kernel(&aql, config[1] /* kernarg*/, kernArgSize, + (startEvent || stopEvent) ? &cf : nullptr); + + + if (startEvent) { + startEvent->attachToCompletionFuture(&cf, hipEventTypeStartCommand); + } + if (stopEvent) { + stopEvent->attachToCompletionFuture (&cf, hipEventTypeStopCommand); + } + if(kernelParams != NULL){ free(config[1]); @@ -470,7 +484,8 @@ hipError_t hipModuleLaunchKernel(hipFunction_t f, return ihipLogStatus(ihipModuleLaunchKernel(f, blockDimX * gridDimX, blockDimY * gridDimY, gridDimZ * blockDimZ, blockDimX, blockDimY, blockDimZ, - sharedMemBytes, hStream, kernelParams, extra)); + sharedMemBytes, hStream, kernelParams, extra, + nullptr, nullptr)); } @@ -478,7 +493,8 @@ hipError_t hipHccModuleLaunchKernel(hipFunction_t f, uint32_t globalWorkSizeX, uint32_t globalWorkSizeY, uint32_t globalWorkSizeZ, uint32_t localWorkSizeX, uint32_t localWorkSizeY, uint32_t localWorkSizeZ, size_t sharedMemBytes, hipStream_t hStream, - void **kernelParams, void **extra) + void **kernelParams, void **extra, + hipEvent_t startEvent, hipEvent_t stopEvent) { HIP_INIT_API(f, globalWorkSizeX, globalWorkSizeY, globalWorkSizeZ, localWorkSizeX, localWorkSizeY, localWorkSizeZ, @@ -486,7 +502,7 @@ hipError_t hipHccModuleLaunchKernel(hipFunction_t f, kernelParams, extra); return ihipLogStatus(ihipModuleLaunchKernel(f, globalWorkSizeX, globalWorkSizeY, globalWorkSizeZ, localWorkSizeX, localWorkSizeY, localWorkSizeZ, - sharedMemBytes, hStream, kernelParams, extra)); + sharedMemBytes, hStream, kernelParams, extra, startEvent, stopEvent)); } hipError_t hipModuleGetGlobal(hipDeviceptr_t *dptr, size_t *bytes, diff --git a/projects/hip/tests/src/deviceLib/hipDeviceMemcpy.cpp b/projects/hip/tests/src/deviceLib/hipDeviceMemcpy.cpp index 54fd02c0c2..3843c07bb9 100644 --- a/projects/hip/tests/src/deviceLib/hipDeviceMemcpy.cpp +++ b/projects/hip/tests/src/deviceLib/hipDeviceMemcpy.cpp @@ -1,18 +1,29 @@ -#include +#include #include "hip/hip_runtime.h" #include "hip/hip_runtime_api.h" +#include "../test_common.h" + #define LEN 1030 #define SIZE LEN << 2 -__global__ void cpy(hipLaunchParm lp, uint32_t *Out, uint32_t *In, uint32_t *Vald) +/* HIT_START + * BUILD: %t %s ../test_common.cpp + * RUN: %t + * HIT_END + */ + + +__global__ void cpy(hipLaunchParm lp, uint32_t *Out, uint32_t *In) { - memcpy(Out, In, SIZE, Vald); + int tx = hipThreadIdx_x; + memcpy(Out + tx, In + tx, SIZE/LEN); } __global__ void set(hipLaunchParm lp, uint32_t *ptr, uint8_t val, size_t size) { - memset(ptr, val, size); + int tx = hipThreadIdx_x; + memset(ptr + tx, val, size); } int main() @@ -24,19 +35,29 @@ int main() Val = new uint32_t; *Val = 0; for(int i=0;i Date: Thu, 13 Apr 2017 12:39:28 +0530 Subject: [PATCH 276/281] Merge branch 'amd-develop' into amd-master Change-Id: I05572d2b32f1df70b54e2efeb32c8a4d8055912d (cherry picked from commit bb976eb6ad068b26de8d25a40edda8d6fa93104f) [ROCm/hip commit: f65574422f16577a86e09a14f138e4c51d98e1fc] --- projects/hip/CMakeLists.txt | 10 +- projects/hip/docs/markdown/hip_bugs.md | 81 ++++++---- .../hip/hcc_detail/grid_launch_GGL.hpp | 33 ++-- .../hip/include/hip/hcc_detail/helpers.hpp | 150 ++++++++---------- .../hip/include/hip/hcc_detail/hip_complex.h | 1 + .../include/hip/hcc_detail/hip_vector_types.h | 38 ++++- .../hip/include/hip/hcc_detail/host_defines.h | 2 +- .../include/hip/hcc_detail/math_functions.h | 1 + projects/hip/include/hip/hip_fp16.h | 2 +- .../hip/packaging/hip-targets-release.cmake | 41 +++++ projects/hip/packaging/hip-targets.cmake | 102 ++++++++++++ projects/hip/packaging/hip_hcc.txt | 2 + projects/hip/src/grid_launch.cpp | 36 +++++ projects/hip/src/math_functions.cpp | 4 + 14 files changed, 374 insertions(+), 129 deletions(-) create mode 100644 projects/hip/packaging/hip-targets-release.cmake create mode 100644 projects/hip/packaging/hip-targets.cmake diff --git a/projects/hip/CMakeLists.txt b/projects/hip/CMakeLists.txt index 94ed2a7562..eee1a14a8a 100644 --- a/projects/hip/CMakeLists.txt +++ b/projects/hip/CMakeLists.txt @@ -142,7 +142,7 @@ add_to_config(_buildInfo COMPILE_HIP_ATP_MARKER) # Build steps ############################# # Rebuild cmake cache updates .hipInfo and .hipVersion -add_custom_target(update_build_and_version_info ALL COMMAND make rebuild_cache) +add_custom_target(update_build_and_version_info COMMAND make rebuild_cache) # Build clang hipify if enabled add_subdirectory(hipify-clang) @@ -372,14 +372,14 @@ endif() # Testing steps ############################# # Target: test -set(HIP_PATH ${CMAKE_INSTALL_PREFIX}) +set(HIP_ROOT_DIR ${CMAKE_INSTALL_PREFIX}) set(HIP_SRC_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -execute_process(COMMAND "${CMAKE_COMMAND}" -E copy_directory "${HIP_SRC_PATH}/cmake" "${HIP_PATH}/cmake" RESULT_VARIABLE RUN_HIT ERROR_QUIET) +execute_process(COMMAND "${CMAKE_COMMAND}" -E copy_directory "${HIP_SRC_PATH}/cmake" "${HIP_ROOT_DIR}/cmake" RESULT_VARIABLE RUN_HIT ERROR_QUIET) if(${RUN_HIT} EQUAL 0) - execute_process(COMMAND "${CMAKE_COMMAND}" -E copy_directory "${HIP_SRC_PATH}/bin" "${HIP_PATH}/bin" RESULT_VARIABLE RUN_HIT ERROR_QUIET) + execute_process(COMMAND "${CMAKE_COMMAND}" -E copy_directory "${HIP_SRC_PATH}/bin" "${HIP_ROOT_DIR}/bin" RESULT_VARIABLE RUN_HIT ERROR_QUIET) endif() if(${RUN_HIT} EQUAL 0) - set(CMAKE_MODULE_PATH "${HIP_PATH}/cmake" ${CMAKE_MODULE_PATH}) + set(CMAKE_MODULE_PATH "${HIP_ROOT_DIR}/cmake" ${CMAKE_MODULE_PATH}) include(${HIP_SRC_PATH}/tests/hit/HIT.cmake) # Add tests diff --git a/projects/hip/docs/markdown/hip_bugs.md b/projects/hip/docs/markdown/hip_bugs.md index 73133843bc..9452fae2fd 100644 --- a/projects/hip/docs/markdown/hip_bugs.md +++ b/projects/hip/docs/markdown/hip_bugs.md @@ -1,5 +1,4 @@ -# HIP Bugs - +# HIP Bugs - [Errors related to undefined reference to `__hcLaunchKernel__***__grid_launch_parm**`](#errors-related-to-undefined-reference-to-__hclaunchkernel____grid_launch_parm) @@ -41,60 +40,86 @@ For example, `Foo` in the code snippets below contains an array-typed member var ``` struct Foo { + float _data; // table is an array, which makes foo int table[3]; }; ``` -An workaround is to provide a custom serializer on CPU side, and append the contents of the array as kernel arguments: +A workaround is to provide a custom serializer on host side which appends the contents of the array as kernel arguments, and a custome deserializaer on the device path to reconstruct the array inside the GPU kernels. +The deserializer can not be a function template, and should have scalar-typed parameters of the number equals to the length of the array-typed member variable. For example: ``` struct Foo { - int table[3]; + float _data; + int _table[3]; + - // user-provided CPU serializer - // must append the contents of the array member as kernel arguments #ifdef __HCC__ + // user-provided CPU serializer + // Append the contents of the array member as kernel arguments __attribute__((annotate(“serialize”))) void __cxxamp_serialize(Kalmar::Serialize &s) const { + s.Append(sizeof(float), &_data); for (int i = 0; i < 3; ++i) - s.Append(sizeof(int), &table[i]); + s.Append(sizeof(int), &_table[i]); } -#endif -}; -``` -Then, provide a custom deserializer on GPU side, to help reconstruct the array within GPU kernels. Notice that the deserializer can not be a function template, and should have scalar-typed parameters of the number equals to the length of the array-typed member variable. For example: - -``` -struct Foo { - int table[3]; // user-provided GPU deserializer // table has 3 int elements, so deserializer must have 3 int parameters. -#ifdef __HCC__ __attribute__((annotate(“user_deserialize”))) - Foo(int x0, int x1, int x2) [[cpu]][[hc]] { - table[0] = x0; - table[1] = x1; - table[2] = x2; + Foo(float d, int x0, int x1, int x2) [[cpu]][[hc]] { + _data = d; + _table[0] = x0; + _table[1] = x1; + _table[2] = x2; } -#endif -#ifdef __HCC__ - __attribute__((annotate(“serialize”))) - void __cxxamp_serialize(Kalmar::Serialize &s) const { - s.Append(sizeof(int), &table[0]); - s.Append(sizeof(int), &table[1]); - s.Append(sizeof(int), &table[2]); - } #endif }; ``` Rather than create serializer functions, another workaround is to pass the member fields from the structure as simple data types. +Note a class or struct can contain only one "user_deserialize" constructor. +For types which contain arrays which are based on template parameter, you can use partial template instantiation to implement one constructor per specialization. +However, an easier approach may be to create one user_deserializer which processes the maximum supported dimension. +This will take more memory in the structure and also require additional kernel arguments, but this may have little performance impact and the conversion is easier than partial template specialization. An example: + +``` +#define MAX_Dim 4 +template struct MyArray { + + T* dataPtr_; + //int size_[Dim]; // Original code with template-sized Dims + int size_[MAX_dim]; // Workaround code - allocate an array big enough for all dims so one serializer works. + + +... + +#ifdef __HCC__ + __attribute__((annotate("serialize"))) + void __cxxamp_serialize(Kalmar::Serialize &s) const { + s.Append(sizeof(float), &_dataPtr); + for (int i=0; i using is_new_grid_launch_t = typename std::conditional< - std::is_callable{}, + is_callable{}, New_grid_launch_tag, Old_grid_launch_tag>::type; } @@ -118,6 +119,7 @@ namespace hip_impl // TODO: these are workarounds, they should be removed. hc::accelerator_view lock_stream_hip_(hipStream_t&, void*&); + void print_prelaunch_trace_(const char*, dim3, dim3, int, hipStream_t); void unlock_stream_hip_( hipStream_t, void*, const char*, hc::accelerator_view*); @@ -137,7 +139,13 @@ namespace hip_impl void* lck_stream = nullptr; auto acc_v = lock_stream_hip_(stream, lck_stream); auto stream_guard = make_RAII_guard( - [](){ /* perhaps use a slimmed down ihipPrintKernelLaunch here */ }, + std::bind( + print_prelaunch_trace_, + kernel_name, + num_blocks, + dim_blocks, + group_mem_bytes, + stream), std::bind( unlock_stream_hip_, stream, lck_stream, kernel_name, &acc_v)); @@ -841,16 +849,15 @@ namespace hip_impl group_mem_bytes,\ stream,\ ...)\ - do {\ - hipLaunchKernelGGL(\ - kernel_name,\ - num_blocks,\ - dim_blocks,\ - group_mem_bytes,\ - stream,\ - hipLaunchParm{},\ - ##__VA_ARGS__);\ - } while(0) - + do {\ + hipLaunchKernelGGL(\ + kernel_name,\ + num_blocks,\ + dim_blocks,\ + group_mem_bytes,\ + stream,\ + hipLaunchParm{},\ + ##__VA_ARGS__);\ + } while(0) } #endif //GENERIC_GRID_LAUNCH diff --git a/projects/hip/include/hip/hcc_detail/helpers.hpp b/projects/hip/include/hip/hcc_detail/helpers.hpp index e5a84a4678..611929766b 100644 --- a/projects/hip/include/hip/hcc_detail/helpers.hpp +++ b/projects/hip/include/hip/hcc_detail/helpers.hpp @@ -21,6 +21,7 @@ THE SOFTWARE. */ #pragma once +#include "concepts.hpp" #include // For std::conditional, std::decay, std::enable_if, // std::false_type, std result_of and std::true_type. @@ -29,9 +30,6 @@ THE SOFTWARE. namespace std { // TODO: these should be removed as soon as possible. #if (__cplusplus < 201406L) - template - using void_t = void; - #if (__cplusplus < 201402L) template using enable_if_t = typename enable_if::type; @@ -43,88 +41,80 @@ namespace std using result_of_t = typename result_of::type; template using remove_reference_t = typename remove_reference::type; - template< - FunctionalProcedure F, - unsigned int n = 0u, - typename = void> - struct is_callable_impl : is_callable_impl {}; - - // Pointer to member function, call through non-pointer. - template - struct is_callable_impl< - F(C, Ts...), - 0u, - void_t().*declval())(declval()...))> - > : true_type { - }; - - // Pointer to member function, call through pointer. - template - struct is_callable_impl< - F(C, Ts...), - 1u, - void_t()).*declval())(declval()...))> - > : std::true_type { - }; - - // Pointer to member data, call through non-pointer, no args. - template - struct is_callable_impl< - F(C), - 2u, - void_t().*declval())> - > : true_type { - }; - - // Pointer to member data, call through pointer, no args. - template - struct is_callable_impl< - F(C), - 3u, - void_t().*declval())> - > : true_type { - }; - - // General call, n args. - template - struct is_callable_impl< - F(Ts...), - 4u, - void_t()(declval()...))> - > : true_type { - }; - - // Not callable. - template - struct is_callable_impl : false_type {}; - - template - struct is_callable : is_callable_impl {}; - #else - template - struct is_callable_impl : false_type {}; - - template - struct is_callable_impl< - F(Ts...), - void_t>> : true_type {}; - - template - struct is_callable : is_callable_impl {}; #endif - template - struct disjunction : false_type {}; - template - struct disjunction : B1 {}; - template - struct disjunction - : conditional_t> - {}; #endif } -namespace hip_impl // Only for documentation, macros ignore namespaces. +namespace hip_impl { + template + using void_t_ = void; + + #if (__cplusplus < 201402L) + template< + FunctionalProcedure F, + unsigned int n = 0u, + typename = void> + struct is_callable_impl : is_callable_impl {}; + + // Pointer to member function, call through non-pointer. + template + struct is_callable_impl< + F(C, Ts...), + 0u, + void_t_().*std::declval())( + std::declval()...))> + > : std::true_type {}; + + // Pointer to member function, call through pointer. + template + struct is_callable_impl< + F(C, Ts...), + 1u, + void_t_()).*std::declval())( + std::declval()...))> + > : std::true_type {}; + + // Pointer to member data, call through non-pointer, no args. + template + struct is_callable_impl< + F(C), + 2u, + void_t_().*std::declval())> + > : std::true_type {}; + + // Pointer to member data, call through pointer, no args. + template + struct is_callable_impl< + F(C), + 3u, + void_t_().*std::declval())> + > : std::true_type {}; + + // General call, n args. + template + struct is_callable_impl< + F(Ts...), + 4u, + void_t_()(std::declval()...))> + > : std::true_type {}; + + // Not callable. + template + struct is_callable_impl : std::false_type {}; + + template + struct is_callable : is_callable_impl {}; + #else + template + struct is_callable_impl : std::false_type {}; + + template + struct is_callable_impl< + F(Ts...), + void_t_>> : std::true_type {}; + #endif + #define count_macro_args_impl_hip_(\ _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15,\ _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29,\ diff --git a/projects/hip/include/hip/hcc_detail/hip_complex.h b/projects/hip/include/hip/hcc_detail/hip_complex.h index 26d73a21a8..c76d65b058 100644 --- a/projects/hip/include/hip/hcc_detail/hip_complex.h +++ b/projects/hip/include/hip/hcc_detail/hip_complex.h @@ -24,6 +24,7 @@ THE SOFTWARE. #define HIP_INCLUDE_HIP_HCC_DETAIL_HIP_COMPLEX_H #include "hip/hcc_detail/hip_vector_types.h" +#include #if __cplusplus #define COMPLEX_ADD_OP_OVERLOAD(type) \ diff --git a/projects/hip/include/hip/hcc_detail/hip_vector_types.h b/projects/hip/include/hip/hcc_detail/hip_vector_types.h index 82bd3b2d6f..35c6c23548 100644 --- a/projects/hip/include/hip/hcc_detail/hip_vector_types.h +++ b/projects/hip/include/hip/hcc_detail/hip_vector_types.h @@ -1270,6 +1270,15 @@ __device__ __host__ static inline type operator op (type& val, int) { \ #define DECLOP_1VAR_COMP(type, op) \ __device__ __host__ static inline bool operator op (type& lhs, type& rhs) { \ return lhs.x op rhs.x; \ +} \ +__device__ __host__ static inline bool operator op (const type& lhs, type& rhs) { \ + return lhs.x op rhs.x; \ +} \ +__device__ __host__ static inline bool operator op (type& lhs, const type& rhs) { \ + return lhs.x op rhs.x ; \ +} \ +__device__ __host__ static inline bool operator op (const type& lhs, const type& rhs) { \ + return lhs.x op rhs.x ; \ } #define DECLOP_1VAR_1IN_1OUT(type, op) \ @@ -1338,6 +1347,15 @@ __device__ __host__ static inline type operator op (type& val, int) { \ #define DECLOP_2VAR_COMP(type, op) \ __device__ __host__ static inline bool operator op (type& lhs, type& rhs) { \ return (lhs.x op rhs.x) && (lhs.y op rhs.y); \ +} \ +__device__ __host__ static inline bool operator op (const type& lhs, type& rhs) { \ + return (lhs.x op rhs.x) && (lhs.y op rhs.y); \ +} \ +__device__ __host__ static inline bool operator op (type& lhs, const type& rhs) { \ + return (lhs.x op rhs.x) && (lhs.y op rhs.y); \ +} \ +__device__ __host__ static inline bool operator op (const type& lhs, const type& rhs) { \ + return (lhs.x op rhs.x) && (lhs.y op rhs.y); \ } #define DECLOP_2VAR_1IN_1OUT(type, op) \ @@ -1415,7 +1433,16 @@ __device__ __host__ static inline type operator op (type& val, int) { \ #define DECLOP_3VAR_COMP(type, op) \ __device__ __host__ static inline bool operator op (type& lhs, type& rhs) { \ return (lhs.x op rhs.x) && (lhs.y op rhs.y) && (lhs.z op rhs.z); \ -} +} \ +__device__ __host__ static inline bool operator op (const type& lhs, type& rhs) { \ + return (lhs.x op rhs.x) && (lhs.y op rhs.y) && (lhs.z op rhs.z); \ +} \ +__device__ __host__ static inline bool operator op (type& lhs, const type& rhs) { \ + return (lhs.x op rhs.x) && (lhs.y op rhs.y) && (lhs.z op rhs.z); \ +} \ +__device__ __host__ static inline bool operator op (const type& lhs, const type& rhs) { \ + return (lhs.x op rhs.x) && (lhs.y op rhs.y) && (lhs.z op rhs.z); \ +} \ #define DECLOP_3VAR_1IN_1OUT(type, op) \ __device__ __host__ static inline type operator op(type &rhs) { \ @@ -1500,6 +1527,15 @@ __device__ __host__ static inline type operator op (type& val, int) { \ #define DECLOP_4VAR_COMP(type, op) \ __device__ __host__ static inline bool operator op (type& lhs, type& rhs) { \ return (lhs.x op rhs.x) && (lhs.y op rhs.y) && (lhs.z op rhs.z) && (lhs.w op rhs.w); \ +} \ +__device__ __host__ static inline bool operator op (const type& lhs, type& rhs) { \ + return (lhs.x op rhs.x) && (lhs.y op rhs.y) && (lhs.z op rhs.z) && (lhs.w op rhs.w); \ +} \ +__device__ __host__ static inline bool operator op (type& lhs, const type& rhs) { \ + return (lhs.x op rhs.x) && (lhs.y op rhs.y) && (lhs.z op rhs.z) && (lhs.w op rhs.w); \ +} \ +__device__ __host__ static inline bool operator op (const type& lhs, const type& rhs) { \ + return (lhs.x op rhs.x) && (lhs.y op rhs.y) && (lhs.z op rhs.z) && (lhs.w op rhs.w); \ } #define DECLOP_4VAR_1IN_1OUT(type, op) \ diff --git a/projects/hip/include/hip/hcc_detail/host_defines.h b/projects/hip/include/hip/hcc_detail/host_defines.h index b0a7421d18..5864cfa0e7 100644 --- a/projects/hip/include/hip/hcc_detail/host_defines.h +++ b/projects/hip/include/hip/hcc_detail/host_defines.h @@ -48,7 +48,7 @@ THE SOFTWARE. #define __global__ __attribute__((hc_grid_launch)) __attribute__((used)) #else //#warning "GGL global define reached" -#define __global__ [[hc]] __attribute__((weak)) +#define __global__ __attribute__((hc, weak)) #endif //GENERIC_GRID_LAUNCH #define __noinline__ __attribute__((noinline)) diff --git a/projects/hip/include/hip/hcc_detail/math_functions.h b/projects/hip/include/hip/hcc_detail/math_functions.h index c3b8186fd3..9faff2743a 100644 --- a/projects/hip/include/hip/hcc_detail/math_functions.h +++ b/projects/hip/include/hip/hcc_detail/math_functions.h @@ -51,6 +51,7 @@ __device__ float exp10f(float x); __device__ float exp2f(float x); __device__ float expf(float x); __device__ float expm1f(float x); +__device__ int abs(int x); __device__ float fabsf(float x); __device__ float fdimf(float x, float y); __device__ float fdividef(float x, float y); diff --git a/projects/hip/include/hip/hip_fp16.h b/projects/hip/include/hip/hip_fp16.h index 0e002d9396..95879dba50 100644 --- a/projects/hip/include/hip/hip_fp16.h +++ b/projects/hip/include/hip/hip_fp16.h @@ -20,7 +20,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifdef HIP_INCLUDE_HIP_HIP_FP16_H +#ifndef HIP_INCLUDE_HIP_HIP_FP16_H #define HIP_INCLUDE_HIP_HIP_FP16_H #include diff --git a/projects/hip/packaging/hip-targets-release.cmake b/projects/hip/packaging/hip-targets-release.cmake new file mode 100644 index 0000000000..ba0a5005f5 --- /dev/null +++ b/projects/hip/packaging/hip-targets-release.cmake @@ -0,0 +1,41 @@ +#---------------------------------------------------------------- +# Generated CMake target import file for configuration "Release". +#---------------------------------------------------------------- + +# Commands may need to know the format version. +set(CMAKE_IMPORT_FILE_VERSION 1) + +# Import target "hip::hip_hcc_static" for configuration "Release" +set_property(TARGET hip::hip_hcc_static APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) +set_target_properties(hip::hip_hcc_static PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX" + IMPORTED_LINK_INTERFACE_LIBRARIES_RELEASE "hc_am" + IMPORTED_LOCATION_RELEASE "/opt/rocm/hip/lib/libhip_hcc_static.a" + ) + +list(APPEND _IMPORT_CHECK_TARGETS hip::hip_hcc_static ) +list(APPEND _IMPORT_CHECK_FILES_FOR_hip::hip_hcc_static "/opt/rocm/hip/lib/libhip_hcc_static.a" ) + +# Import target "hip::hip_hcc" for configuration "Release" +set_property(TARGET hip::hip_hcc APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) +set_target_properties(hip::hip_hcc PROPERTIES + IMPORTED_LINK_INTERFACE_LIBRARIES_RELEASE "hcc::hccrt;hcc::hc_am" + IMPORTED_LOCATION_RELEASE "/opt/rocm/hip/lib/libhip_hcc.so" + IMPORTED_SONAME_RELEASE "libhip_hcc.so" + ) + +list(APPEND _IMPORT_CHECK_TARGETS hip::hip_hcc ) +list(APPEND _IMPORT_CHECK_FILES_FOR_hip::hip_hcc "/opt/rocm/hip/lib/libhip_hcc.so" ) + +# Import target "hip::hip_device" for configuration "Release" +set_property(TARGET hip::hip_device APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) +set_target_properties(hip::hip_device PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX" + IMPORTED_LOCATION_RELEASE "/opt/rocm/hip/lib/libhip_device.a" + ) + +list(APPEND _IMPORT_CHECK_TARGETS hip::hip_device ) +list(APPEND _IMPORT_CHECK_FILES_FOR_hip::hip_device "/opt/rocm/hip/lib/libhip_device.a" ) + +# Commands beyond this point should not need to know the version. +set(CMAKE_IMPORT_FILE_VERSION) diff --git a/projects/hip/packaging/hip-targets.cmake b/projects/hip/packaging/hip-targets.cmake new file mode 100644 index 0000000000..65370eec9e --- /dev/null +++ b/projects/hip/packaging/hip-targets.cmake @@ -0,0 +1,102 @@ +# Generated by CMake 3.5.1 + +if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.5) + message(FATAL_ERROR "CMake >= 2.6.0 required") +endif() +cmake_policy(PUSH) +cmake_policy(VERSION 2.6) +#---------------------------------------------------------------- +# Generated CMake target import file. +#---------------------------------------------------------------- + +# Commands may need to know the format version. +set(CMAKE_IMPORT_FILE_VERSION 1) + +# Protect against multiple inclusion, which would fail when already imported targets are added once more. +set(_targetsDefined) +set(_targetsNotDefined) +set(_expectedTargets) +foreach(_expectedTarget hip::hip_hcc_static hip::hip_hcc hip::hip_device) + list(APPEND _expectedTargets ${_expectedTarget}) + if(NOT TARGET ${_expectedTarget}) + list(APPEND _targetsNotDefined ${_expectedTarget}) + endif() + if(TARGET ${_expectedTarget}) + list(APPEND _targetsDefined ${_expectedTarget}) + endif() +endforeach() +if("${_targetsDefined}" STREQUAL "${_expectedTargets}") + set(CMAKE_IMPORT_FILE_VERSION) + cmake_policy(POP) + return() +endif() +if(NOT "${_targetsDefined}" STREQUAL "") + message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_targetsDefined}\nTargets not yet defined: ${_targetsNotDefined}\n") +endif() +unset(_targetsDefined) +unset(_targetsNotDefined) +unset(_expectedTargets) + + +# The installation prefix configured by this project. +set(_IMPORT_PREFIX "/opt/rocm/hip") + +# Create imported target hip::hip_hcc_static +add_library(hip::hip_hcc_static STATIC IMPORTED) + +set_target_properties(hip::hip_hcc_static PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include;/opt/rocm/hsa/include" + INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include;/opt/rocm/hsa/include" +) + +# Create imported target hip::hip_hcc +add_library(hip::hip_hcc SHARED IMPORTED) + +set_target_properties(hip::hip_hcc PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include;/opt/rocm/hsa/include" + INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include;/opt/rocm/hsa/include" +) + +# Create imported target hip::hip_device +add_library(hip::hip_device STATIC IMPORTED) + +set_target_properties(hip::hip_device PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include;/opt/rocm/hsa/include" + INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include;/opt/rocm/hsa/include" +) + +# Load information for each installed configuration. +get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) +file(GLOB CONFIG_FILES "${_DIR}/hip-targets-*.cmake") +foreach(f ${CONFIG_FILES}) + include(${f}) +endforeach() + +# Cleanup temporary variables. +set(_IMPORT_PREFIX) + +# Loop over all imported files and verify that they actually exist +foreach(target ${_IMPORT_CHECK_TARGETS} ) + foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} ) + if(NOT EXISTS "${file}" ) + message(FATAL_ERROR "The imported target \"${target}\" references the file + \"${file}\" +but this file does not exist. Possible reasons include: +* The file was deleted, renamed, or moved to another location. +* An install or uninstall procedure did not complete successfully. +* The installation package was faulty and contained + \"${CMAKE_CURRENT_LIST_FILE}\" +but not all the files it references. +") + endif() + endforeach() + unset(_IMPORT_CHECK_FILES_FOR_${target}) +endforeach() +unset(_IMPORT_CHECK_TARGETS) + +# This file does not depend on other imported targets which have +# been exported from the same project but in a separate export set. + +# Commands beyond this point should not need to know the version. +set(CMAKE_IMPORT_FILE_VERSION) +cmake_policy(POP) diff --git a/projects/hip/packaging/hip_hcc.txt b/projects/hip/packaging/hip_hcc.txt index 7dd65033fd..7118c32eb9 100644 --- a/projects/hip/packaging/hip_hcc.txt +++ b/projects/hip/packaging/hip_hcc.txt @@ -6,6 +6,8 @@ install(FILES @PROJECT_BINARY_DIR@/libhip_hcc_static.a DESTINATION lib) install(FILES @PROJECT_BINARY_DIR@/libhip_device.a DESTINATION lib) install(FILES @PROJECT_BINARY_DIR@/.hipInfo DESTINATION lib) install(FILES @hip_SOURCE_DIR@/src/hip_hc.ll @hip_SOURCE_DIR@/src/hip_hc_gfx803.ll DESTINATION lib) +install(FILES @PROJECT_BINARY_DIR@/hip-config.cmake @PROJECT_BINARY_DIR@/hip-config-version.cmake DESTINATION lib/cmake/hip) +install(FILES @hip_SOURCE_DIR@/packaging/hip-targets.cmake @hip_SOURCE_DIR@/packaging/hip-targets-release.cmake DESTINATION lib/cmake/hip) ############################# # Packaging steps diff --git a/projects/hip/src/grid_launch.cpp b/projects/hip/src/grid_launch.cpp index 7739995600..cac01df7dc 100644 --- a/projects/hip/src/grid_launch.cpp +++ b/projects/hip/src/grid_launch.cpp @@ -27,6 +27,9 @@ THE SOFTWARE. #include "hc.hpp" #include "trace_helper.h" +#include +#include + namespace hip_impl { hc::accelerator_view lock_stream_hip_( @@ -42,6 +45,39 @@ namespace hip_impl return (*static_cast(locked_stream))->_av; } + void print_prelaunch_trace_( + const char* kernel_name, + dim3 num_blocks, + dim3 dim_blocks, + int group_mem_bytes, + hipStream_t stream) + { + if ((HIP_TRACE_API & (1 << TRACE_CMD)) || + HIP_PROFILE_API || + (COMPILE_HIP_DB && HIP_TRACE_API)) { + std::stringstream os; + os << tls_tidInfo.tid() << "." << tls_tidInfo.apiSeqNum() + << " hipLaunchKernel '" << kernel_name << "'" + << " gridDim:" << num_blocks + << " groupDim:" << dim_blocks + << " sharedMem:+" << group_mem_bytes + << " " << *stream; + + if (HIP_PROFILE_API == 0x1) { + std::string shortAtpString("hipLaunchKernel:"); + shortAtpString += kernel_name; + MARKER_BEGIN(shortAtpString.c_str(), "HIP"); + } else if (HIP_PROFILE_API == 0x2) { + MARKER_BEGIN(os.str().c_str(), "HIP"); + } + + if (COMPILE_HIP_DB && HIP_TRACE_API) { + std::cerr << API_COLOR << os.str() << API_COLOR_END + << std::endl; + } + } + } + void unlock_stream_hip_( hipStream_t stream, void* locked_stream, diff --git a/projects/hip/src/math_functions.cpp b/projects/hip/src/math_functions.cpp index 92cc8689fc..3472216309 100644 --- a/projects/hip/src/math_functions.cpp +++ b/projects/hip/src/math_functions.cpp @@ -114,6 +114,10 @@ __device__ float expm1f(float x) { return hc::precise_math::expm1f(x); } +__device__ int abs(int x) +{ + return x >= 0 ? x : -x; // TODO - optimize with OCML +} __device__ float fabsf(float x) { return hc::precise_math::fabsf(x); From 4ad171f99d31abece46b9ab4d20fb518541989a1 Mon Sep 17 00:00:00 2001 From: James Edwards Date: Mon, 17 Apr 2017 23:58:34 -0500 Subject: [PATCH 277/281] Fix RPM HIP packages from specifying /opt Change-Id: Iec3c3b81eef4c8888d425eefc80b12488a8d20a1 (cherry picked from commit 1963e91a8e0dd3326fae1e91c3633cfbca3cdb40) [ROCm/hip commit: 8ff755b6ccf3c5e4b47cc84c4ff45978eacc4410] --- projects/hip/packaging/hip_base.txt | 1 + projects/hip/packaging/hip_doc.txt | 1 + projects/hip/packaging/hip_hcc.txt | 1 + projects/hip/packaging/hip_nvcc.txt | 1 + projects/hip/packaging/hip_samples.txt | 1 + 5 files changed, 5 insertions(+) diff --git a/projects/hip/packaging/hip_base.txt b/projects/hip/packaging/hip_base.txt index a208bc3463..836a82657b 100644 --- a/projects/hip/packaging/hip_base.txt +++ b/projects/hip/packaging/hip_base.txt @@ -33,5 +33,6 @@ set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${PROJECT_BINARY_DIR}/postinst") set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${PROJECT_BINARY_DIR}/prerm") set(CPACK_RPM_PACKAGE_AUTOREQPROV " no") set(CPACK_RPM_PACKAGE_REQUIRES "perl >= 5.0") +set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/opt") set(CPACK_SOURCE_GENERATOR "TGZ") include(CPack) diff --git a/projects/hip/packaging/hip_doc.txt b/projects/hip/packaging/hip_doc.txt index d5a0c471b1..6f602c84cf 100644 --- a/projects/hip/packaging/hip_doc.txt +++ b/projects/hip/packaging/hip_doc.txt @@ -36,5 +36,6 @@ set(CPACK_BINARY_RPM "ON") set(CPACK_RPM_PACKAGE_ARCHITECTURE "x86_64") set(CPACK_RPM_PACKAGE_AUTOREQPROV " no") set(CPACK_RPM_PACKAGE_REQUIRES "hip_base = ${CPACK_PACKAGE_VERSION}") +set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/opt") set(CPACK_SOURCE_GENERATOR "TGZ") include(CPack) diff --git a/projects/hip/packaging/hip_hcc.txt b/projects/hip/packaging/hip_hcc.txt index 7118c32eb9..b0808aa0bc 100644 --- a/projects/hip/packaging/hip_hcc.txt +++ b/projects/hip/packaging/hip_hcc.txt @@ -46,5 +46,6 @@ if(@COMPILE_HIP_ATP_MARKER@) else() set(CPACK_RPM_PACKAGE_REQUIRES "hip_base = ${CPACK_PACKAGE_VERSION}, ${HCC_PACKAGE_NAME} = @HCC_PACKAGE_VERSION@") endif() +set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/opt") set(CPACK_SOURCE_GENERATOR "TGZ") include(CPack) diff --git a/projects/hip/packaging/hip_nvcc.txt b/projects/hip/packaging/hip_nvcc.txt index ea4943f282..0d7c357623 100644 --- a/projects/hip/packaging/hip_nvcc.txt +++ b/projects/hip/packaging/hip_nvcc.txt @@ -25,5 +25,6 @@ set(CPACK_RPM_PACKAGE_ARCHITECTURE "x86_64") #set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${PROJECT_BINARY_DIR}/prerm") set(CPACK_RPM_PACKAGE_AUTOREQPROV " no") set(CPACK_RPM_PACKAGE_REQUIRES "hip_base = ${CPACK_PACKAGE_VERSION}, cuda >= 7.5") +set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/opt") set(CPACK_SOURCE_GENERATOR "TGZ") include(CPack) diff --git a/projects/hip/packaging/hip_samples.txt b/projects/hip/packaging/hip_samples.txt index f289f2a8e5..6d34a6fd40 100644 --- a/projects/hip/packaging/hip_samples.txt +++ b/projects/hip/packaging/hip_samples.txt @@ -24,5 +24,6 @@ set(CPACK_BINARY_RPM "ON") set(CPACK_RPM_PACKAGE_ARCHITECTURE "x86_64") set(CPACK_RPM_PACKAGE_AUTOREQPROV " no") set(CPACK_RPM_PACKAGE_REQUIRES "hip_base = ${CPACK_PACKAGE_VERSION}") +set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/opt") set(CPACK_SOURCE_GENERATOR "TGZ") include(CPack) From 2c355e223c9296b05b5f33341d5f7fe2f0b18a26 Mon Sep 17 00:00:00 2001 From: James Edwards Date: Fri, 21 Apr 2017 22:34:26 -0500 Subject: [PATCH 278/281] Properly link hip cmake file into top level lib directory. Change-Id: I2113a86ca6985f34fd0cfb091abdbce0f632cfc2 (cherry picked from commit 236c084472fea9f1212a7066a4df33f9075dceca) [ROCm/hip commit: 0e9a3371e742b69f933d35a7c15c232e57cfb12a] --- projects/hip/packaging/hip_hcc.postinst | 15 ++++++++++----- projects/hip/packaging/hip_hcc.prerm | 10 +++++++--- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/projects/hip/packaging/hip_hcc.postinst b/projects/hip/packaging/hip_hcc.postinst index 14179db767..e7d53b742b 100755 --- a/projects/hip/packaging/hip_hcc.postinst +++ b/projects/hip/packaging/hip_hcc.postinst @@ -8,17 +8,22 @@ popd () { } ROCMDIR=/opt/rocm -HIPDIR=$ROCMDIR/hip - -# Soft-link to libraries -HIPLIBFILES=$HIPDIR/lib/* ROCMLIBDIR=$ROCMDIR/lib +HIPDIR=$ROCMDIR/hip +HIPLIBDIR=$ROCMDIR/hip/lib + +# Soft-link to library files +HIPLIBFILES=$(ls -aF $HIPLIBDIR | grep -v [-/$]) mkdir -p $ROCMLIBDIR +mkdir -p $ROCMLIBDIR/cmake pushd $ROCMLIBDIR for f in $HIPLIBFILES do ln -s $f $(basename $f) done - ln -s $HIPDIR/lib/.hipInfo .hipInfo +# Make the hip cmake directory link. +pushd cmake +ln -s $HIPLIBDIR/cmake/hip hip +popd popd diff --git a/projects/hip/packaging/hip_hcc.prerm b/projects/hip/packaging/hip_hcc.prerm index dda313a3a4..ee64aea632 100755 --- a/projects/hip/packaging/hip_hcc.prerm +++ b/projects/hip/packaging/hip_hcc.prerm @@ -9,17 +9,21 @@ popd () { } ROCMDIR=/opt/rocm +ROCMLIBDIR=$ROCMDIR/lib HIPDIR=$ROCMDIR/hip +HIPLIBDIR=$ROCMDIR/hip/lib # Remove soft-links to libraries -HIPLIBFILES=$HIPDIR/lib/* -ROCMLIBDIR=$ROCMDIR/lib +HIPLIBFILES=$(ls -aF $HIPLIBDIR | grep -v [-/$]) pushd $ROCMLIBDIR for f in $HIPLIBFILES do rm $(basename $f) done -rm .hipInfo +pushd cmake +unlink hip +popd +rmdir --ignore-fail-on-non-empty cmake popd rmdir --ignore-fail-on-non-empty $ROCMLIBDIR From bcf5ef03900d1a728661a46e579f2df1759891e5 Mon Sep 17 00:00:00 2001 From: James Edwards Date: Sat, 22 Apr 2017 15:54:14 -0500 Subject: [PATCH 279/281] Specify full path of hip libraries in link file. Change-Id: I49b788f3489e7abff6b11006ff97fdfca4e5942c (cherry picked from commit 63cca4cd291ddf4c5a2fce88a9e3f7ae025a16f9) [ROCm/hip commit: 090398d52226d32a7af05cb5822b3bad03d52a9d] --- projects/hip/packaging/hip_hcc.postinst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/hip/packaging/hip_hcc.postinst b/projects/hip/packaging/hip_hcc.postinst index e7d53b742b..c7f9c3184c 100755 --- a/projects/hip/packaging/hip_hcc.postinst +++ b/projects/hip/packaging/hip_hcc.postinst @@ -19,7 +19,7 @@ mkdir -p $ROCMLIBDIR/cmake pushd $ROCMLIBDIR for f in $HIPLIBFILES do - ln -s $f $(basename $f) + ln -s $HIPLIBDIR/$f $(basename $f) done # Make the hip cmake directory link. pushd cmake From bed0375e99303f1d6ccc2af322804ba44a636f38 Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Mon, 24 Apr 2017 08:50:43 +0530 Subject: [PATCH 280/281] Merge branch 'amd-develop' into amd-master Change-Id: I312fb9d1181733ef5160d1e993e2ae57ced0f6b3 (cherry picked from commit f884e55aca10a8e86c167a11846d87f52993ac43) [ROCm/hip commit: 5433d17e2efce82d5f95b69759f0db2a18ee3dfc] --- projects/hip/RELEASE.md | 46 + projects/hip/cmake/FindHIP.cmake | 8 +- ...A_Driver_API_functions_supported_by_HIP.md | 499 ++++++++ projects/hip/docs/markdown/hip_bugs.md | 19 + projects/hip/hipify-clang/README.md | 29 +- projects/hip/hipify-clang/src/Cuda2Hip.cpp | 1044 +++++++++++------ .../hip/include/hip/nvcc_detail/hip_runtime.h | 4 + .../include/hip/nvcc_detail/hip_runtime_api.h | 4 +- projects/hip/samples/0_Intro/square/Makefile | 1 + .../samples/0_Intro/square/square.hipref.cpp | 2 +- 10 files changed, 1259 insertions(+), 397 deletions(-) create mode 100644 projects/hip/docs/markdown/CUDA_Driver_API_functions_supported_by_HIP.md diff --git a/projects/hip/RELEASE.md b/projects/hip/RELEASE.md index 34eab60833..21fd8da7bb 100644 --- a/projects/hip/RELEASE.md +++ b/projects/hip/RELEASE.md @@ -13,6 +13,52 @@ Upcoming: ## Revision History: +=================================================================================================== +Release: 1.0.17102 +Date: 2017.03.07 +- Lots of improvements to hipify-clang. +- Added HIP package config for cmake. +- Several bug fixes and documentation updates. + + +=================================================================================================== +Release: 1.0.17066 +Date: 2017.02.11 +- Improved support for math device functions. +- Added several half math device functions. +- Enabled support for CUDA 8.0 in hipify-clang. +- Lots of bug fixes and documentation updates. + + +=================================================================================================== +Release: 1.0.17015 +Date: 2017.01.06 +- Several improvements to the hipify-clang infrastructure. +- Refactored module and function APIs. +- HIP now defaults to linking against the shared runtime library. +- Documentation updates. + + +=================================================================================================== +Release: 1.0.16502 +Date: 2016.12.13 +- Added several fast math and packaged math instrincs +- Improved debug and profiler documentation +- Support for building and linking to HIP shared library +- Several improvements to hipify-clang +- Several bug fixes + + +=================================================================================================== +Release: 1.0.16461 +Date: 2016.11.14 +- Significant changes to the HIP Profiling APIs. Refer to the documentation for details +- Improvements to P2P support +- New API: hipDeviceGetByPCIBusId +- Several bug fixes in NV path +- hipModuleLaunch now works for multi-dim kernels + + =================================================================================================== Release:1.0 Date: 2016.11.8 diff --git a/projects/hip/cmake/FindHIP.cmake b/projects/hip/cmake/FindHIP.cmake index 0001436fee..5a5813ba0d 100644 --- a/projects/hip/cmake/FindHIP.cmake +++ b/projects/hip/cmake/FindHIP.cmake @@ -514,7 +514,9 @@ macro(HIP_ADD_EXECUTABLE hip_target) # Separate the sources from the options HIP_GET_SOURCES_AND_OPTIONS(_sources _cmake_options _hipcc_options _hcc_options _nvcc_options ${ARGN}) HIP_PREPARE_TARGET_COMMANDS(${hip_target} OBJ _generated_files _source_files ${_sources} HIPCC_OPTIONS ${_hipcc_options} HCC_OPTIONS ${_hcc_options} NVCC_OPTIONS ${_nvcc_options}) - list(REMOVE_ITEM _sources ${_source_files}) + if(_source_files) + list(REMOVE_ITEM _sources ${_source_files}) + endif() if("x${HCC_HOME}" STREQUAL "x") set(HCC_HOME "/opt/rocm/hcc") endif() @@ -530,7 +532,9 @@ macro(HIP_ADD_LIBRARY hip_target) # Separate the sources from the options HIP_GET_SOURCES_AND_OPTIONS(_sources _cmake_options _hipcc_options _hcc_options _nvcc_options ${ARGN}) HIP_PREPARE_TARGET_COMMANDS(${hip_target} OBJ _generated_files _source_files ${_sources} ${_cmake_options} HIPCC_OPTIONS ${_hipcc_options} HCC_OPTIONS ${_hcc_options} NVCC_OPTIONS ${_nvcc_options}) - list(REMOVE_ITEM _sources ${_source_files}) + if(_source_files) + list(REMOVE_ITEM _sources ${_source_files}) + endif() add_library(${hip_target} ${_cmake_options} ${_generated_files} ${_sources}) set_target_properties(${hip_target} PROPERTIES LINKER_LANGUAGE ${HIP_C_OR_CXX}) endmacro() diff --git a/projects/hip/docs/markdown/CUDA_Driver_API_functions_supported_by_HIP.md b/projects/hip/docs/markdown/CUDA_Driver_API_functions_supported_by_HIP.md new file mode 100644 index 0000000000..3434d29a70 --- /dev/null +++ b/projects/hip/docs/markdown/CUDA_Driver_API_functions_supported_by_HIP.md @@ -0,0 +1,499 @@ +# CUDA Driver API functions supported by HIP + +## **1. Data types used by CUDA driver** + +| **type** | **CUDA** | **HIP** | **CUDA description** | +|-------------:|---------------------------------------------------------------|------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------| +| struct | `CUDA_ARRAY3D_DESCRIPTOR` | | | +| struct | `CUDA_ARRAY_DESCRIPTOR` | | | +| struct | `CUDA_MEMCPY2D` | | | +| struct | `CUDA_MEMCPY3D` | | | +| struct | `CUDA_MEMCPY3D_PEER` | | | +| struct | `CUDA_POINTER_ATTRIBUTE_P2P_TOKENS` | | | +| struct | `CUDA_RESOURCE_DESC` | | | +| struct | `CUDA_RESOURCE_VIEW_DESC` | | | +| struct | `CUdevprop` | `hipDeviceProp_t` | | +| struct | `CUipcEventHandle` | | | +| struct | `CUipcMemHandle` | | | +| enum |***`CUaddress_mode`*** | | Texture reference addressing modes | +| 0 |*`CU_TR_ADDRESS_MODE_WRAP`* | | Wrapping address mode | +| 1 |*`CU_TR_ADDRESS_MODE_CLAMP`* | | Clamp to edge address mode | +| 2 |*`CU_TR_ADDRESS_MODE_MIRROR`* | | Mirror address mode | +| 3 |*`CU_TR_ADDRESS_MODE_BORDER`* | | Border address mode | +| enum |***`CUarray_cubemap_face`*** | | Array indices for cube faces | +| 0x00 |*`CU_CUBEMAP_FACE_POSITIVE_X`* | | Positive X face of cubemap | +| 0x01 |*`CU_CUBEMAP_FACE_NEGATIVE_X`* | | Negative X face of cubemap | +| 0x02 |*`CU_CUBEMAP_FACE_POSITIVE_Y`* | | Positive Y face of cubemap | +| 0x03 |*`CU_CUBEMAP_FACE_NEGATIVE_Y`* | | Negative Y face of cubemap | +| 0x04 |*`CU_CUBEMAP_FACE_POSITIVE_Z`* | | Positive Z face of cubemap | +| 0x05 |*`CU_CUBEMAP_FACE_NEGATIVE_Z`* | | Negative Z face of cubemap | +| enum |***`CUarray_format`*** | | Array formats | +| 0x01 |*`CU_AD_FORMAT_UNSIGNED_INT8`* | | Unsigned 8-bit integers | +| 0x02 |*`CU_AD_FORMAT_UNSIGNED_INT16`* | | Unsigned 16-bit integers | +| 0x03 |*`CU_AD_FORMAT_UNSIGNED_INT32`* | | Unsigned 32-bit integers | +| 0x08 |*`CU_AD_FORMAT_SIGNED_INT8`* | | Signed 8-bit integers | +| 0x09 |*`CU_AD_FORMAT_SIGNED_INT16`* | | Signed 16-bit integers | +| 0x0a |*`CU_AD_FORMAT_SIGNED_INT32`* | | Signed 32-bit integers | +| 0x10 |*`CU_AD_FORMAT_HALF`* | | 16-bit floating point | +| 0x20 |*`CU_AD_FORMAT_FLOAT`* | | 32-bit floating point | +| enum |***`CUctx_flags`*** | | Context creation flags | +| 0x00 |*`CU_CTX_SCHED_AUTO`* | | Automatic scheduling | +| 0x01 |*`CU_CTX_SCHED_SPIN`* | | Set spin as default scheduling | +| 0x02 |*`CU_CTX_SCHED_YIELD`* | | Set yield as default scheduling | +| 0x04 |*`CU_CTX_SCHED_BLOCKING_SYNC`* | | Set blocking synchronization as default scheduling | +| 0x04 |*`CU_CTX_BLOCKING_SYNC`* | | Set blocking synchronization as default scheduling Deprecated. This flag was deprecated as of CUDA 4.0 and was replaced with CU_CTX_SCHED_BLOCKING_SYNC.| +| 0x07 |*`CU_CTX_SCHED_MASK`* | | | +| 0x08 |*`CU_CTX_MAP_HOST`* | | Support mapped pinned allocations | +| 0x10 |*`CU_CTX_LMEM_RESIZE_TO_MAX`* | | Keep local memory allocation after launch | +| 0x1f |*`CU_CTX_FLAGS_MASK`* | | | +| enum |***`CUdevice_attribute`*** | | Device properties | +| 1 |*`CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_BLOCK`* |*`hipDeviceAttributeMaxThreadsPerBlock`* | Maximum number of threads per block | +| 2 |*`CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_X`* |*`hipDeviceAttributeMaxBlockDimX`* | Maximum block dimension X | +| 3 |*`CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Y`* |*`hipDeviceAttributeMaxBlockDimY`* | Maximum block dimension Y | +| 4 |*`CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Z`* |*`hipDeviceAttributeMaxBlockDimZ`* | Maximum block dimension Z | +| 5 |*`CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_X`* |*`hipDeviceAttributeMaxGridDimX`* | Maximum grid dimension X | +| 6 |*`CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_Y`* |*`hipDeviceAttributeMaxGridDimY`* | Maximum grid dimension Y | +| 7 |*`CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_Z`* |*`hipDeviceAttributeMaxGridDimZ`* | Maximum grid dimension Y | +| 8 |*`CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK`* |*`hipDeviceAttributeMaxSharedMemoryPerBlock`* | Maximum shared memory available per block in bytes | +| 8 |*`CU_DEVICE_ATTRIBUTE_SHARED_MEMORY_PER_BLOCK`* |*`hipDeviceAttributeMaxSharedMemoryPerBlock`* | Deprecated, use CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK | +| 9 |*`CU_DEVICE_ATTRIBUTE_TOTAL_CONSTANT_MEMORY`* |*`hipDeviceAttributeTotalConstantMemory`* | Memory available on device for __constant__ variables in a CUDA C kernel in bytes | +| 10 |*`CU_DEVICE_ATTRIBUTE_WARP_SIZE`* |*`hipDeviceAttributeWarpSize`* | Warp size in threads | +| 11 |*`CU_DEVICE_ATTRIBUTE_MAX_PITCH`* | | Maximum pitch in bytes allowed by memory copies | +| 12 |*`CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_BLOCK`* |*`hipDeviceAttributeMaxRegistersPerBlock`* | Maximum number of 32-bit registers available per block | +| 12 |*`CU_DEVICE_ATTRIBUTE_REGISTERS_PER_BLOCK`* |*`hipDeviceAttributeMaxRegistersPerBlock`* | Deprecated, use CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_BLOCK | +| 13 |*`CU_DEVICE_ATTRIBUTE_CLOCK_RATE`* |*`hipDeviceAttributeClockRate`* | Typical clock frequency in kilohertz | +| 14 |*`CU_DEVICE_ATTRIBUTE_TEXTURE_ALIGNMENT`* | | Alignment requirement for textures | +| 15 |*`CU_DEVICE_ATTRIBUTE_GPU_OVERLAP`* | | Device can possibly copy memory and execute a kernel concurrently. Deprecated. Use instead CU_DEVICE_ATTRIBUTE_ASYNC_ENGINE_COUNT| +| 16 |*`CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT`* |*`hipDeviceAttributeMultiprocessorCount`* | Number of multiprocessors on device | +| 17 |*`CU_DEVICE_ATTRIBUTE_KERNEL_EXEC_TIMEOUT`* | | Specifies whether there is a run time limit on kernels | +| 18 |*`CU_DEVICE_ATTRIBUTE_INTEGRATED`* | | Device is integrated with host memory | +| 19 |*`CU_DEVICE_ATTRIBUTE_CAN_MAP_HOST_MEMORY`* | | Device can map host memory into CUDA address space | +| 20 |*`CU_DEVICE_ATTRIBUTE_COMPUTE_MODE`* |*`hipDeviceAttributeComputeMode`* | Compute mode (See CUcomputemode for details) | +| 21 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_WIDTH`* | | Maximum 1D texture width | +| 22 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_WIDTH`* | | Maximum 2D texture width | +| 23 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_HEIGHT`* | | Maximum 2D texture height | +| 24 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_WIDTH`* | | Maximum 3D texture width | +| 25 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_HEIGHT`* | | Maximum 3D texture height | +| 26 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_DEPTH`* | | Maximum 3D texture depth | +| 27 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_WIDTH`* | | Maximum 2D layered texture width | +| 28 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_HEIGHT`* | | Maximum 2D layered texture height | +| 29 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_LAYERS`* | | Maximum layers in a 2D layered texture | +| 27 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_ARRAY_WIDTH`* | | Deprecated, use CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_WIDTH | +| 28 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_ARRAY_HEIGHT`* | | Deprecated, use CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_HEIGHT | +| 29 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_ARRAY_NUMSLICES`* | | Deprecated, use CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_LAYERS | +| 30 |*`CU_DEVICE_ATTRIBUTE_SURFACE_ALIGNMENT`* | | Alignment requirement for surfaces | +| 31 |*`CU_DEVICE_ATTRIBUTE_CONCURRENT_KERNELS`* |*`hipDeviceAttributeConcurrentKernels`* | Device can possibly execute multiple kernels concurrently | +| 32 |*`CU_DEVICE_ATTRIBUTE_ECC_ENABLED`* | | Device has ECC support enabled | +| 33 |*`CU_DEVICE_ATTRIBUTE_PCI_BUS_ID`* |*`hipDeviceAttributePciBusId`* | PCI bus ID of the device | +| 34 |*`CU_DEVICE_ATTRIBUTE_PCI_DEVICE_ID`* |*`hipDeviceAttributePciDeviceId`* | PCI device ID of the device | +| 35 |*`CU_DEVICE_ATTRIBUTE_TCC_DRIVER`* | | Device is using TCC driver model | +| 36 |*`CU_DEVICE_ATTRIBUTE_MEMORY_CLOCK_RATE`* |*`hipDeviceAttributeMemoryClockRate`* | Peak memory clock frequency in kilohertz | +| 37 |*`CU_DEVICE_ATTRIBUTE_GLOBAL_MEMORY_BUS_WIDTH`* |*`hipDeviceAttributeMemoryBusWidth`* | Global memory bus width in bits | +| 38 |*`CU_DEVICE_ATTRIBUTE_L2_CACHE_SIZE`* |*`hipDeviceAttributeL2CacheSize`* | Size of L2 cache in bytes | +| 39 |*`CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_MULTIPROCESSOR`* |*`hipDeviceAttributeMaxThreadsPerMultiProcessor`* | Maximum resident threads per multiprocessor | +| 40 |*`CU_DEVICE_ATTRIBUTE_ASYNC_ENGINE_COUNT`* | | Number of asynchronous engines | +| 41 |*`CU_DEVICE_ATTRIBUTE_UNIFIED_ADDRESSING`* | | Device shares a unified address space with the host | +| 42 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LAYERED_WIDTH`* | | Maximum 1D layered texture width | +| 43 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LAYERED_LAYERS`* | | Maximum layers in a 1D layered texture | +| 44 |*`CU_DEVICE_ATTRIBUTE_CAN_TEX2D_GATHER`* | | Deprecated, do not use | +| 45 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_GATHER_WIDTH`* | | Maximum 2D texture width if CUDA_ARRAY3D_TEXTURE_GATHER is set | +| 46 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_GATHER_HEIGHT`* | | Maximum 2D texture height if CUDA_ARRAY3D_TEXTURE_GATHER is set | +| 47 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_WIDTH_ALTERNATE`* | | Alternate maximum 3D texture width | +| 48 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_HEIGHT_ALTERNATE`* | | Alternate maximum 3D texture height | +| 49 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_DEPTH_ALTERNATE`* | | Alternate maximum 3D texture depth | +| 50 |*`CU_DEVICE_ATTRIBUTE_PCI_DOMAIN_ID`* | | PCI domain ID of the device | +| 51 |*`CU_DEVICE_ATTRIBUTE_TEXTURE_PITCH_ALIGNMENT`* | | Pitch alignment requirement for textures | +| 52 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURECUBEMAP_WIDTH`* | | Maximum cubemap texture width/height | +| 53 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURECUBEMAP_LAYERED_WIDTH`* | | Maximum cubemap layered texture width/height | +| 54 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURECUBEMAP_LAYERED_LAYERS`* | | Maximum layers in a cubemap layered texture | +| 55 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE1D_WIDTH`* | | Maximum 1D surface width | +| 56 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_WIDTH`* | | Maximum 2D surface width | +| 57 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_HEIGHT`* | | Maximum 2D surface height | +| 58 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE3D_WIDTH`* | | Maximum 3D surface width | +| 59 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE3D_HEIGHT`* | | Maximum 3D surface height | +| 60 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE3D_DEPTH`* | | Maximum 3D surface depth | +| 61 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE1D_LAYERED_WIDTH`* | | Maximum 1D layered surface width | +| 62 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE1D_LAYERED_LAYERS`* | | Maximum layers in a 1D layered surface | +| 63 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_WIDTH`* | | Maximum 2D layered surface width | +| 64 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_HEIGHT`* | | Maximum 2D layered surface height | +| 65 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_LAYERS`* | | Maximum layers in a 2D layered surface | +| 66 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_WIDTH`* | | Maximum cubemap surface width | +| 67 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_LAYERED_WIDTH`* | | Maximum cubemap layered surface width | +| 68 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_LAYERED_LAYERS`* | | Maximum layers in a cubemap layered surface | +| 69 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LINEAR_WIDTH`* | | Maximum 1D linear texture width | +| 70 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_WIDTH`* | | Maximum 2D linear texture width | +| 71 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_HEIGHT`* | | Maximum 2D linear texture height | +| 72 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_PITCH`* | | Maximum 2D linear texture pitch in bytes | +| 73 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_MIPMAPPED_WIDTH`* | | Maximum mipmapped 2D texture width | +| 74 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_MIPMAPPED_HEIGHT`* | | Maximum mipmapped 2D texture height | +| 75 |*`CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR`* |*`hipDeviceAttributeComputeCapabilityMajor`* | Major compute capability version number | +| 76 |*`CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR`* |*`hipDeviceAttributeComputeCapabilityMinor`* | Minor compute capability version number | +| 77 |*`CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_MIPMAPPED_WIDTH`* | | Maximum mipmapped 1D texture width | +| 78 |*`CU_DEVICE_ATTRIBUTE_STREAM_PRIORITIES_SUPPORTED`* | | Device supports stream priorities | +| 79 |*`CU_DEVICE_ATTRIBUTE_GLOBAL_L1_CACHE_SUPPORTED`* | | Device supports caching globals in L1 | +| 80 |*`CU_DEVICE_ATTRIBUTE_LOCAL_L1_CACHE_SUPPORTED`* | | Device supports caching locals in L1 | +| 81 |*`CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_MULTIPROCESSOR`* |*`hipDeviceAttributeMaxSharedMemoryPerMultiprocessor`* | Maximum shared memory available per multiprocessor in bytes | +| 82 |*`CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_MULTIPROCESSOR`* | | Maximum number of 32-bit registers available per multiprocessor | +| 83 |*`CU_DEVICE_ATTRIBUTE_MANAGED_MEMORY`* |*`hipDeviceAttributeManagedMemory`* | Device can allocate managed memory on this system | +| 84 |*`CU_DEVICE_ATTRIBUTE_MULTI_GPU_BOARD`* | | Device is on a multi-GPU board | +| 85 |*`CU_DEVICE_ATTRIBUTE_MULTI_GPU_BOARD_GROUP_ID`* | | Unique id for a group of devices on the same multi-GPU board | +| 86 |*`CU_DEVICE_ATTRIBUTE_MAX`* | | | +| enum |***`CUevent_flags`*** | | Event creation flags | +| 0x00 |*`CU_EVENT_DEFAULT`* |*`hipEventDefault`* | Default event flag | +| 0x01 |*`CU_EVENT_BLOCKING_SYNC`* |*`hipEventBlockingSync`* | Event uses blocking synchronization | +| 0x02 |*`CU_EVENT_DISABLE_TIMING`* |*`hipEventDisableTiming`* | Event will not record timing data | +| 0x04 |*`CU_EVENT_INTERPROCESS`* |*`hipEventInterprocess`* | Event is suitable for interprocess use. CU_EVENT_DISABLE_TIMING must be set | +| enum |***`CUfilter_mode`*** |***`hipTextureFilterMode`*** | Texture reference filtering modes | +| 0 |*`CU_TR_FILTER_MODE_POINT`* |*`hipFilterModePoint`* | Point filter mode | +| 1 |*`CU_TR_FILTER_MODE_LINEAR`* |*`hipFilterModeLinear`* | Linear filter mode | +| enum |***`CUfunc_cache`*** |***`hipFuncCache`*** | Function cache configurations | +| 0x00 |*`CU_FUNC_CACHE_PREFER_NONE`* |*`hipFuncCachePreferNone`* | no preference for shared memory or L1 (default) | +| 0x01 |*`CU_FUNC_CACHE_PREFER_SHARED`* |*`hipFuncCachePreferShared`* | prefer larger shared memory and smaller L1 cache | +| 0x02 |*`CU_FUNC_CACHE_PREFER_L1`* |*`hipFuncCachePreferL1`* | prefer larger L1 cache and smaller shared memory | +| 0x03 |*`CU_FUNC_CACHE_PREFER_EQUAL`* |*`hipFuncCachePreferEqual`* | prefer equal sized L1 cache and shared memory | +| enum |***`CUfunction_attribute`*** | | Function properties | +| 0 |*`CU_FUNC_ATTRIBUTE_MAX_THREADS_PER_BLOCK`* | | The maximum number of threads per block, beyond which a launch of the function would fail. This number depends on both the function and the device on which the function is currently loaded. | +| 1 |*`CU_FUNC_ATTRIBUTE_SHARED_SIZE_BYTES`* | | The size in bytes of statically-allocated shared memory required by this function. This does not include dynamically-allocated shared memory requested by the user at runtime. | +| 2 |*`CU_FUNC_ATTRIBUTE_CONST_SIZE_BYTES`* | | The size in bytes of user-allocated constant memory required by this function. | +| 3 |*`CU_FUNC_ATTRIBUTE_LOCAL_SIZE_BYTES`* | | The size in bytes of local memory used by each thread of this function. | +| 4 |*`CU_FUNC_ATTRIBUTE_NUM_REGS`* | | The number of registers used by each thread of this function. | +| 5 |*`CU_FUNC_ATTRIBUTE_PTX_VERSION`* | | The PTX virtual architecture version for which the function was compiled. This value is the major PTX version * 10 + the minor PTX version, so a PTX version 1.3 function would return the value 13. Note that this may return the undefined value of 0 for cubins compiled prior to CUDA 3.0. | +| 6 |*`CU_FUNC_ATTRIBUTE_BINARY_VERSION`* | | The binary architecture version for which the function was compiled. This value is the major binary version * 10 + the minor binary version, so a binary version 1.3 function would return the value 13. Note that this will return a value of 10 for legacy cubins that do not have a properly-encoded binary architecture version. | +| 7 |*`CU_FUNC_ATTRIBUTE_CACHE_MODE_CA`* | | The attribute to indicate whether the function has been compiled with user specified option "-Xptxas --dlcm=ca" set. | +| 8 |*`CU_FUNC_ATTRIBUTE_MAX`* | | | +| enum |***`CUgraphicsMapResourceFlags`*** | | Flags for mapping and unmapping interop resources | +| 0x00 |*`CU_GRAPHICS_MAP_RESOURCE_FLAGS_NONE`* | | | +| 0x01 |*`CU_GRAPHICS_MAP_RESOURCE_FLAGS_READ_ONLY`* | | | +| 0x02 |*`CU_GRAPHICS_MAP_RESOURCE_FLAGS_WRITE_DISCARD`* | | | +| enum |***`CUgraphicsRegisterFlags`*** | | Flags to register a graphics resource | +| 0x00 |*`CU_GRAPHICS_REGISTER_FLAGS_NONE`* | | | +| 0x01 |*`CU_GRAPHICS_REGISTER_FLAGS_READ_ONLY`* | | | +| 0x02 |*`CU_GRAPHICS_REGISTER_FLAGS_WRITE_DISCARD`* | | | +| 0x04 |*`CU_GRAPHICS_REGISTER_FLAGS_SURFACE_LDST`* | | | +| 0x08 |*`CU_GRAPHICS_REGISTER_FLAGS_TEXTURE_GATHER`* | | | +| enum |***`CUipcMem_flags`*** | | CUDA Ipc Mem Flags | +| 0x1 |*`CU_IPC_MEM_LAZY_ENABLE_PEER_ACCESS`* |*`hipIpcMemLazyEnablePeerAccess`* | Automatically enable peer access between remote devices as needed | +| enum |***`CUjit_cacheMode`*** | | Caching modes for dlcm | +| 0 |*`CU_JIT_CACHE_OPTION_NONE`* | | Compile with no -dlcm flag specified | +| |*`CU_JIT_CACHE_OPTION_CG`* | | Compile with L1 cache disabled | +| |*`CU_JIT_CACHE_OPTION_CA`* | | Compile with L1 cache enabled | +| enum |***`CUjit_fallback`*** | | Cubin matching fallback strategies | +| 0 |*`CU_PREFER_PTX`* | | Prefer to compile ptx if exact binary match not found | +| |*`CU_PREFER_BINARY`* | | Prefer to fall back to compatible binary code if exact match not found | +| enum |***`CUjit_option`*** | | Online compiler and linker options | +| 0 |*`CU_JIT_MAX_REGISTERS`* | | Max number of registers that a thread may use. Option type: unsigned int Applies to: compiler only. | +| |*`CU_JIT_THREADS_PER_BLOCK`* | | IN: Specifies minimum number of threads per block to target compilation for OUT: Returns the number of threads the compiler actually targeted. This restricts the resource utilization fo the compiler (e.g. max registers) such that a block with the given number of threads should be able to launch based on register limitations. Note, this option does not currently take into account any other resource limitations, such as shared memory utilization. Cannot be combined with CU_JIT_TARGET. Option type: unsigned int Applies to: compiler only. | +| |*`CU_JIT_WALL_TIME`* | | Overwrites the option value with the total wall clock time, in milliseconds, spent in the compiler and linker Option type: float Applies to: compiler and linker. | +| |*`CU_JIT_INFO_LOG_BUFFER`* | | Pointer to a buffer in which to print any log messages that are informational in nature (the buffer size is specified via option CU_JIT_INFO_LOG_BUFFER_SIZE_BYTES) Option type: char * Applies to: compiler and linker. | +| |*`CU_JIT_INFO_LOG_BUFFER_SIZE_BYTES`* | | IN: Log buffer size in bytes. Log messages will be capped at this size (including null terminator) OUT: Amount of log buffer filled with messages Option type: unsigned int Applies to: compiler and linker. | +| |*`CU_JIT_OPTIMIZATION_LEVEL`* | | Level of optimizations to apply to generated code (0 - 4), with 4 being the default and highest level of optimizations. Option type: unsigned int Applies to: compiler only. | +| |*`CU_JIT_TARGET_FROM_CUCONTEXT`* | | No option value required. Determines the target based on the current attached context (default) Option type: No option value needed Applies to: compiler and linker. | +| |*`CU_JIT_TARGET`* | | Target is chosen based on supplied CUjit_target. Cannot be combined with CU_JIT_THREADS_PER_BLOCK. Option type: unsigned int for enumerated type CUjit_target Applies to: compiler and linker. | +| |*`CU_JIT_FALLBACK_STRATEGY`* | | Specifies choice of fallback strategy if matching cubin is not found. Choice is based on supplied CUjit_fallback. This option cannot be used with cuLink* APIs as the linker requires exact matches. Option type: unsigned int for enumerated type CUjit_fallback Applies to: compiler only. | +| |*`CU_JIT_GENERATE_DEBUG_INFO`* | | Specifies whether to create debug information in output (-g) (0: false, default) Option type: int Applies to: compiler and linker. | +| |*`CU_JIT_LOG_VERBOSE`* | | Generate verbose log messages (0: false, default) Option type: int Applies to: compiler and linker. | +| |*`CU_JIT_GENERATE_LINE_INFO`* | | Generate line number information (-lineinfo) (0: false, default) Option type: int Applies to: compiler only. | +| |*`CU_JIT_CACHE_MODE`* | | Specifies whether to enable caching explicitly (-dlcm) Choice is based on supplied CUjit_cacheMode_enum. Option type: unsigned int for enumerated type CUjit_cacheMode_enum Applies to: compiler only. | +| |*`CU_JIT_NUM_OPTIONS`* | | | +| enum |***`CUjit_target`*** | | Online compilation targets | +| 10 |*`CU_TARGET_COMPUTE_10`* | | Compute device class 1.0. | +| 11 |*`CU_TARGET_COMPUTE_11`* | | Compute device class 1.1. | +| 12 |*`CU_TARGET_COMPUTE_12`* | | Compute device class 1.2. | +| 13 |*`CU_TARGET_COMPUTE_13`* | | Compute device class 1.3. | +| 20 |*`CU_TARGET_COMPUTE_20`* | | Compute device class 2.0. | +| 21 |*`CU_TARGET_COMPUTE_21`* | | Compute device class 2.1. | +| 30 |*`CU_TARGET_COMPUTE_30`* | | Compute device class 3.0. | +| 32 |*`CU_TARGET_COMPUTE_32`* | | Compute device class 3.2. | +| 35 |*`CU_TARGET_COMPUTE_35`* | | Compute device class 3.5. | +| 37 |*`CU_TARGET_COMPUTE_37`* | | Compute device class 3.7. | +| 50 |*`CU_TARGET_COMPUTE_50`* | | Compute device class 5.0. | +| 52 |*`CU_TARGET_COMPUTE_52`* | | Compute device class 5.2. | +| enum |***`CUjitInputType`*** | | Device code formats | +| 0 |*`CU_JIT_INPUT_CUBIN`* | | Compiled device-class-specific device code Applicable options: none. | +| |*`CU_JIT_INPUT_PTX`* | | PTX source code Applicable options: PTX compiler options. | +| |*`CU_JIT_INPUT_FATBINARY`* | | Bundle of multiple cubins and/or PTX of some device code Applicable options: PTX compiler options, CU_JIT_FALLBACK_STRATEGY. | +| |*`CU_JIT_INPUT_OBJECT`* | | Host object with embedded device code Applicable options: PTX compiler options, CU_JIT_FALLBACK_STRATEGY. | +| |*`CU_JIT_INPUT_LIBRARY`* | | Archive of host objects with embedded device code Applicable options: PTX compiler options, CU_JIT_FALLBACK_STRATEGY. | +| |*`CU_JIT_NUM_INPUT_TYPES`* | | | +| enum |***`CUlimit`*** |***`hipLimit_t`*** | Limits | +| 0x00 |*`CU_LIMIT_STACK_SIZE`* | | GPU thread stack size. | +| 0x01 |*`CU_LIMIT_PRINTF_FIFO_SIZE`* | | GPU printf FIFO size. | +| 0x02 |*`CU_LIMIT_MALLOC_HEAP_SIZE`* |*`hipLimitMallocHeapSize`* | GPU malloc heap size. | +| 0x03 |*`CU_LIMIT_DEV_RUNTIME_SYNC_DEPTH`* | | GPU device runtime launch synchronize depth. | +| 0x04 |*`CU_LIMIT_DEV_RUNTIME_PENDING_LAUNCH_COUNT`* | | GPU device runtime pending launch count. | +| |*`CU_LIMIT_MAX`* | | | +| enum |***`CUmemAttach_flags`*** | | CUDA Mem Attach Flags | +| 0x1 |*`CU_MEM_ATTACH_GLOBAL`* | | Memory can be accessed by any stream on any device. | +| 0x2 |*`CU_MEM_ATTACH_HOST`* | | Memory cannot be accessed by any stream on any device. | +| 0x4 |*`CU_MEM_ATTACH_SINGLE`* | | Memory can only be accessed by a single stream on the associated device. | +| enum |***`CUmemorytype`*** | | Memory types | +| 0x01 |*`CU_MEMORYTYPE_HOST`* | | Host memory | +| 0x02 |*`CU_MEMORYTYPE_DEVICE`* | | Device memory | +| 0x03 |*`CU_MEMORYTYPE_ARRAY`* | | Array memory | +| 0x04 |*`CU_MEMORYTYPE_UNIFIED`* | | Unified device or host memory | +| enum |***`CUoccupancy_flags`*** | | Occupancy calculator flag | +| 0x00 |*`CU_OCCUPANCY_DEFAULT`* | | Default behavior | +| 0x01 |*`CU_OCCUPANCY_DISABLE_CACHING_OVERRIDE`* | | Assume global caching is enabled and cannot be automatically turned off | +| enum |***`CUpointer_attribute`*** | | Pointer information | +| 1 |*`CU_POINTER_ATTRIBUTE_CONTEXT`* | | The CUcontext on which a pointer was allocated or registered | +| 2 |*`CU_POINTER_ATTRIBUTE_MEMORY_TYPE`* | | The CUmemorytype describing the physical location of a pointer | +| 3 |*`CU_POINTER_ATTRIBUTE_DEVICE_POINTER`* | | The address at which a pointer's memory may be accessed on the device | +| 4 |*`CU_POINTER_ATTRIBUTE_HOST_POINTER`* | | The address at which a pointer's memory may be accessed on the host | +| 5 |*`CU_POINTER_ATTRIBUTE_P2P_TOKENS`* | | A pair of tokens for use with the nv-p2p.h Linux kernel interface | +| 6 |*`CU_POINTER_ATTRIBUTE_SYNC_MEMOPS`* | | Synchronize every synchronous memory operation initiated on this region | +| 7 |*`CU_POINTER_ATTRIBUTE_BUFFER_ID`* | | A process-wide unique ID for an allocated memory region | +| 8 |*`CU_POINTER_ATTRIBUTE_IS_MANAGED`* | | Indicates if the pointer points to managed memory | +| enum |***`CUmemorytype`*** | | Resource types | +| 0x00 |*`CU_RESOURCE_TYPE_ARRAY`* | | Array resoure | +| 0x01 |*`CU_RESOURCE_TYPE_MIPMAPPED_ARRAY`* | | Mipmapped array resource | +| 0x02 |*`CU_RESOURCE_TYPE_LINEAR`* | | Linear resource | +| 0x03 |*`CU_RESOURCE_TYPE_PITCH2D`* | | Pitch 2D resource | +| enum |***`CUresourceViewFormat`*** | | Resource view format | +| 0x00 |*`CU_RES_VIEW_FORMAT_NONE`* | | No resource view format (use underlying resource format) | +| 0x01 |*`CU_RES_VIEW_FORMAT_UINT_1X8`* | | 1 channel unsigned 8-bit integers | +| 0x02 |*`CU_RES_VIEW_FORMAT_UINT_2X8`* | | 2 channel unsigned 8-bit integers | +| 0x03 |*`CU_RES_VIEW_FORMAT_UINT_4X8`* | | 4 channel unsigned 8-bit integers | +| 0x04 |*`CU_RES_VIEW_FORMAT_SINT_1X8`* | | 1 channel signed 8-bit integers | +| 0x05 |*`CU_RES_VIEW_FORMAT_SINT_2X8`* | | 2 channel signed 8-bit integers | +| 0x06 |*`CU_RES_VIEW_FORMAT_SINT_4X8`* | | 4 channel signed 8-bit integers | +| 0x07 |*`CU_RES_VIEW_FORMAT_UINT_1X16`* | | 1 channel unsigned 16-bit integers | +| 0x08 |*`CU_RES_VIEW_FORMAT_UINT_2X16`* | | 2 channel unsigned 16-bit integers | +| 0x09 |*`CU_RES_VIEW_FORMAT_UINT_4X16`* | | 4 channel unsigned 16-bit integers | +| 0x0a |*`CU_RES_VIEW_FORMAT_SINT_1X16`* | | 1 channel signed 16-bit integers | +| 0x0b |*`CU_RES_VIEW_FORMAT_SINT_2X16`* | | 2 channel signed 16-bit integers | +| 0x0c |*`CU_RES_VIEW_FORMAT_SINT_4X16`* | | 4 channel signed 16-bit integers | +| 0x0d |*`CU_RES_VIEW_FORMAT_UINT_1X32`* | | 1 channel unsigned 32-bit integers | +| 0x0e |*`CU_RES_VIEW_FORMAT_UINT_2X32`* | | 2 channel unsigned 32-bit integers | +| 0x0f |*`CU_RES_VIEW_FORMAT_UINT_4X32`* | | 4 channel unsigned 32-bit integers | +| 0x10 |*`CU_RES_VIEW_FORMAT_SINT_1X32`* | | 1 channel signed 32-bit integers | +| 0x11 |*`CU_RES_VIEW_FORMAT_SINT_2X32`* | | 2 channel signed 32-bit integers | +| 0x12 |*`CU_RES_VIEW_FORMAT_SINT_4X32`* | | 4 channel signed 32-bit integers | +| 0x13 |*`CU_RES_VIEW_FORMAT_FLOAT_1X16`* | | 1 channel 16-bit floating point | +| 0x14 |*`CU_RES_VIEW_FORMAT_FLOAT_2X16`* | | 2 channel 16-bit floating point | +| 0x15 |*`CU_RES_VIEW_FORMAT_FLOAT_4X16`* | | 4 channel 16-bit floating point | +| 0x16 |*`CU_RES_VIEW_FORMAT_FLOAT_1X32`* | | 1 channel 32-bit floating point | +| 0x17 |*`CU_RES_VIEW_FORMAT_FLOAT_2X32`* | | 2 channel 32-bit floating point | +| 0x18 |*`CU_RES_VIEW_FORMAT_FLOAT_4X32`* | | 4 channel 32-bit floating point | +| 0x19 |*`CU_RES_VIEW_FORMAT_UNSIGNED_BC1`* | | Block compressed 1 | +| 0x1a |*`CU_RES_VIEW_FORMAT_UNSIGNED_BC3`* | | Block compressed 2 | +| 0x1b |*`CU_RES_VIEW_FORMAT_UNSIGNED_BC3`* | | Block compressed 3 | +| 0x1c |*`CU_RES_VIEW_FORMAT_UNSIGNED_BC4`* | | Block compressed 4 unsigned | +| 0x1d |*`CU_RES_VIEW_FORMAT_SIGNED_BC4`* | | Block compressed 4 signed | +| 0x1e |*`CU_RES_VIEW_FORMAT_UNSIGNED_BC5`* | | Block compressed 5 unsigned | +| 0x1f |*`CU_RES_VIEW_FORMAT_SIGNED_BC5`* | | Block compressed 5 signed | +| 0x20 |*`CU_RES_VIEW_FORMAT_UNSIGNED_BC6H`* | | Block compressed 6 unsigned half-float | +| 0x21 |*`CU_RES_VIEW_FORMAT_SIGNED_BC6H`* | | Block compressed 6 signed half-float | +| 0x22 |*`CU_RES_VIEW_FORMAT_UNSIGNED_BC7`* | | Block compressed 7 | +| enum |***`CUresult`*** |***`hipError_t`*** | Error codes | +| 0 |*`CUDA_SUCCESS`* |*`hipSuccess`* | The API call returned with no errors. In the case of query calls, this can also mean that the operation being queried is complete (see cuEventQuery() and cuStreamQuery()). | +| 1 |*`CUDA_ERROR_INVALID_VALUE`* |*`hipErrorInvalidValue`* | This indicates that one or more of the parameters passed to the API call is not within an acceptable range of values. | +| 2 |*`CUDA_ERROR_OUT_OF_MEMORY`* |*`hipErrorMemoryAllocation`* | The API call failed because it was unable to allocate enough memory to perform the requested operation. | +| 3 |*`CUDA_ERROR_NOT_INITIALIZED`* |*`hipErrorNotInitialized`* | This indicates that the CUDA driver has not been initialized with cuInit() or that initialization has failed. | +| 4 |*`CUDA_ERROR_DEINITIALIZED`* |*`hipErrorDeinitialized`* | This indicates that the CUDA driver is in the process of shutting down. | +| 5 |*`CUDA_ERROR_PROFILER_DISABLED`* |*`hipErrorProfilerDisabled`* | This indicates profiler is not initialized for this run. This can happen when the application is running with external profiling tools like visual profiler. | +| 6 |*`CUDA_ERROR_PROFILER_NOT_INITIALIZED`* |*`hipErrorProfilerNotInitialized`* | Deprecated This error return is deprecated as of CUDA 5.0. It is no longer an error to attempt to enable/disable the profiling via cuProfilerStart or cuProfilerStop without initialization. | +| 7 |*`CUDA_ERROR_PROFILER_ALREADY_STARTED`* |*`hipErrorProfilerAlreadyStarted`* | Deprecated This error return is deprecated as of CUDA 5.0. It is no longer an error to call cuProfilerStart() when profiling is already enabled. | +| 8 |*`CUDA_ERROR_PROFILER_ALREADY_STOPPED`* |*`hipErrorProfilerAlreadyStopped`* | Deprecated This error return is deprecated as of CUDA 5.0. It is no longer an error to call cuProfilerStop() when profiling is already disabled. | +| 100 |*`CUDA_ERROR_NO_DEVICE`* |*`hipErrorNoDevice`* | This indicates that no CUDA-capable devices were detected by the installed CUDA driver. | +| 101 |*`CUDA_ERROR_INVALID_DEVICE`* |*`hipErrorInvalidDevice`* | This indicates that the device ordinal supplied by the user does not correspond to a valid CUDA device. | +| 200 |*`CUDA_ERROR_INVALID_IMAGE`* |*`hipErrorInvalidImage`* | This indicates that the device kernel image is invalid. This can also indicate an invalid CUDA module. | +| 201 |*`CUDA_ERROR_INVALID_CONTEXT`* |*`hipErrorInvalidContext`* | This most frequently indicates that there is no context bound to the current thread. This can also be returned if the context passed to an API call is not a valid handle (such as a context that has had cuCtxDestroy() invoked on it). This can also be returned if a user mixes different API versions (i.e. 3010 context with 3020 API calls). See cuCtxGetApiVersion() for more details. | +| 202 |*`CUDA_ERROR_CONTEXT_ALREADY_CURRENT`* |*`hipErrorContextAlreadyCurrent`* | This indicated that the context being supplied as a parameter to the API call was already the active context. Deprecated This error return is deprecated as of CUDA 3.2. It is no longer an error to attempt to push the active context via cuCtxPushCurrent(). | +| 205 |*`CUDA_ERROR_MAP_FAILED`* |*`hipErrorMapFailed`* | This indicates that a map or register operation has failed. | +| 206 |*`CUDA_ERROR_UNMAP_FAILED`* |*`hipErrorUnmapFailed`* | This indicates that an unmap or unregister operation has failed. | +| 207 |*`CUDA_ERROR_ARRAY_IS_MAPPED`* |*`hipErrorArrayIsMapped`* | This indicates that the specified array is currently mapped and thus cannot be destroyed. | +| 208 |*`CUDA_ERROR_ALREADY_MAPPED`* |*`hipErrorAlreadyMapped`* | This indicates that the resource is already mapped. | +| 209 |*`CUDA_ERROR_NO_BINARY_FOR_GPU`* |*`hipErrorNoBinaryForGpu* | This indicates that there is no kernel image available that is suitable for the device. This can occur when a user specifies code generation options for a particular CUDA source file that do not include the corresponding device configuration. | +| 210 |*`CUDA_ERROR_ALREADY_ACQUIRED`* |*`hipErrorAlreadyAcquired* | This indicates that a resource has already been acquired. | +| 211 |*`CUDA_ERROR_NOT_MAPPED`* |*`hipErrorNotMapped`* | This indicates that a resource is not mapped. | +| 212 |*`CUDA_ERROR_NOT_MAPPED_AS_ARRAY`* |*`hipErrorNotMappedAsArray`* | This indicates that a mapped resource is not available for access as an array. | +| 213 |*`CUDA_ERROR_NOT_MAPPED_AS_POINTER`* |*`hipErrorNotMappedAsPointer`* | This indicates that a mapped resource is not available for access as a pointer. | +| 214 |*`CUDA_ERROR_ECC_UNCORRECTABLE`* |*`hipErrorECCNotCorrectable`* | This indicates that an uncorrectable ECC error was detected during execution. | +| 215 |*`CUDA_ERROR_UNSUPPORTED_LIMIT`* |*`hipErrorUnsupportedLimit`* | This indicates that the CUlimit passed to the API call is not supported by the active device. | +| 216 |*`CUDA_ERROR_CONTEXT_ALREADY_IN_USE`* |*`hipErrorContextAlreadyInUse`* | This indicates that the CUcontext passed to the API call can only be bound to a single CPU thread at a time but is already bound to a CPU thread. | +| 217 |*`CUDA_ERROR_PEER_ACCESS_UNSUPPORTED`* |*`hipErrorPeerAccessUnsupported`* | This indicates that peer access is not supported across the given devices. | +| 218 |*`CUDA_ERROR_INVALID_PTX`* |*`hipErrorInvalidKernelFile`* | This indicates that a PTX JIT compilation failed. | +| 219 |*`CUDA_ERROR_INVALID_GRAPHICS_CONTEXT`* |*`hipErrorInvalidGraphicsContext`* | This indicates an error with OpenGL or DirectX context. | +| 300 |*`CUDA_ERROR_INVALID_SOURCE`* |*`hipErrorInvalidSource`* | This indicates that the device kernel source is invalid. | +| 301 |*`CUDA_ERROR_FILE_NOT_FOUND`* |*`hipErrorFileNotFound`* | This indicates that the file specified was not found. | +| 302 |*`CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND`* |*`hipErrorSharedObjectSymbolNotFound`* | This indicates that a link to a shared object failed to resolve. | +| 303 |*`CUDA_ERROR_SHARED_OBJECT_INIT_FAILED`* |*`hipErrorSharedObjectInitFailed`* | This indicates that initialization of a shared object failed. | +| 304 |*`CUDA_ERROR_OPERATING_SYSTEM`* |*`hipErrorOperatingSystem`* | This indicates that an OS call failed. | +| 400 |*`CUDA_ERROR_INVALID_HANDLE`* |*`hipErrorInvalidResourceHandle`* | This indicates that a resource handle passed to the API call was not valid. Resource handles are opaque types like CUstream and CUevent. | +| 500 |*`CUDA_ERROR_NOT_FOUND`* |*`hipErrorNotFound`* | This indicates that a named symbol was not found. Examples of symbols are global/constant variable names, texture names, and surface names. | +| 600 |*`CUDA_ERROR_NOT_READY`* |*`hipErrorNotReady`* | This indicates that asynchronous operations issued previously have not completed yet. This result is not actually an error, but must be indicated differently than CUDA_SUCCESS (which indicates completion). Calls that may return this value include cuEventQuery() and cuStreamQuery(). | +| 700 |*`CUDA_ERROR_ILLEGAL_ADDRESS`* |*`hipErrorIllegalAddress`* | While executing a kernel, the device encountered a load or store instruction on an invalid memory address. The context cannot be used, so it must be destroyed (and a new one should be created). All existing device memory allocations from this context are invalid and must be reconstructed if the program is to continue using CUDA. | + + +## **2. Error Handling** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **3. Initialization** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **4. Version Management** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **5. Device Management** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + +## **6. Device Management [DEPRECATED]** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **7. Primary Context Management** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **8. Context Management** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **9. Context Management [DEPRECATED]** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **10. Module Management** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **11. Memory Management** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **12. Unified Addressing** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **13. Stream Management** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **14. Event Management** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **15. Execution Control** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **16. Execution Control [DEPRECATED]** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **17. Occupancy** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **18. Texture Reference Management** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **19. Texture Reference Management [DEPRECATED]** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **20. Surface Reference Management** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **21. Texture Object Management** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **22. Surface Object Management** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **23. Peer Context Memory Access** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **24. Graphics Interoperability** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **25. Profiler Control** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **26. OpenGL Interoperability** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **27. Direct3D 9 Interoperability** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **28. Direct3D 10 Interoperability** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **29. Direct3D 11 Interoperability** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + + +## **30. VDPAU Interoperability** + +| **CUDA** | **HIP** | **CUDA description** | +|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------| + diff --git a/projects/hip/docs/markdown/hip_bugs.md b/projects/hip/docs/markdown/hip_bugs.md index 9452fae2fd..abb31d80e8 100644 --- a/projects/hip/docs/markdown/hip_bugs.md +++ b/projects/hip/docs/markdown/hip_bugs.md @@ -11,7 +11,13 @@ ### Errors related to undefined reference to `__hcLaunchKernel__***__grid_launch_parm**` Some common code practices may lead to hipcc generating a error with the form : +``` undefined reference to `__hcLaunchKernel__ZN15vecAddNamespace6vecAddIidEEv16grid_launch_parmPT0_S3_S3_T_ +``` +Or: +``` +error: weak declaration cannot have internal linkage +``` Suggested workarounds: - Avoid use of static with kernel definition: @@ -26,6 +32,19 @@ namespace { } ``` +### Can't find kernels inside dynamic linked library + +HCC requires use of the "-Bdynamic" flag when creating a dynamic library which contains kernels. The dynamic flag causes the symbols to be created with a signature which allows HCC to discover and load the kernels in the dynamic library. This flag is often not set by default and must be added to the link step of the library. If not done, HCC will be unable to find the kernels defined in the library, and will emit a message such as: + +``` +HSADevice::CreateKernel(): Unable to create kernel" +``` + +To correct, add the following flag to hcc or hipcc: +``` +$ hipcc -Wl,-Bsymbolic ... +``` + ### What is the current limitation of HIP Generic Grid Launch method? 1. __global__ functions cannot be marked as static or put in an unnamed namespace i.e. they cannot be given internal linkage (this would clash with __attribute__((weak))); diff --git a/projects/hip/hipify-clang/README.md b/projects/hip/hipify-clang/README.md index 850dfb3ffa..c0d74dbe48 100644 --- a/projects/hip/hipify-clang/README.md +++ b/projects/hip/hipify-clang/README.md @@ -13,24 +13,31 @@ `hipify-clang` is a clang-based tool which can automate the translation of CUDA source code into portable HIP C++. The tool can automatically add extra HIP arguments (notably the "hipLaunchParm" required at the beginning of every HIP kernel call). -`hipify-clang` has some additional dependencies explained below and can be built as a separate make step. The instructions below are specifically for **Ubuntu 14.04** +`hipify-clang` has some additional dependencies explained below and can be built as a separate make step. The instructions below are specifically for **Ubuntu 14.04** and **Ubuntu 16.04**. ### Build and install - Download and unpack clang+llvm 3.8 binary package preqrequisite. + +**Ubuntu 14.04**: ```shell wget http://llvm.org/releases/3.8.0/clang+llvm-3.8.0-x86_64-linux-gnu-ubuntu-14.04.tar.xz tar xvfJ clang+llvm-3.8.0-x86_64-linux-gnu-ubuntu-14.04.tar.xz ``` +**Ubuntu 16.04**: +```shell +wget http://llvm.org/releases/3.8.0/clang+llvm-3.8.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz +tar xvfJ clang+llvm-3.8.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz +``` - Enable build of hipify-clang and specify path to LLVM. -Note HIPIFY_CLANG_LLVM_DIR must be a full absolute path to the location extracted above. Here's an example assuming we extract the clang 3.8 package into ~/HIP/clang+llvm-3.8.0-x86_64-linux-gnu-ubuntu-14.04/ +Note HIPIFY_CLANG_LLVM_DIR must be a full absolute path to the location extracted above. Here's an example assuming we extract the clang 3.8 package into ~/HIP/clang+llvm-3.8.0/ ```shell cd HIP mkdir build cd build -cmake -DHIPIFY_CLANG_LLVM_DIR=~/HIP/clang+llvm-3.8.0-x86_64-linux-gnu-ubuntu-14.04/ -DCMAKE_BUILD_TYPE=Release .. +cmake -DHIPIFY_CLANG_LLVM_DIR=~/HIP/clang+llvm-3.8.0/ -DCMAKE_BUILD_TYPE=Release .. make make install ``` @@ -41,13 +48,20 @@ make install In the case when `hipify-clang` doesn't find cuda headers, it reports various errors about unknown keywords (e.g. '\__global\__'), API function names (e.g. 'cudaMalloc'), syntax (e.g. 'foo<<<1,n>>>(...)'), etc. -To install CUDA headers, download the "deb(network)" variant of the target installer from https://developer.nvidia.com/cuda-downloads. The commands below show how to download and install a recent version from http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1404/x86_64/cuda-repo-ubuntu1404_7.5-18_amd64.deb. +To install CUDA headers, download the "deb(network)" variant of the target installer. + +**Ubuntu 14.04**: ```shell wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1404/x86_64/cuda-repo-ubuntu1404_7.5-18_amd64.deb sudo dpkg -i cuda-repo-ubuntu1404_7.5-18_amd64.deb sudo apt-get update && sudo apt-get install cuda-minimal-build-7-5 cuda-curand-dev-7-5 ``` - +**Ubuntu 16.04**: +```shell +wget http://archive.ubuntu.com/ubuntu/pool/multiverse/n/nvidia-cuda-toolkit/nvidia-cuda-toolkit_7.5.18-0ubuntu1_amd64.deb +sudo dpkg -i nvidia-cuda-toolkit_7.5.18-0ubuntu1_amd64.deb +sudo apt-get update && sudo apt-get install cuda-minimal-build-7-5 cuda-curand-dev-7-5 +``` To set additional options like Language Selection (only "-x cuda" is supported), Preprocessor Definition (-D), Include Path (-I), etc., options delimiter "--" should be used before them, for instance: ```shell @@ -58,10 +72,11 @@ Delimiter "--" is used to separate hipify-clang options (before the delimiter) f Option "-x clang" is also worth specifying in order to convert source CUDA files with extensions other than standard extensions (*.cu, *.cuh). -#### Disclaimer +## Disclaimer The information contained herein is for informational purposes only, and is subject to change without notice. While every precaution has been taken in the preparation of this document, it may contain technical inaccuracies, omissions and typographical errors, and AMD is under no obligation to update or otherwise correct this information. Advanced Micro Devices, Inc. makes no representations or warranties with respect to the accuracy or completeness of the contents of this document, and assumes no liability of any kind, including the implied warranties of noninfringement, merchantability or fitness for particular purposes, with respect to the operation or use of AMD hardware, software or other products described herein. No license, including implied or arising by estoppel, to any intellectual property rights is granted by this document. Terms and limitations applicable to the purchase or use of AMD's products are as set forth in a signed agreement between the parties or in AMD's Standard Terms and Conditions of Sale. AMD, the AMD Arrow logo, and combinations thereof are trademarks of Advanced Micro Devices, Inc. Other product names used in this publication are for identification purposes only and may be trademarks of their respective companies. -Copyright (c) 2014-2016 Advanced Micro Devices, Inc. All rights reserved. +Copyright (c) 2014-2017 Advanced Micro Devices, Inc. All rights reserved. + diff --git a/projects/hip/hipify-clang/src/Cuda2Hip.cpp b/projects/hip/hipify-clang/src/Cuda2Hip.cpp index 383af0440c..5a2940322e 100644 --- a/projects/hip/hipify-clang/src/Cuda2Hip.cpp +++ b/projects/hip/hipify-clang/src/Cuda2Hip.cpp @@ -81,6 +81,7 @@ enum ConvTypes { CONV_GL, CONV_GRAPHICS, CONV_SURFACE, + CONV_JIT, CONV_OTHER, CONV_INCLUDE, CONV_INCLUDE_CUDA_MAIN_H, @@ -94,7 +95,7 @@ const char *counterNames[CONV_LAST] = { "driver", "dev", "mem", "kern", "coord_func", "math_func", "special_func", "stream", "event", "occupancy", "ctx", "module", "cache", "exec", "err", "def", "tex", "gl", - "graphics", "surface", "other", "include", "include_cuda_main_header", + "graphics", "surface", "jit", "other", "include", "include_cuda_main_header", "type", "literal", "numeric_literal"}; enum ApiTypes { @@ -190,24 +191,23 @@ struct cuda2hipMap { // Error codes and return types cuda2hipRename["CUresult"] = {"hipError_t", CONV_TYPE, API_DRIVER}; + cuda2hipRename["cudaError_enum"] = {"hipError_t", CONV_TYPE, API_DRIVER}; cuda2hipRename["cudaError_t"] = {"hipError_t", CONV_TYPE, API_RUNTIME}; cuda2hipRename["cudaError"] = {"hipError_t", CONV_TYPE, API_RUNTIME}; - // CUDA Driver API error code only - cuda2hipRename["CUDA_ERROR_INVALID_CONTEXT"] = {"hipErrorInvalidContext", CONV_ERR, API_DRIVER}; - cuda2hipRename["CUDA_ERROR_CONTEXT_ALREADY_CURRENT"] = {"hipErrorContextAlreadyCurrent", CONV_ERR, API_DRIVER}; - cuda2hipRename["CUDA_ERROR_MAP_FAILED"] = {"hipErrorMapFailed", CONV_ERR, API_DRIVER}; - cuda2hipRename["CUDA_ERROR_UNMAP_FAILED"] = {"hipErrorUnmapFailed", CONV_ERR, API_DRIVER}; - cuda2hipRename["CUDA_ERROR_ARRAY_IS_MAPPED"] = {"hipErrorArrayIsMapped", CONV_ERR, API_DRIVER}; - cuda2hipRename["CUDA_ERROR_ALREADY_MAPPED"] = {"hipErrorAlreadyMapped", CONV_ERR, API_DRIVER}; - cuda2hipRename["CUDA_ERROR_ALREADY_ACQUIRED"] = {"hipErrorAlreadyAcquired", CONV_ERR, API_DRIVER}; - cuda2hipRename["CUDA_ERROR_NOT_MAPPED"] = {"hipErrorNotMapped", CONV_ERR, API_DRIVER}; - cuda2hipRename["CUDA_ERROR_NOT_MAPPED_AS_ARRAY"] = {"hipErrorNotMappedAsArray", CONV_ERR, API_DRIVER}; - cuda2hipRename["CUDA_ERROR_NOT_MAPPED_AS_POINTER"] = {"hipErrorNotMappedAsPointer", CONV_ERR, API_DRIVER}; - cuda2hipRename["CUDA_ERROR_CONTEXT_ALREADY_IN_USE"] = {"hipErrorContextAlreadyInUse", CONV_ERR, API_DRIVER}; - cuda2hipRename["CUDA_ERROR_INVALID_SOURCE"] = {"hipErrorInvalidSource", CONV_ERR, API_DRIVER}; - cuda2hipRename["CUDA_ERROR_FILE_NOT_FOUND"] = {"hipErrorFileNotFound", CONV_ERR, API_DRIVER}; - cuda2hipRename["CUDA_ERROR_NOT_FOUND"] = {"hipErrorNotFound", CONV_ERR, API_DRIVER}; + // CUDA Driver API error codes only + cuda2hipRename["CUDA_ERROR_INVALID_CONTEXT"] = {"hipErrorInvalidContext", CONV_ERR, API_DRIVER}; // 201 + cuda2hipRename["CUDA_ERROR_CONTEXT_ALREADY_CURRENT"] = {"hipErrorContextAlreadyCurrent", CONV_ERR, API_DRIVER}; // 202 + cuda2hipRename["CUDA_ERROR_ARRAY_IS_MAPPED"] = {"hipErrorArrayIsMapped", CONV_ERR, API_DRIVER}; // 207 + cuda2hipRename["CUDA_ERROR_ALREADY_MAPPED"] = {"hipErrorAlreadyMapped", CONV_ERR, API_DRIVER}; // 208 + cuda2hipRename["CUDA_ERROR_ALREADY_ACQUIRED"] = {"hipErrorAlreadyAcquired", CONV_ERR, API_DRIVER}; // 210 + cuda2hipRename["CUDA_ERROR_NOT_MAPPED"] = {"hipErrorNotMapped", CONV_ERR, API_DRIVER}; // 211 + cuda2hipRename["CUDA_ERROR_NOT_MAPPED_AS_ARRAY"] = {"hipErrorNotMappedAsArray", CONV_ERR, API_DRIVER}; // 212 + cuda2hipRename["CUDA_ERROR_NOT_MAPPED_AS_POINTER"] = {"hipErrorNotMappedAsPointer", CONV_ERR, API_DRIVER}; // 213 + cuda2hipRename["CUDA_ERROR_CONTEXT_ALREADY_IN_USE"] = {"hipErrorContextAlreadyInUse", CONV_ERR, API_DRIVER}; // 216 + cuda2hipRename["CUDA_ERROR_INVALID_SOURCE"] = {"hipErrorInvalidSource", CONV_ERR, API_DRIVER}; // 300 + cuda2hipRename["CUDA_ERROR_FILE_NOT_FOUND"] = {"hipErrorFileNotFound", CONV_ERR, API_DRIVER}; // 301 + cuda2hipRename["CUDA_ERROR_NOT_FOUND"] = {"hipErrorNotFound", CONV_ERR, API_DRIVER}; // 500 // CUDA RT API error code only cuda2hipRename["cudaErrorMissingConfiguration"] = {"hipErrorMissingConfiguration", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 1 @@ -216,8 +216,6 @@ struct cuda2hipMap { cuda2hipRename["cudaErrorInvalidConfiguration"] = {"hipErrorInvalidConfiguration", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 9 cuda2hipRename["cudaErrorInvalidPitchValue"] = {"hipErrorInvalidPitchValue", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 12 cuda2hipRename["cudaErrorInvalidSymbol"] = {"hipErrorInvalidSymbol", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 13 - cuda2hipRename["cudaErrorMapBufferObjectFailed"] = {"hipErrorMapBufferObjectFailed", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 14 - cuda2hipRename["cudaErrorUnmapBufferObjectFailed"] = {"hipErrorUnmapBufferObjectFailed", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 15 cuda2hipRename["cudaErrorInvalidHostPointer"] = {"hipErrorInvalidHostPointer", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 16 cuda2hipRename["cudaErrorInvalidDevicePointer"] = {"hipErrorInvalidDevicePointer", CONV_ERR, API_RUNTIME}; // 17 cuda2hipRename["cudaErrorInvalidTexture"] = {"hipErrorInvalidTexture", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 18 @@ -262,17 +260,96 @@ struct cuda2hipMap { // Deprecated as of CUDA 4.1 cuda2hipRename["cudaErrorApiFailureBase"] = {"hipErrorApiFailureBase", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 10000 - cuda2hipRename["CUDA_SUCCESS"] = {"hipSuccess", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaSuccess"] = {"hipSuccess", CONV_ERR, API_RUNTIME}; // 0 - cuda2hipRename["CUDA_ERROR_OUT_OF_MEMORY"] = {"hipErrorMemoryAllocation", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorMemoryAllocation"] = {"hipErrorMemoryAllocation", CONV_ERR, API_RUNTIME}; // 2 - cuda2hipRename["CUDA_ERROR_NOT_INITIALIZED"] = {"hipErrorNotInitialized", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorInitializationError"] = {"hipErrorInitializationError", CONV_ERR, API_RUNTIME}; // 3 + cuda2hipRename["CUDA_SUCCESS"] = {"hipSuccess", CONV_ERR, API_DRIVER}; // 0 + cuda2hipRename["cudaSuccess"] = {"hipSuccess", CONV_ERR, API_RUNTIME}; // 0 - cuda2hipRename["CUDA_ERROR_LAUNCH_FAILED"] = {"hipErrorLaunchFailure", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorLaunchFailure"] = {"hipErrorLaunchFailure", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 4 + cuda2hipRename["CUDA_ERROR_INVALID_VALUE"] = {"hipErrorInvalidValue", CONV_ERR, API_DRIVER}; // 1 + cuda2hipRename["cudaErrorInvalidValue"] = {"hipErrorInvalidValue", CONV_ERR, API_RUNTIME}; // 11 + + cuda2hipRename["CUDA_ERROR_OUT_OF_MEMORY"] = {"hipErrorMemoryAllocation", CONV_ERR, API_DRIVER}; // 2 + cuda2hipRename["cudaErrorMemoryAllocation"] = {"hipErrorMemoryAllocation", CONV_ERR, API_RUNTIME}; // 2 + + cuda2hipRename["CUDA_ERROR_NOT_INITIALIZED"] = {"hipErrorNotInitialized", CONV_ERR, API_DRIVER}; // 3 + cuda2hipRename["cudaErrorInitializationError"] = {"hipErrorInitializationError", CONV_ERR, API_RUNTIME}; // 3 + + cuda2hipRename["CUDA_ERROR_DEINITIALIZED"] = {"hipErrorDeinitialized", CONV_ERR, API_DRIVER}; // 4 + // TODO: double check, that these errors match + cuda2hipRename["cudaErrorCudartUnloading"] = {"hipErrorDeinitialized", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 29 + + cuda2hipRename["CUDA_ERROR_PROFILER_DISABLED"] = {"hipErrorProfilerDisabled", CONV_ERR, API_DRIVER}; // 5 + cuda2hipRename["cudaErrorProfilerDisabled"] = {"hipErrorProfilerDisabled", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 55 + + cuda2hipRename["CUDA_ERROR_PROFILER_NOT_INITIALIZED"] = {"hipErrorProfilerNotInitialized", CONV_ERR, API_DRIVER}; // 6 + // Deprecated as of CUDA 5.0 + cuda2hipRename["cudaErrorProfilerNotInitialized"] = {"hipErrorProfilerNotInitialized", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 56 + + cuda2hipRename["CUDA_ERROR_PROFILER_ALREADY_STARTED"] = {"hipErrorProfilerAlreadyStarted", CONV_ERR, API_DRIVER}; // 7 + // Deprecated as of CUDA 5.0 + cuda2hipRename["cudaErrorProfilerAlreadyStarted"] = {"hipErrorProfilerAlreadyStarted", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 57 + + cuda2hipRename["CUDA_ERROR_PROFILER_ALREADY_STOPPED"] = {"hipErrorProfilerAlreadyStopped", CONV_ERR, API_DRIVER}; // 8 + // Deprecated as of CUDA 5.0 + cuda2hipRename["cudaErrorProfilerAlreadyStopped"] = {"hipErrorProfilerAlreadyStopped", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 58 + + cuda2hipRename["CUDA_ERROR_NO_DEVICE"] = {"hipErrorNoDevice", CONV_ERR, API_DRIVER}; // 100 + cuda2hipRename["cudaErrorNoDevice"] = {"hipErrorNoDevice", CONV_ERR, API_RUNTIME}; // 38 + + cuda2hipRename["CUDA_ERROR_INVALID_DEVICE"] = {"hipErrorInvalidDevice", CONV_ERR, API_DRIVER}; // 101 + cuda2hipRename["cudaErrorInvalidDevice"] = {"hipErrorInvalidDevice", CONV_ERR, API_RUNTIME}; // 10 + + cuda2hipRename["CUDA_ERROR_INVALID_IMAGE"] = {"hipErrorInvalidImage", CONV_ERR, API_DRIVER}; // 200 + cuda2hipRename["cudaErrorInvalidKernelImage"] = {"hipErrorInvalidImage", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 47 + + cuda2hipRename["CUDA_ERROR_MAP_FAILED"] = {"hipErrorMapFailed", CONV_ERR, API_DRIVER}; // 205 + // TODO: double check, that these errors match + cuda2hipRename["cudaErrorMapBufferObjectFailed"] = {"hipErrorMapFailed", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 14 + + cuda2hipRename["CUDA_ERROR_UNMAP_FAILED"] = {"hipErrorUnmapFailed", CONV_ERR, API_DRIVER}; // 206 + // TODO: double check, that these errors match + cuda2hipRename["cudaErrorUnmapBufferObjectFailed"] = {"hipErrorUnmapFailed", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 15 + + cuda2hipRename["CUDA_ERROR_NO_BINARY_FOR_GPU"] = {"hipErrorNoBinaryForGpu", CONV_ERR, API_DRIVER}; // 209 + cuda2hipRename["cudaErrorNoKernelImageForDevice"] = {"hipErrorNoBinaryForGpu", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 48 + + cuda2hipRename["CUDA_ERROR_ECC_UNCORRECTABLE"] = {"hipErrorECCNotCorrectable", CONV_ERR, API_DRIVER}; // 214 + cuda2hipRename["cudaErrorECCUncorrectable"] = {"hipErrorECCNotCorrectable", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 39 + + cuda2hipRename["CUDA_ERROR_UNSUPPORTED_LIMIT"] = {"hipErrorUnsupportedLimit", CONV_ERR, API_DRIVER}; // 215 + cuda2hipRename["cudaErrorUnsupportedLimit"] = {"hipErrorUnsupportedLimit", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 42 + + cuda2hipRename["CUDA_ERROR_PEER_ACCESS_UNSUPPORTED"] = {"hipErrorPeerAccessUnsupported", CONV_ERR, API_DRIVER}; // 217 + cuda2hipRename["cudaErrorPeerAccessUnsupported"] = {"hipErrorPeerAccessUnsupported", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 64 + + cuda2hipRename["CUDA_ERROR_INVALID_PTX"] = {"hipErrorInvalidKernelFile", CONV_ERR, API_DRIVER}; // 218 + cuda2hipRename["cudaErrorInvalidPtx"] = {"hipErrorInvalidKernelFile", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 78 + + cuda2hipRename["CUDA_ERROR_INVALID_GRAPHICS_CONTEXT"] = {"hipErrorInvalidGraphicsContext", CONV_ERR, API_DRIVER}; // 219 + cuda2hipRename["cudaErrorInvalidGraphicsContext"] = {"hipErrorInvalidGraphicsContext", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 79 + + cuda2hipRename["CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND"] = {"hipErrorSharedObjectSymbolNotFound", CONV_ERR, API_DRIVER}; // 302 + cuda2hipRename["cudaErrorSharedObjectSymbolNotFound"] = {"hipErrorSharedObjectSymbolNotFound", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 40 + + cuda2hipRename["CUDA_ERROR_SHARED_OBJECT_INIT_FAILED"] = {"hipErrorSharedObjectInitFailed", CONV_ERR, API_DRIVER}; // 303 + cuda2hipRename["cudaErrorSharedObjectInitFailed"] = {"hipErrorSharedObjectInitFailed", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 41 + + cuda2hipRename["CUDA_ERROR_OPERATING_SYSTEM"] = {"hipErrorOperatingSystem", CONV_ERR, API_DRIVER}; // 304 + cuda2hipRename["cudaErrorOperatingSystem"] = {"hipErrorOperatingSystem", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 63 + + cuda2hipRename["CUDA_ERROR_INVALID_HANDLE"] = {"hipErrorInvalidResourceHandle", CONV_ERR, API_DRIVER}; // 400 + cuda2hipRename["cudaErrorInvalidResourceHandle"] = {"hipErrorInvalidResourceHandle", CONV_ERR, API_RUNTIME}; // 33 + + cuda2hipRename["CUDA_ERROR_NOT_READY"] = {"hipErrorNotReady", CONV_ERR, API_DRIVER}; // 600 + cuda2hipRename["cudaErrorNotReady"] = {"hipErrorNotReady", CONV_ERR, API_RUNTIME}; // 34 + + cuda2hipRename["CUDA_ERROR_ILLEGAL_ADDRESS"] = {"hipErrorIllegalAddress", CONV_ERR, API_DRIVER}; // 700 + cuda2hipRename["cudaErrorIllegalAddress"] = {"hipErrorIllegalAddress", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 77 + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + cuda2hipRename["CUDA_ERROR_LAUNCH_FAILED"] = {"hipErrorLaunchFailure", CONV_ERR, API_DRIVER}; // 719 + cuda2hipRename["cudaErrorLaunchFailure"] = {"hipErrorLaunchFailure", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 4 cuda2hipRename["CUDA_ERROR_LAUNCH_TIMEOUT"] = {"hipErrorLaunchTimeOut", CONV_ERR, API_DRIVER}; cuda2hipRename["cudaErrorLaunchTimeout"] = {"hipErrorLaunchTimeOut", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 6 @@ -280,94 +357,81 @@ struct cuda2hipMap { cuda2hipRename["CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES"] = {"hipErrorLaunchOutOfResources", CONV_ERR, API_DRIVER}; cuda2hipRename["cudaErrorLaunchOutOfResources"] = {"hipErrorLaunchOutOfResources", CONV_ERR, API_RUNTIME}; // 7 - cuda2hipRename["CUDA_ERROR_INVALID_DEVICE"] = {"hipErrorInvalidDevice", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorInvalidDevice"] = {"hipErrorInvalidDevice", CONV_ERR, API_RUNTIME}; // 10 - - cuda2hipRename["CUDA_ERROR_INVALID_VALUE"] = {"hipErrorInvalidValue", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorInvalidValue"] = {"hipErrorInvalidValue", CONV_ERR, API_RUNTIME}; // 11 - - cuda2hipRename["CUDA_ERROR_DEINITIALIZED"] = {"hipErrorDeinitialized", CONV_ERR, API_DRIVER}; - // TODO: double check, that this error matches to hipErrorDeinitialized - cuda2hipRename["cudaErrorCudartUnloading"] = {"hipErrorDeinitialized", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 29 - cuda2hipRename["CUDA_ERROR_UNKNOWN"] = {"hipErrorUnknown", CONV_ERR, API_DRIVER}; cuda2hipRename["cudaErrorUnknown"] = {"hipErrorUnknown", CONV_ERR, API_RUNTIME}; // 30 - cuda2hipRename["CUDA_ERROR_INVALID_HANDLE"] = {"hipErrorInvalidResourceHandle", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorInvalidResourceHandle"] = {"hipErrorInvalidResourceHandle", CONV_ERR, API_RUNTIME}; // 33 - // cuda2hipRename["CUDA_ERROR_NOT_INITIALIZED"] = {"hipErrorInitializationError", CONV_ERR, API_DRIVER}; // cuda2hipRename["cudaErrorInitializationError"] = {"hipErrorInitializationError", CONV_ERR, API_RUNTIME}; - cuda2hipRename["CUDA_ERROR_NOT_READY"] = {"hipErrorNotReady", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorNotReady"] = {"hipErrorNotReady", CONV_ERR, API_RUNTIME}; // 34 - - cuda2hipRename["CUDA_ERROR_NO_DEVICE"] = {"hipErrorNoDevice", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorNoDevice"] = {"hipErrorNoDevice", CONV_ERR, API_RUNTIME}; // 38 - - cuda2hipRename["CUDA_ERROR_ECC_UNCORRECTABLE"] = {"hipErrorECCNotCorrectable", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorECCUncorrectable"] = {"hipErrorECCNotCorrectable", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 39 - - cuda2hipRename["CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND"] = {"hipErrorSharedObjectSymbolNotFound", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorSharedObjectSymbolNotFound"] = {"hipErrorSharedObjectSymbolNotFound", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 40 - - cuda2hipRename["CUDA_ERROR_SHARED_OBJECT_INIT_FAILED"] = {"hipErrorSharedObjectInitFailed", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorSharedObjectInitFailed"] = {"hipErrorSharedObjectInitFailed", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 41 - - cuda2hipRename["CUDA_ERROR_UNSUPPORTED_LIMIT"] = {"hipErrorUnsupportedLimit", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorUnsupportedLimit"] = {"hipErrorUnsupportedLimit", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 42 - - cuda2hipRename["CUDA_ERROR_INVALID_IMAGE"] = {"hipErrorInvalidImage", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorInvalidKernelImage"] = {"hipErrorInvalidImage", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 47 - - cuda2hipRename["CUDA_ERROR_NO_BINARY_FOR_GPU"] = {"hipErrorNoBinaryForGpu", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorNoKernelImageForDevice"] = {"hipErrorNoBinaryForGpu", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 48 - cuda2hipRename["CUDA_ERROR_PEER_ACCESS_ALREADY_ENABLED"] = {"hipErrorPeerAccessAlreadyEnabled", CONV_ERR, API_DRIVER}; cuda2hipRename["cudaErrorPeerAccessAlreadyEnabled"] = {"hipErrorPeerAccessAlreadyEnabled", CONV_ERR, API_RUNTIME}; // 50 cuda2hipRename["CUDA_ERROR_PEER_ACCESS_NOT_ENABLED"] = {"hipErrorPeerAccessNotEnabled", CONV_ERR, API_DRIVER}; cuda2hipRename["cudaErrorPeerAccessNotEnabled"] = {"hipErrorPeerAccessNotEnabled", CONV_ERR, API_RUNTIME}; // 51 - cuda2hipRename["CUDA_ERROR_PROFILER_DISABLED"] = {"hipErrorProfilerDisabled", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorProfilerDisabled"] = {"hipErrorProfilerDisabled", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 55 - - cuda2hipRename["CUDA_ERROR_PROFILER_NOT_INITIALIZED"] = {"hipErrorProfilerNotInitialized", CONV_ERR, API_DRIVER}; - // Deprecated as of CUDA 5.0 - cuda2hipRename["cudaErrorProfilerNotInitialized"] = {"hipErrorProfilerNotInitialized", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 56 - - cuda2hipRename["CUDA_ERROR_PROFILER_ALREADY_STARTED"] = {"hipErrorProfilerAlreadyStarted", CONV_ERR, API_DRIVER}; - // Deprecated as of CUDA 5.0 - cuda2hipRename["cudaErrorProfilerAlreadyStarted"] = {"hipErrorProfilerAlreadyStarted", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 57 - - cuda2hipRename["CUDA_ERROR_PROFILER_ALREADY_STOPPED"] = {"hipErrorProfilerAlreadyStopped", CONV_ERR, API_DRIVER}; - // Deprecated as of CUDA 5.0 - cuda2hipRename["cudaErrorProfilerAlreadyStopped"] = {"hipErrorProfilerAlreadyStopped", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 58 - cuda2hipRename["CUDA_ERROR_HOST_MEMORY_ALREADY_REGISTERED"] = {"hipErrorHostMemoryAlreadyRegistered", CONV_ERR, API_DRIVER}; cuda2hipRename["cudaErrorHostMemoryAlreadyRegistered"] = {"hipErrorHostMemoryAlreadyRegistered", CONV_ERR, API_RUNTIME}; // 61 cuda2hipRename["CUDA_ERROR_HOST_MEMORY_NOT_REGISTERED"] = {"hipErrorHostMemoryNotRegistered", CONV_ERR, API_DRIVER}; cuda2hipRename["cudaErrorHostMemoryNotRegistered"] = {"hipErrorHostMemoryNotRegistered", CONV_ERR, API_RUNTIME}; // 62 - cuda2hipRename["CUDA_ERROR_OPERATING_SYSTEM"] = {"hipErrorOperatingSystem", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorOperatingSystem"] = {"hipErrorOperatingSystem", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 63 - - cuda2hipRename["CUDA_ERROR_PEER_ACCESS_UNSUPPORTED"] = {"hipErrorPeerAccessUnsupported", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorPeerAccessUnsupported"] = {"hipErrorPeerAccessUnsupported", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 64 - - cuda2hipRename["CUDA_ERROR_ILLEGAL_ADDRESS"] = {"hipErrorIllegalAddress", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorIllegalAddress"] = {"hipErrorIllegalAddress", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 77 - - cuda2hipRename["CUDA_ERROR_INVALID_PTX"] = {"hipErrorInvalidKernelFile", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorInvalidPtx"] = {"hipErrorInvalidKernelFile", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 78 - - cuda2hipRename["CUDA_ERROR_INVALID_GRAPHICS_CONTEXT"] = {"hipErrorInvalidGraphicsContext", CONV_ERR, API_DRIVER}; - cuda2hipRename["cudaErrorInvalidGraphicsContext"] = {"hipErrorInvalidGraphicsContext", CONV_ERR, API_RUNTIME, HIP_UNSUPPORTED}; // 79 - - - ///////////////////////////// CUDA DRIVER API ///////////////////////////// + // enums + cuda2hipRename["CUDA_ARRAY3D_DESCRIPTOR"] = {"HIP_ARRAY3D_DESCRIPTOR", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CUDA_ARRAY_DESCRIPTOR"] = {"HIP_ARRAY_DESCRIPTOR", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CUDA_MEMCPY2D"] = {"HIP_MEMCPY2D", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CUDA_MEMCPY3D"] = {"HIP_MEMCPY3D", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CUDA_MEMCPY3D_PEER"] = {"HIP_MEMCPY3D_PEER", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CUDA_POINTER_ATTRIBUTE_P2P_TOKENS"] = {"HIP_POINTER_ATTRIBUTE_P2P_TOKENS", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CUDA_RESOURCE_DESC"] = {"HIP_RESOURCE_DESC", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CUDA_RESOURCE_VIEW_DESC"] = {"HIP_RESOURCE_VIEW_DESC", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; + + cuda2hipRename["CUipcEventHandle"] = {"hipIpcEventHandle", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CUipcMemHandle"] = {"hipIpcMemHandle", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; + + + + cuda2hipRename["CUaddress_mode"] = {"hipAddress_mode", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_TR_ADDRESS_MODE_WRAP"] = {"HIP_TR_ADDRESS_MODE_WRAP", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0 + cuda2hipRename["CU_TR_ADDRESS_MODE_CLAMP"] = {"HIP_TR_ADDRESS_MODE_CLAMP", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 1 + cuda2hipRename["CU_TR_ADDRESS_MODE_MIRROR"] = {"HIP_TR_ADDRESS_MODE_MIRROR", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 2 + cuda2hipRename["CU_TR_ADDRESS_MODE_BORDER"] = {"HIP_TR_ADDRESS_MODE_BORDER", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 3 + + cuda2hipRename["CUarray_cubemap_face"] = {"hipArray_cubemap_face", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_CUBEMAP_FACE_POSITIVE_X"] = {"HIP_CUBEMAP_FACE_POSITIVE_X", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x00 + cuda2hipRename["CU_CUBEMAP_FACE_NEGATIVE_X"] = {"HIP_CUBEMAP_FACE_NEGATIVE_X", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x01 + cuda2hipRename["CU_CUBEMAP_FACE_POSITIVE_Y"] = {"HIP_CUBEMAP_FACE_POSITIVE_Y", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x02 + cuda2hipRename["CU_CUBEMAP_FACE_NEGATIVE_Y"] = {"HIP_CUBEMAP_FACE_NEGATIVE_Y", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x03 + cuda2hipRename["CU_CUBEMAP_FACE_POSITIVE_Z"] = {"HIP_CUBEMAP_FACE_POSITIVE_Z", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x04 + cuda2hipRename["CU_CUBEMAP_FACE_NEGATIVE_Z"] = {"HIP_CUBEMAP_FACE_NEGATIVE_Z", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x05 + + cuda2hipRename["CUarray_format"] = {"hipArray_format", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_AD_FORMAT_UNSIGNED_INT8"] = {"HIP_AD_FORMAT_UNSIGNED_INT8", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x01 + cuda2hipRename["CU_AD_FORMAT_UNSIGNED_INT16"] = {"HIP_AD_FORMAT_UNSIGNED_INT16", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x02 + cuda2hipRename["CU_AD_FORMAT_UNSIGNED_INT32"] = {"HIP_AD_FORMAT_UNSIGNED_INT32", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x03 + cuda2hipRename["CU_AD_FORMAT_SIGNED_INT8"] = {"HIP_AD_FORMAT_SIGNED_INT8", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x08 + cuda2hipRename["CU_AD_FORMAT_SIGNED_INT16"] = {"HIP_AD_FORMAT_SIGNED_INT16", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x09 + cuda2hipRename["CU_AD_FORMAT_SIGNED_INT32"] = {"HIP_AD_FORMAT_SIGNED_INT32", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x0a + cuda2hipRename["CU_AD_FORMAT_HALF"] = {"HIP_AD_FORMAT_HALF", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x10 + cuda2hipRename["CU_AD_FORMAT_FLOAT"] = {"HIP_AD_FORMAT_FLOAT", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x20 + // Compute mode + cuda2hipRename["CUcomputemode"] = {"hipComputemode", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // API_RUNTIME ANALOGUE (cudaComputeMode) + cuda2hipRename["CU_COMPUTEMODE_DEFAULT"] = {"hipComputeModeDefault", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 0 + cuda2hipRename["CU_COMPUTEMODE_EXCLUSIVE"] = {"hipComputeModeExclusive", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 1 + cuda2hipRename["CU_COMPUTEMODE_PROHIBITED"] = {"hipComputeModeProhibited", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 2 + cuda2hipRename["CU_COMPUTEMODE_EXCLUSIVE_PROCESS"] = {"hipComputeModeExclusiveProcess", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 3 + // Context flags + cuda2hipRename["CUctx_flags"] = {"hipCctx_flags", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_CTX_SCHED_AUTO"] = {"HIP_CTX_SCHED_AUTO", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x00 + cuda2hipRename["CU_CTX_SCHED_SPIN"] = {"HIP_CTX_SCHED_SPIN", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x01 + cuda2hipRename["CU_CTX_SCHED_YIELD"] = {"HIP_CTX_SCHED_YIELD", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x02 + cuda2hipRename["CU_CTX_SCHED_BLOCKING_SYNC"] = {"HIP_CTX_SCHED_BLOCKING_SYNC", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x04 + cuda2hipRename["CU_CTX_BLOCKING_SYNC"] = {"HIP_CTX_BLOCKING_SYNC", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x04 + cuda2hipRename["CU_CTX_SCHED_MASK"] = {"HIP_CTX_SCHED_MASK", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x07 + cuda2hipRename["CU_CTX_MAP_HOST"] = {"HIP_CTX_MAP_HOST", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x08 + cuda2hipRename["CU_CTX_LMEM_RESIZE_TO_MAX"] = {"HIP_CTX_LMEM_RESIZE_TO_MAX", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x10 + cuda2hipRename["CU_CTX_FLAGS_MASK"] = {"HIP_CTX_FLAGS_MASK", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x1f + // Defines cuda2hipRename["CU_LAUNCH_PARAM_BUFFER_POINTER"] = {"HIP_LAUNCH_PARAM_BUFFER_POINTER", CONV_DEV, API_DRIVER}; cuda2hipRename["CU_LAUNCH_PARAM_BUFFER_SIZE"] = {"HIP_LAUNCH_PARAM_BUFFER_SIZE", CONV_DEV, API_DRIVER}; @@ -375,104 +439,108 @@ struct cuda2hipMap { // Types // NOTE: CUdevice might be changed to typedef int in the future. - cuda2hipRename["CUdevice"] = {"hipDevice_t", CONV_TYPE, API_DRIVER}; - cuda2hipRename["CUdevice_attribute_enum"] = {"hipDeviceAttribute_t", CONV_TYPE, API_DRIVER}; - cuda2hipRename["CUdevice_attribute"] = {"hipDeviceAttribute_t", CONV_TYPE, API_DRIVER}; - - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_BLOCK"] = {"hipDeviceAttributeMaxThreadsPerBlock", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_X"] = {"hipDeviceAttributeMaxBlockDimX", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Y"] = {"hipDeviceAttributeMaxBlockDimY", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Z"] = {"hipDeviceAttributeMaxBlockDimZ", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_X"] = {"hipDeviceAttributeMaxGridDimX", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_Y"] = {"hipDeviceAttributeMaxGridDimY", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_Z"] = {"hipDeviceAttributeMaxGridDimZ", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK"] = {"hipDeviceAttributeMaxSharedMemoryPerBlock", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_SHARED_MEMORY_PER_BLOCK"] = {"hipDeviceAttributeMaxSharedMemoryPerBlock", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_TOTAL_CONSTANT_MEMORY"] = {"hipDeviceAttributeTotalConstantMemory", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_WARP_SIZE"] = {"hipDeviceAttributeWarpSize", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_BLOCK"] = {"hipDeviceAttributeMaxRegistersPerBlock", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_REGISTERS_PER_BLOCK"] = {"hipDeviceAttributeMaxRegistersPerBlock", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_CLOCK_RATE"] = {"hipDeviceAttributeClockRate", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MEMORY_CLOCK_RATE"] = {"hipDeviceAttributeMemoryClockRate", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_GLOBAL_MEMORY_BUS_WIDTH"] = {"hipDeviceAttributeMemoryBusWidth", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_COMPUTE_MODE"] = {"hipDeviceAttributeComputeMode", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_L2_CACHE_SIZE"] = {"hipDeviceAttributeL2CacheSize", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_MULTIPROCESSOR"] = {"hipDeviceAttributeMaxThreadsPerMultiProcessor", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR"] = {"hipDeviceAttributeComputeCapabilityMajor", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR"] = {"hipDeviceAttributeComputeCapabilityMinor", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_CONCURRENT_KERNELS"] = {"hipDeviceAttributeConcurrentKernels", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_PCI_BUS_ID"] = {"hipDeviceAttributePciBusId", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_PCI_DEVICE_ID"] = {"hipDeviceAttributePciDeviceId", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_MULTIPROCESSOR"] = {"hipDeviceAttributeMaxSharedMemoryPerMultiprocessor", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MULTI_GPU_BOARD"] = {"hipDeviceAttributeIsMultiGpuBoard", CONV_DEV, API_DRIVER}; + cuda2hipRename["CUdevice"] = {"hipDevice_t", CONV_TYPE, API_DRIVER}; + cuda2hipRename["CUdevice_attribute_enum"] = {"hipDeviceAttribute_t", CONV_TYPE, API_DRIVER}; // API_Runtime ANALOGUE (cudaDeviceAttr) + cuda2hipRename["CUdevice_attribute"] = {"hipDeviceAttribute_t", CONV_TYPE, API_DRIVER}; // API_Runtime ANALOGUE (cudaDeviceAttr) // unsupported yet by HIP - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_PITCH"] = {"hipDeviceAttributeMaxPitch", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_TEXTURE_ALIGNMENT"] = {"hipDeviceAttributeTextureAlignment", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_ASYNC_ENGINE_COUNT"] = {"hipDeviceAttributeAsyncEngineCount", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_BLOCK"] = {"hipDeviceAttributeMaxThreadsPerBlock", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 1 // API_Runtime ANALOGUE (cudaDevAttrMaxThreadsPerBlock = 1) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_X"] = {"hipDeviceAttributeMaxBlockDimX", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 2 // API_Runtime ANALOGUE (cudaDevAttrMaxBlockDimX = 2) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Y"] = {"hipDeviceAttributeMaxBlockDimY", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 3 // API_Runtime ANALOGUE (cudaDevAttrMaxBlockDimY = 3) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Z"] = {"hipDeviceAttributeMaxBlockDimZ", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 4 // API_Runtime ANALOGUE (cudaDevAttrMaxBlockDimZ = 4) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_X"] = {"hipDeviceAttributeMaxGridDimX", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 5 // API_Runtime ANALOGUE (cudaDevAttrMaxGridDimX =5) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_Y"] = {"hipDeviceAttributeMaxGridDimY", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 6 // API_Runtime ANALOGUE (cudaDevAttrMaxGridDimY = 6) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_Z"] = {"hipDeviceAttributeMaxGridDimZ", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 7 // API_Runtime ANALOGUE (cudaDevAttrMaxGridDimZ - 7) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK"] = {"hipDeviceAttributeMaxSharedMemoryPerBlock", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 8 // API_Runtime ANALOGUE (cudaDevAttrMaxSharedMemoryPerBlock = 8) + // Deprecated, use CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK + cuda2hipRename["CU_DEVICE_ATTRIBUTE_SHARED_MEMORY_PER_BLOCK"] = {"hipDeviceAttributeMaxSharedMemoryPerBlock", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 8 + cuda2hipRename["CU_DEVICE_ATTRIBUTE_TOTAL_CONSTANT_MEMORY"] = {"hipDeviceAttributeTotalConstantMemory", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 9 // API_Runtime ANALOGUE (cudaDevAttrTotalConstantMemory = 9) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_WARP_SIZE"] = {"hipDeviceAttributeWarpSize", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 10 // API_Runtime ANALOGUE (cudaDevAttrWarpSize = 10) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_PITCH"] = {"hipDeviceAttributeMaxPitch", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 11 // API_Runtime ANALOGUE (cudaDevAttrMaxPitch = 11) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_BLOCK"] = {"hipDeviceAttributeMaxRegistersPerBlock", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 12 // API_Runtime ANALOGUE (cudaDevAttrMaxRegistersPerBlock = 12) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_REGISTERS_PER_BLOCK"] = {"hipDeviceAttributeMaxRegistersPerBlock", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 12 + cuda2hipRename["CU_DEVICE_ATTRIBUTE_CLOCK_RATE"] = {"hipDeviceAttributeClockRate", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 13 // API_Runtime ANALOGUE (cudaDevAttrMaxRegistersPerBlock = 13) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_TEXTURE_ALIGNMENT"] = {"hipDeviceAttributeTextureAlignment", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 14 // API_Runtime ANALOGUE (cudaDevAttrTextureAlignment = 14) // Deprecated. Use instead CU_DEVICE_ATTRIBUTE_ASYNC_ENGINE_COUNT - cuda2hipRename["CU_DEVICE_ATTRIBUTE_GPU_OVERLAP"] = {"hipDeviceAttributeAsyncEngineCount", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT"] = {"hipDeviceAttributeMultiprocessorCount", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_KERNEL_EXEC_TIMEOUT"] = {"hipDeviceAttributeKernelExecTimeout", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_INTEGRATED"] = {"hipDeviceAttributeIntegrated", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_CAN_MAP_HOST_MEMORY"] = {"hipDeviceAttributeCanMapHostMemory", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_WIDTH"] = {"hipDeviceAttributeMaxTexture1DWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_WIDTH"] = {"hipDeviceAttributeMaxTexture2DWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_HEIGHT"] = {"hipDeviceAttributeMaxTexture2DHeight", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_WIDTH"] = {"hipDeviceAttributeMaxTexture3DWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_HEIGHT"] = {"hipDeviceAttributeMaxTexture3DHeight", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_DEPTH"] = {"hipDeviceAttributeMaxTexture3DDepth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_WIDTH"] = {"hipDeviceAttributeMaxTexture2DLayeredWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_HEIGHT"] = {"hipDeviceAttributeMaxTexture2DLayeredHeight", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_LAYERS"] = {"hipDeviceAttributeMaxTexture2DLayeredLayers", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_ARRAY_WIDTH"] = {"hipDeviceAttributeMaxTexture2DLayeredWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_ARRAY_HEIGHT"] = {"hipDeviceAttributeMaxTexture2DLayeredHeight", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_ARRAY_NUMSLICES"] = {"hipDeviceAttributeMaxTexture2DLayeredLayers", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_SURFACE_ALIGNMENT"] = {"hipDeviceAttributeSurfaceAlignment", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_ECC_ENABLED"] = {"hipDeviceAttributeEccEnabled", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_TCC_DRIVER"] = {"hipDeviceAttributeTccDriver", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_UNIFIED_ADDRESSING"] = {"hipDeviceAttributeUnifiedAddressing", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LAYERED_WIDTH"] = {"hipDeviceAttributeMaxTexture1DLayeredWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LAYERED_LAYERS"] = {"hipDeviceAttributeMaxTexture1DLayeredLayers", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_GATHER_WIDTH"] = {"hipDeviceAttributeMaxTexture2DGatherWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_GATHER_HEIGHT"] = {"hipDeviceAttributeMaxTexture2DGatherHeight", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_WIDTH_ALTERNATE"] = {"hipDeviceAttributeMaxTexture3DWidthAlternate", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_HEIGHT_ALTERNATE"] = {"hipDeviceAttributeMaxTexture3DHeightAlternate", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_DEPTH_ALTERNATE"] = {"hipDeviceAttributeMaxTexture3DDepthAlternate", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_PCI_DOMAIN_ID"] = {"hipDeviceAttributePciDomainId", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_TEXTURE_PITCH_ALIGNMENT"] = {"hipDeviceAttributeTexturePitchAlignment", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURECUBEMAP_WIDTH"] = {"hipDeviceAttributeMaxTextureCubemapWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURECUBEMAP_LAYERED_WIDTH"] = {"hipDeviceAttributeMaxTextureCubemapLayeredWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURECUBEMAP_LAYERED_LAYERS"] = {"hipDeviceAttributeMaxTextureCubemapLayeredLayers", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE1D_WIDTH"] = {"hipDeviceAttributeMaxSurface1DWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_WIDTH"] = {"hipDeviceAttributeMaxSurface2DWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_HEIGHT"] = {"hipDeviceAttributeMaxSurface2DHeight", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE3D_WIDTH"] = {"hipDeviceAttributeMaxSurface3DWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE3D_HEIGHT"] = {"hipDeviceAttributeMaxSurface3DHeight", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE3D_DEPTH"] = {"hipDeviceAttributeMaxSurface3DDepth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE1D_LAYERED_WIDTH"] = {"hipDeviceAttributeMaxSurface1DLayeredWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE1D_LAYERED_LAYERS"] = {"hipDeviceAttributeMaxSurface1DLayeredLayers", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_WIDTH"] = {"hipDeviceAttributeMaxSurface2DLayeredWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_HEIGHT"] = {"hipDeviceAttributeMaxSurface2DLayeredHeight", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_LAYERS"] = {"hipDeviceAttributeMaxSurface2DLayeredLayers", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_WIDTH"] = {"hipDeviceAttributeMaxSurfaceCubemapWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_LAYERED_WIDTH"] = {"hipDeviceAttributeMaxSurfaceCubemapLayeredWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_LAYERED_LAYERS"] = {"hipDeviceAttributeMaxSurfaceCubemapLayeredLayers", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LINEAR_WIDTH"] = {"hipDeviceAttributeMaxTexture1DLinearWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_WIDTH"] = {"hipDeviceAttributeMaxTexture2DLinearWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_HEIGHT"] = {"hipDeviceAttributeMaxTexture2DLinearHeight", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_PITCH"] = {"hipDeviceAttributeMaxTexture2DLinearPitch", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_MIPMAPPED_WIDTH"] = {"hipDeviceAttributeMaxTexture2DMipmappedWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_MIPMAPPED_HEIGHT"] = {"hipDeviceAttributeMaxTexture2DMipmappedHeight", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_MIPMAPPED_WIDTH"] = {"hipDeviceAttributeMaxTexture1DMipmappedWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_STREAM_PRIORITIES_SUPPORTED"] = {"hipDeviceAttributeStreamPrioritiesSupported", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_GLOBAL_L1_CACHE_SUPPORTED"] = {"hipDeviceAttributeGlobalL1CacheSupported", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_LOCAL_L1_CACHE_SUPPORTED"] = {"hipDeviceAttributeLocalL1CacheSupported", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_MULTIPROCESSOR"] = {"hipDeviceAttributeMaxRegistersPerMultiprocessor", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MANAGED_MEMORY"] = {"hipDeviceAttributeManagedMemory", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MULTI_GPU_BOARD_GROUP_ID"] = {"hipDeviceAttributeMultiGpuBoardGroupId", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX"] = {"hipDeviceAttributeMax", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_GPU_OVERLAP"] = {"hipDeviceAttributeAsyncEngineCount", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 15 // API_Runtime ANALOGUE (cudaDevAttrGpuOverlap = 15) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT"] = {"hipDeviceAttributeMultiprocessorCount", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 16 // API_Runtime ANALOGUE (cudaDevAttrMultiProcessorCount = 16) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_KERNEL_EXEC_TIMEOUT"] = {"hipDeviceAttributeKernelExecTimeout", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 17 // API_Runtime ANALOGUE (cudaDevAttrKernelExecTimeout = 17) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_INTEGRATED"] = {"hipDeviceAttributeIntegrated", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 18 // API_Runtime ANALOGUE (cudaDevAttrIntegrated = 18) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_CAN_MAP_HOST_MEMORY"] = {"hipDeviceAttributeCanMapHostMemory", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 19 // API_Runtime ANALOGUE (cudaDevAttrCanMapHostMemory = 19) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_COMPUTE_MODE"] = {"hipDeviceAttributeComputeMode", CONV_DEV, API_DRIVER}; // 20 // API_Runtime ANALOGUE (cudaDevAttrComputeMode = 20) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_WIDTH"] = {"hipDeviceAttributeMaxTexture1DWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 21 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture1DWidth = 21) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_WIDTH"] = {"hipDeviceAttributeMaxTexture2DWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 22 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture2DWidth = 22) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_HEIGHT"] = {"hipDeviceAttributeMaxTexture2DHeight", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 23 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture2DHeight = 23) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_WIDTH"] = {"hipDeviceAttributeMaxTexture3DWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 24 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture3DWidth = 24) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_HEIGHT"] = {"hipDeviceAttributeMaxTexture3DHeight", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 25 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture3DHeight = 25) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_DEPTH"] = {"hipDeviceAttributeMaxTexture3DDepth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 26 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture3DDepth = 26) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_WIDTH"] = {"hipDeviceAttributeMaxTexture2DLayeredWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 27 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture2DLayeredWidth = 27) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_HEIGHT"] = {"hipDeviceAttributeMaxTexture2DLayeredHeight", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 28 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture2DLayeredHeight = 28) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_LAYERS"] = {"hipDeviceAttributeMaxTexture2DLayeredLayers", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 29 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture2DLayeredLayers = 29) + // Deprecated, use CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_WIDTH + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_ARRAY_WIDTH"] = {"hipDeviceAttributeMaxTexture2DLayeredWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 27 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture2DLayeredWidth = 27) + // Deprecated, use CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_HEIGHT + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_ARRAY_HEIGHT"] = {"hipDeviceAttributeMaxTexture2DLayeredHeight", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 28 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture2DLayeredHeight = 28) + // Deprecated, use CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_LAYERS + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_ARRAY_NUMSLICES"] = {"hipDeviceAttributeMaxTexture2DLayeredLayers", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 29 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture2DLayeredLayers = 29) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_SURFACE_ALIGNMENT"] = {"hipDeviceAttributeSurfaceAlignment", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 30 // API_Runtime ANALOGUE (cudaDevAttrSurfaceAlignment = 30) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_CONCURRENT_KERNELS"] = {"hipDeviceAttributeConcurrentKernels", CONV_DEV, API_DRIVER}; // 31 // API_Runtime ANALOGUE (cudaDevAttrConcurrentKernels = 31) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_ECC_ENABLED"] = {"hipDeviceAttributeEccEnabled", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 32 // API_Runtime ANALOGUE (cudaDevAttrEccEnabled = 32) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_PCI_BUS_ID"] = {"hipDeviceAttributePciBusId", CONV_DEV, API_DRIVER}; // 33 // API_Runtime ANALOGUE (cudaDevAttrPciBusId = 33) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_PCI_DEVICE_ID"] = {"hipDeviceAttributePciDeviceId", CONV_DEV, API_DRIVER}; // 34 // API_Runtime ANALOGUE (cudaDevAttrPciDeviceId = 34) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_TCC_DRIVER"] = {"hipDeviceAttributeTccDriver", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 35 // API_Runtime ANALOGUE (cudaDevAttrTccDriver = 35) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MEMORY_CLOCK_RATE"] = {"hipDeviceAttributeMemoryClockRate", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 36 // API_Runtime ANALOGUE (cudaDevAttrMemoryClockRate = 36) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_GLOBAL_MEMORY_BUS_WIDTH"] = {"hipDeviceAttributeMemoryBusWidth", CONV_DEV, API_DRIVER}; // 37 // API_Runtime ANALOGUE (cudaDevAttrGlobalMemoryBusWidth = 37) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_L2_CACHE_SIZE"] = {"hipDeviceAttributeL2CacheSize", CONV_DEV, API_DRIVER}; // 38 // API_Runtime ANALOGUE (cudaDevAttrL2CacheSize = 38) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_MULTIPROCESSOR"] = {"hipDeviceAttributeMaxThreadsPerMultiProcessor", CONV_DEV, API_DRIVER}; // 39 // API_Runtime ANALOGUE (cudaDevAttrMaxThreadsPerMultiProcessor = 39) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_ASYNC_ENGINE_COUNT"] = {"hipDeviceAttributeAsyncEngineCount", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 40 // API_Runtime ANALOGUE (cudaDevAttrAsyncEngineCount = 40) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_UNIFIED_ADDRESSING"] = {"hipDeviceAttributeUnifiedAddressing", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 41 // API_Runtime ANALOGUE (cudaDevAttrUnifiedAddressing = 41) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LAYERED_WIDTH"] = {"hipDeviceAttributeMaxTexture1DLayeredWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 42 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture1DLayeredWidth = 42) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LAYERED_LAYERS"] = {"hipDeviceAttributeMaxTexture1DLayeredLayers", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 43 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture1DLayeredLayers = 43) // deprecated, do not use - // cuda2hipRename["CU_DEVICE_ATTRIBUTE_CAN_TEX2D_GATHER"] = {"hipDeviceAttributeCanTex2DGather", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_DEVICE_ATTRIBUTE_CAN_TEX2D_GATHER"] = {"hipDeviceAttributeCanTex2DGather", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 44 // API_Runtime ANALOGUE (no) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_GATHER_WIDTH"] = {"hipDeviceAttributeMaxTexture2DGatherWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 45 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture2DGatherWidth = 45) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_GATHER_HEIGHT"] = {"hipDeviceAttributeMaxTexture2DGatherHeight", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 46 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture2DGatherHeight = 46) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_WIDTH_ALTERNATE"] = {"hipDeviceAttributeMaxTexture3DWidthAlternate", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 47 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture3DWidthAlt = 47) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_HEIGHT_ALTERNATE"] = {"hipDeviceAttributeMaxTexture3DHeightAlternate", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 48 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture3DHeightAlt = 48) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_DEPTH_ALTERNATE"] = {"hipDeviceAttributeMaxTexture3DDepthAlternate", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 49 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture3DDepthAlt = 49) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_PCI_DOMAIN_ID"] = {"hipDeviceAttributePciDomainId", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 50 // API_Runtime ANALOGUE (cudaDevAttrPciDomainId = 50) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_TEXTURE_PITCH_ALIGNMENT"] = {"hipDeviceAttributeTexturePitchAlignment", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 51 // API_Runtime ANALOGUE (cudaDevAttrTexturePitchAlignment = 51) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURECUBEMAP_WIDTH"] = {"hipDeviceAttributeMaxTextureCubemapWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 52 // API_Runtime ANALOGUE (cudaDevAttrMaxTextureCubemapWidth = 52) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURECUBEMAP_LAYERED_WIDTH"] = {"hipDeviceAttributeMaxTextureCubemapLayeredWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 53 // API_Runtime ANALOGUE (cudaDevAttrMaxTextureCubemapLayeredWidth = 53) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURECUBEMAP_LAYERED_LAYERS"] = {"hipDeviceAttributeMaxTextureCubemapLayeredLayers", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 54 // API_Runtime ANALOGUE (cudaDevAttrMaxTextureCubemapLayeredLayers = 54) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE1D_WIDTH"] = {"hipDeviceAttributeMaxSurface1DWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 55 // API_Runtime ANALOGUE (cudaDevAttrMaxSurface1DWidth = 55) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_WIDTH"] = {"hipDeviceAttributeMaxSurface2DWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 56 // API_Runtime ANALOGUE (cudaDevAttrMaxSurface2DWidth = 56) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_HEIGHT"] = {"hipDeviceAttributeMaxSurface2DHeight", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 57 // API_Runtime ANALOGUE (cudaDevAttrMaxSurface2DHeight = 57) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE3D_WIDTH"] = {"hipDeviceAttributeMaxSurface3DWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 58 // API_Runtime ANALOGUE (cudaDevAttrMaxSurface3DWidth = 58) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE3D_HEIGHT"] = {"hipDeviceAttributeMaxSurface3DHeight", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 59 // API_Runtime ANALOGUE (cudaDevAttrMaxSurface3DHeight = 59) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE3D_DEPTH"] = {"hipDeviceAttributeMaxSurface3DDepth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 60 // API_Runtime ANALOGUE (cudaDevAttrMaxSurface3DDepth = 60) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE1D_LAYERED_WIDTH"] = {"hipDeviceAttributeMaxSurface1DLayeredWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 61 // API_Runtime ANALOGUE (cudaDevAttrMaxSurface1DLayeredWidth = 61) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE1D_LAYERED_LAYERS"] = {"hipDeviceAttributeMaxSurface1DLayeredLayers", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 62 // API_Runtime ANALOGUE (cudaDevAttrMaxSurface1DLayeredLayers = 62) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_WIDTH"] = {"hipDeviceAttributeMaxSurface2DLayeredWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 63 // API_Runtime ANALOGUE (cudaDevAttrMaxSurface2DLayeredWidth = 63) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_HEIGHT"] = {"hipDeviceAttributeMaxSurface2DLayeredHeight", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 64 // API_Runtime ANALOGUE (cudaDevAttrMaxSurface2DLayeredHeight = 64) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_LAYERS"] = {"hipDeviceAttributeMaxSurface2DLayeredLayers", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 65 // API_Runtime ANALOGUE (cudaDevAttrMaxSurface2DLayeredLayers = 65) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_WIDTH"] = {"hipDeviceAttributeMaxSurfaceCubemapWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 66 // API_Runtime ANALOGUE (cudaDevAttrMaxSurfaceCubemapWidth = 66) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_LAYERED_WIDTH"] = {"hipDeviceAttributeMaxSurfaceCubemapLayeredWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 67 // API_Runtime ANALOGUE (cudaDevAttrMaxSurfaceCubemapLayeredWidth = 67) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_LAYERED_LAYERS"] = {"hipDeviceAttributeMaxSurfaceCubemapLayeredLayers", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 68 // API_Runtime ANALOGUE (cudaDevAttrMaxSurfaceCubemapLayeredLayers = 68) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LINEAR_WIDTH"] = {"hipDeviceAttributeMaxTexture1DLinearWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 69 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture1DLinearWidth = 69) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_WIDTH"] = {"hipDeviceAttributeMaxTexture2DLinearWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 70 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture2DLinearWidth = 70) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_HEIGHT"] = {"hipDeviceAttributeMaxTexture2DLinearHeight", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 71 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture2DLinearHeight = 71) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_PITCH"] = {"hipDeviceAttributeMaxTexture2DLinearPitch", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 72 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture2DLinearPitch = 72) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_MIPMAPPED_WIDTH"] = {"hipDeviceAttributeMaxTexture2DMipmappedWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 73 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture2DMipmappedWidth = 73) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_MIPMAPPED_HEIGHT"] = {"hipDeviceAttributeMaxTexture2DMipmappedHeight", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 74 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture2DMipmappedHeight = 74) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR"] = {"hipDeviceAttributeComputeCapabilityMajor", CONV_DEV, API_DRIVER}; // 75 // API_Runtime ANALOGUE (cudaDevAttrComputeCapabilityMajor = 75) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR"] = {"hipDeviceAttributeComputeCapabilityMinor", CONV_DEV, API_DRIVER}; // 76 // API_Runtime ANALOGUE (cudaDevAttrComputeCapabilityMinor = 76) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_MIPMAPPED_WIDTH"] = {"hipDeviceAttributeMaxTexture1DMipmappedWidth", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 77 // API_Runtime ANALOGUE (cudaDevAttrMaxTexture1DMipmappedWidth = 77) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_STREAM_PRIORITIES_SUPPORTED"] = {"hipDeviceAttributeStreamPrioritiesSupported", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 78 // API_Runtime ANALOGUE (cudaDevAttrStreamPrioritiesSupported = 78) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_GLOBAL_L1_CACHE_SUPPORTED"] = {"hipDeviceAttributeGlobalL1CacheSupported", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 79 // API_Runtime ANALOGUE (cudaDevAttrGlobalL1CacheSupported = 79) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_LOCAL_L1_CACHE_SUPPORTED"] = {"hipDeviceAttributeLocalL1CacheSupported", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 80 // API_Runtime ANALOGUE (cudaDevAttrLocalL1CacheSupported = 80) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_MULTIPROCESSOR"] = {"hipDeviceAttributeMaxSharedMemoryPerMultiprocessor", CONV_DEV, API_DRIVER}; // 81 // API_Runtime ANALOGUE (cudaDevAttrMaxSharedMemoryPerMultiprocessor = 81) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_MULTIPROCESSOR"] = {"hipDeviceAttributeMaxRegistersPerMultiprocessor", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 82 // API_Runtime ANALOGUE (cudaDevAttrMaxRegistersPerMultiprocessor = 82) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MANAGED_MEMORY"] = {"hipDeviceAttributeManagedMemory", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 83 // API_Runtime ANALOGUE (cudaDevAttrManagedMemory = 83) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MULTI_GPU_BOARD"] = {"hipDeviceAttributeIsMultiGpuBoard", CONV_DEV, API_DRIVER}; // 84 // API_Runtime ANALOGUE (cudaDevAttrIsMultiGpuBoard = 84) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MULTI_GPU_BOARD_GROUP_ID"] = {"hipDeviceAttributeMultiGpuBoardGroupId", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 85 // API_Runtime ANALOGUE (cudaDevAttrMultiGpuBoardGroupID = 85) + cuda2hipRename["CU_DEVICE_ATTRIBUTE_MAX"] = {"hipDeviceAttributeMax", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 86 // API_Runtime ANALOGUE (no) + // unsupported yet by HIP [CUDA 8.0.44] cuda2hipRename["CU_DEVICE_ATTRIBUTE_HOST_NATIVE_ATOMIC_SUPPORTED"] = {"hipDeviceAttributeHostNativeAtomicSupported", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; cuda2hipRename["CU_DEVICE_ATTRIBUTE_SINGLE_TO_DOUBLE_PRECISION_PERF_RATIO"] = {"hipDeviceAttributeSingleToDoublePrecisionPerfRatio", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; @@ -481,52 +549,232 @@ struct cuda2hipMap { cuda2hipRename["CU_DEVICE_ATTRIBUTE_COMPUTE_PREEMPTION_SUPPORTED"] = {"hipDeviceAttributeComputePreemptionSupported", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; cuda2hipRename["CU_DEVICE_ATTRIBUTE_CAN_USE_HOST_POINTER_FOR_REGISTERED_MEM"] = {"hipDeviceAttributeCanUseHostPointerForRegisteredMem", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CUdevprop_st"] = {"hipDeviceProp_t", CONV_TYPE, API_DRIVER}; - cuda2hipRename["CUdevprop"] = {"hipDeviceProp_t", CONV_TYPE, API_DRIVER}; + cuda2hipRename["CUdevprop_st"] = {"hipDeviceProp_t", CONV_TYPE, API_DRIVER}; + cuda2hipRename["CUdevprop"] = {"hipDeviceProp_t", CONV_TYPE, API_DRIVER}; // TODO: Analogues enum is needed in HIP. Couldn't map enum to struct hipPointerAttribute_t. // TODO: Do for Pointer Attributes the same as for Device Attributes. - // cuda2hipRename["CUpointer_attribute_enum"] = {"hipPointerAttribute_t", CONV_TYPE, API_DRIVER}; - // cuda2hipRename["CUpointer_attribute"] = {"hipPointerAttribute_t", CONV_TYPE, API_DRIVER}; + // cuda2hipRename["CUpointer_attribute_enum"] = {"hipPointerAttribute", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // API_Runtime ANALOGUE (no) + // cuda2hipRename["CUpointer_attribute"] = {"hipPointerAttribute", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // API_Runtime ANALOGUE (no) + cuda2hipRename["CU_POINTER_ATTRIBUTE_CONTEXT"] = {"hipPointerAttributeContext", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 1 // API_Runtime ANALOGUE (no) + cuda2hipRename["CU_POINTER_ATTRIBUTE_MEMORY_TYPE"] = {"hipPointerAttributeMemoryType", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 2 // API_Runtime ANALOGUE (no) + cuda2hipRename["CU_POINTER_ATTRIBUTE_DEVICE_POINTER"] = {"hipPointerAttributeDevicePointer", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 3 // API_Runtime ANALOGUE (no) + cuda2hipRename["CU_POINTER_ATTRIBUTE_HOST_POINTER"] = {"hipPointerAttributeHostPointer", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 4 // API_Runtime ANALOGUE (no) + cuda2hipRename["CU_POINTER_ATTRIBUTE_P2P_TOKENS"] = {"hipPointerAttributeP2pTokens", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 5 // API_Runtime ANALOGUE (no) + cuda2hipRename["CU_POINTER_ATTRIBUTE_SYNC_MEMOPS"] = {"hipPointerAttributeSyncMemops", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 6 // API_Runtime ANALOGUE (no) + cuda2hipRename["CU_POINTER_ATTRIBUTE_BUFFER_ID"] = {"hipPointerAttributeBufferId", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 7 // API_Runtime ANALOGUE (no) + cuda2hipRename["CU_POINTER_ATTRIBUTE_IS_MANAGED"] = {"hipPointerAttributeIsManaged", CONV_DEV, API_DRIVER, HIP_UNSUPPORTED}; // 8 // API_Runtime ANALOGUE (no) + // pointer to CUfunc_st - cuda2hipRename["CUfunction"] = {"hipFunction_t", CONV_TYPE, API_DRIVER}; + cuda2hipRename["CUfunction"] = {"hipFunction_t", CONV_TYPE, API_DRIVER}; // TODO: in HIP ihipModuleSymbol_t should be declared in hip_runtime_api.h, not in hcc_detail/hip_runtime_api.h, as it's analogue CUfunc_st is declared also in cuda.h // ToDO: examples are needed with CUfunc_st - // cuda2hipRename["CUfunc_st"] = {"ihipModuleSymbol_t", CONV_TYPE, API_DRIVER}; + // cuda2hipRename["CUfunc_st"] = {"ihipModuleSymbol_t", CONV_TYPE, API_DRIVER}; // unsupported yet by HIP - cuda2hipRename["CUfunction_attribute_enum"] = {"hipFuncAttribute_t", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CUfunction_attribute"] = {"hipFuncAttribute_t", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CUfunction_attribute"] = {"hipFuncAttribute_t", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CUfunction_attribute_enum"] = {"hipFuncAttribute_t", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_FUNC_ATTRIBUTE_MAX_THREADS_PER_BLOCK"] = {"hipFuncAttributeMaxThreadsPerBlocks", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_FUNC_ATTRIBUTE_SHARED_SIZE_BYTES"] = {"hipFuncAttributeSharedSizeBytes", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_FUNC_ATTRIBUTE_CONST_SIZE_BYTES"] = {"hipFuncAttributeConstSizeBytes", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_FUNC_ATTRIBUTE_LOCAL_SIZE_BYTES"] = {"hipFuncAttributeLocalSizeBytes", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_FUNC_ATTRIBUTE_NUM_REGS"] = {"hipFuncAttributeNumRegs", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_FUNC_ATTRIBUTE_PTX_VERSION"] = {"hipFuncAttributePtxVersion", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_FUNC_ATTRIBUTE_BINARY_VERSION"] = {"hipFuncAttributeBinaryVersion", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_FUNC_ATTRIBUTE_CACHE_MODE_CA"] = {"hipFuncAttributeCacheModeCA", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_FUNC_ATTRIBUTE_MAX"] = {"hipFuncAttributeMax", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["CUfunc_cache_enum"] = {"hipFuncCache", CONV_TYPE, API_DRIVER}; - cuda2hipRename["CUfunc_cache"] = {"hipFuncCache", CONV_TYPE, API_DRIVER}; - cuda2hipRename["CU_FUNC_CACHE_PREFER_NONE"] = {"hipFuncCachePreferNone", CONV_CACHE, API_DRIVER}; - cuda2hipRename["CU_FUNC_CACHE_PREFER_SHARED"] = {"hipFuncCachePreferShared", CONV_CACHE, API_DRIVER}; - cuda2hipRename["CU_FUNC_CACHE_PREFER_L1"] = {"hipFuncCachePreferL1", CONV_CACHE, API_DRIVER}; - cuda2hipRename["CU_FUNC_CACHE_PREFER_EQUAL"] = {"hipFuncCachePreferEqual", CONV_CACHE, API_DRIVER}; + // enum CUgraphicsMapResourceFlags/CUgraphicsMapResourceFlags_enum + cuda2hipRename["CUgraphicsMapResourceFlags"] = {"hipGraphicsMapFlags", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // API_Runtime ANALOGUE (cudaGraphicsMapFlags) + cuda2hipRename["CUgraphicsMapResourceFlags_enum"] = {"hipGraphicsMapFlags", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // API_Runtime ANALOGUE (cudaGraphicsMapFlags) + cuda2hipRename["CU_GRAPHICS_MAP_RESOURCE_FLAGS_NONE"] = {"hipGraphicsMapFlagsNone", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x00 // API_Runtime ANALOGUE (cudaGraphicsMapFlagsNone = 0) + cuda2hipRename["CU_GRAPHICS_MAP_RESOURCE_FLAGS_READ_ONLY"] = {"hipGraphicsMapFlagsReadOnly", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x01 // API_Runtime ANALOGUE (cudaGraphicsMapFlagsReadOnly = 1) + cuda2hipRename["CU_GRAPHICS_MAP_RESOURCE_FLAGS_WRITE_DISCARD"] = {"hipGraphicsMapFlagsWriteDiscard", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x02 // API_Runtime ANALOGUE (cudaGraphicsMapFlagsWriteDiscard = 2) - cuda2hipRename["CUsharedconfig_enum"] = {"hipSharedMemConfig", CONV_TYPE, API_DRIVER}; - cuda2hipRename["CUsharedconfig"] = {"hipSharedMemConfig", CONV_TYPE, API_DRIVER}; - cuda2hipRename["CU_SHARED_MEM_CONFIG_DEFAULT_BANK_SIZE"] = {"hipSharedMemBankSizeDefault", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_SHARED_MEM_CONFIG_FOUR_BYTE_BANK_SIZE"] = {"hipSharedMemBankSizeFourByte", CONV_DEV, API_DRIVER}; - cuda2hipRename["CU_SHARED_MEM_CONFIG_EIGHT_BYTE_BANK_SIZE"] = {"hipSharedMemBankSizeEightByte", CONV_DEV, API_DRIVER}; + // enum CUgraphicsRegisterFlags/CUgraphicsRegisterFlags_enum + cuda2hipRename["CUgraphicsRegisterFlags"] = {"hipGraphicsRegisterFlags", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // API_Runtime ANALOGUE (cudaGraphicsRegisterFlags) + cuda2hipRename["CUgraphicsRegisterFlags_enum"] = {"hipGraphicsRegisterFlags", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // API_Runtime ANALOGUE (cudaGraphicsRegisterFlags) + cuda2hipRename["CU_GRAPHICS_MAP_RESOURCE_FLAGS_NONE"] = {"hipGraphicsRegisterFlagsNone", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x00 // API_Runtime ANALOGUE (cudaGraphicsRegisterFlagsNone = 0) + cuda2hipRename["CU_GRAPHICS_MAP_RESOURCE_FLAGS_READ_ONLY"] = {"hipGraphicsRegisterFlagsReadOnly", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x01 // API_Runtime ANALOGUE (cudaGraphicsRegisterFlagsReadOnly = 1) + cuda2hipRename["CU_GRAPHICS_REGISTER_FLAGS_WRITE_DISCARD"] = {"hipGraphicsRegisterFlagsWriteDiscard", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x02 // API_Runtime ANALOGUE (cudaGraphicsRegisterFlagsWriteDiscard = 2) + cuda2hipRename["CU_GRAPHICS_REGISTER_FLAGS_SURFACE_LDST"] = {"hipGraphicsRegisterFlagsSurfaceLoadStore", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x04 // API_Runtime ANALOGUE (cudaGraphicsRegisterFlagsSurfaceLoadStore = 4) + cuda2hipRename["CU_GRAPHICS_REGISTER_FLAGS_TEXTURE_GATHER"] = {"hipGraphicsRegisterFlagsTextureGather", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x08 // API_Runtime ANALOGUE (cudaGraphicsRegisterFlagsTextureGather = 8) - cuda2hipRename["CUcontext"] = {"hipCtx_t", CONV_TYPE, API_DRIVER}; + // enum CUoccupancy_flags/CUoccupancy_flags_enum + cuda2hipRename["CUoccupancy_flags"] = {"hipOccupancyFlags", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // API_Runtime ANALOGUE (no) + cuda2hipRename["CUoccupancy_flags_enum"] = {"hipOccupancyFlags", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // API_Runtime ANALOGUE (no) + cuda2hipRename["CU_OCCUPANCY_DEFAULT"] = {"hipOccupancyDefault", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x00 // API_Runtime ANALOGUE (cudaOccupancyDefault = 0x0) + cuda2hipRename["CU_OCCUPANCY_DISABLE_CACHING_OVERRIDE"] = {"hipOccupancyDisableCachingOverride", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x01 // API_Runtime ANALOGUE (cudaOccupancyDisableCachingOverride = 0x1) + + + + cuda2hipRename["CUfunc_cache_enum"] = {"hipFuncCache", CONV_TYPE, API_DRIVER}; // API_Runtime ANALOGUE (cudaFuncCache) + cuda2hipRename["CUfunc_cache"] = {"hipFuncCache", CONV_TYPE, API_DRIVER}; // API_Runtime ANALOGUE (cudaFuncCache) + cuda2hipRename["CU_FUNC_CACHE_PREFER_NONE"] = {"hipFuncCachePreferNone", CONV_CACHE, API_DRIVER}; // 0x00 // API_Runtime ANALOGUE (cudaFilterModePoint = 0) + cuda2hipRename["CU_FUNC_CACHE_PREFER_SHARED"] = {"hipFuncCachePreferShared", CONV_CACHE, API_DRIVER}; // 0x01 // API_Runtime ANALOGUE (cudaFuncCachePreferShared = 1) + cuda2hipRename["CU_FUNC_CACHE_PREFER_L1"] = {"hipFuncCachePreferL1", CONV_CACHE, API_DRIVER}; // 0x02 // API_Runtime ANALOGUE (cudaFuncCachePreferL1 = 2) + cuda2hipRename["CU_FUNC_CACHE_PREFER_EQUAL"] = {"hipFuncCachePreferEqual", CONV_CACHE, API_DRIVER}; // 0x03 // API_Runtime ANALOGUE (cudaFuncCachePreferEqual = 3) + + // enum CUipcMem_flags/CUipcMem_flags_enum + cuda2hipRename["CUipcMem_flags"] = {"hipIpcMemFlags", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // API_Runtime ANALOGUE (no) + cuda2hipRename["CUipcMem_flags_enum"] = {"hipIpcMemFlags", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // API_Runtime ANALOGUE (no) + cuda2hipRename["CU_IPC_MEM_LAZY_ENABLE_PEER_ACCESS"] = {"hipIpcMemLazyEnablePeerAccess", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x1 // API_Runtime ANALOGUE (cudaIpcMemLazyEnablePeerAccess = 0x01) + + // enum CUipcMem_flags/CUipcMem_flags_enum + cuda2hipRename["CUipcMem_flags"] = {"hipIpcMemFlags", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // API_Runtime ANALOGUE (no) + + // JIT + // enum CUjit_cacheMode/CUjit_cacheMode_enum + cuda2hipRename["CUjit_cacheMode"] = {"hipJitCacheMode", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; // API_Runtime ANALOGUE (no) + cuda2hipRename["CUjit_cacheMode_enum"] = {"hipJitCacheMode", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_JIT_CACHE_OPTION_NONE"] = {"hipJitCacheModeOptionNone", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_JIT_CACHE_OPTION_CG"] = {"hipJitCacheModeOptionCG", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_JIT_CACHE_OPTION_CA"] = {"hipJitCacheModeOptionCA", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + // enum CUjit_fallback/CUjit_fallback_enum + cuda2hipRename["CUjit_fallback"] = {"hipJitFallback", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; // API_Runtime ANALOGUE (no) + cuda2hipRename["CUjit_fallback_enum"] = {"hipJitFallback", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_PREFER_PTX"] = {"hipJitFallbackPreferPtx", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_PREFER_BINARY"] = {"hipJitFallbackPreferBinary", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + // enum CUjit_option/CUjit_option_enum + cuda2hipRename["CUjit_option"] = {"hipJitOption", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; // API_Runtime ANALOGUE (no) + cuda2hipRename["CUjit_option_enum"] = {"hipJitOption", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_JIT_MAX_REGISTERS"] = {"hipJitOptionMaxRegisters", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_JIT_THREADS_PER_BLOCK"] = {"hipJitOptionThreadsPerBlock", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_JIT_WALL_TIME"] = {"hipJitOptionWallTime", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_JIT_INFO_LOG_BUFFER"] = {"hipJitOptionInfoLogBuffer", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_JIT_INFO_LOG_BUFFER_SIZE_BYTES"] = {"hipJitOptionInfoLogBufferSizeBytes", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_JIT_ERROR_LOG_BUFFER"] = {"hipJitOptionErrorLogBuffer", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_JIT_ERROR_LOG_BUFFER_SIZE_BYTES"] = {"hipJitOptionErrorLogBufferSizeBytes", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_JIT_OPTIMIZATION_LEVEL"] = {"hipJitOptionOptimizationLevel", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_JIT_TARGET_FROM_CUCONTEXT"] = {"hipJitOptionTargetFromContext", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_JIT_TARGET"] = {"hipJitOptionTarget", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_JIT_FALLBACK_STRATEGY"] = {"hipJitOptionFallbackStrategy", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_JIT_GENERATE_DEBUG_INFO"] = {"hipJitOptionGenerateDebugInfo", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_JIT_LOG_VERBOSE"] = {"hipJitOptionLogVerbose", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_JIT_GENERATE_LINE_INFO"] = {"hipJitOptionLogVerbose", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_JIT_CACHE_MODE"] = {"hipJitOptionCacheMode", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_JIT_NUM_OPTIONS"] = {"hipJitOptionNumOptions", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + // enum CUjit_target/CUjit_target_enum + cuda2hipRename["CUjit_target"] = {"hipJitTarget", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; // API_Runtime ANALOGUE (no) + cuda2hipRename["CUjit_target_enum"] = {"hipJitTarget", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_TARGET_COMPUTE_10"] = {"hipJitTargetCompute10", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_TARGET_COMPUTE_11"] = {"hipJitTargetCompute11", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_TARGET_COMPUTE_12"] = {"hipJitTargetCompute12", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_TARGET_COMPUTE_13"] = {"hipJitTargetCompute13", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_TARGET_COMPUTE_20"] = {"hipJitTargetCompute20", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_TARGET_COMPUTE_21"] = {"hipJitTargetCompute21", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_TARGET_COMPUTE_30"] = {"hipJitTargetCompute30", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_TARGET_COMPUTE_32"] = {"hipJitTargetCompute32", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_TARGET_COMPUTE_35"] = {"hipJitTargetCompute35", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_TARGET_COMPUTE_37"] = {"hipJitTargetCompute37", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_TARGET_COMPUTE_50"] = {"hipJitTargetCompute50", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_TARGET_COMPUTE_52"] = {"hipJitTargetCompute52", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + // enum CUjitInputType/CUjitInputType_enum + cuda2hipRename["CUjitInputType"] = {"hipJitInputType", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; // API_Runtime ANALOGUE (no) + cuda2hipRename["CUjitInputType_enum"] = {"hipJitInputType", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_JIT_INPUT_CUBIN"] = {"hipJitInputTypeBin", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_JIT_INPUT_PTX"] = {"hipJitInputTypePtx", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_JIT_INPUT_FATBINARY"] = {"hipJitInputTypeFatBinary", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_JIT_INPUT_OBJECT"] = {"hipJitInputTypeObject", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_JIT_INPUT_LIBRARY"] = {"hipJitInputTypeLibrary", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["CU_JIT_NUM_INPUT_TYPES"] = {"hipJitInputTypeNumInputTypes", CONV_JIT, API_DRIVER, HIP_UNSUPPORTED}; + + // Limits + cuda2hipRename["CUlimit"] = {"hipLimit_t", CONV_TYPE, API_DRIVER}; // API_Runtime ANALOGUE (cudaLimit) + cuda2hipRename["CUlimit_enum"] = {"hipLimit_t", CONV_TYPE, API_DRIVER}; // API_Runtime ANALOGUE (cudaLimit) + cuda2hipRename["CU_LIMIT_STACK_SIZE"] = {"hipLimitStackSize", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x00 // API_Runtime ANALOGUE (cudaLimitStackSize = 0x00) + cuda2hipRename["CU_LIMIT_PRINTF_FIFO_SIZE"] = {"hipLimitPrintfFifoSize", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x01 // API_Runtime ANALOGUE (cudaLimitPrintfFifoSize = 0x01) + cuda2hipRename["CU_LIMIT_MALLOC_HEAP_SIZE"] = {"hipLimitMallocHeapSize", CONV_TYPE, API_DRIVER}; // 0x02 // API_Runtime ANALOGUE (cudaLimitMallocHeapSize = 0x02) + cuda2hipRename["CU_LIMIT_DEV_RUNTIME_SYNC_DEPTH"] = {"hipLimitDevRuntimeSyncDepth", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x03 // API_Runtime ANALOGUE (cudaLimitDevRuntimeSyncDepth = 0x03) + cuda2hipRename["CU_LIMIT_DEV_RUNTIME_PENDING_LAUNCH_COUNT"] = {"hipLimitDevRuntimePendingLaunchCount", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x04 // API_Runtime ANALOGUE (cudaLimitDevRuntimePendingLaunchCount = 0x04) + cuda2hipRename["CU_LIMIT_STACK_SIZE"] = {"hipLimitStackSize", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // API_Runtime ANALOGUE (no) + + // enum CUmemAttach_flags/CUmemAttach_flags_enum + cuda2hipRename["CUmemAttach_flags"] = {"hipMemAttachFlags_t", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // API_Runtime ANALOGUE (no) + cuda2hipRename["CUmemAttach_flags_enum"] = {"hipMemAttachFlags_t", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // API_Runtime ANALOGUE (no) + cuda2hipRename["CU_MEM_ATTACH_GLOBAL"] = {"hipMemAttachGlobal", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x1 // API_Runtime ANALOGUE (#define cudaMemAttachGlobal 0x01) + cuda2hipRename["CU_MEM_ATTACH_HOST"] = {"hipMemAttachHost", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x2 // API_Runtime ANALOGUE (#define cudaMemAttachHost 0x02) + cuda2hipRename["CU_MEM_ATTACH_SINGLE"] = {"hipMemAttachSingle", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x4 // API_Runtime ANALOGUE (#define cudaMemAttachSingle 0x04) + + // enum CUmemorytype/CUmemorytype_enum + cuda2hipRename["CUmemorytype"] = {"hipMemType_t", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // API_Runtime ANALOGUE (no - cudaMemoryType is not an analogue) + cuda2hipRename["CUmemorytype_enum"] = {"hipMemType_t", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // API_Runtime ANALOGUE (no - cudaMemoryType is not an analogue) + cuda2hipRename["CU_MEMORYTYPE_HOST"] = {"hipMemTypeHost", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x01 // API_Runtime ANALOGUE (no) + cuda2hipRename["CU_MEMORYTYPE_DEVICE"] = {"hipMemTypeDevice", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x02 // API_Runtime ANALOGUE (no) + cuda2hipRename["CU_MEMORYTYPE_ARRAY"] = {"hipMemTypeArray", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x03 // API_Runtime ANALOGUE (no) + cuda2hipRename["CU_MEMORYTYPE_UNIFIED"] = {"hipMemTypeUnified", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}; // 0x04 // API_Runtime ANALOGUE (no) + + // enum CUresourcetype + cuda2hipRename["CUresourcetype"] = {"hipResourceType", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // API_Runtime ANALOGUE (cudaResourceType) + cuda2hipRename["CUresourcetype_enum"] = {"hipResourceType", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // API_Runtime ANALOGUE (cudaResourceType) + cuda2hipRename["CU_RESOURCE_TYPE_ARRAY"] = {"hipResourceTypeArray", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x00 // API_Runtime ANALOGUE (cudaResourceTypeArray = 0x00) + cuda2hipRename["CU_RESOURCE_TYPE_MIPMAPPED_ARRAY"] = {"hipResourceTypeMipmappedArray", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x01 // API_Runtime ANALOGUE (cudaResourceTypeMipmappedArray = 0x01) + cuda2hipRename["CU_RESOURCE_TYPE_LINEAR"] = {"hipResourceTypeLinear", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x02 // API_Runtime ANALOGUE (cudaResourceTypeLinear = 0x02) + cuda2hipRename["CU_RESOURCE_TYPE_PITCH2D"] = {"hipResourceTypePitch2D", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x03 // API_Runtime ANALOGUE (cudaResourceTypePitch2D = 0x03) + + // enum CUresourceViewFormat/CUresourceViewFormat_enum + cuda2hipRename["CUresourceViewFormat"] = {"hipResourceViewFormat", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // API_Runtime ANALOGUE (cudaResourceViewFormat) + cuda2hipRename["CUresourceViewFormat_enum"] = {"hipResourceViewFormat", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // API_Runtime ANALOGUE (cudaResourceViewFormat) + cuda2hipRename["CU_RES_VIEW_FORMAT_NONE"] = {"hipResViewFormatNone", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x00 // API_Runtime ANALOGUE (cudaResViewFormatNone = 0x00) + cuda2hipRename["CU_RES_VIEW_FORMAT_UINT_1X8"] = {"hipResViewFormatUnsignedChar1", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x01 // API_Runtime ANALOGUE (cudaResViewFormatUnsignedChar1 = 0x01) + cuda2hipRename["CU_RES_VIEW_FORMAT_UINT_2X8"] = {"hipResViewFormatUnsignedChar2", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x02 // API_Runtime ANALOGUE (cudaResViewFormatUnsignedChar2 = 0x02) + cuda2hipRename["CU_RES_VIEW_FORMAT_UINT_4X8"] = {"hipResViewFormatUnsignedChar4", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x03 // API_Runtime ANALOGUE (cudaResViewFormatUnsignedChar4 = 0x03) + cuda2hipRename["CU_RES_VIEW_FORMAT_SINT_1X8"] = {"hipResViewFormatSignedChar1", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x04 // API_Runtime ANALOGUE (cudaResViewFormatSignedChar1 = 0x04) + cuda2hipRename["CU_RES_VIEW_FORMAT_SINT_2X8"] = {"hipResViewFormatSignedChar2", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x05 // API_Runtime ANALOGUE (cudaResViewFormatSignedChar2 = 0x05) + cuda2hipRename["CU_RES_VIEW_FORMAT_SINT_4X8"] = {"hipResViewFormatSignedChar4", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x06 // API_Runtime ANALOGUE (cudaResViewFormatSignedChar4 = 0x06) + cuda2hipRename["CU_RES_VIEW_FORMAT_UINT_1X16"] = {"hipResViewFormatUnsignedShort1", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x07 // API_Runtime ANALOGUE (cudaResViewFormatUnsignedShort1 = 0x07) + cuda2hipRename["CU_RES_VIEW_FORMAT_UINT_2X16"] = {"hipResViewFormatUnsignedShort2", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x08 // API_Runtime ANALOGUE (cudaResViewFormatUnsignedShort2 = 0x08) + cuda2hipRename["CU_RES_VIEW_FORMAT_UINT_4X16"] = {"hipResViewFormatUnsignedShort4", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x09 // API_Runtime ANALOGUE (cudaResViewFormatUnsignedShort4 = 0x09) + cuda2hipRename["CU_RES_VIEW_FORMAT_SINT_1X16"] = {"hipResViewFormatSignedShort1", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x0a // API_Runtime ANALOGUE (cudaResViewFormatSignedShort1 = 0x0a) + cuda2hipRename["CU_RES_VIEW_FORMAT_SINT_2X16"] = {"hipResViewFormatSignedShort2", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x0b // API_Runtime ANALOGUE (cudaResViewFormatSignedShort2 = 0x0b) + cuda2hipRename["CU_RES_VIEW_FORMAT_SINT_4X16"] = {"hipResViewFormatSignedShort4", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x0c // API_Runtime ANALOGUE (cudaResViewFormatSignedShort4 = 0x0c) + cuda2hipRename["CU_RES_VIEW_FORMAT_UINT_1X32"] = {"hipResViewFormatUnsignedInt1", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x0d // API_Runtime ANALOGUE (cudaResViewFormatUnsignedInt1 = 0x0d) + cuda2hipRename["CU_RES_VIEW_FORMAT_UINT_2X32"] = {"hipResViewFormatUnsignedInt2", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x0e // API_Runtime ANALOGUE (cudaResViewFormatUnsignedInt2 = 0x0e) + cuda2hipRename["CU_RES_VIEW_FORMAT_UINT_4X32"] = {"hipResViewFormatUnsignedInt4", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x0f // API_Runtime ANALOGUE (cudaResViewFormatUnsignedInt4 = 0x0f) + cuda2hipRename["CU_RES_VIEW_FORMAT_SINT_1X32"] = {"hipResViewFormatSignedInt1", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x10 // API_Runtime ANALOGUE (cudaResViewFormatSignedInt1 = 0x10) + cuda2hipRename["CU_RES_VIEW_FORMAT_SINT_2X32"] = {"hipResViewFormatSignedInt2", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x11 // API_Runtime ANALOGUE (cudaResViewFormatSignedInt2 = 0x11) + cuda2hipRename["CU_RES_VIEW_FORMAT_SINT_4X32"] = {"hipResViewFormatSignedInt4", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x12 // API_Runtime ANALOGUE (cudaResViewFormatSignedInt4 = 0x12) + cuda2hipRename["CU_RES_VIEW_FORMAT_FLOAT_1X16"] = {"hipResViewFormatHalf1", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x13 // API_Runtime ANALOGUE (cudaResViewFormatHalf1 = 0x13) + cuda2hipRename["CU_RES_VIEW_FORMAT_FLOAT_2X16"] = {"hipResViewFormatHalf2", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x14 // API_Runtime ANALOGUE (cudaResViewFormatHalf2 = 0x14) + cuda2hipRename["CU_RES_VIEW_FORMAT_FLOAT_4X16"] = {"hipResViewFormatHalf4", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x15 // API_Runtime ANALOGUE (cudaResViewFormatHalf4 = 0x15) + cuda2hipRename["CU_RES_VIEW_FORMAT_FLOAT_1X32"] = {"hipResViewFormatFloat1", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x16 // API_Runtime ANALOGUE (cudaResViewFormatFloat1 = 0x16) + cuda2hipRename["CU_RES_VIEW_FORMAT_FLOAT_2X32"] = {"hipResViewFormatFloat2", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x17 // API_Runtime ANALOGUE (cudaResViewFormatFloat2 = 0x17) + cuda2hipRename["CU_RES_VIEW_FORMAT_FLOAT_4X32"] = {"hipResViewFormatFloat4", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x18 // API_Runtime ANALOGUE (cudaResViewFormatFloat4 = 0x18) + cuda2hipRename["CU_RES_VIEW_FORMAT_UNSIGNED_BC1"] = {"hipResViewFormatUnsignedBlockCompressed1", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x19 // API_Runtime ANALOGUE (cudaResViewFormatUnsignedBlockCompressed1 = 0x19) + cuda2hipRename["CU_RES_VIEW_FORMAT_UNSIGNED_BC2"] = {"hipResViewFormatUnsignedBlockCompressed2", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x1a // API_Runtime ANALOGUE (cudaResViewFormatUnsignedBlockCompressed2 = 0x1a) + cuda2hipRename["CU_RES_VIEW_FORMAT_UNSIGNED_BC3"] = {"hipResViewFormatUnsignedBlockCompressed3", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x1b // API_Runtime ANALOGUE (cudaResViewFormatUnsignedBlockCompressed3 = 0x1b) + cuda2hipRename["CU_RES_VIEW_FORMAT_UNSIGNED_BC4"] = {"hipResViewFormatUnsignedBlockCompressed4", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x1c // API_Runtime ANALOGUE (cudaResViewFormatUnsignedBlockCompressed4 = 0x1c) + cuda2hipRename["CU_RES_VIEW_FORMAT_SIGNED_BC4"] = {"hipResViewFormatSignedBlockCompressed4", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x1d // API_Runtime ANALOGUE (cudaResViewFormatSignedBlockCompressed4 = 0x1d) + cuda2hipRename["CU_RES_VIEW_FORMAT_UNSIGNED_BC5"] = {"hipResViewFormatUnsignedBlockCompressed5", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x1e // API_Runtime ANALOGUE (cudaResViewFormatUnsignedBlockCompressed5 = 0x1e) + cuda2hipRename["CU_RES_VIEW_FORMAT_SIGNED_BC5"] = {"hipResViewFormatSignedBlockCompressed5", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x1f // API_Runtime ANALOGUE (cudaResViewFormatSignedBlockCompressed5 = 0x1f) + cuda2hipRename["CU_RES_VIEW_FORMAT_UNSIGNED_BC6H"] = {"hipResViewFormatUnsignedBlockCompressed6H", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x20 // API_Runtime ANALOGUE (cudaResViewFormatUnsignedBlockCompressed6H = 0x20) + cuda2hipRename["CU_RES_VIEW_FORMAT_SIGNED_BC6H"] = {"hipResViewFormatSignedBlockCompressed6H", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x21 // API_Runtime ANALOGUE (cudaResViewFormatSignedBlockCompressed6H = 0x21) + cuda2hipRename["CU_RES_VIEW_FORMAT_UNSIGNED_BC7"] = {"hipResViewFormatUnsignedBlockCompressed7", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x22 // API_Runtime ANALOGUE (cudaResViewFormatUnsignedBlockCompressed7 = 0x22) + + + + cuda2hipRename["CUsharedconfig_enum"] = {"hipSharedMemConfig", CONV_TYPE, API_DRIVER}; + cuda2hipRename["CUsharedconfig"] = {"hipSharedMemConfig", CONV_TYPE, API_DRIVER}; + cuda2hipRename["CU_SHARED_MEM_CONFIG_DEFAULT_BANK_SIZE"] = {"hipSharedMemBankSizeDefault", CONV_DEV, API_DRIVER}; + cuda2hipRename["CU_SHARED_MEM_CONFIG_FOUR_BYTE_BANK_SIZE"] = {"hipSharedMemBankSizeFourByte", CONV_DEV, API_DRIVER}; + cuda2hipRename["CU_SHARED_MEM_CONFIG_EIGHT_BYTE_BANK_SIZE"] = {"hipSharedMemBankSizeEightByte", CONV_DEV, API_DRIVER}; + + cuda2hipRename["CUcontext"] = {"hipCtx_t", CONV_TYPE, API_DRIVER}; // TODO: // cuda2hipRename["CUctx_st"] = {"XXXX", CONV_TYPE, API_DRIVER}; - cuda2hipRename["CUmodule"] = {"hipModule_t", CONV_TYPE, API_DRIVER}; + cuda2hipRename["CUmodule"] = {"hipModule_t", CONV_TYPE, API_DRIVER}; // TODO: // cuda2hipRename["CUmod_st"] = {"XXXX", CONV_TYPE, API_DRIVER}; - cuda2hipRename["CUstream"] = {"hipStream_t", CONV_TYPE, API_DRIVER}; + cuda2hipRename["CUstream"] = {"hipStream_t", CONV_TYPE, API_DRIVER}; // TODO: // cuda2hipRename["CUstream_st"] = {"XXXX", CONV_TYPE, API_DRIVER}; // Stream Flags - cuda2hipRename["CU_STREAM_DEFAULT"] = {"hipStreamDefault", CONV_STREAM, API_DRIVER}; - cuda2hipRename["CU_STREAM_NON_BLOCKING"] = {"hipStreamNonBlocking", CONV_STREAM, API_DRIVER}; + cuda2hipRename["CU_STREAM_DEFAULT"] = {"hipStreamDefault", CONV_STREAM, API_DRIVER}; + cuda2hipRename["CU_STREAM_NON_BLOCKING"] = {"hipStreamNonBlocking", CONV_STREAM, API_DRIVER}; // Init - cuda2hipRename["cuInit"] = {"hipInit", CONV_DRIVER, API_DRIVER}; + cuda2hipRename["cuInit"] = {"hipInit", CONV_DRIVER, API_DRIVER}; // Driver cuda2hipRename["cuDriverGetVersion"] = {"hipDriverGetVersion", CONV_DRIVER, API_DRIVER}; @@ -568,14 +816,17 @@ struct cuda2hipMap { // Events // pointer to CUevent_st cuda2hipRename["CUevent"] = {"hipEvent_t", CONV_TYPE, API_DRIVER}; - // ToDO: - // cuda2hipRename["CUevent_st"] = {"XXXX", CONV_TYPE, API_DRIVER}; + // ToDo: + // cuda2hipRename["CUevent_st"] = {"XXXX", CONV_TYPE, API_DRIVER}; // Event Flags + cuda2hipRename["CUevent_flags"] = {"hipEventFlags", CONV_EVENT, API_DRIVER, HIP_UNSUPPORTED}; + // ToDo: + // cuda2hipRename["CUevent_flags_enum"] = {"hipEventFlags", CONV_EVENT, API_DRIVER, HIP_UNSUPPORTED}; cuda2hipRename["CU_EVENT_DEFAULT"] = {"hipEventDefault", CONV_EVENT, API_DRIVER}; cuda2hipRename["CU_EVENT_BLOCKING_SYNC"] = {"hipEventBlockingSync", CONV_EVENT, API_DRIVER}; cuda2hipRename["CU_EVENT_DISABLE_TIMING"] = {"hipEventDisableTiming", CONV_EVENT, API_DRIVER}; cuda2hipRename["CU_EVENT_INTERPROCESS"] = {"hipEventInterprocess", CONV_EVENT, API_DRIVER}; - + // Event functions cuda2hipRename["cuEventCreate"] = {"hipEventCreate", CONV_EVENT, API_DRIVER}; cuda2hipRename["cuEventDestroy_v2"] = {"hipEventDestroy", CONV_EVENT, API_DRIVER}; cuda2hipRename["cuEventElapsedTime"] = {"hipEventElapsedTime", CONV_EVENT, API_DRIVER}; @@ -627,7 +878,7 @@ struct cuda2hipMap { cuda2hipRename["cuMemsetD16_v2"] = {"hipMemsetD16", CONV_STREAM, API_DRIVER, HIP_UNSUPPORTED}; cuda2hipRename["cuMemsetD16Async"] = {"hipMemsetD16Async", CONV_STREAM, API_DRIVER, HIP_UNSUPPORTED}; cuda2hipRename["cuMemsetD2D16_v2"] = {"hipMemsetD2D16", CONV_STREAM, API_DRIVER, HIP_UNSUPPORTED}; - cuda2hipRename["cuMemsetD2D16Async"] = {"hipMemsetD2D16Async", CONV_STREAM, API_DRIVER, HIP_UNSUPPORTED}; + cuda2hipRename["cuMemsetD2D16Async"] = {"hipMemsetD2D16Async", CONV_STREAM, API_DRIVER, HIP_UNSUPPORTED}; cuda2hipRename["cuMemsetD32_v2"] = {"hipMemset", CONV_MEM, API_DRIVER}; cuda2hipRename["cuMemsetD32Async"] = {"hipMemsetAsync", CONV_MEM, API_DRIVER}; @@ -639,6 +890,14 @@ struct cuda2hipMap { cuda2hipRename["cuMemHostRegister_v2"] = {"hipHostRegister", CONV_MEM, API_DRIVER}; cuda2hipRename["cuMemHostUnregister"] = {"hipHostUnregister", CONV_MEM, API_DRIVER}; + // Texture Reference Mngmnt + // Texture reference filtering modes + cuda2hipRename["CUfilter_mode"] = {"hipTextureFilterMode", CONV_TEX, API_DRIVER}; // API_Runtime ANALOGUE (cudaTextureFilterMode) + // ToDo: + // cuda2hipRename["CUfilter_mode"] = {"CUfilter_mode_enum", CONV_TEX, API_DRIVER}; // API_Runtime ANALOGUE (cudaTextureFilterMode) + cuda2hipRename["CU_TR_FILTER_MODE_POINT"] = {"hipFilterModePoint", CONV_TEX, API_DRIVER}; // 0 // API_Runtime ANALOGUE (cudaFilterModePoint = 0) + cuda2hipRename["CU_TR_FILTER_MODE_LINEAR"] = {"hipFilterModeLinear", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 1 // API_Runtime ANALOGUE (cudaFilterModeLinear = 1) + // Profiler // unsupported yet by HIP cuda2hipRename["cuProfilerInitialize"] = {"hipProfilerInitialize", CONV_OTHER, API_DRIVER, HIP_UNSUPPORTED}; @@ -676,6 +935,14 @@ struct cuda2hipMap { cuda2hipRename["MINOR_VERSION"] = {"hipLibraryMinorVersion", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; cuda2hipRename["PATCH_LEVEL"] = {"hipLibraryPatchVersion", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; + // defines + cuda2hipRename["cudaMemAttachGlobal"] = {"hipMemAttachGlobal", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; // 0x01 // API_Driver ANALOGUE (CU_MEM_ATTACH_GLOBAL = 0x1) + cuda2hipRename["cudaMemAttachHost"] = {"hipMemAttachHost", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; // 0x02 // API_Driver ANALOGUE (CU_MEM_ATTACH_HOST = 0x2) + cuda2hipRename["cudaMemAttachSingle"] = {"hipMemAttachSingle", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; // 0x04 // API_Driver ANALOGUE (CU_MEM_ATTACH_SINGLE = 0x4) + + cuda2hipRename["cudaOccupancyDefault"] = {"hipOccupancyDefault", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; // 0x00 // API_Driver ANALOGUE (CU_OCCUPANCY_DEFAULT = 0x0) + cuda2hipRename["cudaOccupancyDisableCachingOverride"] = {"hipOccupancyDisableCachingOverride", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; // 0x01 // API_Driver ANALOGUE (CU_OCCUPANCY_DISABLE_CACHING_OVERRIDE = 0x1) + // Error API cuda2hipRename["cudaGetLastError"] = {"hipGetLastError", CONV_ERR, API_RUNTIME}; cuda2hipRename["cudaPeekAtLastError"] = {"hipPeekAtLastError", CONV_ERR, API_RUNTIME}; @@ -766,7 +1033,7 @@ struct cuda2hipMap { cuda2hipRename["cudaHostAlloc"] = {"hipHostMalloc", CONV_MEM, API_RUNTIME}; // Memory types - cuda2hipRename["cudaMemoryType"] = {"hipMemoryType", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaMemoryType"] = {"hipMemoryType", CONV_MEM, API_RUNTIME}; // API_Driver ANALOGUE (no - CUmemorytype is not an analogue) cuda2hipRename["cudaMemoryTypeHost"] = {"hipMemoryTypeHost", CONV_MEM, API_RUNTIME}; cuda2hipRename["cudaMemoryTypeDevice"] = {"hipMemoryTypeDevice", CONV_MEM, API_RUNTIME}; @@ -838,7 +1105,6 @@ struct cuda2hipMap { cuda2hipRename["cudaEventBlockingSync"] = {"hipEventBlockingSync", CONV_EVENT, API_RUNTIME}; cuda2hipRename["cudaEventDisableTiming"] = {"hipEventDisableTiming", CONV_EVENT, API_RUNTIME}; cuda2hipRename["cudaEventInterprocess"] = {"hipEventInterprocess", CONV_EVENT, API_RUNTIME}; - // Streams cuda2hipRename["cudaStream_t"] = {"hipStream_t", CONV_TYPE, API_RUNTIME}; cuda2hipRename["cudaStreamCreate"] = {"hipStreamCreate", CONV_STREAM, API_RUNTIME}; @@ -874,93 +1140,94 @@ struct cuda2hipMap { // Attributes cuda2hipRename["cudaDeviceGetAttribute"] = {"hipDeviceGetAttribute", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDeviceAttr"] = {"hipDeviceAttribute_t", CONV_TYPE, API_RUNTIME}; - cuda2hipRename["cudaDevAttrMaxThreadsPerBlock"] = {"hipDeviceAttributeMaxThreadsPerBlock", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrMaxBlockDimX"] = {"hipDeviceAttributeMaxBlockDimX", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrMaxBlockDimY"] = {"hipDeviceAttributeMaxBlockDimY", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrMaxBlockDimZ"] = {"hipDeviceAttributeMaxBlockDimZ", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrMaxGridDimX"] = {"hipDeviceAttributeMaxGridDimX", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrMaxGridDimY"] = {"hipDeviceAttributeMaxGridDimY", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrMaxGridDimZ"] = {"hipDeviceAttributeMaxGridDimZ", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrMaxSharedMemoryPerBlock"] = {"hipDeviceAttributeMaxSharedMemoryPerBlock", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrTotalConstantMemory"] = {"hipDeviceAttributeTotalConstantMemory", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrWarpSize"] = {"hipDeviceAttributeWarpSize", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrMaxRegistersPerBlock"] = {"hipDeviceAttributeMaxRegistersPerBlock", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrClockRate"] = {"hipDeviceAttributeClockRate", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrMemoryClockRate"] = {"hipDeviceAttributeMemoryClockRate", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrGlobalMemoryBusWidth"] = {"hipDeviceAttributeMemoryBusWidth", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrMultiProcessorCount"] = {"hipDeviceAttributeMultiprocessorCount", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrComputeMode"] = {"hipDeviceAttributeComputeMode", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrL2CacheSize"] = {"hipDeviceAttributeL2CacheSize", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrMaxThreadsPerMultiProcessor"] = {"hipDeviceAttributeMaxThreadsPerMultiProcessor", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrComputeCapabilityMajor"] = {"hipDeviceAttributeComputeCapabilityMajor", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrComputeCapabilityMinor"] = {"hipDeviceAttributeComputeCapabilityMinor", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrConcurrentKernels"] = {"hipDeviceAttributeConcurrentKernels", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrPciBusId"] = {"hipDeviceAttributePciBusId", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrPciDeviceId"] = {"hipDeviceAttributePciDeviceId", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrMaxSharedMemoryPerMultiprocessor"] = {"hipDeviceAttributeMaxSharedMemoryPerMultiprocessor", CONV_DEV, API_RUNTIME}; - cuda2hipRename["cudaDevAttrIsMultiGpuBoard"] = {"hipDeviceAttributeIsMultiGpuBoard", CONV_DEV, API_RUNTIME}; - // unsupported yet by HIP - cuda2hipRename["cudaDevAttrMaxPitch"] = {"hipDeviceAttributeMaxPitch", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrTextureAlignment"] = {"hipDeviceAttributeTextureAlignment", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDeviceAttr"] = {"hipDeviceAttribute_t", CONV_TYPE, API_RUNTIME}; // API_DRIVER ANALOGUE (CUdevice_attribute) + cuda2hipRename["cudaDevAttrMaxThreadsPerBlock"] = {"hipDeviceAttributeMaxThreadsPerBlock", CONV_DEV, API_RUNTIME}; // 1 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_BLOCK = 1) + cuda2hipRename["cudaDevAttrMaxBlockDimX"] = {"hipDeviceAttributeMaxBlockDimX", CONV_DEV, API_RUNTIME}; // 2 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_X = 2) + cuda2hipRename["cudaDevAttrMaxBlockDimY"] = {"hipDeviceAttributeMaxBlockDimY", CONV_DEV, API_RUNTIME}; // 3 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Y = 3) + cuda2hipRename["cudaDevAttrMaxBlockDimZ"] = {"hipDeviceAttributeMaxBlockDimZ", CONV_DEV, API_RUNTIME}; // 4 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Z = 4) + cuda2hipRename["cudaDevAttrMaxGridDimX"] = {"hipDeviceAttributeMaxGridDimX", CONV_DEV, API_RUNTIME}; // 5 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_X = 5) + cuda2hipRename["cudaDevAttrMaxGridDimY"] = {"hipDeviceAttributeMaxGridDimY", CONV_DEV, API_RUNTIME}; // 6 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_X = 6) + cuda2hipRename["cudaDevAttrMaxGridDimZ"] = {"hipDeviceAttributeMaxGridDimZ", CONV_DEV, API_RUNTIME}; // 7 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_X = 7) + cuda2hipRename["cudaDevAttrMaxSharedMemoryPerBlock"] = {"hipDeviceAttributeMaxSharedMemoryPerBlock", CONV_DEV, API_RUNTIME}; // 8 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK = 8) + cuda2hipRename["cudaDevAttrTotalConstantMemory"] = {"hipDeviceAttributeTotalConstantMemory", CONV_DEV, API_RUNTIME}; // 9 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_TOTAL_CONSTANT_MEMORY =9) + cuda2hipRename["cudaDevAttrWarpSize"] = {"hipDeviceAttributeWarpSize", CONV_DEV, API_RUNTIME}; // 10 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_WARP_SIZE = 10) + cuda2hipRename["cudaDevAttrMaxPitch"] = {"hipDeviceAttributeMaxPitch", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 11 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAX_PITCH = 11) + cuda2hipRename["cudaDevAttrMaxRegistersPerBlock"] = {"hipDeviceAttributeMaxRegistersPerBlock", CONV_DEV, API_RUNTIME}; // 12 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_BLOCK = 12) + cuda2hipRename["cudaDevAttrClockRate"] = {"hipDeviceAttributeClockRate", CONV_DEV, API_RUNTIME}; // 13 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_CLOCK_RATE = 13) + cuda2hipRename["cudaDevAttrTextureAlignment"] = {"hipDeviceAttributeTextureAlignment", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 14 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_TEXTURE_ALIGNMENT = 14) // Is not deprecated as CUDA Driver's API analogue CU_DEVICE_ATTRIBUTE_GPU_OVERLAP - cuda2hipRename["cudaDevAttrGpuOverlap"] = {"hipDeviceAttributeGpuOverlap", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrKernelExecTimeout"] = {"hipDeviceAttributeKernelExecTimeout", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrIntegrated"] = {"hipDeviceAttributeIntegrated", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrCanMapHostMemory"] = {"hipDeviceAttributeCanMapHostMemory", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrMaxTexture1DWidth"] = {"hipDeviceAttributeMaxTexture1DWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrMaxTexture2DWidth"] = {"hipDeviceAttributeMaxTexture2DWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrMaxTexture2DHeight"] = {"hipDeviceAttributeMaxTexture2DHeight", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrMaxTexture3DWidth"] = {"hipDeviceAttributeMaxTexture3DWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrMaxTexture3DHeight"] = {"hipDeviceAttributeMaxTexture3DHeight", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrMaxTexture3DDepth"] = {"hipDeviceAttributeMaxTexture3DDepth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrMaxTexture2DLayeredWidth"] = {"hipDeviceAttributeMaxTexture2DLayeredWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrMaxTexture2DLayeredHeight"] = {"hipDeviceAttributeMaxTexture2DLayeredHeight", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrMaxTexture2DLayeredLayers"] = {"hipDeviceAttributeMaxTexture2DLayeredLayers", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrSurfaceAlignment"] = {"hipDeviceAttributeSurfaceAlignment", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrEccEnabled"] = {"hipDeviceAttributeEccEnabled", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrTccDriver"] = {"hipDeviceAttributeTccDriver", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrAsyncEngineCount"] = {"hipDevAttrAsyncEngineCount", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrUnifiedAddressing"] = {"hipDeviceAttributeUnifiedAddressing", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrMaxTexture1DLayeredWidth"] = {"hipDeviceAttributeMaxTexture1DLayeredWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrMaxTexture1DLayeredLayers"] = {"hipDeviceAttributeMaxTexture1DLayeredLayers", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrMaxTexture2DGatherWidth"] = {"hipDeviceAttributeMaxTexture2DGatherWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrMaxTexture2DGatherHeight"] = {"hipDeviceAttributeMaxTexture2DGatherHeight", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrMaxTexture3DWidthAlt"] = {"hipDeviceAttributeMaxTexture3DWidthAlternate", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrMaxTexture3DHeightAlt"] = {"hipDeviceAttributeMaxTexture3DHeightAlternate", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrMaxTexture3DDepthAlt"] = {"hipDeviceAttributeMaxTexture3DDepthAlternate", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrPciDomainId"] = {"hipDeviceAttributePciDomainId", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrTexturePitchAlignment"] = {"hipDeviceAttributeTexturePitchAlignment", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrMaxTextureCubemapWidth"] = {"hipDeviceAttributeMaxTextureCubemapWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrMaxTextureCubemapLayeredWidth"] = {"hipDeviceAttributeMaxTextureCubemapLayeredWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrMaxTextureCubemapLayeredLayers"] = {"hipDeviceAttributeMaxTextureCubemapLayeredLayers", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrMaxSurface1DWidth"] = {"hipDeviceAttributeMaxSurface1DWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrMaxSurface2DWidth"] = {"hipDeviceAttributeMaxSurface2DWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrMaxSurface2DHeight"] = {"hipDeviceAttributeMaxSurface2DHeight", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrMaxSurface3DWidth"] = {"hipDeviceAttributeMaxSurface3DWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrMaxSurface3DHeight"] = {"hipDeviceAttributeMaxSurface3DHeight", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrMaxSurface3DDepth"] = {"hipDeviceAttributeMaxSurface3DDepth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrMaxSurface1DLayeredWidth"] = {"hipDeviceAttributeMaxSurface1DLayeredWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrMaxSurface1DLayeredLayers"] = {"hipDeviceAttributeMaxSurface1DLayeredLayers", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrMaxSurface2DLayeredWidth"] = {"hipDeviceAttributeMaxSurface2DLayeredWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrMaxSurface2DLayeredHeight"] = {"hipDeviceAttributeMaxSurface2DLayeredHeight", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrMaxSurface2DLayeredLayers"] = {"hipDeviceAttributeMaxSurface2DLayeredLayers", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrMaxSurfaceCubemapWidth"] = {"hipDeviceAttributeMaxSurfaceCubemapWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrMaxSurfaceCubemapLayeredWidth"] = {"hipDeviceAttributeMaxSurfaceCubemapLayeredWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrMaxSurfaceCubemapLayeredLayers"] = {"hipDeviceAttributeMaxSurfaceCubemapLayeredLayers", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrMaxTexture1DLinearWidth"] = {"hipDeviceAttributeMaxTexture1DLinearWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrMaxTexture2DLinearWidth"] = {"hipDeviceAttributeMaxTexture2DLinearWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrMaxTexture2DLinearHeight"] = {"hipDeviceAttributeMaxTexture2DLinearHeight", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrMaxTexture2DLinearPitch"] = {"hipDeviceAttributeMaxTexture2DLinearPitch", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrMaxTexture2DMipmappedWidth"] = {"hipDeviceAttributeMaxTexture2DMipmappedWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrMaxTexture2DMipmappedHeight"] = {"hipDeviceAttributeMaxTexture2DMipmappedHeight", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrMaxTexture1DMipmappedWidth"] = {"hipDeviceAttributeMaxTexture1DMipmappedWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrStreamPrioritiesSupported"] = {"hipDeviceAttributeStreamPrioritiesSupported", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrGlobalL1CacheSupported"] = {"hipDeviceAttributeGlobalL1CacheSupported", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrLocalL1CacheSupported"] = {"hipDeviceAttributeLocalL1CacheSupported", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrMaxRegistersPerMultiprocessor"] = {"hipDeviceAttributeMaxRegistersPerMultiprocessor", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrManagedMemory"] = {"hipDeviceAttributeManagedMemory", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaDevAttrMultiGpuBoardGroupID"] = {"hipDeviceAttributeMultiGpuBoardGroupID", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaDevAttrGpuOverlap"] = {"hipDeviceAttributeGpuOverlap", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 15 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_GPU_OVERLAP = 15) + cuda2hipRename["cudaDevAttrMultiProcessorCount"] = {"hipDeviceAttributeMultiprocessorCount", CONV_DEV, API_RUNTIME}; // 16 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT = 16) + cuda2hipRename["cudaDevAttrKernelExecTimeout"] = {"hipDeviceAttributeKernelExecTimeout", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 17 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_KERNEL_EXEC_TIMEOUT = 17) + cuda2hipRename["cudaDevAttrIntegrated"] = {"hipDeviceAttributeIntegrated", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 18 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_INTEGRATED = 18) + cuda2hipRename["cudaDevAttrCanMapHostMemory"] = {"hipDeviceAttributeCanMapHostMemory", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 19 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_CAN_MAP_HOST_MEMORY = 19) + cuda2hipRename["cudaDevAttrComputeMode"] = {"hipDeviceAttributeComputeMode", CONV_DEV, API_RUNTIME}; // 20 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_COMPUTE_MODE = 20) + cuda2hipRename["cudaDevAttrMaxTexture1DWidth"] = {"hipDeviceAttributeMaxTexture1DWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 21 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_WIDTH = 21) + cuda2hipRename["cudaDevAttrMaxTexture2DWidth"] = {"hipDeviceAttributeMaxTexture2DWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 22 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_WIDTH = 22) + cuda2hipRename["cudaDevAttrMaxTexture2DHeight"] = {"hipDeviceAttributeMaxTexture2DHeight", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 23 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_HEIGHT = 23) + cuda2hipRename["cudaDevAttrMaxTexture3DWidth"] = {"hipDeviceAttributeMaxTexture3DWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 24 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_WIDTH = 24) + cuda2hipRename["cudaDevAttrMaxTexture3DHeight"] = {"hipDeviceAttributeMaxTexture3DHeight", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 25 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_HEIGHT = 25) + cuda2hipRename["cudaDevAttrMaxTexture3DDepth"] = {"hipDeviceAttributeMaxTexture3DDepth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 26 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_DEPTH = 26) + cuda2hipRename["cudaDevAttrMaxTexture2DLayeredWidth"] = {"hipDeviceAttributeMaxTexture2DLayeredWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 27 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_WIDTH = 27) + cuda2hipRename["cudaDevAttrMaxTexture2DLayeredHeight"] = {"hipDeviceAttributeMaxTexture2DLayeredHeight", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 28 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_HEIGHT = 28) + cuda2hipRename["cudaDevAttrMaxTexture2DLayeredLayers"] = {"hipDeviceAttributeMaxTexture2DLayeredLayers", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 29 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LAYERED_LAYERS = 29) + cuda2hipRename["cudaDevAttrSurfaceAlignment"] = {"hipDeviceAttributeSurfaceAlignment", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 30 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_SURFACE_ALIGNMENT = 30) + cuda2hipRename["cudaDevAttrConcurrentKernels"] = {"hipDeviceAttributeConcurrentKernels", CONV_DEV, API_RUNTIME}; // 31 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_CONCURRENT_KERNELS = 31) + cuda2hipRename["cudaDevAttrEccEnabled"] = {"hipDeviceAttributeEccEnabled", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 32 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_ECC_ENABLED = 32) + cuda2hipRename["cudaDevAttrPciBusId"] = {"hipDeviceAttributePciBusId", CONV_DEV, API_RUNTIME}; // 33 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_PCI_BUS_ID = 33) + cuda2hipRename["cudaDevAttrPciDeviceId"] = {"hipDeviceAttributePciDeviceId", CONV_DEV, API_RUNTIME}; // 34 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_PCI_DEVICE_ID = 34) + cuda2hipRename["cudaDevAttrTccDriver"] = {"hipDeviceAttributeTccDriver", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 35 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_TCC_DRIVER = 35) + cuda2hipRename["cudaDevAttrMemoryClockRate"] = {"hipDeviceAttributeMemoryClockRate", CONV_DEV, API_RUNTIME}; // 36 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MEMORY_CLOCK_RATE = 36) + cuda2hipRename["cudaDevAttrGlobalMemoryBusWidth"] = {"hipDeviceAttributeMemoryBusWidth", CONV_DEV, API_RUNTIME}; // 37 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_GLOBAL_MEMORY_BUS_WIDTH = 37) + cuda2hipRename["cudaDevAttrL2CacheSize"] = {"hipDeviceAttributeL2CacheSize", CONV_DEV, API_RUNTIME}; // 38 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_L2_CACHE_SIZE = 38) + cuda2hipRename["cudaDevAttrMaxThreadsPerMultiProcessor"] = {"hipDeviceAttributeMaxThreadsPerMultiProcessor", CONV_DEV, API_RUNTIME}; // 39 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_MULTIPROCESSOR = 39) + cuda2hipRename["cudaDevAttrAsyncEngineCount"] = {"hipDeviceAttributeAsyncEngineCount", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 40 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_ASYNC_ENGINE_COUNT = 40) + cuda2hipRename["cudaDevAttrUnifiedAddressing"] = {"hipDeviceAttributeUnifiedAddressing", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 41 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_UNIFIED_ADDRESSING = 41) + cuda2hipRename["cudaDevAttrMaxTexture1DLayeredWidth"] = {"hipDeviceAttributeMaxTexture1DLayeredWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 42 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LAYERED_WIDTH = 42) + cuda2hipRename["cudaDevAttrMaxTexture1DLayeredLayers"] = {"hipDeviceAttributeMaxTexture1DLayeredLayers", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 43 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LAYERED_LAYERS = 43) + // 44 - no + cuda2hipRename["cudaDevAttrMaxTexture2DGatherWidth"] = {"hipDeviceAttributeMaxTexture2DGatherWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 45 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_GATHER_WIDTH = 45) + cuda2hipRename["cudaDevAttrMaxTexture2DGatherHeight"] = {"hipDeviceAttributeMaxTexture2DGatherHeight", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 46 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_GATHER_HEIGHT = 46) + cuda2hipRename["cudaDevAttrMaxTexture3DWidthAlt"] = {"hipDeviceAttributeMaxTexture3DWidthAlternate", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 47 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_WIDTH_ALTERNATE = 47) + cuda2hipRename["cudaDevAttrMaxTexture3DHeightAlt"] = {"hipDeviceAttributeMaxTexture3DHeightAlternate", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 48 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_HEIGHT_ALTERNATE = 48) + cuda2hipRename["cudaDevAttrMaxTexture3DDepthAlt"] = {"hipDeviceAttributeMaxTexture3DDepthAlternate", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 49 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_DEPTH_ALTERNATE = 49) + cuda2hipRename["cudaDevAttrPciDomainId"] = {"hipDeviceAttributePciDomainId", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 50 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_PCI_DOMAIN_ID = 50) + cuda2hipRename["cudaDevAttrTexturePitchAlignment"] = {"hipDeviceAttributeTexturePitchAlignment", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 51 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_TEXTURE_PITCH_ALIGNMENT = 51) + cuda2hipRename["cudaDevAttrMaxTextureCubemapWidth"] = {"hipDeviceAttributeMaxTextureCubemapWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 52 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURECUBEMAP_WIDTH = 52) + cuda2hipRename["cudaDevAttrMaxTextureCubemapLayeredWidth"] = {"hipDeviceAttributeMaxTextureCubemapLayeredWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 53 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURECUBEMAP_LAYERED_WIDTH = 53) + cuda2hipRename["cudaDevAttrMaxTextureCubemapLayeredLayers"] = {"hipDeviceAttributeMaxTextureCubemapLayeredLayers", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 54 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURECUBEMAP_LAYERED_LAYERS = 54) + cuda2hipRename["cudaDevAttrMaxSurface1DWidth"] = {"hipDeviceAttributeMaxSurface1DWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 55 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE1D_WIDTH = 55) + cuda2hipRename["cudaDevAttrMaxSurface2DWidth"] = {"hipDeviceAttributeMaxSurface2DWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 56 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_WIDTH = 56) + cuda2hipRename["cudaDevAttrMaxSurface2DHeight"] = {"hipDeviceAttributeMaxSurface2DHeight", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 57 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_HEIGHT = 57) + cuda2hipRename["cudaDevAttrMaxSurface3DWidth"] = {"hipDeviceAttributeMaxSurface3DWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 58 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE3D_WIDTH = 58) + cuda2hipRename["cudaDevAttrMaxSurface3DHeight"] = {"hipDeviceAttributeMaxSurface3DHeight", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 59 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE3D_HEIGHT = 59) + cuda2hipRename["cudaDevAttrMaxSurface3DDepth"] = {"hipDeviceAttributeMaxSurface3DDepth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 60 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE3D_DEPTH = 60) + cuda2hipRename["cudaDevAttrMaxSurface1DLayeredWidth"] = {"hipDeviceAttributeMaxSurface1DLayeredWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 61 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE1D_LAYERED_WIDTH = 61) + cuda2hipRename["cudaDevAttrMaxSurface1DLayeredLayers"] = {"hipDeviceAttributeMaxSurface1DLayeredLayers", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 62 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE1D_LAYERED_LAYERS = 62) + cuda2hipRename["cudaDevAttrMaxSurface2DLayeredWidth"] = {"hipDeviceAttributeMaxSurface2DLayeredWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 63 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_WIDTH = 63) + cuda2hipRename["cudaDevAttrMaxSurface2DLayeredHeight"] = {"hipDeviceAttributeMaxSurface2DLayeredHeight", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 64 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_HEIGHT = 64) + cuda2hipRename["cudaDevAttrMaxSurface2DLayeredLayers"] = {"hipDeviceAttributeMaxSurface2DLayeredLayers", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 65 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_LAYERS = 65) + cuda2hipRename["cudaDevAttrMaxSurfaceCubemapWidth"] = {"hipDeviceAttributeMaxSurfaceCubemapWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 66 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_WIDTH = 66) + cuda2hipRename["cudaDevAttrMaxSurfaceCubemapLayeredWidth"] = {"hipDeviceAttributeMaxSurfaceCubemapLayeredWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 67 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_LAYERED_WIDTH = 67) + cuda2hipRename["cudaDevAttrMaxSurfaceCubemapLayeredLayers"] = {"hipDeviceAttributeMaxSurfaceCubemapLayeredLayers", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 68 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_LAYERED_LAYERS = 68) + cuda2hipRename["cudaDevAttrMaxTexture1DLinearWidth"] = {"hipDeviceAttributeMaxTexture1DLinearWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 69 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LINEAR_WIDTH = 69) + cuda2hipRename["cudaDevAttrMaxTexture2DLinearWidth"] = {"hipDeviceAttributeMaxTexture2DLinearWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 70 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_WIDTH = 70) + cuda2hipRename["cudaDevAttrMaxTexture2DLinearHeight"] = {"hipDeviceAttributeMaxTexture2DLinearHeight", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 71 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_HEIGHT = 71) + cuda2hipRename["cudaDevAttrMaxTexture2DLinearPitch"] = {"hipDeviceAttributeMaxTexture2DLinearPitch", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 72 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_LINEAR_PITCH = 72) + cuda2hipRename["cudaDevAttrMaxTexture2DMipmappedWidth"] = {"hipDeviceAttributeMaxTexture2DMipmappedWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 73 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_MIPMAPPED_WIDTH = 73) + cuda2hipRename["cudaDevAttrMaxTexture2DMipmappedHeight"] = {"hipDeviceAttributeMaxTexture2DMipmappedHeight", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 74 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_MIPMAPPED_HEIGHT = 74) + cuda2hipRename["cudaDevAttrComputeCapabilityMajor"] = {"hipDeviceAttributeComputeCapabilityMajor", CONV_DEV, API_RUNTIME}; // 75 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR = 75) + cuda2hipRename["cudaDevAttrComputeCapabilityMinor"] = {"hipDeviceAttributeComputeCapabilityMinor", CONV_DEV, API_RUNTIME}; // 76 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR = 76) + cuda2hipRename["cudaDevAttrMaxTexture1DMipmappedWidth"] = {"hipDeviceAttributeMaxTexture1DMipmappedWidth", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 77 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_MIPMAPPED_WIDTH = 77) + cuda2hipRename["cudaDevAttrStreamPrioritiesSupported"] = {"hipDeviceAttributeStreamPrioritiesSupported", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 78 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_STREAM_PRIORITIES_SUPPORTED = 78) + cuda2hipRename["cudaDevAttrGlobalL1CacheSupported"] = {"hipDeviceAttributeGlobalL1CacheSupported", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 79 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_GLOBAL_L1_CACHE_SUPPORTED = 79) + cuda2hipRename["cudaDevAttrLocalL1CacheSupported"] = {"hipDeviceAttributeLocalL1CacheSupported", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 80 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_LOCAL_L1_CACHE_SUPPORTED = 80) + cuda2hipRename["cudaDevAttrMaxSharedMemoryPerMultiprocessor"] = {"hipDeviceAttributeMaxSharedMemoryPerMultiprocessor", CONV_DEV, API_RUNTIME}; // 81 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_MULTIPROCESSOR = 81) + cuda2hipRename["cudaDevAttrMaxRegistersPerMultiprocessor"] = {"hipDeviceAttributeMaxRegistersPerMultiprocessor", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 82 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_MULTIPROCESSOR = 82) + cuda2hipRename["cudaDevAttrManagedMemory"] = {"hipDeviceAttributeManagedMemory", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 83 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MANAGED_MEMORY = 83) + cuda2hipRename["cudaDevAttrIsMultiGpuBoard"] = {"hipDeviceAttributeIsMultiGpuBoard", CONV_DEV, API_RUNTIME}; // 84 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MULTI_GPU_BOARD = 84) + cuda2hipRename["cudaDevAttrMultiGpuBoardGroupID"] = {"hipDeviceAttributeMultiGpuBoardGroupID", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 85 // API_DRIVER ANALOGUE (CU_DEVICE_ATTRIBUTE_MULTI_GPU_BOARD_GROUP_ID = 85) + // unsupported yet by HIP [CUDA 8.0.44] cuda2hipRename["cudaDevAttrHostNativeAtomicSupported"] = {"hipDeviceAttributeHostNativeAtomicSupported", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; cuda2hipRename["cudaDevAttrSingleToDoublePrecisionPerfRatio"] = {"hipDeviceAttributeSingleToDoublePrecisionPerfRatio", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; @@ -970,10 +1237,11 @@ struct cuda2hipMap { cuda2hipRename["cudaDevAttrCanUseHostPointerForRegisteredMem"] = {"hipDeviceAttributeCanUseHostPointerForRegisteredMem", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // Pointer Attributes - cuda2hipRename["cudaPointerAttributes"] = {"hipPointerAttribute_t", CONV_TYPE, API_RUNTIME}; - cuda2hipRename["cudaPointerGetAttributes"] = {"hipPointerGetAttributes", CONV_MEM, API_RUNTIME}; + // struct cudaPointerAttributes + cuda2hipRename["cudaPointerAttributes"] = {"hipPointerAttribute_t", CONV_TYPE, API_RUNTIME}; + cuda2hipRename["cudaPointerGetAttributes"] = {"hipPointerGetAttributes", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaHostGetDevicePointer"] = {"hipHostGetDevicePointer", CONV_MEM, API_RUNTIME}; + cuda2hipRename["cudaHostGetDevicePointer"] = {"hipHostGetDevicePointer", CONV_MEM, API_RUNTIME}; // Device cuda2hipRename["cudaDeviceProp"] = {"hipDeviceProp_t", CONV_TYPE, API_RUNTIME}; @@ -985,11 +1253,11 @@ struct cuda2hipMap { cuda2hipRename["cudaSetValidDevices"] = {"hipSetValidDevices", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // Compute mode - cuda2hipRename["cudaComputeMode"] = {"hipComputeMode", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaComputeModeDefault"] = {"hipComputeModeDefault", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaComputeModeExclusive"] = {"hipComputeModeExclusive", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaComputeModeProhibited"] = {"hipComputeModeProhibited", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaComputeModeExclusiveProcess"] = {"hipComputeModeExclusiveProcess", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaComputeMode"] = {"hipComputeMode", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // API_DRIVER ANALOGUE (CUcomputemode) + cuda2hipRename["cudaComputeModeDefault"] = {"hipComputeModeDefault", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 0 + cuda2hipRename["cudaComputeModeExclusive"] = {"hipComputeModeExclusive", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 1 + cuda2hipRename["cudaComputeModeProhibited"] = {"hipComputeModeProhibited", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 2 + cuda2hipRename["cudaComputeModeExclusiveProcess"] = {"hipComputeModeExclusiveProcess", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; // 3 // Device Flags // unsupported yet by HIP @@ -1020,11 +1288,11 @@ struct cuda2hipMap { // Execution control // CUDA function cache configurations - cuda2hipRename["cudaFuncCache"] = {"hipFuncCache_t", CONV_CACHE, API_RUNTIME}; - cuda2hipRename["cudaFuncCachePreferNone"] = {"hipFuncCachePreferNone", CONV_CACHE, API_RUNTIME}; - cuda2hipRename["cudaFuncCachePreferShared"] = {"hipFuncCachePreferShared", CONV_CACHE, API_RUNTIME}; - cuda2hipRename["cudaFuncCachePreferL1"] = {"hipFuncCachePreferL1", CONV_CACHE, API_RUNTIME}; - cuda2hipRename["cudaFuncCachePreferEqual"] = {"hipFuncCachePreferEqual", CONV_CACHE, API_RUNTIME}; + cuda2hipRename["cudaFuncCache"] = {"hipFuncCache_t", CONV_CACHE, API_RUNTIME}; // API_Driver ANALOGUE (CUfunc_cache) + cuda2hipRename["cudaFuncCachePreferNone"] = {"hipFuncCachePreferNone", CONV_CACHE, API_RUNTIME}; // 0 // API_Driver ANALOGUE (CU_FUNC_CACHE_PREFER_NONE = 0x00) + cuda2hipRename["cudaFuncCachePreferShared"] = {"hipFuncCachePreferShared", CONV_CACHE, API_RUNTIME}; // 1 // API_Driver ANALOGUE (CU_FUNC_CACHE_PREFER_SHARED = 0x01) + cuda2hipRename["cudaFuncCachePreferL1"] = {"hipFuncCachePreferL1", CONV_CACHE, API_RUNTIME}; // 2 // API_Driver ANALOGUE (CU_FUNC_CACHE_PREFER_L1 = 0x02) + cuda2hipRename["cudaFuncCachePreferEqual"] = {"hipFuncCachePreferEqual", CONV_CACHE, API_RUNTIME}; // 3 // API_Driver ANALOGUE (CU_FUNC_CACHE_PREFER_EQUAL = 0x03) // Execution control functions // unsupported yet by HIP @@ -1062,7 +1330,9 @@ struct cuda2hipMap { cuda2hipRename["cudaDeviceEnablePeerAccess"] = {"hipDeviceEnablePeerAccess", CONV_DEV, API_RUNTIME}; cuda2hipRename["cudaMemcpyPeerAsync"] = {"hipMemcpyPeerAsync", CONV_MEM, API_RUNTIME}; cuda2hipRename["cudaMemcpyPeer"] = {"hipMemcpyPeer", CONV_MEM, API_RUNTIME}; - cuda2hipRename["cudaIpcMemLazyEnablePeerAccess"] = {"hipIpcMemLazyEnablePeerAccess", CONV_ERR, API_RUNTIME}; + + // #define cudaIpcMemLazyEnablePeerAccess 0x01 + cuda2hipRename["cudaIpcMemLazyEnablePeerAccess"] = {"hipIpcMemLazyEnablePeerAccess", CONV_TYPE, API_RUNTIME}; // 0x01 // API_Driver ANALOGUE (CU_IPC_MEM_LAZY_ENABLE_PEER_ACCESS = 0x1) // Shared memory cuda2hipRename["cudaDeviceSetSharedMemConfig"] = {"hipDeviceSetSharedMemConfig", CONV_DEV, API_RUNTIME}; @@ -1078,14 +1348,12 @@ struct cuda2hipMap { cuda2hipRename["cudaSharedMemBankSizeEightByte"] = {"hipSharedMemBankSizeEightByte", CONV_DEV, API_RUNTIME}; // Limits - cuda2hipRename["cudaLimit"] = {"hipLimit_t", CONV_DEV, API_RUNTIME}; - // unsupported yet by HIP - cuda2hipRename["cudaLimitStackSize"] = {"hipLimitStackSize", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaLimitPrintfFifoSize"] = {"hipLimitPrintfFifoSize", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaLimitMallocHeapSize"] = {"hipLimitMallocHeapSize", CONV_DEV, API_RUNTIME}; - // unsupported yet by HIP - cuda2hipRename["cudaLimitDevRuntimeSyncDepth"] = {"hipLimitPrintfFifoSize", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaLimitDevRuntimePendingLaunchCount"] = {"hipLimitMallocHeapSize", CONV_DEV, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaLimit"] = {"hipLimit_t", CONV_TYPE, API_RUNTIME}; // API_Driver ANALOGUE (CUlimit) + cuda2hipRename["cudaLimitStackSize"] = {"hipLimitStackSize", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; // 0x00 // API_Driver ANALOGUE (CU_LIMIT_STACK_SIZE = 0x00) + cuda2hipRename["cudaLimitPrintfFifoSize"] = {"hipLimitPrintfFifoSize", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; // 0x01 // API_Driver ANALOGUE (CU_LIMIT_PRINTF_FIFO_SIZE = 0x01) + cuda2hipRename["cudaLimitMallocHeapSize"] = {"hipLimitMallocHeapSize", CONV_TYPE, API_RUNTIME}; // 0x02 // API_Driver ANALOGUE (CU_LIMIT_MALLOC_HEAP_SIZE = 0x02) + cuda2hipRename["cudaLimitDevRuntimeSyncDepth"] = {"hipLimitDevRuntimeSyncDepth", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; // 0x03 // API_Driver ANALOGUE (CU_LIMIT_DEV_RUNTIME_SYNC_DEPTH = 0x03) + cuda2hipRename["cudaLimitDevRuntimePendingLaunchCount"] = {"hipLimitDevRuntimePendingLaunchCount", CONV_TYPE, API_RUNTIME, HIP_UNSUPPORTED}; // 0x04 // API_Driver ANALOGUE (CU_LIMIT_DEV_RUNTIME_PENDING_LAUNCH_COUNT = 0x04) cuda2hipRename["cudaDeviceGetLimit"] = {"hipDeviceGetLimit", CONV_DEV, API_RUNTIME}; @@ -1108,10 +1376,9 @@ struct cuda2hipMap { // unsupported yet by HIP cuda2hipRename["cudaReadModeNormalizedFloat"] = {"hipReadModeNormalizedFloat", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaTextureFilterMode"] = {"hipTextureFilterMode", CONV_TEX, API_RUNTIME}; - cuda2hipRename["cudaFilterModePoint"] = {"hipFilterModePoint", CONV_TEX, API_RUNTIME}; - // unsupported yet by HIP - cuda2hipRename["cudaFilterModeLinear"] = {"hipFilterModeLinear", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + cuda2hipRename["cudaTextureFilterMode"] = {"hipTextureFilterMode", CONV_TEX, API_RUNTIME}; // API_DRIVER ANALOGUE (CUfilter_mode) + cuda2hipRename["cudaFilterModePoint"] = {"hipFilterModePoint", CONV_TEX, API_RUNTIME}; // 0 // API_DRIVER ANALOGUE (CU_TR_FILTER_MODE_POINT = 0) + cuda2hipRename["cudaFilterModeLinear"] = {"hipFilterModeLinear", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 1 // API_DRIVER ANALOGUE (CU_TR_FILTER_MODE_POINT = 1) cuda2hipRename["cudaBindTexture"] = {"hipBindTexture", CONV_TEX, API_RUNTIME}; cuda2hipRename["cudaUnbindTexture"] = {"hipUnbindTexture", CONV_TEX, API_RUNTIME}; @@ -1131,7 +1398,7 @@ struct cuda2hipMap { cuda2hipRename["cudaChannelFormatDesc"] = {"hipChannelFormatDesc", CONV_TEX, API_RUNTIME}; cuda2hipRename["cudaCreateChannelDesc"] = {"hipCreateChannelDesc", CONV_TEX, API_RUNTIME}; // unsupported yet by HIP - cuda2hipRename["cudaGetChannelDesc"] = {"hipGetChannelDesc", CONV_TEX, API_RUNTIME}; + cuda2hipRename["cudaGetChannelDesc"] = {"hipGetChannelDesc", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // Texture Object Management // structs @@ -1139,49 +1406,52 @@ struct cuda2hipMap { cuda2hipRename["cudaResourceDesc"] = {"hipResourceDesc", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; cuda2hipRename["cudaResourceViewDesc"] = {"hipResourceViewDesc", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; cuda2hipRename["cudaTextureDesc"] = {"hipTextureDesc", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; - // enums - // unsupported yet by HIP - cuda2hipRename["cudaResourceType"] = {"hipResourceType", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaResourceTypeArray"] = {"hipResourceTypeArray", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaResourceTypeMipmappedArray"] = {"hipResourceTypeMipmappedArray", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaResourceTypeLinear"] = {"hipResourceTypeLinear", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaResourceTypePitch2D"] = {"hipResourceTypePitch2D", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaResourceViewFormat"] = {"hipResourceViewFormat", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaResViewFormatNone"] = {"hipResViewFormatNone", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaResViewFormatUnsignedChar1"] = {"hipResViewFormatUnsignedChar1", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaResViewFormatUnsignedChar2"] = {"hipResViewFormatUnsignedChar2", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaResViewFormatUnsignedChar4"] = {"hipResViewFormatUnsignedChar4", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaResViewFormatSignedChar1"] = {"hipResViewFormatSignedChar1", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaResViewFormatSignedChar2"] = {"hipResViewFormatSignedChar2", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaResViewFormatSignedChar4"] = {"hipResViewFormatSignedChar4", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaResViewFormatUnsignedShort1"] = {"hipResViewFormatUnsignedShort1", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaResViewFormatUnsignedShort2"] = {"hipResViewFormatUnsignedShort2", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaResViewFormatUnsignedShort4"] = {"hipResViewFormatUnsignedShort4", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaResViewFormatSignedShort1"] = {"hipResViewFormatSignedShort1", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaResViewFormatSignedShort2"] = {"hipResViewFormatSignedShort2", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaResViewFormatSignedShort4"] = {"hipResViewFormatSignedShort4", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaResViewFormatUnsignedInt1"] = {"hipResViewFormatUnsignedInt1", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaResViewFormatUnsignedInt2"] = {"hipResViewFormatUnsignedInt2", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaResViewFormatUnsignedInt4"] = {"hipResViewFormatUnsignedInt4", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaResViewFormatSignedInt1"] = {"hipResViewFormatSignedInt1", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaResViewFormatSignedInt2"] = {"hipResViewFormatSignedInt2", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaResViewFormatSignedInt4"] = {"hipResViewFormatSignedInt4", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaResViewFormatHalf1"] = {"hipResViewFormatHalf1", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaResViewFormatHalf2"] = {"hipResViewFormatHalf2", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaResViewFormatHalf4"] = {"hipResViewFormatHalf4", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaResViewFormatFloat1"] = {"hipResViewFormatFloat1", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaResViewFormatFloat2"] = {"hipResViewFormatFloat2", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaResViewFormatFloat4"] = {"hipResViewFormatFloat4", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaResViewFormatUnsignedBlockCompressed1"] = {"hipResViewFormatUnsignedBlockCompressed1", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaResViewFormatUnsignedBlockCompressed2"] = {"hipResViewFormatUnsignedBlockCompressed2", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaResViewFormatUnsignedBlockCompressed3"] = {"hipResViewFormatUnsignedBlockCompressed3", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaResViewFormatUnsignedBlockCompressed4"] = {"hipResViewFormatUnsignedBlockCompressed4", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaResViewFormatSignedBlockCompressed4"] = {"hipResViewFormatSignedBlockCompressed4", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaResViewFormatUnsignedBlockCompressed5"] = {"hipResViewFormatUnsignedBlockCompressed5", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaResViewFormatSignedBlockCompressed5"] = {"hipResViewFormatSignedBlockCompressed5", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaResViewFormatSignedBlockCompressed6H"] = {"hipResViewFormatSignedBlockCompressed6H", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaResViewFormatUnsignedBlockCompressed7"] = {"hipResViewFormatUnsignedBlockCompressed7", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; + // enums + // enum cudaResourceType + cuda2hipRename["cudaResourceType"] = {"hipResourceType", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // API_Driver ANALOGUE (CUresourcetype) + cuda2hipRename["cudaResourceTypeArray"] = {"hipResourceTypeArray", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x00 // API_Driver ANALOGUE (CU_RESOURCE_TYPE_ARRAY = 0x00) + cuda2hipRename["cudaResourceTypeMipmappedArray"] = {"hipResourceTypeMipmappedArray", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x01 // API_Driver ANALOGUE (CU_RESOURCE_TYPE_MIPMAPPED_ARRAY = 0x01) + cuda2hipRename["cudaResourceTypeLinear"] = {"hipResourceTypeLinear", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x02 // API_Driver ANALOGUE (CU_RESOURCE_TYPE_LINEAR = 0x02) + cuda2hipRename["cudaResourceTypePitch2D"] = {"hipResourceTypePitch2D", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x03 // API_Driver ANALOGUE (CU_RESOURCE_TYPE_PITCH2D = 0x03) + + + cuda2hipRename["cudaResourceViewFormat"] = {"hipResourceViewFormat", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // API_Driver ANALOGUE (CUresourceViewFormat) + cuda2hipRename["cudaResViewFormatNone"] = {"hipResViewFormatNone", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x00 // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_NONE = 0x00) + cuda2hipRename["cudaResViewFormatUnsignedChar1"] = {"hipResViewFormatUnsignedChar1", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x01 // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_UINT_1X8 = 0x01) + cuda2hipRename["cudaResViewFormatUnsignedChar2"] = {"hipResViewFormatUnsignedChar2", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x02 // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_UINT_2X8 = 0x02) + cuda2hipRename["cudaResViewFormatUnsignedChar4"] = {"hipResViewFormatUnsignedChar4", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x03 // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_UINT_4X8 = 0x03) + cuda2hipRename["cudaResViewFormatSignedChar1"] = {"hipResViewFormatSignedChar1", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x04 // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_SINT_1X8 = 0x04) + cuda2hipRename["cudaResViewFormatSignedChar2"] = {"hipResViewFormatSignedChar2", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x05 // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_SINT_2X8 = 0x05) + cuda2hipRename["cudaResViewFormatSignedChar4"] = {"hipResViewFormatSignedChar4", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x06 // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_SINT_4X8 = 0x06) + cuda2hipRename["cudaResViewFormatUnsignedShort1"] = {"hipResViewFormatUnsignedShort1", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x07 // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_UINT_1X16 = 0x07) + cuda2hipRename["cudaResViewFormatUnsignedShort2"] = {"hipResViewFormatUnsignedShort2", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x08 // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_UINT_2X16 = 0x08) + cuda2hipRename["cudaResViewFormatUnsignedShort4"] = {"hipResViewFormatUnsignedShort4", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x09 // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_UINT_4X16 = 0x09) + cuda2hipRename["cudaResViewFormatSignedShort1"] = {"hipResViewFormatSignedShort1", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x0a // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_SINT_1X16 = 0x0a) + cuda2hipRename["cudaResViewFormatSignedShort2"] = {"hipResViewFormatSignedShort2", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x0b // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_SINT_2X16 = 0x0b) + cuda2hipRename["cudaResViewFormatSignedShort4"] = {"hipResViewFormatSignedShort4", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x0c // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_SINT_4X16 = 0x0c) + cuda2hipRename["cudaResViewFormatUnsignedInt1"] = {"hipResViewFormatUnsignedInt1", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x0d // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_UINT_1X32 = 0x0d) + cuda2hipRename["cudaResViewFormatUnsignedInt2"] = {"hipResViewFormatUnsignedInt2", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x0e // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_UINT_2X32 = 0x0e) + cuda2hipRename["cudaResViewFormatUnsignedInt4"] = {"hipResViewFormatUnsignedInt4", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x0f // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_UINT_4X32 = 0x0f) + cuda2hipRename["cudaResViewFormatSignedInt1"] = {"hipResViewFormatSignedInt1", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x10 // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_SINT_1X32 = 0x10) + cuda2hipRename["cudaResViewFormatSignedInt2"] = {"hipResViewFormatSignedInt2", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x11 // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_SINT_2X32 = 0x11) + cuda2hipRename["cudaResViewFormatSignedInt4"] = {"hipResViewFormatSignedInt4", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x12 // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_SINT_4X32 = 0x12) + cuda2hipRename["cudaResViewFormatHalf1"] = {"hipResViewFormatHalf1", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x13 // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_FLOAT_1X16 = 0x13) + cuda2hipRename["cudaResViewFormatHalf2"] = {"hipResViewFormatHalf2", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x14 // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_FLOAT_2X16 = 0x14) + cuda2hipRename["cudaResViewFormatHalf4"] = {"hipResViewFormatHalf4", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x15 // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_FLOAT_4X16 = 0x15) + cuda2hipRename["cudaResViewFormatFloat1"] = {"hipResViewFormatFloat1", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x16 // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_FLOAT_1X32 = 0x16) + cuda2hipRename["cudaResViewFormatFloat2"] = {"hipResViewFormatFloat2", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x17 // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_FLOAT_2X32 = 0x17) + cuda2hipRename["cudaResViewFormatFloat4"] = {"hipResViewFormatFloat4", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x18 // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_FLOAT_4X32 = 0x18) + cuda2hipRename["cudaResViewFormatUnsignedBlockCompressed1"] = {"hipResViewFormatUnsignedBlockCompressed1", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x19 // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_UNSIGNED_BC1 = 0x19) + cuda2hipRename["cudaResViewFormatUnsignedBlockCompressed2"] = {"hipResViewFormatUnsignedBlockCompressed2", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x1a // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_UNSIGNED_BC2 = 0x1a) + cuda2hipRename["cudaResViewFormatUnsignedBlockCompressed3"] = {"hipResViewFormatUnsignedBlockCompressed3", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x1b // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_UNSIGNED_BC3 = 0x1b) + cuda2hipRename["cudaResViewFormatUnsignedBlockCompressed4"] = {"hipResViewFormatUnsignedBlockCompressed4", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x1c // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_UNSIGNED_BC4 = 0x1c) + cuda2hipRename["cudaResViewFormatSignedBlockCompressed4"] = {"hipResViewFormatSignedBlockCompressed4", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x1d // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_SIGNED_BC4 = 0x1d) + cuda2hipRename["cudaResViewFormatUnsignedBlockCompressed5"] = {"hipResViewFormatUnsignedBlockCompressed5", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x1e // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_UNSIGNED_BC5 = 0x1e) + cuda2hipRename["cudaResViewFormatSignedBlockCompressed5"] = {"hipResViewFormatSignedBlockCompressed5", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x1f // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_SIGNED_BC5 = 0x1f) + cuda2hipRename["cudaResViewFormatUnsignedBlockCompressed6H"] = {"hipResViewFormatUnsignedBlockCompressed6H", CONV_TEX, API_DRIVER, HIP_UNSUPPORTED}; // 0x20 // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_UNSIGNED_BC6H = 0x20) + cuda2hipRename["cudaResViewFormatSignedBlockCompressed6H"] = {"hipResViewFormatSignedBlockCompressed6H", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x21 // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_SIGNED_BC6H = 0x21) + cuda2hipRename["cudaResViewFormatUnsignedBlockCompressed7"] = {"hipResViewFormatUnsignedBlockCompressed7", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; // 0x22 // API_Driver ANALOGUE (CU_RES_VIEW_FORMAT_UNSIGNED_BC7 = 0x22) cuda2hipRename["cudaTextureAddressMode"] = {"hipTextureAddressMode", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; cuda2hipRename["cudaAddressModeWrap"] = {"hipAddressModeWrap", CONV_TEX, API_RUNTIME, HIP_UNSUPPORTED}; @@ -1255,17 +1525,19 @@ struct cuda2hipMap { cuda2hipRename["cudaGraphicsCubeFacePositiveZ"] = {"hipGraphicsCubeFacePositiveZ", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; cuda2hipRename["cudaGraphicsCubeFaceNegativeZ"] = {"hipGraphicsCubeFaceNegativeZ", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaGraphicsMapFlags"] = {"hipGraphicsMapFlags", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaGraphicsMapFlagsNone"] = {"hipGraphicsMapFlagsNone", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaGraphicsMapFlagsReadOnly"] = {"hipGraphicsMapFlagsReadOnly", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaGraphicsMapFlagsWriteDiscard"] = {"hipGraphicsMapFlagsWriteDiscard", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; + // enum cudaGraphicsMapFlags + cuda2hipRename["cudaGraphicsMapFlags"] = {"hipGraphicsMapFlags", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; // API_Driver ANALOGUE (CUgraphicsMapResourceFlags) + cuda2hipRename["cudaGraphicsMapFlagsNone"] = {"hipGraphicsMapFlagsNone", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; // 0 // API_Driver ANALOGUE (CU_GRAPHICS_MAP_RESOURCE_FLAGS_NONE = 0x00) + cuda2hipRename["cudaGraphicsMapFlagsReadOnly"] = {"hipGraphicsMapFlagsReadOnly", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; // 1 // API_Driver ANALOGUE (CU_GRAPHICS_MAP_RESOURCE_FLAGS_READ_ONLY = 0x01) + cuda2hipRename["cudaGraphicsMapFlagsWriteDiscard"] = {"hipGraphicsMapFlagsWriteDiscard", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; // 2 // API_Driver ANALOGUE (CU_GRAPHICS_MAP_RESOURCE_FLAGS_WRITE_DISCARD = 0x02) - cuda2hipRename["cudaGraphicsRegisterFlags"] = {"hipGraphicsRegisterFlags", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaGraphicsRegisterFlagsNone"] = {"hipGraphicsRegisterFlagsNone", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaGraphicsRegisterFlagsReadOnly"] = {"hipGraphicsRegisterFlagsReadOnly", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaGraphicsRegisterFlagsWriteDiscard"] = {"hipGraphicsRegisterFlagsWriteDiscard", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaGraphicsRegisterFlagsSurfaceLoadStore"] = {"hipGraphicsRegisterFlagsSurfaceLoadStore", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; - cuda2hipRename["cudaGraphicsRegisterFlagsTextureGather"] = {"hipGraphicsRegisterFlagsTextureGather", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; + // enum cudaGraphicsRegisterFlags + cuda2hipRename["cudaGraphicsRegisterFlags"] = {"hipGraphicsRegisterFlags", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; // API_Driver ANALOGUE (CUgraphicsRegisterFlags) + cuda2hipRename["cudaGraphicsRegisterFlagsNone"] = {"hipGraphicsRegisterFlagsNone", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; // 0 // API_Driver ANALOGUE (CU_GRAPHICS_MAP_RESOURCE_FLAGS_NONE = 0x00) + cuda2hipRename["cudaGraphicsRegisterFlagsReadOnly"] = {"hipGraphicsRegisterFlagsReadOnly", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; // 1 // API_Driver ANALOGUE (CU_GRAPHICS_MAP_RESOURCE_FLAGS_READ_ONLY = 0x01) + cuda2hipRename["cudaGraphicsRegisterFlagsWriteDiscard"] = {"hipGraphicsRegisterFlagsWriteDiscard", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; // 2 // API_Driver ANALOGUE (CU_GRAPHICS_REGISTER_FLAGS_WRITE_DISCARD = 0x02) + cuda2hipRename["cudaGraphicsRegisterFlagsSurfaceLoadStore"] = {"hipGraphicsRegisterFlagsSurfaceLoadStore", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; // 4 // API_Driver ANALOGUE (CU_GRAPHICS_REGISTER_FLAGS_SURFACE_LDST = 0x04) + cuda2hipRename["cudaGraphicsRegisterFlagsTextureGather"] = {"hipGraphicsRegisterFlagsTextureGather", CONV_GRAPHICS, API_RUNTIME, HIP_UNSUPPORTED}; // 8 // API_Driver ANALOGUE (CU_GRAPHICS_REGISTER_FLAGS_TEXTURE_GATHER = 0x08) //---------------------------------------BLAS-------------------------------------// // Blas types diff --git a/projects/hip/include/hip/nvcc_detail/hip_runtime.h b/projects/hip/include/hip/nvcc_detail/hip_runtime.h index b4fa13f48c..80da388007 100644 --- a/projects/hip/include/hip/nvcc_detail/hip_runtime.h +++ b/projects/hip/include/hip/nvcc_detail/hip_runtime.h @@ -36,6 +36,10 @@ do {\ kernelName<<>>(0, ##__VA_ARGS__);\ } while(0) +#define hipLaunchKernelGGL(kernelName, numblocks, numthreads, memperblock, streamId, ...) \ +do {\ +kernelName<<>>(__VA_ARGS__);\ +} while(0) #define hipReadModeElementType cudaReadModeElementType diff --git a/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h b/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h index 7e881df3ab..0cc40f32af 100644 --- a/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/nvcc_detail/hip_runtime_api.h @@ -948,4 +948,6 @@ inline static hipChannelFormatDesc hipCreateChannelDesc() { return cudaCreateChannelDesc(); } -#endif +#endif //__CUDACC__ + +#endif //HIP_INCLUDE_HIP_NVCC_DETAIL_HIP_RUNTIME_API_H diff --git a/projects/hip/samples/0_Intro/square/Makefile b/projects/hip/samples/0_Intro/square/Makefile index 1e8cdba080..aa48cc5864 100644 --- a/projects/hip/samples/0_Intro/square/Makefile +++ b/projects/hip/samples/0_Intro/square/Makefile @@ -15,5 +15,6 @@ square.hip.out: square.hipref.cpp + clean: rm -f *.o *.out diff --git a/projects/hip/samples/0_Intro/square/square.hipref.cpp b/projects/hip/samples/0_Intro/square/square.hipref.cpp index 963ab63260..e694bfb8a4 100644 --- a/projects/hip/samples/0_Intro/square/square.hipref.cpp +++ b/projects/hip/samples/0_Intro/square/square.hipref.cpp @@ -83,7 +83,7 @@ int main(int argc, char *argv[]) const unsigned threadsPerBlock = 256; printf ("info: launch 'vector_square' kernel\n"); - hipLaunchKernel(vector_square, dim3(blocks), dim3(threadsPerBlock), 0, nullptr, C_d, A_d, N); + hipLaunchKernel(vector_square, dim3(blocks), dim3(threadsPerBlock), 0, 0, C_d, A_d, N); printf ("info: copy Device2Host\n"); CHECK ( hipMemcpy(C_h, C_d, Nbytes, hipMemcpyDeviceToHost)); From 72befd9cbe4280abbeed4323a0d8f77dc084ddc4 Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Wed, 26 Apr 2017 23:58:44 +0530 Subject: [PATCH 281/281] Merge branch 'amd-develop' into amd-master Change-Id: I51545bb66e9c9ff39bed86e2a8621e49a0e3f1c1 (cherry picked from commit a096c3c9b7230979952231208b13f22570f7a4d5) [ROCm/hip commit: 662f4f81393280187ab8ca6abf16d169939c415e] --- projects/hip/.vimrc | 1 - .../include/hip/hcc_detail/hip_runtime_api.h | 6 +- .../hip/include/hip/nvcc_detail/hip_complex.h | 6 +- projects/hip/src/hip_hcc.cpp | 82 +++- projects/hip/src/hip_memory.cpp | 26 +- .../src/runtimeApi/memory/hipHostRegister.cpp | 143 ++++--- .../tests/src/runtimeApi/memory/hipMemcpy.cpp | 367 ++++++++++++++---- .../runtimeApi/memory/hipMemoryAllocate.cpp | 10 + 8 files changed, 500 insertions(+), 141 deletions(-) delete mode 100644 projects/hip/.vimrc diff --git a/projects/hip/.vimrc b/projects/hip/.vimrc deleted file mode 100644 index 019afa57e6..0000000000 --- a/projects/hip/.vimrc +++ /dev/null @@ -1 +0,0 @@ -:set makeprg=make\ -C\ build.hcc-LC.db diff --git a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h index f9bfb5a310..7a99ff0810 100644 --- a/projects/hip/include/hip/hcc_detail/hip_runtime_api.h +++ b/projects/hip/include/hip/hcc_detail/hip_runtime_api.h @@ -853,7 +853,7 @@ hipError_t hipEventQuery(hipEvent_t event) ; * * @see hipGetDeviceCount, hipGetDevice, hipSetDevice, hipChooseDevice */ -hipError_t hipPointerGetAttributes(hipPointerAttribute_t *attributes, void* ptr); +hipError_t hipPointerGetAttributes(hipPointerAttribute_t *attributes, const void* ptr); /** * @brief Allocate memory on the default accelerator @@ -863,7 +863,7 @@ hipError_t hipPointerGetAttributes(hipPointerAttribute_t *attributes, void* ptr) * * If size is 0, no memory is allocated, *ptr returns nullptr, and hipSuccess is returned. * - * @return #hipSuccess + * @return #hipSuccess, #hipErrorMemoryAllocation, #hipErrorInvalidValue (bad context, null *ptr) * * @see hipMallocPitch, hipFree, hipMallocArray, hipFreeArray, hipMalloc3D, hipMalloc3DArray, hipHostFree, hipHostMalloc */ @@ -1922,7 +1922,7 @@ hipError_t hipModuleLoadData(hipModule_t *module, const void *image); * @param [in] blockDimZ Z grid dimension specified in work-items * @param [in] sharedMemBytes Amount of dynamic shared memory to allocate for this kernel. The kernel can access this with HIP_DYNAMIC_SHARED. * @param [in] stream Stream where the kernel should be dispatched. May be 0, in which case th default stream is used with associated synchronization rules. - * @param [in] kernelParams + * @param [in] kernelParams * @param [in] extra Pointer to kernel arguments. These are passed directly to the kernel and must be in the memory layout and alignment expected by the kernel. * * @returns hipSuccess, hipInvalidDevice, hipErrorNotInitialized, hipErrorInvalidValue diff --git a/projects/hip/include/hip/nvcc_detail/hip_complex.h b/projects/hip/include/hip/nvcc_detail/hip_complex.h index 84afb13e50..20cb24460c 100644 --- a/projects/hip/include/hip/nvcc_detail/hip_complex.h +++ b/projects/hip/include/hip/nvcc_detail/hip_complex.h @@ -64,7 +64,7 @@ __device__ __host__ static inline hipFloatComplex hipCdivf(hipFloatComplex p, hi } __device__ __host__ static inline float hipCabsf(hipFloatComplex z){ - return cuCabsf(p, q); + return cuCabsf(z); } typedef cuDoubleComplex hipDoubleComplex; @@ -85,7 +85,7 @@ __device__ __host__ static inline hipDoubleComplex hipConj(hipDoubleComplex z){ return cuConj(z); } -__device__ __host__ static inline hipDoubleComplex hipCsqabs(hipDoubleComplex z){ +__device__ __host__ static inline double hipCsqabs(hipDoubleComplex z){ return cuCabs(z) * cuCabs(z); } @@ -123,7 +123,7 @@ __device__ __host__ static inline hipComplex hipCfmaf(hipComplex p, hipComplex q return cuCfmaf(p, q, r); } -__device__ __host__ static inline hipDoubleComplex hipCfma(hipComplex p, hipComplex q, hipComplex r){ +__device__ __host__ static inline hipDoubleComplex hipCfma(hipDoubleComplex p, hipDoubleComplex q, hipDoubleComplex r){ return cuCfma(p, q, r); } diff --git a/projects/hip/src/hip_hcc.cpp b/projects/hip/src/hip_hcc.cpp index 35a3e11e71..71d947488d 100644 --- a/projects/hip/src/hip_hcc.cpp +++ b/projects/hip/src/hip_hcc.cpp @@ -1765,20 +1765,24 @@ void ihipStream_t::resolveHcMemcpyDirection(unsigned hipMemKind, if (HIP_FORCE_P2P_HOST & 0x1) { *forceUnpinnedCopy = true; - tprintf (DB_COPY, "P2P. Copy engine (dev:%d agent=0x%lx) can see src and dst but HIP_FORCE_P2P_HOST=0, forcing copy through staging buffers.\n", - (*copyDevice)->getDeviceNum(), (*copyDevice)->getDevice()->_hsaAgent.handle); + tprintf (DB_COPY, "Copy engine (dev:%d agent=0x%lx) can see src and dst but HIP_FORCE_P2P_HOST=0, forcing copy through staging buffers.\n", + *copyDevice ? (*copyDevice)->getDeviceNum() : -1, + *copyDevice ? (*copyDevice)->getDevice()->_hsaAgent.handle : 0x0); } else { - tprintf (DB_COPY, "P2P. Copy engine (dev:%d agent=0x%lx) can see src and dst.\n", - (*copyDevice)->getDeviceNum(), (*copyDevice)->getDevice()->_hsaAgent.handle); + tprintf (DB_COPY, "Copy engine (dev:%d agent=0x%lx) can see src and dst.\n", + *copyDevice ? (*copyDevice)->getDeviceNum() : -1, + *copyDevice ? (*copyDevice)->getDevice()->_hsaAgent.handle : 0x0); } } else { *forceUnpinnedCopy = true; tprintf (DB_COPY, "P2P: Copy engine(dev:%d agent=0x%lx) cannot see both host and device pointers - forcing copy with unpinned engine.\n", - (*copyDevice)->getDeviceNum(), (*copyDevice)->getDevice()->_hsaAgent.handle); + *copyDevice ? (*copyDevice)->getDeviceNum() : -1, + *copyDevice ? (*copyDevice)->getDevice()->_hsaAgent.handle : 0x0); if (HIP_FAIL_SOC & 0x2) { fprintf (stderr, "HIP_FAIL_SOC: P2P: copy engine(dev:%d agent=0x%lx) cannot see both host and device pointers - forcing copy with unpinned engine.\n", - (*copyDevice)->getDeviceNum(), (*copyDevice)->getDevice()->_hsaAgent.handle); + *copyDevice ? (*copyDevice)->getDeviceNum() : -1, + *copyDevice ? (*copyDevice)->getDevice()->_hsaAgent.handle : 0x0); throw ihipException(hipErrorRuntimeOther); } } @@ -1794,6 +1798,62 @@ void printPointerInfo(unsigned dbFlag, const char *tag, const void *ptr, const h } +// the pointer-info as returned by HC refers to the allocation +// This routine modifies the pointer-info so it appears to refer to the specific ptr and sizeBytes. +// TODO -remove this when HCC uses HSA pointer info functions directly. +void tailorPtrInfo(hc::AmPointerInfo *ptrInfo, const void * ptr, size_t sizeBytes) +{ + const char *ptrc = static_cast (ptr); + if (ptrInfo->_sizeBytes == 0) { + // invalid ptrInfo, don't modify + return; + } else if (ptrInfo->_isInDeviceMem) { + assert (ptrInfo->_devicePointer != nullptr); + std::ptrdiff_t diff = ptrc - static_cast (ptrInfo->_devicePointer); + + //TODO : assert-> runtime assert that only appears in debug mode + assert (diff >= 0); + assert (diff <= ptrInfo->_sizeBytes); + + ptrInfo->_devicePointer = const_cast (ptr); + + if (ptrInfo->_hostPointer != nullptr) { + ptrInfo->_hostPointer = static_cast(ptrInfo->_hostPointer) + diff; + } + + } else { + + assert (ptrInfo->_hostPointer != nullptr); + std::ptrdiff_t diff = ptrc - static_cast (ptrInfo->_hostPointer); + + //TODO : assert-> runtime assert that only appears in debug mode + assert (diff >= 0); + assert (diff <= ptrInfo->_sizeBytes); + + ptrInfo->_hostPointer = const_cast(ptr); + + if (ptrInfo->_devicePointer != nullptr) { + ptrInfo->_devicePointer = static_cast(ptrInfo->_devicePointer) + diff; + } + } + + assert (sizeBytes <= ptrInfo->_sizeBytes); + ptrInfo->_sizeBytes = sizeBytes; +}; + + +bool getTailoredPtrInfo(hc::AmPointerInfo *ptrInfo, const void * ptr, size_t sizeBytes) +{ + bool tracked = (hc::am_memtracker_getinfo(ptrInfo, ptr) == AM_SUCCESS); + + if (tracked) { + tailorPtrInfo(ptrInfo, ptr, sizeBytes); + } + + return tracked; +}; + + // TODO : For registered and host memory, if the portable flag is set, we need to recognize that and perform appropriate copy operation. // What can happen now is that Portable memory is mapped into multiple devices but Peer access is not enabled. i // The peer detection logic doesn't see that the memory is already mapped and so tries to use an unpinned copy algorithm. If this is PinInPlace, then an error can occur. @@ -1812,8 +1872,8 @@ void ihipStream_t::locked_copySync(void* dst, const void* src, size_t sizeBytes, hc::accelerator acc; hc::AmPointerInfo dstPtrInfo(NULL, NULL, 0, acc, 0, 0); hc::AmPointerInfo srcPtrInfo(NULL, NULL, 0, acc, 0, 0); - bool dstTracked = (hc::am_memtracker_getinfo(&dstPtrInfo, dst) == AM_SUCCESS); - bool srcTracked = (hc::am_memtracker_getinfo(&srcPtrInfo, src) == AM_SUCCESS); + bool dstTracked = getTailoredPtrInfo(&dstPtrInfo, dst, sizeBytes); + bool srcTracked = getTailoredPtrInfo(&srcPtrInfo, src, sizeBytes); // Some code in HCC and in printPointerInfo uses _sizeBytes==0 as an indication ptr is not valid, so check it here: @@ -1873,6 +1933,7 @@ void ihipStream_t::lockedSymbolCopySync(hc::accelerator &acc, void* dst, void* s void ihipStream_t::lockedSymbolCopyAsync(hc::accelerator &acc, void* dst, void* src, size_t sizeBytes, size_t offset, unsigned kind) { + // TODO - review - this looks broken , should not be adding pointers to tracker dynamically: if(kind == hipMemcpyHostToDevice) { hc::AmPointerInfo srcPtrInfo(NULL, NULL, 0, acc, 0, 0); bool srcTracked = (hc::am_memtracker_getinfo(&srcPtrInfo, src) == AM_SUCCESS); @@ -1899,6 +1960,7 @@ void ihipStream_t::lockedSymbolCopyAsync(hc::accelerator &acc, void* dst, void* } } + void ihipStream_t::locked_copyAsync(void* dst, const void* src, size_t sizeBytes, unsigned kind) { @@ -1926,8 +1988,8 @@ void ihipStream_t::locked_copyAsync(void* dst, const void* src, size_t sizeBytes hc::accelerator acc; hc::AmPointerInfo dstPtrInfo(NULL, NULL, 0, acc, 0, 0); hc::AmPointerInfo srcPtrInfo(NULL, NULL, 0, acc, 0, 0); - bool dstTracked = (hc::am_memtracker_getinfo(&dstPtrInfo, dst) == AM_SUCCESS); - bool srcTracked = (hc::am_memtracker_getinfo(&srcPtrInfo, src) == AM_SUCCESS); + bool dstTracked = getTailoredPtrInfo(&dstPtrInfo, dst, sizeBytes); + bool srcTracked = getTailoredPtrInfo(&srcPtrInfo, src, sizeBytes); hc::hcCommandKind hcCopyDir; diff --git a/projects/hip/src/hip_memory.cpp b/projects/hip/src/hip_memory.cpp index da5530349f..821f64bc76 100644 --- a/projects/hip/src/hip_memory.cpp +++ b/projects/hip/src/hip_memory.cpp @@ -133,7 +133,7 @@ void * allocAndSharePtr(const char *msg, size_t sizeBytes, ihipCtx_t *ctx, unsig //_appAllocationFlags : These are flags provided by the user when allocation is performed. They are returned to user in hipHostGetFlags and other APIs. // TODO - add more info here when available. // -hipError_t hipPointerGetAttributes(hipPointerAttribute_t *attributes, void* ptr) +hipError_t hipPointerGetAttributes(hipPointerAttribute_t *attributes, const void* ptr) { HIP_INIT_API(attributes, ptr); @@ -149,10 +149,10 @@ hipError_t hipPointerGetAttributes(hipPointerAttribute_t *attributes, void* ptr) attributes->devicePointer = amPointerInfo._devicePointer; attributes->isManaged = 0; if(attributes->memoryType == hipMemoryTypeHost){ - attributes->hostPointer = ptr; + attributes->hostPointer = (void*)ptr; } if(attributes->memoryType == hipMemoryTypeDevice){ - attributes->devicePointer = ptr; + attributes->devicePointer = (void*)ptr; } attributes->allocationFlags = amPointerInfo._appAllocationFlags; attributes->device = amPointerInfo._appId; @@ -207,22 +207,26 @@ hipError_t hipMalloc(void** ptr, size_t sizeBytes) HIP_INIT_API(ptr, sizeBytes); HIP_SET_DEVICE(); hipError_t hip_status = hipSuccess; + + auto ctx = ihipGetTlsDefaultCtx(); // return NULL pointer when malloc size is 0 if (sizeBytes == 0) { *ptr = NULL; - return ihipLogStatus(hipSuccess); - } + hip_status = hipSuccess; - auto ctx = ihipGetTlsDefaultCtx(); + } else if ((ctx==nullptr) || (ptr == nullptr)) { + hip_status = hipErrorInvalidValue; - if (ctx) { + } else { auto device = ctx->getWriteableDevice(); *ptr = hip_internal::allocAndSharePtr("device_mem", sizeBytes, ctx, 0/*amFlags*/, 0/*hipFlags*/); - } else { - hip_status = hipErrorMemoryAllocation; - } + if(sizeBytes && (*ptr == NULL)){ + hip_status = hipErrorMemoryAllocation; + } + + } return ihipLogStatus(hip_status); @@ -1268,7 +1272,7 @@ hipError_t hipIpcOpenMemHandle(void** devPtr, hipIpcMemHandle_t handle, unsigned hsa_amd_ipc_memory_attach((hsa_amd_ipc_memory_t*)&(iHandle->ipc_handle), iHandle->psize, crit->peerCnt(), crit->peerAgents(), devPtr); if(hsa_status != HSA_STATUS_SUCCESS) hipStatus = hipErrorMapBufferObjectFailed; - } + } #else hipStatus = hipErrorRuntimeOther; #endif diff --git a/projects/hip/tests/src/runtimeApi/memory/hipHostRegister.cpp b/projects/hip/tests/src/runtimeApi/memory/hipHostRegister.cpp index 1a1319c500..8cf0979261 100644 --- a/projects/hip/tests/src/runtimeApi/memory/hipHostRegister.cpp +++ b/projects/hip/tests/src/runtimeApi/memory/hipHostRegister.cpp @@ -19,87 +19,142 @@ THE SOFTWARE. /* HIT_START * BUILD: %t %s ../../test_common.cpp - * RUN: %t + * RUN: %t --tests 0x1 + * RUN: %t --tests 0x2 + * RUN: %t --tests 0x4 * HIT_END */ +// TODO - bug if run both back-to-back, once fixed should just need one command line + #include"test_common.h" #include __global__ void Inc(hipLaunchParm lp, float *Ad){ -int tx = hipThreadIdx_x + hipBlockIdx_x * hipBlockDim_x; -Ad[tx] = Ad[tx] + float(1); + int tx = hipThreadIdx_x + hipBlockIdx_x * hipBlockDim_x; + Ad[tx] = Ad[tx] + float(1); } -int main(){ - float *A, **Ad; - int num_devices; - HIPCHECK(hipGetDeviceCount(&num_devices)); - Ad = new float*[num_devices]; - const size_t size = N * sizeof(float); - A = (float*)malloc(size); - HIPCHECK(hipHostRegister(A, size, 0)); + +template +void doMemCopy(size_t numElements, int offset, T *A, T *Bh, T *Bd, bool internalRegister) +{ + A = A + offset; + numElements -= offset; + + size_t sizeBytes = numElements * sizeof(T); + + if (internalRegister) { + HIPCHECK(hipHostRegister(A, sizeBytes, 0)); + } - for(int i=0;iOFFSETS_TO_TRY); + + if (p_tests & 0x2) { + for (size_t i=0; i +class DeviceMemory +{ +public: + DeviceMemory(size_t numElements); + ~DeviceMemory(); + + T *A_d() const { return _A_d + _offset; }; + T *B_d() const { return _B_d + _offset; }; + T *C_d() const { return _C_d + _offset; }; + T *C_dd() const { return _C_dd + _offset; }; + + size_t maxNumElements() const { return _maxNumElements; }; + + + void offset(int offset) { _offset = offset; }; + int offset() const { return _offset; }; + +private: + T * _A_d; + T* _B_d; + T* _C_d; + T* _C_dd; + + + size_t _maxNumElements; + int _offset; +}; + +template +DeviceMemory::DeviceMemory(size_t numElements) + : _maxNumElements(numElements), + _offset(0) +{ + T ** np = nullptr; + HipTest::initArrays (&_A_d, &_B_d, &_C_d, np, np, np, numElements, 0); + + + size_t sizeElements = numElements * sizeof(T); + + + HIPCHECK ( hipMalloc(&_C_dd, sizeElements) ); +} + + +template +DeviceMemory::~DeviceMemory () +{ + T * np = nullptr; + HipTest::freeArrays (_A_d, _B_d, _C_d, np, np, np, 0); + + HIPCHECK (hipFree(_C_dd)); + + _C_dd = NULL; +}; + + + +//------- +template +class HostMemory +{ +public: + HostMemory(size_t numElements, bool usePinnedHost); + void reset(size_t numElements, bool full=false) ; + ~HostMemory(); + + + T *A_h() const { return _A_h + _offset; }; + T *B_h() const { return _B_h + _offset; }; + T *C_h() const { return _C_h + _offset; }; + + + + size_t maxNumElements() const { return _maxNumElements; }; + + void offset(int offset) { _offset = offset; }; + int offset() const { return _offset; }; +public: + + // Host arrays, secondary copy + T * A_hh; + T* B_hh; + + bool _usePinnedHost; +private: + size_t _maxNumElements; + + int _offset; + + // Host arrays + T * _A_h; + T* _B_h; + T* _C_h; +}; + +template +HostMemory::HostMemory(size_t numElements, bool usePinnedHost) + : _maxNumElements(numElements), + _usePinnedHost(usePinnedHost), + _offset(0) +{ + T ** np = nullptr; + HipTest::initArrays (np, np, np, &_A_h, &_B_h, &_C_h, numElements, usePinnedHost); + + A_hh = NULL; + B_hh = NULL; + + + size_t sizeElements = numElements * sizeof(T); + + if (usePinnedHost) { + HIPCHECK ( hipHostMalloc((void**)&A_hh, sizeElements, hipHostMallocDefault) ); + HIPCHECK ( hipHostMalloc((void**)&B_hh, sizeElements, hipHostMallocDefault) ); + } else { + A_hh = (T*)malloc(sizeElements); + B_hh = (T*)malloc(sizeElements); + } + +} + + +template +void +HostMemory::reset(size_t numElements, bool full) +{ + // Initialize the host data: + for (size_t i=0; i +HostMemory::~HostMemory () +{ + HipTest::freeArraysForHost (_A_h, _B_h, _C_h, _usePinnedHost); + + if (_usePinnedHost) { + HIPCHECK (hipHostFree(A_hh)); + HIPCHECK (hipHostFree(B_hh)); + + } else { + free(A_hh); + free(B_hh); + } + T *A_hh = NULL; + T *B_hh = NULL; + +}; @@ -52,71 +210,57 @@ void printSep() // IN: useMemkindDefault : If true, use memkinddefault (runtime figures out direction). if false, use explicit memcpy direction. // template -void memcpytest2(size_t numElements, bool usePinnedHost, bool useHostToHost, bool useDeviceToDevice, bool useMemkindDefault) +void memcpytest2(DeviceMemory *dmem, HostMemory *hmem, size_t numElements, bool useHostToHost, bool useDeviceToDevice, bool useMemkindDefault) { size_t sizeElements = numElements * sizeof(T); - printf ("test: %s<%s> size=%lu (%6.2fMB) usePinnedHost:%d, useHostToHost:%d, useDeviceToDevice:%d, useMemkindDefault:%d\n", + printf ("test: %s<%s> size=%lu (%6.2fMB) usePinnedHost:%d, useHostToHost:%d, useDeviceToDevice:%d, useMemkindDefault:%d, offsets:dev:%+d host:+%d\n", __func__, TYPENAME(T), sizeElements, sizeElements/1024.0/1024.0, - usePinnedHost, useHostToHost, useDeviceToDevice, useMemkindDefault); + hmem->_usePinnedHost, useHostToHost, useDeviceToDevice, useMemkindDefault, + dmem->offset(), hmem->offset() + ); - T *A_d, *B_d, *C_d; - T *A_h, *B_h, *C_h; - - - HipTest::initArrays (&A_d, &B_d, &C_d, &A_h, &B_h, &C_h, numElements, usePinnedHost); + hmem->reset(numElements); unsigned blocks = HipTest::setNumBlocks(blocksPerCU, threadsPerBlock, numElements); - T *A_hh = NULL; - T *B_hh = NULL; - T *C_dd = NULL; + assert (numElements <= dmem->maxNumElements()); + assert (numElements <= hmem->maxNumElements()); if (useHostToHost) { - if (usePinnedHost) { - HIPCHECK ( hipHostMalloc((void**)&A_hh, sizeElements, hipHostMallocDefault) ); - HIPCHECK ( hipHostMalloc((void**)&B_hh, sizeElements, hipHostMallocDefault) ); - } else { - A_hh = (T*)malloc(sizeElements); - B_hh = (T*)malloc(sizeElements); - } - - // Do some extra host-to-host copies here to mix things up: - HIPCHECK ( hipMemcpy(A_hh, A_h, sizeElements, useMemkindDefault? hipMemcpyDefault : hipMemcpyHostToHost)); - HIPCHECK ( hipMemcpy(B_hh, B_h, sizeElements, useMemkindDefault? hipMemcpyDefault : hipMemcpyHostToHost)); + HIPCHECK ( hipMemcpy(hmem->A_hh, hmem->A_h(), sizeElements, useMemkindDefault? hipMemcpyDefault : hipMemcpyHostToHost)); + HIPCHECK ( hipMemcpy(hmem->B_hh, hmem->B_h(), sizeElements, useMemkindDefault? hipMemcpyDefault : hipMemcpyHostToHost)); - HIPCHECK ( hipMemcpy(A_d, A_hh, sizeElements, useMemkindDefault ? hipMemcpyDefault : hipMemcpyHostToDevice)); - HIPCHECK ( hipMemcpy(B_d, B_hh, sizeElements, useMemkindDefault ? hipMemcpyDefault : hipMemcpyHostToDevice)); + HIPCHECK ( hipMemcpy(dmem->A_d(), hmem->A_hh, sizeElements, useMemkindDefault ? hipMemcpyDefault : hipMemcpyHostToDevice)); + HIPCHECK ( hipMemcpy(dmem->B_d(), hmem->B_hh, sizeElements, useMemkindDefault ? hipMemcpyDefault : hipMemcpyHostToDevice)); } else { - HIPCHECK ( hipMemcpy(A_d, A_h, sizeElements, useMemkindDefault ? hipMemcpyDefault : hipMemcpyHostToDevice)); - HIPCHECK ( hipMemcpy(B_d, B_h, sizeElements, useMemkindDefault ? hipMemcpyDefault : hipMemcpyHostToDevice)); + HIPCHECK ( hipMemcpy(dmem->A_d(), hmem->A_h(), sizeElements, useMemkindDefault ? hipMemcpyDefault : hipMemcpyHostToDevice)); + HIPCHECK ( hipMemcpy(dmem->B_d(), hmem->B_h(), sizeElements, useMemkindDefault ? hipMemcpyDefault : hipMemcpyHostToDevice)); } - hipLaunchKernel(HipTest::vectorADD, dim3(blocks), dim3(threadsPerBlock), 0, 0, A_d, B_d, C_d, numElements); + hipLaunchKernel(HipTest::vectorADD, dim3(blocks), dim3(threadsPerBlock), 0, 0, dmem->A_d(), dmem->B_d(), dmem->C_d(), numElements); if (useDeviceToDevice) { - HIPCHECK ( hipMalloc(&C_dd, sizeElements) ); + // Do an extra device-to-device copy here to mix things up: + HIPCHECK ( hipMemcpy(dmem->C_dd(), dmem->C_d(), sizeElements, useMemkindDefault? hipMemcpyDefault : hipMemcpyDeviceToDevice)); - // Do an extra device-to-device copies here to mix things up: - HIPCHECK ( hipMemcpy(C_dd, C_d, sizeElements, useMemkindDefault? hipMemcpyDefault : hipMemcpyDeviceToDevice)); + //Destroy the original dmem->C_d(): + HIPCHECK ( hipMemset(dmem->C_d(), 0x5A, sizeElements)); - //Destroy the original C_d: - HIPCHECK ( hipMemset(C_d, 0x5A, sizeElements)); - - HIPCHECK ( hipMemcpy(C_h, C_dd, sizeElements, useMemkindDefault? hipMemcpyDefault:hipMemcpyDeviceToHost)); + HIPCHECK ( hipMemcpy(hmem->C_h(), dmem->C_dd(), sizeElements, useMemkindDefault? hipMemcpyDefault:hipMemcpyDeviceToHost)); } else { - HIPCHECK ( hipMemcpy(C_h, C_d, sizeElements, useMemkindDefault? hipMemcpyDefault:hipMemcpyDeviceToHost)); + HIPCHECK ( hipMemcpy(hmem->C_h(), dmem->C_d(), sizeElements, useMemkindDefault? hipMemcpyDefault:hipMemcpyDeviceToHost)); } HIPCHECK ( hipDeviceSynchronize() ); - HipTest::checkVectorADD(A_h, B_h, C_h, numElements); + HipTest::checkVectorADD(hmem->A_h(), hmem->B_h(), hmem->C_h(), numElements); + - HipTest::freeArrays (A_d, B_d, C_d, A_h, B_h, C_h, usePinnedHost); printf (" %s success\n", __func__); } @@ -129,11 +273,15 @@ void memcpytest2_for_type(size_t numElements) { printSep(); + DeviceMemory memD(numElements); + HostMemory memU(numElements, 0/*usePinnedHost*/); + HostMemory memP(numElements, 1/*usePinnedHost*/); + for (int usePinnedHost =0; usePinnedHost<=1; usePinnedHost++) { for (int useHostToHost =0; useHostToHost<=1; useHostToHost++) { // TODO for (int useDeviceToDevice =0; useDeviceToDevice<=1; useDeviceToDevice++) { for (int useMemkindDefault =0; useMemkindDefault<=1; useMemkindDefault++) { - memcpytest2(numElements, usePinnedHost, useHostToHost, useDeviceToDevice, useMemkindDefault); + memcpytest2(&memD, usePinnedHost ? &memP : &memU, numElements, useHostToHost, useDeviceToDevice, useMemkindDefault); } } } @@ -144,7 +292,7 @@ void memcpytest2_for_type(size_t numElements) //--- //Try many different sizes to memory copy. template -void memcpytest2_sizes(size_t maxElem=0, size_t offset=0) +void memcpytest2_sizes(size_t maxElem=0) { printSep(); printf ("test: %s<%s>\n", __func__, TYPENAME(T)); @@ -159,14 +307,68 @@ void memcpytest2_sizes(size_t maxElem=0, size_t offset=0) maxElem = free/sizeof(T)/5; } - printf (" device#%d: hipMemGetInfo: free=%zu (%4.2fMB) total=%zu (%4.2fMB) maxSize=%6.1fMB offset=%lu\n", - deviceId, free, (float)(free/1024.0/1024.0), total, (float)(total/1024.0/1024.0), maxElem*sizeof(T)/1024.0/1024.0, offset); + printf (" device#%d: hipMemGetInfo: free=%zu (%4.2fMB) total=%zu (%4.2fMB) maxSize=%6.1fMB\n", + deviceId, free, (float)(free/1024.0/1024.0), total, (float)(total/1024.0/1024.0), maxElem*sizeof(T)/1024.0/1024.0); + HIPCHECK ( hipDeviceReset() ); + DeviceMemory memD(maxElem); + HostMemory memU(maxElem, 0/*usePinnedHost*/); + HostMemory memP(maxElem, 1/*usePinnedHost*/); - for (size_t elem=64; elem+offset<=maxElem; elem*=2) { - HIPCHECK ( hipDeviceReset() ); - memcpytest2(elem+offset, 0, 1, 1, 0); // unpinned host - HIPCHECK ( hipDeviceReset() ); - memcpytest2(elem+offset, 1, 1, 1, 0); // pinned host + for (size_t elem=1; elem<=maxElem; elem*=2) { + memcpytest2(&memD, &memU, elem, 1, 1, 0); // unpinned host + memcpytest2(&memD, &memP, elem, 1, 1, 0); // pinned host + } +} + + +//--- +//Try many different sizes to memory copy. +template +void memcpytest2_offsets(size_t maxElem, bool devOffsets, bool hostOffsets) +{ + printSep(); + printf ("test: %s<%s>\n", __func__, TYPENAME(T)); + + int deviceId; + HIPCHECK(hipGetDevice(&deviceId)); + + size_t free, total; + HIPCHECK(hipMemGetInfo(&free, &total)); + + + printf (" device#%d: hipMemGetInfo: free=%zu (%4.2fMB) total=%zu (%4.2fMB) maxSize=%6.1fMB\n", + deviceId, free, (float)(free/1024.0/1024.0), total, (float)(total/1024.0/1024.0), maxElem*sizeof(T)/1024.0/1024.0); + HIPCHECK ( hipDeviceReset() ); + DeviceMemory memD(maxElem); + HostMemory memU(maxElem, 0/*usePinnedHost*/); + HostMemory memP(maxElem, 1/*usePinnedHost*/); + + size_t elem = maxElem / 2; + + for (int offset=0; offset < 512; offset++) { + assert (elem + offset < maxElem); + if (devOffsets) { + memD.offset(offset); + } + if (hostOffsets) { + memU.offset(offset); + memP.offset(offset); + } + memcpytest2(&memD, &memU, elem, 1, 1, 0); // unpinned host + memcpytest2(&memD, &memP, elem, 1, 1, 0); // pinned host + } + + for (int offset=512; offset < elem; offset*=2) { + assert (elem + offset < maxElem); + if (devOffsets) { + memD.offset(offset); + } + if (hostOffsets) { + memU.offset(offset); + memP.offset(offset); + } + memcpytest2(&memD, &memU, elem, 1, 1, 0); // unpinned host + memcpytest2(&memD, &memP, elem, 1, 1, 0); // pinned host } } @@ -178,13 +380,17 @@ void multiThread_1(bool serialize, bool usePinnedHost) { printSep(); printf ("test: %s<%s> serialize=%d usePinnedHost=%d\n", __func__, TYPENAME(T), serialize, usePinnedHost); - std::thread t1 (memcpytest2,N, usePinnedHost,0,0,0); + DeviceMemory memD(N); + HostMemory mem1(N, usePinnedHost); + HostMemory mem2(N, usePinnedHost); + + std::thread t1 (memcpytest2, &memD, &mem1, N, 0,0,0); if (serialize) { t1.join(); } - std::thread t2 (memcpytest2,N, usePinnedHost,0,0,0); + std::thread t2 (memcpytest2,&memD, &mem2, N, 0,0,0); if (serialize) { t2.join(); } @@ -218,37 +424,39 @@ int main(int argc, char *argv[]) if (p_tests & 0x2) { - // Some tests around the 64MB boundary which have historically shown issues: - printf ("\n\n=== tests&0x2 (64MB boundary)\n"); -#if 0 + // Some tests around the 64KB boundary which have historically shown issues: + printf ("\n\n=== tests&0x2 (64KB boundary)\n"); + size_t maxElem = 32*1024*1024; + DeviceMemory memD(maxElem); + HostMemory memU(maxElem, 0/*usePinnedHost*/); + HostMemory memP(maxElem, 0/*usePinnedHost*/); // These all pass: - memcpytest2(15*1024*1024, 1, 0, 0, 0); - memcpytest2(16*1024*1024, 1, 0, 0, 0); - memcpytest2(16*1024*1024+16*1024, 1, 0, 0, 0); -#endif + memcpytest2(&memD, &memP, 15*1024*1024, 0, 0, 0); + memcpytest2(&memD, &memP, 16*1024*1024, 0, 0, 0); + memcpytest2(&memD, &memP, 16*1024*1024+16*1024, 0, 0, 0); + // Just over 64MB: - memcpytest2(16*1024*1024+512*1024, 1, 0, 0, 0); - memcpytest2(17*1024*1024+1024, 1, 0, 0, 0); - memcpytest2(32*1024*1024, 1, 0, 0, 0); - memcpytest2(32*1024*1024, 0, 0, 0, 0); - memcpytest2(32*1024*1024, 1, 1, 1, 0); - memcpytest2(32*1024*1024, 1, 1, 1, 0); + memcpytest2(&memD, &memP, 16*1024*1024+512*1024, 0, 0, 0); + memcpytest2(&memD, &memP, 17*1024*1024+1024, 0, 0, 0); + memcpytest2(&memD, &memP, 32*1024*1024, 0, 0, 0); + memcpytest2(&memD, &memU, 32*1024*1024, 0, 0, 0); + memcpytest2(&memD, &memP, 32*1024*1024, 1, 1, 0); + memcpytest2(&memD, &memP, 32*1024*1024, 1, 1, 0); + + } + if (p_tests & 0x4) { - printf ("\n\n=== tests&4 (test sizes and offsets)\n"); + printf ("\n\n=== tests&4 (test sizes)\n"); HIPCHECK ( hipDeviceReset() ); + memcpytest2_sizes(0); printSep(); - memcpytest2_sizes(0,0); - printSep(); - memcpytest2_sizes(0,64); - printSep(); - memcpytest2_sizes(1024*1024, 13); - printSep(); - memcpytest2_sizes(1024*1024, 50); } + + if (p_tests & 0x8) { printf ("\n\n=== tests&8\n"); HIPCHECK ( hipDeviceReset() ); @@ -270,6 +478,27 @@ int main(int argc, char *argv[]) } + if (p_tests & 0x10) { + printf ("\n\n=== tests&0x10 (test device offsets)\n"); + HIPCHECK ( hipDeviceReset() ); + size_t maxSize = 256*1024; + memcpytest2_offsets (maxSize, true, false); + memcpytest2_offsets (maxSize, true, false); + memcpytest2_offsets(maxSize, true, false); + } + + + if (p_tests & 0x20) { + printf ("\n\n=== tests&0x10 (test device offsets)\n"); + HIPCHECK ( hipDeviceReset() ); + size_t maxSize = 256*1024; + memcpytest2_offsets (maxSize, false, true); + memcpytest2_offsets (maxSize, false, true); + memcpytest2_offsets(maxSize, false, true); + } + + + passed(); } diff --git a/projects/hip/tests/src/runtimeApi/memory/hipMemoryAllocate.cpp b/projects/hip/tests/src/runtimeApi/memory/hipMemoryAllocate.cpp index 1f7599491a..0a256d6362 100644 --- a/projects/hip/tests/src/runtimeApi/memory/hipMemoryAllocate.cpp +++ b/projects/hip/tests/src/runtimeApi/memory/hipMemoryAllocate.cpp @@ -56,5 +56,15 @@ int main(){ HIPCHECK_API(hipFree(NULL) , hipSuccess); HIPCHECK_API(hipHostFree(NULL) , hipSuccess); + + { + // Some negative testing - request a too-big allocation and verify it fails: + // Someday when we support virtual memory may need to refactor these: + size_t tooBig = 128LL*1024*1024*1024*1024; // 128 TB; + void *p; + HIPCHECK_API ( hipMalloc(&p, tooBig), hipErrorMemoryAllocation ); + HIPCHECK_API ( hipHostMalloc(&p, tooBig), hipErrorMemoryAllocation ); + } + passed(); }