author
int64
658
755k
date
stringlengths
19
19
timezone
int64
-46,800
43.2k
hash
stringlengths
40
40
message
stringlengths
5
490
mods
list
language
stringclasses
20 values
license
stringclasses
3 values
repo
stringlengths
5
68
original_message
stringlengths
12
491
378,357
11.04.2020 21:41:02
-3,600
7b2e817ed2e4a003e23801517ce533c8e5f4c302
[Build] Update CMake to use C++11 and fix MacOS warnings
[ { "change_type": "MODIFY", "old_path": "src/CMakeLists.txt", "new_path": "src/CMakeLists.txt", "diff": "@@ -32,4 +32,7 @@ endif()\ntarget_link_libraries(libocca ${LIBOCCA_LIBRARIES})\n+target_compile_features(libocca PUBLIC cxx_std_11)\n+target_compile_options(libocca PRIVATE -Wall -Wextra -Wno-c++11-extensions -Wno-unused-parameter)\n+\ninstall(TARGETS libocca DESTINATION lib)\n" }, { "change_type": "MODIFY", "old_path": "src/tools/sys.cpp", "new_path": "src/tools/sys.cpp", "diff": "@@ -62,12 +62,9 @@ namespace occa {\nreturn (double) (ct.tv_sec + (1.0e-9 * ct.tv_nsec));\n#elif (OCCA_OS == OCCA_MACOS_OS)\n# ifdef __clang__\n- uint64_t ct;\n- ct = mach_absolute_time();\n+ uint64_t nanoseconds = clock_gettime_nsec_np(CLOCK_UPTIME_RAW);\n- const Nanoseconds ct2 = AbsoluteToNanoseconds(*(AbsoluteTime *) &ct);\n-\n- return ((double) 1.0e-9) * ((double) ( *((uint64_t*) &ct2) ));\n+ return 1.0e-9 * nanoseconds;\n# else\nclock_serv_t cclock;\nhost_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);\n@@ -366,7 +363,14 @@ namespace occa {\nint getTID() {\n#if (OCCA_OS & (OCCA_LINUX_OS | OCCA_MACOS_OS))\n- return syscall(SYS_gettid);\n+ #if OCCA_OS == OCCA_MACOS_OS & (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_12)\n+ uint64_t tid64;\n+ pthread_threadid_np(NULL, &tid64);\n+ pid_t tid = (pid_t)tid64;\n+ #else\n+ pid_t tid = syscall(SYS_gettid);\n+ #endif\n+ return tid;\n#else\nreturn GetCurrentThreadId();\n#endif\n" } ]
C++
MIT License
libocca/occa
[Build] Update CMake to use C++11 and fix MacOS warnings (#313)
378,349
13.04.2020 23:18:55
14,400
1a39edfff211a778121ae1fd24a91cb8be65a8d6
[Preprocessor] Handles nested parentheses when reading arguments
[ { "change_type": "MODIFY", "old_path": "src/lang/macro.cpp", "new_path": "src/lang/macro.cpp", "diff": "@@ -629,12 +629,12 @@ namespace occa {\nreturn true;\n}\n- const int argc = argCount();\n- int argIndex = 0;\n+ tokenVector argTokens;\n// Count the initial [(] token\nint parenthesesCount = 1;\n+ // Pull all of the argument tokens first\nwhile (true) {\ntoken_t *token = NULL;\npp >> token;\n@@ -656,13 +656,29 @@ namespace occa {\n--parenthesesCount;\nif (!parenthesesCount) {\ndelete token;\n- return true;\n+ break;\n}\n}\n}\n}\n- // Make sure we don't go out of bounds\n+ // Push tokens between the [(] and [)] tokens\n+ argTokens.push_back(token);\n+ }\n+\n+ const int argc = argCount();\n+ int argIndex = 0;\n+ parenthesesCount = 0;\n+\n+ const int tokenCount = (int) argTokens.size();\n+ for (int i = 0; i < tokenCount; ++i) {\n+ token_t *token = argTokens[i];\n+ // Make it easy to free the vector if something goes wrong\n+ argTokens[i] = NULL;\n+\n+ const opType_t opType = token_t::safeOperatorType(token);\n+\n+ // Check if we're adding a new argument and that we don't go out of bounds\nif (argIndex >= (int) args.size()) {\nargs.push_back(tokenVector());\n@@ -679,30 +695,28 @@ namespace occa {\nerrorOn(token,\n\"Macro does not take arguments\");\n}\n- delete token;\n- break;\n+ freeTokenVector(argTokens);\n+ return false;\n}\n}\n- if (token->type() != tokenType::op) {\n- // Add token to current arg\n- args[argIndex].push_back(token);\n+ if ((opType == operatorType::comma) && !parenthesesCount) {\n+ // Starting next argument\n+ ++argIndex;\n+ delete token;\ncontinue;\n}\n- // Check for comma\n- if (token->to<operatorToken>().opType() != operatorType::comma) {\n- // Add token to current arg\n- args[argIndex].push_back(token);\n- continue;\n+ if (opType == operatorType::parenthesesStart) {\n+ ++parenthesesCount;\n+ } else if (opType == operatorType::parenthesesEnd) {\n+ --parenthesesCount;\n}\n- // Starting next argument\n- ++argIndex;\n- delete token;\n+ args[argIndex].push_back(token);\n}\n- return false;\n+ return true;\n}\nbool macro_t::checkArgs(identifierToken &source,\n" }, { "change_type": "MODIFY", "old_path": "tests/src/lang/preprocessor.cpp", "new_path": "tests/src/lang/preprocessor.cpp", "diff": "@@ -125,14 +125,20 @@ void testMacroDefines() {\n\"#define I(...) 5 ##__VA_ARGS__\\n\"\n\"I(11,)\\n\"\n\"I()\\n\"\n- // Errors:\n+ // Test nested parentheses\n+ \"#define J2(A1, A2, A3) A1 A2 A3\\n\"\n+ \"#define J1(A1) J2(A1, (1, 2), ((3), (4)))\\n\"\n+ \"J1(0)\\n\"\n+ // Test Errors:\n// - Argument missing\n- \"C()\\n\"\n+ \"#define Error_A(a) 1\\n\"\n+ \"Error_A()\\n\"\n// - Too many arguments\n- \"D(4, 5, 6)\\n\"\n+ \"#define Error_B(a) 1\\n\"\n+ \"Error_B(4, 5, 6)\\n\"\n// - Test stringify with concat fail\n- \"#define J(A1, A2) # A1 ## A2\\n\"\n- \"J(1, 3)\\n\"\n+ \"#define Error_C(C1, C2) # C1 ## C2\\n\"\n+ \"Error_C(1, 3)\\n\"\n);\nwhile (!tokenStream.isEmpty()) {\ngetToken();\n" } ]
C++
MIT License
libocca/occa
[Preprocessor] Handles nested parentheses when reading arguments (#315)
378,349
14.04.2020 01:17:35
14,400
37c5311e1548589171c1613d3f417909ce77fac1
[Test] Fix issues with MacOS tests (Still fails in Travis)
[ { "change_type": "MODIFY", "old_path": "tests/run_examples", "new_path": "tests/run_examples", "diff": "@@ -83,6 +83,10 @@ for mode in $(\"${OCCA_DIR}/bin/occa\" modes); do\ncd \"${EXAMPLE_DIR}/${example_dir}\"\nmake clean; make\n+ if [[ $(uname -s) == \"Darwin\" || \"${TRAVIS_OS_NAME}\" == \"osx\" ]]; then\n+ install_name_tool -change \"@rpath/libocca.dyld\" \"${OCCA_DIR}/lib/libocca.dylib\" main\n+ fi\n+\noutput=$(./main \"${flags[@]}\" 2>&1)\n# Check for example failures\n" } ]
C++
MIT License
libocca/occa
[Test] Fix @rpath issues with MacOS tests (Still fails in Travis) (#316)
378,349
14.04.2020 01:17:44
14,400
af622f8b68cda16b34c6ebf027dfd36e94ebad0b
[Core] Add support for OCCA_INCLUDE_PATH and OCCA_LIBRARY_PATH
[ { "change_type": "MODIFY", "old_path": "include/occa/modes/cuda/device.hpp", "new_path": "include/occa/modes/cuda/device.hpp", "diff": "@@ -65,7 +65,8 @@ namespace occa {\nconst occa::properties &kernelProps,\nio::lock_t lock);\n- void setArchCompilerFlags(occa::properties &kernelProps);\n+ void setArchCompilerFlags(const occa::properties &kernelProps,\n+ std::string &compilerFlags);\nvoid compileKernel(const std::string &hashDir,\nconst std::string &kernelName,\n" }, { "change_type": "MODIFY", "old_path": "include/occa/tools/env.hpp", "new_path": "include/occa/tools/env.hpp", "diff": "@@ -15,7 +15,8 @@ namespace occa {\nextern std::string OCCA_DIR, OCCA_CACHE_DIR;\nextern size_t OCCA_MEM_BYTE_ALIGN;\n- extern strVector OCCA_PATH;\n+ extern strVector OCCA_INCLUDE_PATH;\n+ extern strVector OCCA_LIBRARY_PATH;\nextern bool OCCA_COLOR_ENABLED;\nproperties& baseSettings();\n" }, { "change_type": "MODIFY", "old_path": "include/occa/tools/sys.hpp", "new_path": "include/occa/tools/sys.hpp", "diff": "@@ -94,7 +94,11 @@ namespace occa {\nstd::string compilerSharedBinaryFlags(const std::string &compiler);\nstd::string compilerSharedBinaryFlags(const int vendor_);\n+ void addCompilerIncludeFlags(std::string &compilerFlags);\n+ void addCompilerLibraryFlags(std::string &compilerFlags);\n+\nvoid addCompilerFlags(std::string &compilerFlags, const std::string &flags);\n+ void addCompilerFlags(std::string &compilerFlags, const strVector &flags);\n//==================================\n//---[ Dynamic Methods ]------------\n" }, { "change_type": "MODIFY", "old_path": "src/lang/preprocessor.cpp", "new_path": "src/lang/preprocessor.cpp", "diff": "@@ -28,25 +28,24 @@ namespace occa {\ninit();\ninitDirectives();\n- if (!settings_.has(\"okl/include_paths\")) {\n- return;\n- }\n-\n- json paths = settings_[\"okl/include_paths\"];\n- if (!paths.isArray()) {\n- return;\n- }\n+ includePaths = env::OCCA_INCLUDE_PATH;\n- jsonArray pathArray = paths.array();\n+ json oklIncludePaths = settings_[\"okl/include_paths\"];\n+ if (oklIncludePaths.isArray()) {\n+ jsonArray pathArray = oklIncludePaths.array();\nconst int pathCount = (int) pathArray.size();\nfor (int i = 0; i < pathCount; ++i) {\njson path = pathArray[i];\nif (path.isString()) {\n- std::string pathStr = path;\n- io::endWithSlash(pathStr);\n- includePaths.push_back(pathStr);\n+ includePaths.push_back(path);\n+ }\n}\n}\n+\n+ const int includePathCount = (int) includePaths.size();\n+ for (int i = 0; i < includePathCount; ++i) {\n+ io::endWithSlash(includePaths[i]);\n+ }\n}\npreprocessor_t::preprocessor_t(const preprocessor_t &pp) :\n" }, { "change_type": "MODIFY", "old_path": "src/modes/cuda/device.cpp", "new_path": "src/modes/cuda/device.cpp", "diff": "@@ -238,13 +238,12 @@ namespace occa {\nkernelProps);\n}\n- void device::setArchCompilerFlags(occa::properties &kernelProps) {\n- if (kernelProps.get<std::string>(\"compiler_flags\").find(\"-arch=sm_\") == std::string::npos) {\n- const int major = archMajorVersion;\n- const int minor = archMinorVersion;\n- std::stringstream ss;\n- ss << \" -arch=sm_\" << major << minor << ' ';\n- kernelProps[\"compiler_flags\"] += ss.str();\n+ void device::setArchCompilerFlags(const occa::properties &kernelProps,\n+ std::string &compilerFlags) {\n+ if (compilerFlags.find(\"-arch=sm_\") == std::string::npos) {\n+ compilerFlags += \" -arch=sm_\";\n+ compilerFlags += std::to_string(archMajorVersion);\n+ compilerFlags += std::to_string(archMinorVersion);\n}\n}\n@@ -260,7 +259,16 @@ namespace occa {\nstd::string binaryFilename = hashDir + kc::binaryFile;\nconst std::string ptxBinaryFilename = hashDir + \"ptx_binary.o\";\n- setArchCompilerFlags(allProps);\n+ const std::string compiler = allProps[\"compiler\"];\n+ std::string compilerFlags = allProps[\"compiler_flags\"];\n+ const bool compilingOkl = allProps.get(\"okl/enabled\", true);\n+\n+ setArchCompilerFlags(allProps, compilerFlags);\n+\n+ if (!compilingOkl) {\n+ sys::addCompilerIncludeFlags(compilerFlags);\n+ sys::addCompilerLibraryFlags(compilerFlags);\n+ }\n//---[ PTX Check Command ]--------\nstd::stringstream command;\n@@ -268,8 +276,8 @@ namespace occa {\ncommand << allProps[\"compiler_env_script\"] << \" && \";\n}\n- command << allProps[\"compiler\"]\n- << ' ' << allProps[\"compiler_flags\"]\n+ command << compiler\n+ << ' ' << compilerFlags\n<< \" -Xptxas -v,-dlcm=cg\"\n#if (OCCA_OS == OCCA_WINDOWS_OS)\n<< \" -D OCCA_OS=OCCA_WINDOWS_OS -D _MSC_VER=1800\"\n" }, { "change_type": "MODIFY", "old_path": "src/modes/serial/device.cpp", "new_path": "src/modes/serial/device.cpp", "diff": "@@ -265,6 +265,7 @@ namespace occa {\nstd::string sourceFilename;\nlang::sourceMetadata_t metadata;\n+ const bool compilingOkl = kernelProps.get(\"okl/enabled\", true);\nconst bool compilingCpp = (\n((int) kernelProps[\"compiler_language\"]) == sys::language::CPP\n);\n@@ -286,7 +287,7 @@ namespace occa {\nassembleKernelHeader(kernelProps))\n);\n- if (kernelProps.get(\"okl/enabled\", true)) {\n+ if (compilingOkl) {\nconst std::string outputFile = hashDir + kc::sourceFile;\nbool valid = parseFile(sourceFilename,\noutputFile,\n@@ -317,6 +318,11 @@ namespace occa {\nsys::addCompilerFlags(compilerFlags, compilerSharedFlags);\n+ if (!compilingOkl) {\n+ sys::addCompilerIncludeFlags(compilerFlags);\n+ sys::addCompilerLibraryFlags(compilerFlags);\n+ }\n+\n#if (OCCA_OS & (OCCA_LINUX_OS | OCCA_MACOS_OS))\ncommand << compiler\n<< ' ' << compilerFlags\n" }, { "change_type": "MODIFY", "old_path": "src/tools/env.cpp", "new_path": "src/tools/env.cpp", "diff": "@@ -22,7 +22,8 @@ namespace occa {\nstd::string OCCA_DIR, OCCA_CACHE_DIR;\nsize_t OCCA_MEM_BYTE_ALIGN;\n- strVector OCCA_PATH;\n+ strVector OCCA_INCLUDE_PATH;\n+ strVector OCCA_LIBRARY_PATH;\nbool OCCA_COLOR_ENABLED;\nproperties& baseSettings() {\n@@ -49,7 +50,6 @@ namespace occa {\nloadConfig();\nsetupCachePath();\n- setupIncludePath();\nregisterFileOpeners();\nisInitialized = true;\n@@ -79,6 +79,9 @@ namespace occa {\nOCCA_CACHE_DIR = env::var(\"OCCA_CACHE_DIR\");\nOCCA_COLOR_ENABLED = env::get<bool>(\"OCCA_COLOR_ENABLED\", true);\n+ OCCA_INCLUDE_PATH = split(env::var(\"OCCA_INCLUDE_PATH\"), ':', '\\\\');\n+ OCCA_LIBRARY_PATH = split(env::var(\"OCCA_LIBRARY_PATH\"), ':', '\\\\');\n+\nio::endWithSlash(HOME);\nio::endWithSlash(CWD);\nio::endWithSlash(PATH);\n@@ -148,37 +151,6 @@ namespace occa {\n}\n}\n- void envInitializer_t::setupIncludePath() {\n- std::string envPath = env::var(\"OCCA_PATH\");\n- if (!envPath.size()) {\n- return;\n- }\n-\n- // Override OCCA_PATH with environment variable\n- env::OCCA_PATH.clear();\n-\n- const char *cStart = envPath.c_str();\n- const char *cEnd;\n- while(cStart[0] != '\\0') {\n- cEnd = cStart;\n-#if (OCCA_OS & (OCCA_LINUX_OS | OCCA_MACOS_OS))\n- lex::skipTo(cEnd, ':');\n-#else\n- lex::skipTo(cEnd, ';');\n-#endif\n-\n- if (0 < (cEnd - cStart)) {\n- std::string newPath(cStart, cEnd - cStart);\n- newPath = io::filename(newPath);\n- io::endWithSlash(newPath);\n-\n- env::OCCA_PATH.push_back(newPath);\n- }\n-\n- cStart = (cEnd + (cEnd[0] != '\\0'));\n- }\n- }\n-\nvoid envInitializer_t::registerFileOpeners() {\nio::fileOpener::add(new io::occaFileOpener());\n}\n" }, { "change_type": "MODIFY", "old_path": "src/tools/sys.cpp", "new_path": "src/tools/sys.cpp", "diff": "@@ -772,12 +772,39 @@ namespace occa {\nreturn \"\";\n}\n+ void addCompilerIncludeFlags(std::string &compilerFlags) {\n+ strVector includeDirs = env::OCCA_INCLUDE_PATH;\n+\n+ const int count = (int) includeDirs.size();\n+ for (int i = 0; i < count; ++i) {\n+ includeDirs[i] = \"-I\" + includeDirs[i];\n+ }\n+\n+ addCompilerFlags(compilerFlags, includeDirs);\n+ }\n+\n+ void addCompilerLibraryFlags(std::string &compilerFlags) {\n+ strVector libraryDirs = env::OCCA_LIBRARY_PATH;\n+\n+ const int count = (int) libraryDirs.size();\n+ for (int i = 0; i < count; ++i) {\n+ libraryDirs[i] = \"-L\" + libraryDirs[i];\n+ }\n+\n+ addCompilerFlags(compilerFlags, libraryDirs);\n+ }\n+\nvoid addCompilerFlags(std::string &compilerFlags, const std::string &flags) {\n- strVector compilerFlagsVec = split(compilerFlags, ' ');\nconst strVector flagsVec = split(flags, ' ');\n+ addCompilerFlags(compilerFlags, flagsVec);\n+ }\n+\n+ void addCompilerFlags(std::string &compilerFlags, const strVector &flags) {\n+ strVector compilerFlagsVec = split(compilerFlags, ' ');\n- for (int i = 0; i < (int) flagsVec.size(); ++i) {\n- const std::string &flag = flagsVec[i];\n+ const int flagCount = (int) flags.size();\n+ for (int i = 0; i < flagCount; ++i) {\n+ const std::string &flag = flags[i];\nif (indexOf(compilerFlagsVec, flag) < 0) {\ncompilerFlagsVec.push_back(flag);\n}\n" } ]
C++
MIT License
libocca/occa
[Core] Add support for OCCA_INCLUDE_PATH and OCCA_LIBRARY_PATH (#317)
378,356
14.04.2020 23:40:14
-36,000
6a620f24354f544e40dc60399b088d6ff635f576
[C] Use from stdbool.h for boolean types
[ { "change_type": "MODIFY", "old_path": "include/occa/c/types.h", "new_path": "include/occa/c/types.h", "diff": "#define OCCA_C_TYPES_HEADER\n#include <stdint.h>\n+#include <stdbool.h>\n#include <stdlib.h>\n#include <occa/c/defines.h>\n@@ -19,7 +20,7 @@ typedef struct {\nint magicHeader;\nint type;\noccaUDim_t bytes;\n- char needsFree;\n+ bool needsFree;\nunion {\nuint8_t uint8_;\n@@ -99,7 +100,7 @@ OCCA_LFUNC int OCCA_RFUNC occaIsDefault(occaType value);\nOCCA_LFUNC occaType OCCA_RFUNC occaPtr(void *value);\n-OCCA_LFUNC occaType OCCA_RFUNC occaBool(int value);\n+OCCA_LFUNC occaType OCCA_RFUNC occaBool(bool value);\nOCCA_LFUNC occaType OCCA_RFUNC occaInt8(int8_t value);\nOCCA_LFUNC occaType OCCA_RFUNC occaUInt8(uint8_t value);\n" }, { "change_type": "MODIFY", "old_path": "src/c/types.cpp", "new_path": "src/c/types.cpp", "diff": "@@ -667,8 +667,8 @@ OCCA_LFUNC occaType OCCA_RFUNC occaPtr(void *value) {\nreturn occa::c::newOccaType(value);\n}\n-OCCA_LFUNC occaType OCCA_RFUNC occaBool(int value) {\n- return occa::c::newOccaType((bool) value);\n+OCCA_LFUNC occaType OCCA_RFUNC occaBool(bool value) {\n+ return occa::c::newOccaType(value);\n}\nOCCA_LFUNC occaType OCCA_RFUNC occaInt8(int8_t value) {\n" } ]
C++
MIT License
libocca/occa
[C] Use from stdbool.h for boolean types (#318)
378,354
14.04.2020 18:59:07
-19,080
8fb5f93536b9e8accea3ae5154e9dbbde2547350
[CUDA] ptx compilation in native CUDA mode was missing include files
[ { "change_type": "MODIFY", "old_path": "src/modes/cuda/device.cpp", "new_path": "src/modes/cuda/device.cpp", "diff": "@@ -305,7 +305,7 @@ namespace occa {\n//---[ Compiling Command ]--------\ncommand.str(\"\");\ncommand << allProps[\"compiler\"]\n- << ' ' << allProps[\"compiler_flags\"]\n+ << ' ' << compilerFlags\n<< \" -ptx\"\n#if (OCCA_OS == OCCA_WINDOWS_OS)\n<< \" -D OCCA_OS=OCCA_WINDOWS_OS -D _MSC_VER=1800\"\n" } ]
C++
MIT License
libocca/occa
[CUDA] ptx compilation in native CUDA mode was missing include files (#319)
378,349
14.04.2020 20:10:11
14,400
327badbed03fb6acd332d5ef8a8c4e7709476fc8
[OpenCl] Fix slice of slices, can't take subbuffers of subbuffers...
[ { "change_type": "MODIFY", "old_path": "include/occa/modes/opencl/memory.hpp", "new_path": "include/occa/modes/opencl/memory.hpp", "diff": "@@ -21,6 +21,9 @@ namespace occa {\nconst occa::properties &props);\nprivate:\n+ cl_mem *rootClMem;\n+ dim_t rootOffset;\n+\ncl_mem clMem;\nvoid *mappedPtr;\n" }, { "change_type": "MODIFY", "old_path": "src/modes/opencl/device.cpp", "new_path": "src/modes/opencl/device.cpp", "diff": "@@ -339,6 +339,8 @@ namespace occa {\nfinish();\n}\n+ mem->rootClMem = &mem->clMem;\n+\nreturn mem;\n}\n@@ -355,6 +357,7 @@ namespace occa {\nCL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR,\nbytes,\nNULL, &error);\n+ mem->rootClMem = &mem->clMem;\nOCCA_OPENCL_ERROR(\"Device: clCreateBuffer\", error);\n" }, { "change_type": "MODIFY", "old_path": "src/modes/opencl/memory.cpp", "new_path": "src/modes/opencl/memory.cpp", "diff": "@@ -9,10 +9,13 @@ namespace occa {\nudim_t size_,\nconst occa::properties &properties_) :\nocca::modeMemory_t(modeDevice_, size_, properties_),\n+ rootClMem(&clMem),\n+ rootOffset(0),\nmappedPtr(NULL) {}\nmemory::~memory() {\nif (isOrigin) {\n+ // Free mapped-host pointer\nif (mappedPtr) {\nOCCA_OPENCL_ERROR(\"Mapped Free: clEnqueueUnmapMemObject\",\nclEnqueueUnmapMemObject(getCommandQueue(),\n@@ -20,12 +23,17 @@ namespace occa {\nmappedPtr,\n0, NULL, NULL));\n}\n- if (size) {\n- // Free mapped-host pointer\n+ }\n+\n+ // Is the root cl_mem or the root cl_mem hasn't been freed yet\n+ if (size && (isOrigin || *rootClMem)) {\nOCCA_OPENCL_ERROR(\"Mapped Free: clReleaseMemObject\",\nclReleaseMemObject(clMem));\n}\n- }\n+\n+ rootClMem = NULL;\n+ rootOffset = 0;\n+\nclMem = NULL;\nmappedPtr = NULL;\nsize = 0;\n@@ -51,12 +59,15 @@ namespace occa {\nsize - offset,\nproperties);\n+ m->rootClMem = rootClMem;\n+ m->rootOffset = rootOffset + offset;\n+\ncl_buffer_region info;\n- info.origin = offset;\n+ info.origin = m->rootOffset;\ninfo.size = m->size;\ncl_int error;\n- m->clMem = clCreateSubBuffer(clMem,\n+ m->clMem = clCreateSubBuffer(*rootClMem,\nCL_MEM_READ_WRITE,\nCL_BUFFER_CREATE_TYPE_REGION,\n&info,\n" } ]
C++
MIT License
libocca/occa
[OpenCl] Fix slice of slices, can't take subbuffers of subbuffers... (#278)
378,349
15.04.2020 03:22:39
14,400
f0b26b77acb3e0b9493faab6d1c380abc94534da
[C] Update occaFree
[ { "change_type": "MODIFY", "old_path": "examples/c/01_add_vectors/main.c", "new_path": "examples/c/01_add_vectors/main.c", "diff": "@@ -105,13 +105,13 @@ int main(int argc, const char **argv) {\nfree(ab);\n// Free device memory and occa objects\n- occaFree(args);\n- occaFree(props);\n- occaFree(addVectors);\n- occaFree(o_a);\n- occaFree(o_b);\n- occaFree(o_ab);\n- occaFree(device);\n+ occaFree(&args);\n+ occaFree(&props);\n+ occaFree(&addVectors);\n+ occaFree(&o_a);\n+ occaFree(&o_b);\n+ occaFree(&o_ab);\n+ occaFree(&device);\n}\noccaJson parseArgs(int argc, const char **argv) {\n" }, { "change_type": "MODIFY", "old_path": "examples/c/02_background_device/main.c", "new_path": "examples/c/02_background_device/main.c", "diff": "@@ -67,8 +67,8 @@ int main(int argc, const char **argv) {\n}\n}\n- occaFree(args);\n- occaFree(addVectors);\n+ occaFree(&args);\n+ occaFree(&addVectors);\noccaFreeUvaPtr(a);\noccaFreeUvaPtr(b);\noccaFreeUvaPtr(ab);\n" }, { "change_type": "MODIFY", "old_path": "examples/c/03_inline_okl/main.c", "new_path": "examples/c/03_inline_okl/main.c", "diff": "@@ -69,9 +69,9 @@ int main(int argc, const char **argv) {\n}\n}\n- occaFree(args);\n- occaFree(props);\n- occaFree(scope);\n+ occaFree(&args);\n+ occaFree(&props);\n+ occaFree(&scope);\noccaFreeUvaPtr(a);\noccaFreeUvaPtr(b);\noccaFreeUvaPtr(ab);\n" }, { "change_type": "MODIFY", "old_path": "examples/c/04_reduction/main.c", "new_path": "examples/c/04_reduction/main.c", "diff": "@@ -87,11 +87,11 @@ int main(int argc, const char **argv) {\nfree(vec);\nfree(blockSum);\n- occaFree(args);\n- occaFree(reductionProps);\n- occaFree(reduction);\n- occaFree(o_vec);\n- occaFree(o_blockSum);\n+ occaFree(&args);\n+ occaFree(&reductionProps);\n+ occaFree(&reduction);\n+ occaFree(&o_vec);\n+ occaFree(&o_blockSum);\nreturn 0;\n}\n" }, { "change_type": "MODIFY", "old_path": "include/occa/c/types.h", "new_path": "include/occa/c/types.h", "diff": "@@ -137,7 +137,7 @@ OCCA_LFUNC occaType OCCA_RFUNC occaStruct(const void *value,\nOCCA_LFUNC occaType OCCA_RFUNC occaString(const char *str);\n//======================================\n-OCCA_LFUNC void OCCA_RFUNC occaFree(occaType value);\n+OCCA_LFUNC void OCCA_RFUNC occaFree(occaType *value);\nOCCA_END_EXTERN_C\n" }, { "change_type": "MODIFY", "old_path": "src/c/types.cpp", "new_path": "src/c/types.cpp", "diff": "@@ -767,56 +767,58 @@ OCCA_LFUNC occaType OCCA_RFUNC occaString(const char *str) {\n}\n//======================================\n-OCCA_LFUNC void OCCA_RFUNC occaFree(occaType value) {\n- if (occaIsUndefined(value)) {\n+OCCA_LFUNC void OCCA_RFUNC occaFree(occaType *value) {\n+ occaType &valueRef = *value;\n+\n+ if (occaIsUndefined(valueRef)) {\nreturn;\n}\n- switch (value.type) {\n+ switch (valueRef.type) {\ncase occa::c::typeType::device: {\n- occa::c::device(value).free();\n+ occa::c::device(valueRef).free();\nbreak;\n}\ncase occa::c::typeType::kernel: {\n- occa::c::kernel(value).free();\n+ occa::c::kernel(valueRef).free();\nbreak;\n}\ncase occa::c::typeType::kernelBuilder: {\n- occa::c::kernelBuilder(value).free();\n+ occa::c::kernelBuilder(valueRef).free();\nbreak;\n}\ncase occa::c::typeType::memory: {\n- occa::c::memory(value).free();\n+ occa::c::memory(valueRef).free();\nbreak;\n}\ncase occa::c::typeType::stream: {\n- occa::c::stream(value).free();\n+ occa::c::stream(valueRef).free();\nbreak;\n}\ncase occa::c::typeType::streamTag: {\n- occa::c::streamTag(value).free();\n+ occa::c::streamTag(valueRef).free();\nbreak;\n}\ncase occa::c::typeType::dtype: {\n- delete &occa::c::dtype(value);\n+ delete &occa::c::dtype(valueRef);\nbreak;\n}\ncase occa::c::typeType::scope: {\n- delete &occa::c::scope(value);\n+ delete &occa::c::scope(valueRef);\nbreak;\n}\ncase occa::c::typeType::json: {\n- if (value.needsFree) {\n- delete &occa::c::json(value);\n+ if (valueRef.needsFree) {\n+ delete &occa::c::json(valueRef);\n}\nbreak;\n}\ncase occa::c::typeType::properties: {\n- if (value.needsFree) {\n- delete &occa::c::properties(value);\n+ if (valueRef.needsFree) {\n+ delete &occa::c::properties(valueRef);\n}\nbreak;\n}}\n- value.magicHeader = occaUndefined.magicHeader;\n+ valueRef.magicHeader = occaUndefined.magicHeader;\n}\nOCCA_END_EXTERN_C\n" }, { "change_type": "MODIFY", "old_path": "tests/run_examples", "new_path": "tests/run_examples", "diff": "@@ -9,6 +9,10 @@ ASAN_OPTIONS+=':detect_container_overflow=0'\nHEADER_CHARS=80\n+if [[ $(uname -s) == \"Darwin\" || \"${TRAVIS_OS_NAME}\" == \"osx\" ]]; then\n+ export DYLD_LIBRARY_PATH=\"${OCCA_DIR}/lib:${DYLD_LIBRARY_PATH}\"\n+fi\n+\ndeclare -a examples=(\ncpp/01_add_vectors\ncpp/02_background_device\n@@ -83,10 +87,6 @@ for mode in $(\"${OCCA_DIR}/bin/occa\" modes); do\ncd \"${EXAMPLE_DIR}/${example_dir}\"\nmake clean; make\n- if [[ $(uname -s) == \"Darwin\" || \"${TRAVIS_OS_NAME}\" == \"osx\" ]]; then\n- install_name_tool -change \"@rpath/libocca.dyld\" \"${OCCA_DIR}/lib/libocca.dylib\" main\n- fi\n-\noutput=$(./main \"${flags[@]}\" 2>&1)\n# Check for example failures\n" }, { "change_type": "MODIFY", "old_path": "tests/src/c/base.cpp", "new_path": "tests/src/c/base.cpp", "diff": "@@ -68,14 +68,14 @@ void testMemoryMethods() {\noccaDefault);\nASSERT_EQ(occaMemorySize(mem),\nbytes);\n- occaFree(mem);\n+ occaFree(&mem);\nmem = occaMalloc(bytes,\nNULL,\nprops);\nASSERT_EQ(occaMemorySize(mem),\nbytes);\n- occaFree(mem);\n+ occaFree(&mem);\n// umalloc\nvoid *ptr = occaUMalloc(bytes,\n@@ -88,7 +88,7 @@ void testMemoryMethods() {\nprops);\noccaFreeUvaPtr(ptr);\n- occaFree(props);\n+ occaFree(&props);\n}\nvoid testKernelMethods() {\n@@ -111,36 +111,36 @@ void testKernelMethods() {\nocca::c::kernel(addVectors).binaryFilename()\n);\n- occaFree(addVectors);\n+ occaFree(&addVectors);\naddVectors = occaBuildKernel(addVectorsFile.c_str(),\n\"addVectors\",\nprops);\n- occaFree(addVectors);\n+ occaFree(&addVectors);\n// occaBuildFromString\naddVectors = occaBuildKernelFromString(addVectorsSource.c_str(),\n\"addVectors\",\noccaDefault);\n- occaFree(addVectors);\n+ occaFree(&addVectors);\naddVectors = occaBuildKernelFromString(addVectorsSource.c_str(),\n\"addVectors\",\nprops);\n- occaFree(addVectors);\n+ occaFree(&addVectors);\n// occaBuildFromBinary\naddVectors = occaBuildKernelFromBinary(addVectorsBinaryFile.c_str(),\n\"addVectors\",\noccaDefault);\n- occaFree(addVectors);\n+ occaFree(&addVectors);\naddVectors = occaBuildKernelFromBinary(addVectorsBinaryFile.c_str(),\n\"addVectors\",\nprops);\n- occaFree(addVectors);\n+ occaFree(&addVectors);\n- occaFree(props);\n+ occaFree(&props);\n}\nvoid testStreamMethods() {\n@@ -176,5 +176,5 @@ void testStreamMethods() {\nASSERT_LE(innerEnd - innerStart,\ntagTime);\n- occaFree(cStream);\n+ occaFree(&cStream);\n}\n" }, { "change_type": "MODIFY", "old_path": "tests/src/c/device.cpp", "new_path": "tests/src/c/device.cpp", "diff": "@@ -39,7 +39,7 @@ int main(const int argc, const char **argv) {\ntestKernelMethods();\ntestStreamMethods();\n- occaFree(props);\n+ occaFree(&props);\nreturn 0;\n}\n@@ -55,7 +55,7 @@ void testInit() {\nASSERT_EQ(device.type,\nOCCA_DEVICE);\n- occaFree(device);\n+ occaFree(&device);\ndevice = occaCreateDevice(\noccaString(deviceStr.c_str())\n@@ -69,7 +69,7 @@ void testInit() {\noccaDeviceFinish(device);\n- occaFree(device);\n+ occaFree(&device);\n}\nvoid testProperties() {\noccaDevice device = occaUndefined;\n@@ -91,7 +91,7 @@ void testProperties() {\noccaProperties memoryProps = occaDeviceGetMemoryProperties(device);\nASSERT_TRUE(occaPropertiesHas(memoryProps, \"mkey\"));\n- occaFree(device);\n+ occaFree(&device);\n}\nvoid testMemoryMethods() {\n@@ -134,13 +134,13 @@ void testMemoryMethods() {\nallocatedBytes);\n// Free\n- occaFree(mem1);\n+ occaFree(&mem1);\nallocatedBytes -= memBytes;\nASSERT_EQ((size_t) occaDeviceMemoryAllocated(device),\nallocatedBytes);\n- occaFree(mem2);\n+ occaFree(&mem2);\nallocatedBytes -= memBytes;\nASSERT_EQ((size_t) occaDeviceMemoryAllocated(device),\n@@ -159,7 +159,7 @@ void testMemoryMethods() {\nASSERT_EQ((size_t) occaDeviceMemoryAllocated(device),\nallocatedBytes);\n- occaFree(device);\n+ occaFree(&device);\n}\nvoid testKernelMethods() {\n@@ -182,41 +182,41 @@ void testKernelMethods() {\nocca::c::kernel(addVectors).binaryFilename()\n);\n- occaFree(addVectors);\n+ occaFree(&addVectors);\naddVectors = occaDeviceBuildKernel(device,\naddVectorsFile.c_str(),\n\"addVectors\",\nprops);\n- occaFree(addVectors);\n+ occaFree(&addVectors);\n// occaBuildFromString\naddVectors = occaDeviceBuildKernelFromString(device,\naddVectorsSource.c_str(),\n\"addVectors\",\noccaDefault);\n- occaFree(addVectors);\n+ occaFree(&addVectors);\naddVectors = occaDeviceBuildKernelFromString(device,\naddVectorsSource.c_str(),\n\"addVectors\",\nprops);\n- occaFree(addVectors);\n+ occaFree(&addVectors);\n// occaBuildFromBinary\naddVectors = occaDeviceBuildKernelFromBinary(device,\naddVectorsBinaryFile.c_str(),\n\"addVectors\",\noccaDefault);\n- occaFree(addVectors);\n+ occaFree(&addVectors);\naddVectors = occaDeviceBuildKernelFromBinary(device,\naddVectorsBinaryFile.c_str(),\n\"addVectors\",\nprops);\n- occaFree(addVectors);\n+ occaFree(&addVectors);\n- occaFree(device);\n+ occaFree(&device);\n}\nvoid testStreamMethods() {\n@@ -255,6 +255,6 @@ void testStreamMethods() {\nASSERT_LE(innerEnd - innerStart,\ntagTime);\n- occaFree(cStream);\n- occaFree(device);\n+ occaFree(&cStream);\n+ occaFree(&device);\n}\n" }, { "change_type": "MODIFY", "old_path": "tests/src/c/dtype.cpp", "new_path": "tests/src/c/dtype.cpp", "diff": "@@ -92,12 +92,12 @@ void testDtype() {\noccaDtypesMatch(foo3, foo4)\n);\n- occaFree(fakeFloat);\n- occaFree(fakeDouble);\n- occaFree(foo1);\n- occaFree(foo2);\n- occaFree(foo3);\n- occaFree(foo4);\n+ occaFree(&fakeFloat);\n+ occaFree(&fakeDouble);\n+ occaFree(&foo1);\n+ occaFree(&foo2);\n+ occaFree(&foo3);\n+ occaFree(&foo4);\n}\nvoid testJsonMethods() {\n@@ -162,11 +162,11 @@ void testJsonMethods() {\n::free((void*) fooJsonStr);\n::free((void*) rawFooJsonStr);\n- occaFree(doubleJson);\n- occaFree(rawDoubleJson);\n- occaFree(foo);\n- occaFree(fooJson);\n- occaFree(rawFooJson);\n- occaFree(foo2);\n- occaFree(foo3);\n+ occaFree(&doubleJson);\n+ occaFree(&rawDoubleJson);\n+ occaFree(&foo);\n+ occaFree(&fooJson);\n+ occaFree(&rawFooJson);\n+ occaFree(&foo2);\n+ occaFree(&foo3);\n}\n" }, { "change_type": "MODIFY", "old_path": "tests/src/c/json.cpp", "new_path": "tests/src/c/json.cpp", "diff": "@@ -32,7 +32,7 @@ int main(const int argc, const char **argv) {\ntestSerialization();\ntestCasting();\n- occaFree(cJson);\n+ occaFree(&cJson);\nreturn 0;\n}\n@@ -81,7 +81,7 @@ void testTypeChecking() {\nASSERT_TRUE(occaJsonObjectHas(cJson2, \"string\"));\nASSERT_TRUE(occaJsonObjectHas(cJson2, \"array\"));\n- occaFree(cJson2);\n+ occaFree(&cJson2);\n}\nvoid testTypes() {\n@@ -179,7 +179,7 @@ void testTypes() {\nASSERT_TRUE(occaJsonIsObject(propValue));\nASSERT_TRUE(occaJsonObjectHas(propValue, \"value\"));\n- occaFree(cJson2);\n+ occaFree(&cJson2);\n}\nvoid testArray() {\n@@ -238,7 +238,7 @@ void testArray() {\noccaJsonArrayClear(array);\nASSERT_EQ(occaJsonArraySize(array), 0);\n- occaFree(array);\n+ occaFree(&array);\n}\nvoid testBadType() {\n@@ -286,7 +286,7 @@ void testSerialization() {\nASSERT_EQ(props,\nprops2);\n- occaFree(cJson2);\n+ occaFree(&cJson2);\n}\nvoid testCasting() {\n@@ -307,5 +307,5 @@ void testCasting() {\noccaJsonCastToObject(cJson2);\nASSERT_TRUE(occaJsonIsObject(cJson2));\n- occaFree(cJson2);\n+ occaFree(&cJson2);\n}\n" }, { "change_type": "MODIFY", "old_path": "tests/src/c/kernel.cpp", "new_path": "tests/src/c/kernel.cpp", "diff": "@@ -23,7 +23,7 @@ int main(const int argc, const char **argv) {\ntestInfo();\ntestRun();\n- occaFree(addVectors);\n+ occaFree(&addVectors);\nreturn 0;\n}\n@@ -92,7 +92,7 @@ void testRun() {\n\"argKernel\",\nkernelProps)\n);\n- occaFree(kernelProps);\n+ occaFree(&kernelProps);\n// Dummy dims\noccaDim outerDims, innerDims;\n" }, { "change_type": "MODIFY", "old_path": "tests/src/c/memory.cpp", "new_path": "tests/src/c/memory.cpp", "diff": "@@ -72,9 +72,9 @@ void testInit() {\nASSERT_EQ(ptr[0], 1);\nASSERT_EQ(ptr[1], 2);\n- occaFree(props);\n- occaFree(subMem);\n- occaFree(mem);\n+ occaFree(&props);\n+ occaFree(&subMem);\n+ occaFree(&mem);\ndelete [] data;\n}\n@@ -117,7 +117,7 @@ void testUvaMethods() {\noccaMemorySyncToDevice(mem, occaAllBytes, 0);\noccaMemorySyncToHost(mem, occaAllBytes, 0);\n- occaFree(mem);\n+ occaFree(&mem);\n}\nvoid testCopyMethods() {\n@@ -190,8 +190,8 @@ void testCopyMethods() {\nprops);\nASSERT_EQ(ptr2[1], 1);\n- occaFree(mem2);\n- occaFree(mem4);\n+ occaFree(&mem2);\n+ occaFree(&mem4);\n// UVA memory copy\nint *o_data2 = (int*) occaUMalloc(bytes2, data2, occaDefault);\n@@ -228,7 +228,7 @@ void testCopyMethods() {\ndelete [] data4;\noccaFreeUvaPtr(o_data2);\noccaFreeUvaPtr(o_data4);\n- occaFree(props);\n+ occaFree(&props);\n}\nvoid testInteropMethods() {\n@@ -275,7 +275,7 @@ void testInteropMethods() {\nbytes,\nprops);\n- occaFree(mem1);\n- occaFree(mem2);\n- occaFree(props);\n+ occaFree(&mem1);\n+ occaFree(&mem2);\n+ occaFree(&props);\n}\n" }, { "change_type": "MODIFY", "old_path": "tests/src/c/properties.cpp", "new_path": "tests/src/c/properties.cpp", "diff": "@@ -27,7 +27,7 @@ int main(const int argc, const char **argv) {\ntestKeyMiss();\ntestSerialization();\n- occaFree(cProps);\n+ occaFree(&cProps);\nreturn 0;\n}\n@@ -127,7 +127,7 @@ void testTypes() {\nASSERT_TRUE(occaJsonIsObject(propValue));\nASSERT_TRUE(occaJsonObjectHas(propValue, \"value\"));\n- occaFree(cProps2);\n+ occaFree(&cProps2);\n}\nvoid testBadType() {\n@@ -175,7 +175,7 @@ void testSerialization() {\nASSERT_EQ(props,\nprops2);\n- occaFree(cProps2);\n+ occaFree(&cProps2);\n}\nvoid testCasting() {\n@@ -196,5 +196,5 @@ void testCasting() {\noccaJsonCastToObject(cProps2);\nASSERT_TRUE(occaJsonIsObject(cProps2));\n- occaFree(cProps2);\n+ occaFree(&cProps2);\n}\n" }, { "change_type": "MODIFY", "old_path": "tests/src/c/types.cpp", "new_path": "tests/src/c/types.cpp", "diff": "@@ -18,7 +18,7 @@ void testNewOccaTypes() {\ndo { \\\noccaType v = occa::c::newOccaType(VALUE); \\\nASSERT_EQ(v.type, OCCA_TYPE); \\\n- occaFree(v); \\\n+ occaFree(&v); \\\n} while (0)\noccaType value = occaUndefined;\n@@ -46,13 +46,13 @@ void testNewOccaTypes() {\n{\noccaType v = occa::c::newOccaType(*(new occa::properties()), true);\nASSERT_EQ(v.type, OCCA_PROPERTIES);\n- occaFree(v);\n+ occaFree(&v);\n}\n{\nocca::properties props;\noccaType v = occa::c::newOccaType(props, false);\nASSERT_EQ(v.type, OCCA_PROPERTIES);\n- occaFree(v);\n+ occaFree(&v);\n}\noccaProperties cProps = (\n@@ -63,7 +63,7 @@ void testNewOccaTypes() {\n1);\nASSERT_EQ((int) props[\"b\"],\n2);\n- occaFree(cProps);\n+ occaFree(&cProps);\n#undef TEST_OCCA_TYPE\n}\n" } ]
C++
MIT License
libocca/occa
[C] Update occaFree (#322)
378,355
15.04.2020 20:47:19
18,000
d916f6cfbec003c65dccae39ddf4fd47848c6533
[Cmake] HIP/CUDA/OpenCL on AMD and NV support through CMake
[ { "change_type": "MODIFY", "old_path": "CMakeLists.txt", "new_path": "CMakeLists.txt", "diff": "@@ -42,10 +42,11 @@ endif()\n# searches for CUDA if allowed\nif (ALLOW_CUDA)\n- set(OCCA_CUDA_ENABLED 1)\n- set(WITH_CUDA 1)\n- enable_language(CUDA)\n- set(CUDA_USE_STATIC_CUDA_RUNTIME OFF)\n+ include(CUDA)\n+endif()\n+\n+if (ALLOW_HIP)\n+ include(HIP)\nendif()\n# searches for MPI if allowed\n@@ -57,11 +58,6 @@ if (ALLOW_METAL)\ninclude(Metal)\nendif()\n-if (ALLOW_HIP)\n-# set(OCCA_HIP_ENABLED 1)\n-# set(WITH_HIP 1)\n-# include(ROCm) ... not available, TODO occa/cmake/FindROCm.cmake\n-endif()\nadd_definitions(-DUSE_CMAKE)\n" }, { "change_type": "MODIFY", "old_path": "cmake/CUDA.cmake", "new_path": "cmake/CUDA.cmake", "diff": "find_package(CUDA)\nif (CUDA_FOUND)\n- set(OCCA_CUDA_ENABLED 1)\n+ #find the shared library, rather than the static that find_package returns\n+ find_library(\n+ CUDART_LIB\n+ NAMES cudart\n+ PATHS\n+ ${CUDA_TOOLKIT_ROOT_DIR}\n+ PATH_SUFFIXES lib64 lib\n+ DOC \"CUDA RT lib location\"\n+ )\n+\n+ set(CUDA_LIBRARIES \"${CUDART_LIB};cuda\")\n+\nset(WITH_CUDA 1)\n+ set(OCCA_CUDA_ENABLED 1)\ninclude_directories( ${CUDA_INCLUDE_DIRS} )\n-endif()\n+\n+ message(STATUS \"CUDA version: ${CUDA_VERSION_STRING}\")\n+ message(STATUS \"CUDA Include Paths: ${CUDA_INCLUDE_DIRS}\")\n+ message(STATUS \"CUDA Libraries: ${CUDA_LIBRARIES}\")\n+else (CUDA_FOUND)\n+ set(WITH_CUDA 0)\n+ set(OCCA_CUDA_ENABLED 0)\n+endif(CUDA_FOUND)\n" }, { "change_type": "ADD", "old_path": null, "new_path": "cmake/FindHIP.cmake", "diff": "+###############################################################################\n+# FIND: HIP and associated helper binaries\n+###############################################################################\n+# HIP is supported on Linux only\n+if(UNIX AND NOT APPLE AND NOT CYGWIN)\n+ # Search for HIP installation\n+ if(NOT HIP_ROOT_DIR)\n+ # Search in user specified path first\n+ find_path(\n+ HIP_ROOT_DIR\n+ NAMES hipconfig\n+ PATHS\n+ ENV ROCM_PATH\n+ ENV HIP_PATH\n+ PATH_SUFFIXES bin\n+ DOC \"HIP installed location\"\n+ NO_DEFAULT_PATH\n+ )\n+ # Now search in default path\n+ find_path(\n+ HIP_ROOT_DIR\n+ NAMES hipconfig\n+ PATHS\n+ /opt/rocm\n+ /opt/rocm/hip\n+ PATH_SUFFIXES bin\n+ DOC \"HIP installed location\"\n+ )\n+\n+ # Check if we found HIP installation\n+ if(HIP_ROOT_DIR)\n+ # If so, fix the path\n+ string(REGEX REPLACE \"[/\\\\\\\\]?bin[64]*[/\\\\\\\\]?$\" \"\" HIP_ROOT_DIR ${HIP_ROOT_DIR})\n+ # And push it back to the cache\n+ set(HIP_ROOT_DIR ${HIP_ROOT_DIR} CACHE PATH \"HIP installed location\" FORCE)\n+ endif()\n+\n+ if(NOT EXISTS ${HIP_ROOT_DIR})\n+ if(HIP_FIND_REQUIRED)\n+ message(FATAL_ERROR \"Specify HIP_ROOT_DIR\")\n+ elseif(NOT HIP_FIND_QUIETLY)\n+ message(\"HIP_ROOT_DIR not found or specified\")\n+ endif()\n+ endif()\n+ endif()\n+\n+ # Find HIPCONFIG executable\n+ find_program(\n+ HIP_HIPCONFIG_EXECUTABLE\n+ NAMES hipconfig\n+ PATHS\n+ \"${HIP_ROOT_DIR}\"\n+ ENV ROCM_PATH\n+ ENV HIP_PATH\n+ /opt/rocm\n+ /opt/rocm/hip\n+ PATH_SUFFIXES bin\n+ NO_DEFAULT_PATH\n+ )\n+ if(NOT HIP_HIPCONFIG_EXECUTABLE)\n+ # Now search in default paths\n+ find_program(HIP_HIPCONFIG_EXECUTABLE hipconfig)\n+ endif()\n+ mark_as_advanced(HIP_HIPCONFIG_EXECUTABLE)\n+\n+ if(HIP_HIPCONFIG_EXECUTABLE AND NOT HIP_VERSION)\n+ # Compute the version\n+ execute_process(\n+ COMMAND ${HIP_HIPCONFIG_EXECUTABLE} --version\n+ OUTPUT_VARIABLE _hip_version\n+ ERROR_VARIABLE _hip_error\n+ OUTPUT_STRIP_TRAILING_WHITESPACE\n+ ERROR_STRIP_TRAILING_WHITESPACE\n+ )\n+ if(NOT _hip_error)\n+ set(HIP_VERSION ${_hip_version} CACHE STRING \"Version of HIP as computed from hipcc\")\n+ else()\n+ set(HIP_VERSION \"0.0.0\" CACHE STRING \"Version of HIP as computed by FindHIP()\")\n+ endif()\n+ mark_as_advanced(HIP_VERSION)\n+ endif()\n+ if(HIP_VERSION)\n+ string(REPLACE \".\" \";\" _hip_version_list \"${HIP_VERSION}\")\n+ list(GET _hip_version_list 0 HIP_VERSION_MAJOR)\n+ list(GET _hip_version_list 1 HIP_VERSION_MINOR)\n+ list(GET _hip_version_list 2 HIP_VERSION_PATCH)\n+ set(HIP_VERSION_STRING \"${HIP_VERSION}\")\n+ endif()\n+\n+ if(HIP_HIPCONFIG_EXECUTABLE AND NOT HIP_PLATFORM)\n+ # Compute the platform\n+ execute_process(\n+ COMMAND ${HIP_HIPCONFIG_EXECUTABLE} --platform\n+ OUTPUT_VARIABLE _hip_platform\n+ OUTPUT_STRIP_TRAILING_WHITESPACE\n+ )\n+ set(HIP_PLATFORM ${_hip_platform} CACHE STRING \"HIP platform as computed by hipconfig\")\n+ mark_as_advanced(HIP_PLATFORM)\n+ endif()\n+\n+ if(${HIP_PLATFORM} STREQUAL \"hcc\")\n+ set(HIP_INCLUDE_DIRS \"${HIP_ROOT_DIR}/include;${HIP_ROOT_DIR}/hcc/include\")\n+ set(HIP_LIBRARIES \"${HIP_ROOT_DIR}/lib/libhip_hcc.so\")\n+ set(HIP_RUNTIME_DEFINE \"__HIP_PLATFORM_HCC__\")\n+ elseif(${HIP_PLATFORM} STREQUAL \"nvcc\")\n+ find_package(CUDA)\n+\n+ #find the shared library, rather than the static that find_package returns\n+ find_library(\n+ CUDART_LIB\n+ NAMES cudart\n+ PATHS\n+ ${CUDA_TOOLKIT_ROOT_DIR}\n+ PATH_SUFFIXES lib64 lib\n+ DOC \"CUDA RT lib location\"\n+ )\n+\n+ set(HIP_INCLUDE_DIRS \"${HIP_ROOT_DIR}/include;${CUDA_INCLUDE_DIRS}\")\n+ set(HIP_LIBRARIES \"${CUDART_LIB};cuda\")\n+ set(HIP_RUNTIME_DEFINE \"__HIP_PLATFORM_NVCC__\")\n+ endif()\n+ mark_as_advanced(HIP_INCLUDE_DIRS)\n+ mark_as_advanced(HIP_LIBRARIES)\n+ mark_as_advanced(HIP_RUNTIME_DEFINE)\n+\n+endif()\n+\n+include(FindPackageHandleStandardArgs)\n+find_package_handle_standard_args(\n+ HIP\n+ REQUIRED_VARS\n+ HIP_ROOT_DIR\n+ HIP_INCLUDE_DIRS\n+ HIP_LIBRARIES\n+ HIP_RUNTIME_DEFINE\n+ HIP_HIPCONFIG_EXECUTABLE\n+ HIP_PLATFORM\n+ VERSION_VAR HIP_VERSION\n+ )\n\\ No newline at end of file\n" }, { "change_type": "ADD", "old_path": null, "new_path": "cmake/HIP.cmake", "diff": "+find_package(HIP)\n+\n+if (HIP_FOUND)\n+ set(WITH_HIP 1)\n+ set(OCCA_HIP_ENABLED 1)\n+ add_definitions(-D${HIP_RUNTIME_DEFINE})\n+ include_directories( ${HIP_INCLUDE_DIRS} )\n+\n+ message(STATUS \"HIP version: ${HIP_VERSION_STRING}\")\n+ message(STATUS \"HIP platform: ${HIP_PLATFORM}\")\n+ message(STATUS \"HIP Include Paths: ${HIP_INCLUDE_DIRS}\")\n+ message(STATUS \"HIP Libraries: ${HIP_LIBRARIES}\")\n+else (HIP_FOUND)\n+ set(WITH_HIP 0)\n+ set(OCCA_HIP_ENABLED 0)\n+endif(HIP_FOUND)\n" }, { "change_type": "MODIFY", "old_path": "cmake/OpenCL.cmake", "new_path": "cmake/OpenCL.cmake", "diff": "+#Look in some default places for OpenCL and set OPENCL_ROOT\n+\n+# Search in user specified path first\n+find_path(\n+ OPENCL_ROOT\n+ NAMES include/CL/cl.h\n+ PATHS\n+ ENV OPENCL_PATH\n+ DOC \"OPENCL root location\"\n+ NO_DEFAULT_PATH\n+ )\n+# Now search in default path\n+find_path(\n+ OPENCL_ROOT\n+ NAMES include/CL/cl.h\n+ PATHS\n+ /usr/\n+ /opt/rocm/opencl\n+ /usr/local/cuda\n+ DOC \"OPENCL root location\"\n+ )\n+\n+#Trick cmake's default OpenCL module to look in our directory\n+set(ENV{AMDAPPSDKROOT} ${OPENCL_ROOT})\n+\nfind_package(OpenCL)\nif (OpenCL_FOUND)\n" }, { "change_type": "MODIFY", "old_path": "examples/CMakeLists.txt", "new_path": "examples/CMakeLists.txt", "diff": "@@ -13,6 +13,9 @@ macro(add_test_with_modes exe)\nif (WITH_CUDA)\nadd_test_with_mode(${exe} cuda \"mode: 'CUDA', device_id: 0\")\nendif()\n+ if (WITH_HIP)\n+ add_test_with_mode(${exe} hip \"mode: 'HIP', device_id: 0\")\n+ endif()\nif (WITH_METAL)\nadd_test_with_mode(${exe} metal \"mode: 'Metal', device_id: 0\")\nendif()\n@@ -26,8 +29,7 @@ endmacro()\nmacro(compile_c_example target file)\nadd_executable(examples_c_${target} ${file})\n- target_link_libraries(examples_c_${target} libocca ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS})\n- include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)\n+ target_link_libraries(examples_c_${target} libocca)\nif (ENABLE_TESTS)\nadd_test_with_modes(examples_c_${target})\nendif()\n@@ -35,8 +37,7 @@ endmacro()\nmacro(compile_cpp_example target file)\nadd_executable(examples_cpp_${target} ${file})\n- target_link_libraries(examples_cpp_${target} libocca ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS})\n- include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)\n+ target_link_libraries(examples_cpp_${target} libocca)\nif (ENABLE_TESTS)\nadd_test_without_mode(examples_cpp_${target})\nendif()\n@@ -44,8 +45,7 @@ endmacro()\nmacro(compile_cpp_example_with_modes target file)\nadd_executable(examples_cpp_${target} ${file})\n- target_link_libraries(examples_cpp_${target} libocca ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS})\n- include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)\n+ target_link_libraries(examples_cpp_${target} libocca)\nif (ENABLE_TESTS)\nadd_test_with_modes(examples_cpp_${target})\nendif()\n" }, { "change_type": "MODIFY", "old_path": "src/CMakeLists.txt", "new_path": "src/CMakeLists.txt", "diff": "@@ -15,11 +15,15 @@ set_target_properties(libocca PROPERTIES OUTPUT_NAME occa LIBRARY_OUTPUT_DIRECTO\nset(LIBOCCA_LIBRARIES ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS})\nif (WITH_CUDA)\n- set(LIBOCCA_LIBRARIES cuda cudart ${LIBOCCA_LIBRARIES})\n+ set(LIBOCCA_LIBRARIES ${CUDA_LIBRARIES} ${LIBOCCA_LIBRARIES})\n+endif()\n+\n+if (WITH_HIP)\n+ set(LIBOCCA_LIBRARIES ${HIP_LIBRARIES} ${LIBOCCA_LIBRARIES})\nendif()\nif (WITH_OPENCL)\n- set(LIBOCCA_LIBRARIES ${LIBOCCA_LIBRARIES} ${OpenCL_LIBRARIES} ${LIBOCCA_LIBRARIES})\n+ set(LIBOCCA_LIBRARIES ${OpenCL_LIBRARIES} ${LIBOCCA_LIBRARIES})\nendif()\nif (WITH_MPI)\n" } ]
C++
MIT License
libocca/occa
[Cmake] HIP/CUDA/OpenCL on AMD and NV support through CMake (#323)
378,349
15.04.2020 21:30:48
18,000
c91f4a822d17cbc8b18dac515e63cab86c8d8970
[CI] Trying out Github Actions
[ { "change_type": "ADD", "old_path": null, "new_path": ".github/workflows/test-workflow.yml", "diff": "+name: Test Workflow\n+\n+on:\n+ push:\n+ branches: [ master ]\n+ pull_request:\n+ branches: [ master ]\n+\n+jobs:\n+ run:\n+ strategy:\n+ matrix:\n+ include:\n+ - os: ubuntu-18.04\n+ CC: gcc-8\n+ CXX: g++-8\n+\n+ - os: ubuntu-18.04\n+ CC: gcc-9\n+ CXX: g++-9\n+\n+ - os: ubuntu-18.04\n+ CC: clang-6\n+ CXX: clang++-6\n+\n+ - os: ubuntu-18.04\n+ CC: clang-9\n+ CXX: clang++-9\n+\n+ - os: macos-10.15\n+ CC: gcc-9\n+ CXX: g++-9\n+\n+ - os: macos-10.15\n+ CC: clang-9\n+ CXX: clang++-9\n+\n+ runs-on: ${{ matrix.os }}\n+\n+ env:\n+ CC: ${{ matrix.CC }}\n+ CXX: ${{ matrix.CXX }}\n+\n+ steps:\n+ - uses: actions/checkout@v2\n+\n+ - name: Compile\n+ run: make -j\n+\n+ - name: Run unit tests\n+ run: ./tests/run_tests\n+\n+ - name: Run examples\n+ run: ./tests/run_examples\n+\n+ - name: Upload code coverage\n+ uses: codecov/codecov-action@v1\n" } ]
C++
MIT License
libocca/occa
[CI] Trying out Github Actions
378,349
15.04.2020 23:53:11
14,400
162e0ce0228327e0086c12234b7785ea78634811
[CI] Removing Travis CI to test Github Actions
[ { "change_type": "MODIFY", "old_path": ".codecov.yml", "new_path": ".codecov.yml", "diff": "@@ -24,7 +24,7 @@ ignore:\n- src/tools/runFunction.cpp\n# Exception is not tracked properly\n- src/tools/exception.cpp\n- # Modes that can't be tested with Travis\n+ # Modes that can't be tested with CI\n- include/occa/modes/cuda\n- include/occa/modes/hip\n- include/occa/modes/opencl\n" }, { "change_type": "ADD", "old_path": null, "new_path": ".github/workflows/build-status.yml", "diff": "+name: Build Status\n+\n+on:\n+ push:\n+ branches: [ master ]\n+ pull_request:\n+ branches: [ master ]\n+\n+jobs:\n+ run:\n+ strategy:\n+ matrix:\n+ include:\n+ - name: (Ubuntu) gcc-8\n+ os: ubuntu-18.04\n+ CC: gcc-8\n+ CXX: g++-8\n+ OCCA_COVERAGE: 1\n+\n+ - name: (Ubuntu) gcc-9\n+ os: ubuntu-18.04\n+ CC: gcc-9\n+ CXX: g++-9\n+ OCCA_COVERAGE: 1\n+\n+ - name: (Ubuntu) clang-6\n+ os: ubuntu-18.04\n+ CC: clang-6.0\n+ CXX: clang++-6.0\n+ OCCA_COVERAGE: 0\n+\n+ - name: (Ubuntu) clang-9\n+ os: ubuntu-18.04\n+ CC: clang-9\n+ CXX: clang++-9\n+ OCCA_COVERAGE: 0\n+\n+ - name: (MacOS) gcc\n+ os: macos-10.15\n+ CC: gcc\n+ CXX: g++\n+ OCCA_COVERAGE: 1\n+\n+ - name: (MacOS) clang\n+ os: macos-10.15\n+ CC: clang\n+ CXX: clang++\n+ OCCA_COVERAGE: 0\n+\n+ runs-on: ${{ matrix.os }}\n+ name: ${{ matrix.name }}\n+\n+ env:\n+ CC: ${{ matrix.CC }}\n+ CXX: ${{ matrix.CXX }}\n+ OCCA_COVERAGE: ${{ matrix.OCCA_COVERAGE }}\n+\n+ steps:\n+ - uses: actions/checkout@v2\n+\n+ - name: Compile library\n+ run: make -j\n+\n+ - name: Compile tests\n+ run: make -j tests\n+\n+ - name: Run unit tests\n+ run: ./tests/run_tests\n+\n+ - name: Run examples\n+ run: ./tests/run_examples\n+\n+ - name: Upload code coverage\n+ uses: codecov/codecov-action@v1\n" }, { "change_type": "DELETE", "old_path": ".github/workflows/test-workflow.yml", "new_path": null, "diff": "-name: Test Workflow\n-\n-on:\n- push:\n- branches: [ master ]\n- pull_request:\n- branches: [ master ]\n-\n-jobs:\n- run:\n- strategy:\n- matrix:\n- include:\n- - os: ubuntu-18.04\n- CC: gcc-8\n- CXX: g++-8\n-\n- - os: ubuntu-18.04\n- CC: gcc-9\n- CXX: g++-9\n-\n- - os: ubuntu-18.04\n- CC: clang-6\n- CXX: clang++-6\n-\n- - os: ubuntu-18.04\n- CC: clang-9\n- CXX: clang++-9\n-\n- - os: macos-10.15\n- CC: gcc-9\n- CXX: g++-9\n-\n- - os: macos-10.15\n- CC: clang-9\n- CXX: clang++-9\n-\n- runs-on: ${{ matrix.os }}\n-\n- env:\n- CC: ${{ matrix.CC }}\n- CXX: ${{ matrix.CXX }}\n-\n- steps:\n- - uses: actions/checkout@v2\n-\n- - name: Compile\n- run: make -j\n-\n- - name: Run unit tests\n- run: ./tests/run_tests\n-\n- - name: Run examples\n- run: ./tests/run_examples\n-\n- - name: Upload code coverage\n- uses: codecov/codecov-action@v1\n" }, { "change_type": "DELETE", "old_path": ".travis.yml", "new_path": null, "diff": "-# Unable to run LeakSanitizer propertly without root\n-# https://github.com/travis-ci/travis-ci/issues/9033\n-sudo: true\n-language: cpp\n-notifications:\n- email: false\n-\n-# Use Linux + gcc unless specified\n-os: linux\n-dist: xenial\n-compiler: gcc\n-\n-env:\n- global:\n- - LD_LIBRARY_PATH=\"${TRAVIS_BUILD_DIR}/lib:${LD_LIBRARY_PATH}\"\n- - DEBUG=1\n-\n-before_install:\n- - |\n- if [ \"${TRAVIS_OS_NAME}\" = \"osx\" ]; then\n- travis_wait 30 brew update;\n- else\n- sudo apt-get update;\n- fi\n- - |\n- if [ -n \"${MATRIX_INIT}\" ]; then\n- eval \"${MATRIX_INIT}\"\n- fi\n-\n-script:\n- - cd ${TRAVIS_BUILD_DIR}\n- - make -j 4\n-\n- - cd ${TRAVIS_BUILD_DIR}\n- - make -j 4 test\n- - bash <(curl --no-buffer -s https://codecov.io/bash) > codecov_output\n- - head -n 100 codecov_output\n-\n-matrix:\n- include:\n- - name: \"gcc-5\"\n- env:\n- - CC=gcc-5\n- - CXX=g++-5\n- - OCCA_COVERAGE=1\n- addons:\n- apt:\n- sources:\n- - ubuntu-toolchain-r-test\n- packages:\n- - g++-5\n- - name: \"gcc-6\"\n- env:\n- - CC=gcc-6\n- - CXX=g++-6\n- - OCCA_COVERAGE=1\n- addons:\n- apt:\n- sources:\n- - ubuntu-toolchain-r-test\n- packages:\n- - g++-6\n- - name: \"gcc-7\"\n- env:\n- - CC=gcc-7\n- - CXX=g++-7\n- - OCCA_COVERAGE=1\n- addons:\n- apt:\n- sources:\n- - ubuntu-toolchain-r-test\n- packages:\n- - g++-7\n- - name: \"gcc-7 (CMake)\"\n- env:\n- - CC=gcc-7\n- - CXX=g++-7\n- - OCCA_COVERAGE=1\n- addons:\n- apt:\n- sources:\n- - ubuntu-toolchain-r-test\n- - cmake\n- packages:\n- - g++-7\n- script:\n- - cd ${TRAVIS_BUILD_DIR}\n- - mkdir build\n- - cd build\n- - cmake ..\n- - make -j 4\n- - name: \"clang-4.0\"\n- env:\n- - CC=clang-4.0\n- - CXX=clang++-4.0\n- - CODECOV=OFF\n- compiler: clang\n- addons:\n- apt:\n- sources:\n- - llvm-toolchain-4.0\n- packages:\n- - clang-4.0\n- - name: \"clang-5.0\"\n- env:\n- - CC=clang-5.0\n- - CXX=clang++-5.0\n- - CODpECOV=OFF\n- compiler: clang\n- addons:\n- apt:\n- sources:\n- - llvm-toolchain-5.0\n- packages:\n- - clang-5.0\n- - name: \"clang-6.0\"\n- env:\n- - CC=clang-6.0\n- - CXX=clang++-6.0\n- - CODECOV=OFF\n- compiler: clang\n- addons:\n- apt:\n- sources:\n- - ubuntu-toolchain-r-test\n- - llvm-toolchain-6.0\n- packages:\n- - clang-6.0\n- - name: \"clang\"\n- os: osx\n- osx_image: xcode10.2\n- compiler: clang\n- env:\n- - CC=clang\n- - CXX=clang++\n- - CODECOV=OFF\n" }, { "change_type": "MODIFY", "old_path": "README.md", "new_path": "README.md", "diff": "</p>\n&nbsp;\n<p align=\"center\">\n- <a href=\"https://travis-ci.org/libocca/occa\"><img alt=\"Build Status\" src=\"https://travis-ci.org/libocca/occa.svg?branch=master\"></a>\n+ <a href=\"https://github.com/libocca/occa/workflows/Build%20Status/badge.svg\"><img alt=\"Build Status\" src=\"https://github.com/libocca/occa/workflows/Build%20Status/badge.svg\"></a>\n<a href=\"https://codecov.io/github/libocca/occa\"><img alt=\"codecov.io\" src=\"https://codecov.io/github/libocca/occa/coverage.svg\"></a>\n<a href=\"https://gitter.im/libocca/occa?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge\"><img alt=\"Gitter\" src=\"https://badges.gitter.im/libocca/occa.svg\"></a>\n</p>\n" }, { "change_type": "MODIFY", "old_path": "tests/run_examples", "new_path": "tests/run_examples", "diff": "@@ -9,9 +9,8 @@ ASAN_OPTIONS+=':detect_container_overflow=0'\nHEADER_CHARS=80\n-if [[ $(uname -s) == \"Darwin\" || \"${TRAVIS_OS_NAME}\" == \"osx\" ]]; then\n+export LD_LIBRARY_PATH=\"${OCCA_DIR}/lib:${LD_LIBRARY_PATH}\"\nexport DYLD_LIBRARY_PATH=\"${OCCA_DIR}/lib:${DYLD_LIBRARY_PATH}\"\n-fi\ndeclare -a examples=(\ncpp/01_add_vectors\n@@ -44,23 +43,19 @@ for mode in $(\"${OCCA_DIR}/bin/occa\" modes); do\nfor example_dir in \"${examples[@]}\"; do\nflags=(--verbose --device \"${device}\")\n- # OpenCL throws CL_DEVICE_MAX_WORK_GROUP_SIZE\n- if [ -n \"${TRAVIS}\" ] && [ \"${mode}\" == \"OpenCL\" ]; then\n- continue\n- fi\n-\n# Filters\ncase \"${example_dir}\" in\n# OpenCL + Shared memory is finicky\n+ # OpenCL throws CL_DEVICE_MAX_WORK_GROUP_SIZE\ncpp/04_reduction)\nif [[ \"${mode}\" == OpenCL ]]; then\ncontinue\nfi;;\n- cpp/06_arrays)\n+ cpp/08_arrays)\nif [[ \"${mode}\" == OpenCL ]]; then\ncontinue\nfi;;\n- c/03_reduction)\n+ c/04_reduction)\nif [[ \"${mode}\" == OpenCL ]]; then\ncontinue\nfi;;\n@@ -87,20 +82,13 @@ for mode in $(\"${OCCA_DIR}/bin/occa\" modes); do\ncd \"${EXAMPLE_DIR}/${example_dir}\"\nmake clean; make\n- output=$(./main \"${flags[@]}\" 2>&1)\n+ ./main \"${flags[@]}\"\n# Check for example failures\nif [ $? -ne 0 ]; then\nfailed_examples+=\" - ${mode}: ${example_dir}\\n\"\nfi\n- # Make sure not to go over the log size\n- if [ -n \"${TRAVIS}\" ]; then\n- echo -e \"${output}\" | head -n 100\n- else\n- echo -e \"${output}\"\n- fi\n-\n# Test output footer\nprintf '%*s\\n' ${HEADER_CHARS} | tr ' ' '='\ndone\n" }, { "change_type": "MODIFY", "old_path": "tests/run_tests", "new_path": "tests/run_tests", "diff": "@@ -24,12 +24,12 @@ for test_cpp in ${tests_cpp}; do\nline=$(printf '%*s' ${linechars} | tr ' ' '-')\necho -e \"\\n---[ ${test_name} ]${line}\"\n- output=$(\"${test}\")\n+ \"${test}\"\n# Check for test failures\nif [ $? -ne 0 ]; then\ncase \"${test}\" in\n- # TODO: Find out why these tests are failing in Travis\n+ # TODO: Find out why these tests are failing in CI\n*lang/mode/metal|*lang/mode/cuda|*lang/mode/opencl)\n;;\n*)\n@@ -37,13 +37,6 @@ for test_cpp in ${tests_cpp}; do\nesac\nfi\n- # Make sure not to go over the log size\n- if [ -n \"${TRAVIS}\" ]; then\n- echo -e \"${output}\" | head -n 100\n- else\n- echo -e \"${output}\"\n- fi\n-\n# Test output footer\nprintf '%*s\\n' ${HEADER_CHARS} | tr ' ' '='\ndone\n" } ]
C++
MIT License
libocca/occa
[CI] Removing Travis CI to test Github Actions (#324)
378,358
22.04.2020 17:29:34
-7,200
02c1782c3b7fb5589eb196f3e8f9e3ac6f486ab1
[Build][HIP] Fix HIP compilation issues
[ { "change_type": "MODIFY", "old_path": "scripts/Makefile", "new_path": "scripts/Makefile", "diff": "@@ -273,26 +273,19 @@ endif\n#---[ HIP ]-----------------------------\nhipEnabled = 0\n-ifneq ($(OCCA_HIP_ENABLED),0)\n- ifeq ($(usingLinux),1)\nhipIncFlags = $(call includeFlagsFor,hip/hip_runtime_api.h)\n-\nifneq (,$(hipIncFlags))\n- hipEnabled := 1\n- endif\n+ HIP_PATH = ${hipIncFlags:-I%=%}/..\n+ hipEnabled = 1\nendif\n+ifdef OCCA_HIP_ENABLED\n+ hipEnabled = $(OCCA_HIP_ENABLED)\nendif\nifeq ($(hipEnabled),1)\n- hipIncFlags = $(call includeFlagsFor,hip/hip_runtime_api.h)\n-\n- ifndef HIP_PATH\n- HIP_PATH = ${hipIncFlags:-I%=%}/../..\n- endif\n-\n+ ifneq (,$(HIP_PATH))\nhipPlatform = $(shell $(HIP_PATH)/bin/hipconfig --platform)\nhipConfig = $(shell $(HIP_PATH)/bin/hipconfig --cpp_config)\n-\nifeq ($(hipPlatform),nvcc)\nlinkerFlags += -lcuda -lcudart\nhipLibFlags = $(call libraryFlagsFor,cuda)\n@@ -301,11 +294,11 @@ ifeq ($(hipEnabled),1)\nlinkerFlags += -lhip_hcc\nhipLibFlags = $(call libraryFlagsFor,hip_hcc)\nendif\n-\npaths += $(hipConfig)\npaths += $(hipIncFlags)\nlinkerFlags += $(hipLibFlags)\nendif\n+endif\n#---[ OpenCL ]--------------------------\n" } ]
C++
MIT License
libocca/occa
[Build][HIP] Fix HIP compilation issues (#330)
378,356
27.04.2020 06:19:42
-36,000
560d8eb320dccb664427b44e58f7acff7bc5b35a
[C] Use bool instead of int
[ { "change_type": "MODIFY", "old_path": "include/occa/c/json.h", "new_path": "include/occa/c/json.h", "diff": "@@ -23,11 +23,11 @@ OCCA_LFUNC const char* OCCA_RFUNC occaJsonDump(occaJson j,\n//---[ Type checks ]--------------------\n-OCCA_LFUNC int OCCA_RFUNC occaJsonIsBoolean(occaJson j);\n-OCCA_LFUNC int OCCA_RFUNC occaJsonIsNumber(occaJson j);\n-OCCA_LFUNC int OCCA_RFUNC occaJsonIsString(occaJson j);\n-OCCA_LFUNC int OCCA_RFUNC occaJsonIsArray(occaJson j);\n-OCCA_LFUNC int OCCA_RFUNC occaJsonIsObject(occaJson j);\n+OCCA_LFUNC bool OCCA_RFUNC occaJsonIsBoolean(occaJson j);\n+OCCA_LFUNC bool OCCA_RFUNC occaJsonIsNumber(occaJson j);\n+OCCA_LFUNC bool OCCA_RFUNC occaJsonIsString(occaJson j);\n+OCCA_LFUNC bool OCCA_RFUNC occaJsonIsArray(occaJson j);\n+OCCA_LFUNC bool OCCA_RFUNC occaJsonIsObject(occaJson j);\n//======================================\n@@ -41,7 +41,7 @@ OCCA_LFUNC void OCCA_RFUNC occaJsonCastToObject(occaJson j);\n//---[ Getters ]------------------------\n-OCCA_LFUNC int OCCA_RFUNC occaJsonGetBoolean(occaJson j);\n+OCCA_LFUNC bool OCCA_RFUNC occaJsonGetBoolean(occaJson j);\nOCCA_LFUNC occaType OCCA_RFUNC occaJsonGetNumber(occaJson j,\nconst int type);\nOCCA_LFUNC const char* OCCA_RFUNC occaJsonGetString(occaJson j);\n@@ -57,7 +57,7 @@ OCCA_LFUNC void OCCA_RFUNC occaJsonObjectSet(occaJson j,\nconst char *key,\noccaType value);\n-OCCA_LFUNC int OCCA_RFUNC occaJsonObjectHas(occaJson j,\n+OCCA_LFUNC bool OCCA_RFUNC occaJsonObjectHas(occaJson j,\nconst char *key);\n//======================================\n" }, { "change_type": "MODIFY", "old_path": "src/c/json.cpp", "new_path": "src/c/json.cpp", "diff": "@@ -45,27 +45,27 @@ OCCA_LFUNC const char* OCCA_RFUNC occaJsonDump(occaJson j,\n//---[ Type checks ]--------------------\n-int OCCA_RFUNC occaJsonIsBoolean(occaJson j) {\n+bool OCCA_RFUNC occaJsonIsBoolean(occaJson j) {\nocca::json &j_ = occa::c::json(j);\nreturn j_.isBoolean();\n}\n-int OCCA_RFUNC occaJsonIsNumber(occaJson j) {\n+bool OCCA_RFUNC occaJsonIsNumber(occaJson j) {\nocca::json &j_ = occa::c::json(j);\nreturn j_.isNumber();\n}\n-int OCCA_RFUNC occaJsonIsString(occaJson j) {\n+bool OCCA_RFUNC occaJsonIsString(occaJson j) {\nocca::json &j_ = occa::c::json(j);\nreturn j_.isString();\n}\n-int OCCA_RFUNC occaJsonIsArray(occaJson j) {\n+bool OCCA_RFUNC occaJsonIsArray(occaJson j) {\nocca::json &j_ = occa::c::json(j);\nreturn j_.isArray();\n}\n-int OCCA_RFUNC occaJsonIsObject(occaJson j) {\n+bool OCCA_RFUNC occaJsonIsObject(occaJson j) {\nocca::json &j_ = occa::c::json(j);\nreturn j_.isObject();\n}\n@@ -96,9 +96,9 @@ void OCCA_RFUNC occaJsonCastToObject(occaJson j) {\n//---[ Getters ]------------------------\n-int OCCA_RFUNC occaJsonGetBoolean(occaJson j) {\n+bool OCCA_RFUNC occaJsonGetBoolean(occaJson j) {\nocca::json &j_ = occa::c::json(j);\n- return (int) j_.boolean();\n+ return j_.boolean();\n}\noccaType OCCA_RFUNC occaJsonGetNumber(occaJson j,\n@@ -144,7 +144,7 @@ void OCCA_RFUNC occaJsonObjectSet(occaJson j,\nj_[key] = occa::c::inferJson(value);\n}\n-int OCCA_RFUNC occaJsonObjectHas(occaJson j,\n+bool OCCA_RFUNC occaJsonObjectHas(occaJson j,\nconst char *key) {\nocca::json &j_ = occa::c::json(j);\nif (!j_.isInitialized()) {\n" } ]
C++
MIT License
libocca/occa
[C] Use bool instead of int (#331)
378,356
27.04.2020 09:57:25
-36,000
cda9b75c0207235496e98a2e5f9dcb161741fed2
[C] Use bool instead of int for boolean types everywhere
[ { "change_type": "MODIFY", "old_path": "include/occa/c/device.h", "new_path": "include/occa/c/device.h", "diff": "@@ -9,7 +9,7 @@ OCCA_START_EXTERN_C\nOCCA_LFUNC occaDevice OCCA_RFUNC occaCreateDevice(occaType info);\nOCCA_LFUNC occaDevice OCCA_RFUNC occaCreateDeviceFromString(const char *info);\n-OCCA_LFUNC int OCCA_RFUNC occaDeviceIsInitialized(occaDevice device);\n+OCCA_LFUNC bool OCCA_RFUNC occaDeviceIsInitialized(occaDevice device);\nOCCA_LFUNC const char* OCCA_RFUNC occaDeviceMode(occaDevice device);\n@@ -27,7 +27,7 @@ OCCA_LFUNC occaUDim_t OCCA_RFUNC occaDeviceMemoryAllocated(occaDevice device);\nOCCA_LFUNC void OCCA_RFUNC occaDeviceFinish(occaDevice device);\n-OCCA_LFUNC int OCCA_RFUNC occaDeviceHasSeparateMemorySpace(occaDevice device);\n+OCCA_LFUNC bool OCCA_RFUNC occaDeviceHasSeparateMemorySpace(occaDevice device);\n//---[ Stream ]-------------------------\nOCCA_LFUNC occaStream OCCA_RFUNC occaDeviceCreateStream(occaDevice device,\n" }, { "change_type": "MODIFY", "old_path": "include/occa/c/dtype.h", "new_path": "include/occa/c/dtype.h", "diff": "@@ -20,16 +20,16 @@ OCCA_LFUNC int OCCA_RFUNC occaDtypeBytes(occaDtype dtype);\nOCCA_LFUNC void OCCA_RFUNC occaDtypeRegisterType(occaDtype dtype);\n-OCCA_LFUNC int OCCA_RFUNC occaDtypeIsRegistered(occaDtype dtype);\n+OCCA_LFUNC bool OCCA_RFUNC occaDtypeIsRegistered(occaDtype dtype);\nOCCA_LFUNC void OCCA_RFUNC occaDtypeAddField(occaDtype dtype,\nconst char *field,\noccaDtype fieldType);\n-OCCA_LFUNC int OCCA_RFUNC occaDtypesAreEqual(occaDtype a,\n+OCCA_LFUNC bool OCCA_RFUNC occaDtypesAreEqual(occaDtype a,\noccaDtype b);\n-OCCA_LFUNC int OCCA_RFUNC occaDtypesMatch(occaDtype a,\n+OCCA_LFUNC bool OCCA_RFUNC occaDtypesMatch(occaDtype a,\noccaDtype b);\nOCCA_LFUNC occaDtype OCCA_RFUNC occaDtypeFromJson(occaJson json);\n" }, { "change_type": "MODIFY", "old_path": "include/occa/c/kernel.h", "new_path": "include/occa/c/kernel.h", "diff": "OCCA_START_EXTERN_C\n-OCCA_LFUNC int OCCA_RFUNC occaKernelIsInitialized(occaKernel kernel);\n+OCCA_LFUNC bool OCCA_RFUNC occaKernelIsInitialized(occaKernel kernel);\nOCCA_LFUNC occaProperties OCCA_RFUNC occaKernelGetProperties(occaKernel kernel);\n" }, { "change_type": "MODIFY", "old_path": "include/occa/c/memory.h", "new_path": "include/occa/c/memory.h", "diff": "OCCA_START_EXTERN_C\n-OCCA_LFUNC int OCCA_RFUNC occaMemoryIsInitialized(occaMemory memory);\n+OCCA_LFUNC bool OCCA_RFUNC occaMemoryIsInitialized(occaMemory memory);\nOCCA_LFUNC void* OCCA_RFUNC occaMemoryPtr(occaMemory memory,\noccaProperties props);\n@@ -22,11 +22,11 @@ OCCA_LFUNC occaMemory OCCA_RFUNC occaMemorySlice(occaMemory memory,\nconst occaDim_t bytes);\n//---[ UVA ]----------------------------\n-OCCA_LFUNC int OCCA_RFUNC occaMemoryIsManaged(occaMemory memory);\n+OCCA_LFUNC bool OCCA_RFUNC occaMemoryIsManaged(occaMemory memory);\n-OCCA_LFUNC int OCCA_RFUNC occaMemoryInDevice(occaMemory memory);\n+OCCA_LFUNC bool OCCA_RFUNC occaMemoryInDevice(occaMemory memory);\n-OCCA_LFUNC int OCCA_RFUNC occaMemoryIsStale(occaMemory memory);\n+OCCA_LFUNC bool OCCA_RFUNC occaMemoryIsStale(occaMemory memory);\nOCCA_LFUNC void OCCA_RFUNC occaMemoryStartManaging(occaMemory memory);\n" }, { "change_type": "MODIFY", "old_path": "include/occa/c/properties.h", "new_path": "include/occa/c/properties.h", "diff": "@@ -18,7 +18,7 @@ OCCA_LFUNC void OCCA_RFUNC occaPropertiesSet(occaProperties props,\nconst char *key,\noccaType value);\n-OCCA_LFUNC int OCCA_RFUNC occaPropertiesHas(occaProperties props,\n+OCCA_LFUNC bool OCCA_RFUNC occaPropertiesHas(occaProperties props,\nconst char *key);\nOCCA_END_EXTERN_C\n" }, { "change_type": "MODIFY", "old_path": "include/occa/c/types.h", "new_path": "include/occa/c/types.h", "diff": "@@ -95,8 +95,8 @@ extern const occaUDim_t occaAllBytes;\n//======================================\n//-----[ Known Types ]------------------\n-OCCA_LFUNC int OCCA_RFUNC occaIsUndefined(occaType value);\n-OCCA_LFUNC int OCCA_RFUNC occaIsDefault(occaType value);\n+OCCA_LFUNC bool OCCA_RFUNC occaIsUndefined(occaType value);\n+OCCA_LFUNC bool OCCA_RFUNC occaIsDefault(occaType value);\nOCCA_LFUNC occaType OCCA_RFUNC occaPtr(void *value);\n" }, { "change_type": "MODIFY", "old_path": "include/occa/c/uva.h", "new_path": "include/occa/c/uva.h", "diff": "OCCA_START_EXTERN_C\n-OCCA_LFUNC int OCCA_RFUNC occaIsManaged(void *ptr);\n+OCCA_LFUNC bool OCCA_RFUNC occaIsManaged(void *ptr);\nOCCA_LFUNC void OCCA_RFUNC occaStartManaging(void *ptr);\nOCCA_LFUNC void OCCA_RFUNC occaStopManaging(void *ptr);\n@@ -15,7 +15,7 @@ OCCA_LFUNC void OCCA_RFUNC occaSyncToDevice(void *ptr,\nOCCA_LFUNC void OCCA_RFUNC occaSyncToHost(void *ptr,\nconst occaUDim_t bytes);\n-OCCA_LFUNC int OCCA_RFUNC occaNeedsSync(void *ptr);\n+OCCA_LFUNC bool OCCA_RFUNC occaNeedsSync(void *ptr);\nOCCA_LFUNC void OCCA_RFUNC occaSync(void *ptr);\nOCCA_LFUNC void OCCA_RFUNC occaDontSync(void *ptr);\n" }, { "change_type": "MODIFY", "old_path": "src/c/device.cpp", "new_path": "src/c/device.cpp", "diff": "@@ -28,7 +28,7 @@ occaDevice OCCA_RFUNC occaCreateDeviceFromString(const char *info) {\nreturn occa::c::newOccaType(device);\n}\n-int OCCA_RFUNC occaDeviceIsInitialized(occaDevice device) {\n+bool OCCA_RFUNC occaDeviceIsInitialized(occaDevice device) {\nreturn (int) occa::c::device(device).isInitialized();\n}\n@@ -68,7 +68,7 @@ void OCCA_RFUNC occaDeviceFinish(occaDevice device) {\nocca::c::device(device).finish();\n}\n-OCCA_LFUNC int OCCA_RFUNC occaDeviceHasSeparateMemorySpace(occaDevice device) {\n+OCCA_LFUNC bool OCCA_RFUNC occaDeviceHasSeparateMemorySpace(occaDevice device) {\nreturn (int) occa::c::device(device).hasSeparateMemorySpace();\n}\n" }, { "change_type": "MODIFY", "old_path": "src/c/dtype.cpp", "new_path": "src/c/dtype.cpp", "diff": "@@ -32,7 +32,7 @@ OCCA_LFUNC void OCCA_RFUNC occaDtypeRegisterType(occaDtype dtype) {\nocca::c::dtype(dtype).registerType();\n}\n-OCCA_LFUNC int OCCA_RFUNC occaDtypeIsRegistered(occaDtype dtype) {\n+OCCA_LFUNC bool OCCA_RFUNC occaDtypeIsRegistered(occaDtype dtype) {\nreturn occa::c::dtype(dtype).isRegistered();\n}\n@@ -44,12 +44,12 @@ OCCA_LFUNC void OCCA_RFUNC occaDtypeAddField(occaDtype dtype,\nocca::c::dtype(fieldType));\n}\n-OCCA_LFUNC int OCCA_RFUNC occaDtypesAreEqual(occaDtype a,\n+OCCA_LFUNC bool OCCA_RFUNC occaDtypesAreEqual(occaDtype a,\noccaDtype b) {\nreturn (occa::c::dtype(a) == occa::c::dtype(b));\n}\n-OCCA_LFUNC int OCCA_RFUNC occaDtypesMatch(occaDtype a,\n+OCCA_LFUNC bool OCCA_RFUNC occaDtypesMatch(occaDtype a,\noccaDtype b) {\nreturn occa::c::dtype(a).matches(occa::c::dtype(b));\n}\n" }, { "change_type": "MODIFY", "old_path": "src/c/kernel.cpp", "new_path": "src/c/kernel.cpp", "diff": "OCCA_START_EXTERN_C\n-int OCCA_RFUNC occaKernelIsInitialized(occaKernel kernel) {\n+bool OCCA_RFUNC occaKernelIsInitialized(occaKernel kernel) {\nreturn (int) occa::c::kernel(kernel).isInitialized();\n}\n" }, { "change_type": "MODIFY", "old_path": "src/c/memory.cpp", "new_path": "src/c/memory.cpp", "diff": "OCCA_START_EXTERN_C\n-int OCCA_RFUNC occaMemoryIsInitialized(occaMemory memory) {\n+bool OCCA_RFUNC occaMemoryIsInitialized(occaMemory memory) {\nreturn occa::c::memory(memory).isInitialized();\n}\n@@ -42,15 +42,15 @@ occaMemory OCCA_RFUNC occaMemorySlice(occaMemory memory,\n}\n//---[ UVA ]----------------------------\n-int OCCA_RFUNC occaMemoryIsManaged(occaMemory memory) {\n+bool OCCA_RFUNC occaMemoryIsManaged(occaMemory memory) {\nreturn (int) occa::c::memory(memory).isManaged();\n}\n-int OCCA_RFUNC occaMemoryInDevice(occaMemory memory) {\n+bool OCCA_RFUNC occaMemoryInDevice(occaMemory memory) {\nreturn (int) occa::c::memory(memory).inDevice();\n}\n-int OCCA_RFUNC occaMemoryIsStale(occaMemory memory) {\n+bool OCCA_RFUNC occaMemoryIsStale(occaMemory memory) {\nreturn (int) occa::c::memory(memory).isStale();\n}\n" }, { "change_type": "MODIFY", "old_path": "src/c/properties.cpp", "new_path": "src/c/properties.cpp", "diff": "@@ -30,7 +30,7 @@ void OCCA_RFUNC occaPropertiesSet(occaProperties props,\nprops_[key] = occa::c::inferJson(value);\n}\n-int OCCA_RFUNC occaPropertiesHas(occaProperties props,\n+bool OCCA_RFUNC occaPropertiesHas(occaProperties props,\nconst char *key) {\nocca::properties& props_ = occa::c::properties(props);\nreturn props_.has(key);\n" }, { "change_type": "MODIFY", "old_path": "src/c/types.cpp", "new_path": "src/c/types.cpp", "diff": "@@ -650,16 +650,16 @@ const occaUDim_t occaAllBytes = -1;\n//======================================\n//-----[ Known Types ]------------------\n-OCCA_LFUNC int OCCA_RFUNC occaIsUndefined(occaType value) {\n+OCCA_LFUNC bool OCCA_RFUNC occaIsUndefined(occaType value) {\nreturn ((value.magicHeader == OCCA_C_TYPE_UNDEFINED_HEADER) ||\n(value.magicHeader != OCCA_C_TYPE_MAGIC_HEADER));\n}\n-OCCA_LFUNC int OCCA_RFUNC occaIsNull(occaType value) {\n+OCCA_LFUNC bool OCCA_RFUNC occaIsNull(occaType value) {\nreturn (value.type == occa::c::typeType::null_);\n}\n-OCCA_LFUNC int OCCA_RFUNC occaIsDefault(occaType value) {\n+OCCA_LFUNC bool OCCA_RFUNC occaIsDefault(occaType value) {\nreturn (value.type == occa::c::typeType::default_);\n}\n" }, { "change_type": "MODIFY", "old_path": "src/c/uva.cpp", "new_path": "src/c/uva.cpp", "diff": "OCCA_START_EXTERN_C\n-OCCA_LFUNC int OCCA_RFUNC occaIsManaged(void *ptr) {\n+OCCA_LFUNC bool OCCA_RFUNC occaIsManaged(void *ptr) {\nreturn occa::isManaged(ptr);\n}\n@@ -26,7 +26,7 @@ OCCA_LFUNC void OCCA_RFUNC occaSyncToHost(void *ptr,\nocca::syncToHost(ptr, bytes);\n}\n-OCCA_LFUNC int OCCA_RFUNC occaNeedsSync(void *ptr) {\n+OCCA_LFUNC bool OCCA_RFUNC occaNeedsSync(void *ptr) {\nreturn occa::needsSync(ptr);\n}\n" } ]
C++
MIT License
libocca/occa
[C] Use bool instead of int for boolean types everywhere (#332)
378,356
28.04.2020 12:03:14
-36,000
f906041240eb36e51b80ba542682975314db03a4
[Build] Fix compiler flags for OpenMP
[ { "change_type": "MODIFY", "old_path": "scripts/Makefile", "new_path": "scripts/Makefile", "diff": "@@ -230,14 +230,12 @@ endif\n#---[ OpenMP ]--------------------------\nifdef OCCA_OPENMP_ENABLED\nopenmpEnabled = $(OCCA_OPENMP_ENABLED)\n- fOpenmpEnabled = $(OCCA_OPENMP_ENABLED)\nelse\nopenmpEnabled = $(call compilerSupportsOpenMP)\n-\n+endif\nifeq ($(openmpEnabled),1)\nflags += $(call compilerOpenMPFlag)\nendif\n-endif\n#---[ CUDA ]----------------------------\n" } ]
C++
MIT License
libocca/occa
[Build] Fix compiler flags for OpenMP (#335)
378,356
03.05.2020 03:57:55
-36,000
e8e27cf23b3050eab593fe40c34da762a04a209b
[C] Add occaTrue and occaFalse
[ { "change_type": "MODIFY", "old_path": "include/occa/c/types.h", "new_path": "include/occa/c/types.h", "diff": "@@ -91,6 +91,8 @@ extern const int OCCA_PROPERTIES;\nextern const occaType occaNull;\nextern const occaType occaUndefined;\nextern const occaType occaDefault;\n+extern const occaType occaTrue;\n+extern const occaType occaFalse;\nextern const occaUDim_t occaAllBytes;\n//======================================\n" }, { "change_type": "MODIFY", "old_path": "src/c/types.cpp", "new_path": "src/c/types.cpp", "diff": "@@ -646,6 +646,8 @@ const int OCCA_PROPERTIES = occa::c::typeType::properties;\nconst occaType occaUndefined = occa::c::undefinedOccaType();\nconst occaType occaDefault = occa::c::defaultOccaType();\nconst occaType occaNull = occa::c::nullOccaType();\n+const occaType occaTrue = occa::c::newOccaType(true);\n+const occaType occaFalse = occa::c::newOccaType(false);\nconst occaUDim_t occaAllBytes = -1;\n//======================================\n" } ]
C++
MIT License
libocca/occa
[C] Add occaTrue and occaFalse (#338)
378,356
03.05.2020 03:59:19
-36,000
5956d3cc9f020769793d598766c8ef4eb6357867
[Build][CI] Minor fixes
[ { "change_type": "MODIFY", "old_path": "Makefile", "new_path": "Makefile", "diff": "@@ -113,7 +113,7 @@ $(COMPILED_DEFINES_CHANGED):\n#---[ Builds ]------------------------------------\n# ---[ libocca ]-------------\n$(libPath)/libocca.$(soExt):$(objects) $(headers) $(COMPILED_DEFINES)\n- mkdir -p $(libPath)\n+ @mkdir -p $(libPath)\n$(compiler) $(compilerFlags) $(sharedFlag) $(pthreadFlag) $(soNameFlag) -o $(libPath)/libocca.$(soExt) $(flags) $(objects) $(paths) $(filter-out -locca, $(linkerFlags))\n$(binPath)/occa:$(OCCA_DIR)/bin/occa.cpp $(libPath)/libocca.$(soExt) $(COMPILED_DEFINES_CHANGED)\n" }, { "change_type": "MODIFY", "old_path": "tests/run_bin_tests", "new_path": "tests/run_bin_tests", "diff": "@@ -10,7 +10,7 @@ function verbose_run {\n\"$@\"\n}\n-verbose_run \"${BIN_OCCA}\" autocomplete\n+verbose_run \"${BIN_OCCA}\" autocomplete bash\nverbose_run \"${BIN_OCCA}\" clear\nverbose_run \"${BIN_OCCA}\" compile --help\nverbose_run \"${BIN_OCCA}\" env\n" } ]
C++
MIT License
libocca/occa
[Build][CI] Minor fixes (#336)
378,356
05.05.2020 00:24:01
-36,000
a73b681a6a6464f5c5ca2f9696d7e3d0fdef9992
[Build][CI] Add -march=native for gcc and fix CI tests
[ { "change_type": "MODIFY", "old_path": ".github/workflows/build.yml", "new_path": ".github/workflows/build.yml", "diff": "@@ -35,10 +35,10 @@ jobs:\nCXX: clang++-9\nOCCA_COVERAGE: 0\n- - name: (MacOS) gcc\n+ - name: (MacOS) gcc-9\nos: macos-10.15\n- CC: gcc\n- CXX: g++\n+ CC: gcc-9\n+ CXX: g++-9\nOCCA_COVERAGE: 1\n- name: (MacOS) clang\n@@ -58,6 +58,9 @@ jobs:\nsteps:\n- uses: actions/checkout@v2\n+ - name: Compiler info\n+ run: make -j info\n+\n- name: Compile library\nrun: make -j\n" }, { "change_type": "MODIFY", "old_path": "Makefile", "new_path": "Makefile", "diff": "@@ -195,6 +195,7 @@ info:\n$(info LDFLAGS = $(or $(LDFLAGS),(empty)))\n$(info --------------------------------)\n$(info compiler = $(value compiler))\n+ $(info vendor = $(vendor))\n$(info compilerFlags = $(compilerFlags))\n$(info flags = $(flags))\n$(info paths = $(paths))\n" }, { "change_type": "MODIFY", "old_path": "include/occa/scripts/shellTools.sh", "new_path": "include/occa/scripts/shellTools.sh", "diff": "@@ -381,7 +381,7 @@ function compilerReleaseFlags {\nlocal vendor=$(compilerVendor \"$1\")\ncase \"$vendor\" in\n- GCC|LLVM) echo \" -O3 -D __extern_always_inline=inline\" ;;\n+ GCC|LLVM) echo \" -O3 -march=native -D __extern_always_inline=inline\" ;;\nINTEL) echo \" -O3 -xHost\" ;;\nCRAY) echo \" -O3 -h intrinsics -fast\" ;;\nIBM) echo \" -O3 -qhot=simd\" ;;\n" }, { "change_type": "MODIFY", "old_path": "scripts/Makefile", "new_path": "scripts/Makefile", "diff": "@@ -150,6 +150,7 @@ endif\nlibraryFlagsFor = $(shell . $(OCCA_DIR)/include/occa/scripts/shellTools.sh; libraryFlags \"$1\")\nincludeFlagsFor = $(shell . $(OCCA_DIR)/include/occa/scripts/shellTools.sh; headerFlags \"$1\")\n+compilerVendor = $(shell . $(OCCA_DIR)/include/occa/scripts/shellTools.sh; compilerVendor \"$(compiler)\")\ncompilerReleaseFlags = $(shell . $(OCCA_DIR)/include/occa/scripts/shellTools.sh; compilerReleaseFlags \"$(compiler)\")\ncompilerDebugFlags = $(shell . $(OCCA_DIR)/include/occa/scripts/shellTools.sh; compilerDebugFlags \"$(compiler)\")\ncompilerCpp11Flags = $(shell . $(OCCA_DIR)/include/occa/scripts/shellTools.sh; compilerCpp11Flags \"$(compiler)\")\n@@ -164,12 +165,22 @@ compilerOpenMPFlag = $(shell . $(OCCA_DIR)/include/occa/scripts/shellTools.s\n#---[ Compiler Info ]-----------------------------\n+vendor = $(call compilerVendor)\ndebugFlags = $(call compilerDebugFlags)\nreleaseFlags = $(call compilerReleaseFlags)\ncpp11Flags = $(call compilerCpp11Flags)\npicFlag = $(call compilerPicFlag)\nsharedFlag = $(call compilerSharedFlag)\npthreadFlag = $(call compilerPthreadFlag)\n+\n+# Workaround for GitHub Actions CI tests on Ubuntu using GCC.\n+ifdef GITHUB_ACTIONS\n+ ifeq ($(usingLinux),1)\n+ ifeq ($(vendor),GCC)\n+ releaseFlags := $(filter-out -march=native,$(releaseFlags))\n+ endif\n+ endif\n+endif\n#=================================================\n" } ]
C++
MIT License
libocca/occa
[Build][CI] Add -march=native for gcc and fix CI tests (#340)
378,349
30.05.2020 21:47:10
14,400
2f28ff664d83790855287d5bffa52df76dfe46db
[Preprocessor] Allows including standard headers (prints warnings)
[ { "change_type": "MODIFY", "old_path": "include/occa/io/utils.hpp", "new_path": "include/occa/io/utils.hpp", "diff": "@@ -35,6 +35,7 @@ namespace occa {\nstd::string slashToSnake(const std::string &str);\nbool isAbsolutePath(const std::string &filename);\n+ std::string getRelativePath(const std::string &filename);\nstd::string expandEnvVariables(const std::string &filename);\n" }, { "change_type": "MODIFY", "old_path": "include/occa/lang/preprocessor.hpp", "new_path": "include/occa/lang/preprocessor.hpp", "diff": "@@ -16,6 +16,8 @@ namespace occa {\nnamespace lang {\nclass tokenizer_t;\n+ typedef std::map<std::string, bool> stringSet;\n+\ntypedef std::vector<token_t*> tokenVector;\ntypedef std::stack<token_t*> tokenStack;\ntypedef std::list<token_t*> tokenList;\n@@ -57,6 +59,7 @@ namespace occa {\nmacroMap compilerMacros;\nmacroMap sourceMacros;\n+ stringSet standardHeaders;\n//================================\n//---[ Metadata ]-----------------\n@@ -82,6 +85,7 @@ namespace occa {\npreprocessor_t& operator = (const preprocessor_t &pp);\nvoid initDirectives();\n+ void initStandardHeaders();\nvoid warningOn(token_t *token,\nconst std::string &message);\n@@ -173,6 +177,7 @@ namespace occa {\nvoid processWarning(identifierToken &directive);\nvoid processInclude(identifierToken &directive);\n+ bool isStandardHeader(const std::string &header);\nvoid processPragma(identifierToken &directive);\nvoid processOccaPragma(identifierToken &directive,\ntokenVector &lineTokens);\n" }, { "change_type": "MODIFY", "old_path": "src/io/utils.cpp", "new_path": "src/io/utils.cpp", "diff": "#include <occa/io/utils.hpp>\n#include <occa/tools/env.hpp>\n#include <occa/tools/lex.hpp>\n+#include <occa/tools/misc.hpp>\nnamespace occa {\n// Kernel Caching\n@@ -68,9 +69,13 @@ namespace occa {\nstd::string currentWorkingDirectory() {\nchar cwdBuff[FILENAME_MAX];\n#if (OCCA_OS == OCCA_WINDOWS_OS)\n- _getcwd(cwdBuff, sizeof(cwdBuff));\n+ ignoreResult(\n+ _getcwd(cwdBuff, sizeof(cwdBuff))\n+ );\n#else\n- getcwd(cwdBuff, sizeof(cwdBuff));\n+ ignoreResult(\n+ getcwd(cwdBuff, sizeof(cwdBuff))\n+ );\n#endif\nreturn endWithSlash(std::string(cwdBuff));\n}\n@@ -150,6 +155,13 @@ namespace occa {\n#endif\n}\n+ std::string getRelativePath(const std::string &filename) {\n+ if (startsWith(filename, \"./\")) {\n+ return filename.substr(2);\n+ }\n+ return filename;\n+ }\n+\nstd::string expandEnvVariables(const std::string &filename) {\nconst int chars = (int) filename.size();\nif (!chars) {\n@@ -177,7 +189,7 @@ namespace occa {\nexpFilename = fo.expand(expFilename);\nif (makeAbsolute && !isAbsolutePath(expFilename)) {\n- expFilename = env::CWD + expFilename;\n+ return env::CWD + getRelativePath(expFilename);\n}\nreturn expFilename;\n}\n" }, { "change_type": "MODIFY", "old_path": "src/lang/preprocessor.cpp", "new_path": "src/lang/preprocessor.cpp", "diff": "@@ -27,6 +27,7 @@ namespace occa {\npreprocessor_t::preprocessor_t(const occa::properties &settings_) {\ninit();\ninitDirectives();\n+ initStandardHeaders();\nincludePaths = env::OCCA_INCLUDE_PATH;\n@@ -205,6 +206,128 @@ namespace occa {\ndirectives[\"line\"] = &preprocessor_t::processLine;\n}\n+ void preprocessor_t::initStandardHeaders() {\n+ standardHeaders[\"algorithm\"] = true;\n+ standardHeaders[\"any\"] = true;\n+ standardHeaders[\"array\"] = true;\n+ standardHeaders[\"assert.h\"] = true;\n+ standardHeaders[\"atomic\"] = true;\n+ standardHeaders[\"bitset\"] = true;\n+ standardHeaders[\"cassert\"] = true;\n+ standardHeaders[\"ccomplex\"] = true;\n+ standardHeaders[\"cctype\"] = true;\n+ standardHeaders[\"cerrno\"] = true;\n+ standardHeaders[\"cfenv\"] = true;\n+ standardHeaders[\"cfloat\"] = true;\n+ standardHeaders[\"charconv\"] = true;\n+ standardHeaders[\"chrono\"] = true;\n+ standardHeaders[\"cinttypes\"] = true;\n+ standardHeaders[\"ciso646\"] = true;\n+ standardHeaders[\"climits\"] = true;\n+ standardHeaders[\"clocale\"] = true;\n+ standardHeaders[\"cmath\"] = true;\n+ standardHeaders[\"codecvt\"] = true;\n+ standardHeaders[\"compare\"] = true;\n+ standardHeaders[\"complex.h\"] = true;\n+ standardHeaders[\"complex\"] = true;\n+ standardHeaders[\"condition_variable\"] = true;\n+ standardHeaders[\"csetjmp\"] = true;\n+ standardHeaders[\"csignal\"] = true;\n+ standardHeaders[\"cstdalign\"] = true;\n+ standardHeaders[\"cstdarg\"] = true;\n+ standardHeaders[\"cstdbool\"] = true;\n+ standardHeaders[\"cstddef\"] = true;\n+ standardHeaders[\"cstdint\"] = true;\n+ standardHeaders[\"cstdio\"] = true;\n+ standardHeaders[\"cstdlib\"] = true;\n+ standardHeaders[\"cstring\"] = true;\n+ standardHeaders[\"ctgmath\"] = true;\n+ standardHeaders[\"ctime\"] = true;\n+ standardHeaders[\"ctype.h\"] = true;\n+ standardHeaders[\"cuchar\"] = true;\n+ standardHeaders[\"cwchar\"] = true;\n+ standardHeaders[\"cwctype\"] = true;\n+ standardHeaders[\"deque\"] = true;\n+ standardHeaders[\"errno.h\"] = true;\n+ standardHeaders[\"exception\"] = true;\n+ standardHeaders[\"execution\"] = true;\n+ standardHeaders[\"fenv.h\"] = true;\n+ standardHeaders[\"filesystem\"] = true;\n+ standardHeaders[\"float.h\"] = true;\n+ standardHeaders[\"forward_list\"] = true;\n+ standardHeaders[\"fstream\"] = true;\n+ standardHeaders[\"functional\"] = true;\n+ standardHeaders[\"future\"] = true;\n+ standardHeaders[\"initializer_list\"] = true;\n+ standardHeaders[\"inttypes.h\"] = true;\n+ standardHeaders[\"iomanip\"] = true;\n+ standardHeaders[\"ios\"] = true;\n+ standardHeaders[\"iosfwd\"] = true;\n+ standardHeaders[\"iostream\"] = true;\n+ standardHeaders[\"iso646.h\"] = true;\n+ standardHeaders[\"istream\"] = true;\n+ standardHeaders[\"iterator\"] = true;\n+ standardHeaders[\"limits.h\"] = true;\n+ standardHeaders[\"limits\"] = true;\n+ standardHeaders[\"list\"] = true;\n+ standardHeaders[\"locale.h\"] = true;\n+ standardHeaders[\"locale\"] = true;\n+ standardHeaders[\"map\"] = true;\n+ standardHeaders[\"math.h\"] = true;\n+ standardHeaders[\"memory\"] = true;\n+ standardHeaders[\"memory_resource\"] = true;\n+ standardHeaders[\"mutex\"] = true;\n+ standardHeaders[\"new\"] = true;\n+ standardHeaders[\"numeric\"] = true;\n+ standardHeaders[\"optional\"] = true;\n+ standardHeaders[\"ostream\"] = true;\n+ standardHeaders[\"queue\"] = true;\n+ standardHeaders[\"random\"] = true;\n+ standardHeaders[\"ratio\"] = true;\n+ standardHeaders[\"regex\"] = true;\n+ standardHeaders[\"scoped_allocator\"] = true;\n+ standardHeaders[\"set\"] = true;\n+ standardHeaders[\"setjmp.h\"] = true;\n+ standardHeaders[\"shared_mutex\"] = true;\n+ standardHeaders[\"signal.h\"] = true;\n+ standardHeaders[\"sstream\"] = true;\n+ standardHeaders[\"stack\"] = true;\n+ standardHeaders[\"stdalign.h\"] = true;\n+ standardHeaders[\"stdarg.h\"] = true;\n+ standardHeaders[\"stdatomic.h\"] = true;\n+ standardHeaders[\"stdbool.h\"] = true;\n+ standardHeaders[\"stddef.h\"] = true;\n+ standardHeaders[\"stdexcept\"] = true;\n+ standardHeaders[\"stdint.h\"] = true;\n+ standardHeaders[\"stdio.h\"] = true;\n+ standardHeaders[\"stdlib.h\"] = true;\n+ standardHeaders[\"stdnoreturn.h\"] = true;\n+ standardHeaders[\"streambuf\"] = true;\n+ standardHeaders[\"string.h\"] = true;\n+ standardHeaders[\"string\"] = true;\n+ standardHeaders[\"string_view\"] = true;\n+ standardHeaders[\"strstream\"] = true;\n+ standardHeaders[\"syncstream\"] = true;\n+ standardHeaders[\"system_error\"] = true;\n+ standardHeaders[\"tgmath.h\"] = true;\n+ standardHeaders[\"thread\"] = true;\n+ standardHeaders[\"threads.h\"] = true;\n+ standardHeaders[\"time.h\"] = true;\n+ standardHeaders[\"tuple\"] = true;\n+ standardHeaders[\"type_traits\"] = true;\n+ standardHeaders[\"typeindex\"] = true;\n+ standardHeaders[\"typeinfo\"] = true;\n+ standardHeaders[\"uchar.h\"] = true;\n+ standardHeaders[\"unordered_map\"] = true;\n+ standardHeaders[\"unordered_set\"] = true;\n+ standardHeaders[\"utility\"] = true;\n+ standardHeaders[\"valarray\"] = true;\n+ standardHeaders[\"variant\"] = true;\n+ standardHeaders[\"vector\"] = true;\n+ standardHeaders[\"wchar.h\"] = true;\n+ standardHeaders[\"wctype.h\"] = true;\n+ }\n+\nvoid preprocessor_t::warningOn(token_t *token,\nconst std::string &message) {\n++warnings;\n@@ -1174,7 +1297,17 @@ namespace occa {\n}\n}\n}\n+\nif (!io::exists(header)) {\n+ // Default to standard headers if they exist\n+ if (standardHeaders.find(header) != standardHeaders.end()) {\n+ warningOn(&directive,\n+ \"Including standard headers may not be portable for all modes\");\n+ pushOutput(new directiveToken(directive.origin,\n+ \"include <\" + header + \">\"));\n+ return;\n+ }\n+\nerrorOn(&directive,\n\"File does not exist\");\nskipToNewline();\n" }, { "change_type": "MODIFY", "old_path": "src/tools/sys.cpp", "new_path": "src/tools/sys.cpp", "diff": "@@ -277,7 +277,12 @@ namespace occa {\nfor (int i = 0; i < pathSize; ++i) {\nconst std::string &dir = path[i];\n- foundOcca |= dir == \"occa\" || dir == \".occa\";\n+ foundOcca |= (\n+ dir == \"occa\"\n+ || dir == \".occa\"\n+ || startsWith(dir, \"occa_\")\n+ || startsWith(dir, \".occa_\")\n+ );\nif (!dir.size() ||\n(dir == \".\")) {\n" }, { "change_type": "MODIFY", "old_path": "tests/src/fortran/typedefs_helper.cpp", "new_path": "tests/src/fortran/typedefs_helper.cpp", "diff": "@@ -69,7 +69,7 @@ void printOccaType(const occaType *value, const bool verbose) {\nprintf(\" ===============================================\\n\");\nprintf(\" Dump OCCA type data:\\n\");\nprintf(\" -----------------------------------------------\\n\");\n- printf(\" Memory address: %p\\n\", value);\n+ printf(\" Memory address: %p\\n\", (void*) value);\nprintf(\"\\n\");\nprintf(\" magicHeader: %d\\n\", value->magicHeader);\nprintf(\" type: %d\\n\", value->type);\n" }, { "change_type": "MODIFY", "old_path": "tests/src/io/fileOpener.cpp", "new_path": "tests/src/io/fileOpener.cpp", "diff": "@@ -42,23 +42,23 @@ void testOccaFileOpener() {\nASSERT_EQ(occaOpener.expand(\"occa://foo.okl\"),\n\"\");\n- ASSERT_EQ(occaOpener.expand(\"occa://a/\"),\n+ ASSERT_EQ(occaOpener.expand(\"occa://my_library/\"),\n\"\");\n- ASSERT_EQ(occaOpener.expand(\"occa://a/foo.okl\"),\n+ ASSERT_EQ(occaOpener.expand(\"occa://my_library/foo.okl\"),\n\"\");\n- occa::io::addLibraryPath(\"a\", \"foo\");\n+ occa::io::addLibraryPath(\"my_library\", \"foo\");\n- ASSERT_EQ(occaOpener.expand(\"occa://a/\"),\n+ ASSERT_EQ(occaOpener.expand(\"occa://my_library/\"),\n\"foo/\");\n- ASSERT_EQ(occaOpener.expand(\"occa://a/foo.okl\"),\n+ ASSERT_EQ(occaOpener.expand(\"occa://my_library/foo.okl\"),\n\"foo/foo.okl\");\n- occa::io::addLibraryPath(\"a\", \"foo/\");\n+ occa::io::addLibraryPath(\"my_library\", \"foo/\");\n- ASSERT_EQ(occaOpener.expand(\"occa://a/\"),\n+ ASSERT_EQ(occaOpener.expand(\"occa://my_library/\"),\n\"foo/\");\n- ASSERT_EQ(occaOpener.expand(\"occa://a/foo.okl\"),\n+ ASSERT_EQ(occaOpener.expand(\"occa://my_library/foo.okl\"),\n\"foo/foo.okl\");\nASSERT_THROW(\n" }, { "change_type": "MODIFY", "old_path": "tests/src/io/utils.cpp", "new_path": "tests/src/io/utils.cpp", "diff": "@@ -59,6 +59,15 @@ void testPathMethods() {\nASSERT_EQ(occa::io::convertSlashes(\"/a/b\"),\n\"/a/b\");\n+ ASSERT_EQ(occa::io::getRelativePath(\"./a\"),\n+ \"a\");\n+ ASSERT_EQ(occa::io::getRelativePath(\"./a/b\"),\n+ \"a/b\");\n+ ASSERT_EQ(occa::io::getRelativePath(\".a/b\"),\n+ \".a/b\");\n+ ASSERT_EQ(occa::io::getRelativePath(\"../a/b\"),\n+ \"../a/b\");\n+\nASSERT_EQ(occa::io::expandEnvVariables(\"~\"),\nocca::env::HOME);\nASSERT_EQ(occa::io::expandEnvVariables(\"~/a\"),\n" }, { "change_type": "MODIFY", "old_path": "tests/src/lang/preprocessor.cpp", "new_path": "tests/src/lang/preprocessor.cpp", "diff": "@@ -15,6 +15,7 @@ void testIfWithUndefines();\nvoid testErrorDefines();\nvoid testSpecialMacros();\nvoid testInclude();\n+void testIncludeStandardHeader();\nvoid testPragma();\nvoid testOccaPragma();\nvoid testOccaDirective();\n@@ -82,6 +83,7 @@ int main(const int argc, const char **argv) {\ntestErrorDefines();\ntestSpecialMacros();\ntestInclude();\n+ testIncludeStandardHeader();\ntestPragma();\ntestOccaPragma();\ntestOccaDirective();\n@@ -600,6 +602,35 @@ void testInclude() {\n(int) pp.dependencies.size());\n}\n+void testIncludeStandardHeader() {\n+#define checkInclude(header) \\\n+ getToken(); \\\n+ ASSERT_EQ_BINARY(tokenType::directive, \\\n+ token->type()); \\\n+ ASSERT_EQ(\"include <\" header \">\", \\\n+ token->to<directiveToken>().value)\n+\n+ setStream(\n+ \"#include \\\"math.h\\\"\\n\"\n+ \"#include <math.h>\\n\"\n+ \"#include \\\"cmath\\\"\\n\"\n+ \"#include <cmath>\\n\"\n+ \"#include \\\"iostream\\\"\\n\"\n+ \"#include <iostream>\\n\"\n+ );\n+\n+ preprocessor_t *pp = (preprocessor_t*) tokenStream.getInput(\"preprocessor_t\");\n+\n+ checkInclude(\"math.h\");\n+ checkInclude(\"math.h\");\n+ checkInclude(\"cmath\");\n+ checkInclude(\"cmath\");\n+ checkInclude(\"iostream\");\n+ checkInclude(\"iostream\");\n+\n+ ASSERT_EQ(6, pp->warnings);\n+}\n+\nvoid testPragma() {\nsetStream(\"#pragma\\n\");\ngetToken();\n" }, { "change_type": "MODIFY", "old_path": "tests/src/tools/sys.cpp", "new_path": "tests/src/tools/sys.cpp", "diff": "@@ -17,11 +17,17 @@ int main(const int argc, const char **argv) {\n}\nvoid testRmrf() {\n+ // Need to make sure \"occa\" is in the filepath\n+ occa::io::addLibraryPath(\"my_library\", \"/path/to/my_library/occa\");\n+\nASSERT_TRUE(occa::sys::isSafeToRmrf(\"/a/occa/b\"));\nASSERT_TRUE(occa::sys::isSafeToRmrf(\"/a/b/../b/.occa\"));\n+ ASSERT_TRUE(occa::sys::isSafeToRmrf(\"/a/occa_dir/b\"));\n+ ASSERT_TRUE(occa::sys::isSafeToRmrf(\"/a/b/../b/.occa_dir\"));\nASSERT_TRUE(occa::sys::isSafeToRmrf(\"/../../../../../occa/a/b\"));\nASSERT_TRUE(occa::sys::isSafeToRmrf(\"~/c/.cache/occa\"));\n- ASSERT_TRUE(occa::sys::isSafeToRmrf(\"occa://lib\"));\n+ ASSERT_TRUE(occa::sys::isSafeToRmrf(\"occa://my_library/\"));\n+ ASSERT_TRUE(occa::sys::isSafeToRmrf(\"occa://my_library/file\"));\nASSERT_FALSE(occa::sys::isSafeToRmrf(\"/occa/a/..\"));\nASSERT_FALSE(occa::sys::isSafeToRmrf(\"/a/b/c/..\"));\n@@ -29,12 +35,13 @@ void testRmrf() {\nASSERT_FALSE(occa::sys::isSafeToRmrf(\"/../../../../../a/b\"));\nASSERT_FALSE(occa::sys::isSafeToRmrf(\"~/c/..\"));\n+ // Needs to have occa in the name\nconst std::string dummyDir = \"occa_foo_bar_test\";\nocca::sys::rmrf(dummyDir);\nASSERT_FALSE(occa::io::isDir(dummyDir));\n- occa::sys::mkdir(dummyDir);\n+ occa::sys::mkpath(dummyDir);\nASSERT_TRUE(occa::io::isDir(dummyDir));\nocca::sys::rmrf(dummyDir);\n" } ]
C++
MIT License
libocca/occa
[Preprocessor] Allows including standard headers (prints warnings) (#346)
378,349
30.05.2020 22:30:52
14,400
4c1a3087643a32dd72b6a413c1ded38c8856a7fc
[Preprocessor] Adds OCCA defines when compiling kernels
[ { "change_type": "MODIFY", "old_path": "src/lang/preprocessor.cpp", "new_path": "src/lang/preprocessor.cpp", "diff": "@@ -79,6 +79,15 @@ namespace occa {\ncompilerMacros[specialMacros[i]->name()] = specialMacros[i];\n}\n+ // OCCA-specific macros\n+ addCompilerDefine(\"OCCA_MAJOR_VERSION\", toString(OCCA_MAJOR_VERSION));\n+ addCompilerDefine(\"OCCA_MINOR_VERSION\", toString(OCCA_MINOR_VERSION));\n+ addCompilerDefine(\"OCCA_PATCH_VERSION\", toString(OCCA_PATCH_VERSION));\n+ addCompilerDefine(\"OCCA_VERSION\", toString(OCCA_VERSION));\n+ addCompilerDefine(\"OKL_VERSION\" , toString(OKL_VERSION));\n+ addCompilerDefine(\"__OKL__\" , \"1\");\n+ addCompilerDefine(\"__OCCA__\" , \"1\");\n+\n// Alternative representations\naddCompilerDefine(\"and\" , \"&&\");\naddCompilerDefine(\"and_eq\", \"&=\");\n" }, { "change_type": "MODIFY", "old_path": "tests/src/lang/preprocessor.cpp", "new_path": "tests/src/lang/preprocessor.cpp", "diff": "@@ -13,6 +13,7 @@ void testIfElse();\nvoid testIfElseDefines();\nvoid testIfWithUndefines();\nvoid testErrorDefines();\n+void testOccaMacros();\nvoid testSpecialMacros();\nvoid testInclude();\nvoid testIncludeStandardHeader();\n@@ -81,6 +82,7 @@ int main(const int argc, const char **argv) {\ntestIfElseDefines();\ntestIfWithUndefines();\ntestErrorDefines();\n+ testOccaMacros();\ntestSpecialMacros();\ntestInclude();\ntestIncludeStandardHeader();\n@@ -512,6 +514,35 @@ void testErrorDefines() {\n}\n}\n+void testOccaMacros() {\n+ setStream(\n+ \"OCCA_MAJOR_VERSION\\n\"\n+ \"OCCA_MINOR_VERSION\\n\"\n+ \"OCCA_PATCH_VERSION\\n\"\n+ \"OCCA_VERSION\\n\"\n+ \"OKL_VERSION\\n\"\n+ \"__OKL__\\n\"\n+ \"__OCCA__\\n\"\n+ );\n+\n+ ASSERT_EQ(OCCA_MAJOR_VERSION,\n+ (int) nextTokenPrimitiveValue());\n+ ASSERT_EQ(OCCA_MINOR_VERSION,\n+ (int) nextTokenPrimitiveValue());\n+ ASSERT_EQ(OCCA_PATCH_VERSION,\n+ (int) nextTokenPrimitiveValue());\n+ ASSERT_EQ(OCCA_VERSION,\n+ (int) nextTokenPrimitiveValue());\n+ ASSERT_EQ(OKL_VERSION,\n+ (int) nextTokenPrimitiveValue());\n+ // __OKL__\n+ ASSERT_EQ(1,\n+ (int) nextTokenPrimitiveValue());\n+ // __OCCA__\n+ ASSERT_EQ(1,\n+ (int) nextTokenPrimitiveValue());\n+}\n+\nvoid testSpecialMacros() {\nsetStream(\n\"__COUNTER__\\n\"\n" } ]
C++
MIT License
libocca/occa
[Preprocessor] Adds OCCA defines when compiling kernels (#347)
378,349
31.05.2020 00:29:21
14,400
ddccbd590b9c7762e70ce07d26380663de751b92
[Lang] Pretty-prints long function calls and tuples
[ { "change_type": "MODIFY", "old_path": "include/occa/lang/expr/exprNode.hpp", "new_path": "include/occa/lang/expr/exprNode.hpp", "diff": "@@ -21,6 +21,10 @@ namespace occa {\ntypedef std::stack<exprNode*> exprNodeStack;\ntypedef std::vector<token_t*> tokenVector;\n+ // Variables to help make output prettier\n+ static const int PRETTIER_MAX_VAR_WIDTH = 30;\n+ static const int PRETTIER_MAX_LINE_WIDTH = 80;\n+\nnamespace exprNodeType {\nextern const udim_t empty;\nextern const udim_t primitive;\n" }, { "change_type": "MODIFY", "old_path": "include/occa/lang/printer.hpp", "new_path": "include/occa/lang/printer.hpp", "diff": "namespace occa {\nnamespace lang {\n- int charsFromNewline(const std::string &s);\n-\nclass printer {\nprivate:\nstd::stringstream ss;\n@@ -38,6 +36,7 @@ namespace occa {\nvoid pushInlined(const bool inlined);\nvoid popInlined();\n+ int indentationSize();\nvoid addIndentation();\nvoid removeIndentation();\n@@ -45,6 +44,7 @@ namespace occa {\nbool lastCharNeedsWhitespace();\nvoid forceNextInlined();\n+ int cursorPosition();\nstd::string indentFromNewline();\nvoid printIndentation();\n" }, { "change_type": "MODIFY", "old_path": "src/lang/expr/callNode.cpp", "new_path": "src/lang/expr/callNode.cpp", "diff": "@@ -52,15 +52,53 @@ namespace occa {\n}\nvoid callNode::print(printer &pout) const {\n- pout << *value\n- << '(';\n+ bool useNewlineDelimiters = false;\n+ std::string functionName = value->toString();\n+ int lineWidth = (\n+ pout.cursorPosition()\n+ + (int) functionName.size()\n+ );\n+\nconst int argCount = (int) args.size();\n+ for (int i = 0; i < argCount; ++i) {\n+ const std::string argStr = args[i]->toString();\n+ const int argSize = (int) argStr.size();\n+ lineWidth += argSize;\n+\n+ useNewlineDelimiters |= (\n+ argSize > PRETTIER_MAX_VAR_WIDTH\n+ || lineWidth > PRETTIER_MAX_LINE_WIDTH\n+ );\n+ }\n+\n+ pout << functionName\n+ << '(';\n+\n+ if (useNewlineDelimiters) {\n+ pout.addIndentation();\n+ pout.printNewline();\n+ pout.printIndentation();\n+ }\n+\nfor (int i = 0; i < argCount; ++i) {\nif (i) {\n+ if (useNewlineDelimiters) {\n+ pout << ',';\n+ pout.printNewline();\n+ pout.printIndentation();\n+ } else {\npout << \", \";\n}\n+ }\npout << *(args[i]);\n}\n+\n+ if (useNewlineDelimiters) {\n+ pout.removeIndentation();\n+ pout.printNewline();\n+ pout.printIndentation();\n+ }\n+\npout << ')';\n}\n" }, { "change_type": "MODIFY", "old_path": "src/lang/expr/expression.cpp", "new_path": "src/lang/expr/expression.cpp", "diff": "@@ -411,7 +411,7 @@ namespace occa {\n// Only consider () as a function call if preceeded by:\n// - identifier\n// - pairEnd\n- const int prevTokenType = state.beforePairToken->type();\n+ const int prevTokenType = token_t::safeType(state.beforePairToken);\nif (!(prevTokenType & (outputTokenType |\ntokenType::op))) {\ntransformLastPair(opToken, state);\n" }, { "change_type": "MODIFY", "old_path": "src/lang/expr/tupleNode.cpp", "new_path": "src/lang/expr/tupleNode.cpp", "diff": "@@ -48,14 +48,50 @@ namespace occa {\n}\nvoid tupleNode::print(printer &pout) const {\n- pout << '{';\n+ bool useNewlineDelimiters = false;\n+ strVector printedArgs;\n+ // For the initial {\n+ int lineWidth = pout.cursorPosition() + 1;\n+\nconst int argCount = (int) args.size();\n+ for (int i = 0; i < argCount; ++i) {\n+ const std::string argStr = args[i]->toString();\n+ const int argSize = (int) argStr.size();\n+ lineWidth += argSize;\n+\n+ useNewlineDelimiters |= (\n+ argSize > PRETTIER_MAX_VAR_WIDTH\n+ || lineWidth > PRETTIER_MAX_LINE_WIDTH\n+ );\n+ }\n+\n+ pout << '{';\n+\n+ if (useNewlineDelimiters) {\n+ pout.addIndentation();\n+ pout.printNewline();\n+ pout.printIndentation();\n+ }\n+\nfor (int i = 0; i < argCount; ++i) {\nif (i) {\n+ if (useNewlineDelimiters) {\n+ pout << ',';\n+ pout.printNewline();\n+ pout.printIndentation();\n+ } else {\npout << \", \";\n}\n+ }\npout << *(args[i]);\n}\n+\n+ if (useNewlineDelimiters) {\n+ pout.removeIndentation();\n+ pout.printNewline();\n+ pout.printIndentation();\n+ }\n+\npout << '}';\n}\n" }, { "change_type": "MODIFY", "old_path": "src/lang/printer.cpp", "new_path": "src/lang/printer.cpp", "diff": "namespace occa {\nnamespace lang {\n- int charsFromNewline(const std::string &s) {\n- const char *c = s.c_str();\n- const int chars = (int) s.size();\n- for (int pos = (chars - 1); pos >= 0; --pos) {\n- if (*c == '\\n') {\n- return (chars - pos - 1);\n- }\n- }\n- return chars;\n- }\n-\nprinter::printer() :\nss(),\nout(NULL) {\n@@ -67,6 +56,10 @@ namespace occa {\n}\n}\n+ int printer::indentationSize() {\n+ (int) indent.size();\n+ }\n+\nvoid printer::addIndentation() {\nindent += \" \";\n}\n@@ -97,6 +90,10 @@ namespace occa {\nlastChar = '\\0';\n}\n+ int printer::cursorPosition() {\n+ return charsFromNewline;\n+ }\n+\nstd::string printer::indentFromNewline() {\nreturn std::string(charsFromNewline, ' ');\n}\n" } ]
C++
MIT License
libocca/occa
[Lang] Pretty-prints long function calls and tuples (#348)
378,349
31.05.2020 16:02:22
14,400
c83a8cb8cfa0551b8517527a012915d6f3ec5f03
[Parser] Cleans up output indentation when using a buffer
[ { "change_type": "MODIFY", "old_path": "include/occa/lang/printer.hpp", "new_path": "include/occa/lang/printer.hpp", "diff": "@@ -56,23 +56,35 @@ namespace occa {\nvoid print(const TM &t) {\nss << t;\nconst std::string str = ss.str();\n- const char *c_str = str.c_str();\nconst int chars = (int) str.size();\n- if (chars) {\n+ if (!chars) {\n+ return;\n+ }\n+\n+ int scanStart;\n+ if (out) {\n+ // Clear buffer\nss.str(\"\");\n- lastChar = c_str[chars - 1];\n- for (int i = 0; i < chars; ++i) {\n+ scanStart = 0;\n+ } else {\n+ // We don't clear the buffer so no need to re-read past characters\n+ scanStart = charsFromNewline;\n+ }\n+\n+ const char *c_str = str.c_str();\n+ for (int i = scanStart; i < chars; ++i) {\nif (c_str[i] != '\\n') {\n++charsFromNewline;\n} else {\ncharsFromNewline = 0;\n}\n}\n+\n+ lastChar = c_str[chars - 1];\n+\nif (out) {\n+ // Print to buffer\n*out << str;\n- } else {\n- ss << str;\n- }\n}\n}\n};\n" }, { "change_type": "MODIFY", "old_path": "include/occa/lang/token/commentToken.hpp", "new_path": "include/occa/lang/token/commentToken.hpp", "diff": "@@ -9,7 +9,7 @@ namespace occa {\nstatic const int none = 0;\nstatic const int left = (1 << 0);\nstatic const int right = (1 << 1);\n- };\n+ }\nclass commentToken : public token_t {\npublic:\n" } ]
C++
MIT License
libocca/occa
[Parser] Cleans up output indentation when using a buffer (#352)
378,349
31.05.2020 17:37:42
14,400
34cf8ab5ebe4f21937102c527636df071e23b51d
[CI] Adds codecov back
[ { "change_type": "MODIFY", "old_path": ".github/workflows/build.yml", "new_path": ".github/workflows/build.yml", "diff": "@@ -16,6 +16,7 @@ jobs:\nCC: gcc-8\nCXX: g++-8\nFC: gfortran-8\n+ GCOV: gcov-8\nOCCA_COVERAGE: 1\nOCCA_FORTRAN_ENABLED: 1\n@@ -24,6 +25,7 @@ jobs:\nCC: gcc-9\nCXX: g++-9\nFC: gfortran-9\n+ GCOV: gcov-9\nOCCA_COVERAGE: 1\nOCCA_FORTRAN_ENABLED: 1\n@@ -43,6 +45,7 @@ jobs:\nos: macos-10.15\nCC: gcc-9\nCXX: g++-9\n+ GCOV: gcov-9\nOCCA_COVERAGE: 1\n- name: (MacOS) clang\n@@ -58,6 +61,7 @@ jobs:\nCC: ${{ matrix.CC }}\nCXX: ${{ matrix.CXX }}\nFC: ${{ matrix.FC }}\n+ GCOV: ${{ matrix.GCOV }}\nOCCA_COVERAGE: ${{ matrix.OCCA_COVERAGE }}\nOCCA_FORTRAN_ENABLED: ${{ matrix.OCCA_FORTRAN_ENABLED }}\nFORTRAN_EXAMPLES: ${{ matrix.OCCA_FORTRAN_ENABLED }}\n@@ -66,13 +70,13 @@ jobs:\n- uses: actions/checkout@v2\n- name: Compiler info\n- run: make -j info\n+ run: make -j 16 info\n- name: Compile library\n- run: make -j\n+ run: make -j 16\n- name: Compile tests\n- run: make -j tests\n+ run: make -j 16 tests\n- name: Run unit tests\nrun: ./tests/run_tests\n@@ -81,4 +85,5 @@ jobs:\nrun: ./tests/run_examples\n- name: Upload code coverage\n- uses: codecov/codecov-action@v1\n+ run: bash <(curl --no-buffer -s https://codecov.io/bash) -x \"${GCOV}\"\n+ if: ${{ matrix.OCCA_COVERAGE }}\n" } ]
C++
MIT License
libocca/occa
[CI] Adds codecov back (#351)
378,349
31.05.2020 22:18:31
14,400
013c0f1c66c132aaf9569d2d278f5db42c8eb334
[Preprocessor] Adds OKL_KERNEL_HASH define to help debug running kernels
[ { "change_type": "MODIFY", "old_path": "include/occa/lang/preprocessor.hpp", "new_path": "include/occa/lang/preprocessor.hpp", "diff": "@@ -63,6 +63,8 @@ namespace occa {\n//================================\n//---[ Metadata ]-----------------\n+ occa::properties settings;\n+\nstrToBoolMap dependencies;\nint warnings, errors;\n//================================\n@@ -84,6 +86,8 @@ namespace occa {\npreprocessor_t& operator = (const preprocessor_t &pp);\n+ void setSettings(occa::properties settings_);\n+\nvoid initDirectives();\nvoid initStandardHeaders();\n" }, { "change_type": "MODIFY", "old_path": "src/lang/preprocessor.cpp", "new_path": "src/lang/preprocessor.cpp", "diff": "@@ -29,9 +29,11 @@ namespace occa {\ninitDirectives();\ninitStandardHeaders();\n+ setSettings(settings_);\n+\nincludePaths = env::OCCA_INCLUDE_PATH;\n- json oklIncludePaths = settings_[\"okl/include_paths\"];\n+ json oklIncludePaths = settings[\"okl/include_paths\"];\nif (oklIncludePaths.isArray()) {\njsonArray pathArray = oklIncludePaths.array();\nconst int pathCount = (int) pathArray.size();\n@@ -88,6 +90,16 @@ namespace occa {\naddCompilerDefine(\"__OKL__\" , \"1\");\naddCompilerDefine(\"__OCCA__\" , \"1\");\n+ // Add kernel hash as a define\n+ std::string hashValue = settings.get<std::string>(\"hash\", \"\");\n+ if (hashValue.size()) {\n+ hash_t hash = hash_t::fromString(hashValue);\n+ hashValue = hash.getString();\n+ } else {\n+ hashValue = \"unknown\";\n+ }\n+ addCompilerDefine(\"OKL_KERNEL_HASH\", \"\\\"\" + hashValue + \"\\\"\");\n+\n// Alternative representations\naddCompilerDefine(\"and\" , \"&&\");\naddCompilerDefine(\"and_eq\", \"&=\");\n@@ -196,6 +208,10 @@ namespace occa {\nreturn *this;\n}\n+ void preprocessor_t::setSettings(occa::properties settings_) {\n+ settings = settings_;\n+ }\n+\nvoid preprocessor_t::initDirectives() {\ndirectives[\"if\"] = &preprocessor_t::processIf;\ndirectives[\"ifdef\"] = &preprocessor_t::processIfdef;\n" }, { "change_type": "MODIFY", "old_path": "tests/src/lang/preprocessor.cpp", "new_path": "tests/src/lang/preprocessor.cpp", "diff": "@@ -515,6 +515,13 @@ void testErrorDefines() {\n}\nvoid testOccaMacros() {\n+ occa::hash_t hash = occa::hash_t::fromString(\"df15688e1bde01ebb5b3750031d017b2312d028acd9753b27dd4ba0aef0a4d41\");\n+\n+ occa::properties preprocessorSettings;\n+ preprocessorSettings[\"hash\"] = hash.getFullString();\n+\n+ preprocessor.setSettings(preprocessorSettings);\n+\nsetStream(\n\"OCCA_MAJOR_VERSION\\n\"\n\"OCCA_MINOR_VERSION\\n\"\n@@ -523,6 +530,7 @@ void testOccaMacros() {\n\"OKL_VERSION\\n\"\n\"__OKL__\\n\"\n\"__OCCA__\\n\"\n+ \"OKL_KERNEL_HASH\\n\"\n);\nASSERT_EQ(OCCA_MAJOR_VERSION,\n@@ -541,6 +549,18 @@ void testOccaMacros() {\n// __OCCA__\nASSERT_EQ(1,\n(int) nextTokenPrimitiveValue());\n+ // OKL_KERNEL_HASH\n+ ASSERT_EQ(hash.getString(),\n+ nextTokenStringValue());\n+\n+ // Test default OKL_KERNEL_HASH\n+ preprocessor.setSettings(\"\");\n+\n+ setStream(\"OKL_KERNEL_HASH\");\n+\n+ // OKL_KERNEL_HASH\n+ ASSERT_EQ(\"unknown\",\n+ nextTokenStringValue());\n}\nvoid testSpecialMacros() {\n" } ]
C++
MIT License
libocca/occa
[Preprocessor] Adds OKL_KERNEL_HASH define to help debug running kernels (#354)
378,349
01.06.2020 02:14:10
14,400
fbcd3a39013c26719777c1a68eecb5de2df9ade7
[Parser] Bug not setting the proper child statements with comment statements
[ { "change_type": "MODIFY", "old_path": "src/lang/parser.cpp", "new_path": "src/lang/parser.cpp", "diff": "@@ -663,7 +663,7 @@ namespace occa {\n// We need to create a block statement to hold these statements\nblockStatement *blockSmnt = new blockStatement(smnt->up,\nsmnt->source);\n- statementPtrVector &statements = smntContext.up->children;\n+ statementPtrVector &statements = blockSmnt->children;\nsmntContext.pushUp(*blockSmnt);\n@@ -678,6 +678,11 @@ namespace occa {\n}\n}\n+ // Add the last non-comment statement\n+ if (smnt) {\n+ statements.push_back(smnt);\n+ }\n+\nsmntContext.popUp();\nreturn blockSmnt;\n" }, { "change_type": "MODIFY", "old_path": "tests/files/addVectors.okl", "new_path": "tests/files/addVectors.okl", "diff": "float *ab) {\nfor (int i = 0; i < /*Comment 5.1*/ entries; ++i; /*Comment 5.2*/ @tile(16, @outer, @inner)) {\nab[i] = a[i] + b[i];\n+\n+ double A[3][3];\n+ for (int i = 0; i < 3; i++)\n+ for (int j = 0; j < 3; j++)\n+ // Comment 6.1\n+ // Comment 6.2\n+ A[i][k] = a[i] + b[j];\n}\n}\n" } ]
C++
MIT License
libocca/occa
[Parser] Bug not setting the proper child statements with comment statements (#355)
378,349
01.06.2020 23:44:49
14,400
d321a21bd0a57d877244b1fc59ca5df518d9cdeb
[Parser] Adds directiveStatement from directiveToken
[ { "change_type": "MODIFY", "old_path": "include/occa/lang/parser.hpp", "new_path": "include/occa/lang/parser.hpp", "diff": "@@ -207,6 +207,7 @@ namespace occa {\nstatement_t* loadCommentStatement(attributeTokenMap &smntAttributes);\n+ statement_t* loadDirectiveStatement(attributeTokenMap &smntAttributes);\nstatement_t* loadPragmaStatement(attributeTokenMap &smntAttributes);\nstatement_t* loadGotoStatement(attributeTokenMap &smntAttributes);\n" }, { "change_type": "MODIFY", "old_path": "src/lang/parser.cpp", "new_path": "src/lang/parser.cpp", "diff": "@@ -52,6 +52,7 @@ namespace occa {\nstatementLoaders[statementType::return_] = &parser_t::loadReturnStatement;\nstatementLoaders[statementType::classAccess] = &parser_t::loadClassAccessStatement;\nstatementLoaders[statementType::comment] = &parser_t::loadCommentStatement;\n+ statementLoaders[statementType::directive] = &parser_t::loadDirectiveStatement;\nstatementLoaders[statementType::pragma] = &parser_t::loadPragmaStatement;\nstatementLoaders[statementType::goto_] = &parser_t::loadGotoStatement;\nstatementLoaders[statementType::gotoLabel] = &parser_t::loadGotoLabelStatement;\n@@ -1573,6 +1574,16 @@ namespace occa {\nreturn smnt;\n}\n+ statement_t* parser_t::loadDirectiveStatement(attributeTokenMap &smntAttributes) {\n+ directiveStatement *smnt = new directiveStatement(smntContext.up,\n+ *((directiveToken*) tokenContext[0]));\n+ addAttributesTo(smntAttributes, smnt);\n+\n+ ++tokenContext;\n+\n+ return smnt;\n+ }\n+\nstatement_t* parser_t::loadPragmaStatement(attributeTokenMap &smntAttributes) {\npragmaStatement *smnt = new pragmaStatement(smntContext.up,\n*((pragmaToken*) tokenContext[0]));\n" }, { "change_type": "MODIFY", "old_path": "src/lang/statementPeeker.cpp", "new_path": "src/lang/statementPeeker.cpp", "diff": "@@ -92,6 +92,10 @@ namespace occa {\nreturn statementType::comment;\n}\n+ if (tokenType & tokenType::directive) {\n+ return statementType::directive;\n+ }\n+\nif (tokenType & tokenType::pragma) {\nreturn statementType::pragma;\n}\n" }, { "change_type": "MODIFY", "old_path": "tests/files/addVectors.okl", "new_path": "tests/files/addVectors.okl", "diff": "+#include <math.h>\n+\n// Comment 1\n/*\n" } ]
C++
MIT License
libocca/occa
[Parser] Adds directiveStatement from directiveToken (#356)
378,349
04.06.2020 07:15:06
14,400
295eba66b9b2cdfc9f987fec7046dca79a0f0a2b
[Parser] tokenContext auto-removes certain tokens
[ { "change_type": "MODIFY", "old_path": "include/occa/c/types.h", "new_path": "include/occa/c/types.h", "diff": "@@ -100,7 +100,7 @@ extern const occaUDim_t occaAllBytes;\nOCCA_LFUNC bool OCCA_RFUNC occaIsUndefined(occaType value);\nOCCA_LFUNC bool OCCA_RFUNC occaIsDefault(occaType value);\n-OCCA_LFUNC occaType OCCA_RFUNC occaPtr(void *value);\n+OCCA_LFUNC occaType OCCA_RFUNC occaPtr(const void *value);\nOCCA_LFUNC occaType OCCA_RFUNC occaBool(bool value);\n" }, { "change_type": "MODIFY", "old_path": "include/occa/c/types.hpp", "new_path": "include/occa/c/types.hpp", "diff": "@@ -49,6 +49,7 @@ namespace occa {\noccaType newOccaType(const TM &value);\noccaType newOccaType(void *value);\n+ occaType newOccaType(const void *value);\ntemplate <>\noccaType newOccaType(const occa::primitive &value);\n" }, { "change_type": "MODIFY", "old_path": "include/occa/lang/parser.hpp", "new_path": "include/occa/lang/parser.hpp", "diff": "@@ -51,10 +51,10 @@ namespace occa {\nstatementContext_t smntContext;\nstatementPeeker_t smntPeeker;\n- bool ignoringComments;\nbool checkSemicolon;\nunknownToken defaultRootToken;\n+ statementPtrVector comments;\nattributeTokenMap attributes;\nbool success;\n@@ -114,6 +114,11 @@ namespace occa {\nexprNode* getExpression(const int start,\nconst int end);\n+ void loadComments();\n+ void loadComments(const int start,\n+ const int end);\n+ void pushComments();\n+\nvoid loadAttributes(attributeTokenMap &attrs);\nattribute_t* getAttribute(const std::string &name);\n@@ -165,8 +170,8 @@ namespace occa {\nvoid loadAllStatements();\n+ statement_t* loadNextStatement();\nstatement_t* getNextStatement();\n- statement_t* getNextNonCommentStatement();\nstatement_t* loadBlockStatement(attributeTokenMap &smntAttributes);\n@@ -205,8 +210,6 @@ namespace occa {\nstatement_t* loadClassAccessStatement(attributeTokenMap &smntAttributes);\n- statement_t* loadCommentStatement(attributeTokenMap &smntAttributes);\n-\nstatement_t* loadDirectiveStatement(attributeTokenMap &smntAttributes);\nstatement_t* loadPragmaStatement(attributeTokenMap &smntAttributes);\n" }, { "change_type": "MODIFY", "old_path": "include/occa/lang/tokenContext.hpp", "new_path": "include/occa/lang/tokenContext.hpp", "diff": "@@ -36,6 +36,9 @@ namespace occa {\nclass tokenContext_t {\npublic:\ntokenVector tokens;\n+ // Keep track of used tokens (e.g. not commnents)\n+ intVector tokenIndices;\n+\nintIntMap pairs;\nintVector semicolons;\nbool hasError;\n@@ -48,7 +51,8 @@ namespace occa {\n~tokenContext_t();\nvoid clear();\n- void setup();\n+ void setup(const tokenVector &tokens_);\n+ void setupTokenIndices();\nvoid findPairs();\nvoid findSemicolons();\n@@ -72,16 +76,24 @@ namespace occa {\nvoid popAndSkip();\nint position() const;\n+\nint size() const;\n+ void getSkippedTokens(tokenVector &skippedTokens,\n+ const int start,\n+ const int end);\n+\n+ token_t* getToken(const int index);\n+ token_t* getNativeToken(const int index);\n+\n+ void setToken(const int index,\n+ token_t *value);\n+\ntoken_t* operator [] (const int index);\ntokenContext_t& operator ++ ();\ntokenContext_t& operator ++ (int);\ntokenContext_t& operator += (const int offset);\n- void setToken(const int index,\n- token_t *value);\n-\ntoken_t* end();\ntoken_t* getPrintToken(const bool atEnd);\n" }, { "change_type": "MODIFY", "old_path": "src/c/types.cpp", "new_path": "src/c/types.cpp", "diff": "@@ -31,6 +31,10 @@ namespace occa {\n}\noccaType newOccaType(void *value) {\n+ return newOccaType((const void*) value);\n+ }\n+\n+ occaType newOccaType(const void *value) {\noccaType oType;\noType.magicHeader = OCCA_C_TYPE_MAGIC_HEADER;\noType.type = typeType::ptr;\n@@ -670,7 +674,7 @@ OCCA_LFUNC bool OCCA_RFUNC occaIsDefault(occaType value) {\nreturn (value.type == occa::c::typeType::default_);\n}\n-OCCA_LFUNC occaType OCCA_RFUNC occaPtr(void *value) {\n+OCCA_LFUNC occaType OCCA_RFUNC occaPtr(const void *value) {\nreturn occa::c::newOccaType(value);\n}\n" }, { "change_type": "MODIFY", "old_path": "src/lang/parser.cpp", "new_path": "src/lang/parser.cpp", "diff": "@@ -51,7 +51,6 @@ namespace occa {\nstatementLoaders[statementType::break_] = &parser_t::loadBreakStatement;\nstatementLoaders[statementType::return_] = &parser_t::loadReturnStatement;\nstatementLoaders[statementType::classAccess] = &parser_t::loadClassAccessStatement;\n- statementLoaders[statementType::comment] = &parser_t::loadCommentStatement;\nstatementLoaders[statementType::directive] = &parser_t::loadDirectiveStatement;\nstatementLoaders[statementType::pragma] = &parser_t::loadPragmaStatement;\nstatementLoaders[statementType::goto_] = &parser_t::loadGotoStatement;\n@@ -168,6 +167,7 @@ namespace occa {\ncheckSemicolon = true;\n+ comments.clear();\nclearAttributes();\nonClear();\n@@ -258,10 +258,11 @@ namespace occa {\n}\nvoid parser_t::loadTokens() {\n+ tokenVector tokens;\ntoken_t *token;\nwhile (!stream.isEmpty()) {\nstream >> token;\n- tokenContext.tokens.push_back(token);\n+ tokens.push_back(token);\n}\nif (tokenizer.errors ||\n@@ -270,7 +271,7 @@ namespace occa {\nreturn;\n}\n- tokenContext.setup();\n+ tokenContext.setup(tokens);\nsuccess &= !tokenContext.hasError;\n}\n@@ -322,6 +323,49 @@ namespace occa {\nreturn expr;\n}\n+ void parser_t::loadComments() {\n+ const int start = tokenContext.position();\n+ loadComments(start, start);\n+ }\n+\n+ void parser_t::loadComments(const int start,\n+ const int end) {\n+ tokenVector skippedTokens;\n+ tokenContext.getSkippedTokens(skippedTokens, start, end);\n+\n+ const int skippedTokenCount = (int) skippedTokens.size();\n+ if (!skippedTokenCount) {\n+ return;\n+ }\n+\n+ for (int i = 0; i < skippedTokenCount; ++i) {\n+ token_t *token = skippedTokens[i];\n+ if (!(token->type() & tokenType::comment)) {\n+ continue;\n+ }\n+\n+ comments.push_back(\n+ new commentStatement(smntContext.up,\n+ *((commentToken*) token))\n+ );\n+ }\n+\n+ // Push comments if we're in the root statement\n+ if (smntContext.up == &root) {\n+ pushComments();\n+ }\n+ }\n+\n+ void parser_t::pushComments() {\n+ const int commentsCount = (int) comments.size();\n+ for (int i = 0; i < commentsCount; ++i) {\n+ statement_t *smnt = comments[i];\n+ smnt->up = smntContext.up;\n+ smntContext.up->children.push_back(smnt);\n+ }\n+ comments.clear();\n+ }\n+\nvoid parser_t::loadAttributes(attributeTokenMap &attrs) {\nsuccess &= lang::loadAttributes(tokenContext,\nsmntContext,\n@@ -455,9 +499,20 @@ namespace occa {\n}\nint parser_t::peek() {\n+ const int tokenContextStart = tokenContext.position();\n+\n+ // Peek skips tokens when loading attributes\nint sType;\nsuccess &= smntPeeker.peek(attributes,\nsType);\n+\n+ const int tokenContextEnd = tokenContext.position();\n+\n+ // Load comments between skipped tokens\n+ if (tokenContextStart != tokenContextEnd) {\n+ loadComments(tokenContextStart, tokenContextEnd);\n+ }\n+\nreturn sType;\n}\n//==================================\n@@ -609,19 +664,29 @@ namespace occa {\nstatements.push_back(smnt);\nsmnt = getNextStatement();\n}\n+\n+ // Load comments at the end of the block\n+ loadComments();\n+ pushComments();\n}\n- statement_t* parser_t::getNextStatement() {\n+ statement_t* parser_t::loadNextStatement() {\nif (isEmpty()) {\ncheckSemicolon = true;\nreturn NULL;\n}\n+ loadComments();\n+\nconst int sType = peek();\nif (!success) {\nreturn NULL;\n}\n+ if (sType & statementType::blockStatements) {\n+ pushComments();\n+ }\n+\nstatementLoaderMap::iterator it = statementLoaders.find(sType);\nif (it != statementLoaders.end()) {\n// Copy attributes before continuing to avoid passing them to\n@@ -655,37 +720,27 @@ namespace occa {\nreturn NULL;\n}\n- statement_t* parser_t::getNextNonCommentStatement() {\n- statement_t *smnt = getNextStatement();\n- if (!smnt || smnt->type() != statementType::comment) {\n+ statement_t* parser_t::getNextStatement() {\n+ statement_t *smnt = loadNextStatement();\n+ if (!smnt || !comments.size()) {\nreturn smnt;\n}\n// We need to create a block statement to hold these statements\nblockStatement *blockSmnt = new blockStatement(smnt->up,\nsmnt->source);\n- statementPtrVector &statements = blockSmnt->children;\n+ statementPtrVector &childStatements = blockSmnt->children;\n- smntContext.pushUp(*blockSmnt);\n+ // Set the new block statement to load up comments\n+ childStatements.swap(comments);\n+ childStatements.push_back(smnt);\n+ const int childStatementCount = (int) childStatements.size();\n+ for (int i = 0; i < childStatementCount; ++i) {\n// Update new parent statement\n- smnt->up = blockSmnt;\n-\n- while (smnt) {\n- statements.push_back(smnt);\n- smnt = getNextStatement();\n- if (!smnt || smnt->type() != statementType::comment) {\n- break;\n- }\n+ childStatements[i]->up = blockSmnt;\n}\n- // Add the last non-comment statement\n- if (smnt) {\n- statements.push_back(smnt);\n- }\n-\n- smntContext.popUp();\n-\nreturn blockSmnt;\n}\n@@ -931,7 +986,7 @@ namespace occa {\naddAttributesTo(smntAttributes, &funcSmnt);\nsmntContext.pushUp(funcSmnt);\n- statement_t *content = getNextNonCommentStatement();\n+ statement_t *content = getNextStatement();\nsmntContext.popUp();\nif (success) {\nfuncSmnt.set(*content);\n@@ -1012,7 +1067,7 @@ namespace occa {\n}\ncheckSemicolon = (count < expectedCount);\n- statement_t *smnt = getNextNonCommentStatement();\n+ statement_t *smnt = getNextStatement();\nstatements.push_back(smnt);\nif (!success) {\nerror = true;\n@@ -1090,7 +1145,7 @@ namespace occa {\nifSmnt.setCondition(condition);\n- statement_t *content = getNextNonCommentStatement();\n+ statement_t *content = getNextStatement();\nif (!content) {\nif (success) {\ntokenContext.printError(\"Missing content for [if] statement\");\n@@ -1106,7 +1161,7 @@ namespace occa {\nwhile ((sType = peek()) & (statementType::elif_ |\nstatementType::else_)) {\nsmntContext.pushUp(ifSmnt);\n- statement_t *elSmnt = getNextNonCommentStatement();\n+ statement_t *elSmnt = getNextStatement();\nsmntContext.popUp();\nif (!elSmnt) {\nif (success) {\n@@ -1163,7 +1218,7 @@ namespace occa {\nelifSmnt.setCondition(condition);\n- statement_t *content = getNextNonCommentStatement();\n+ statement_t *content = getNextStatement();\nsmntContext.popUp();\nif (!content) {\ntokenContext.printError(\"Missing content for [else if] statement\");\n@@ -1185,7 +1240,7 @@ namespace occa {\nsmntContext.pushUp(elseSmnt);\naddAttributesTo(smntAttributes, &elseSmnt);\n- statement_t *content = getNextNonCommentStatement();\n+ statement_t *content = getNextStatement();\nsmntContext.popUp();\nif (!content) {\ntokenContext.printError(\"Missing content for [else] statement\");\n@@ -1259,7 +1314,7 @@ namespace occa {\n// If the last statement had attributes, we need to pass them now\naddAttributesTo(attributes, &forSmnt);\n- statement_t *content = getNextNonCommentStatement();\n+ statement_t *content = getNextStatement();\nsmntContext.popUp();\nif (!content) {\nif (success) {\n@@ -1303,7 +1358,7 @@ namespace occa {\nwhileSmnt.setCondition(condition);\n- statement_t *content = getNextNonCommentStatement();\n+ statement_t *content = getNextStatement();\nsmntContext.popUp();\nif (!content) {\ntokenContext.printError(\"Missing content for [while] statement\");\n@@ -1326,7 +1381,7 @@ namespace occa {\nsmntContext.pushUp(whileSmnt);\naddAttributesTo(smntAttributes, &whileSmnt);\n- statement_t *content = getNextNonCommentStatement();\n+ statement_t *content = getNextStatement();\nif (!content) {\nif (success) {\ntokenContext.printError(\"Missing content for [do-while] statement\");\n@@ -1403,7 +1458,7 @@ namespace occa {\nswitchSmnt.setCondition(condition);\n- statement_t *content = getNextNonCommentStatement();\n+ statement_t *content = getNextStatement();\nsmntContext.popUp();\nif (!content) {\nparenEnd->printError(\"Missing content for [switch] statement\");\n@@ -1418,7 +1473,7 @@ namespace occa {\n} else {\nswitchSmnt.add(*content);\n- content = getNextNonCommentStatement();\n+ content = getNextStatement();\nif (!content) {\nparenEnd->printError(\"Missing statement for switch's [case]\");\nsuccess = false;\n@@ -1565,15 +1620,6 @@ namespace occa {\nreturn smnt;\n}\n- statement_t* parser_t::loadCommentStatement(attributeTokenMap &smntAttributes) {\n- commentStatement *smnt = new commentStatement(smntContext.up,\n- *((commentToken*) tokenContext[0]));\n-\n- ++tokenContext;\n-\n- return smnt;\n- }\n-\nstatement_t* parser_t::loadDirectiveStatement(attributeTokenMap &smntAttributes) {\ndirectiveStatement *smnt = new directiveStatement(smntContext.up,\n*((directiveToken*) tokenContext[0]));\n" }, { "change_type": "MODIFY", "old_path": "src/lang/statementPeeker.cpp", "new_path": "src/lang/statementPeeker.cpp", "diff": "@@ -68,9 +68,7 @@ namespace occa {\nint tokenIndex = 0;\n- while (success &&\n- (tokenIndex < tokens)) {\n-\n+ while (success && (tokenIndex < tokens)) {\ntoken_t *token = tokenContext[tokenIndex];\nconst int tokenType = token->type();\n@@ -88,10 +86,6 @@ namespace occa {\nreturn statementType::expression;\n}\n- if (tokenType & tokenType::comment) {\n- return statementType::comment;\n- }\n-\nif (tokenType & tokenType::directive) {\nreturn statementType::directive;\n}\n" }, { "change_type": "MODIFY", "old_path": "src/lang/tokenContext.cpp", "new_path": "src/lang/tokenContext.cpp", "diff": "namespace occa {\nnamespace lang {\n+ static const int skippableTokenTypes = (\n+ tokenType::comment\n+ | tokenType::unknown\n+ | tokenType::none\n+ );\n+\ntokenRange::tokenRange() :\nstart(0),\nend(0) {}\n@@ -33,26 +39,45 @@ namespace occa {\nfor (int i = 0; i < tokenCount; ++i) {\ndelete tokens[i];\n}\n+\ntokens.clear();\n+ tokenIndices.clear();\n+\npairs.clear();\nsemicolons.clear();\nstack.clear();\n}\n- void tokenContext_t::setup() {\n+ // Called once all tokens are set from the parser\n+ void tokenContext_t::setup(const tokenVector &tokens_) {\n+ clear();\n+\n+ tokens = tokens_;\n+ setupTokenIndices();\n+\ntp.start = 0;\n- tp.end = (int) tokens.size();\n+ tp.end = (int) tokenIndices.size();\nfindPairs();\nfindSemicolons();\n}\n+ void tokenContext_t::setupTokenIndices() {\n+ const int tokenCount = (int) tokens.size();\n+ for (int i = 0; i < tokenCount; ++i) {\n+ token_t *token = tokens[i];\n+ if (!(token->type() & skippableTokenTypes)) {\n+ tokenIndices.push_back(i);\n+ }\n+ }\n+ }\n+\nvoid tokenContext_t::findPairs() {\nintVector pairStack;\n- const int tokenCount = (int) tokens.size();\n+ const int tokenCount = size();\nfor (int i = 0; i < tokenCount; ++i) {\n- token_t *token = tokens[i];\n+ token_t *token = getToken(i);\nopType_t opType = token->getOpType();\nif (!(opType & operatorType::pair)) {\ncontinue;\n@@ -81,8 +106,9 @@ namespace occa {\n// Make sure we close the pair\nconst int pairIndex = pairStack.back();\npairStack.pop_back();\n- pairOperator_t &pairStartOp =\n- *((pairOperator_t*) tokens[pairIndex]->to<operatorToken>().op);\n+ pairOperator_t &pairStartOp = (\n+ *((pairOperator_t*) getToken(pairIndex)->to<operatorToken>().op)\n+ );\nif (pairStartOp.opType != (pairEndOp.opType >> 1)) {\nif (!supressErrors) {\n@@ -90,7 +116,7 @@ namespace occa {\nss << \"Could not find a closing '\"\n<< pairStartOp.pairStr\n<< '\\'';\n- tokens[pairIndex]->printError(ss.str());\n+ getToken(pairIndex)->printError(ss.str());\nhasError = true;\n}\nreturn;\n@@ -103,24 +129,25 @@ namespace occa {\nif (pairStack.size()) {\nconst int pairIndex = pairStack.back();\npairStack.pop_back();\n- pairOperator_t &pairStartOp =\n- *((pairOperator_t*) tokens[pairIndex]->to<operatorToken>().op);\n+ pairOperator_t &pairStartOp = (\n+ *((pairOperator_t*) getToken(pairIndex)->to<operatorToken>().op)\n+ );\nif (!supressErrors) {\nstd::stringstream ss;\nss << \"Could not find a closing '\"\n<< pairStartOp.pairStr\n<< '\\'';\n- tokens[pairIndex]->printError(ss.str());\n+ getToken(pairIndex)->printError(ss.str());\nhasError = true;\n}\n}\n}\nvoid tokenContext_t::findSemicolons() {\n- const int tokenCount = (int) tokens.size();\n+ const int tokenCount = size();\nfor (int i = 0; i < tokenCount; ++i) {\n- token_t *token = tokens[i];\n+ token_t *token = getToken(i);\nopType_t opType = token->getOpType();\nif (opType & operatorType::semicolon) {\nsemicolons.push_back(i);\n@@ -210,11 +237,53 @@ namespace occa {\nreturn (tp.end - tp.start);\n}\n+ void tokenContext_t::getSkippedTokens(tokenVector &skippedTokens,\n+ const int start,\n+ const int end) {\n+ if (start >= tokenIndices.size()) {\n+ return;\n+ }\n+\n+ const int startNativeIndex = (\n+ start\n+ ? tokenIndices[start - 1]\n+ : 0\n+ );\n+ const int endNativeIndex = (\n+ end < (int) tokenIndices.size()\n+ ? tokenIndices[end]\n+ : tp.end\n+ );\n+\n+ for (int i = startNativeIndex; i < endNativeIndex; ++i) {\n+ token_t *token = tokens[i];\n+ if (token->type() & skippableTokenTypes) {\n+ skippedTokens.push_back(token);\n+ }\n+ }\n+ }\n+\n+ token_t* tokenContext_t::getToken(const int index) {\n+ return tokens[tokenIndices[index]];\n+ }\n+\n+ void tokenContext_t::setToken(const int index,\n+ token_t *value) {\n+ if (!indexInRange(index)) {\n+ return;\n+ }\n+ const int pos = tokenIndices[tp.start + index];\n+ if (tokens[pos] != value) {\n+ delete tokens[pos];\n+ tokens[pos] = value;\n+ }\n+ }\n+\ntoken_t* tokenContext_t::operator [] (const int index) {\nif (!indexInRange(index)) {\nreturn NULL;\n}\n- return tokens[tp.start + index];\n+ return getToken(tp.start + index);\n}\ntokenContext_t& tokenContext_t::operator ++ () {\n@@ -232,42 +301,34 @@ namespace occa {\nreturn *this;\n}\n- void tokenContext_t::setToken(const int index,\n- token_t *value) {\n- if (!indexInRange(index)) {\n- return;\n- }\n- const int pos = tp.start + index;\n- if (tokens[pos] != value) {\n- delete tokens[pos];\n- tokens[pos] = value;\n- }\n- }\n-\ntoken_t* tokenContext_t::end() {\nif (indexInRange(tp.end - tp.start - 1)) {\n- return tokens[tp.end - 1];\n+ return getToken(tp.end - 1);\n}\nreturn NULL;\n}\ntoken_t* tokenContext_t::getPrintToken(const bool atEnd) {\n- if (tokens.size() == 0) {\n+ if (size() == 0) {\nreturn NULL;\n}\n+\nconst int start = tp.start;\nif (atEnd) {\ntp.start = tp.end;\n}\n+\nint offset = 0;\n- if (!indexInRange(offset) &&\n- (0 < tp.start)) {\n+ if (!indexInRange(offset) && (0 < tp.start)) {\noffset = -1;\n}\n- token_t *token = tokens[tp.start + offset];\n+\n+ token_t *token = getToken(tp.start + offset);\nif (atEnd) {\n+ // Reset tp.start\ntp.start = start;\n}\n+\nreturn token;\n}\n@@ -317,7 +378,7 @@ namespace occa {\ntokens_.clear();\ntokens_.reserve(tp.end - tp.start);\nfor (int i = tp.start; i < tp.end; ++i) {\n- tokens_.push_back(tokens[i]);\n+ tokens_.push_back(getToken(i));\n}\n}\n@@ -325,7 +386,7 @@ namespace occa {\ntokens_.clear();\ntokens_.reserve(tp.end - tp.start);\nfor (int i = tp.start; i < tp.end; ++i) {\n- tokens_.push_back(tokens[i]->clone());\n+ tokens_.push_back(getToken(i)->clone());\n}\n}\n@@ -344,14 +405,14 @@ namespace occa {\ntoken_t* tokenContext_t::getClosingPairToken() {\nconst int endIndex = getClosingPair();\nif (endIndex >= 0) {\n- return tokens[tp.start + endIndex];\n+ return getToken(tp.start + endIndex);\n}\nreturn NULL;\n}\nint tokenContext_t::getNextOperator(const opType_t &opType) {\nfor (int pos = tp.start; pos < tp.end; ++pos) {\n- token_t *token = tokens[pos];\n+ token_t *token = getToken(pos);\nif (!(token->type() & tokenType::op)) {\ncontinue;\n}\n@@ -457,8 +518,17 @@ namespace occa {\n}\nvoid tokenContext_t::debugPrint() {\n- for (int i = tp.start; i < tp.end; ++i) {\n- io::stdout << '[' << *tokens[i] << \"]\\n\";\n+ const int start = tokenIndices[tp.start];\n+ const int end = tokenIndices[tp.end - 1];\n+\n+ for (int i = start; i < end; ++i) {\n+ token_t &token = *(tokens[i]);\n+\n+ if (token.type() & skippableTokenTypes) {\n+ io::stdout << '[' << token << \"] (SKIPPED)\\n\";\n+ } else {\n+ io::stdout << '[' << token << \"]\\n\";\n+ }\n}\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "tests/files/addVectors.okl", "new_path": "tests/files/addVectors.okl", "diff": "// Comment 6.1\n// Comment 6.2\nA[i][j] = a[i] + b[j];\n+\n+ for (int i = 0; i < 3; i++)\n+ for (int j = 0; j < 3; j++)\n+ // Comment 7.1\n+ A[i][j] = a[i] + b[j];\n+ // Comment 7.2\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "tests/src/io/lock.cpp", "new_path": "tests/src/io/lock.cpp", "diff": "@@ -15,8 +15,8 @@ int main(const int argc, const char **argv) {\n#ifndef USE_CMAKE\nocca::env::OCCA_CACHE_DIR = occa::io::dirname(__FILE__);\n#endif\n- occa::settings()[\"locks/stale-warning\"] = 0;\n- occa::settings()[\"locks/stale-age\"] = 0.2;\n+ occa::settings()[\"locks/stale_warning\"] = 0;\n+ occa::settings()[\"locks/stale_age\"] = 0.2;\nsrand(time(NULL));\n" }, { "change_type": "MODIFY", "old_path": "tests/src/lang/tokenContext.cpp", "new_path": "tests/src/lang/tokenContext.cpp", "diff": "@@ -17,9 +17,9 @@ std::string source;\nvoid setupContext(tokenContext_t &tokenContext,\nconst std::string &source_) {\nsource = source_;\n- tokenContext.clear();\n- tokenContext.tokens = tokenizer_t::tokenize(source);\n- tokenContext.setup();\n+ tokenContext.setup(\n+ tokenizer_t::tokenize(source)\n+ );\n}\nint main(const int argc, const char **argv) {\n@@ -40,14 +40,15 @@ void testMethods() {\nprimitiveToken *primitive = new primitiveToken(originSource::string,\n1, \"1\");\n- tokenContext.tokens.push_back(newline);\n- tokenContext.tokens.push_back(identifier);\n- tokenContext.tokens.push_back(primitive);\n+ tokenVector tokens;\n+ tokens.push_back(newline);\n+ tokens.push_back(identifier);\n+ tokens.push_back(primitive);\nASSERT_EQ(0, tokenContext.tp.start);\nASSERT_EQ(0, tokenContext.tp.end);\n- tokenContext.setup();\n+ tokenContext.setup(tokens);\nASSERT_EQ(0, tokenContext.tp.start);\nASSERT_EQ(3, tokenContext.tp.end);\n" } ]
C++
MIT License
libocca/occa
[Parser] tokenContext auto-removes certain tokens (#358)
378,349
06.06.2020 11:53:27
14,400
93c97b9d66bf85250fa7a622fe3e11b2aaaef1c8
[README] Adds Slack badge
[ { "change_type": "MODIFY", "old_path": "README.md", "new_path": "README.md", "diff": "<p align=\"center\">\n<a href=\"https://github.com/libocca/occa/workflows/Build/badge.svg\"><img alt=\"Build\" src=\"https://github.com/libocca/occa/workflows/Build/badge.svg\"></a>\n<a href=\"https://codecov.io/github/libocca/occa\"><img alt=\"codecov.io\" src=\"https://codecov.io/github/libocca/occa/coverage.svg\"></a>\n- <a href=\"https://gitter.im/libocca/occa?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge\"><img alt=\"Gitter\" src=\"https://badges.gitter.im/libocca/occa.svg\"></a>\n+ <a href=\"https://join.slack.com/t/libocca/shared_invite/zt-4jcnu451-qPpPWUzhm7YQKY_HMhIsIw\"><img alt=\"Slack\" src=\"https://img.shields.io/badge/Chat-on%20Slack-%23522653?logo=slack\"></a>\n</p>\n&nbsp;\n" } ]
C++
MIT License
libocca/occa
[README] Adds Slack badge
378,349
06.06.2020 15:37:20
14,400
8f69e844b52a67778a42ab1b4ef893040be4a1bd
[Lang] Adds stream cache clearning to fix
[ { "change_type": "MODIFY", "old_path": "include/occa/lang/preprocessor.hpp", "new_path": "include/occa/lang/preprocessor.hpp", "diff": "@@ -37,8 +37,7 @@ namespace occa {\nextern const int finishedIf;\n}\n- class preprocessor_t : public withInputCache<token_t*, token_t*>,\n- public withOutputCache<token_t*, token_t*> {\n+ class preprocessor_t : public withCache<token_t*, token_t*> {\npublic:\ntypedef void (preprocessor_t::*processDirective_t)(identifierToken &directive);\ntypedef std::map<std::string, processDirective_t> directiveMap;\n@@ -71,7 +70,6 @@ namespace occa {\n//---[ Misc ]---------------------\ntokenizer_t *tokenizer;\n- bool hasLoadedTokenizer;\nstrVector includePaths;\n//================================\n" }, { "change_type": "MODIFY", "old_path": "include/occa/lang/processingStages.hpp", "new_path": "include/occa/lang/processingStages.hpp", "diff": "@@ -11,6 +11,7 @@ namespace occa {\ntypedef streamMap<token_t*, token_t*> tokenMap;\ntypedef withInputCache<token_t*, token_t*> tokenInputCacheMap;\ntypedef withOutputCache<token_t*, token_t*> tokenOutputCacheMap;\n+ typedef withCache<token_t*, token_t*> tokenCacheMap;\nclass newlineTokenFilter : public tokenFilter {\npublic:\n@@ -29,8 +30,7 @@ namespace occa {\nvirtual void fetchNext();\n};\n- class externTokenMerger : public tokenInputCacheMap,\n- public tokenOutputCacheMap {\n+ class externTokenMerger : public tokenCacheMap {\npublic:\nexternTokenMerger();\nexternTokenMerger(const externTokenMerger &other);\n" }, { "change_type": "MODIFY", "old_path": "include/occa/lang/stream.hpp", "new_path": "include/occa/lang/stream.hpp", "diff": "@@ -28,6 +28,7 @@ namespace occa {\nvirtual void setNext(output_t &out) = 0;\n+ virtual void clearCache();\nvirtual void* passMessageToInput(const occa::properties &props);\nvoid* getInput(const std::string &name);\n@@ -62,6 +63,7 @@ namespace occa {\nstream& clone() const;\n+ void clearCache();\nvoid* passMessageToInput(const occa::properties &props);\nvoid* getInput(const std::string &name);\n@@ -93,6 +95,7 @@ namespace occa {\nvirtual streamMap& clone() const;\nvirtual streamMap& clone_() const = 0;\n+ virtual void clearCache();\nvirtual void* passMessageToInput(const occa::properties &props);\n};\n@@ -125,6 +128,8 @@ namespace occa {\nvirtual void setNext(input_t &out);\nvirtual bool isValid(const input_t &value) = 0;\n+\n+ virtual void clearCache();\n};\ntemplate <class input_t>\n@@ -155,6 +160,8 @@ namespace occa {\nvoid pushInput(const input_t &value);\nvoid getNextInput(input_t &value);\n+\n+ virtual void clearCache();\n};\ntemplate <class input_t, class output_t>\n@@ -172,6 +179,18 @@ namespace occa {\nvoid pushOutput(const output_t &value);\nvirtual void fetchNext() = 0;\n+\n+ virtual void clearCache();\n+ };\n+\n+ template <class input_t, class output_t>\n+ class withCache : public withInputCache<input_t, input_t>,\n+ public withOutputCache<output_t, output_t> {\n+ public:\n+ withCache();\n+ withCache(const withCache<input_t, output_t> &other);\n+\n+ virtual void clearCache();\n};\n//====================================\n}\n" }, { "change_type": "MODIFY", "old_path": "include/occa/lang/stream.tpp", "new_path": "include/occa/lang/stream.tpp", "diff": "@@ -4,6 +4,9 @@ namespace occa {\ntemplate <class output_t>\nbaseStream<output_t>::~baseStream() {}\n+ template <class output_t>\n+ void baseStream<output_t>::clearCache() {}\n+\ntemplate <class output_t>\nvoid* baseStream<output_t>::passMessageToInput(const occa::properties &props) {\nreturn NULL;\n@@ -64,6 +67,11 @@ namespace occa {\nreturn *(new stream(&(head->clone())));\n}\n+ template <class output_t>\n+ void stream<output_t>::clearCache() {\n+ head->clearCache();\n+ }\n+\ntemplate <class output_t>\nvoid* stream<output_t>::passMessageToInput(const occa::properties &props) {\nreturn head->passMessageToInput(props);\n@@ -137,6 +145,13 @@ namespace occa {\nreturn smap;\n}\n+ template <class input_t, class output_t>\n+ void streamMap<input_t, output_t>::clearCache() {\n+ if (input) {\n+ input->clearCache();\n+ }\n+ }\n+\ntemplate <class input_t, class output_t>\nvoid* streamMap<input_t, output_t>::passMessageToInput(const occa::properties &props) {\nif (input) {\n@@ -198,6 +213,13 @@ namespace occa {\n}\n}\n+ template <class input_t>\n+ void streamFilter<input_t>::clearCache() {\n+ streamMap<input_t, input_t>::clearCache();\n+ usedLastValue = true;\n+ isEmpty_ = true;\n+ }\n+\ntemplate <class input_t>\nstreamFilterFunc<input_t>::streamFilterFunc(bool (*func_)(const input_t &value)) :\nfunc(func_) {}\n@@ -248,6 +270,12 @@ namespace occa {\n}\n}\n+ template <class input_t, class output_t>\n+ void withInputCache<input_t, output_t>::clearCache() {\n+ streamMap<input_t, output_t>::clearCache();\n+ inputCache.clear();\n+ }\n+\ntemplate <class input_t, class output_t>\nwithOutputCache<input_t, output_t>::withOutputCache() :\noutputCache() {}\n@@ -279,6 +307,28 @@ namespace occa {\nvoid withOutputCache<input_t, output_t>::pushOutput(const output_t &value) {\noutputCache.push_back(value);\n}\n+\n+ template <class input_t, class output_t>\n+ void withOutputCache<input_t, output_t>::clearCache() {\n+ streamMap<input_t, output_t>::clearCache();\n+ outputCache.clear();\n+ }\n+\n+ template <class input_t, class output_t>\n+ withCache<input_t, output_t>::withCache() {}\n+\n+ template <class input_t, class output_t>\n+ withCache<input_t, output_t>::withCache(\n+ const withCache<input_t, output_t> &other\n+ ) :\n+ withInputCache<input_t, input_t>(other),\n+ withOutputCache<output_t, output_t>(other) {}\n+\n+ template <class input_t, class output_t>\n+ void withCache<input_t, output_t>::clearCache() {\n+ withInputCache<input_t, input_t>::clearCache();\n+ withOutputCache<output_t, output_t>::clearCache();\n+ }\n//====================================\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/lang/parser.cpp", "new_path": "src/lang/parser.cpp", "diff": "@@ -223,6 +223,7 @@ namespace occa {\nvoid parser_t::setSource(const std::string &source,\nconst bool isFile) {\nclear();\n+ stream.clearCache();\nif (isFile) {\ntokenizer.set(new file_t(source));\n" }, { "change_type": "MODIFY", "old_path": "src/lang/preprocessor.cpp", "new_path": "src/lang/preprocessor.cpp", "diff": "@@ -52,8 +52,7 @@ namespace occa {\n}\npreprocessor_t::preprocessor_t(const preprocessor_t &pp) :\n- withInputCache(pp),\n- withOutputCache(pp) {\n+ withCache(pp) {\n*this = pp;\n}\n@@ -117,7 +116,6 @@ namespace occa {\nerrors = 0;\ntokenizer = NULL;\n- hasLoadedTokenizer = false;\n}\nvoid preprocessor_t::clear() {\n@@ -130,7 +128,6 @@ namespace occa {\nwarnings = 0;\ntokenizer = NULL;\n- hasLoadedTokenizer = false;\nwhile (inputCache.size()) {\ndelete inputCache.front();\n@@ -486,9 +483,8 @@ namespace occa {\n//==================================\nvoid preprocessor_t::loadTokenizer() {\n- if (!hasLoadedTokenizer) {\n+ if (!tokenizer) {\ntokenizer = (tokenizer_t*) getInput(\"tokenizer_t\");\n- hasLoadedTokenizer = true;\n}\n}\n@@ -1371,6 +1367,7 @@ namespace occa {\n}\n// Push source after updating origin to the [\\n] token\n+ input->clearCache();\ntokenizer->pushSource(header);\n}\n" }, { "change_type": "MODIFY", "old_path": "src/lang/processingStages.cpp", "new_path": "src/lang/processingStages.cpp", "diff": "@@ -83,8 +83,7 @@ namespace occa {\nexternTokenMerger::externTokenMerger() {}\nexternTokenMerger::externTokenMerger(const externTokenMerger &other) :\n- tokenInputCacheMap(other),\n- tokenOutputCacheMap(other) {}\n+ tokenCacheMap(other) {}\ntokenMap& externTokenMerger::clone_() const {\nreturn *(new externTokenMerger(*this));\n" } ]
C++
MIT License
libocca/occa
[Lang] Adds stream cache clearning to fix #311 (#362)
378,349
06.06.2020 22:47:18
14,400
18b787e49d9a03d94fdc7b27879ffc40784b34da
[Parser] Fixes comments on blocks
[ { "change_type": "MODIFY", "old_path": "include/occa/lang/parser.hpp", "new_path": "include/occa/lang/parser.hpp", "diff": "@@ -51,6 +51,7 @@ namespace occa {\nstatementContext_t smntContext;\nstatementPeeker_t smntPeeker;\n+ int loadingStatementType;\nbool checkSemicolon;\nunknownToken defaultRootToken;\n" }, { "change_type": "MODIFY", "old_path": "src/lang/parser.cpp", "new_path": "src/lang/parser.cpp", "diff": "@@ -19,6 +19,7 @@ namespace occa {\nsmntContext,\n*this,\nattributeMap),\n+ loadingStatementType(0),\ncheckSemicolon(true),\ndefaultRootToken(originSource::builtin),\nsuccess(true),\n@@ -165,6 +166,7 @@ namespace occa {\npreprocessor.clear();\naddSettingDefines();\n+ loadingStatementType = 0;\ncheckSemicolon = true;\ncomments.clear();\n@@ -680,6 +682,8 @@ namespace occa {\nattributeTokenMap smntAttributes = attributes;\nattributes.clear();\n+ loadingStatementType = sType;\n+\nstatementLoader_t loader = it->second;\nstatement_t *smnt = (this->*loader)(smntAttributes);\nif (!smnt) {\n@@ -708,10 +712,18 @@ namespace occa {\nstatement_t* parser_t::getNextStatement() {\nstatement_t *smnt = loadNextStatement();\n+\n+ // It's the end or we don't have comments\nif (!smnt || !comments.size()) {\nreturn smnt;\n}\n+ // We're about to load a block statement type, add the comments to it\n+ if (!(loadingStatementType & statementType::blockStatements)) {\n+ pushComments();\n+ return smnt;\n+ }\n+\n// We need to create a block statement to hold these statements\nblockStatement *blockSmnt = new blockStatement(smnt->up,\nsmnt->source);\n" }, { "change_type": "MODIFY", "old_path": "tests/files/addVectors.okl", "new_path": "tests/files/addVectors.okl", "diff": "const float *b,\n// Comment 4.3\nfloat *ab) {\n+ // Comment 5.0\nfor (int i = 0; i < /*Comment 5.1*/ entries; ++i; /*Comment 5.2*/ @tile(16, @outer, @inner)) {\ndouble A[3][3] = {\n{0.0, 1.0, 2.0},\n" } ]
C++
MIT License
libocca/occa
[Parser] Fixes comments on blocks (#364)
378,349
06.06.2020 23:36:40
14,400
2b3759bd212240999ed2a85d57a869a2c595533c
[Tokenizer] Don't prematurely load primitives
[ { "change_type": "MODIFY", "old_path": "src/lang/tokenizer.cpp", "new_path": "src/lang/tokenizer.cpp", "diff": "@@ -392,12 +392,19 @@ namespace occa {\nif (c == '\\0') {\nreturn tokenType::none;\n}\n- // Primitive must be checked before identifiers\n- // and operators since:\n+\n+ const char *pos = fp.start;\n+ const bool isPrimitive = (\n+ primitive::load(pos, false).type != occa::primitiveType::none\n+ );\n+\n+ // Primitive must be checked before identifiers and operators since:\n// - true/false\n// - Operators can start with a . (for example, .01)\n- const char *pos = fp.start;\n- if (primitive::load(pos, false).type != occa::primitiveType::none) {\n+ // However, make sure we aren't parsing an identifier:\n+ // - true_var\n+ // - false_case\n+ if (isPrimitive && !lex::inCharset(*pos, charcodes::identifierStart)) {\nreturn tokenType::primitive;\n}\nif (lex::inCharset(c, charcodes::identifierStart)) {\n@@ -420,9 +427,13 @@ namespace occa {\nint tokenizer_t::peekForIdentifier() {\npush();\n+\n+ // Go through the identifier keys\n++fp.start;\nskipFrom(charcodes::identifier);\n+\nconst std::string identifier = str();\n+\nint type = shallowPeek();\npopAndRewind();\n" }, { "change_type": "MODIFY", "old_path": "tests/src/lang/tokenizer/token.cpp", "new_path": "tests/src/lang/tokenizer/token.cpp", "diff": "@@ -29,6 +29,11 @@ void testPeekMethods() {\ntokenType::identifier,\ntokenizer.peek()\n);\n+ setStream(\"true_case\");\n+ ASSERT_EQ_BINARY(\n+ tokenType::identifier,\n+ tokenizer.peek()\n+ );\nsetStream(\"1\");\nASSERT_EQ_BINARY(\n@@ -125,6 +130,11 @@ void testTokenMethods() {\ntokenType::identifier,\ngetTokenType()\n);\n+ setToken(\"true_case\");\n+ ASSERT_EQ_BINARY(\n+ tokenType::identifier,\n+ getTokenType()\n+ );\nsetToken(\"true\");\nASSERT_EQ_BINARY(\n" } ]
C++
MIT License
libocca/occa
[Tokenizer] Don't prematurely load primitives (#365)
378,349
07.06.2020 17:10:20
14,400
d4fdc10938bc323f03a0f7acca6ed41ca4c98a29
[Parser] Properly stores struct definitions
[ { "change_type": "MODIFY", "old_path": "include/occa/lang/file.hpp", "new_path": "include/occa/lang/file.hpp", "diff": "@@ -99,6 +99,8 @@ namespace occa {\ndim_t distanceTo(const fileOrigin &origin);\n+ bool operator == (const fileOrigin &origin);\n+\nvoid preprint(io::output &out) const;\nvoid postprint(io::output &out) const;\n" }, { "change_type": "MODIFY", "old_path": "src/lang/file.cpp", "new_path": "src/lang/file.cpp", "diff": "@@ -254,6 +254,16 @@ namespace occa {\nreturn (origin.position.start - position.end);\n}\n+ bool fileOrigin::operator == (const fileOrigin &origin) {\n+ if (file != origin.file) {\n+ return false;\n+ }\n+ return (\n+ position.start == origin.position.start\n+ && position.end == origin.position.end\n+ );\n+ }\n+\nvoid fileOrigin::preprint(io::output &out) const {\nprint(out, true);\n}\n" }, { "change_type": "MODIFY", "old_path": "src/lang/statement/declarationStatement.cpp", "new_path": "src/lang/statement/declarationStatement.cpp", "diff": "@@ -121,7 +121,7 @@ namespace occa {\nif (!success) {\ndelete type;\n}\n- } else if (var.vartype.has(struct_)) {\n+ } else if (var.vartype.definesStruct()) {\n// Struct\ndeclaredType = true;\n" }, { "change_type": "MODIFY", "old_path": "src/lang/statement/functionDeclStatement.cpp", "new_path": "src/lang/statement/functionDeclStatement.cpp", "diff": "@@ -47,12 +47,16 @@ namespace occa {\n}\nvoid functionDeclStatement::print(printer &pout) const {\n+ // Double newlines to make it look cleaner\n+ pout.printNewlines(2);\n+\npout.printStartIndentation();\nfunction.printDeclaration(pout);\npout << ' ';\nblockStatement::print(pout);\n+\n// Double newlines to make it look cleaner\n- pout << '\\n';\n+ pout.printNewlines(2);\n}\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/lang/type/vartype.cpp", "new_path": "src/lang/type/vartype.cpp", "diff": "@@ -310,8 +310,14 @@ namespace occa {\nvartype_t vartype_t::declarationType() const {\nvartype_t other;\n- other.type = type;\n+\n+ if (typeToken && type) {\n+ other.setType(*typeToken, *type);\n+ } else if (type) {\n+ other.setType(*type);\n+ }\nother.qualifiers = qualifiers;\n+\nreturn other;\n}\n@@ -341,8 +347,8 @@ namespace occa {\n}\nbool vartype_t::definesStruct() const {\n- if (has(struct_)) {\n- return true;\n+ if (typeToken && type && (type->type() & typeType::struct_)) {\n+ return (typeToken->origin == type->source->origin);\n}\nif (!has(typedef_)) {\nreturn false;\n" } ]
C++
MIT License
libocca/occa
[Parser] Properly stores struct definitions (#366)
378,355
17.06.2020 22:00:19
18,000
7b9b2a97879c1f2a384c4fed234aece4d331e00d
[CMake] Place compiledDefines header in Cmake build directory, rather than source tree.
[ { "change_type": "MODIFY", "old_path": "CMakeLists.txt", "new_path": "CMakeLists.txt", "diff": "@@ -62,10 +62,11 @@ set_target_properties(libocca PROPERTIES OUTPUT_NAME occa LIBRARY_OUTPUT_DIRECTO\n#Find needed and requested packages\nfind_package(Threads REQUIRED)\n-target_link_libraries(libocca PRIVATE ${CMAKE_THREAD_LIBS_INIT})\n+target_link_libraries(libocca PRIVATE ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS})\ntarget_include_directories(libocca PUBLIC\n- $<BUILD_INTERFACE:${OCCA_SOURCE_DIR}/include>)\n+ $<BUILD_INTERFACE:${OCCA_SOURCE_DIR}/include>\n+ $<BUILD_INTERFACE:${OCCA_BUILD_DIR}/include>)\ntarget_compile_definitions(libocca PRIVATE -DUSE_CMAKE)\n@@ -221,7 +222,7 @@ if (ENABLE_MPI)\nendif(ENABLE_MPI)\n#Generate CompiledDefines from libraries we found\n-configure_file(scripts/compiledDefinesTemplate.hpp.in ${OCCA_SOURCE_DIR}/include/occa/defines/compiledDefines.hpp)\n+configure_file(scripts/compiledDefinesTemplate.hpp.in ${OCCA_BUILD_DIR}/include/occa/defines/compiledDefines.hpp)\n#Find source files\nfile(GLOB_RECURSE OCCA_SRC RELATIVE ${OCCA_SOURCE_DIR} \"src/*.cpp\")\n" }, { "change_type": "MODIFY", "old_path": "src/modes/cuda/device.cpp", "new_path": "src/modes/cuda/device.cpp", "diff": "@@ -283,6 +283,7 @@ namespace occa {\n<< \" -D OCCA_OS=OCCA_WINDOWS_OS -D _MSC_VER=1800\"\n#endif\n<< \" -I\" << env::OCCA_DIR << \"include\"\n+ << \" -I\" << env::OCCA_INSTALL_DIR << \"include\"\n<< \" -L\" << env::OCCA_INSTALL_DIR << \"lib -locca\"\n<< \" -x cu -c \" << sourceFilename\n<< \" -o \" << ptxBinaryFilename;\n@@ -311,6 +312,7 @@ namespace occa {\n<< \" -D OCCA_OS=OCCA_WINDOWS_OS -D _MSC_VER=1800\"\n#endif\n<< \" -I\" << env::OCCA_DIR << \"include\"\n+ << \" -I\" << env::OCCA_INSTALL_DIR << \"include\"\n<< \" -L\" << env::OCCA_INSTALL_DIR << \"lib -locca\"\n<< \" -x cu \" << sourceFilename\n<< \" -o \" << binaryFilename;\n" }, { "change_type": "MODIFY", "old_path": "src/modes/hip/device.cpp", "new_path": "src/modes/hip/device.cpp", "diff": "@@ -284,6 +284,7 @@ namespace occa {\n<< ' ' << hipccCompilerFlags\n#if defined(__HIP_PLATFORM_NVCC___) || defined(__HIP_ROCclr__)\n<< \" -I\" << env::OCCA_DIR << \"include\"\n+ << \" -I\" << env::OCCA_INSTALL_DIR << \"include\"\n#endif\n/* NC: hipcc doesn't seem to like linking a library in */\n//<< \" -L\" << env::OCCA_INSTALL_DIR << \"lib -locca\"\n" }, { "change_type": "MODIFY", "old_path": "src/modes/serial/device.cpp", "new_path": "src/modes/serial/device.cpp", "diff": "@@ -329,6 +329,7 @@ namespace occa {\n<< ' ' << sourceFilename\n<< \" -o \" << binaryFilename\n<< \" -I\" << env::OCCA_DIR << \"include\"\n+ << \" -I\" << env::OCCA_INSTALL_DIR << \"include\"\n<< \" -L\" << env::OCCA_INSTALL_DIR << \"lib -locca\"\n<< ' ' << compilerLinkerFlags\n<< std::endl;\n@@ -340,6 +341,7 @@ namespace occa {\n<< \" /wd4244 /wd4800 /wd4804 /wd4018\"\n<< ' ' << compilerFlags\n<< \" /I\" << env::OCCA_DIR << \"include\"\n+ << \" /I\" << env::OCCA_INSTALL_DIR << \"include\"\n<< ' ' << sourceFilename\n<< \" /link \" << env::OCCA_INSTALL_DIR << \"lib/libocca.lib\",\n<< ' ' << compilerLinkerFlags\n" } ]
C++
MIT License
libocca/occa
[CMake] Place compiledDefines header in Cmake build directory, rather than source tree. (#371)
378,349
12.07.2020 20:57:03
14,400
7074540c64d196e5c4899f4f89dffd66fe2411a9
[Core] Allows for case-insensitive mode names
[ { "change_type": "MODIFY", "old_path": ".github/workflows/build.yml", "new_path": ".github/workflows/build.yml", "diff": "@@ -2,9 +2,9 @@ name: Build\non:\npush:\n- branches: [ master ]\n+ branches: [ main ]\npull_request:\n- branches: [ master ]\n+ branches: [ main ]\njobs:\nrun:\n" }, { "change_type": "MODIFY", "old_path": "bin/occa.cpp", "new_path": "bin/occa.cpp", "diff": "@@ -136,7 +136,9 @@ bool runTranslate(const json &args) {\nconst json &options = args[\"options\"];\nconst json &arguments = args[\"arguments\"];\n- const std::string mode = options[\"mode\"];\n+ const std::string originalMode = options[\"mode\"];\n+ const std::string mode = lowercase(originalMode);\n+\nconst bool printLauncher = options[\"launcher\"];\nconst std::string filename = arguments[0];\n@@ -151,22 +153,22 @@ bool runTranslate(const json &args) {\nlang::parser_t *parser = NULL;\nlang::parser_t *launcherParser = NULL;\n- if (mode == \"\" || mode == \"Serial\") {\n+ if (mode == \"\" || mode == \"serial\") {\nparser = new lang::okl::serialParser(kernelProps);\n- } else if (mode == \"OpenMP\") {\n+ } else if (mode == \"openmp\") {\nparser = new lang::okl::openmpParser(kernelProps);\n- } else if (mode == \"CUDA\") {\n+ } else if (mode == \"cuda\") {\nparser = new lang::okl::cudaParser(kernelProps);\n- } else if (mode == \"HIP\") {\n+ } else if (mode == \"hip\") {\nparser = new lang::okl::hipParser(kernelProps);\n- } else if (mode == \"OpenCL\") {\n+ } else if (mode == \"opencl\") {\nparser = new lang::okl::openclParser(kernelProps);\n- } else if (mode == \"Metal\") {\n+ } else if (mode == \"metal\") {\nparser = new lang::okl::metalParser(kernelProps);\n}\nif (!parser) {\n- printError(\"Unable to translate for mode [\" + mode + \"]\");\n+ printError(\"Unable to translate for mode [\" + originalMode + \"]\");\n::exit(1);\n}\n@@ -197,10 +199,10 @@ bool runTranslate(const json &args) {\n<< \"*/\\n\";\n}\n- if (printLauncher && ((mode == \"CUDA\")\n- || (mode == \"HIP\")\n- || (mode == \"OpenCL\")\n- || (mode == \"Metal\"))) {\n+ if (printLauncher && ((mode == \"cuda\")\n+ || (mode == \"hip\")\n+ || (mode == \"opencl\")\n+ || (mode == \"metal\"))) {\nlauncherParser = &(((occa::lang::okl::withLauncher*) parser)->launcherParser);\nstd::cout << launcherParser->toString();\n} else {\n@@ -284,7 +286,7 @@ bool runModes(const json &args) {\nstrToModeMap &modeMap = getModeMap();\nstrToModeMap::iterator it = modeMap.begin();\nwhile (it != modeMap.end()) {\n- std::cout << it->first << '\\n';\n+ std::cout << it->second->name() << '\\n';\n++it;\n}\nreturn true;\n" }, { "change_type": "MODIFY", "old_path": "include/occa/modes.hpp", "new_path": "include/occa/modes.hpp", "diff": "@@ -43,7 +43,9 @@ namespace occa {\nbool modeIsEnabled(const std::string &mode);\n- mode_t* getMode(const occa::properties &props);\n+ mode_t* getMode(const std::string &mode);\n+\n+ mode_t* getModeFromProps(const occa::properties &props);\nmodeDevice_t* newModeDevice(const occa::properties &props);\n}\n" }, { "change_type": "MODIFY", "old_path": "src/core/base.cpp", "new_path": "src/core/base.cpp", "diff": "@@ -252,7 +252,7 @@ namespace occa {\nint index = 0;\nfor (; it != modeMap.end(); ++it) {\n- if (it->first == \"Serial\") {\n+ if (it->second->name() == \"Serial\") {\nserialIndex = index;\n}\ntable.add(it->second->getDescription());\n@@ -260,9 +260,11 @@ namespace occa {\n}\n// Set so Serial mode is first to show up\n+ if (serialIndex != 0) {\nstyling::section serialSection = table.sections[serialIndex];\ntable.sections[serialIndex] = table.sections[0];\ntable.sections[0] = serialSection;\n+ }\nio::stdout << table;\n}\n" }, { "change_type": "MODIFY", "old_path": "src/modes.cpp", "new_path": "src/modes.cpp", "diff": "#include <occa/core/device.hpp>\n#include <occa/io/output.hpp>\n#include <occa/modes.hpp>\n+#include <occa/tools/string.hpp>\nnamespace occa {\n//---[ mode_t ]-----------------------\n@@ -36,7 +37,8 @@ namespace occa {\n}\nvoid registerMode(mode_t* mode) {\n- getUnsafeModeMap()[mode->name()] = mode;\n+ const std::string caseInsensitiveMode = lowercase(mode->name());\n+ getUnsafeModeMap()[caseInsensitiveMode] = mode;\n}\nvoid initializeModes() {\n@@ -65,25 +67,38 @@ namespace occa {\n}\nbool modeIsEnabled(const std::string &mode) {\n+ return getMode(mode);\n+ }\n+\n+ mode_t* getMode(const std::string &mode) {\n+ const std::string caseInsensitiveMode = lowercase(mode);\nstrToModeMap &modeMap = getModeMap();\n- return (modeMap.find(mode) != modeMap.end());\n+\n+ strToModeMap::iterator it = modeMap.find(caseInsensitiveMode);\n+ if (it != modeMap.end()) {\n+ return it->second;\n}\n- mode_t* getMode(const occa::properties &props) {\n- std::string mode = props[\"mode\"];\n- const bool noMode = !mode.size();\n- if (noMode || !modeIsEnabled(mode)) {\n- if (noMode) {\n- io::stderr << \"No OCCA mode given, defaulting to [Serial] mode\\n\";\n- } else {\n- io::stderr << \"[\" << mode << \"] mode is not enabled, defaulting to [Serial] mode\\n\";\n+ return NULL;\n}\n- mode = \"Serial\";\n+\n+ mode_t* getModeFromProps(const occa::properties &props) {\n+ std::string modeName = props[\"mode\"];\n+ mode_t *mode = getMode(modeName);\n+\n+ if (mode) {\n+ return mode;\n+ }\n+\n+ if (modeName.size()) {\n+ io::stderr << \"[\" << modeName << \"] mode is not enabled, defaulting to [Serial] mode\\n\";\n+ } else {\n+ io::stderr << \"No OCCA mode given, defaulting to [Serial] mode\\n\";\n}\n- return getModeMap()[mode];\n+ return getMode(\"Serial\");\n}\nmodeDevice_t* newModeDevice(const occa::properties &props) {\n- return getMode(props)->newDevice(props);\n+ return getModeFromProps(props)->newDevice(props);\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "tests/src/modes.cpp", "new_path": "tests/src/modes.cpp", "diff": "#include <occa/modes.hpp>\n-void testMode();\n+void testModeByName();\n+void testModeByProps();\nint main(const int argc, const char **argv) {\n- testMode();\n+ testModeByName();\n+ testModeByProps();\nreturn 0;\n}\n-void testMode() {\n- occa::mode_t *serialMode = occa::getMode(\"mode: 'Serial'\");\n+void testModeByName() {\n+ occa::mode_t *serialMode = occa::getMode(\"Serial\");\nASSERT_NEQ((void*) serialMode,\n(void*) NULL);\n- ASSERT_EQ(occa::getMode(\"\"),\n+ ASSERT_EQ((void*) serialMode,\n+ (void*) occa::getMode(\"serial\"));\n+\n+ ASSERT_EQ((void*) occa::getMode(\"\"),\n+ (void*) NULL);\n+\n+ ASSERT_EQ((void*) occa::getMode(\"Foo\"),\n+ (void*) NULL);\n+}\n+\n+void testModeByProps() {\n+ occa::mode_t *serialMode = occa::getModeFromProps(\"mode: 'Serial'\");\n+ ASSERT_NEQ((void*) serialMode,\n+ (void*) NULL);\n+\n+ ASSERT_EQ((void*) serialMode,\n+ (void*) occa::getModeFromProps(\"mode: 'serial'\"));\n+\n+ ASSERT_EQ(occa::getModeFromProps(\"\"),\nserialMode);\n- ASSERT_EQ(occa::getMode(\"mode: 'Foo'\"),\n+ ASSERT_EQ(occa::getModeFromProps(\"mode: 'Foo'\"),\nserialMode);\n}\n\\ No newline at end of file\n" } ]
C++
MIT License
libocca/occa
[Core] Allows for case-insensitive mode names (#384)
378,349
16.07.2020 23:57:14
14,400
88b56b6eda3753bc43c97febbabb0d208ed39fb8
[CUDA] Removes certain errors on destructors due to CUDA Deinitialization
[ { "change_type": "MODIFY", "old_path": "include/occa/defines/errors.hpp", "new_path": "include/occa/defines/errors.hpp", "diff": "#define OCCA_CUDA_ERROR2(expr, filename, function, line, message) OCCA_CUDA_ERROR3(expr, filename, function, line, message)\n#define OCCA_CUDA_ERROR(message, expr) OCCA_CUDA_ERROR2(expr, __FILE__, __PRETTY_FUNCTION__, __LINE__, message)\n+#define OCCA_CUDA_DESTRUCTOR_ERROR3(expr, filename, function, line, message) OCCA_CUDA_TEMPLATE_CHECK(occa::cuda::destructorError, expr, filename, function, line, message)\n+#define OCCA_CUDA_DESTRUCTOR_ERROR2(expr, filename, function, line, message) OCCA_CUDA_DESTRUCTOR_ERROR3(expr, filename, function, line, message)\n+#define OCCA_CUDA_DESTRUCTOR_ERROR(message, expr) OCCA_CUDA_DESTRUCTOR_ERROR2(expr, __FILE__, __PRETTY_FUNCTION__, __LINE__, message)\n+\n#define OCCA_CUDA_WARNING3(expr, filename, function, line, message) OCCA_CUDA_TEMPLATE_CHECK(occa::cuda::warn, expr, filename, function, line, message)\n#define OCCA_CUDA_WARNING2(expr, filename, function, line, message) OCCA_CUDA_WARNING3(expr, filename, function, line, message)\n#define OCCA_CUDA_WARNING(message, expr) OCCA_CUDA_WARNING2(expr, __FILE__, __PRETTY_FUNCTION__, __LINE__, message)\n" }, { "change_type": "MODIFY", "old_path": "include/occa/modes/cuda/utils.hpp", "new_path": "include/occa/modes/cuda/utils.hpp", "diff": "@@ -95,6 +95,12 @@ namespace occa {\nconst int line,\nconst std::string &message);\n+ void destructorError(CUresult errorCode,\n+ const std::string &filename,\n+ const std::string &function,\n+ const int line,\n+ const std::string &message);\n+\nstd::string getErrorMessage(const CUresult errorCode);\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/modes/cuda/device.cpp", "new_path": "src/modes/cuda/device.cpp", "diff": "@@ -79,8 +79,10 @@ namespace occa {\ndevice::~device() {\nif (cuContext) {\n- OCCA_CUDA_ERROR(\"Device: Freeing Context\",\n- cuCtxDestroy(cuContext) );\n+ OCCA_CUDA_DESTRUCTOR_ERROR(\n+ \"Device: Freeing Context\",\n+ cuCtxDestroy(cuContext)\n+ );\ncuContext = NULL;\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/modes/cuda/kernel.cpp", "new_path": "src/modes/cuda/kernel.cpp", "diff": "@@ -27,8 +27,10 @@ namespace occa {\nkernel::~kernel() {\nif (cuModule) {\n- OCCA_CUDA_ERROR(\"Kernel (\" + name + \") : Unloading Module\",\n- cuModuleUnload(cuModule));\n+ OCCA_CUDA_DESTRUCTOR_ERROR(\n+ \"Kernel (\" + name + \") : Unloading Module\",\n+ cuModuleUnload(cuModule)\n+ );\ncuModule = NULL;\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/modes/cuda/memory.cpp", "new_path": "src/modes/cuda/memory.cpp", "diff": "@@ -15,8 +15,10 @@ namespace occa {\nmemory::~memory() {\nif (isOrigin) {\nif (mappedPtr) {\n- OCCA_CUDA_ERROR(\"Device: mappedFree()\",\n- cuMemFreeHost(mappedPtr));\n+ OCCA_CUDA_DESTRUCTOR_ERROR(\n+ \"Device: mappedFree()\",\n+ cuMemFreeHost(mappedPtr)\n+ );\n} else if (cuPtr) {\ncuMemFree(cuPtr);\n}\n" }, { "change_type": "MODIFY", "old_path": "src/modes/cuda/stream.cpp", "new_path": "src/modes/cuda/stream.cpp", "diff": "@@ -10,8 +10,10 @@ namespace occa {\ncuStream(cuStream_) {}\nstream::~stream() {\n- OCCA_CUDA_ERROR(\"Device: freeStream\",\n- cuStreamDestroy(cuStream));\n+ OCCA_CUDA_DESTRUCTOR_ERROR(\n+ \"Device: freeStream\",\n+ cuStreamDestroy(cuStream)\n+ );\n}\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/modes/cuda/streamTag.cpp", "new_path": "src/modes/cuda/streamTag.cpp", "diff": "@@ -9,8 +9,10 @@ namespace occa {\ncuEvent(cuEvent_) {}\nstreamTag::~streamTag() {\n- OCCA_CUDA_ERROR(\"streamTag: Freeing CUevent\",\n- cuEventDestroy(cuEvent));\n+ OCCA_CUDA_DESTRUCTOR_ERROR(\n+ \"streamTag: Freeing CUevent\",\n+ cuEventDestroy(cuEvent)\n+ );\n}\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/modes/cuda/utils.cpp", "new_path": "src/modes/cuda/utils.cpp", "diff": "@@ -20,6 +20,8 @@ namespace occa {\n}\nint getDeviceCount() {\n+ init();\n+\nint deviceCount = 0;\nOCCA_CUDA_ERROR(\"Finding Number of Devices\",\ncuDeviceGetCount(&deviceCount));\n@@ -27,6 +29,8 @@ namespace occa {\n}\nCUdevice getDevice(const int id) {\n+ init();\n+\nCUdevice device = -1;\nOCCA_CUDA_ERROR(\"Getting CUdevice\",\ncuDeviceGet(&device, id));\n@@ -87,7 +91,6 @@ namespace occa {\nCUdeviceptr srcMemory,\nconst udim_t bytes,\nCUstream usingStream) {\n-\npeerToPeerMemcpy(destDevice, destContext, destMemory,\nsrcDevice , srcContext , srcMemory ,\nbytes,\n@@ -103,7 +106,6 @@ namespace occa {\nCUdeviceptr srcMemory,\nconst udim_t bytes,\nCUstream usingStream) {\n-\npeerToPeerMemcpy(destDevice, destContext, destMemory,\nsrcDevice , srcContext , srcMemory ,\nbytes,\n@@ -119,7 +121,6 @@ namespace occa {\nconst udim_t bytes,\nCUstream usingStream,\nconst bool isAsync) {\n-\n#if CUDA_VERSION >= 4000\nif (!isAsync) {\nOCCA_CUDA_ERROR(\"Peer-to-Peer Memory Copy\",\n@@ -154,6 +155,7 @@ namespace occa {\nCUdevice cuDevice = ((device.mode() == \"CUDA\")\n? ((cuda::device*) device.getModeDevice())->cuDevice\n: CU_DEVICE_CPU);\n+\nOCCA_CUDA_ERROR(\"Advising about unified memory\",\ncuMemAdvise(((cuda::memory*) mem.getModeMemory())->cuPtr,\n(size_t) bytes_,\n@@ -177,6 +179,7 @@ namespace occa {\nvoid prefetch(occa::memory mem, const dim_t bytes, occa::device device) {\nOCCA_ERROR(\"Memory allocated with mode [\" << mem.mode() << \"], not [CUDA]\",\nmem.mode() == \"CUDA\");\n+\n#if CUDA_VERSION >= 8000\nudim_t bytes_ = ((bytes == -1) ? mem.size() : bytes);\nCUdevice cuDevice = ((device.mode() == \"CUDA\")\n@@ -202,7 +205,6 @@ namespace occa {\nocca::device wrapDevice(CUdevice device,\nCUcontext context,\nconst occa::properties &props) {\n-\nocca::properties allProps;\nallProps[\"mode\"] = \"CUDA\";\nallProps[\"device_id\"] = -1;\n@@ -267,6 +269,22 @@ namespace occa {\nocca::error(filename, function, line, ss.str());\n}\n+ // On destructors, ignore the case when CUDA becomes uninitialized\n+ void destructorError(CUresult errorCode,\n+ const std::string &filename,\n+ const std::string &function,\n+ const int line,\n+ const std::string &message) {\n+ if (!errorCode || errorCode == CUDA_ERROR_DEINITIALIZED) {\n+ return;\n+ }\n+ std::stringstream ss;\n+ ss << message << '\\n'\n+ << \"CUDA Error [ \" << errorCode << \" ]: \"\n+ << occa::cuda::getErrorMessage(errorCode);\n+ occa::error(filename, function, line, ss.str());\n+ }\n+\nstd::string getErrorMessage(const CUresult errorCode) {\n#define OCCA_CUDA_ERROR_CASE(MACRO) \\\ncase MACRO: return #MACRO\n" } ]
C++
MIT License
libocca/occa
[CUDA] Removes certain errors on destructors due to CUDA Deinitialization (#390)
378,358
24.07.2020 02:00:58
-7,200
f8eb8344aff8ce43aadf8df9acc3d63eec8fb3ef
Fix - use current stream instead of 0
[ { "change_type": "MODIFY", "old_path": "src/modes/cuda/device.cpp", "new_path": "src/modes/cuda/device.cpp", "diff": "@@ -147,7 +147,7 @@ namespace occa {\ncuEventCreate(&cuEvent,\nCU_EVENT_DEFAULT));\nOCCA_CUDA_ERROR(\"Device: Tagging Stream\",\n- cuEventRecord(cuEvent, 0));\n+ cuEventRecord(cuEvent, getCuStream()));\nreturn new occa::cuda::streamTag(this, cuEvent);\n}\n" } ]
C++
MIT License
libocca/occa
Fix #378 - use current stream instead of 0 (#391)
378,347
05.08.2020 05:15:11
0
793a2a8fcc031f4e2b0ed6c21d08c0b5f8f95590
on powerpc (e.g. lassen) -march is not a valid flag of gcc, use -mcpu and -mtune instead there
[ { "change_type": "MODIFY", "old_path": "include/occa/scripts/shellTools.sh", "new_path": "include/occa/scripts/shellTools.sh", "diff": "@@ -224,6 +224,7 @@ function compilerVendor {\nlocal b_HP=6\nlocal b_VisualStudio=7\nlocal b_Cray=8\n+ local b_PPC=9\nlocal testFilename=\"${SCRIPTS_DIR}/tests/compiler.cpp\"\nlocal binaryFilename=\"${SCRIPTS_DIR}/tests/compiler\"\n@@ -243,6 +244,7 @@ function compilerVendor {\n\"${b_HP}\") echo HP ;;\n\"${b_Cray}\") echo CRAY ;;\n\"${b_VisualStudio}\") echo VISUALSTUDIO ;;\n+ \"${b_PPC}\") echo POWERPC ;;\n*) echo N/A ;;\nesac\n}\n@@ -251,7 +253,7 @@ function compilerCpp11Flags {\nlocal vendor=$(compilerVendor \"$1\")\ncase \"$vendor\" in\n- GCC|LLVM|INTEL|PGI)\n+ GCC|LLVM|INTEL|PGI|POWERPC)\necho \"-std=c++11\";;\nCRAY) echo \"-hstd=c++11\" ;;\nIBM) echo \"-qlanglvl=extended0x\" ;;\n@@ -268,6 +270,7 @@ function compilerReleaseFlags {\ncase \"$vendor\" in\nGCC|LLVM) echo \" -O3 -march=native -D __extern_always_inline=inline\" ;;\n+ POWERPC) echo \" -O3 -mcpu=native -mtune=native -D __extern_always_inline=inline\" ;;\nINTEL) echo \" -O3 -xHost\" ;;\nCRAY) echo \" -O3 -h intrinsics -fast\" ;;\nIBM) echo \" -O3 -qhot=simd\" ;;\n@@ -291,7 +294,7 @@ function compilerPicFlag {\nlocal vendor=$(compilerVendor \"$1\")\ncase \"$vendor\" in\n- GCC|LLVM|INTEL|PATHSCALE|CRAY|PGI)\n+ GCC|LLVM|INTEL|PATHSCALE|CRAY|PGI|POWERPC)\necho \"-fPIC\";;\nIBM) echo \"-qpic\";;\nHP) echo \"+z\";;\n@@ -303,7 +306,7 @@ function compilerSharedFlag {\nlocal vendor=$(compilerVendor \"$1\")\ncase \"$vendor\" in\n- GCC|LLVM|INTEL|PATHSCALE|CRAY|PGI)\n+ GCC|LLVM|INTEL|PATHSCALE|CRAY|PGI|POWERPC)\necho \"-shared\";;\nIBM) echo \"-qmkshrobj\";;\nHP) echo \"-b\";;\n@@ -319,7 +322,7 @@ function compilerOpenMPFlag {\nlocal vendor=$(compilerVendor \"$1\")\ncase \"$vendor\" in\n- GCC|LLVM) echo \"-fopenmp\" ;;\n+ GCC|LLVM|POWERPC) echo \"-fopenmp\" ;;\nINTEL|PATHSCALE) echo \"-openmp\" ;;\nCRAY) echo \"\" ;;\nIBM) echo \"-qsmp\" ;;\n" }, { "change_type": "MODIFY", "old_path": "include/occa/scripts/tests/compiler.cpp", "new_path": "include/occa/scripts/tests/compiler.cpp", "diff": "#define OCCA_HP_VENDOR 6\n#define OCCA_VISUALSTUDIO_VENDOR 7\n#define OCCA_CRAY_VENDOR 8\n-#define OCCA_NOT_FOUND 9\n+#define OCCA_PPC_VENDOR 9\n+#define OCCA_NOT_FOUND 10\nint main(int argc, char **argv) {\n@@ -37,6 +38,9 @@ int main(int argc, char **argv) {\n#elif defined(__clang__)\nreturn OCCA_LLVM_VENDOR;\n+#elif defined(__powerpc__)\n+ return OCCA_PPC_VENDOR;\n+\n// Clang also defines __GNUC__, so check for it after __clang__\n#elif defined(__GNUC__) || defined(__GNUG__)\nreturn OCCA_GNU_VENDOR;\n" } ]
C++
MIT License
libocca/occa
on powerpc (e.g. lassen) -march is not a valid flag of gcc, use -mcpu and -mtune instead there (#392) Co-authored-by: Lukas Manuel Sebastian Spies <spies2@lassen709.coral.llnl.gov>
378,350
15.08.2020 14:10:47
21,600
4292cfcfe2eb358b97b78dbebb901636a482c99f
Sys - add PPC for compiler flag detection
[ { "change_type": "MODIFY", "old_path": "include/occa/tools/sys.hpp", "new_path": "include/occa/tools/sys.hpp", "diff": "@@ -26,7 +26,8 @@ namespace occa {\nstatic const int b_HP = 6;\nstatic const int b_VisualStudio = 7;\nstatic const int b_Cray = 8;\n- static const int b_max = 9;\n+ static const int b_PPC = 9;\n+ static const int b_max = 10;\nstatic const int GNU = (1 << b_GNU); // gcc , g++\nstatic const int LLVM = (1 << b_LLVM); // clang , clang++\n@@ -37,6 +38,7 @@ namespace occa {\nstatic const int HP = (1 << b_HP); // aCC\nstatic const int VisualStudio = (1 << b_VisualStudio); // cl.exe\nstatic const int Cray = (1 << b_Cray); // cc , CC\n+ static const int PPC = (1 << b_PPC); // cc , CC\n}\nnamespace language {\n" }, { "change_type": "MODIFY", "old_path": "src/tools/sys.cpp", "new_path": "src/tools/sys.cpp", "diff": "@@ -722,6 +722,7 @@ namespace occa {\nsys::vendor::Intel |\nsys::vendor::HP |\nsys::vendor::PGI |\n+ sys::vendor::PPC |\nsys::vendor::Pathscale)) {\nreturn \"-std=c++11\";\n} else if (vendor_ & sys::vendor::Cray) {\n@@ -745,6 +746,7 @@ namespace occa {\nsys::vendor::Intel |\nsys::vendor::HP |\nsys::vendor::PGI |\n+ sys::vendor::PPC |\nsys::vendor::Pathscale)) {\nreturn \"-std=c99\";\n} else if (vendor_ & sys::vendor::Cray) {\n@@ -768,6 +770,7 @@ namespace occa {\nsys::vendor::Intel |\nsys::vendor::PGI |\nsys::vendor::Cray |\n+ sys::vendor::PPC |\nsys::vendor::Pathscale)) {\nreturn \"-fPIC -shared\";\n} else if (vendor_ & sys::vendor::IBM) {\n" } ]
C++
MIT License
libocca/occa
Sys - add PPC for compiler flag detection (#395)
378,350
17.08.2020 12:49:42
21,600
56eb9eaefb461e9a66064b1e04f532f8614ac086
OpenMP - add base compiler flag for OpenMP on PPC with GCC
[ { "change_type": "MODIFY", "old_path": "src/modes/openmp/utils.cpp", "new_path": "src/modes/openmp/utils.cpp", "diff": "@@ -10,6 +10,7 @@ namespace occa {\nstd::string baseCompilerFlag(const int vendor_) {\nif (vendor_ & (sys::vendor::GNU |\n+ sys::vendor::PPC |\nsys::vendor::LLVM)) {\nreturn \"-fopenmp\";\n} else if (vendor_ & sys::vendor::Intel) {\n" } ]
C++
MIT License
libocca/occa
OpenMP - add base compiler flag for OpenMP on PPC with GCC (#398)
378,349
09.09.2020 23:35:45
14,400
c8a587666a23e045f25dc871c3257364a5f6a7d5
[CUDA] Sets the CUDA context in more methods
[ { "change_type": "MODIFY", "old_path": "include/occa/modes/cuda/device.hpp", "new_path": "include/occa/modes/cuda/device.hpp", "diff": "@@ -42,6 +42,8 @@ namespace occa {\nvoid* getNullPtr();\n+ void setCudaContext();\n+\n//---[ Stream ]-------------------\nvirtual modeStream_t* createStream(const occa::properties &props);\n" }, { "change_type": "MODIFY", "old_path": "src/modes/cuda/device.cpp", "new_path": "src/modes/cuda/device.cpp", "diff": "@@ -126,12 +126,17 @@ namespace occa {\nreturn (void*) &(nullPtr->cuPtr);\n}\n+ void device::setCudaContext() {\n+ OCCA_CUDA_ERROR(\"Device: Setting Context\",\n+ cuCtxSetCurrent(cuContext));\n+ }\n+\n//---[ Stream ]---------------------\nmodeStream_t* device::createStream(const occa::properties &props) {\nCUstream cuStream = NULL;\n- OCCA_CUDA_ERROR(\"Device: Setting Context\",\n- cuCtxSetCurrent(cuContext));\n+ setCudaContext();\n+\nOCCA_CUDA_ERROR(\"Device: createStream\",\ncuStreamCreate(&cuStream, CU_STREAM_DEFAULT));\n@@ -141,8 +146,8 @@ namespace occa {\nocca::streamTag device::tagStream() {\nCUevent cuEvent = NULL;\n- OCCA_CUDA_ERROR(\"Device: Setting Context\",\n- cuCtxSetCurrent(cuContext));\n+ setCudaContext();\n+\nOCCA_CUDA_ERROR(\"Device: Tagging Stream (Creating Tag)\",\ncuEventCreate(&cuEvent,\nCU_EVENT_DEFAULT));\n@@ -219,6 +224,8 @@ namespace occa {\nCUfunction cuFunction;\nCUresult error;\n+ setCudaContext();\n+\nerror = cuModuleLoad(&cuModule, binaryFilename.c_str());\nif (error) {\nlock.release();\n@@ -353,6 +360,8 @@ namespace occa {\nCUmodule cuModule;\nCUresult error;\n+ setCudaContext();\n+\nerror = cuModuleLoad(&cuModule, binaryFilename.c_str());\nif (error) {\nlock.release();\n@@ -410,6 +419,8 @@ namespace occa {\nCUmodule cuModule = NULL;\nCUfunction cuFunction = NULL;\n+ setCudaContext();\n+\nOCCA_CUDA_ERROR(\"Kernel [\" + kernelName + \"]: Loading Module\",\ncuModuleLoad(&cuModule, filename.c_str()));\n@@ -438,8 +449,7 @@ namespace occa {\ncuda::memory &mem = *(new cuda::memory(this, bytes, props));\n- OCCA_CUDA_ERROR(\"Device: Setting Context\",\n- cuCtxSetCurrent(cuContext));\n+ setCudaContext();\nOCCA_CUDA_ERROR(\"Device: malloc\",\ncuMemAlloc(&(mem.cuPtr), bytes));\n@@ -456,8 +466,8 @@ namespace occa {\ncuda::memory &mem = *(new cuda::memory(this, bytes, props));\n- OCCA_CUDA_ERROR(\"Device: Setting Context\",\n- cuCtxSetCurrent(cuContext));\n+ setCudaContext();\n+\nOCCA_CUDA_ERROR(\"Device: malloc host\",\ncuMemAllocHost((void**) &(mem.mappedPtr), bytes));\nOCCA_CUDA_ERROR(\"Device: get device pointer from host\",\n@@ -481,8 +491,8 @@ namespace occa {\nconst unsigned int flags = (props.get(\"attached_host\", false) ?\nCU_MEM_ATTACH_HOST : CU_MEM_ATTACH_GLOBAL);\n- OCCA_CUDA_ERROR(\"Device: Setting Context\",\n- cuCtxSetCurrent(cuContext));\n+ setCudaContext();\n+\nOCCA_CUDA_ERROR(\"Device: Unified alloc\",\ncuMemAllocManaged(&(mem.cuPtr),\nbytes,\n" }, { "change_type": "MODIFY", "old_path": "src/modes/cuda/kernel.cpp", "new_path": "src/modes/cuda/kernel.cpp", "diff": "@@ -62,6 +62,8 @@ namespace occa {\n}\nvoid kernel::deviceRun() const {\n+ device *devicePtr = (device*) modeDevice;\n+\nconst int args = (int) arguments.size();\nif (!args) {\nvArgs.resize(1);\n@@ -74,10 +76,12 @@ namespace occa {\nvArgs[i] = arguments[i].ptr();\n// Set a proper NULL pointer\nif (!vArgs[i]) {\n- vArgs[i] = ((device*) modeDevice)->getNullPtr();\n+ vArgs[i] = devicePtr->getNullPtr();\n}\n}\n+ devicePtr->setCudaContext();\n+\nOCCA_CUDA_ERROR(\"Launching Kernel\",\ncuLaunchKernel(cuFunction,\nouterDims.x, outerDims.y, outerDims.z,\n" } ]
C++
MIT License
libocca/occa
[CUDA] Sets the CUDA context in more methods (#400)
378,341
22.10.2020 15:40:53
-7,200
3a7ee3610e335dd28af53cc803a113e0744d7ddf
[CMake] Fix intermittent errors when building Fortran examples/tests * [Git] Fix .gitignore for build/opt if they are symlinks * [CMake] Fix possible file conflict while building Fortran tests / examples This caused intermittent problems in GNU builds in particular. See also
[ { "change_type": "MODIFY", "old_path": ".gitignore", "new_path": ".gitignore", "diff": "lib/\nobj/\nmain\n-opt/\n+opt\n# CMake\n-build/\n+build\n# Bin\nbin/\n" }, { "change_type": "MODIFY", "old_path": "examples/CMakeLists.txt", "new_path": "examples/CMakeLists.txt", "diff": "@@ -78,7 +78,6 @@ if (ENABLE_FORTRAN)\nmacro(compile_fortran_example_with_modes target file)\nadd_executable(examples_fortran_${target} ${file})\ntarget_link_libraries(examples_fortran_${target} libocca)\n- target_include_directories(examples_fortran_${target} PUBLIC \"${CMAKE_Fortran_MODULE_DIRECTORY}\")\nif (ENABLE_TESTS)\nadd_test_with_modes(examples_fortran_${target})\nendif()\n@@ -87,7 +86,6 @@ if (ENABLE_FORTRAN)\nmacro(compile_fortran_mpi_example_with_modes target file)\nadd_executable(examples_fortran_${target} ${file})\ntarget_link_libraries(examples_fortran_${target} libocca)\n- target_include_directories(examples_fortran_${target} PUBLIC \"${CMAKE_Fortran_MODULE_DIRECTORY}\")\nif (ENABLE_TESTS)\nadd_mpi_test_with_modes(examples_fortran_${target})\nendif()\n" }, { "change_type": "MODIFY", "old_path": "tests/src/fortran/CMakeLists.txt", "new_path": "tests/src/fortran/CMakeLists.txt", "diff": "add_executable(fortran-types types.f90)\ntarget_link_libraries(fortran-types libocca)\n-target_include_directories(fortran-types PUBLIC \"${CMAKE_Fortran_MODULE_DIRECTORY}\")\nadd_test(NAME test-fortran-types COMMAND fortran-types)\nset_property(TEST test-fortran-types APPEND PROPERTY ENVIRONMENT OCCA_CACHE_DIR=${OCCA_BUILD_DIR}/occa)\n@@ -8,6 +7,5 @@ add_library(libtypedefs_helper SHARED typedefs_helper.cpp)\ntarget_link_libraries(libtypedefs_helper libocca)\nadd_executable(fortran-typedefs typedefs.f90)\ntarget_link_libraries(fortran-typedefs libocca libtypedefs_helper)\n-target_include_directories(fortran-typedefs PUBLIC \"${CMAKE_Fortran_MODULE_DIRECTORY}\")\nadd_test(NAME test-fortran-typedefs COMMAND fortran-typedefs)\nset_property(TEST test-fortran-typedefs APPEND PROPERTY ENVIRONMENT OCCA_CACHE_DIR=${OCCA_BUILD_DIR}/occa)\n" } ]
C++
MIT License
libocca/occa
[CMake] Fix intermittent errors when building Fortran examples/tests (#405) * [Git] Fix .gitignore for build/opt if they are symlinks * [CMake] Fix possible file conflict while building Fortran tests / examples This caused intermittent problems in GNU builds in particular. See also https://gitlab.kitware.com/cmake/cmake/-/issues/17525
378,349
24.10.2020 14:36:13
14,400
de41ca93d518429ed7866246600b14c9ca2d9aa1
[Lang][Expr] Adds expr: expression builder helper
[ { "change_type": "MODIFY", "old_path": "include/occa/lang/expr.hpp", "new_path": "include/occa/lang/expr.hpp", "diff": "// Helper methods\n#include <occa/lang/expr/expressionParser.hpp>\n+#include <occa/lang/expr/expr.hpp>\n#endif\n" }, { "change_type": "ADD", "old_path": null, "new_path": "include/occa/lang/expr/expr.hpp", "diff": "+#ifndef OCCA_LANG_EXPR_EXPR_HEADER\n+#define OCCA_LANG_EXPR_EXPR_HEADER\n+\n+#include <occa/lang/operator.hpp>\n+#include <occa/lang/primitive.hpp>\n+\n+namespace occa {\n+ namespace lang {\n+ class exprNode;\n+ class token_t;\n+ class unaryOperator_t;\n+ class binaryOperator_t;\n+ class variable_t;\n+ class blockStatement;\n+ class expressionStatement;\n+\n+ //---[ expr ]-----------------------\n+ class expr {\n+ public:\n+ exprNode *node;\n+\n+ expr();\n+ expr(exprNode *node_);\n+ expr(exprNode &node_);\n+\n+ expr(token_t *source_,\n+ const primitive &p);\n+\n+ expr(variable_t &var);\n+\n+ expr(token_t *source_, variable_t &var);\n+\n+ expr(const expr &other);\n+ ~expr();\n+\n+ expr& operator = (exprNode *node_);\n+ expr& operator = (const expr &other);\n+\n+ token_t* source() const;\n+ const opType_t& opType() const;\n+\n+ exprNode* cloneExprNode();\n+\n+ exprNode* popExprNode();\n+\n+ expr operator [] (const expr &e);\n+\n+ expressionStatement* createStatement(blockStatement *up,\n+ const bool hasSemicolon = true);\n+\n+ static expr parens(const expr &e);\n+\n+ static expr leftUnaryOpExpr(const unaryOperator_t &op_,\n+ const expr &e);\n+\n+ static expr rightUnaryOpExpr(const unaryOperator_t &op_,\n+ const expr &e);\n+\n+ static expr binaryOpExpr(const binaryOperator_t &op_,\n+ const expr &left,\n+ const expr &right);\n+\n+ // --e\n+ expr operator -- ();\n+ // e--\n+ expr operator -- (int);\n+\n+ // ++e\n+ expr operator ++ ();\n+ // e++\n+ expr operator ++ (int);\n+ };\n+ //==================================\n+\n+ //---[ Operators ]------------------\n+ expr operator + (const expr &left, const expr &right);\n+ expr operator - (const expr &left, const expr &right);\n+ expr operator * (const expr &left, const expr &right);\n+ expr operator / (const expr &left, const expr &right);\n+ expr operator % (const expr &left, const expr &right);\n+\n+ expr operator += (const expr &left, const expr &right);\n+ expr operator -= (const expr &left, const expr &right);\n+ expr operator *= (const expr &left, const expr &right);\n+ expr operator /= (const expr &left, const expr &right);\n+\n+ expr operator < (const expr &left, const expr &right);\n+ expr operator <= (const expr &left, const expr &right);\n+ expr operator == (const expr &left, const expr &right);\n+ expr operator != (const expr &left, const expr &right);\n+ expr operator > (const expr &left, const expr &right);\n+ expr operator >= (const expr &left, const expr &right);\n+ //==================================\n+ }\n+}\n+\n+#endif\n" }, { "change_type": "MODIFY", "old_path": "include/occa/lang/expr/primitiveNode.hpp", "new_path": "include/occa/lang/expr/primitiveNode.hpp", "diff": "#define OCCA_LANG_EXPR_PRIMITIVENODE_HEADER\n#include <occa/lang/expr/exprNode.hpp>\n+#include <occa/lang/primitive.hpp>\nnamespace occa {\nnamespace lang {\n" }, { "change_type": "MODIFY", "old_path": "src/lang/builtins/attributes/dim.cpp", "new_path": "src/lang/builtins/attributes/dim.cpp", "diff": "@@ -76,45 +76,20 @@ namespace occa {\n}\n// Expand the dimensions:\n- // x\n- // y + (2 * x)\n- exprNode *index = call.args[order[dimCount - 1]];\n+ // (x, y)\n+ // -> y + (2 * x)\n+ expr index = call.args[order[dimCount - 1]];\nfor (int i = (dimCount - 2); i >= 0; --i) {\n- const int i2 = order[i];\n- token_t *source = call.args[i2]->token;\n- exprNode *indexInParen = index->wrapInParentheses();\n+ const int orderIndex = order[i];\n- // Don't delete the initial call.args[...]\n- if (i < (dimCount - 2)) {\n- delete index;\n- }\n-\n- exprNode *dimInParen = dimAttr.args[i2].expr->wrapInParentheses();\n- binaryOpNode mult(source,\n- op::mult,\n- *dimInParen,\n- *indexInParen);\n- delete dimInParen;\n- delete indexInParen;\n+ expr arg = call.args[orderIndex];\n+ expr dim = dimAttr.args[orderIndex].expr;\n- parenthesesNode multInParen(source,\n- mult);\n- exprNode *argInParen = call.args[i2]->wrapInParentheses();\n-\n- index = new binaryOpNode(source,\n- op::add,\n- *argInParen,\n- multInParen);\n- delete argInParen;\n+ index = arg + expr::parens(expr::parens(dim) * expr::parens(index));\n}\n- exprNode *newValue = new subscriptNode(call.token,\n- *(call.value),\n- *index);\n- // Don't delete the initial call.args[...]\n- if (dimCount > 1) {\n- delete index;\n- }\n+ expr expansion = expr(call.value)[index];\n+ exprNode *newValue = expansion.popExprNode();\nsmnt.updateIdentifierReferences(newValue);\n" }, { "change_type": "MODIFY", "old_path": "src/lang/builtins/attributes/tile.cpp", "new_path": "src/lang/builtins/attributes/tile.cpp", "diff": "@@ -177,49 +177,49 @@ namespace occa {\n->\nfor (xTile = START; xTile < END; xTile += (TILE * (INC)))\n*/\n- exprNode &updateExpr = *(((expressionStatement*) innerForSmnt.update)->expr);\n- opType_t opType = ((exprOpNode&) updateExpr).opType();\n-\n- token_t *updateToken = updateExpr.startNode()->token;\n-\n- exprNode *updateSizeExpr = &tileSize;\n- const binaryOperator_t *updateOp = &op::addEq;\n- if (opType & (operatorType::leftDecrement |\n- operatorType::rightDecrement)) {\n- updateOp = &op::subEq;\n+ expr innerUpdateExpr = ((expressionStatement*) innerForSmnt.update)->expr;\n+ expr tileSizeExpr = &tileSize;\n+ expr blockIterator(innerUpdateExpr.source(), blockIter);\n+\n+ opType_t opType = innerUpdateExpr.opType();\n+\n+ expr blockUpdate;\n+ if (opType & (operatorType::leftIncrement | operatorType::rightIncrement)) {\n+ // ++IT (or IT++)\n+ // -> BLOCK_IT += TILE\n+ blockUpdate = (\n+ blockIterator += tileSizeExpr\n+ );\n}\n- else if (opType & (operatorType::addEq |\n- operatorType::subEq)) {\n- // INC\n- exprNode *updateSize = ((binaryOpNode&) updateExpr).rightValue;\n- // (INC)\n- parenthesesNode updateInParen(updateToken,\n- *updateSize);\n- // TILE * (INC)\n- binaryOpNode mult(updateToken,\n- op::mult,\n- tileSize,\n- updateInParen);\n- // (TILE * (INC))\n- updateSizeExpr = new parenthesesNode(updateToken,\n- mult);\n- if (opType & operatorType::subEq) {\n- updateOp = &op::subEq;\n+ else if (opType & (operatorType::leftDecrement | operatorType::rightDecrement)) {\n+ // --IT (or IT--)\n+ // -> BLOCK_IT -= TILE\n+ blockUpdate = (\n+ blockIterator -= tileSizeExpr\n+ );\n}\n+ else if (opType & (operatorType::addEq | operatorType::subEq)) {\n+ // INC\n+ expr increment = innerUpdateExpr.node->to<binaryOpNode>().rightValue;\n+\n+ // ((TILE) * (INC))\n+ expr blockIncrement = expr::parens(\n+ expr::parens(tileSizeExpr) * expr::parens(increment)\n+ );\n+\n+ if (opType & operatorType::addEq) {\n+ blockUpdate = (\n+ blockIterator += blockIncrement\n+ );\n+ } else {\n+ blockUpdate = (\n+ blockIterator -= blockIncrement\n+ );\n}\n- // VAR += (TILE * (INC))\n- variableNode varNode(updateToken, blockIter);\n- exprNode *newUpdateExpr = new binaryOpNode(updateToken,\n- *updateOp,\n- varNode,\n- *updateSizeExpr);\n- if (updateSizeExpr != &tileSize) {\n- // Delete (TILE * (INC)) if it was created\n- delete updateSizeExpr;\n}\nblockForSmnt.update = new expressionStatement(&blockForSmnt,\n- *newUpdateExpr,\n+ *blockUpdate.popExprNode(),\nfalse);\n}\n@@ -235,56 +235,47 @@ namespace occa {\n->\nfor (x = xTile; x < (xTile + TILE); x += INC)\n*/\n- // Init variables\n- variableDeclaration &decl = (((declarationStatement*) blockForSmnt.init)\n- ->declarations[0]);\n- token_t *initToken = decl.variable().source;\n- variableNode iterNode(initToken,\n- *oklForSmnt.iterator);\n- variableNode blockIterNode(initToken, blockIter);\n+ auto &blockDecls = ((declarationStatement*) blockForSmnt.init)->declarations;\n+ token_t *declVarSource = blockDecls[0].variable().source;\n// Check variables\n- binaryOpNode &checkExpr = ((binaryOpNode&)\n- *(((expressionStatement*) blockForSmnt.check)->expr));\n- token_t *checkToken = checkExpr.startNode()->token;\n+ expressionStatement &checkSmnt = (expressionStatement&) *blockForSmnt.check;\n+ binaryOpNode &checkExpr = (binaryOpNode&) *checkSmnt.expr;\n// Update variables\n- const operator_t &updateOp = (\n- ((binaryOpNode&)\n- *(((expressionStatement*) blockForSmnt.update)->expr)\n- ).op);\n- const bool addUpdate = (updateOp.opType & operatorType::addEq);\n-\n- // Create init\n- innerForSmnt.init = new declarationStatement(&innerForSmnt, initToken);\n- variableDeclarationVector &decls = (\n- ((declarationStatement*) innerForSmnt.init)\n- ->declarations\n- );\n+ expressionStatement &updateSmnt = (expressionStatement&) *blockForSmnt.update;\n+ binaryOpNode &updateExpr = (binaryOpNode&) *updateSmnt.expr;\n+\n+ // Create init statement\n+ innerForSmnt.init = new declarationStatement(&innerForSmnt, declVarSource);\n+ auto &initDecls = ((declarationStatement*) innerForSmnt.init)->declarations;\n- decls.push_back(\n+ expr blockIterator(declVarSource, blockIter);\n+ expr iterator(*oklForSmnt.iterator);\n+ expr tileSizeExpr = &tileSize;\n+\n+ initDecls.push_back(\nvariableDeclaration(*oklForSmnt.iterator,\n- *(blockIterNode.clone()))\n+ blockIterator.cloneExprNode())\n+ );\n+\n+ // Create check statement\n+ // Note: At this point, the tile for-loop has an update\n+ // with either an [+=] or [-=] update operator\n+ expr bounds = expr::parens(\n+ (updateExpr.opType() & operatorType::addEq)\n+ ? blockIterator + tileSizeExpr\n+ : blockIterator - tileSizeExpr\n);\n- // Create check\n- binaryOpNode checkValueNode(checkToken,\n- addUpdate ? op::add : op::sub,\n- blockIterNode,\n- tileSize);\n- parenthesesNode checkInParen(checkToken,\n- checkValueNode);\n-\n- const bool varInLeft = oklForSmnt.checkValueOnRight;\n- binaryOpNode &newCheckNode = *(\n- new binaryOpNode(\n- checkToken,\n- (const binaryOperator_t&) checkExpr.op,\n- varInLeft ? (exprNode&) iterNode : (exprNode&) checkInParen,\n- varInLeft ? (exprNode&) checkInParen : (exprNode&) iterNode\n- ));\n- innerForSmnt.check = new expressionStatement(&innerForSmnt,\n- newCheckNode);\n+ const binaryOperator_t &checkOp = (const binaryOperator_t&) checkExpr.op;\n+ expr check = (\n+ oklForSmnt.checkValueOnRight\n+ ? expr::binaryOpExpr(checkOp, iterator, bounds)\n+ : expr::binaryOpExpr(checkOp, bounds, iterator)\n+ );\n+\n+ innerForSmnt.check = check.createStatement(&innerForSmnt);\n}\nvoid tile::setupCheckStatement(attributeToken_t &attr,\n@@ -292,44 +283,38 @@ namespace occa {\nvariable_t &blockIter,\nforStatement &blockForSmnt,\nforStatement &innerForSmnt) {\n- attributeArgMap::iterator it = attr.kwargs.find(\"check\");\n- bool check = true;\n+ // Default to adding the check\n+ auto it = attr.kwargs.find(\"check\");\n+ bool requiresBoundsCheck = true;\nif (it != attr.kwargs.end()) {\n- check = (bool) it->second.expr->evaluate();\n+ requiresBoundsCheck = (bool) it->second.expr->evaluate();\n}\n- if (!check) {\n+ if (!requiresBoundsCheck) {\nreturn;\n}\n// Check variables\n- binaryOpNode &checkExpr = ((binaryOpNode&)\n- *(((expressionStatement*) blockForSmnt.check)->expr));\n+ expressionStatement &checkSmnt = (expressionStatement&) *blockForSmnt.check;\n+ binaryOpNode &checkExpr = (binaryOpNode&) *checkSmnt.expr;\ntoken_t *checkToken = checkExpr.startNode()->token;\n- const bool varInLeft = oklForSmnt.checkValueOnRight;\n- // Make ifStatement\n- ifStatement &ifSmnt = *(new ifStatement(&innerForSmnt,\n- checkToken));\n+ // Make if statement\n+ ifStatement &ifSmnt = *(new ifStatement(&innerForSmnt, checkToken));\ninnerForSmnt.swapChildren(ifSmnt);\ninnerForSmnt.add(ifSmnt);\n- // Get global check\n- token_t *iterToken = (varInLeft\n- ? checkExpr.leftValue->token\n- : checkExpr.rightValue->token);\n- variableNode iterNode(iterToken,\n- *oklForSmnt.iterator);\n- binaryOpNode &newCheckNode = *(\n- new binaryOpNode(\n- checkExpr.token,\n- (const binaryOperator_t&) checkExpr.op,\n- varInLeft ? (exprNode&) iterNode : *(checkExpr.leftValue),\n- varInLeft ? (exprNode&) *(checkExpr.rightValue) : (exprNode&) iterNode\n- ));\n-\n- ifSmnt.setCondition(new expressionStatement(&ifSmnt,\n- newCheckNode,\n- false));\n+ expr iterator(*oklForSmnt.iterator);\n+\n+ const binaryOperator_t &checkOp = (const binaryOperator_t&) checkExpr.op;\n+ expr check = (\n+ oklForSmnt.checkValueOnRight\n+ ? expr::binaryOpExpr(checkOp, iterator, checkExpr.rightValue)\n+ : expr::binaryOpExpr(checkOp, checkExpr.leftValue, iterator)\n+ );\n+\n+ ifSmnt.setCondition(\n+ check.createStatement(&ifSmnt, false)\n+ );\n}\n}\n}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "src/lang/expr/expr.cpp", "diff": "+#include <occa/lang/expr/expr.hpp>\n+#include <occa/lang/expr/exprNodes.hpp>\n+#include <occa/lang/statement.hpp>\n+#include <occa/lang/variable.hpp>\n+\n+namespace occa {\n+ namespace lang {\n+ //---[ expr ]-----------------------\n+ expr::expr() :\n+ node(NULL) {}\n+\n+ expr::expr(exprNode *node_) :\n+ node(exprNode::clone(node_)) {}\n+\n+ expr::expr(exprNode &node_) :\n+ node(node_.clone()) {}\n+\n+ expr::expr(token_t *source_,\n+ const primitive &p) :\n+ node(new primitiveNode(source_, p)) {}\n+\n+ expr::expr(variable_t &var) :\n+ node(new variableNode(var.source, var)) {}\n+\n+ expr::expr(token_t *source_, variable_t &var) :\n+ node(new variableNode(source_, var)) {}\n+\n+ expr::expr(const expr &other) :\n+ node(exprNode::clone(other.node)) {}\n+\n+ expr::~expr() {\n+ delete node;\n+ }\n+\n+ expr& expr::operator = (exprNode *node_) {\n+ delete node;\n+ node = exprNode::clone(node_);\n+ return *this;\n+ }\n+\n+ expr& expr::operator = (const expr &other) {\n+ delete node;\n+ node = exprNode::clone(other.node);\n+ return *this;\n+ }\n+\n+\n+ token_t* expr::source() const {\n+ return node ? node->token : NULL;\n+ }\n+\n+ const opType_t& expr::opType() const {\n+ exprOpNode *opNode = dynamic_cast<exprOpNode*>(node);\n+ if (opNode) {\n+ return opNode->op.opType;\n+ }\n+ return operatorType::none;\n+ }\n+\n+ exprNode* expr::cloneExprNode() {\n+ return exprNode::clone(node);\n+ }\n+\n+ exprNode* expr::popExprNode() {\n+ exprNode *n = node;\n+ node = NULL;\n+ return n;\n+ }\n+\n+ expr expr::operator [] (const expr &e) {\n+ return new subscriptNode(source(),\n+ *node,\n+ *e.node);\n+ }\n+\n+ expressionStatement* expr::createStatement(blockStatement *up,\n+ const bool hasSemicolon) {\n+ return new expressionStatement(up, *node->clone(), hasSemicolon);\n+ }\n+\n+ expr expr::parens(const expr &e) {\n+ if (!e.node) {\n+ return expr();\n+ }\n+ return e.node->wrapInParentheses();\n+ }\n+\n+ expr expr::leftUnaryOpExpr(const unaryOperator_t &op_,\n+ const expr &e) {\n+ return new leftUnaryOpNode(e.source(),\n+ op_,\n+ *e.node);\n+ }\n+\n+ expr expr::rightUnaryOpExpr(const unaryOperator_t &op_,\n+ const expr &e) {\n+ return new rightUnaryOpNode(e.source(),\n+ op_,\n+ *e.node);\n+ }\n+\n+ expr expr::binaryOpExpr(const binaryOperator_t &op_,\n+ const expr &left,\n+ const expr &right) {\n+ return new binaryOpNode(left.source(),\n+ op_,\n+ *left.node,\n+ *right.node);\n+ }\n+\n+ // --e\n+ expr expr::operator -- () {\n+ return leftUnaryOpExpr(op::leftDecrement, *this);\n+ }\n+\n+ // e--\n+ expr expr::operator -- (int) {\n+ return rightUnaryOpExpr(op::rightDecrement, *this);\n+ }\n+\n+ // ++e\n+ expr expr::operator ++ () {\n+ return leftUnaryOpExpr(op::leftIncrement, *this);\n+ }\n+\n+ // e++\n+ expr expr::operator ++ (int) {\n+ return rightUnaryOpExpr(op::rightIncrement, *this);\n+ }\n+ //==================================\n+\n+ //---[ Operators ]------------------\n+ expr operator + (const expr &left, const expr &right) {\n+ return expr::binaryOpExpr(op::add, left, right);\n+ }\n+\n+ expr operator - (const expr &left, const expr &right) {\n+ return expr::binaryOpExpr(op::sub, left, right);\n+ }\n+\n+ expr operator * (const expr &left, const expr &right) {\n+ return expr::binaryOpExpr(op::mult, left, right);\n+ }\n+\n+ expr operator / (const expr &left, const expr &right) {\n+ return expr::binaryOpExpr(op::div, left, right);\n+ }\n+\n+ expr operator % (const expr &left, const expr &right) {\n+ return expr::binaryOpExpr(op::mod, left, right);\n+ }\n+\n+ expr operator += (const expr &left, const expr &right) {\n+ return expr::binaryOpExpr(op::addEq, left, right);\n+ }\n+\n+ expr operator -= (const expr &left, const expr &right) {\n+ return expr::binaryOpExpr(op::subEq, left, right);\n+ }\n+\n+ expr operator *= (const expr &left, const expr &right) {\n+ return expr::binaryOpExpr(op::multEq, left, right);\n+ }\n+\n+ expr operator /= (const expr &left, const expr &right) {\n+ return expr::binaryOpExpr(op::divEq, left, right);\n+ }\n+\n+ expr operator < (const expr &left, const expr &right) {\n+ return expr::binaryOpExpr(op::lessThan, left, right);\n+ }\n+\n+ expr operator <= (const expr &left, const expr &right) {\n+ return expr::binaryOpExpr(op::lessThanEq, left, right);\n+ }\n+\n+ expr operator == (const expr &left, const expr &right) {\n+ return expr::binaryOpExpr(op::equal, left, right);\n+ }\n+\n+ expr operator != (const expr &left, const expr &right) {\n+ return expr::binaryOpExpr(op::notEqual, left, right);\n+ }\n+\n+ expr operator > (const expr &left, const expr &right) {\n+ return expr::binaryOpExpr(op::greaterThan, left, right);\n+ }\n+\n+ expr operator >= (const expr &left, const expr &right) {\n+ return expr::binaryOpExpr(op::greaterThanEq, left, right);\n+ }\n+ //==================================\n+ }\n+}\n" } ]
C++
MIT License
libocca/occa
[Lang][Expr] Adds expr: expression builder helper (#407)
378,349
24.10.2020 17:26:17
14,400
41ee6c7a78b740bc2e5dc5c1ba1167a9a68d281f
[Lang][Preprocessor] Adds okl/strict_headers option
[ { "change_type": "MODIFY", "old_path": "include/occa/lang/preprocessor.hpp", "new_path": "include/occa/lang/preprocessor.hpp", "diff": "@@ -42,6 +42,10 @@ namespace occa {\ntypedef void (preprocessor_t::*processDirective_t)(identifierToken &directive);\ntypedef std::map<std::string, processDirective_t> directiveMap;\n+ //---[ Settings ]-----------------\n+ bool strictHeaders;\n+ //================================\n+\n//---[ Status ]-------------------\nstd::vector<int> statusStack;\nint status;\n" }, { "change_type": "MODIFY", "old_path": "include/occa/lang/tokenizer.hpp", "new_path": "include/occa/lang/tokenizer.hpp", "diff": "@@ -112,6 +112,8 @@ namespace occa {\ntoken_t* getCharToken(const int encoding);\nint peekForHeader();\n+ bool loadingQuotedHeader();\n+ bool loadingAngleBracketHeader();\nstd::string getHeader();\nvoid setOrigin(const int line,\n" }, { "change_type": "MODIFY", "old_path": "src/lang/preprocessor.cpp", "new_path": "src/lang/preprocessor.cpp", "diff": "@@ -33,6 +33,8 @@ namespace occa {\nincludePaths = env::OCCA_INCLUDE_PATH;\n+ strictHeaders = settings.get(\"okl/strict_headers\", true);\n+\njson oklIncludePaths = settings[\"okl/include_paths\"];\nif (oklIncludePaths.isArray()) {\njsonArray pathArray = oklIncludePaths.array();\n@@ -1304,15 +1306,32 @@ namespace occa {\n}\n// Expand non-absolute path\n- std::string header = io::findInPaths(io::filename(tokenizer->getHeader(), false), includePaths);\n+ bool headerIsQuoted = tokenizer->loadingQuotedHeader();\n+ std::string header = io::findInPaths(\n+ io::filename(tokenizer->getHeader(), false),\n+ includePaths\n+ );\nif (!io::exists(header)) {\n- // Default to standard headers if they exist\n- if (standardHeaders.find(header) != standardHeaders.end()) {\n+ const bool isSystemHeader =(\n+ standardHeaders.find(header) != standardHeaders.end()\n+ );\n+ const bool includeRawHeader = (\n+ !strictHeaders || isSystemHeader\n+ );\n+\n+ if (strictHeaders && isSystemHeader) {\nwarningOn(&directive,\n\"Including standard headers may not be portable for all modes\");\n- pushOutput(new directiveToken(directive.origin,\n- \"include <\" + header + \">\"));\n+ }\n+\n+ if (includeRawHeader) {\n+ const std::string line = (\n+ headerIsQuoted\n+ ? \"include \\\"\" + header + \"\\\"\"\n+ : \"include <\" + header + \">\"\n+ );\n+ pushOutput(new directiveToken(directive.origin, line));\nreturn;\n}\n" }, { "change_type": "MODIFY", "old_path": "src/lang/tokenizer.cpp", "new_path": "src/lang/tokenizer.cpp", "diff": "@@ -815,12 +815,40 @@ namespace occa {\nreturn tokenType::none;\n}\n- std::string tokenizer_t::getHeader() {\n+ bool tokenizer_t::loadingQuotedHeader() {\n+ // Assumes we are loading a header\n+ int type = shallowPeek();\n+\n+ return (type & tokenType::string);\n+ }\n+\n+ bool tokenizer_t::loadingAngleBracketHeader() {\n+ // Assumes we are loading a header\nint type = shallowPeek();\n+ return (type & tokenType::op);\n+ }\n+\n+ std::string tokenizer_t::getHeader() {\n+ bool isQuoted = loadingQuotedHeader();\n+ bool isAngleBracket = loadingAngleBracketHeader();\n+\n+ if (!isQuoted && !isAngleBracket) {\n+ printError(\"Not able to parse header\");\n+ return NULL;\n+ }\n+\n// Push after in case of whitespace\npush();\n- if (type & tokenType::op) {\n+\n+ // (Quoted) #include \"...\"\n+ if (isQuoted) {\n+ std::string value;\n+ getString(value);\n+ return value;\n+ }\n+\n+ // (Angle bracket) #include <...>\n++fp.start; // Skip <\npush();\nskipTo(\">\\n\");\n@@ -836,16 +864,6 @@ namespace occa {\nreturn header;\n}\n- if (!(type & tokenType::string)) {\n- printError(\"Not able to parse header\");\n- return NULL;\n- }\n-\n- std::string value;\n- getString(value);\n- return value;\n- }\n-\nvoid tokenizer_t::setOrigin(const int line,\nconst std::string &filename) {\n// TODO: Needs to create a new file instance to avoid\n" }, { "change_type": "MODIFY", "old_path": "tests/src/lang/preprocessor.cpp", "new_path": "tests/src/lang/preprocessor.cpp", "diff": "@@ -658,9 +658,12 @@ void testIncludeStandardHeader() {\ngetToken(); \\\nASSERT_EQ_BINARY(tokenType::directive, \\\ntoken->type()); \\\n- ASSERT_EQ(\"include <\" header \">\", \\\n+ ASSERT_EQ(\"include \" header, \\\ntoken->to<directiveToken>().value)\n+ for (int i = 0; i < 2; ++i) {\n+ const bool hasStrictHeaders = (bool) i;\n+\nsetStream(\n\"#include \\\"math.h\\\"\\n\"\n\"#include <math.h>\\n\"\n@@ -671,15 +674,21 @@ void testIncludeStandardHeader() {\n);\npreprocessor_t *pp = (preprocessor_t*) tokenStream.getInput(\"preprocessor_t\");\n+ pp->strictHeaders = hasStrictHeaders;\n- checkInclude(\"math.h\");\n- checkInclude(\"math.h\");\n- checkInclude(\"cmath\");\n- checkInclude(\"cmath\");\n- checkInclude(\"iostream\");\n- checkInclude(\"iostream\");\n+ checkInclude(\"\\\"math.h\\\"\");\n+ checkInclude(\"<math.h>\");\n+ checkInclude(\"\\\"cmath\\\"\");\n+ checkInclude(\"<cmath>\");\n+ checkInclude(\"\\\"iostream\\\"\");\n+ checkInclude(\"<iostream>\");\n+ if (hasStrictHeaders) {\nASSERT_EQ(6, pp->warnings);\n+ } else {\n+ ASSERT_EQ(0, pp->warnings);\n+ }\n+ }\n}\nvoid testPragma() {\n" }, { "change_type": "MODIFY", "old_path": "tests/src/lang/tokenizer/token.cpp", "new_path": "tests/src/lang/tokenizer/token.cpp", "diff": "@@ -108,6 +108,18 @@ void testPeekMethods() {\ntestCharPeek(\"U'\\\\''\" , encodingType::U);\ntestCharPeek(\"L'\\\\''\" , encodingType::L);\n+ setStream(\"<foobar>\");\n+ ASSERT_TRUE(tokenizer.loadingAngleBracketHeader());\n+ ASSERT_FALSE(tokenizer.loadingQuotedHeader());\n+\n+ setStream(\"\\\"foobar\\\"\");\n+ ASSERT_FALSE(tokenizer.loadingAngleBracketHeader());\n+ ASSERT_TRUE(tokenizer.loadingQuotedHeader());\n+\n+ setStream(\"foobar\");\n+ ASSERT_FALSE(tokenizer.loadingAngleBracketHeader());\n+ ASSERT_FALSE(tokenizer.loadingQuotedHeader());\n+\nASSERT_EQ(\"foobar\",\ngetHeader(\"<foobar>\"));\nASSERT_EQ(\"foobar\",\n" } ]
C++
MIT License
libocca/occa
[Lang][Preprocessor] Adds okl/strict_headers option (#408)
378,349
24.10.2020 18:39:15
14,400
9306a7917cf01e5160c01743d441ee51216341d1
[Lang] Adds source code statement
[ { "change_type": "MODIFY", "old_path": "bin/occa.cpp", "new_path": "bin/occa.cpp", "diff": "@@ -148,8 +148,9 @@ bool runTranslate(const json &args) {\n}\nproperties kernelProps = getOptionProperties(options[\"kernel-props\"]);\n- kernelProps[\"okl/include_paths\"] = options[\"include-path\"];\n+ kernelProps[\"mode\"] = mode;\nkernelProps[\"defines\"].asObject() += getOptionDefines(options[\"define\"]);\n+ kernelProps[\"okl/include_paths\"] = options[\"include-path\"];\nlang::parser_t *parser = NULL;\nlang::parser_t *launcherParser = NULL;\n" }, { "change_type": "MODIFY", "old_path": "include/occa/lang/preprocessor.hpp", "new_path": "include/occa/lang/preprocessor.hpp", "diff": "#include <ostream>\n#include <vector>\n#include <map>\n+#include <set>\n#include <stack>\n#include <occa/defines.hpp>\n@@ -16,7 +17,7 @@ namespace occa {\nnamespace lang {\nclass tokenizer_t;\n- typedef std::map<std::string, bool> stringSet;\n+ typedef std::set<std::string> stringSet;\ntypedef std::vector<token_t*> tokenVector;\ntypedef std::stack<token_t*> tokenStack;\n" }, { "change_type": "MODIFY", "old_path": "include/occa/lang/statement.hpp", "new_path": "include/occa/lang/statement.hpp", "diff": "#include <occa/lang/statement/ifStatement.hpp>\n#include <occa/lang/statement/returnStatement.hpp>\n#include <occa/lang/statement/whileStatement.hpp>\n+#include <occa/lang/statement/sourceCodeStatement.hpp>\n#endif\n" }, { "change_type": "ADD", "old_path": null, "new_path": "include/occa/lang/statement/sourceCodeStatement.hpp", "diff": "+#ifndef OCCA_LANG_STATEMENT_SOURCECODESTATEMENT_HEADER\n+#define OCCA_LANG_STATEMENT_SOURCECODESTATEMENT_HEADER\n+\n+#include <occa/lang/statement/statement.hpp>\n+\n+namespace occa {\n+ namespace lang {\n+ class sourceCodeStatement : public statement_t {\n+ public:\n+ std::string sourceCode;\n+\n+ sourceCodeStatement(blockStatement *up_,\n+ token_t *sourceToken,\n+ const std::string &sourceCode_);\n+ sourceCodeStatement(blockStatement *up_,\n+ const sourceCodeStatement &other);\n+ ~sourceCodeStatement();\n+\n+ virtual statement_t& clone_(blockStatement *up_) const;\n+\n+ virtual int type() const;\n+ virtual std::string statementName() const;\n+\n+ virtual void print(printer &pout) const;\n+ };\n+ }\n+}\n+\n+#endif\n" }, { "change_type": "MODIFY", "old_path": "include/occa/lang/statement/statement.hpp", "new_path": "include/occa/lang/statement/statement.hpp", "diff": "@@ -69,6 +69,8 @@ namespace occa {\nextern const int attribute;\n+ extern const int sourceCode;\n+\nextern const int blockStatements;\n}\n" }, { "change_type": "MODIFY", "old_path": "include/occa/lang/utils/array.hpp", "new_path": "include/occa/lang/utils/array.hpp", "diff": "#ifndef OCCA_LANG_UTILS_BASEARRAY_HEADER\n#define OCCA_LANG_UTILS_BASEARRAY_HEADER\n+#include <initializer_list>\n#include <string>\n#include <vector>\n@@ -15,12 +16,15 @@ namespace occa {\nvectorType data;\n- inline array(vectorType &data_) :\n+ inline array(const vectorType &data_) :\ndata(data_) {}\ninline array(const array &other) :\ndata(other.data) {}\n+ inline array(std::initializer_list<TM> list) :\n+ data(list) {}\n+\n// Implement for-loop iterators\ninline vectorIterator begin() noexcept {\nreturn data.begin();\n" }, { "change_type": "MODIFY", "old_path": "src/lang/modes/cuda.cpp", "new_path": "src/lang/modes/cuda.cpp", "diff": "#include <occa/lang/modes/oklForStatement.hpp>\n#include <occa/lang/builtins/attributes.hpp>\n#include <occa/lang/builtins/types.hpp>\n-#include <occa/lang/expr/identifierNode.hpp>\nnamespace occa {\nnamespace lang {\n@@ -107,10 +106,10 @@ namespace occa {\nemptyStatement &emptySmnt = *((emptyStatement*) smnt);\nstatement_t &barrierSmnt = (\n- *(new expressionStatement(\n+ *(new sourceCodeStatement(\nemptySmnt.up,\n- *(new identifierNode(emptySmnt.source,\n- \" __syncthreads()\"))\n+ emptySmnt.source,\n+ \" __syncthreads();\"\n))\n);\n" }, { "change_type": "MODIFY", "old_path": "src/lang/modes/metal.cpp", "new_path": "src/lang/modes/metal.cpp", "diff": "@@ -71,10 +71,10 @@ namespace occa {\nemptyStatement &emptySmnt = (emptyStatement&) *smnt;\nstatement_t &barrierSmnt = (\n- *(new expressionStatement(\n+ *(new sourceCodeStatement(\nemptySmnt.up,\n- *(new identifierNode(emptySmnt.source,\n- \"threadgroup_barrier(mem_flags::mem_threadgroup)\"))\n+ emptySmnt.source,\n+ \"threadgroup_barrier(mem_flags::mem_threadgroup);\"\n))\n);\n" }, { "change_type": "MODIFY", "old_path": "src/lang/modes/opencl.cpp", "new_path": "src/lang/modes/opencl.cpp", "diff": "@@ -228,10 +228,10 @@ namespace occa {\nemptyStatement &emptySmnt = (emptyStatement&) *smnt;\nstatement_t &barrierSmnt = (\n- *(new expressionStatement(\n+ *(new sourceCodeStatement(\nemptySmnt.up,\n- *(new identifierNode(emptySmnt.source,\n- \"barrier(CLK_LOCAL_MEM_FENCE)\"))\n+ emptySmnt.source,\n+ \"barrier(CLK_LOCAL_MEM_FENCE);\"\n))\n);\n" }, { "change_type": "MODIFY", "old_path": "src/lang/modes/withLauncher.cpp", "new_path": "src/lang/modes/withLauncher.cpp", "diff": "@@ -194,66 +194,43 @@ namespace occa {\n);\n}\n- launchBlock.addFirst(\n- *(new expressionStatement(\n- &launchBlock,\n- *(new identifierNode(forSmnt.source,\n- \"inner.dims = \" + occa::toString(innerDims)))\n- ))\n- );\n- launchBlock.addFirst(\n- *(new expressionStatement(\n- &launchBlock,\n- *(new identifierNode(forSmnt.source,\n- \"outer.dims = \" + occa::toString(outerDims)))\n- ))\n- );\n- launchBlock.addFirst(\n- *(new expressionStatement(\n- &launchBlock,\n- *(new identifierNode(forSmnt.source,\n- \"occa::dim outer, inner\"))\n- ))\n- );\n- // Wrap kernel\n- std::stringstream ss;\n- ss << \"occa::kernel kernel(deviceKernel[\"\n- << kernelIndex\n- << \"])\";\n- launchBlock.add(\n- *(new expressionStatement(\n- &launchBlock,\n- *(new identifierNode(forSmnt.source,\n- ss.str()))\n- ))\n- );\n- // Set run dims\n- launchBlock.add(\n- *(new expressionStatement(\n- &launchBlock,\n- *(new identifierNode(forSmnt.source,\n- \"kernel.setRunDims(outer, inner)\"))\n- ))\n- );\n- // launch kernel\n- std::string kernelCall = \"kernel(\";\n+ // Kernel launch\n+ std::string kernelLaunch = \"kernel(\";\nfunction_t &func = kernelSmnt.function();\nconst int argCount = (int) func.args.size();\nfor (int i = 0; i < argCount; ++i) {\nvariable_t &arg = *(func.args[i]);\nif (i) {\n- kernelCall += \", \";\n+ kernelLaunch += \", \";\n}\n- kernelCall += arg.name();\n+ kernelLaunch += arg.name();\n}\n- kernelCall += ')';\n+ kernelLaunch += \");\";\n+\n+ array<std::string> initSource = {\n+ \"occa::dim outer, inner;\",\n+ \"outer.dims = \" + occa::toString(outerDims) + \";\",\n+ \"inner.dims = \" + occa::toString(innerDims) + \";\"\n+ };\n+\n+ array<std::string> kernelLaunchSource = {\n+ \"occa::kernel kernel(deviceKernel[\" + occa::toString(kernelIndex) + \"]);\",\n+ \"kernel.setRunDims(outer, inner);\",\n+ kernelLaunch\n+ };\n+\n+ // We need to insert them at the top in reverse order\n+ initSource.reverse().forEach([&](std::string str) {\n+ launchBlock.addFirst(\n+ *new sourceCodeStatement(&launchBlock, forSmnt.source, str)\n+ );\n+ });\n+\n+ kernelLaunchSource.forEach([&](std::string str) {\nlaunchBlock.add(\n- *(new expressionStatement(\n- &launchBlock,\n- *(new identifierNode(forSmnt.source,\n- kernelCall))\n- ))\n+ *new sourceCodeStatement(&launchBlock, forSmnt.source, str)\n);\n+ });\nforSmnt.removeFromParent();\n" }, { "change_type": "MODIFY", "old_path": "src/lang/preprocessor.cpp", "new_path": "src/lang/preprocessor.cpp", "diff": "@@ -91,6 +91,9 @@ namespace occa {\naddCompilerDefine(\"__OKL__\" , \"1\");\naddCompilerDefine(\"__OCCA__\" , \"1\");\n+ const std::string mode = settings.get<std::string>(\"mode\", \"\");\n+ addCompilerDefine(\"OKL_MODE\", \"\\\"\" + uppercase(mode) + \"\\\"\");\n+\n// Add kernel hash as a define\nstd::string hashValue = settings.get<std::string>(\"hash\", \"\");\nif (hashValue.size()) {\n@@ -231,125 +234,125 @@ namespace occa {\n}\nvoid preprocessor_t::initStandardHeaders() {\n- standardHeaders[\"algorithm\"] = true;\n- standardHeaders[\"any\"] = true;\n- standardHeaders[\"array\"] = true;\n- standardHeaders[\"assert.h\"] = true;\n- standardHeaders[\"atomic\"] = true;\n- standardHeaders[\"bitset\"] = true;\n- standardHeaders[\"cassert\"] = true;\n- standardHeaders[\"ccomplex\"] = true;\n- standardHeaders[\"cctype\"] = true;\n- standardHeaders[\"cerrno\"] = true;\n- standardHeaders[\"cfenv\"] = true;\n- standardHeaders[\"cfloat\"] = true;\n- standardHeaders[\"charconv\"] = true;\n- standardHeaders[\"chrono\"] = true;\n- standardHeaders[\"cinttypes\"] = true;\n- standardHeaders[\"ciso646\"] = true;\n- standardHeaders[\"climits\"] = true;\n- standardHeaders[\"clocale\"] = true;\n- standardHeaders[\"cmath\"] = true;\n- standardHeaders[\"codecvt\"] = true;\n- standardHeaders[\"compare\"] = true;\n- standardHeaders[\"complex.h\"] = true;\n- standardHeaders[\"complex\"] = true;\n- standardHeaders[\"condition_variable\"] = true;\n- standardHeaders[\"csetjmp\"] = true;\n- standardHeaders[\"csignal\"] = true;\n- standardHeaders[\"cstdalign\"] = true;\n- standardHeaders[\"cstdarg\"] = true;\n- standardHeaders[\"cstdbool\"] = true;\n- standardHeaders[\"cstddef\"] = true;\n- standardHeaders[\"cstdint\"] = true;\n- standardHeaders[\"cstdio\"] = true;\n- standardHeaders[\"cstdlib\"] = true;\n- standardHeaders[\"cstring\"] = true;\n- standardHeaders[\"ctgmath\"] = true;\n- standardHeaders[\"ctime\"] = true;\n- standardHeaders[\"ctype.h\"] = true;\n- standardHeaders[\"cuchar\"] = true;\n- standardHeaders[\"cwchar\"] = true;\n- standardHeaders[\"cwctype\"] = true;\n- standardHeaders[\"deque\"] = true;\n- standardHeaders[\"errno.h\"] = true;\n- standardHeaders[\"exception\"] = true;\n- standardHeaders[\"execution\"] = true;\n- standardHeaders[\"fenv.h\"] = true;\n- standardHeaders[\"filesystem\"] = true;\n- standardHeaders[\"float.h\"] = true;\n- standardHeaders[\"forward_list\"] = true;\n- standardHeaders[\"fstream\"] = true;\n- standardHeaders[\"functional\"] = true;\n- standardHeaders[\"future\"] = true;\n- standardHeaders[\"initializer_list\"] = true;\n- standardHeaders[\"inttypes.h\"] = true;\n- standardHeaders[\"iomanip\"] = true;\n- standardHeaders[\"ios\"] = true;\n- standardHeaders[\"iosfwd\"] = true;\n- standardHeaders[\"iostream\"] = true;\n- standardHeaders[\"iso646.h\"] = true;\n- standardHeaders[\"istream\"] = true;\n- standardHeaders[\"iterator\"] = true;\n- standardHeaders[\"limits.h\"] = true;\n- standardHeaders[\"limits\"] = true;\n- standardHeaders[\"list\"] = true;\n- standardHeaders[\"locale.h\"] = true;\n- standardHeaders[\"locale\"] = true;\n- standardHeaders[\"map\"] = true;\n- standardHeaders[\"math.h\"] = true;\n- standardHeaders[\"memory\"] = true;\n- standardHeaders[\"memory_resource\"] = true;\n- standardHeaders[\"mutex\"] = true;\n- standardHeaders[\"new\"] = true;\n- standardHeaders[\"numeric\"] = true;\n- standardHeaders[\"optional\"] = true;\n- standardHeaders[\"ostream\"] = true;\n- standardHeaders[\"queue\"] = true;\n- standardHeaders[\"random\"] = true;\n- standardHeaders[\"ratio\"] = true;\n- standardHeaders[\"regex\"] = true;\n- standardHeaders[\"scoped_allocator\"] = true;\n- standardHeaders[\"set\"] = true;\n- standardHeaders[\"setjmp.h\"] = true;\n- standardHeaders[\"shared_mutex\"] = true;\n- standardHeaders[\"signal.h\"] = true;\n- standardHeaders[\"sstream\"] = true;\n- standardHeaders[\"stack\"] = true;\n- standardHeaders[\"stdalign.h\"] = true;\n- standardHeaders[\"stdarg.h\"] = true;\n- standardHeaders[\"stdatomic.h\"] = true;\n- standardHeaders[\"stdbool.h\"] = true;\n- standardHeaders[\"stddef.h\"] = true;\n- standardHeaders[\"stdexcept\"] = true;\n- standardHeaders[\"stdint.h\"] = true;\n- standardHeaders[\"stdio.h\"] = true;\n- standardHeaders[\"stdlib.h\"] = true;\n- standardHeaders[\"stdnoreturn.h\"] = true;\n- standardHeaders[\"streambuf\"] = true;\n- standardHeaders[\"string.h\"] = true;\n- standardHeaders[\"string\"] = true;\n- standardHeaders[\"string_view\"] = true;\n- standardHeaders[\"strstream\"] = true;\n- standardHeaders[\"syncstream\"] = true;\n- standardHeaders[\"system_error\"] = true;\n- standardHeaders[\"tgmath.h\"] = true;\n- standardHeaders[\"thread\"] = true;\n- standardHeaders[\"threads.h\"] = true;\n- standardHeaders[\"time.h\"] = true;\n- standardHeaders[\"tuple\"] = true;\n- standardHeaders[\"type_traits\"] = true;\n- standardHeaders[\"typeindex\"] = true;\n- standardHeaders[\"typeinfo\"] = true;\n- standardHeaders[\"uchar.h\"] = true;\n- standardHeaders[\"unordered_map\"] = true;\n- standardHeaders[\"unordered_set\"] = true;\n- standardHeaders[\"utility\"] = true;\n- standardHeaders[\"valarray\"] = true;\n- standardHeaders[\"variant\"] = true;\n- standardHeaders[\"vector\"] = true;\n- standardHeaders[\"wchar.h\"] = true;\n- standardHeaders[\"wctype.h\"] = true;\n+ standardHeaders.insert(\"algorithm\");\n+ standardHeaders.insert(\"any\");\n+ standardHeaders.insert(\"array\");\n+ standardHeaders.insert(\"assert.h\");\n+ standardHeaders.insert(\"atomic\");\n+ standardHeaders.insert(\"bitset\");\n+ standardHeaders.insert(\"cassert\");\n+ standardHeaders.insert(\"ccomplex\");\n+ standardHeaders.insert(\"cctype\");\n+ standardHeaders.insert(\"cerrno\");\n+ standardHeaders.insert(\"cfenv\");\n+ standardHeaders.insert(\"cfloat\");\n+ standardHeaders.insert(\"charconv\");\n+ standardHeaders.insert(\"chrono\");\n+ standardHeaders.insert(\"cinttypes\");\n+ standardHeaders.insert(\"ciso646\");\n+ standardHeaders.insert(\"climits\");\n+ standardHeaders.insert(\"clocale\");\n+ standardHeaders.insert(\"cmath\");\n+ standardHeaders.insert(\"codecvt\");\n+ standardHeaders.insert(\"compare\");\n+ standardHeaders.insert(\"complex.h\");\n+ standardHeaders.insert(\"complex\");\n+ standardHeaders.insert(\"condition_variable\");\n+ standardHeaders.insert(\"csetjmp\");\n+ standardHeaders.insert(\"csignal\");\n+ standardHeaders.insert(\"cstdalign\");\n+ standardHeaders.insert(\"cstdarg\");\n+ standardHeaders.insert(\"cstdbool\");\n+ standardHeaders.insert(\"cstddef\");\n+ standardHeaders.insert(\"cstdint\");\n+ standardHeaders.insert(\"cstdio\");\n+ standardHeaders.insert(\"cstdlib\");\n+ standardHeaders.insert(\"cstring\");\n+ standardHeaders.insert(\"ctgmath\");\n+ standardHeaders.insert(\"ctime\");\n+ standardHeaders.insert(\"ctype.h\");\n+ standardHeaders.insert(\"cuchar\");\n+ standardHeaders.insert(\"cwchar\");\n+ standardHeaders.insert(\"cwctype\");\n+ standardHeaders.insert(\"deque\");\n+ standardHeaders.insert(\"errno.h\");\n+ standardHeaders.insert(\"exception\");\n+ standardHeaders.insert(\"execution\");\n+ standardHeaders.insert(\"fenv.h\");\n+ standardHeaders.insert(\"filesystem\");\n+ standardHeaders.insert(\"float.h\");\n+ standardHeaders.insert(\"forward_list\");\n+ standardHeaders.insert(\"fstream\");\n+ standardHeaders.insert(\"functional\");\n+ standardHeaders.insert(\"future\");\n+ standardHeaders.insert(\"initializer_list\");\n+ standardHeaders.insert(\"inttypes.h\");\n+ standardHeaders.insert(\"iomanip\");\n+ standardHeaders.insert(\"ios\");\n+ standardHeaders.insert(\"iosfwd\");\n+ standardHeaders.insert(\"iostream\");\n+ standardHeaders.insert(\"iso646.h\");\n+ standardHeaders.insert(\"istream\");\n+ standardHeaders.insert(\"iterator\");\n+ standardHeaders.insert(\"limits.h\");\n+ standardHeaders.insert(\"limits\");\n+ standardHeaders.insert(\"list\");\n+ standardHeaders.insert(\"locale.h\");\n+ standardHeaders.insert(\"locale\");\n+ standardHeaders.insert(\"map\");\n+ standardHeaders.insert(\"math.h\");\n+ standardHeaders.insert(\"memory\");\n+ standardHeaders.insert(\"memory_resource\");\n+ standardHeaders.insert(\"mutex\");\n+ standardHeaders.insert(\"new\");\n+ standardHeaders.insert(\"numeric\");\n+ standardHeaders.insert(\"optional\");\n+ standardHeaders.insert(\"ostream\");\n+ standardHeaders.insert(\"queue\");\n+ standardHeaders.insert(\"random\");\n+ standardHeaders.insert(\"ratio\");\n+ standardHeaders.insert(\"regex\");\n+ standardHeaders.insert(\"scoped_allocator\");\n+ standardHeaders.insert(\"set\");\n+ standardHeaders.insert(\"setjmp.h\");\n+ standardHeaders.insert(\"shared_mutex\");\n+ standardHeaders.insert(\"signal.h\");\n+ standardHeaders.insert(\"sstream\");\n+ standardHeaders.insert(\"stack\");\n+ standardHeaders.insert(\"stdalign.h\");\n+ standardHeaders.insert(\"stdarg.h\");\n+ standardHeaders.insert(\"stdatomic.h\");\n+ standardHeaders.insert(\"stdbool.h\");\n+ standardHeaders.insert(\"stddef.h\");\n+ standardHeaders.insert(\"stdexcept\");\n+ standardHeaders.insert(\"stdint.h\");\n+ standardHeaders.insert(\"stdio.h\");\n+ standardHeaders.insert(\"stdlib.h\");\n+ standardHeaders.insert(\"stdnoreturn.h\");\n+ standardHeaders.insert(\"streambuf\");\n+ standardHeaders.insert(\"string.h\");\n+ standardHeaders.insert(\"string\");\n+ standardHeaders.insert(\"string_view\");\n+ standardHeaders.insert(\"strstream\");\n+ standardHeaders.insert(\"syncstream\");\n+ standardHeaders.insert(\"system_error\");\n+ standardHeaders.insert(\"tgmath.h\");\n+ standardHeaders.insert(\"thread\");\n+ standardHeaders.insert(\"threads.h\");\n+ standardHeaders.insert(\"time.h\");\n+ standardHeaders.insert(\"tuple\");\n+ standardHeaders.insert(\"type_traits\");\n+ standardHeaders.insert(\"typeindex\");\n+ standardHeaders.insert(\"typeinfo\");\n+ standardHeaders.insert(\"uchar.h\");\n+ standardHeaders.insert(\"unordered_map\");\n+ standardHeaders.insert(\"unordered_set\");\n+ standardHeaders.insert(\"utility\");\n+ standardHeaders.insert(\"valarray\");\n+ standardHeaders.insert(\"variant\");\n+ standardHeaders.insert(\"vector\");\n+ standardHeaders.insert(\"wchar.h\");\n+ standardHeaders.insert(\"wctype.h\");\n}\nvoid preprocessor_t::warningOn(token_t *token,\n" }, { "change_type": "ADD", "old_path": null, "new_path": "src/lang/statement/sourceCodeStatement.cpp", "diff": "+#include <occa/lang/statement/sourceCodeStatement.hpp>\n+#include <occa/lang/utils/array.hpp>\n+#include <occa/tools/string.hpp>\n+\n+namespace occa {\n+ namespace lang {\n+ sourceCodeStatement::sourceCodeStatement(blockStatement *up_,\n+ token_t *sourceToken,\n+ const std::string &sourceCode_) :\n+ statement_t(up_, sourceToken),\n+ sourceCode(sourceCode_) {}\n+\n+ sourceCodeStatement::sourceCodeStatement(blockStatement *up_,\n+ const sourceCodeStatement &other) :\n+ statement_t(up_, other),\n+ sourceCode(other.sourceCode) {}\n+\n+ sourceCodeStatement::~sourceCodeStatement() {}\n+\n+ statement_t& sourceCodeStatement::clone_(blockStatement *up_) const {\n+ return *(new sourceCodeStatement(up_, *this));\n+ }\n+\n+ int sourceCodeStatement::type() const {\n+ return statementType::sourceCode;\n+ }\n+\n+ std::string sourceCodeStatement::statementName() const {\n+ return \"source code\";\n+ }\n+\n+ void sourceCodeStatement::print(printer &pout) const {\n+ array<std::string> lines = split(sourceCode, '\\n');\n+\n+ lines.forEach([&](std::string line) {\n+ pout.printStartIndentation();\n+ pout << strip(line);\n+ pout.printEndNewline();\n+ });\n+ }\n+ }\n+}\n" }, { "change_type": "MODIFY", "old_path": "src/lang/statement/statement.cpp", "new_path": "src/lang/statement/statement.cpp", "diff": "@@ -48,6 +48,8 @@ namespace occa {\nconst int attribute = (1 << 28);\n+ const int sourceCode = (1 << 29);\n+\nconst int blockStatements = (\nblock |\nelif_ |\n" }, { "change_type": "MODIFY", "old_path": "tests/src/lang/preprocessor.cpp", "new_path": "tests/src/lang/preprocessor.cpp", "diff": "@@ -519,6 +519,7 @@ void testOccaMacros() {\nocca::properties preprocessorSettings;\npreprocessorSettings[\"hash\"] = hash.getFullString();\n+ preprocessorSettings[\"mode\"] = \"CUDA\";\npreprocessor.setSettings(preprocessorSettings);\n@@ -528,6 +529,7 @@ void testOccaMacros() {\n\"OCCA_PATCH_VERSION\\n\"\n\"OCCA_VERSION\\n\"\n\"OKL_VERSION\\n\"\n+ \"OKL_MODE\\n\"\n\"__OKL__\\n\"\n\"__OCCA__\\n\"\n\"OKL_KERNEL_HASH\\n\"\n@@ -543,12 +545,19 @@ void testOccaMacros() {\n(int) nextTokenPrimitiveValue());\nASSERT_EQ(OKL_VERSION,\n(int) nextTokenPrimitiveValue());\n+\n+ // OKL_MODE\n+ ASSERT_EQ(\"CUDA\",\n+ nextTokenStringValue());\n+\n// __OKL__\nASSERT_EQ(1,\n(int) nextTokenPrimitiveValue());\n+\n// __OCCA__\nASSERT_EQ(1,\n(int) nextTokenPrimitiveValue());\n+\n// OKL_KERNEL_HASH\nASSERT_EQ(hash.getString(),\nnextTokenStringValue());\n" } ]
C++
MIT License
libocca/occa
[Lang] Adds source code statement (#409)
378,341
30.10.2020 04:20:57
-3,600
f564ad343f899d458b53722a8b53dab908432cb0
[CLI] Report OCCA_MPI_ENABLED
[ { "change_type": "MODIFY", "old_path": "src/bin/occa.cpp", "new_path": "src/bin/occa.cpp", "diff": "@@ -249,6 +249,7 @@ namespace occa {\n<< \" - OCCA_HIP_ENABLED : \" << envEcho(\"OCCA_HIP_ENABLED\", OCCA_HIP_ENABLED) << \"\\n\"\n<< \" - OCCA_OPENCL_ENABLED : \" << envEcho(\"OCCA_OPENCL_ENABLED\", OCCA_OPENCL_ENABLED) << \"\\n\"\n<< \" - OCCA_METAL_ENABLED : \" << envEcho(\"OCCA_METAL_ENABLED\", OCCA_METAL_ENABLED) << \"\\n\"\n+ << \" - OCCA_MPI_ENABLED : \" << envEcho(\"OCCA_MPI_ENABLED\", OCCA_MPI_ENABLED) << \"\\n\"\n<< \" Run-Time Options:\\n\"\n<< \" - OCCA_CXX : \" << envEcho(\"OCCA_CXX\") << \"\\n\"\n" } ]
C++
MIT License
libocca/occa
[CLI] Report OCCA_MPI_ENABLED (#412)
378,341
30.10.2020 04:21:50
-3,600
02b2986348c7c0232110cd68445ef3c0252152cb
[Fix] shadowing warnings
[ { "change_type": "MODIFY", "old_path": "src/lang/expr/expressionParser.cpp", "new_path": "src/lang/expr/expressionParser.cpp", "diff": "@@ -171,8 +171,8 @@ namespace occa {\nfreeTokenVector(tokens);\n}\n- exprNode* expressionParser::parse(tokenVector &tokens) {\n- expressionParser parser(tokens);\n+ exprNode* expressionParser::parse(tokenVector &tokens_) {\n+ expressionParser parser(tokens_);\nreturn parser.parse();\n}\n" }, { "change_type": "MODIFY", "old_path": "src/lang/modes/oklForStatement.cpp", "new_path": "src/lang/modes/oklForStatement.cpp", "diff": "@@ -358,8 +358,8 @@ namespace occa {\nreturn getOklLoopIndex(forSmnt, oklAttr);\n}\n- int oklForStatement::getOklLoopIndex(forStatement &forSmnt, const std::string &oklAttr) {\n- attributeToken_t &oklAttrToken = forSmnt.attributes[oklAttr];\n+ int oklForStatement::getOklLoopIndex(forStatement &forSmnt_, const std::string &oklAttr_) {\n+ attributeToken_t &oklAttrToken = forSmnt_.attributes[oklAttr_];\nif (oklAttrToken.args.size()) {\n// The attribute is either @outer(N) or @inner(N)\n// We need to evaluate the value inside the attribute first though\n@@ -369,7 +369,7 @@ namespace occa {\n// Find index by looking at how many for-loops of the same attribute are in it\nint maxInnerCount = 0;\nforOklForLoopStatements(\n- forSmnt,\n+ forSmnt_,\n[&](forStatement &innerForSmnt,\nconst std::string innerAttr,\nconst statementArray &path) {\n@@ -378,7 +378,7 @@ namespace occa {\npath\n.filter([&](statement_t *smnt) {\nreturn ((smnt->type() & statementType::for_)\n- && smnt->hasAttribute(oklAttr));\n+ && smnt->hasAttribute(oklAttr_));\n})\n.length()\n);\n@@ -396,9 +396,9 @@ namespace occa {\nreturn getOklLoopPath(forSmnt);\n}\n- statementArray oklForStatement::getOklLoopPath(forStatement &forSmnt) {\n+ statementArray oklForStatement::getOklLoopPath(forStatement &forSmnt_) {\nstatementArray oklParentPath = (\n- forSmnt\n+ forSmnt_\n.getParentPath()\n.filter([&](statement_t *smnt) {\nreturn (\n@@ -410,9 +410,9 @@ namespace occa {\n})\n);\n- // forSmnt is not in the getParentPath() list\n+ // forSmnt_ is not in the getParentPath() list\n// so we need to push it manually\n- oklParentPath.push(&forSmnt);\n+ oklParentPath.push(&forSmnt_);\nreturn oklParentPath;\n}\n" } ]
C++
MIT License
libocca/occa
[Fix] shadowing warnings (#414)
378,349
30.10.2020 00:29:29
14,400
b606b91766f12d244dd5eb03efb5ca195e9f3202
[Lang] Adds support for U/L/LL suffix on hex/binary primitives
[ { "change_type": "MODIFY", "old_path": "include/occa/lang/primitive.hpp", "new_path": "include/occa/lang/primitive.hpp", "diff": "@@ -53,6 +53,7 @@ namespace occa {\nclass primitive {\npublic:\nint type;\n+ std::string source;\nunion {\nbool bool_;\n@@ -79,12 +80,14 @@ namespace occa {\n}\ninline primitive(const primitive &p) :\n- type(p.type) {\n+ type(p.type),\n+ source(p.source) {\nvalue.ptr = p.value.ptr;\n}\ninline primitive& operator = (const primitive &p) {\ntype = p.type;\n+ source = p.source;\nvalue.ptr = p.value.ptr;\nreturn *this;\n}\n@@ -327,6 +330,8 @@ namespace occa {\n}\nstd::string toString() const;\n+ std::string toBinaryString() const;\n+ std::string toHexString() const;\nfriend io::output& operator << (io::output &out,\nconst primitive &p);\n" }, { "change_type": "MODIFY", "old_path": "src/lang/primitive.cpp", "new_path": "src/lang/primitive.cpp", "diff": "@@ -13,9 +13,9 @@ namespace occa {\nconst char *c = s.c_str();\n*this = load(c);\n}\n-\nprimitive primitive::load(const char *&c,\nconst bool includeSign) {\n+ bool loadedFormattedValue = false;\nbool unsigned_ = false;\nbool negative = false;\nbool decimal = false;\n@@ -28,18 +28,22 @@ namespace occa {\nif (strncmp(c, \"true\", 4) == 0) {\np = true;\n+ p.source = \"true\";\n+\nc += 4;\nreturn p;\n}\nif (strncmp(c, \"false\", 5) == 0) {\np = false;\n+ p.source = \"false\";\n+\nc += 5;\nreturn p;\n}\nif ((*c == '+') || (*c == '-')) {\nif (!includeSign) {\n- return p;\n+ return primitive();\n}\nnegative = (*c == '-');\n++c;\n@@ -51,21 +55,24 @@ namespace occa {\n++c;\nconst char C = uppercase(*c);\nif ((C == 'B') || (C == 'X')) {\n+ loadedFormattedValue = true;\n+\nif (C == 'B') {\np = primitive::loadBinary(++c, negative);\n} else if (C == 'X') {\np = primitive::loadHex(++c, negative);\n}\n+\nif (p.type & primitiveType::none) {\nc = c0;\nreturn primitive();\n}\n- return p;\n} else {\n--c;\n}\n}\n+ if (!loadedFormattedValue) {\nwhile (true) {\nif (('0' <= *c) && (*c <= '9')) {\n++digits;\n@@ -76,9 +83,11 @@ namespace occa {\n}\n++c;\n}\n+ }\n- if (!digits) {\n+ if (!loadedFormattedValue && !digits) {\nc = c0;\n+ p.source = std::string(c0, c - c0);\nreturn p;\n}\n@@ -90,7 +99,8 @@ namespace occa {\n} else if (C == 'U') {\nunsigned_ = true;\n++c;\n- } else if (C == 'E') {\n+ } else if (!loadedFormattedValue) {\n+ if (C == 'E') {\nprimitive exp = primitive::load(++c);\n// Check if there was an 'F' in exp\ndecimal = true;\n@@ -102,8 +112,28 @@ namespace occa {\n} else {\nbreak;\n}\n+ } else {\n+ break;\n+ }\n}\n+ if (loadedFormattedValue) {\n+ // Hex and binary only handle U, L, and LL\n+ if (longs == 0) {\n+ if (unsigned_) {\n+ p = p.to<uint32_t>();\n+ } else {\n+ p = p.to<int32_t>();\n+ }\n+ } else if (longs >= 1) {\n+ if (unsigned_) {\n+ p = p.to<uint64_t>();\n+ } else {\n+ p = p.to<int64_t>();\n+ }\n+ }\n+ } else {\n+ // Handle the multiple other formats with normal digits\nif (decimal || float_) {\nif (float_) {\np = (float) occa::atof(std::string(c0, c - c0));\n@@ -126,7 +156,9 @@ namespace occa {\n}\n}\n}\n+ }\n+ p.source = std::string(c0, c - c0);\nreturn p;\n}\n@@ -154,9 +186,10 @@ namespace occa {\nreturn isNegative ? primitive((int16_t) -value_) : primitive((uint16_t) value_);\n} else if (bits < 32) {\nreturn isNegative ? primitive((int32_t) -value_) : primitive((uint32_t) value_);\n- }\n+ } else {\nreturn isNegative ? primitive((int64_t) -value_) : primitive((uint64_t) value_);\n}\n+ }\nprimitive primitive::loadHex(const char *&c, const bool isNegative) {\nconst char *c0 = c;\n@@ -172,6 +205,7 @@ namespace occa {\n}\n++c;\n}\n+\nif (c == c0) {\nreturn primitive();\n}\n@@ -183,11 +217,16 @@ namespace occa {\nreturn isNegative ? primitive((int16_t) -value_) : primitive((uint16_t) value_);\n} else if (bits < 32) {\nreturn isNegative ? primitive((int32_t) -value_) : primitive((uint32_t) value_);\n- }\n+ } else {\nreturn isNegative ? primitive((int64_t) -value_) : primitive((uint64_t) value_);\n}\n+ }\nstd::string primitive::toString() const {\n+ if (source.size()) {\n+ return source;\n+ }\n+\nstd::string str;\nswitch (type) {\ncase primitiveType::bool_ : str = (value.bool_ ? \"true\" : \"false\"); break;\n" }, { "change_type": "MODIFY", "old_path": "tests/src/lang/primitive.cpp", "new_path": "tests/src/lang/primitive.cpp", "diff": "@@ -110,6 +110,14 @@ void testLoad() {\n(double) occa::primitive(\"150.1E-1\"));\nASSERT_EQ(-15.01,\n(double) occa::primitive(\"-150.1E-1\"));\n+\n+ ASSERT_TRUE(!!(occa::primitive(\"0x7f800000U\").type & occa::primitiveType::isUnsigned));\n+\n+ ASSERT_TRUE(!!(occa::primitive(\"0x7f800000L\").type & occa::primitiveType::int64_));\n+ ASSERT_TRUE(!!(occa::primitive(\"0x7f800000LL\").type & occa::primitiveType::int64_));\n+\n+ ASSERT_TRUE(!!(occa::primitive(\"0x7f800000UL\").type & occa::primitiveType::uint64_));\n+ ASSERT_TRUE(!!(occa::primitive(\"0x7f800000LLU\").type & occa::primitiveType::uint64_));\n}\nvoid testBadParsing() {\n@@ -145,9 +153,18 @@ void testBadParsing() {\n}\nvoid testToString() {\n- ASSERT_EQ(\"68719476735L\",\n+ ASSERT_EQ(\"0xFFFFFFFFF\",\nocca::primitive(\"0xFFFFFFFFF\").toString());\n+ ASSERT_EQ(\"0x7f800000U\",\n+ occa::primitive(\"0x7f800000U\").toString());\n+\n+ ASSERT_EQ(\"0x7f800000L\",\n+ occa::primitive(\"0x7f800000L\").toString());\n+\n+ ASSERT_EQ(\"0x7f800000LL\",\n+ occa::primitive(\"0x7f800000LL\").toString());\n+\nASSERT_EQ(\"NaN\",\nocca::primitive(\"\").toString());\n}\n" } ]
C++
MIT License
libocca/occa
[Lang] Adds support for U/L/LL suffix on hex/binary primitives (#416)
378,349
30.10.2020 23:53:48
14,400
3eb4fe25bcff55a2f336d9df5ffb92d4270ec9ca
[Lang] Add initialization
[ { "change_type": "MODIFY", "old_path": "src/lang/modes/serial.cpp", "new_path": "src/lang/modes/serial.cpp", "diff": "@@ -193,19 +193,27 @@ namespace occa {\nstatementArray::from(root)\n.flatFilterByStatementType(statementType::for_, \"inner\")\n.forEach([&](statement_t *smnt) {\n- const statementArray path = smnt->getParentPath();\nconst bool hasExclusiveUsage = smnt->hasInScope(exclusiveIndexName);\n+ if (!hasExclusiveUsage) {\n+ return;\n+ }\n- if (hasExclusiveUsage) {\nloopsWithExclusiveUsage.insert(smnt);\n+ statementArray path = smnt->getParentPath();\n+\n// Get outer-most inner loop\n+ bool isInnerMostInnerLoop = true;\nfor (auto pathSmnt : path) {\nif (pathSmnt->hasAttribute(\"inner\")) {\nouterMostInnerLoops.insert(pathSmnt);\n+ isInnerMostInnerLoop = false;\nbreak;\n}\n}\n+\n+ if (isInnerMostInnerLoop) {\n+ outerMostInnerLoops.insert(smnt);\n}\n// Remove parent \"inner\" loops from the innerMostInnerLoops set\n@@ -217,6 +225,7 @@ namespace occa {\n}\n});\n+ // Initialize the exclusive index to 0 before the outer-most inner loop\nfor (auto smnt : outerMostInnerLoops) {\nforStatement &forSmnt = (forStatement&) *smnt;\nkeyword_t &keyword = forSmnt.getScopeKeyword(exclusiveIndexName);\n@@ -238,6 +247,7 @@ namespace occa {\n);\n}\n+ // Increment the exclusive index in the inner-most inner loop\nfor (auto smnt : innerMostInnerLoops) {\nforStatement &forSmnt = (forStatement&) *smnt;\nkeyword_t &keyword = forSmnt.getScopeKeyword(exclusiveIndexName);\n" } ]
C++
MIT License
libocca/occa
[Lang] Add @.exclusive initialization (#417)
378,349
01.11.2020 11:11:18
18,000
a6c68ffb065f4553ad75b14a1a10c94f844b58b3
[CLI] Does proper file completion
[ { "change_type": "MODIFY", "old_path": "src/tools/cli.cpp", "new_path": "src/tools/cli.cpp", "diff": "@@ -828,12 +828,11 @@ namespace occa {\n<< \" local suggestions=$(\" << fullBashCommand << \" -- \\\"${COMP_WORDS[@]}\\\")\" << std::endl\n<< \" case \\\"${suggestions}\\\" in\" << std::endl\n<< \" \" << BASH_STOPS_EXPANSION << \")\" << std::endl\n- << \" compopt -o nospace\" << std::endl\n- << \" COMPREPLY=()\" << std::endl\n+ << \" compopt -o default -o nospace\" << std::endl\n+ << \" COMPREPLY=''\" << std::endl\n<< \" ;;\" << std::endl\n<< \" \" << BASH_EXPANDS_FILES << \")\" << std::endl\n- << \" compopt -o nospace\" << std::endl\n- << \" _cd\" << std::endl\n+ << \" # Rely on the default options\" << std::endl\n<< \" ;;\" << std::endl\n<< \" *)\" << std::endl\n<< \" COMPREPLY=($(compgen -W \\\"${suggestions}\\\" -- \\\"${COMP_WORDS[COMP_CWORD]}\\\"))\" << std::endl\n@@ -841,7 +840,7 @@ namespace occa {\n<< \" esac\" << std::endl\n<< \"}\" << std::endl\n<< \"\" << std::endl\n- << \"complete -F \" << autocompleteName << \" \" << name << std::endl;\n+ << \"complete -o bashdefault -o default -F \" << autocompleteName << \" \" << name << std::endl;\n}\nvoid command::printBashSuggestions(const strVector &shellArgs) {\n" } ]
C++
MIT License
libocca/occa
[CLI] Does proper file completion (#419)
378,349
08.11.2020 11:31:59
18,000
4cc784e86459c01c8821da0a02eea3ad4fb36ef5
[QOL] Adds occa::env::setOccaCacheDir
[ { "change_type": "MODIFY", "old_path": "include/occa/tools/env.hpp", "new_path": "include/occa/tools/env.hpp", "diff": "@@ -34,6 +34,8 @@ namespace occa {\nreturn fromString<TM>(value);\n}\n+ void setOccaCacheDir(const std::string &path);\n+\nclass envInitializer_t {\npublic:\nenvInitializer_t();\n@@ -42,15 +44,17 @@ namespace occa {\nprivate:\nbool isInitialized;\n- void initSettings();\n- void initEnvironment();\n- void loadConfig();\n+ static void initSettings();\n+ static void initEnvironment();\n+ static void loadConfig();\n+\n+ static void setupCachePath();\n+ static void setupIncludePath();\n+ static void registerFileOpeners();\n- void setupCachePath();\n- void setupIncludePath();\n- void registerFileOpeners();\n+ static void cleanFileOpeners();\n- void cleanFileOpeners();\n+ friend void setOccaCacheDir(const std::string &path);\n};\nextern envInitializer_t envInitializer;\n" }, { "change_type": "MODIFY", "old_path": "src/tools/env.cpp", "new_path": "src/tools/env.cpp", "diff": "@@ -41,6 +41,11 @@ namespace occa {\nreturn \"\";\n}\n+ void setOccaCacheDir(const std::string &path) {\n+ OCCA_CACHE_DIR = path;\n+ envInitializer_t::setupCachePath();\n+ }\n+\nenvInitializer_t::envInitializer_t() :\nisInitialized(false) {\nif (isInitialized) {\n@@ -139,6 +144,7 @@ namespace occa {\n}\nvoid envInitializer_t::setupCachePath() {\n+ // Set defaults if needed\nif (env::OCCA_CACHE_DIR.size() == 0) {\nstd::stringstream ss;\n@@ -155,6 +161,7 @@ namespace occa {\n#endif\nenv::OCCA_CACHE_DIR = ss.str();\n}\n+\nenv::OCCA_CACHE_DIR = io::filename(env::OCCA_CACHE_DIR);\nio::endWithSlash(env::OCCA_CACHE_DIR);\n" } ]
C++
MIT License
libocca/occa
[QOL] Adds occa::env::setOccaCacheDir (#420)
378,348
09.11.2020 21:46:59
21,600
c0931e5dfb6a5cef280caba312eab8850d751683
Make build system understand new hipconfig output From ROCm 4.0, hipconfig --platform will output 'amd' instead of 'hcc'. This change simply proactively mitigates a potential surprise where OCCA thinks it couldn't find ROCm.
[ { "change_type": "MODIFY", "old_path": "scripts/Makefile", "new_path": "scripts/Makefile", "diff": "@@ -338,7 +338,7 @@ ifdef OCCA_HIP_ENABLED\nifeq ($(hipPlatform),nvcc)\nlinkerFlags += -lcuda\nlinkerFlags += -lcudart\n- else ifeq ($(hipPlatform),hcc)\n+ else ifeq ($(hipPlatform),$(filter $(hipPlatform),hcc amd))\n#set HIP_COMPILER if not supplied by user\nifeq (,$(HIP_COMPILER))\nhipCompiler = $(shell $(HIP_PATH)/bin/hipconfig --compiler)\n@@ -374,7 +374,7 @@ else\nifeq ($(hipPlatform),nvcc)\nhipLibFlags = $(call libraryFlagsFor,cuda)\nhipLibFlags += $(call libraryFlagsFor,cudart)\n- else ifeq ($(hipPlatform),hcc)\n+ else ifeq ($(hipPlatform),$(filter $(hipPlatform),hcc amd))\n#set HIP_COMPILER if not supplied by user\nifeq (,$(HIP_COMPILER))\nhipCompiler = $(shell $(HIP_PATH)/bin/hipconfig --compiler)\n" } ]
C++
MIT License
libocca/occa
Make build system understand new hipconfig output (#421) From ROCm 4.0, hipconfig --platform will output 'amd' instead of 'hcc'. This change simply proactively mitigates a potential surprise where OCCA thinks it couldn't find ROCm.
378,355
28.12.2020 13:26:47
21,600
246d25df0310b99d20d9792779dd41f33bf595d2
[CMake] Enable use of CMake in github actions .yml (continued from libocca/occa#342)
[ { "change_type": "MODIFY", "old_path": ".github/workflows/build.yml", "new_path": ".github/workflows/build.yml", "diff": "@@ -21,6 +21,15 @@ jobs:\nOCCA_COVERAGE: 1\nOCCA_FORTRAN_ENABLED: 1\n+ - name: (Ubuntu) CMake + gcc-8\n+ os: ubuntu-18.04\n+ CC: gcc-8\n+ CXX: g++-8\n+ CXXFLAGS: -Wno-maybe-uninitialized -Wno-cpp\n+ GCOV: gcov-8\n+ OCCA_COVERAGE: 1\n+ useCMake: true\n+\n- name: (Ubuntu) gcc-9\nos: ubuntu-18.04\nCC: gcc-9\n@@ -79,18 +88,37 @@ jobs:\n- name: Compiler info\nrun: make -j 16 info\n+ if: ${{ !matrix.useCMake }}\n+\n+ - name: CMake build\n+ run: |\n+ cmake -E make_directory ${{runner.workspace}}/occa/build\n+ cd ${{runner.workspace}}/occa/build\n+ cmake -DENABLE_TESTS=On -DENABLE_EXAMPLES=On ${{runner.workspace}}/occa\n+ make -j 16\n+ if: ${{ matrix.useCMake }}\n- name: Compile library\nrun: make -j 16\n+ if: ${{ !matrix.useCMake }}\n- name: Compile tests\nrun: make -j 16 tests\n+ if: ${{ !matrix.useCMake }}\n- name: Run unit tests\nrun: ./tests/run_tests\n+ if: ${{ !matrix.useCMake }}\n- name: Run examples\nrun: ./tests/run_examples\n+ if: ${{ !matrix.useCMake }}\n+\n+ - name: Run CTests\n+ run: |\n+ cd ${{runner.workspace}}/occa/build\n+ make test\n+ if: ${{ matrix.useCMake }}\n- name: Upload code coverage\nrun: bash <(curl --no-buffer -s https://codecov.io/bash) -x \"${GCOV}\"\n" }, { "change_type": "MODIFY", "old_path": "cmake/SetCompilerFlags.cmake", "new_path": "cmake/SetCompilerFlags.cmake", "diff": "@@ -28,10 +28,10 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL \"PGI\")\nset(CMAKE_CXX_FLAGS_RELEASE \"-O1 -DNDEBUG\")\nendif()\n-set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} ${SUPPORTED_WARN_CXX_FLAGS}\")\n+set(CMAKE_CXX_FLAGS \"${SUPPORTED_WARN_CXX_FLAGS} ${CMAKE_CXX_FLAGS}\")\nset_optional_cxx_flag(SUPPORTED_WERROR_CXX_FLAGS \"-Werror\")\n-set(CMAKE_CXX_FLAGS_DEBUG \"${CMAKE_CXX_FLAGS_DEBUG} ${SUPPORTED_WERROR_CXX_FLAGS}\")\n+set(CMAKE_CXX_FLAGS_DEBUG \"${SUPPORTED_WERROR_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG}\")\ninclude(CheckCCompilerFlag)\n@@ -56,10 +56,10 @@ set_optional_c_flag(SUPPORTED_WARN_C_FLAGS \"-Wno-c++11-long-long\")\nset_optional_c_flag(SUPPORTED_WARN_C_FLAGS \"-diag-disable 11074 -diag-disable 11076\") # Disable warnings about inline limits reached\nset_optional_c_flag(SUPPORTED_WARN_C_FLAGS \"--display_error_number\") # Show PGI error numbers\n-set(CMAKE_C_FLAGS \"${CMAKE_C_FLAGS} ${SUPPORTED_WARN_C_FLAGS}\")\n+set(CMAKE_C_FLAGS \"${SUPPORTED_WARN_C_FLAGS} ${CMAKE_C_FLAGS}\")\nset_optional_c_flag(SUPPORTED_WERROR_C_FLAGS \"-Werror\")\n-set(CMAKE_C_FLAGS_DEBUG \"${CMAKE_C_FLAGS_DEBUG} ${SUPPORTED_WERROR_C_FLAGS}\")\n+set(CMAKE_C_FLAGS_DEBUG \"${SUPPORTED_WERROR_C_FLAGS} ${CMAKE_C_FLAGS_DEBUG}\")\nif (ENABLE_FORTRAN)\ninclude(CheckFortranCompilerFlag)\n" } ]
C++
MIT License
libocca/occa
[CMake] Enable use of CMake in github actions .yml (continued from libocca/occa#342) (#425)
378,355
28.12.2020 13:27:21
21,600
902b0a9bac363f4efe81cb3e7a271da48ec5a863
[HIP] Avoid checking the error code from hipGetDeviceCount
[ { "change_type": "MODIFY", "old_path": "src/modes/hip/utils.cpp", "new_path": "src/modes/hip/utils.cpp", "diff": "@@ -18,9 +18,8 @@ namespace occa {\n}\nint getDeviceCount() {\n- int deviceCount;\n- OCCA_HIP_ERROR(\"Finding Number of Devices\",\n- hipGetDeviceCount(&deviceCount));\n+ int deviceCount=0;\n+ hipGetDeviceCount(&deviceCount);\nreturn deviceCount;\n}\n" } ]
C++
MIT License
libocca/occa
[HIP] Avoid checking the error code from hipGetDeviceCount (#426)
378,355
28.12.2020 13:29:15
21,600
5c721e64b69bda47f4f6914d43341ba81d292131
[Modes] Adding a getDeviceCount API to query number of available devices in an enabled mode
[ { "change_type": "MODIFY", "old_path": "include/occa/modes.hpp", "new_path": "include/occa/modes.hpp", "diff": "@@ -31,6 +31,8 @@ namespace occa {\nvirtual styling::section &getDescription();\nvirtual modeDevice_t* newDevice(const occa::properties &props) = 0;\n+\n+ virtual int getDeviceCount(const occa::properties &props) = 0;\n};\nstrToModeMap& getUnsafeModeMap();\n@@ -48,6 +50,8 @@ namespace occa {\nmode_t* getModeFromProps(const occa::properties &props);\nmodeDevice_t* newModeDevice(const occa::properties &props);\n+\n+ int getDeviceCount(const occa::properties &props);\n}\n#endif\n" }, { "change_type": "MODIFY", "old_path": "include/occa/modes/cuda/registration.hpp", "new_path": "include/occa/modes/cuda/registration.hpp", "diff": "@@ -21,6 +21,8 @@ namespace occa {\nstyling::section& getDescription();\nmodeDevice_t* newDevice(const occa::properties &props);\n+\n+ int getDeviceCount(const occa::properties &props);\n};\nextern cudaMode mode;\n" }, { "change_type": "MODIFY", "old_path": "include/occa/modes/hip/registration.hpp", "new_path": "include/occa/modes/hip/registration.hpp", "diff": "@@ -19,6 +19,8 @@ namespace occa {\nstyling::section& getDescription();\nmodeDevice_t* newDevice(const occa::properties &props);\n+\n+ int getDeviceCount(const occa::properties &props);\n};\nextern hipMode mode;\n" }, { "change_type": "MODIFY", "old_path": "include/occa/modes/metal/registration.hpp", "new_path": "include/occa/modes/metal/registration.hpp", "diff": "@@ -19,6 +19,8 @@ namespace occa {\nstyling::section& getDescription();\nmodeDevice_t* newDevice(const occa::properties &props);\n+\n+ int getDeviceCount(const occa::properties &props);\n};\nextern metalMode mode;\n" }, { "change_type": "MODIFY", "old_path": "include/occa/modes/opencl/registration.hpp", "new_path": "include/occa/modes/opencl/registration.hpp", "diff": "@@ -19,6 +19,8 @@ namespace occa {\nstyling::section& getDescription();\nmodeDevice_t* newDevice(const occa::properties &props);\n+\n+ int getDeviceCount(const occa::properties &props);\n};\nextern openclMode mode;\n" }, { "change_type": "MODIFY", "old_path": "include/occa/modes/openmp/registration.hpp", "new_path": "include/occa/modes/openmp/registration.hpp", "diff": "@@ -17,6 +17,8 @@ namespace occa {\nvoid setupProperties();\nmodeDevice_t* newDevice(const occa::properties &props);\n+\n+ int getDeviceCount(const occa::properties &props);\n};\nextern openmpMode mode;\n" }, { "change_type": "MODIFY", "old_path": "include/occa/modes/serial/registration.hpp", "new_path": "include/occa/modes/serial/registration.hpp", "diff": "@@ -20,6 +20,8 @@ namespace occa {\nstyling::section& getDescription();\nmodeDevice_t* newDevice(const occa::properties &props);\n+\n+ int getDeviceCount(const occa::properties &props);\n};\nextern serialMode mode;\n" }, { "change_type": "MODIFY", "old_path": "src/modes.cpp", "new_path": "src/modes.cpp", "diff": "@@ -101,4 +101,15 @@ namespace occa {\nmodeDevice_t* newModeDevice(const occa::properties &props) {\nreturn getModeFromProps(props)->newDevice(props);\n}\n+\n+ int getDeviceCount(const occa::properties &props) {\n+ std::string modeName = props[\"mode\"];\n+ mode_t *mode = getMode(modeName);\n+\n+ if (mode) {\n+ return mode->getDeviceCount(props);\n+ } else {\n+ return 0;\n+ }\n+ }\n}\n" }, { "change_type": "MODIFY", "old_path": "src/modes/cuda/registration.cpp", "new_path": "src/modes/cuda/registration.cpp", "diff": "@@ -44,6 +44,10 @@ namespace occa {\nreturn new device(setModeProp(props));\n}\n+ int cudaMode::getDeviceCount(const occa::properties &props) {\n+ return cuda::getDeviceCount();\n+ }\n+\ncudaMode mode;\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/modes/hip/registration.cpp", "new_path": "src/modes/hip/registration.cpp", "diff": "@@ -46,6 +46,10 @@ namespace occa {\nreturn new device(setModeProp(props));\n}\n+ int hipMode::getDeviceCount(const occa::properties &props) {\n+ return hip::getDeviceCount();\n+ }\n+\nhipMode mode;\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/modes/metal/registration.cpp", "new_path": "src/modes/metal/registration.cpp", "diff": "@@ -41,6 +41,10 @@ namespace occa {\nreturn new device(setModeProp(props));\n}\n+ int metalMode::getDeviceCount(const occa::properties &props) {\n+ return api::metal::getDeviceCount();\n+ }\n+\nmetalMode mode;\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/modes/opencl/registration.cpp", "new_path": "src/modes/opencl/registration.cpp", "diff": "@@ -44,6 +44,16 @@ namespace occa {\nreturn new device(setModeProp(props));\n}\n+ int openclMode::getDeviceCount(const occa::properties &props) {\n+ OCCA_ERROR(\"[OpenCL] getDeviceCount not given a [platform_id] integer\",\n+ props.has(\"platform_id\") &&\n+ props[\"platform_id\"].isNumber());\n+\n+ int platformId = props.get<int>(\"platform_id\");\n+\n+ return getDeviceCountInPlatform(platformId);\n+ }\n+\nopenclMode mode;\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/modes/openmp/registration.cpp", "new_path": "src/modes/openmp/registration.cpp", "diff": "@@ -25,6 +25,10 @@ namespace occa {\nreturn new device(setModeProp(props));\n}\n+ int openmpMode::getDeviceCount(const occa::properties &props) {\n+ return 1;\n+ }\n+\nopenmpMode mode;\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/modes/serial/registration.cpp", "new_path": "src/modes/serial/registration.cpp", "diff": "@@ -81,6 +81,10 @@ namespace occa {\nreturn new device(setModeProp(props));\n}\n+ int serialMode::getDeviceCount(const occa::properties &props) {\n+ return 1;\n+ }\n+\nserialMode mode;\n}\n}\n" } ]
C++
MIT License
libocca/occa
[Modes] Adding a getDeviceCount API to query number of available devices in an enabled mode (#427)
378,349
28.12.2020 15:21:02
18,000
ebc9e65399bbea50f292d5301adb74bc93cab929
Avoids kernel calls on noop dim sizes
[ { "change_type": "MODIFY", "old_path": "include/occa/core/kernel.hpp", "new_path": "include/occa/core/kernel.hpp", "diff": "@@ -70,6 +70,8 @@ namespace occa {\nvoid setupRun();\n+ bool isNoop() const;\n+\n//---[ Virtual Methods ]------------\nvirtual ~modeKernel_t() = 0;\n" }, { "change_type": "MODIFY", "old_path": "include/occa/types/dim.hpp", "new_path": "include/occa/types/dim.hpp", "diff": "@@ -23,7 +23,8 @@ namespace occa {\ndim operator * (const dim &d) const;\ndim operator / (const dim &d) const;\n- bool hasNegativeEntries();\n+ bool isZero() const;\n+ bool hasNegativeEntries() const;\nudim_t& operator [] (int i);\nudim_t operator [] (int i) const;\n" }, { "change_type": "MODIFY", "old_path": "src/core/kernel.cpp", "new_path": "src/core/kernel.cpp", "diff": "@@ -142,6 +142,12 @@ namespace occa {\n}\n}\n}\n+\n+ bool modeKernel_t::isNoop() const {\n+ return (\n+ outerDims.isZero() && innerDims.isZero()\n+ );\n+ }\n//====================================\n//---[ kernel ]-----------------------\n@@ -305,6 +311,10 @@ namespace occa {\nvoid kernel::run() const {\nassertInitialized();\n+ if (modeKernel->isNoop()) {\n+ return;\n+ }\n+\nmodeKernel->setupRun();\nmodeKernel->run();\n}\n" }, { "change_type": "MODIFY", "old_path": "src/types/dim.cpp", "new_path": "src/types/dim.cpp", "diff": "@@ -66,7 +66,11 @@ namespace occa {\nz / d.z);\n}\n- bool dim::hasNegativeEntries() {\n+ bool dim::isZero() const {\n+ return !(x && y && z);\n+ }\n+\n+ bool dim::hasNegativeEntries() const {\nreturn ((x & (1 << (sizeof(udim_t) - 1))) ||\n(y & (1 << (sizeof(udim_t) - 1))) ||\n(z & (1 << (sizeof(udim_t) - 1))));\n" } ]
C++
MIT License
libocca/occa
[#396] Avoids kernel calls on noop dim sizes (#431)
378,355
30.12.2020 14:39:46
21,600
9cb237c3099000f9388ec231430501d5a9681621
[Lang] Add barriers only after last inner block in each kernel, skipping last inner block
[ { "change_type": "MODIFY", "old_path": "include/occa/lang/modes/withLauncher.hpp", "new_path": "include/occa/lang/modes/withLauncher.hpp", "diff": "@@ -42,6 +42,10 @@ namespace occa {\nbool isOuterMostOklLoop(forStatement &forSmnt,\nconst std::string &attr);\n+ bool isLastInnerLoop(forStatement &forSmnt);\n+\n+ bool isInsideLoop(forStatement &forSmnt);\n+\nvoid setKernelLaunch(functionDeclStatement &kernelSmnt,\nforStatement &forSmnt,\nconst int kernelIndex);\n" }, { "change_type": "MODIFY", "old_path": "src/lang/modes/withLauncher.cpp", "new_path": "src/lang/modes/withLauncher.cpp", "diff": "@@ -139,17 +139,35 @@ namespace occa {\nbool withLauncher::isOuterMostOklLoop(forStatement &forSmnt,\nconst std::string &attr) {\n- statement_t *smnt = forSmnt.up;\n- while (smnt) {\n- if ((smnt->type() & statementType::for_)\n- && smnt->hasAttribute(attr)) {\n+ for (auto &parentSmnt : forSmnt.getParentPath()) {\n+ if (parentSmnt->type() & statementType::for_\n+ && parentSmnt->hasAttribute(attr)) {\nreturn false;\n}\n- smnt = smnt->up;\n}\nreturn true;\n}\n+ bool withLauncher::isLastInnerLoop(forStatement &forSmnt) {\n+ blockStatement &parent = *(forSmnt.up);\n+ for(int smntIndex = forSmnt.childIndex()+1; smntIndex<parent.size(); smntIndex++) {\n+ if ((parent[smntIndex]->type() & statementType::for_)\n+ && parent[smntIndex]->hasAttribute(\"inner\")) {\n+ return false;\n+ }\n+ }\n+ return true;\n+ }\n+\n+ bool withLauncher::isInsideLoop(forStatement &forSmnt) {\n+ for (auto &parentSmnt : forSmnt.getParentPath()) {\n+ if (parentSmnt->type() & (statementType::for_ | statementType::while_)) {\n+ return true;\n+ }\n+ }\n+ return false;\n+ }\n+\nvoid withLauncher::setKernelLaunch(functionDeclStatement &kernelSmnt,\nforStatement &forSmnt,\nconst int kernelIndex) {\n@@ -446,20 +464,25 @@ namespace occa {\nreplaceOccaFor(outerSmnt);\n});\n- const bool applyBarriers = usesBarriers();\n-\n+ if (usesBarriers()) {\nstatementArray::from(kernelSmnt)\n.flatFilterByAttribute(\"inner\")\n.filterByStatementType(statementType::for_)\n.forEach([&](statement_t *smnt) {\nforStatement &innerSmnt = (forStatement&) *smnt;\n- // TODO 1.1: Only apply barriers when needed in the last inner-loop\n- if (applyBarriers &&\n- isOuterMostInnerLoop(innerSmnt)) {\n+ //Only apply barriers when needed in the last inner-loop\n+ if (isOuterMostInnerLoop(innerSmnt)\n+ && (!isLastInnerLoop(innerSmnt) || isInsideLoop(innerSmnt)))\naddBarriersAfterInnerLoop(innerSmnt);\n+ });\n}\n+ statementArray::from(kernelSmnt)\n+ .flatFilterByAttribute(\"inner\")\n+ .filterByStatementType(statementType::for_)\n+ .forEach([&](statement_t *smnt) {\n+ forStatement &innerSmnt = (forStatement&) *smnt;\nreplaceOccaFor(innerSmnt);\n});\n}\n" } ]
C++
MIT License
libocca/occa
[Lang] Add barriers only after last inner block in each kernel, skipping last inner block (#424)
378,349
01.01.2021 02:14:48
18,000
d992693849c65aa0e9f4e49e2b63d09d9a75a53d
Happy New Years!
[ { "change_type": "MODIFY", "old_path": "LICENSE", "new_path": "LICENSE", "diff": "The MIT License (MIT)\n-Copyright (c) 2014-2019 David Medina and Tim Warburton\n+Copyright (c) 2014-2021 David Medina and Tim Warburton\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\n" } ]
C++
MIT License
libocca/occa
Happy New Years!
378,349
01.01.2021 22:42:21
18,000
d23f05d8b15c1af1c53272180facd65ace26df0c
[Refactor] Move modeIsEnabled back to public API
[ { "change_type": "MODIFY", "old_path": "include/occa/core/base.hpp", "new_path": "include/occa/core/base.hpp", "diff": "@@ -146,6 +146,8 @@ namespace occa {\n//====================================\n//---[ Helper Methods ]---------------\n+ bool modeIsEnabled(const std::string &mode);\n+\nint getDeviceCount(const occa::properties &props);\nvoid printModeInfo();\n" }, { "change_type": "MODIFY", "old_path": "src/core/base.cpp", "new_path": "src/core/base.cpp", "diff": "@@ -253,6 +253,10 @@ namespace occa {\n//====================================\n//---[ Helper Methods ]---------------\n+ bool modeIsEnabled(const std::string &mode) {\n+ return getMode(mode);\n+ }\n+\nint getDeviceCount(const occa::properties &props) {\nstd::string modeName = props[\"mode\"];\nmode_t *mode = getMode(modeName);\n" }, { "change_type": "MODIFY", "old_path": "src/occa/internal/modes.cpp", "new_path": "src/occa/internal/modes.cpp", "diff": "@@ -66,10 +66,6 @@ namespace occa {\nisInitialized = true;\n}\n- bool modeIsEnabled(const std::string &mode) {\n- return getMode(mode);\n- }\n-\nmode_t* getMode(const std::string &mode) {\nconst std::string caseInsensitiveMode = lowercase(mode);\nstrToModeMap &modeMap = getModeMap();\n" }, { "change_type": "MODIFY", "old_path": "src/occa/internal/modes.hpp", "new_path": "src/occa/internal/modes.hpp", "diff": "@@ -43,8 +43,6 @@ namespace occa {\nvoid initializeModes();\n- bool modeIsEnabled(const std::string &mode);\n-\nmode_t* getMode(const std::string &mode);\nmode_t* getModeFromProps(const occa::properties &props);\n" } ]
C++
MIT License
libocca/occa
[Refactor] Move modeIsEnabled back to public API (#436)
378,349
01.01.2021 23:36:02
18,000
c596688eba56dc2c6c45aae04128be260fedc7c0
[HIP] Update ptr ref hackery
[ { "change_type": "MODIFY", "old_path": "src/occa/internal/modes/hip/memory.cpp", "new_path": "src/occa/internal/modes/hip/memory.cpp", "diff": "@@ -12,11 +12,7 @@ namespace occa {\nudim_t size_,\nconst occa::properties &properties_) :\nocca::modeMemory_t(modeDevice_, size_, properties_),\n-#ifdef __HIP_PLATFORM_HCC__\n- hipPtr(ptr),\n-#else\n- hipPtr((hipDeviceptr_t&) ptr),\n-#endif\n+ hipPtr(reinterpret_cast<hipDeviceptr_t&>(ptr)),\nmappedPtr(NULL) {}\nmemory::~memory() {\n" }, { "change_type": "MODIFY", "old_path": "src/occa/internal/modes/hip/memory.hpp", "new_path": "src/occa/internal/modes/hip/memory.hpp", "diff": "@@ -19,7 +19,7 @@ namespace occa {\nfriend void* getMappedPtr(occa::memory mem);\npublic:\n- hipDeviceptr_t hipPtr;\n+ hipDeviceptr_t &hipPtr;\nchar *mappedPtr;\nmemory(modeDevice_t *modeDevice_,\n" } ]
C++
MIT License
libocca/occa
[HIP] Update ptr ref hackery (#437)
378,349
03.01.2021 10:46:14
18,000
3acf80649566b494d16dd8213977ef603c9c51d0
[Refactor] Moved some io methods to public API
[ { "change_type": "MODIFY", "old_path": "include/occa/utils.hpp", "new_path": "include/occa/utils.hpp", "diff": "#include <occa/utils/env.hpp>\n#include <occa/utils/exception.hpp>\n#include <occa/utils/hash.hpp>\n+#include <occa/utils/io.hpp>\n#include <occa/utils/logging.hpp>\n#include <occa/utils/uva.hpp>\n" }, { "change_type": "ADD", "old_path": null, "new_path": "include/occa/utils/io.hpp", "diff": "+#ifndef OCCA_UTILS_IO_HEADER\n+#define OCCA_UTILS_IO_HEADER\n+\n+#include <iostream>\n+\n+namespace occa {\n+ namespace io {\n+ bool exists(const std::string &filename);\n+\n+ void addLibraryPath(const std::string &library,\n+ const std::string &path);\n+ }\n+}\n+\n+#endif\n" }, { "change_type": "MODIFY", "old_path": "src/occa/internal/io/fileOpener.cpp", "new_path": "src/occa/internal/io/fileOpener.cpp", "diff": "@@ -79,30 +79,6 @@ namespace occa {\nstatic libraryPathMap_t libraryPaths;\nreturn libraryPaths;\n}\n-\n- void addLibraryPath(const std::string &library,\n- const std::string &path) {\n- std::string safeLibrary = library;\n- if (endsWith(safeLibrary, \"/\")) {\n- safeLibrary = safeLibrary.substr(0, safeLibrary.size() - 1);\n- }\n- OCCA_ERROR(\"Library name cannot be empty\",\n- safeLibrary.size());\n- OCCA_ERROR(\"Library name cannot have / characters\",\n- safeLibrary.find('/') == std::string::npos);\n-\n- std::string safePath = path;\n- // Remove the trailing /\n- if (endsWith(safePath, \"/\")) {\n- safePath = safePath.substr(0, safePath.size() - 1);\n- }\n- if (!safePath.size()) {\n- return;\n- }\n-\n- libraryPathMap_t &libraryPaths = getLibraryPathMap();\n- libraryPaths[safeLibrary] = safePath;\n- }\n//==================================\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/occa/internal/io/fileOpener.hpp", "new_path": "src/occa/internal/io/fileOpener.hpp", "diff": "@@ -51,9 +51,6 @@ namespace occa {\n};\nlibraryPathMap_t &getLibraryPathMap();\n-\n- void addLibraryPath(const std::string &library,\n- const std::string &path);\n//==================================\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/occa/internal/io/utils.cpp", "new_path": "src/occa/internal/io/utils.cpp", "diff": "@@ -338,16 +338,6 @@ namespace occa {\nreturn filesInDir(dir, DT_REG);\n}\n- bool exists(const std::string &filename) {\n- std::string expFilename = io::filename(filename);\n- FILE *fp = fopen(expFilename.c_str(), \"rb\");\n- if (fp == NULL) {\n- return false;\n- }\n- fclose(fp);\n- return true;\n- }\n-\nchar* c_read(const std::string &filename,\nsize_t *chars,\nenums::FileType fileType) {\n" }, { "change_type": "ADD", "old_path": null, "new_path": "src/utils/io.cpp", "diff": "+#include <occa/utils/io.hpp>\n+#include <occa/internal/io.hpp>\n+#include <occa/internal/utils/string.hpp>\n+\n+namespace occa {\n+ namespace io {\n+ bool exists(const std::string &filename) {\n+ std::string expFilename = io::filename(filename);\n+ FILE *fp = fopen(expFilename.c_str(), \"rb\");\n+ if (fp == NULL) {\n+ return false;\n+ }\n+ fclose(fp);\n+ return true;\n+ }\n+\n+ void addLibraryPath(const std::string &library,\n+ const std::string &path) {\n+ std::string safeLibrary = library;\n+ if (endsWith(safeLibrary, \"/\")) {\n+ safeLibrary = safeLibrary.substr(0, safeLibrary.size() - 1);\n+ }\n+ OCCA_ERROR(\"Library name cannot be empty\",\n+ safeLibrary.size());\n+ OCCA_ERROR(\"Library name cannot have / characters\",\n+ safeLibrary.find('/') == std::string::npos);\n+\n+ std::string safePath = path;\n+ // Remove the trailing /\n+ if (endsWith(safePath, \"/\")) {\n+ safePath = safePath.substr(0, safePath.size() - 1);\n+ }\n+ if (!safePath.size()) {\n+ return;\n+ }\n+\n+ libraryPathMap_t &libraryPaths = getLibraryPathMap();\n+ libraryPaths[safeLibrary] = safePath;\n+ }\n+ }\n+}\n" }, { "change_type": "MODIFY", "old_path": "tests/src/internal/io/fileOpener.cpp", "new_path": "tests/src/internal/io/fileOpener.cpp", "diff": "+#include <occa/utils/io.hpp>\n#include <occa/internal/io.hpp>\n#include <occa/internal/utils/env.hpp>\n#include <occa/internal/utils/testing.hpp>\n" } ]
C++
MIT License
libocca/occa
[Refactor] Moved some io methods to public API (#440)
378,349
04.01.2021 00:59:31
18,000
a5e852f5beb39d7a5f16d3cd477d80eba87d4077
[Fix][JSON] Add explicit bool casting for {} json initializer
[ { "change_type": "MODIFY", "old_path": "include/occa/types/json.hpp", "new_path": "include/occa/types/json.hpp", "diff": "@@ -590,6 +590,39 @@ namespace occa {\nstd::string name;\njson value;\n+ jsonKeyValue(const std::string &name_,\n+ const bool value_);\n+\n+ jsonKeyValue(const std::string &name_,\n+ const uint8_t value_);\n+\n+ jsonKeyValue(const std::string &name_,\n+ const int8_t value_);\n+\n+ jsonKeyValue(const std::string &name_,\n+ const uint16_t value_);\n+\n+ jsonKeyValue(const std::string &name_,\n+ const int16_t value_);\n+\n+ jsonKeyValue(const std::string &name_,\n+ const uint32_t value_);\n+\n+ jsonKeyValue(const std::string &name_,\n+ const int32_t value_);\n+\n+ jsonKeyValue(const std::string &name_,\n+ const uint64_t value_);\n+\n+ jsonKeyValue(const std::string &name_,\n+ const int64_t value_);\n+\n+ jsonKeyValue(const std::string &name_,\n+ const float value_);\n+\n+ jsonKeyValue(const std::string &name_,\n+ const double value_);\n+\njsonKeyValue(const std::string &name_,\nconst primitive &value_);\n" }, { "change_type": "MODIFY", "old_path": "src/types/json.cpp", "new_path": "src/types/json.cpp", "diff": "@@ -667,6 +667,61 @@ namespace occa {\nreturn vec;\n}\n+ jsonKeyValue::jsonKeyValue(const std::string &name_,\n+ const bool value_) :\n+ name(name_),\n+ value(value_) {}\n+\n+ jsonKeyValue::jsonKeyValue(const std::string &name_,\n+ const uint8_t value_) :\n+ name(name_),\n+ value(value_) {}\n+\n+ jsonKeyValue::jsonKeyValue(const std::string &name_,\n+ const int8_t value_) :\n+ name(name_),\n+ value(value_) {}\n+\n+ jsonKeyValue::jsonKeyValue(const std::string &name_,\n+ const uint16_t value_) :\n+ name(name_),\n+ value(value_) {}\n+\n+ jsonKeyValue::jsonKeyValue(const std::string &name_,\n+ const int16_t value_) :\n+ name(name_),\n+ value(value_) {}\n+\n+ jsonKeyValue::jsonKeyValue(const std::string &name_,\n+ const uint32_t value_) :\n+ name(name_),\n+ value(value_) {}\n+\n+ jsonKeyValue::jsonKeyValue(const std::string &name_,\n+ const int32_t value_) :\n+ name(name_),\n+ value(value_) {}\n+\n+ jsonKeyValue::jsonKeyValue(const std::string &name_,\n+ const uint64_t value_) :\n+ name(name_),\n+ value(value_) {}\n+\n+ jsonKeyValue::jsonKeyValue(const std::string &name_,\n+ const int64_t value_) :\n+ name(name_),\n+ value(value_) {}\n+\n+ jsonKeyValue::jsonKeyValue(const std::string &name_,\n+ const float value_) :\n+ name(name_),\n+ value(value_) {}\n+\n+ jsonKeyValue::jsonKeyValue(const std::string &name_,\n+ const double value_) :\n+ name(name_),\n+ value(value_) {}\n+\njsonKeyValue::jsonKeyValue(const std::string &name_,\nconst primitive &value_) :\nname(name_),\n" } ]
C++
MIT License
libocca/occa
[Fix][JSON] Add explicit bool casting for {} json initializer (#444)
378,341
04.01.2021 16:51:27
-3,600
93318e38c8e15359d41da64919c346dc373d0cf4
[Fix] Use correct new path for expermental mpi.hpp
[ { "change_type": "MODIFY", "old_path": "examples/cpp/10_mpi/main.cpp", "new_path": "examples/cpp/10_mpi/main.cpp", "diff": "#include <iostream>\n#include <occa.hpp>\n-#include <occa/mpi.hpp>\n+#include <occa/experimental/mpi.hpp>\n#if OCCA_MPI_ENABLED\n" }, { "change_type": "MODIFY", "old_path": "src/mpi.cpp", "new_path": "src/mpi.cpp", "diff": "#if OCCA_MPI_ENABLED\n#include <occa/core/base.hpp>\n-#include <occa/mpi.hpp>\n+#include <occa/experimental/mpi.hpp>\n#include <occa/internal/utils/tls.hpp>\nnamespace occa {\n" } ]
C++
MIT License
libocca/occa
[Fix] Use correct new path for expermental mpi.hpp (#445)
378,341
04.01.2021 16:58:34
-3,600
adabffc0a8aa877226f9987cfe63999194ccd85a
[Fix] Add exception for one Fortran test that doesn't fit the standard CMake functions
[ { "change_type": "MODIFY", "old_path": "tests/CMakeLists.txt", "new_path": "tests/CMakeLists.txt", "diff": "@@ -21,6 +21,10 @@ function(add_occa_test test_source)\ntarget_include_directories(${cmake_test_target} PRIVATE\n$<BUILD_INTERFACE:${OCCA_SOURCE_DIR}/src>)\n+ if (${test_source} MATCHES \"typedefs.f90\")\n+ target_link_libraries(${cmake_test_target} libtypedefs_helper libocca ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS})\n+ endif()\n+\nadd_test(\nNAME ${cmake_test_target}\nCOMMAND ${test_binary})\n@@ -41,6 +45,12 @@ if (ENABLE_FORTRAN)\nRELATIVE ${CMAKE_CURRENT_SOURCE_DIR} \"src/*.f90\")\nlist(APPEND occa_tests ${occa_fortran_tests})\n+\n+ list(FILTER occa_tests\n+ EXCLUDE REGEX \"src/fortran/typedefs_helper.cpp\")\n+\n+ add_library(libtypedefs_helper SHARED \"src/fortran/typedefs_helper.cpp\")\n+ target_link_libraries(libtypedefs_helper libocca)\nelse()\nlist(FILTER occa_tests\nEXCLUDE REGEX \"src/fortran\")\n" } ]
C++
MIT License
libocca/occa
[Fix] Add exception for one Fortran test that doesn't fit the standard CMake functions (#446)
378,349
05.01.2021 20:28:00
18,000
cc9bd4fb1d66d6a377f7f9683eb7b38ffd3cae00
[HIP] Fix the way hip sets arguments, I broke it on
[ { "change_type": "MODIFY", "old_path": "src/occa/internal/modes/hip/kernel.cpp", "new_path": "src/occa/internal/modes/hip/kernel.cpp", "diff": "@@ -85,7 +85,7 @@ namespace occa {\npadding = 0;\n}\n- ::memcpy(dataPtr, arg.ptr(), bytes);\n+ ::memcpy(dataPtr, &arg.value.value.int64_, bytes);\ndataPtr += bytes;\n}\n" } ]
C++
MIT License
libocca/occa
[HIP] Fix the way hip sets arguments, I broke it on #438 (#448)
378,355
06.01.2021 15:32:07
21,600
8adddfc3d2391bd418c963b128f8616315e50392
[Core] Make getDeviceCount syntax match new device::setup syntax
[ { "change_type": "MODIFY", "old_path": "include/occa/core/base.hpp", "new_path": "include/occa/core/base.hpp", "diff": "@@ -148,6 +148,7 @@ namespace occa {\n//---[ Helper Methods ]---------------\nbool modeIsEnabled(const std::string &mode);\n+ int getDeviceCount(const std::string &props);\nint getDeviceCount(const occa::json &props);\nvoid printModeInfo();\n" }, { "change_type": "MODIFY", "old_path": "src/core/base.cpp", "new_path": "src/core/base.cpp", "diff": "@@ -263,6 +263,10 @@ namespace occa {\nreturn getMode(mode);\n}\n+ int getDeviceCount(const std::string &props) {\n+ return getDeviceCount(json::parse(props));\n+ }\n+\nint getDeviceCount(const occa::json &props) {\nstd::string modeName = props[\"mode\"];\nmode_t *mode = getMode(modeName);\n" } ]
C++
MIT License
libocca/occa
[Core] Make getDeviceCount syntax match new device::setup syntax (#452)
378,349
06.01.2021 18:37:27
18,000
a13bb894654abcbf28d000bde8344f740eeab7c8
[#450][IO] Don't cache the cache path
[ { "change_type": "MODIFY", "old_path": "src/occa/internal/io/utils.cpp", "new_path": "src/occa/internal/io/utils.cpp", "diff": "@@ -51,20 +51,12 @@ namespace occa {\nstatic const unsigned char DT_DIR = 'd';\n#endif\n- const std::string& cachePath() {\n- static std::string path;\n- if (path.size() == 0) {\n- path = env::OCCA_CACHE_DIR + \"cache/\";\n- }\n- return path;\n+ std::string cachePath() {\n+ return env::OCCA_CACHE_DIR + \"cache/\";\n}\n- const std::string& libraryPath() {\n- static std::string path;\n- if (path.size() == 0) {\n- path = env::OCCA_CACHE_DIR + \"libraries/\";\n- }\n- return path;\n+ std::string libraryPath() {\n+ return env::OCCA_CACHE_DIR + \"libraries/\";\n}\nstd::string currentWorkingDirectory() {\n" }, { "change_type": "MODIFY", "old_path": "src/occa/internal/io/utils.hpp", "new_path": "src/occa/internal/io/utils.hpp", "diff": "@@ -20,8 +20,8 @@ namespace occa {\n}\nnamespace io {\n- const std::string& cachePath();\n- const std::string& libraryPath();\n+ std::string cachePath();\n+ std::string libraryPath();\nstd::string currentWorkingDirectory();\n" } ]
C++
MIT License
libocca/occa
[#450][IO] Don't cache the cache path (#453)
378,349
06.01.2021 18:54:16
18,000
a8cbb2d52373ed540be675a61f715a5ce6f5fd9f
[OpenCL] Define CL_TARGET_OPENCL_VERSION
[ { "change_type": "MODIFY", "old_path": "src/occa/internal/modes/opencl/polyfill.hpp", "new_path": "src/occa/internal/modes/opencl/polyfill.hpp", "diff": "#if OCCA_OPENCL_ENABLED\n+// Remove warnings due to CL_TARGET_OPENCL_VERSION not being set\n+# ifndef CL_TARGET_OPENCL_VERSION\n+# define CL_TARGET_OPENCL_VERSION 220\n+# endif\n+\n# if (OCCA_OS & OCCA_LINUX_OS)\n# include <CL/cl.h>\n# include <CL/cl_gl.h>\n" } ]
C++
MIT License
libocca/occa
[OpenCL] Define CL_TARGET_OPENCL_VERSION (#454)
378,349
06.01.2021 19:34:32
18,000
addc6bc3048bf42fd7fe935f85bb518451a6dd56
[CUDA] Always use the primary context
[ { "change_type": "MODIFY", "old_path": "src/occa/internal/modes/cuda/device.cpp", "new_path": "src/occa/internal/modes/cuda/device.cpp", "diff": "@@ -30,7 +30,7 @@ namespace occa {\ncuDeviceGet(&cuDevice, deviceID));\nOCCA_CUDA_ERROR(\"Device: Creating Context\",\n- cuCtxCreate(&cuContext, CU_CTX_SCHED_AUTO, cuDevice));\n+ cuDevicePrimaryCtxRetain(&cuContext, cuDevice));\n}\np2pEnabled = false;\n@@ -81,7 +81,7 @@ namespace occa {\nif (cuContext) {\nOCCA_CUDA_DESTRUCTOR_ERROR(\n\"Device: Freeing Context\",\n- cuCtxDestroy(cuContext)\n+ cuDevicePrimaryCtxRelease(cuDevice)\n);\ncuContext = NULL;\n}\n" }, { "change_type": "MODIFY", "old_path": "src/occa/internal/modes/cuda/polyfill.hpp", "new_path": "src/occa/internal/modes/cuda/polyfill.hpp", "diff": "@@ -26,7 +26,6 @@ namespace occa {\ntypedef struct _CUstream* CUstream;\n//---[ Enums ]------------------------\n- static const int CU_CTX_SCHED_AUTO = 0;\nstatic const int CU_DEVICE_CPU = 0;\nstatic const int CU_EVENT_DEFAULT = 0;\nstatic const int CU_MEM_ATTACH_GLOBAL = 0;\n@@ -118,11 +117,11 @@ namespace occa {\n}\n// ---[ Context ]-------------------\n- inline CUresult cuCtxCreate(CUcontext *pctx, unsigned int flags, CUdevice dev) {\n+ inline CUresult cuDevicePrimaryCtxRetain(CUcontext *pctx, CUdevice dev) {\nreturn OCCA_CUDA_IS_NOT_ENABLED;\n}\n- inline CUresult cuCtxDestroy(CUcontext ctx) {\n+ inline CUresult cuDevicePrimaryCtxRelease(CUdevice dev) {\nreturn OCCA_CUDA_IS_NOT_ENABLED;\n}\n" } ]
C++
MIT License
libocca/occa
[CUDA] Always use the primary context (#455)
378,355
12.01.2021 18:46:00
21,600
704350435e6e449e45b28d325cb328b07f0b4653
[Lang] Adding missing if statment condition to inner statement array
[ { "change_type": "MODIFY", "old_path": "src/occa/internal/lang/statement/ifStatement.cpp", "new_path": "src/occa/internal/lang/statement/ifStatement.cpp", "diff": "@@ -69,6 +69,9 @@ namespace occa {\nstatementArray ifStatement::getInnerStatements() {\nstatementArray arr;\n+ if (condition) {\n+ arr.push(condition);\n+ }\nfor (statement_t *elifSmnt : elifSmnts) {\narr.push(elifSmnt);\n}\n" } ]
C++
MIT License
libocca/occa
[Lang] Adding missing if statment condition to inner statement array (#456)
378,355
12.01.2021 18:47:41
21,600
f89f13908703507120c2c0d5f4a43a62a7e34bc2
[OpenCL] Avoid checking the error code in getDeviceCountInPlatform
[ { "change_type": "MODIFY", "old_path": "src/occa/internal/modes/opencl/utils.cpp", "new_path": "src/occa/internal/modes/opencl/utils.cpp", "diff": "@@ -95,16 +95,13 @@ namespace occa {\n}\nint getDeviceCountInPlatform(int pID, int type) {\n- cl_uint dCount;\n-\ncl_platform_id clPID = platformID(pID);\n+ cl_uint deviceCount = 0;\n- OCCA_OPENCL_ERROR(\"OpenCL: Get Device ID Count\",\n- clGetDeviceIDs(clPID,\n- deviceType(type),\n- 0, NULL, &dCount));\n+ clGetDeviceIDs(clPID, deviceType(type),\n+ 0, NULL, &deviceCount);\n- return dCount;\n+ return deviceCount;\n}\ncl_device_id deviceID(int pID, int dID, int type) {\n" } ]
C++
MIT License
libocca/occa
[OpenCL] Avoid checking the error code in getDeviceCountInPlatform (#457)
378,348
12.01.2021 18:55:11
21,600
483de1641e3b9140ecff02353a9a8aee1ec51239
[HIP] Use arch name property to determine gpu arch
[ { "change_type": "MODIFY", "old_path": "src/occa/internal/modes/hip/polyfill.hpp", "new_path": "src/occa/internal/modes/hip/polyfill.hpp", "diff": "@@ -37,6 +37,7 @@ namespace occa {\nsize_t totalGlobalMem;\nint maxThreadsPerBlock;\nint gcnArch;\n+ char gcnArchName[256];\nint major;\nint minor;\n" }, { "change_type": "MODIFY", "old_path": "src/occa/internal/modes/hip/utils.cpp", "new_path": "src/occa/internal/modes/hip/utils.cpp", "diff": "@@ -57,9 +57,14 @@ namespace occa {\nOCCA_HIP_ERROR(\"Getting HIP device properties\",\nhipGetDeviceProperties(&hipProps, deviceId));\n- if (hipProps.gcnArch) {\n+ if (hipProps.gcnArch) { // AMD or NVIDIA\n+#if HIP_VERSION >= 306\n+ return hipProps.gcnArchName;\n+#else\nreturn \"gfx\" + toString(hipProps.gcnArch);\n+#endif\n}\n+\nstd::string sm = \"sm_\";\nsm += toString(\nmajorVersion >= 0\n" } ]
C++
MIT License
libocca/occa
[HIP] Use arch name property to determine gpu arch (#429)
378,349
17.01.2021 14:17:41
18,000
6e7a38faacb3146034fad4349dc244d9e83b9b27
[Array] Adds dotProduct and clamp
[ { "change_type": "MODIFY", "old_path": "include/occa/functional/array.hpp", "new_path": "include/occa/functional/array.hpp", "diff": "@@ -888,6 +888,15 @@ namespace occa {\n}\n//==================================\n+ //---[ Utility methods ]------------\n+ TM operator [] (const dim_t index) const {\n+ TM value;\n+ memory_.copyTo(&value,\n+ 1 * sizeof(TM),\n+ index * sizeof(TM));\n+ return value;\n+ }\n+\narray slice(const dim_t offset,\nconst dim_t count = -1) const {\nreturn array(\n@@ -1064,6 +1073,60 @@ namespace occa {\n);\n}\n//==================================\n+\n+ //---[ Linear Algebra Methods ]-----\n+ TM dotProduct(const array<TM> &other) {\n+ occa::scope fnScope({\n+ {\"other\", other}\n+ });\n+\n+ return reduce<TM>(\n+ reductionType::sum,\n+ OCCA_FUNCTION(fnScope, [=](TM acc, TM value, int index) -> TM {\n+ return acc + (value * other[index]);\n+ })\n+ );\n+ }\n+\n+ array clamp(const TM minValue,\n+ const TM maxValue) {\n+ occa::scope fnScope({\n+ {\"minValue\", minValue},\n+ {\"maxValue\", maxValue},\n+ });\n+\n+ return map<TM>(\n+ OCCA_FUNCTION(fnScope, [=](TM value) -> TM {\n+ const TM valueWithMaxClamp = value > maxValue ? maxValue : value;\n+ return valueWithMaxClamp < minValue ? minValue : valueWithMaxClamp;\n+ })\n+ );\n+ }\n+\n+ array clampMin(const TM minValue) {\n+ occa::scope fnScope({\n+ {\"minValue\", minValue},\n+ });\n+\n+ return map<TM>(\n+ OCCA_FUNCTION(fnScope, [=](TM value) -> TM {\n+ return value < minValue ? minValue : value;\n+ })\n+ );\n+ }\n+\n+ array clampMax(const TM maxValue) {\n+ occa::scope fnScope({\n+ {\"maxValue\", maxValue},\n+ });\n+\n+ return map<TM>(\n+ OCCA_FUNCTION(fnScope, [=](TM value) -> TM {\n+ return value > maxValue ? maxValue : value;\n+ })\n+ );\n+ }\n+ //==================================\n};\ntemplate <>\n" }, { "change_type": "MODIFY", "old_path": "tests/src/functional/array.cpp", "new_path": "tests/src/functional/array.cpp", "diff": "@@ -57,6 +57,8 @@ void testShiftLeft(occa::device device);\nvoid testShiftRight(occa::device device);\nvoid testMax(occa::device device);\nvoid testMin(occa::device device);\n+void testDotProduct(occa::device device);\n+void testClamp(occa::device device);\nint main(const int argc, const char **argv) {\nstd::vector<occa::device> devices = {\n@@ -102,6 +104,8 @@ int main(const int argc, const char **argv) {\ntestShiftRight(device);\ntestMax(device);\ntestMin(device);\n+ testDotProduct(device);\n+ testClamp(device);\n}\nreturn 0;\n@@ -919,3 +923,34 @@ void testMin(occa::device device) {\nASSERT_EQ(ctx.minValue, ctx.array.min());\n}\n+\n+void testDotProduct(occa::device device) {\n+ context ctx(device);\n+\n+ int dotProduct = 0;\n+ for (int i = 0; i < ctx.length; ++i) {\n+ dotProduct += (ctx.values[i] * ctx.values[i]);\n+ }\n+\n+ ASSERT_EQ(dotProduct,\n+ ctx.array.dotProduct(ctx.array));\n+}\n+\n+void testClamp(occa::device device) {\n+ context ctx(device);\n+\n+ occa::array<int> clampedArray = ctx.array.clamp(4, 7);\n+\n+ ASSERT_EQ(4, clampedArray.min());\n+ ASSERT_EQ(7, clampedArray.max());\n+\n+ clampedArray = ctx.array.clampMin(4);\n+\n+ ASSERT_EQ(4, clampedArray.min());\n+ ASSERT_EQ(9, clampedArray.max());\n+\n+ clampedArray = ctx.array.clampMax(7);\n+\n+ ASSERT_EQ(0, clampedArray.min());\n+ ASSERT_EQ(7, clampedArray.max());\n+}\n" } ]
C++
MIT License
libocca/occa
[Array] Adds dotProduct and clamp (#458)
378,349
18.01.2021 16:58:55
18,000
eb2be149ee99aba105f73b133c3286bb327134ec
[C] Adds occaKernelRunWithArgs
[ { "change_type": "MODIFY", "old_path": "include/occa/c/kernel.h", "new_path": "include/occa/c/kernel.h", "diff": "@@ -51,6 +51,10 @@ void occaKernelVaRun(occaKernel kernel,\nconst int argc,\nva_list args);\n+void occaKernelRunWithArgs(occaKernel kernel,\n+ const int argc,\n+ occaType *args);\n+\nOCCA_END_EXTERN_C\n#endif\n" }, { "change_type": "MODIFY", "old_path": "src/c/kernel.cpp", "new_path": "src/c/kernel.cpp", "diff": "@@ -151,4 +151,24 @@ void occaKernelVaRun(occaKernel kernel,\nkernel_.run();\n}\n+void occaKernelRunWithArgs(occaKernel kernel,\n+ const int argc,\n+ occaType *args) {\n+ occa::kernel kernel_ = occa::c::kernel(kernel);\n+ OCCA_ERROR(\"Uninitialized kernel\",\n+ kernel_.isInitialized());\n+\n+ occa::modeKernel_t &modeKernel = *(kernel_.getModeKernel());\n+ modeKernel.arguments.clear();\n+ modeKernel.arguments.reserve(argc);\n+\n+ for (int i = 0; i < argc; ++i) {\n+ modeKernel.pushArgument(\n+ occa::c::kernelArg(args[i])\n+ );\n+ }\n+\n+ kernel_.run();\n+}\n+\nOCCA_END_EXTERN_C\n" }, { "change_type": "MODIFY", "old_path": "tests/src/c/kernel.cpp", "new_path": "tests/src/c/kernel.cpp", "diff": "@@ -153,6 +153,27 @@ void testRun() {\noccaKernelPushArg(argKernel, occaString(str.c_str()));\noccaKernelRunFromArgs(argKernel);\n+ // Test array call\n+ occaType args[15] = {\n+ occaNull,\n+ mem,\n+ occaPtr(uvaPtr),\n+ occaInt8(3),\n+ occaUInt8(4),\n+ occaInt16(5),\n+ occaUInt16(6),\n+ occaInt32(7),\n+ occaUInt32(8),\n+ occaInt64(9),\n+ occaUInt64(10),\n+ occaFloat(11.0),\n+ occaDouble(12.0),\n+ occaStruct(xy, sizeof(xy)),\n+ occaString(str.c_str())\n+ };\n+\n+ occaKernelRunWithArgs(argKernel, 15, args);\n+\n// Bad argument types\nASSERT_THROW(\noccaKernelRunN(argKernel, 1, occaGetDevice());\n" } ]
C++
MIT License
libocca/occa
[C] Adds occaKernelRunWithArgs (#459)
378,341
20.01.2021 18:20:14
-3,600
4ea8f4c532701f3c2f738ad171ccbf3fe5d989ee
[Fix] Kernel header defines can be things other than strings
[ { "change_type": "MODIFY", "old_path": "src/core/kernel.cpp", "new_path": "src/core/kernel.cpp", "diff": "@@ -222,7 +222,8 @@ namespace occa {\n// Add defines\nfor (const auto &entry : props[\"defines\"].object()) {\n- if (entry.second.isString()) {\n+ if (entry.second.isString() || entry.second.isNumber() ||\n+ entry.second.isBool() || entry.second.isNull()) {\nkernelHeader += \"#define \";\nkernelHeader += ' ';\nkernelHeader += entry.first;\n" } ]
C++
MIT License
libocca/occa
[Fix] Kernel header defines can be things other than strings (#466)
378,341
20.01.2021 18:55:34
-3,600
78292d416697c9aab4b7534f2d55fe5199ce07ec
[Fix] Shadowing warnings in functionDefinition.cpp
[ { "change_type": "MODIFY", "old_path": "src/functional/functionDefinition.cpp", "new_path": "src/functional/functionDefinition.cpp", "diff": "@@ -37,51 +37,51 @@ namespace occa {\nreturn ss.str();\n}\n- hash_t functionDefinition::getHash(const occa::scope &scope,\n- const std::string &source,\n- const dtype_t &returnType) {\n- hash_t hash = (\n- occa::hash(scope)\n- ^ occa::hash(source)\n- ^ occa::hash(returnType.name())\n+ hash_t functionDefinition::getHash(const occa::scope &scope_,\n+ const std::string &source_,\n+ const dtype_t &returnType_) {\n+ hash_t hash_ = (\n+ occa::hash(scope_)\n+ ^ occa::hash(source_)\n+ ^ occa::hash(returnType_.name())\n);\n- return hash;\n+ return hash_;\n}\nfunctionDefinitionSharedPtr functionDefinition::cache(\n- const occa::scope &scope,\n- const std::string &source,\n- const dtype_t &returnType,\n- const dtypeVector &argTypes\n+ const occa::scope &scope_,\n+ const std::string &source_,\n+ const dtype_t &returnType_,\n+ const dtypeVector &argTypes_\n) {\n- hash_t hash = getHash(\n- scope,\n- source,\n- returnType\n+ hash_t hash_ = getHash(\n+ scope_,\n+ source_,\n+ returnType_\n);\n- functionStore.lock(hash);\n+ functionStore.lock(hash_);\nstd::shared_ptr<functionDefinition> fnDefPtr;\n- const bool createdPtr = functionStore.unsafeGetOrCreate(hash, fnDefPtr);\n+ const bool createdPtr = functionStore.unsafeGetOrCreate(hash_, fnDefPtr);\n// Create the function definition\nif (createdPtr) {\nfunctionDefinition &fnDef = *(fnDefPtr.get());\n// Constructor args\n- fnDef.scope = scope;\n- fnDef.source = source;\n- fnDef.returnType = returnType;\n- fnDef.argTypes = argTypes;\n+ fnDef.scope = scope_;\n+ fnDef.source = source_;\n+ fnDef.returnType = returnType_;\n+ fnDef.argTypes = argTypes_;\n// Generated args\n- fnDef.hash = hash;\n- fnDef.argumentSource = getArgumentSource(source, scope);\n- fnDef.bodySource = getBodySource(source);\n+ fnDef.hash = hash_;\n+ fnDef.argumentSource = getArgumentSource(source_, scope_);\n+ fnDef.bodySource = getBodySource(source_);\n}\n- functionStore.unlock(hash);\n+ functionStore.unlock(hash_);\nreturn fnDefPtr;\n}\n@@ -91,9 +91,9 @@ namespace occa {\nocca::lex::skipTo(c, ']');\n}\n- std::string functionDefinition::getArgumentSource(const std::string &source,\n- const occa::scope &scope) {\n- const char *root = source.c_str();\n+ std::string functionDefinition::getArgumentSource(const std::string &source_,\n+ const occa::scope &scope_) {\n+ const char *root = source_.c_str();\nconst char *start = root;\nconst char *end = root;\n@@ -107,10 +107,10 @@ namespace occa {\nreturn strip(std::string(start, end - start));\n}\n- std::string functionDefinition::getBodySource(const std::string &source) {\n- const char *root = source.c_str();\n+ std::string functionDefinition::getBodySource(const std::string &source_) {\n+ const char *root = source_.c_str();\nconst char *start = root;\n- const char *end = root + source.size();\n+ const char *end = root + source_.size();\nskipLambdaCapture(start);\nocca::lex::skipTo(start, '{');\n" } ]
C++
MIT License
libocca/occa
[Fix] Shadowing warnings in functionDefinition.cpp (#468)
378,349
20.01.2021 18:42:47
18,000
98b856c64c61bbdbe617966b5b2997046c57464d
[Examples] Fix out-of-bounds access
[ { "change_type": "MODIFY", "old_path": "examples/cpp/05_arrays/main.cpp", "new_path": "examples/cpp/05_arrays/main.cpp", "diff": "@@ -30,8 +30,8 @@ int main(int argc, const char **argv) {\n}\n// Uses the background device\n- occa::array<float> array_a(10);\n- occa::array<float> array_b(10);\n+ occa::array<float> array_a(entries);\n+ occa::array<float> array_b(entries);\n// Copy over host data\narray_a.copyFrom(a);\n" } ]
C++
MIT License
libocca/occa
[Examples] Fix out-of-bounds access (#469)
378,349
23.01.2021 10:54:02
18,000
3f995b7cfe88b78f687d04bbe47a732c1e52c446
[Fix][#471] Fixes weird Intel compiler bug
[ { "change_type": "MODIFY", "old_path": "include/occa/functional/array.hpp", "new_path": "include/occa/functional/array.hpp", "diff": "@@ -450,10 +450,8 @@ namespace occa {\nreturn clone();\n}\n- const int size = (int) length();\n-\nocca::scope fnScope({\n- {\"size\", size},\n+ {\"size\", (int) length()},\n{\"offset\", offset},\n{\"emptyValue\", emptyValue},\n});\n" } ]
C++
MIT License
libocca/occa
[Fix][#471] Fixes weird Intel compiler bug (#472)
378,349
23.01.2021 14:55:25
18,000
0e1ffe8a1c0532cacf71b60c31656ff191ad7c6a
[Doc] Update README example
[ { "change_type": "MODIFY", "old_path": "README.md", "new_path": "README.md", "diff": "@@ -62,8 +62,7 @@ occa::scope scope({\nocca::forLoop()\n.tile({entries, 16})\n- .run(OCCA_FUNCTION(scope, [=](const int outerIndex, const int innerIndex) -> void {\n- const int i = innerIndex + (2 * outerIndex);\n+ .run(OCCA_FUNCTION(scope, [=](const int i) -> void {\nab[i] = a[i] + b[i];\n}));\n```\n" } ]
C++
MIT License
libocca/occa
[Doc] Update README example
378,341
28.01.2021 03:48:37
-3,600
c21fabd5e7f791c1a2068fc5592ab0703a7be36f
[Fortran] Generate fixed arity interface
[ { "change_type": "ADD", "old_path": null, "new_path": "include/occa/c/kernel_fortran_interface.h", "diff": "+// --------------[ DO NOT EDIT ]--------------\n+// THIS IS AN AUTOMATICALLY GENERATED FILE\n+// EDIT:\n+// scripts/codegen/create_fortran_kernel_interface.py\n+// ===========================================\n+\n+#include <occa/internal/c/types.hpp>\n+\n+OCCA_START_EXTERN_C\n+\n+void occaKernelRunF01(occaKernel kernel,\n+ const int argc,\n+ occaType arg01);\n+\n+\n+void occaKernelRunF02(occaKernel kernel,\n+ const int argc,\n+ occaType arg01,\n+ occaType arg02);\n+\n+\n+void occaKernelRunF03(occaKernel kernel,\n+ const int argc,\n+ occaType arg01,\n+ occaType arg02,\n+ occaType arg03);\n+\n+\n+void occaKernelRunF04(occaKernel kernel,\n+ const int argc,\n+ occaType arg01,\n+ occaType arg02,\n+ occaType arg03,\n+ occaType arg04);\n+\n+\n+void occaKernelRunF05(occaKernel kernel,\n+ const int argc,\n+ occaType arg01,\n+ occaType arg02,\n+ occaType arg03,\n+ occaType arg04,\n+ occaType arg05);\n+\n+\n+void occaKernelRunF06(occaKernel kernel,\n+ const int argc,\n+ occaType arg01,\n+ occaType arg02,\n+ occaType arg03,\n+ occaType arg04,\n+ occaType arg05,\n+ occaType arg06);\n+\n+\n+void occaKernelRunF07(occaKernel kernel,\n+ const int argc,\n+ occaType arg01,\n+ occaType arg02,\n+ occaType arg03,\n+ occaType arg04,\n+ occaType arg05,\n+ occaType arg06,\n+ occaType arg07);\n+\n+\n+void occaKernelRunF08(occaKernel kernel,\n+ const int argc,\n+ occaType arg01,\n+ occaType arg02,\n+ occaType arg03,\n+ occaType arg04,\n+ occaType arg05,\n+ occaType arg06,\n+ occaType arg07,\n+ occaType arg08);\n+\n+\n+void occaKernelRunF09(occaKernel kernel,\n+ const int argc,\n+ occaType arg01,\n+ occaType arg02,\n+ occaType arg03,\n+ occaType arg04,\n+ occaType arg05,\n+ occaType arg06,\n+ occaType arg07,\n+ occaType arg08,\n+ occaType arg09);\n+\n+\n+void occaKernelRunF10(occaKernel kernel,\n+ const int argc,\n+ occaType arg01,\n+ occaType arg02,\n+ occaType arg03,\n+ occaType arg04,\n+ occaType arg05,\n+ occaType arg06,\n+ occaType arg07,\n+ occaType arg08,\n+ occaType arg09,\n+ occaType arg10);\n+\n+\n+void occaKernelRunF11(occaKernel kernel,\n+ const int argc,\n+ occaType arg01,\n+ occaType arg02,\n+ occaType arg03,\n+ occaType arg04,\n+ occaType arg05,\n+ occaType arg06,\n+ occaType arg07,\n+ occaType arg08,\n+ occaType arg09,\n+ occaType arg10,\n+ occaType arg11);\n+\n+\n+void occaKernelRunF12(occaKernel kernel,\n+ const int argc,\n+ occaType arg01,\n+ occaType arg02,\n+ occaType arg03,\n+ occaType arg04,\n+ occaType arg05,\n+ occaType arg06,\n+ occaType arg07,\n+ occaType arg08,\n+ occaType arg09,\n+ occaType arg10,\n+ occaType arg11,\n+ occaType arg12);\n+\n+\n+void occaKernelRunF13(occaKernel kernel,\n+ const int argc,\n+ occaType arg01,\n+ occaType arg02,\n+ occaType arg03,\n+ occaType arg04,\n+ occaType arg05,\n+ occaType arg06,\n+ occaType arg07,\n+ occaType arg08,\n+ occaType arg09,\n+ occaType arg10,\n+ occaType arg11,\n+ occaType arg12,\n+ occaType arg13);\n+\n+\n+void occaKernelRunF14(occaKernel kernel,\n+ const int argc,\n+ occaType arg01,\n+ occaType arg02,\n+ occaType arg03,\n+ occaType arg04,\n+ occaType arg05,\n+ occaType arg06,\n+ occaType arg07,\n+ occaType arg08,\n+ occaType arg09,\n+ occaType arg10,\n+ occaType arg11,\n+ occaType arg12,\n+ occaType arg13,\n+ occaType arg14);\n+\n+\n+void occaKernelRunF15(occaKernel kernel,\n+ const int argc,\n+ occaType arg01,\n+ occaType arg02,\n+ occaType arg03,\n+ occaType arg04,\n+ occaType arg05,\n+ occaType arg06,\n+ occaType arg07,\n+ occaType arg08,\n+ occaType arg09,\n+ occaType arg10,\n+ occaType arg11,\n+ occaType arg12,\n+ occaType arg13,\n+ occaType arg14,\n+ occaType arg15);\n+\n+\n+void occaKernelRunF16(occaKernel kernel,\n+ const int argc,\n+ occaType arg01,\n+ occaType arg02,\n+ occaType arg03,\n+ occaType arg04,\n+ occaType arg05,\n+ occaType arg06,\n+ occaType arg07,\n+ occaType arg08,\n+ occaType arg09,\n+ occaType arg10,\n+ occaType arg11,\n+ occaType arg12,\n+ occaType arg13,\n+ occaType arg14,\n+ occaType arg15,\n+ occaType arg16);\n+\n+\n+void occaKernelRunF17(occaKernel kernel,\n+ const int argc,\n+ occaType arg01,\n+ occaType arg02,\n+ occaType arg03,\n+ occaType arg04,\n+ occaType arg05,\n+ occaType arg06,\n+ occaType arg07,\n+ occaType arg08,\n+ occaType arg09,\n+ occaType arg10,\n+ occaType arg11,\n+ occaType arg12,\n+ occaType arg13,\n+ occaType arg14,\n+ occaType arg15,\n+ occaType arg16,\n+ occaType arg17);\n+\n+\n+void occaKernelRunF18(occaKernel kernel,\n+ const int argc,\n+ occaType arg01,\n+ occaType arg02,\n+ occaType arg03,\n+ occaType arg04,\n+ occaType arg05,\n+ occaType arg06,\n+ occaType arg07,\n+ occaType arg08,\n+ occaType arg09,\n+ occaType arg10,\n+ occaType arg11,\n+ occaType arg12,\n+ occaType arg13,\n+ occaType arg14,\n+ occaType arg15,\n+ occaType arg16,\n+ occaType arg17,\n+ occaType arg18);\n+\n+\n+void occaKernelRunF19(occaKernel kernel,\n+ const int argc,\n+ occaType arg01,\n+ occaType arg02,\n+ occaType arg03,\n+ occaType arg04,\n+ occaType arg05,\n+ occaType arg06,\n+ occaType arg07,\n+ occaType arg08,\n+ occaType arg09,\n+ occaType arg10,\n+ occaType arg11,\n+ occaType arg12,\n+ occaType arg13,\n+ occaType arg14,\n+ occaType arg15,\n+ occaType arg16,\n+ occaType arg17,\n+ occaType arg18,\n+ occaType arg19);\n+\n+\n+void occaKernelRunF20(occaKernel kernel,\n+ const int argc,\n+ occaType arg01,\n+ occaType arg02,\n+ occaType arg03,\n+ occaType arg04,\n+ occaType arg05,\n+ occaType arg06,\n+ occaType arg07,\n+ occaType arg08,\n+ occaType arg09,\n+ occaType arg10,\n+ occaType arg11,\n+ occaType arg12,\n+ occaType arg13,\n+ occaType arg14,\n+ occaType arg15,\n+ occaType arg16,\n+ occaType arg17,\n+ occaType arg18,\n+ occaType arg19,\n+ occaType arg20);\n+\n+\n+OCCA_END_EXTERN_C\n" }, { "change_type": "RENAME", "old_path": "scripts/codegen/create_fortran_kernel_module.py", "new_path": "scripts/codegen/create_fortran_kernel_interface.py", "diff": "@@ -9,24 +9,17 @@ import argparse\nOCCA_DIR = os.path.abspath(\n- os.path.join(os.path.dirname(__file__), \"..\")\n+ os.path.join(os.path.dirname(__file__), \"..\", \"..\")\n)\n-\n-EDIT_WARNING = ('''\n-! --------------[ DO NOT EDIT ]--------------\n-! THIS IS AN AUTOMATICALLY GENERATED FILE\n-! EDIT:\n-! %s\n-! %s\n-! ===========================================\n-'''.strip() % (os.path.relpath(__file__, OCCA_DIR),\n- os.path.relpath('occa_kernel_m.f90.in', OCCA_DIR)))\n-\n+CODEGEN_DIR = os.path.join(OCCA_DIR, 'scripts', 'codegen')\n+FORTRAN_DIR = os.path.join(OCCA_DIR, 'src', 'fortran')\n+C_SRC_DIR = os.path.join(OCCA_DIR, 'src', 'c')\n+C_INC_DIR = os.path.join(OCCA_DIR, 'include', 'occa', 'c')\nOCCA_KERNEL_RUN_N = ('''\nsubroutine occaKernelRunN%02d(kernel, argc, %s) &\n- bind(C, name=\"occaKernelRunN\")\n+ bind(C, name=\"occaKernelRunF%02d\")\nimport occaKernel, C_int, occaType\nimplicit none\ntype(occaKernel), value :: kernel\n@@ -45,6 +38,15 @@ OCCA_KERNEL_RUN = ('''\n''').lstrip('\\n')\n+def generate_edit_warning(fpath, comment_marker='!'):\n+ return \\\n+ ('%s --------------[ DO NOT EDIT ]--------------\\n' % comment_marker) + \\\n+ ('%s THIS IS AN AUTOMATICALLY GENERATED FILE\\n' % comment_marker) + \\\n+ ('%s EDIT:\\n' % comment_marker) + \\\n+ ('%s %s\\n' % (comment_marker, os.path.relpath(__file__, OCCA_DIR))) + \\\n+ (('%s %s\\n' %(comment_marker, os.path.relpath(fpath, OCCA_DIR))) if fpath else '') + \\\n+ ('%s ===========================================\\n' % comment_marker)\n+\nif __name__ == '__main__':\n# Parse command-line arguments\nparser = argparse.ArgumentParser(usage=__doc__)\n@@ -53,16 +55,17 @@ if __name__ == '__main__':\nMAX_ARGS = args.NargsMax\nif MAX_ARGS > 99:\n- raise ValueError('The format was designed for max. 99 arguments!')\n+ raise ValueError('The format was designed for max. %d arguments!' % MAX_ARGS)\n- with open('occa_kernel_m.f90.in', 'r') as f:\n+ fname_in = os.path.join(CODEGEN_DIR, 'occa_kernel_m.f90.in')\n+ with open(fname_in, 'r') as f:\nf_in = f.readlines()\n- fname = os.path.join(OCCA_DIR, 'src', 'fortran', 'occa_kernel_m.f90')\n+ fname = os.path.join(FORTRAN_DIR, 'occa_kernel_m.f90')\nprint('Write OCCA Fortran kernel module to: %s' % (fname))\nwith open(fname, 'w') as f:\n# Add edit warning to the top of the file\n- f.write(EDIT_WARNING)\n+ f.write(generate_edit_warning(fname_in))\nf.write('\\n')\n# Write header\n@@ -91,7 +94,7 @@ if __name__ == '__main__':\nargs_d = ', '.join(arg_lst)\nif (N > 1): f.write('\\n')\n- f.write(OCCA_KERNEL_RUN_N % (N, args_f, args_d))\n+ f.write(OCCA_KERNEL_RUN_N % (N, args_f, N, args_d))\n# Write input file\nline = f_in.pop(0)\n@@ -142,3 +145,40 @@ if __name__ == '__main__':\n# Write remainder of the input file\nfor line in f_in:\nf.write(line)\n+\n+ # Generate interface functions with fixed arity to safely interface C with Fortran\n+ fname = os.path.join(C_SRC_DIR, 'kernel_fortran_interface.cpp')\n+ print('Write OCCA Fortran kernel interface C source to: %s' % fname)\n+ with open(fname, 'w') as f:\n+ f.write(generate_edit_warning(None, comment_marker='//'))\n+ f.write('\\n')\n+ f.write('#include <occa/c/kernel_fortran_interface.h>\\n')\n+ f.write('#include <occa/c/kernel.h>\\n')\n+ f.write('\\n')\n+ f.write('OCCA_START_EXTERN_C\\n')\n+ f.write('\\n')\n+ for N in range(1, MAX_ARGS+1):\n+ f.write('void occaKernelRunF%02d(occaKernel kernel,\\n' % N);\n+ f.write(' const int argc,\\n');\n+ for n in range(1, N+1):\n+ f.write(' occaType arg%02d%s\\n' % (n, ') {' if n == N else ','))\n+ f.write(' occaKernelRunN(kernel, argc,\\n')\n+ for n in range(1, N+1):\n+ f.write('%16s arg%02d%s' % ('', n, ');\\n}\\n\\n' if n == N else ',\\n'))\n+ f.write('OCCA_END_EXTERN_C\\n')\n+\n+ fname = os.path.join(C_INC_DIR, 'kernel_fortran_interface.h')\n+ print('Write OCCA Fortran kernel interface C headers to: %s' % fname)\n+ with open(fname, 'w') as f:\n+ f.write(generate_edit_warning(None, comment_marker='//'))\n+ f.write('\\n')\n+ f.write('#include <occa/internal/c/types.hpp>\\n')\n+ f.write('\\n')\n+ f.write('OCCA_START_EXTERN_C\\n')\n+ f.write('\\n')\n+ for N in range(1, MAX_ARGS+1):\n+ f.write('void occaKernelRunF%02d(occaKernel kernel,\\n' % N);\n+ f.write(' const int argc,\\n');\n+ for n in range(1, N+1):\n+ f.write(' occaType arg%02d%s\\n' % (n, ');\\n\\n' if n == N else ','))\n+ f.write('OCCA_END_EXTERN_C\\n')\n" }, { "change_type": "ADD", "old_path": null, "new_path": "src/c/kernel_fortran_interface.cpp", "diff": "+// --------------[ DO NOT EDIT ]--------------\n+// THIS IS AN AUTOMATICALLY GENERATED FILE\n+// EDIT:\n+// scripts/codegen/create_fortran_kernel_interface.py\n+// ===========================================\n+\n+#include <occa/c/kernel_fortran_interface.h>\n+#include <occa/c/kernel.h>\n+\n+OCCA_START_EXTERN_C\n+\n+void occaKernelRunF01(occaKernel kernel,\n+ const int argc,\n+ occaType arg01) {\n+ occaKernelRunN(kernel, argc,\n+ arg01);\n+}\n+\n+void occaKernelRunF02(occaKernel kernel,\n+ const int argc,\n+ occaType arg01,\n+ occaType arg02) {\n+ occaKernelRunN(kernel, argc,\n+ arg01,\n+ arg02);\n+}\n+\n+void occaKernelRunF03(occaKernel kernel,\n+ const int argc,\n+ occaType arg01,\n+ occaType arg02,\n+ occaType arg03) {\n+ occaKernelRunN(kernel, argc,\n+ arg01,\n+ arg02,\n+ arg03);\n+}\n+\n+void occaKernelRunF04(occaKernel kernel,\n+ const int argc,\n+ occaType arg01,\n+ occaType arg02,\n+ occaType arg03,\n+ occaType arg04) {\n+ occaKernelRunN(kernel, argc,\n+ arg01,\n+ arg02,\n+ arg03,\n+ arg04);\n+}\n+\n+void occaKernelRunF05(occaKernel kernel,\n+ const int argc,\n+ occaType arg01,\n+ occaType arg02,\n+ occaType arg03,\n+ occaType arg04,\n+ occaType arg05) {\n+ occaKernelRunN(kernel, argc,\n+ arg01,\n+ arg02,\n+ arg03,\n+ arg04,\n+ arg05);\n+}\n+\n+void occaKernelRunF06(occaKernel kernel,\n+ const int argc,\n+ occaType arg01,\n+ occaType arg02,\n+ occaType arg03,\n+ occaType arg04,\n+ occaType arg05,\n+ occaType arg06) {\n+ occaKernelRunN(kernel, argc,\n+ arg01,\n+ arg02,\n+ arg03,\n+ arg04,\n+ arg05,\n+ arg06);\n+}\n+\n+void occaKernelRunF07(occaKernel kernel,\n+ const int argc,\n+ occaType arg01,\n+ occaType arg02,\n+ occaType arg03,\n+ occaType arg04,\n+ occaType arg05,\n+ occaType arg06,\n+ occaType arg07) {\n+ occaKernelRunN(kernel, argc,\n+ arg01,\n+ arg02,\n+ arg03,\n+ arg04,\n+ arg05,\n+ arg06,\n+ arg07);\n+}\n+\n+void occaKernelRunF08(occaKernel kernel,\n+ const int argc,\n+ occaType arg01,\n+ occaType arg02,\n+ occaType arg03,\n+ occaType arg04,\n+ occaType arg05,\n+ occaType arg06,\n+ occaType arg07,\n+ occaType arg08) {\n+ occaKernelRunN(kernel, argc,\n+ arg01,\n+ arg02,\n+ arg03,\n+ arg04,\n+ arg05,\n+ arg06,\n+ arg07,\n+ arg08);\n+}\n+\n+void occaKernelRunF09(occaKernel kernel,\n+ const int argc,\n+ occaType arg01,\n+ occaType arg02,\n+ occaType arg03,\n+ occaType arg04,\n+ occaType arg05,\n+ occaType arg06,\n+ occaType arg07,\n+ occaType arg08,\n+ occaType arg09) {\n+ occaKernelRunN(kernel, argc,\n+ arg01,\n+ arg02,\n+ arg03,\n+ arg04,\n+ arg05,\n+ arg06,\n+ arg07,\n+ arg08,\n+ arg09);\n+}\n+\n+void occaKernelRunF10(occaKernel kernel,\n+ const int argc,\n+ occaType arg01,\n+ occaType arg02,\n+ occaType arg03,\n+ occaType arg04,\n+ occaType arg05,\n+ occaType arg06,\n+ occaType arg07,\n+ occaType arg08,\n+ occaType arg09,\n+ occaType arg10) {\n+ occaKernelRunN(kernel, argc,\n+ arg01,\n+ arg02,\n+ arg03,\n+ arg04,\n+ arg05,\n+ arg06,\n+ arg07,\n+ arg08,\n+ arg09,\n+ arg10);\n+}\n+\n+void occaKernelRunF11(occaKernel kernel,\n+ const int argc,\n+ occaType arg01,\n+ occaType arg02,\n+ occaType arg03,\n+ occaType arg04,\n+ occaType arg05,\n+ occaType arg06,\n+ occaType arg07,\n+ occaType arg08,\n+ occaType arg09,\n+ occaType arg10,\n+ occaType arg11) {\n+ occaKernelRunN(kernel, argc,\n+ arg01,\n+ arg02,\n+ arg03,\n+ arg04,\n+ arg05,\n+ arg06,\n+ arg07,\n+ arg08,\n+ arg09,\n+ arg10,\n+ arg11);\n+}\n+\n+void occaKernelRunF12(occaKernel kernel,\n+ const int argc,\n+ occaType arg01,\n+ occaType arg02,\n+ occaType arg03,\n+ occaType arg04,\n+ occaType arg05,\n+ occaType arg06,\n+ occaType arg07,\n+ occaType arg08,\n+ occaType arg09,\n+ occaType arg10,\n+ occaType arg11,\n+ occaType arg12) {\n+ occaKernelRunN(kernel, argc,\n+ arg01,\n+ arg02,\n+ arg03,\n+ arg04,\n+ arg05,\n+ arg06,\n+ arg07,\n+ arg08,\n+ arg09,\n+ arg10,\n+ arg11,\n+ arg12);\n+}\n+\n+void occaKernelRunF13(occaKernel kernel,\n+ const int argc,\n+ occaType arg01,\n+ occaType arg02,\n+ occaType arg03,\n+ occaType arg04,\n+ occaType arg05,\n+ occaType arg06,\n+ occaType arg07,\n+ occaType arg08,\n+ occaType arg09,\n+ occaType arg10,\n+ occaType arg11,\n+ occaType arg12,\n+ occaType arg13) {\n+ occaKernelRunN(kernel, argc,\n+ arg01,\n+ arg02,\n+ arg03,\n+ arg04,\n+ arg05,\n+ arg06,\n+ arg07,\n+ arg08,\n+ arg09,\n+ arg10,\n+ arg11,\n+ arg12,\n+ arg13);\n+}\n+\n+void occaKernelRunF14(occaKernel kernel,\n+ const int argc,\n+ occaType arg01,\n+ occaType arg02,\n+ occaType arg03,\n+ occaType arg04,\n+ occaType arg05,\n+ occaType arg06,\n+ occaType arg07,\n+ occaType arg08,\n+ occaType arg09,\n+ occaType arg10,\n+ occaType arg11,\n+ occaType arg12,\n+ occaType arg13,\n+ occaType arg14) {\n+ occaKernelRunN(kernel, argc,\n+ arg01,\n+ arg02,\n+ arg03,\n+ arg04,\n+ arg05,\n+ arg06,\n+ arg07,\n+ arg08,\n+ arg09,\n+ arg10,\n+ arg11,\n+ arg12,\n+ arg13,\n+ arg14);\n+}\n+\n+void occaKernelRunF15(occaKernel kernel,\n+ const int argc,\n+ occaType arg01,\n+ occaType arg02,\n+ occaType arg03,\n+ occaType arg04,\n+ occaType arg05,\n+ occaType arg06,\n+ occaType arg07,\n+ occaType arg08,\n+ occaType arg09,\n+ occaType arg10,\n+ occaType arg11,\n+ occaType arg12,\n+ occaType arg13,\n+ occaType arg14,\n+ occaType arg15) {\n+ occaKernelRunN(kernel, argc,\n+ arg01,\n+ arg02,\n+ arg03,\n+ arg04,\n+ arg05,\n+ arg06,\n+ arg07,\n+ arg08,\n+ arg09,\n+ arg10,\n+ arg11,\n+ arg12,\n+ arg13,\n+ arg14,\n+ arg15);\n+}\n+\n+void occaKernelRunF16(occaKernel kernel,\n+ const int argc,\n+ occaType arg01,\n+ occaType arg02,\n+ occaType arg03,\n+ occaType arg04,\n+ occaType arg05,\n+ occaType arg06,\n+ occaType arg07,\n+ occaType arg08,\n+ occaType arg09,\n+ occaType arg10,\n+ occaType arg11,\n+ occaType arg12,\n+ occaType arg13,\n+ occaType arg14,\n+ occaType arg15,\n+ occaType arg16) {\n+ occaKernelRunN(kernel, argc,\n+ arg01,\n+ arg02,\n+ arg03,\n+ arg04,\n+ arg05,\n+ arg06,\n+ arg07,\n+ arg08,\n+ arg09,\n+ arg10,\n+ arg11,\n+ arg12,\n+ arg13,\n+ arg14,\n+ arg15,\n+ arg16);\n+}\n+\n+void occaKernelRunF17(occaKernel kernel,\n+ const int argc,\n+ occaType arg01,\n+ occaType arg02,\n+ occaType arg03,\n+ occaType arg04,\n+ occaType arg05,\n+ occaType arg06,\n+ occaType arg07,\n+ occaType arg08,\n+ occaType arg09,\n+ occaType arg10,\n+ occaType arg11,\n+ occaType arg12,\n+ occaType arg13,\n+ occaType arg14,\n+ occaType arg15,\n+ occaType arg16,\n+ occaType arg17) {\n+ occaKernelRunN(kernel, argc,\n+ arg01,\n+ arg02,\n+ arg03,\n+ arg04,\n+ arg05,\n+ arg06,\n+ arg07,\n+ arg08,\n+ arg09,\n+ arg10,\n+ arg11,\n+ arg12,\n+ arg13,\n+ arg14,\n+ arg15,\n+ arg16,\n+ arg17);\n+}\n+\n+void occaKernelRunF18(occaKernel kernel,\n+ const int argc,\n+ occaType arg01,\n+ occaType arg02,\n+ occaType arg03,\n+ occaType arg04,\n+ occaType arg05,\n+ occaType arg06,\n+ occaType arg07,\n+ occaType arg08,\n+ occaType arg09,\n+ occaType arg10,\n+ occaType arg11,\n+ occaType arg12,\n+ occaType arg13,\n+ occaType arg14,\n+ occaType arg15,\n+ occaType arg16,\n+ occaType arg17,\n+ occaType arg18) {\n+ occaKernelRunN(kernel, argc,\n+ arg01,\n+ arg02,\n+ arg03,\n+ arg04,\n+ arg05,\n+ arg06,\n+ arg07,\n+ arg08,\n+ arg09,\n+ arg10,\n+ arg11,\n+ arg12,\n+ arg13,\n+ arg14,\n+ arg15,\n+ arg16,\n+ arg17,\n+ arg18);\n+}\n+\n+void occaKernelRunF19(occaKernel kernel,\n+ const int argc,\n+ occaType arg01,\n+ occaType arg02,\n+ occaType arg03,\n+ occaType arg04,\n+ occaType arg05,\n+ occaType arg06,\n+ occaType arg07,\n+ occaType arg08,\n+ occaType arg09,\n+ occaType arg10,\n+ occaType arg11,\n+ occaType arg12,\n+ occaType arg13,\n+ occaType arg14,\n+ occaType arg15,\n+ occaType arg16,\n+ occaType arg17,\n+ occaType arg18,\n+ occaType arg19) {\n+ occaKernelRunN(kernel, argc,\n+ arg01,\n+ arg02,\n+ arg03,\n+ arg04,\n+ arg05,\n+ arg06,\n+ arg07,\n+ arg08,\n+ arg09,\n+ arg10,\n+ arg11,\n+ arg12,\n+ arg13,\n+ arg14,\n+ arg15,\n+ arg16,\n+ arg17,\n+ arg18,\n+ arg19);\n+}\n+\n+void occaKernelRunF20(occaKernel kernel,\n+ const int argc,\n+ occaType arg01,\n+ occaType arg02,\n+ occaType arg03,\n+ occaType arg04,\n+ occaType arg05,\n+ occaType arg06,\n+ occaType arg07,\n+ occaType arg08,\n+ occaType arg09,\n+ occaType arg10,\n+ occaType arg11,\n+ occaType arg12,\n+ occaType arg13,\n+ occaType arg14,\n+ occaType arg15,\n+ occaType arg16,\n+ occaType arg17,\n+ occaType arg18,\n+ occaType arg19,\n+ occaType arg20) {\n+ occaKernelRunN(kernel, argc,\n+ arg01,\n+ arg02,\n+ arg03,\n+ arg04,\n+ arg05,\n+ arg06,\n+ arg07,\n+ arg08,\n+ arg09,\n+ arg10,\n+ arg11,\n+ arg12,\n+ arg13,\n+ arg14,\n+ arg15,\n+ arg16,\n+ arg17,\n+ arg18,\n+ arg19,\n+ arg20);\n+}\n+\n+OCCA_END_EXTERN_C\n" }, { "change_type": "MODIFY", "old_path": "src/fortran/occa_kernel_m.f90", "new_path": "src/fortran/occa_kernel_m.f90", "diff": "! --------------[ DO NOT EDIT ]--------------\n! THIS IS AN AUTOMATICALLY GENERATED FILE\n! EDIT:\n-! scripts/codegen/create_fortran_kernel_module.py\n+! scripts/codegen/create_fortran_kernel_interface.py\n! scripts/codegen/occa_kernel_m.f90.in\n! ===========================================\n+\nmodule occa_kernel_m\n! occa/c/kernel.h\n@@ -144,7 +145,7 @@ module occa_kernel_m\n! void occaKernelRunN(occaKernel kernel, const int argc, ...);\n!\nsubroutine occaKernelRunN01(kernel, argc, arg01) &\n- bind(C, name=\"occaKernelRunN\")\n+ bind(C, name=\"occaKernelRunF01\")\nimport occaKernel, C_int, occaType\nimplicit none\ntype(occaKernel), value :: kernel\n@@ -153,7 +154,7 @@ module occa_kernel_m\nend subroutine\nsubroutine occaKernelRunN02(kernel, argc, arg01, arg02) &\n- bind(C, name=\"occaKernelRunN\")\n+ bind(C, name=\"occaKernelRunF02\")\nimport occaKernel, C_int, occaType\nimplicit none\ntype(occaKernel), value :: kernel\n@@ -162,7 +163,7 @@ module occa_kernel_m\nend subroutine\nsubroutine occaKernelRunN03(kernel, argc, arg01, arg02, arg03) &\n- bind(C, name=\"occaKernelRunN\")\n+ bind(C, name=\"occaKernelRunF03\")\nimport occaKernel, C_int, occaType\nimplicit none\ntype(occaKernel), value :: kernel\n@@ -171,7 +172,7 @@ module occa_kernel_m\nend subroutine\nsubroutine occaKernelRunN04(kernel, argc, arg01, arg02, arg03, arg04) &\n- bind(C, name=\"occaKernelRunN\")\n+ bind(C, name=\"occaKernelRunF04\")\nimport occaKernel, C_int, occaType\nimplicit none\ntype(occaKernel), value :: kernel\n@@ -181,7 +182,7 @@ module occa_kernel_m\nsubroutine occaKernelRunN05(kernel, argc, arg01, arg02, arg03, arg04, &\narg05) &\n- bind(C, name=\"occaKernelRunN\")\n+ bind(C, name=\"occaKernelRunF05\")\nimport occaKernel, C_int, occaType\nimplicit none\ntype(occaKernel), value :: kernel\n@@ -191,7 +192,7 @@ module occa_kernel_m\nsubroutine occaKernelRunN06(kernel, argc, arg01, arg02, arg03, arg04, &\narg05, arg06) &\n- bind(C, name=\"occaKernelRunN\")\n+ bind(C, name=\"occaKernelRunF06\")\nimport occaKernel, C_int, occaType\nimplicit none\ntype(occaKernel), value :: kernel\n@@ -201,7 +202,7 @@ module occa_kernel_m\nsubroutine occaKernelRunN07(kernel, argc, arg01, arg02, arg03, arg04, &\narg05, arg06, arg07) &\n- bind(C, name=\"occaKernelRunN\")\n+ bind(C, name=\"occaKernelRunF07\")\nimport occaKernel, C_int, occaType\nimplicit none\ntype(occaKernel), value :: kernel\n@@ -212,7 +213,7 @@ module occa_kernel_m\nsubroutine occaKernelRunN08(kernel, argc, arg01, arg02, arg03, arg04, &\narg05, arg06, arg07, arg08) &\n- bind(C, name=\"occaKernelRunN\")\n+ bind(C, name=\"occaKernelRunF08\")\nimport occaKernel, C_int, occaType\nimplicit none\ntype(occaKernel), value :: kernel\n@@ -224,7 +225,7 @@ module occa_kernel_m\nsubroutine occaKernelRunN09(kernel, argc, arg01, arg02, arg03, arg04, &\narg05, arg06, arg07, arg08, &\narg09) &\n- bind(C, name=\"occaKernelRunN\")\n+ bind(C, name=\"occaKernelRunF09\")\nimport occaKernel, C_int, occaType\nimplicit none\ntype(occaKernel), value :: kernel\n@@ -236,7 +237,7 @@ module occa_kernel_m\nsubroutine occaKernelRunN10(kernel, argc, arg01, arg02, arg03, arg04, &\narg05, arg06, arg07, arg08, &\narg09, arg10) &\n- bind(C, name=\"occaKernelRunN\")\n+ bind(C, name=\"occaKernelRunF10\")\nimport occaKernel, C_int, occaType\nimplicit none\ntype(occaKernel), value :: kernel\n@@ -248,7 +249,7 @@ module occa_kernel_m\nsubroutine occaKernelRunN11(kernel, argc, arg01, arg02, arg03, arg04, &\narg05, arg06, arg07, arg08, &\narg09, arg10, arg11) &\n- bind(C, name=\"occaKernelRunN\")\n+ bind(C, name=\"occaKernelRunF11\")\nimport occaKernel, C_int, occaType\nimplicit none\ntype(occaKernel), value :: kernel\n@@ -260,7 +261,7 @@ module occa_kernel_m\nsubroutine occaKernelRunN12(kernel, argc, arg01, arg02, arg03, arg04, &\narg05, arg06, arg07, arg08, &\narg09, arg10, arg11, arg12) &\n- bind(C, name=\"occaKernelRunN\")\n+ bind(C, name=\"occaKernelRunF12\")\nimport occaKernel, C_int, occaType\nimplicit none\ntype(occaKernel), value :: kernel\n@@ -273,7 +274,7 @@ module occa_kernel_m\narg05, arg06, arg07, arg08, &\narg09, arg10, arg11, arg12, &\narg13) &\n- bind(C, name=\"occaKernelRunN\")\n+ bind(C, name=\"occaKernelRunF13\")\nimport occaKernel, C_int, occaType\nimplicit none\ntype(occaKernel), value :: kernel\n@@ -287,7 +288,7 @@ module occa_kernel_m\narg05, arg06, arg07, arg08, &\narg09, arg10, arg11, arg12, &\narg13, arg14) &\n- bind(C, name=\"occaKernelRunN\")\n+ bind(C, name=\"occaKernelRunF14\")\nimport occaKernel, C_int, occaType\nimplicit none\ntype(occaKernel), value :: kernel\n@@ -301,7 +302,7 @@ module occa_kernel_m\narg05, arg06, arg07, arg08, &\narg09, arg10, arg11, arg12, &\narg13, arg14, arg15) &\n- bind(C, name=\"occaKernelRunN\")\n+ bind(C, name=\"occaKernelRunF15\")\nimport occaKernel, C_int, occaType\nimplicit none\ntype(occaKernel), value :: kernel\n@@ -315,7 +316,7 @@ module occa_kernel_m\narg05, arg06, arg07, arg08, &\narg09, arg10, arg11, arg12, &\narg13, arg14, arg15, arg16) &\n- bind(C, name=\"occaKernelRunN\")\n+ bind(C, name=\"occaKernelRunF16\")\nimport occaKernel, C_int, occaType\nimplicit none\ntype(occaKernel), value :: kernel\n@@ -330,7 +331,7 @@ module occa_kernel_m\narg09, arg10, arg11, arg12, &\narg13, arg14, arg15, arg16, &\narg17) &\n- bind(C, name=\"occaKernelRunN\")\n+ bind(C, name=\"occaKernelRunF17\")\nimport occaKernel, C_int, occaType\nimplicit none\ntype(occaKernel), value :: kernel\n@@ -345,7 +346,7 @@ module occa_kernel_m\narg09, arg10, arg11, arg12, &\narg13, arg14, arg15, arg16, &\narg17, arg18) &\n- bind(C, name=\"occaKernelRunN\")\n+ bind(C, name=\"occaKernelRunF18\")\nimport occaKernel, C_int, occaType\nimplicit none\ntype(occaKernel), value :: kernel\n@@ -360,7 +361,7 @@ module occa_kernel_m\narg09, arg10, arg11, arg12, &\narg13, arg14, arg15, arg16, &\narg17, arg18, arg19) &\n- bind(C, name=\"occaKernelRunN\")\n+ bind(C, name=\"occaKernelRunF19\")\nimport occaKernel, C_int, occaType\nimplicit none\ntype(occaKernel), value :: kernel\n@@ -376,7 +377,7 @@ module occa_kernel_m\narg09, arg10, arg11, arg12, &\narg13, arg14, arg15, arg16, &\narg17, arg18, arg19, arg20) &\n- bind(C, name=\"occaKernelRunN\")\n+ bind(C, name=\"occaKernelRunF20\")\nimport occaKernel, C_int, occaType\nimplicit none\ntype(occaKernel), value :: kernel\n" } ]
C++
MIT License
libocca/occa
[Fortran] Generate fixed arity interface (#477)
378,355
12.03.2021 00:45:29
21,600
aa6ee009adc0214ed214642a74b2e8235261b169
[HIP] Removing use of __HIP_ROCclr__ since it is marked as deprecated. Using more stable HIP_VERSION check
[ { "change_type": "MODIFY", "old_path": "cmake/FindHIP.cmake", "new_path": "cmake/FindHIP.cmake", "diff": "@@ -108,7 +108,7 @@ if(UNIX AND NOT APPLE AND NOT CYGWIN)\nelseif(${HIP_COMPILER} STREQUAL \"clang\")\nset(HIP_INCLUDE_DIRS \"${HIP_ROOT_DIR}/include\")\nset(HIP_LIBRARIES \"${HIP_ROOT_DIR}/lib/libamdhip64.so\")\n- set(HIP_RUNTIME_DEFINE \"__HIP_PLATFORM_HCC__;__HIP_ROCclr__\")\n+ set(HIP_RUNTIME_DEFINE \"__HIP_PLATFORM_HCC__\")\nset(HIP_PLATFORM \"hip-clang\")\nendif()\nelseif(${HIP_PLATFORM} STREQUAL \"nvcc\")\n" }, { "change_type": "MODIFY", "old_path": "src/occa/internal/modes/hip/device.cpp", "new_path": "src/occa/internal/modes/hip/device.cpp", "diff": "@@ -70,7 +70,7 @@ namespace occa {\nif (startsWith(arch, \"sm_\")) {\narchFlag = \" -arch=\" + arch;\n} else if (startsWith(arch, \"gfx\")) {\n-#ifdef __HIP_ROCclr__\n+#if HIP_VERSION >= 305\narchFlag = \" --amdgpu-target=\" + arch;\n#else\narchFlag = \" -t \" + arch;\n@@ -236,7 +236,7 @@ namespace occa {\n);\nif (hipccCompilerFlags.find(\"-arch=sm\") == std::string::npos &&\n-#ifdef __HIP_ROCclr__\n+#if HIP_VERSION >= 305\nhipccCompilerFlags.find(\"-t gfx\") == std::string::npos\n#else\nhipccCompilerFlags.find(\"--amdgpu-target=gfx\") == std::string::npos\n@@ -278,13 +278,13 @@ namespace occa {\n//---[ Compiling Command ]--------\ncommand << compiler\n<< \" --genco\"\n-#if defined(__HIP_PLATFORM_NVCC___) || defined(__HIP_ROCclr__)\n+#if defined(__HIP_PLATFORM_NVCC___) || (HIP_VERSION >= 305)\n<< ' ' << compilerFlags\n#else\n<< \" -f=\\\\\\\"\" << compilerFlags << \"\\\\\\\"\"\n#endif\n<< ' ' << hipccCompilerFlags\n-#if defined(__HIP_PLATFORM_NVCC___) || defined(__HIP_ROCclr__)\n+#if defined(__HIP_PLATFORM_NVCC___) || (HIP_VERSION >= 305)\n<< \" -I\" << env::OCCA_DIR << \"include\"\n<< \" -I\" << env::OCCA_INSTALL_DIR << \"include\"\n#endif\n" } ]
C++
MIT License
libocca/occa
[HIP] Removing use of __HIP_ROCclr__ since it is marked as deprecated. Using more stable HIP_VERSION check (#486)
378,341
12.03.2021 07:45:44
-3,600
9923f46799461f5acf154cfd8358043ef9f449c5
Attempt to make kernelProperties / compilers more consistent Compiler flags etc are no longer setup on the device, but only when building the kernel (using the same defaults as before). It handles situations where some kernels are C and others are C++ and applies the correct flags/compilers for both cases.
[ { "change_type": "MODIFY", "old_path": "examples/cpp/11_native_c_kernels/main.cpp", "new_path": "examples/cpp/11_native_c_kernels/main.cpp", "diff": "@@ -28,7 +28,6 @@ int main(int argc, const char **argv) {\nocca::device device({\n{\"mode\", \"Serial\"},\n- {\"kernel/compiler\", \"gcc\"},\n// Defaults to 'C++' (not case-sensitive)\n{\"kernel/compiler_language\", \"C\"}\n});\n" }, { "change_type": "MODIFY", "old_path": "src/occa/internal/bin/occa.cpp", "new_path": "src/occa/internal/bin/occa.cpp", "diff": "@@ -242,6 +242,8 @@ namespace occa {\n<< \" Makefile:\\n\"\n<< \" - CXX : \" << envEcho(\"CXX\") << \"\\n\"\n<< \" - CXXFLAGS : \" << envEcho(\"CXXFLAGS\") << \"\\n\"\n+ << \" - CC : \" << envEcho(\"CC\") << \"\\n\"\n+ << \" - CFLAGS : \" << envEcho(\"CFLAGS\") << \"\\n\"\n<< \" - FC : \" << envEcho(\"FC\") << \"\\n\"\n<< \" - FCFLAGS : \" << envEcho(\"FCFLAGS\") << \"\\n\"\n<< \" - LDFLAGS : \" << envEcho(\"LDFLAGS\") << \"\\n\"\n@@ -257,6 +259,8 @@ namespace occa {\n<< \" Run-Time Options:\\n\"\n<< \" - OCCA_CXX : \" << envEcho(\"OCCA_CXX\") << \"\\n\"\n<< \" - OCCA_CXXFLAGS : \" << envEcho(\"OCCA_CXXFLAGS\") << \"\\n\"\n+ << \" - OCCA_CC : \" << envEcho(\"OCCA_CC\") << \"\\n\"\n+ << \" - OCCA_CFLAGS : \" << envEcho(\"OCCA_CFLAGS\") << \"\\n\"\n<< \" - OCCA_LDFLAGS : \" << envEcho(\"OCCA_LDFLAGS\") << \"\\n\"\n<< \" - OCCA_COMPILER_SHARED_FLAGS : \" << envEcho(\"OCCA_COMPILER_SHARED_FLAGS\") << \"\\n\"\n<< \" - OCCA_INCLUDE_PATH : \" << envEcho(\"OCCA_INCLUDE_PATH\") << \"\\n\"\n" }, { "change_type": "MODIFY", "old_path": "src/occa/internal/modes/serial/device.cpp", "new_path": "src/occa/internal/modes/serial/device.cpp", "diff": "namespace occa {\nnamespace serial {\ndevice::device(const occa::json &properties_) :\n- occa::modeDevice_t(properties_) {\n-\n- occa::json &kernelProps = properties[\"kernel\"];\n- std::string compiler;\n- std::string compilerFlags;\n- std::string compilerLanguage;\n- std::string compilerEnvScript;\n- std::string compilerLinkerFlags;\n- std::string compilerSharedFlags;\n-\n- if (env::var(\"OCCA_CXX\").size()) {\n- compiler = env::var(\"OCCA_CXX\");\n- } else if (kernelProps.get<std::string>(\"compiler\").size()) {\n- compiler = (std::string) kernelProps[\"compiler\"];\n- } else if (env::var(\"CXX\").size()) {\n- compiler = env::var(\"CXX\");\n- } else {\n-#if (OCCA_OS & (OCCA_LINUX_OS | OCCA_MACOS_OS))\n- compiler = \"g++\";\n-#else\n- compiler = \"cl.exe\";\n-#endif\n- }\n-\n- if (env::var(\"OCCA_CXXFLAGS\").size()) {\n- compilerFlags = env::var(\"OCCA_CXXFLAGS\");\n- } else if (kernelProps.get<std::string>(\"compiler_flags\").size()) {\n- compilerFlags = (std::string) kernelProps[\"compiler_flags\"];\n- } else if (env::var(\"CXXFLAGS\").size()) {\n- compilerFlags = env::var(\"CXXFLAGS\");\n- } else {\n-#if (OCCA_OS & (OCCA_LINUX_OS | OCCA_MACOS_OS))\n- compilerFlags = \"-O3\";\n-#else\n- compilerFlags = \" /Ox\";\n-#endif\n- }\n-\n- const int compilerVendor = sys::compilerVendor(compiler);\n-\n- if (env::var(\"OCCA_COMPILER_LANGUAGE\").size()) {\n- compilerLanguage = env::var(\"OCCA_COMPILER_LANGUAGE\");\n- } else if (kernelProps.get<std::string>(\"compiler_language\").size()) {\n- compilerLanguage = (std::string) kernelProps[\"compiler_language\"];\n- }\n-\n- // Default to C++\n- const bool compilingCpp = lowercase(compilerLanguage) != \"c\";\n- const int compilerLanguageFlag = (\n- compilingCpp\n- ? sys::language::CPP\n- : sys::language::C\n- );\n- if (compilingCpp) {\n- sys::addCompilerFlags(compilerFlags, sys::compilerCpp11Flags(compilerVendor));\n- } else {\n- sys::addCompilerFlags(compilerFlags, sys::compilerC99Flags(compilerVendor));\n- }\n-\n- if (env::var(\"OCCA_COMPILER_SHARED_FLAGS\").size()) {\n- compilerSharedFlags = env::var(\"OCCA_COMPILER_SHARED_FLAGS\");\n- } else if (kernelProps.get<std::string>(\"compiler_shared_flags\").size()) {\n- compilerSharedFlags = (std::string) kernelProps[\"compiler_shared_flags\"];\n- } else {\n- compilerSharedFlags = sys::compilerSharedBinaryFlags(compilerVendor);\n- }\n-\n- if (env::var(\"OCCA_LDFLAGS\").size()) {\n- compilerLinkerFlags = env::var(\"OCCA_LDFLAGS\");\n- } else if (kernelProps.get<std::string>(\"compiler_linker_flags\").size()) {\n- compilerLinkerFlags = (std::string) kernelProps[\"compiler_linker_flags\"];\n- }\n-\n- if (kernelProps.get<std::string>(\"compiler_env_script\").size()) {\n- compilerEnvScript = (std::string) kernelProps[\"compiler_env_script\"];\n- } else {\n-#if (OCCA_OS == OCCA_WINDOWS_OS)\n- std::string byteness;\n-\n- if (sizeof(void*) == 4) {\n- byteness = \"x86 \";\n- } else if (sizeof(void*) == 8) {\n- byteness = \"amd64\";\n- } else {\n- OCCA_FORCE_ERROR(\"sizeof(void*) is not equal to 4 or 8\");\n- }\n-# if (OCCA_VS_VERSION == 1800)\n- // MSVC++ 12.0 - Visual Studio 2013\n- char *visualStudioTools = getenv(\"VS120COMNTOOLS\");\n-# elif (OCCA_VS_VERSION == 1700)\n- // MSVC++ 11.0 - Visual Studio 2012\n- char *visualStudioTools = getenv(\"VS110COMNTOOLS\");\n-# else\n- //(OCCA_VS_VERSION < 1700)\n- // MSVC++ 10.0 - Visual Studio 2010\n- char *visualStudioTools = getenv(\"VS100COMNTOOLS\");\n-# endif\n-\n- if (visualStudioTools) {\n- compilerEnvScript = \"\\\"\" + std::string(visualStudioTools) + \"..\\\\..\\\\VC\\\\vcvarsall.bat\\\" \" + byteness;\n- } else {\n- io::stdout << \"WARNING: Visual Studio environment variable not found -> compiler environment (vcvarsall.bat) maybe not correctly setup.\" << std::endl;\n- }\n-#endif\n- }\n-\n- kernelProps[\"compiler\"] = compiler;\n- kernelProps[\"compiler_flags\"] = compilerFlags;\n- kernelProps[\"compiler_env_script\"] = compilerEnvScript;\n- kernelProps[\"compiler_vendor\"] = compilerVendor;\n- kernelProps[\"compiler_language\"] = compilerLanguageFlag;\n- kernelProps[\"compiler_linker_flags\"] = compilerLinkerFlags;\n- kernelProps[\"compiler_shared_flags\"] = compilerSharedFlags;\n- }\n+ occa::modeDevice_t(properties_) {}\ndevice::~device() {}\n@@ -206,6 +93,7 @@ namespace occa {\nreturn true;\n}\n+ // TODO: Functionally obsolete overload? kernelProps from the device will now be empty anyway.\nmodeKernel_t* device::buildKernel(const std::string &filename,\nconst std::string &kernelName,\nconst hash_t kernelHash,\n@@ -263,13 +151,129 @@ namespace occa {\nreturn k;\n}\n- std::string sourceFilename;\n- lang::sourceMetadata_t metadata;\n+ std::string compilerLanguage;\n+ std::string compiler;\n+ std::string compilerFlags;\n+ std::string compilerLinkerFlags;\n+ std::string compilerSharedFlags;\n+ std::string compilerEnvScript;\n+\n+ // Default to C++\n+ compilerLanguage = \"cpp\";\n+ if (env::var(\"OCCA_COMPILER_LANGUAGE\").size()) {\n+ compilerLanguage = env::var(\"OCCA_COMPILER_LANGUAGE\");\n+ } else if (kernelProps.get<std::string>(\"compiler_language\").size()) {\n+ compilerLanguage = (std::string) kernelProps[\"compiler_language\"];\n+ }\n+\nconst bool compilingOkl = kernelProps.get(\"okl/enabled\", true);\n- const bool compilingCpp = (\n- ((int) kernelProps[\"compiler_language\"]) == sys::language::CPP\n+ const bool compilingCpp = compilingOkl || (lowercase(compilerLanguage) != \"c\");\n+ const int compilerLanguageFlag = (\n+ compilingCpp\n+ ? sys::language::CPP\n+ : sys::language::C\n);\n+ if (compilerLanguageFlag == sys::language::CPP && env::var(\"OCCA_CXX\").size()) {\n+ compiler = env::var(\"OCCA_CXX\");\n+ } else if (compilerLanguageFlag == sys::language::C && env::var(\"OCCA_CC\").size()) {\n+ compiler = env::var(\"OCCA_CC\");\n+ } else if (kernelProps.get<std::string>(\"compiler\").size()) {\n+ compiler = (std::string) kernelProps[\"compiler\"];\n+ } else if (compilerLanguageFlag == sys::language::CPP && env::var(\"CXX\").size()) {\n+ compiler = env::var(\"CXX\");\n+ } else if (compilerLanguageFlag == sys::language::C && env::var(\"CC\").size()) {\n+ compiler = env::var(\"CC\");\n+ } else if (compilerLanguageFlag == sys::language::CPP) {\n+#if (OCCA_OS & (OCCA_LINUX_OS | OCCA_MACOS_OS))\n+ compiler = \"g++\";\n+#else\n+ compiler = \"cl.exe\";\n+#endif\n+ } else {\n+#if (OCCA_OS & (OCCA_LINUX_OS | OCCA_MACOS_OS))\n+ compiler = \"gcc\";\n+#else\n+ compiler = \"cl.exe\";\n+#endif\n+ }\n+\n+ if (compilerLanguageFlag == sys::language::CPP && env::var(\"OCCA_CXXFLAGS\").size()) {\n+ compilerFlags = env::var(\"OCCA_CXXFLAGS\");\n+ } else if (compilerLanguageFlag == sys::language::C && env::var(\"OCCA_CFLAGS\").size()) {\n+ compilerFlags = env::var(\"OCCA_CFLAGS\");\n+ } else if (kernelProps.get<std::string>(\"compiler_flags\").size()) {\n+ compilerFlags = (std::string) kernelProps[\"compiler_flags\"];\n+ } else if (compilerLanguageFlag == sys::language::CPP && env::var(\"CXXFLAGS\").size()) {\n+ compilerFlags = env::var(\"CXXFLAGS\");\n+ } else if (compilerLanguageFlag == sys::language::C && env::var(\"CFLAGS\").size()) {\n+ compilerFlags = env::var(\"CFLAGS\");\n+ } else {\n+#if (OCCA_OS & (OCCA_LINUX_OS | OCCA_MACOS_OS))\n+ compilerFlags = \"-O3\";\n+#else\n+ compilerFlags = \" /Ox\";\n+#endif\n+ }\n+\n+ const int compilerVendor = sys::compilerVendor(compiler);\n+\n+ if (env::var(\"OCCA_COMPILER_SHARED_FLAGS\").size()) {\n+ compilerSharedFlags = env::var(\"OCCA_COMPILER_SHARED_FLAGS\");\n+ } else if (kernelProps.get<std::string>(\"compiler_shared_flags\").size()) {\n+ compilerSharedFlags = (std::string) kernelProps[\"compiler_shared_flags\"];\n+ } else {\n+ compilerSharedFlags = sys::compilerSharedBinaryFlags(compilerVendor);\n+ }\n+\n+ if (env::var(\"OCCA_LDFLAGS\").size()) {\n+ compilerLinkerFlags = env::var(\"OCCA_LDFLAGS\");\n+ } else if (kernelProps.get<std::string>(\"compiler_linker_flags\").size()) {\n+ compilerLinkerFlags = (std::string) kernelProps[\"compiler_linker_flags\"];\n+ }\n+\n+ if (kernelProps.get<std::string>(\"compiler_env_script\").size()) {\n+ compilerEnvScript = (std::string) kernelProps[\"compiler_env_script\"];\n+ } else {\n+#if (OCCA_OS == OCCA_WINDOWS_OS)\n+ std::string byteness;\n+\n+ if (sizeof(void*) == 4) {\n+ byteness = \"x86 \";\n+ } else if (sizeof(void*) == 8) {\n+ byteness = \"amd64\";\n+ } else {\n+ OCCA_FORCE_ERROR(\"sizeof(void*) is not equal to 4 or 8\");\n+ }\n+# if (OCCA_VS_VERSION == 1800)\n+ // MSVC++ 12.0 - Visual Studio 2013\n+ char *visualStudioTools = getenv(\"VS120COMNTOOLS\");\n+# elif (OCCA_VS_VERSION == 1700)\n+ // MSVC++ 11.0 - Visual Studio 2012\n+ char *visualStudioTools = getenv(\"VS110COMNTOOLS\");\n+# else\n+ //(OCCA_VS_VERSION < 1700)\n+ // MSVC++ 10.0 - Visual Studio 2010\n+ char *visualStudioTools = getenv(\"VS100COMNTOOLS\");\n+# endif\n+\n+ if (visualStudioTools) {\n+ compilerEnvScript = \"\\\"\" + std::string(visualStudioTools) + \"..\\\\..\\\\VC\\\\vcvarsall.bat\\\" \" + byteness;\n+ } else {\n+ io::stdout << \"WARNING: Visual Studio environment variable not found -> compiler environment (vcvarsall.bat) maybe not correctly setup.\" << std::endl;\n+ }\n+#endif\n+ }\n+\n+ if (compilerLanguageFlag == sys::language::CPP) {\n+ sys::addCompilerFlags(compilerFlags, sys::compilerCpp11Flags(compilerVendor));\n+ } else if (compilerLanguageFlag == sys::language::C) {\n+ sys::addCompilerFlags(compilerFlags, sys::compilerC99Flags(compilerVendor));\n+ }\n+\n+ std::string sourceFilename;\n+ lang::sourceMetadata_t metadata;\n+\nif (isLauncherKernel) {\nsourceFilename = filename;\n} else {\n@@ -306,16 +310,10 @@ namespace occa {\n}\nstd::stringstream command;\n- std::string compilerEnvScript = kernelProps[\"compiler_env_script\"];\nif (compilerEnvScript.size()) {\ncommand << compilerEnvScript << \" && \";\n}\n- const std::string compiler = kernelProps[\"compiler\"];\n- std::string compilerFlags = kernelProps[\"compiler_flags\"];\n- std::string compilerLinkerFlags = kernelProps[\"compiler_linker_flags\"];\n- std::string compilerSharedFlags = kernelProps[\"compiler_shared_flags\"];\n-\nsys::addCompilerFlags(compilerFlags, compilerSharedFlags);\nif (!compilingOkl) {\n" } ]
C++
MIT License
libocca/occa
Attempt to make kernelProperties / compilers more consistent (#483) Compiler flags etc are no longer setup on the device, but only when building the kernel (using the same defaults as before). It handles situations where some kernels are C and others are C++ and applies the correct flags/compilers for both cases.
378,349
12.04.2021 01:54:33
14,400
c42d2fd6ac8010cf31dbc325b0457fbe889a8e72
[#487][Lang] Missed checking iterator for-loop statement
[ { "change_type": "MODIFY", "old_path": ".github/workflows/build.yml", "new_path": ".github/workflows/build.yml", "diff": "@@ -11,59 +11,49 @@ jobs:\nstrategy:\nmatrix:\ninclude:\n- - name: (Ubuntu) gcc-8\n- os: ubuntu-18.04\n- CC: gcc-8\n- CXX: g++-8\n+ - name: \"[Ubuntu] gcc-9\"\n+ os: ubuntu-latest\n+ CC: gcc-9\n+ CXX: g++-9\nCXXFLAGS: -Wno-maybe-uninitialized\n- FC: gfortran-8\n- GCOV: gcov-8\n+ FC: gfortran-9\n+ GCOV: gcov-9\nOCCA_COVERAGE: 1\nOCCA_FORTRAN_ENABLED: 1\n- - name: (Ubuntu) CMake + gcc-8\n- os: ubuntu-18.04\n- CC: gcc-8\n- CXX: g++-8\n- CXXFLAGS: -Wno-maybe-uninitialized -Wno-cpp\n- GCOV: gcov-8\n- OCCA_COVERAGE: 1\n- useCMake: true\n-\n- - name: (Ubuntu) gcc-9\n- os: ubuntu-18.04\n+ - name: \"[Ubuntu] CMake + gcc-9\"\n+ os: ubuntu-latest\nCC: gcc-9\nCXX: g++-9\n- CXXFLAGS: -Wno-maybe-uninitialized\n- FC: gfortran-9\n+ CXXFLAGS: -Wno-maybe-uninitialized -Wno-cpp\nGCOV: gcov-9\nOCCA_COVERAGE: 1\n- OCCA_FORTRAN_ENABLED: 1\n+ useCMake: true\n- - name: (Ubuntu) clang-6\n- os: ubuntu-18.04\n- CC: clang-6.0\n- CXX: clang++-6.0\n+ - name: \"[Ubuntu] clang-10\"\n+ os: ubuntu-latest\n+ CC: clang-10\n+ CXX: clang++-10\nCXXFLAGS: -Wno-uninitialized\nOCCA_COVERAGE: 0\n- - name: (Ubuntu) clang-9\n- os: ubuntu-18.04\n+ - name: \"[Ubuntu] clang-9\"\n+ os: ubuntu-latest\nCC: clang-9\nCXX: clang++-9\nCXXFLAGS: -Wno-uninitialized\nOCCA_COVERAGE: 0\n- - name: (MacOS) gcc-9\n- os: macos-10.15\n+ - name: \"[MacOS] gcc-9\"\n+ os: macos-latest\nCC: gcc-9\nCXX: g++-9\nCXXFLAGS: -Wno-maybe-uninitialized\nGCOV: gcov-9\nOCCA_COVERAGE: 1\n- - name: (MacOS) clang\n- os: macos-10.15\n+ - name: \"[MacOS] clang\"\n+ os: macos-latest\nCC: clang\nCXX: clang++\nCXXFLAGS: -Wno-uninitialized\n" }, { "change_type": "MODIFY", "old_path": "scripts/build/shellTools.sh", "new_path": "scripts/build/shellTools.sh", "diff": "@@ -234,6 +234,11 @@ function compilerVendor {\nlocal binaryFilename=\"${OCCA_SOURCE_SCRIPTS_DIR}/findCompilerVendor\"\neval \"${compiler}\" \"${testFilename}\" -o \"${binaryFilename}\" > /dev/null 2>&1\n+ if [[ \"$?\" -ne 0 ]]; then\n+ echo \"Failed to build findCompilerVendor:\"\n+ eval \"${compiler}\" \"${testFilename}\" -o \"${binaryFilename}\"\n+ fi\n+\neval \"${binaryFilename}\"\nbit=\"$?\"\n" }, { "change_type": "MODIFY", "old_path": "src/occa/internal/lang/modes/oklForStatement.cpp", "new_path": "src/occa/internal/lang/modes/oklForStatement.cpp", "diff": "@@ -366,7 +366,7 @@ namespace occa {\nreturn (int) oklAttrToken.args[0].expr->evaluate();\n}\n- // Find index by looking at how many for-loops of the same attribute are in it\n+ // Find index by looking at how many for-loops of the same attribute are inside\nint maxInnerCount = 0;\nforOklForLoopStatements(\nforSmnt_,\n@@ -374,13 +374,19 @@ namespace occa {\nconst std::string innerAttr,\nconst statementArray &path) {\n+ const auto isInnerOklLoop = [&](statement_t *smnt) {\n+ return (\n+ (smnt != &forSmnt_)\n+ && (smnt->type() & statementType::for_)\n+ && smnt->hasAttribute(oklAttr_)\n+ );\n+ };\n+\n+ // Check innerForSmnt first\n+ // Then add to the matched statements between forSmnt_ and innerForSmnt\nconst int innerCount = (\n- path\n- .filter([&](statement_t *smnt) {\n- return ((smnt->type() & statementType::for_)\n- && smnt->hasAttribute(oklAttr_));\n- })\n- .length()\n+ isInnerOklLoop(&innerForSmnt)\n+ + path.filter(isInnerOklLoop).length()\n);\nif (innerCount > maxInnerCount) {\n@@ -388,8 +394,7 @@ namespace occa {\n}\n});\n- // Index is 1 less than count\n- return maxInnerCount ? maxInnerCount - 1 : 0;\n+ return maxInnerCount;\n}\nstatementArray oklForStatement::getOklLoopPath() {\n" }, { "change_type": "MODIFY", "old_path": "src/occa/internal/lang/type/pointer.cpp", "new_path": "src/occa/internal/lang/type/pointer.cpp", "diff": "@@ -10,6 +10,11 @@ namespace occa {\npointer_t::pointer_t(const pointer_t &other) :\nqualifiers(other.qualifiers) {}\n+ pointer_t& pointer_t::operator = (const pointer_t &other) {\n+ qualifiers = other.qualifiers;\n+ return *this;\n+ }\n+\nbool pointer_t::has(const qualifier_t &qualifier) const {\nreturn qualifiers.has(qualifier);\n}\n" }, { "change_type": "MODIFY", "old_path": "src/occa/internal/lang/type/pointer.hpp", "new_path": "src/occa/internal/lang/type/pointer.hpp", "diff": "@@ -13,6 +13,8 @@ namespace occa {\npointer_t(const qualifiers_t &qualifiers_);\npointer_t(const pointer_t &other);\n+ pointer_t& operator = (const pointer_t &other);\n+\nbool has(const qualifier_t &qualifier) const;\nvoid operator += (const qualifier_t &qualifier);\n" } ]
C++
MIT License
libocca/occa
[#487][Lang] Missed checking iterator for-loop statement (#492)
378,341
01.09.2021 20:54:21
-7,200
327582bfb6667defb008d743961fa38053960214
[Tests] Update GitHub build ubuntu-latest has moved beyond 20210517.1, from which point clang-9 is no longer included - 10/11/12 are available. Drop clang 9, use clang 11 instead.
[ { "change_type": "MODIFY", "old_path": ".github/workflows/build.yml", "new_path": ".github/workflows/build.yml", "diff": "@@ -30,17 +30,17 @@ jobs:\nOCCA_COVERAGE: 1\nuseCMake: true\n- - name: \"[Ubuntu] clang-10\"\n+ - name: \"[Ubuntu] clang-11\"\nos: ubuntu-latest\n- CC: clang-10\n- CXX: clang++-10\n+ CC: clang-11\n+ CXX: clang++-11\nCXXFLAGS: -Wno-uninitialized\nOCCA_COVERAGE: 0\n- - name: \"[Ubuntu] clang-9\"\n+ - name: \"[Ubuntu] clang-10\"\nos: ubuntu-latest\n- CC: clang-9\n- CXX: clang++-9\n+ CC: clang-10\n+ CXX: clang++-10\nCXXFLAGS: -Wno-uninitialized\nOCCA_COVERAGE: 0\n" } ]
C++
MIT License
libocca/occa
[Tests] Update GitHub build (#499) ubuntu-latest has moved beyond 20210517.1, from which point clang-9 is no longer included - 10/11/12 are available. Drop clang 9, use clang 11 instead.
378,349
05.09.2021 20:02:10
14,400
8a82df1157ccb18d6fda9bd9e8940a51d8b939d2
Print compilation error
[ { "change_type": "MODIFY", "old_path": "src/occa/internal/modes/cuda/device.cpp", "new_path": "src/occa/internal/modes/cuda/device.cpp", "diff": "@@ -326,22 +326,28 @@ namespace occa {\n<< \" -I\" << env::OCCA_INSTALL_DIR << \"include\"\n<< \" -L\" << env::OCCA_INSTALL_DIR << \"lib -locca\"\n<< \" -x cu \" << sourceFilename\n- << \" -o \" << binaryFilename;\n+ << \" -o \" << binaryFilename\n+ << \" 2>&1\";\n- if (!verbose) {\n- command << \" > /dev/null 2>&1\";\n- }\nconst std::string &sCommand = command.str();\nif (verbose) {\n- io::stdout << sCommand << '\\n';\n+ io::stdout << \"Compiling [\" << kernelName << \"]\\n\" << sCommand << \"\\n\";\n}\n- const int compileError = system(sCommand.c_str());\n+ std::string commandOutput;\n+ const int commandExitCode = sys::call(\n+ sCommand.c_str(),\n+ commandOutput\n+ );\nlock.release();\n- if (compileError) {\n- OCCA_FORCE_ERROR(\"Error compiling [\" << kernelName << \"],\"\n- \" Command: [\" << sCommand << ']');\n+ if (commandExitCode) {\n+ OCCA_FORCE_ERROR(\n+ \"Error compiling [\" << kernelName << \"],\"\n+ \" Command: [\" << sCommand << ']'\n+ << \"Output:\\n\\n\"\n+ << commandOutput << \"\\n\"\n+ );\n}\n//================================\n}\n" }, { "change_type": "MODIFY", "old_path": "src/occa/internal/modes/hip/device.cpp", "new_path": "src/occa/internal/modes/hip/device.cpp", "diff": "@@ -291,22 +291,28 @@ namespace occa {\n/* NC: hipcc doesn't seem to like linking a library in */\n//<< \" -L\" << env::OCCA_INSTALL_DIR << \"lib -locca\"\n<< ' ' << sourceFilename\n- << \" -o \" << binaryFilename;\n+ << \" -o \" << binaryFilename\n+ << \" 2>&1\";\n- if (!verbose) {\n- command << \" > /dev/null 2>&1\";\n- }\nconst std::string &sCommand = command.str();\nif (verbose) {\n- io::stdout << sCommand << '\\n';\n+ io::stdout << \"Compiling [\" << kernelName << \"]\\n\" << sCommand << \"\\n\";\n}\n- const int compileError = system(sCommand.c_str());\n+ std::string commandOutput;\n+ const int commandExitCode = sys::call(\n+ sCommand.c_str(),\n+ commandOutput\n+ );\nlock.release();\n- if (compileError) {\n- OCCA_FORCE_ERROR(\"Error compiling [\" << kernelName << \"],\"\n- \" Command: [\" << sCommand << ']');\n+ if (commandExitCode) {\n+ OCCA_FORCE_ERROR(\n+ \"Error compiling [\" << kernelName << \"],\"\n+ \" Command: [\" << sCommand << \"]\\n\"\n+ << \"Output:\\n\\n\"\n+ << commandOutput << \"\\n\"\n+ );\n}\n//================================\n}\n" }, { "change_type": "MODIFY", "old_path": "src/occa/internal/modes/serial/device.cpp", "new_path": "src/occa/internal/modes/serial/device.cpp", "diff": "@@ -330,6 +330,7 @@ namespace occa {\n<< \" -I\" << env::OCCA_INSTALL_DIR << \"include\"\n<< \" -L\" << env::OCCA_INSTALL_DIR << \"lib -locca\"\n<< ' ' << compilerLinkerFlags\n+ << \" 2>&1\"\n<< std::endl;\n#else\ncommand << kernelProps[\"compiler\"]\n@@ -348,21 +349,31 @@ namespace occa {\n#endif\nconst std::string &sCommand = strip(command.str());\n-\nif (verbose) {\nio::stdout << \"Compiling [\" << kernelName << \"]\\n\" << sCommand << \"\\n\";\n}\n+ std::string commandOutput;\n#if (OCCA_OS & (OCCA_LINUX_OS | OCCA_MACOS_OS))\n- const int compileError = system(sCommand.c_str());\n+ const int commandExitCode = sys::call(\n+ sCommand.c_str(),\n+ commandOutput\n+ );\n#else\n- const int compileError = system((\"\\\"\" + sCommand + \"\\\"\").c_str());\n+ const int commandExitCode = sys::call(\n+ (\"\\\"\" + sCommand + \"\\\"\").c_str(),\n+ commandOutput\n+ );\n#endif\nlock.release();\n- if (compileError) {\n- OCCA_FORCE_ERROR(\"Error compiling [\" << kernelName << \"],\"\n- \" Command: [\" << sCommand << ']');\n+ if (commandExitCode) {\n+ OCCA_FORCE_ERROR(\n+ \"Error compiling [\" << kernelName << \"],\"\n+ \" Command: [\" << sCommand << \"]\\n\"\n+ << \"Output:\\n\\n\"\n+ << commandOutput << \"\\n\"\n+ );\n}\nmodeKernel_t *k = buildKernelFromBinary(binaryFilename,\n" }, { "change_type": "MODIFY", "old_path": "tests/src/fortran/typedefs_helper.cpp", "new_path": "tests/src/fortran/typedefs_helper.cpp", "diff": "@@ -75,7 +75,7 @@ void printOccaType(const occaType *value, const bool verbose) {\nprintf(\"\\n\");\nprintf(\" magicHeader: %d\\n\", value->magicHeader);\nprintf(\" type: %d\\n\", value->type);\n- printf(\" bytes: %ld\\n\", value->bytes);\n+ printf(\" bytes: %ld\\n\", (long) value->bytes);\nprintf(\" needsFree: %d (%s)\\n\", value->needsFree,\nvalue->needsFree ? \"true\" : \"false\");\nprintf(\" value (C `union`):\\n\");\n@@ -84,17 +84,17 @@ void printOccaType(const occaType *value, const bool verbose) {\nprintf(\" value.uint8_: %d\\n\", value->value.uint8_);\nprintf(\" value.uint16_: %d\\n\", value->value.uint16_);\nprintf(\" value.uint32_: %d\\n\", value->value.uint32_);\n- printf(\" value.uint64_: %ld\\n\", value->value.uint64_);\n+ printf(\" value.uint64_: %ld\\n\", (long) value->value.uint64_);\nprintf(\" value.int8_: %d\\n\", value->value.int8_);\nprintf(\" value.int16_: %d\\n\", value->value.int16_);\nprintf(\" value.int32_: %d\\n\", value->value.int32_);\n- printf(\" value.int64_: %ld\\n\", value->value.int64_);\n+ printf(\" value.int64_: %ld\\n\", (long) value->value.int64_);\nprintf(\" value.float_: %f\\n\", value->value.float_);\nprintf(\" value.double_: %f\\n\", value->value.double_);\nprintf(\" value.ptr: %p\\n\", (void*) value->value.ptr);\n} else {\n// In the Fortran module we store the data as int64\n- printf(\" value.int64_: %ld\\n\", value->value.int64_);\n+ printf(\" value.int64_: %ld\\n\", (long) value->value.int64_);\nprintf(\" value.ptr: %p\\n\", (void*) value->value.ptr);\n}\nprintf(\" ===============================================\\n\");\n" } ]
C++
MIT License
libocca/occa
[#188] Print compilation error (#503)
378,341
07.09.2021 21:20:38
-7,200
d4f01fe126f76a4ec8b0f7e59954d4e283d4abbc
[OpenMP] Fix conflict with re-used stringstream in closure Previously this used the 'ss' stringstream both inside the closure and outside, resulting in the first element of the compiler invocation (i.e. the compiler executable) sometimes ending up in flag, instead of the actual OpenMP flag.
[ { "change_type": "MODIFY", "old_path": "src/occa/internal/modes/openmp/utils.cpp", "new_path": "src/occa/internal/modes/openmp/utils.cpp", "diff": "@@ -54,17 +54,18 @@ namespace occa {\n[&](const strVector &tempFilenames) -> bool {\nconst std::string &tempBinaryFilename = tempFilenames[0];\nconst std::string &tempOutFilename = tempFilenames[1];\n+ std::stringstream ss_;\n// Try to compile a minimal OpenMP file to see whether\n// the compiler supports OpenMP or not\nstd::string flag = baseCompilerFlag(vendor_);\n- ss << compiler\n+ ss_ << compiler\n<< ' ' << flag\n<< ' ' << srcFilename\n<< \" -o \" << tempBinaryFilename\n<< \" > /dev/null 2>&1\";\n- const std::string compileLine = ss.str();\n+ const std::string compileLine = ss_.str();\nconst int compileError = system(compileLine.c_str());\nif (compileError) {\n" } ]
C++
MIT License
libocca/occa
[OpenMP] Fix conflict with re-used stringstream in closure (#510) Previously this used the 'ss' stringstream both inside the closure and outside, resulting in the first element of the compiler invocation (i.e. the compiler executable) sometimes ending up in flag, instead of the actual OpenMP flag.
378,341
08.09.2021 03:25:52
-7,200
e39975c1947973dfd334904e6ca38fcd1c7c9a6a
[Internal] Fix another conflict with re-used stringstream in closure
[ { "change_type": "MODIFY", "old_path": "src/occa/internal/utils/sys.cpp", "new_path": "src/occa/internal/utils/sys.cpp", "diff": "@@ -742,13 +742,14 @@ namespace occa {\n[&](const strVector &tempFilenames) -> bool {\nconst std::string &tempBinaryFilename = tempFilenames[0];\nconst std::string &tempBuildLogFilename = tempFilenames[1];\n+ std::stringstream ss_;\n- ss << compiler\n+ ss_ << compiler\n<< ' ' << srcFilename\n<< \" -o \" << tempBinaryFilename\n<< \" > \" << tempBuildLogFilename << \" 2>&1\";\n- const std::string compileLine = ss.str();\n+ const std::string compileLine = ss_.str();\nignoreResult( system(compileLine.c_str()) );\nOCCA_ERROR(\n" } ]
C++
MIT License
libocca/occa
[Internal] Fix another conflict with re-used stringstream in closure (#511)
378,351
13.09.2021 00:20:53
18,000
6bf93489243b44c2342222d81c62f535abbffb03
[Bugfix][DPCPP] Use correct binary filename when compiling DPC++ kernels.
[ { "change_type": "MODIFY", "old_path": "src/occa/internal/modes/dpcpp/device.cpp", "new_path": "src/occa/internal/modes/dpcpp/device.cpp", "diff": "@@ -130,6 +130,8 @@ namespace occa\n{\ncompileKernel(hashDir,\nkernelName,\n+ sourceFilename,\n+ binaryFilename,\nkernelProps);\nif (usingOkl)\n@@ -163,14 +165,13 @@ namespace occa\nvoid device::compileKernel(const std::string &hashDir,\nconst std::string &kernelName,\n+ const std::string &sourceFilename,\n+ const std::string &binaryFilename,\nconst occa::json &kernelProps)\n{\nocca::json allProps = kernelProps;\nconst bool verbose = allProps.get(\"verbose\", false);\n- std::string sourceFilename = hashDir + kc::sourceFile;\n- std::string binaryFilename = hashDir + kc::binaryFile;\n-\nsetArchCompilerFlags(allProps);\nconst bool compilingOkl = allProps.get(\"okl/enabled\", true);\n" }, { "change_type": "MODIFY", "old_path": "src/occa/internal/modes/dpcpp/device.hpp", "new_path": "src/occa/internal/modes/dpcpp/device.hpp", "diff": "@@ -59,6 +59,8 @@ namespace occa\nvoid compileKernel(const std::string &hashDir,\nconst std::string &kernelName,\n+ const std::string &sourceFilename,\n+ const std::string &binaryFilename,\nconst occa::json &kernelProps);\nvirtual modeKernel_t *buildOKLKernelFromBinary(const hash_t kernelHash,\n" } ]
C++
MIT License
libocca/occa
[Bugfix][DPCPP] Use correct binary filename when compiling DPC++ kernels. (#513)
378,342
13.09.2021 12:17:01
18,000
5028b14eb6448f6264bcc12b9d05f9eaab827606
Avoid using strncmp in occa::primitive::load whenever the string is too short.
[ { "change_type": "MODIFY", "old_path": "src/types/primitive.cpp", "new_path": "src/types/primitive.cpp", "diff": "@@ -29,6 +29,9 @@ namespace occa {\nconst char *c0 = c;\nprimitive p;\n+ const int cLength = strlen(c);\n+\n+ if(cLength >= 4){\nif (strncmp(c, \"true\", 4) == 0) {\np = true;\np.source = \"true\";\n@@ -36,6 +39,8 @@ namespace occa {\nc += 4;\nreturn p;\n}\n+ }\n+ if(cLength >= 5){\nif (strncmp(c, \"false\", 5) == 0) {\np = false;\np.source = \"false\";\n@@ -43,6 +48,7 @@ namespace occa {\nc += 5;\nreturn p;\n}\n+ }\nif ((*c == '+') || (*c == '-')) {\nif (!includeSign) {\n" } ]
C++
MIT License
libocca/occa
(#495) Avoid using strncmp in occa::primitive::load whenever the string is too short. (#496)
378,351
17.09.2021 22:15:07
18,000
9fc908fa7d7ce2d1b9f7cba80a804ae73c29b368
[Bugfix][OpenCL] Update opencl timing to give meaningful results.
[ { "change_type": "MODIFY", "old_path": "src/occa/internal/modes/opencl/device.cpp", "new_path": "src/occa/internal/modes/opencl/device.cpp", "diff": "@@ -112,11 +112,11 @@ namespace occa {\n#ifdef CL_VERSION_1_2\nOCCA_OPENCL_ERROR(\"Device: Tagging Stream\",\n- clEnqueueMarkerWithWaitList(getCommandQueue(),\n+ clEnqueueBarrierWithWaitList(getCommandQueue(),\n0, NULL, &clEvent));\n#else\nOCCA_OPENCL_ERROR(\"Device: Tagging Stream\",\n- clEnqueueMarker(getCommandQueue(),\n+ clEnqueueBarrier(getCommandQueue(),\n&clEvent));\n#endif\n@@ -140,9 +140,9 @@ namespace occa {\ndynamic_cast<occa::opencl::streamTag*>(endTag.getModeStreamTag())\n);\n- finish();\n+ waitFor(endTag);\n- return (clEndTag->getTime() - clStartTag->getTime());\n+ return (clEndTag->endTime() - clStartTag->startTime());\n}\ncl_command_queue& device::getCommandQueue() const {\n" }, { "change_type": "MODIFY", "old_path": "src/occa/internal/modes/opencl/polyfill.hpp", "new_path": "src/occa/internal/modes/opencl/polyfill.hpp", "diff": "@@ -91,6 +91,7 @@ namespace occa {\nstatic cl_mem_flags CL_MEM_ALLOC_HOST_PTR = 2;\nstatic cl_profiling_info CL_PROFILING_COMMAND_END = 0;\n+ static cl_profiling_info CL_PROFILING_COMMAND_START = 1;\nstatic cl_program_build_info CL_PROGRAM_BUILD_LOG = 0;\n@@ -210,6 +211,18 @@ namespace occa {\nreturn OCCA_OPENCL_IS_NOT_ENABLED;\n}\n+ inline cl_int clEnqueueBarrier(cl_command_queue command_queue,\n+ cl_event *event) {\n+ return OCCA_OPENCL_IS_NOT_ENABLED;\n+ }\n+\n+ inline cl_int clEnqueueBarrierWithWaitList(cl_command_queue command_queue ,\n+ cl_uint num_events_in_wait_list ,\n+ const cl_event *event_wait_list ,\n+ cl_event *event) {\n+ return OCCA_OPENCL_IS_NOT_ENABLED;\n+ }\n+\ninline cl_int clGetEventProfilingInfo(cl_event event,\ncl_profiling_info param_name,\nsize_t param_value_size,\n" }, { "change_type": "MODIFY", "old_path": "src/occa/internal/modes/opencl/streamTag.cpp", "new_path": "src/occa/internal/modes/opencl/streamTag.cpp", "diff": "@@ -7,24 +7,40 @@ namespace occa {\ncl_event clEvent_) :\nmodeStreamTag_t(modeDevice_),\nclEvent(clEvent_),\n- time(-1) {}\n+ start_time(-1),\n+ end_time(-1) {}\nstreamTag::~streamTag() {\nOCCA_OPENCL_ERROR(\"streamTag: Freeing cl_event\",\nclReleaseEvent(clEvent));\n}\n- double streamTag::getTime() {\n- if (time < 0) {\n+ double streamTag::startTime() {\n+ if (start_time < 0) {\n+ cl_ulong clTime;\n+ OCCA_OPENCL_ERROR(\"streamTag: Getting event profiling info\",\n+ clGetEventProfilingInfo(clEvent,\n+ CL_PROFILING_COMMAND_START,\n+ sizeof(cl_ulong),\n+ &clTime, NULL));\n+ constexpr double nanoseconds{1.0e-9};\n+ start_time = nanoseconds * static_cast<double>(clTime);\n+ }\n+ return start_time;\n+ }\n+\n+ double streamTag::endTime() {\n+ if (end_time < 0) {\ncl_ulong clTime;\nOCCA_OPENCL_ERROR(\"streamTag: Getting event profiling info\",\nclGetEventProfilingInfo(clEvent,\nCL_PROFILING_COMMAND_END,\nsizeof(cl_ulong),\n&clTime, NULL));\n- time = 1.0e-9 * clTime;\n+ constexpr double nanoseconds{1.0e-9};\n+ end_time = nanoseconds * static_cast<double>(clTime);\n}\n- return time;\n+ return end_time;\n}\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/occa/internal/modes/opencl/streamTag.hpp", "new_path": "src/occa/internal/modes/opencl/streamTag.hpp", "diff": "@@ -9,14 +9,16 @@ namespace occa {\nclass streamTag : public occa::modeStreamTag_t {\npublic:\ncl_event clEvent;\n- double time;\n+ double start_time;\n+ double end_time;\nstreamTag(modeDevice_t *modeDevice_,\ncl_event clEvent_);\nvirtual ~streamTag();\n- double getTime();\n+ double startTime();\n+ double endTime();\n};\n}\n}\n" } ]
C++
MIT License
libocca/occa
[Bugfix][OpenCL] Update opencl timing to give meaningful results. (#518)
378,351
06.10.2021 22:20:20
18,000
95b7a37e17b27841aefbe0f0bc8e985c76ef5665
Remove C++17 features from DPC++ headers.
[ { "change_type": "MODIFY", "old_path": "CMakeLists.txt", "new_path": "CMakeLists.txt", "diff": "@@ -19,6 +19,7 @@ if(NOT CMAKE_BUILD_TYPE)\nset(CMAKE_BUILD_TYPE \"Release\" CACHE STRING \"Build type\" FORCE)\nendif()\n+# CMake will decay to a previous C++ standard if a compiler does not support C++17\nset(CMAKE_CXX_STANDARD 17)\nset(CMAKE_CXX_STANDARD_REQUIRED ON)\nset(CMAKE_CXX_EXTENSIONS OFF)\n@@ -215,12 +216,8 @@ if(ENABLE_DPCPP)\nmessage(CHECK_PASS \"found all components\")\nset(OCCA_DPCPP_ENABLED 1)\n- set(SYCL_CXX_FLAGS \"-fsycl\")\n- message(\"-- SYCL CXX flags: ${SYCL_CXX_FLAGS}\")\n-\ntarget_include_directories(libocca PRIVATE ${SYCL_INCLUDE_DIRS})\ntarget_link_libraries(libocca PRIVATE ${SYCL_LIBRARIES})\n- target_compile_options(libocca BEFORE PRIVATE \"${SYCL_CXX_FLAGS}\")\nendif()\nendif(ENABLE_DPCPP)\n#=======================================\n@@ -302,10 +299,6 @@ if(OCCA_OPENMP_ENABLED)\nCOMPILE_FLAGS ${OpenMP_CXX_FLAGS})\nendif()\n-if(OCCA_DPCPP_ENABLED)\n- set_source_files_properties(${OCCA_SRC_cpp} PROPERTIES COMPILE_FLAGS ${SYCL_CXX_FLAGS})\n-endif()\n-\nif(ENABLE_FORTRAN)\nfile(GLOB_RECURSE OCCA_SRC_f90\nRELATIVE ${OCCA_SOURCE_DIR} \"src/*.f90\")\n" }, { "change_type": "MODIFY", "old_path": "src/occa/internal/lang/expr/dpcppAtomicNode.cpp", "new_path": "src/occa/internal/lang/expr/dpcppAtomicNode.cpp", "diff": "@@ -32,17 +32,13 @@ namespace occa\nvoid dpcppAtomicNode::print(printer &pout) const\n{\n- pout << sycl_atomic_ref;\n- pout << \"<\";\n+ pout << \"sycl::ONEAPI::atomic_ref<\";\n// Currently CUDA only supports atomics on fundamental types:\n// assume that we can safefuly ignore the pointer types for now\n// and simply print the typename.\n- pout << atomic_type.name();\n- pout << \",\";\n-\n- pout << memory_order_relaxed;\n- pout << \",\";\n+ pout << atomic_type.name() << \",\";\n+ pout << \"sycl::ONEAPI::memory_order::relaxed,\";\n// The SYCL standard states,\n//\n@@ -53,16 +49,15 @@ namespace occa\n// Currently OCCA does not address system-wide atomics;\n// therefore, assume for now that we can always safely\n// use `memory_scope::device`.\n- pout << memory_scope_device;\n- pout << \",\";\n+ pout << \"sycl::ONEAPI::memory_scope::device,\";\nif(atomic_type.hasAttribute(\"shared\"))\n{\n- pout << address_space_local_space;\n+ pout << \"sycl::access::address_space::global_space\";\n}\nelse\n{\n- pout << address_space_global_space;\n+ pout << \"sycl::access::address_space::local_space\";\n}\npout << \">(\";\n" }, { "change_type": "MODIFY", "old_path": "src/occa/internal/lang/expr/dpcppAtomicNode.hpp", "new_path": "src/occa/internal/lang/expr/dpcppAtomicNode.hpp", "diff": "@@ -35,15 +35,6 @@ namespace occa\nvirtual void print(printer &pout) const;\nvirtual void debugPrint(const std::string &prefix) const;\n-\n- private:\n- inline static const std::string sycl_atomic_ref{\"sycl::ONEAPI::atomic_ref\"};\n- inline static const std::string memory_order_relaxed{\"sycl::ONEAPI::memory_order::relaxed\"};\n-\n- inline static const std::string memory_scope_device{\"sycl::ONEAPI::memory_scope::device\"};\n-\n- inline static const std::string address_space_global_space{\"sycl::access::address_space::global_space\"};\n- inline static const std::string address_space_local_space{\"sycl::access::address_space::local_space\"};\n};\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/occa/internal/lang/modes/dpcpp.cpp", "new_path": "src/occa/internal/lang/modes/dpcpp.cpp", "diff": "@@ -68,12 +68,12 @@ namespace occa\nstd::string dpcppParser::getOuterIterator(const int loopIndex)\n{\n- return work_item_name + \".get_group(\" + occa::toString(dpcppDimensionOrder(loopIndex)) + \")\";\n+ return \"item_.get_group(\" + occa::toString(dpcppDimensionOrder(loopIndex)) + \")\";\n}\nstd::string dpcppParser::getInnerIterator(const int loopIndex)\n{\n- return work_item_name + \".get_local_id(\" + occa::toString(dpcppDimensionOrder(loopIndex)) + \")\";\n+ return \"item_.get_local_id(\" + occa::toString(dpcppDimensionOrder(loopIndex)) + \")\";\n}\n// @note: As of SYCL 2020 this will need to change from `CL/sycl.hpp` to `sycl.hpp`\n@@ -82,7 +82,7 @@ namespace occa\nroot.addFirst(\n*(new directiveStatement(\n&root,\n- directiveToken(root.source->origin, \"include <\" + sycl_header + \">\"))));\n+ directiveToken(root.source->origin, \"include <sycl.hpp>\"))));\n}\nvoid dpcppParser::addExtensions()\n@@ -131,7 +131,7 @@ namespace occa\nstatement_t &barrierSmnt = (*(new sourceCodeStatement(\nemptySmnt.up,\nemptySmnt.source,\n- work_item_name + \".barrier(sycl::access::fence_space::local_space);\")));\n+ \"item_.barrier(sycl::access::fence_space::local_space);\")));\nemptySmnt.replaceWith(barrierSmnt);\n@@ -158,16 +158,16 @@ namespace occa\nif (!success)\nreturn;\n- variable_t sycl_nditem(syclNdItem, work_item_name);\n+ variable_t sycl_nditem(syclNdItem, \"item_\");\n- variable_t sycl_handler(syclHandler, group_handler_name);\n+ variable_t sycl_handler(syclHandler, \"handler_\");\nsycl_handler.vartype.setReferenceToken(\nnew operatorToken(sycl_handler.source->origin, op::address));\n- variable_t sycl_ndrange(syclNdRange, ndrange_name);\n+ variable_t sycl_ndrange(syclNdRange, \"range_\");\nsycl_ndrange += pointer_t();\n- variable_t sycl_queue(syclQueue, queue_name);\n+ variable_t sycl_queue(syclQueue, \"queue_\");\nsycl_queue += pointer_t();\nfunction->addArgumentFirst(sycl_ndrange);\n@@ -268,7 +268,7 @@ namespace occa\n{\nauto *shared_value = new dpcppLocalMemoryNode(var.source->clone(),\nvar.vartype,\n- work_item_name);\n+ \"item_\");\ndecl.setValue(shared_value);\nvar.vartype.setType(auto_);\n" }, { "change_type": "MODIFY", "old_path": "src/occa/internal/lang/modes/dpcpp.hpp", "new_path": "src/occa/internal/lang/modes/dpcpp.hpp", "diff": "@@ -47,12 +47,6 @@ namespace occa\nstatic bool transformAtomicBasicExpressionStatement(expressionStatement &exprSmnt);\nprivate:\n- inline static const std::string sycl_header{\"CL/sycl.hpp\"};\n- inline static const std::string queue_name{\"queue_\"};\n- inline static const std::string ndrange_name{\"range_\"};\n- inline static const std::string group_handler_name{\"handler_\"};\n- inline static const std::string work_item_name{\"item_\"};\n-\ninline int dpcppDimensionOrder(const int index) { return 2 - index; }\n};\n} // namespace okl\n" } ]
C++
MIT License
libocca/occa
Remove C++17 features from DPC++ headers. (#526)
378,344
22.10.2021 03:52:01
-7,200
abeedaf642e0bf3cb8cea420be59a589ddb609bb
Add MPI::MPI_Fortran to link_libraries of fortran mpi example The example directly uses mpi, without the link compilation will fail on the use mpi statement when using a non-mpi-wrapper compiler
[ { "change_type": "MODIFY", "old_path": "examples/CMakeLists.txt", "new_path": "examples/CMakeLists.txt", "diff": "@@ -96,7 +96,7 @@ if (ENABLE_FORTRAN)\nmacro(compile_fortran_mpi_example_with_modes target file)\nadd_executable(examples_fortran_${target} ${file})\n- target_link_libraries(examples_fortran_${target} libocca)\n+ target_link_libraries(examples_fortran_${target} libocca MPI::MPI_Fortran)\nif (ENABLE_TESTS)\nadd_mpi_test_with_modes(examples_fortran_${target})\nendif()\n" } ]
C++
MIT License
libocca/occa
Add MPI::MPI_Fortran to link_libraries of fortran mpi example (#530) The example directly uses mpi, without the link compilation will fail on the use mpi statement when using a non-mpi-wrapper compiler
378,341
16.11.2021 19:43:23
-3,600
45462a3d62160a82009542ff7806ed86553527f8
Fix PGI builds (needs newlines at EOF)
[ { "change_type": "MODIFY", "old_path": "src/occa/internal/lang/expr/dpcppAtomicNode.cpp", "new_path": "src/occa/internal/lang/expr/dpcppAtomicNode.cpp", "diff": "@@ -76,3 +76,4 @@ namespace occa\n} // namespace lang\n} // namespace occa\n+\n" }, { "change_type": "MODIFY", "old_path": "src/occa/internal/lang/expr/dpcppLocalMemoryNode.cpp", "new_path": "src/occa/internal/lang/expr/dpcppLocalMemoryNode.cpp", "diff": "@@ -43,3 +43,4 @@ namespace occa\n} // namespace lang\n} // namespace occa\n+\n" }, { "change_type": "MODIFY", "old_path": "src/occa/internal/lang/expr/exprNode.hpp", "new_path": "src/occa/internal/lang/expr/exprNode.hpp", "diff": "@@ -163,3 +163,4 @@ namespace occa {\n}\n#endif\n+\n" }, { "change_type": "MODIFY", "old_path": "src/occa/internal/lang/modes/withLauncher.cpp", "new_path": "src/occa/internal/lang/modes/withLauncher.cpp", "diff": "@@ -569,3 +569,4 @@ namespace occa {\n}\n}\n}\n+\n" }, { "change_type": "MODIFY", "old_path": "src/occa/internal/modes/dpcpp/stream.cpp", "new_path": "src/occa/internal/modes/dpcpp/stream.cpp", "diff": "@@ -23,3 +23,4 @@ namespace occa {\n}\n}\n}\n+\n" } ]
C++
MIT License
libocca/occa
Fix PGI builds (needs newlines at EOF) (#537)
378,341
24.11.2021 18:32:16
-3,600
b07ec0bdd0d70c50f0898f050d3705dc4ee5f378
[Fortran] Use mpi_f08 module to fix Intel compiler warnings Intel compiler version 19.1.0.20200306 (and above, presumably) complains: error Explicit declaration of the EXTERNAL attribute is required This can be solved by using the newer mpi_f08 module and accompanying newer datatypes.
[ { "change_type": "MODIFY", "old_path": "examples/fortran/10_mpi/main.f90", "new_path": "examples/fortran/10_mpi/main.f90", "diff": "program main\n- use mpi\n+ use mpi_f08\nuse occa\nuse, intrinsic :: iso_fortran_env, only : stdout=>output_unit, &\nstderr=>error_unit\n@@ -7,9 +7,10 @@ program main\nimplicit none\ninteger :: ierr, id\n- integer :: myid, npes, gcomm, tag ! MPI variables\n- integer, dimension(2) :: request\n- integer, dimension(MPI_STATUS_SIZE) :: status\n+ integer :: myid, npes, tag ! MPI variables\n+ type(MPI_Comm) :: gcomm\n+ type(MPI_Request), dimension(2) :: request\n+ type(MPI_Status) :: status\ninteger :: otherID, offset\ninteger(occaUDim_t) :: iu\ninteger(occaUDim_t) :: entries = 8\n@@ -97,7 +98,7 @@ program main\nrequest = MPI_REQUEST_NULL\ncall MPI_IRecv(ab_ptr(otherID*offset+1), &\noffset, &\n- MPI_FLOAT, &\n+ MPI_REAL4, &\notherID, &\ntag, &\ngcomm, &\n@@ -105,7 +106,7 @@ program main\nierr)\ncall MPI_ISend(ab_ptr(myid*offset+1), &\noffset, &\n- MPI_FLOAT, &\n+ MPI_REAL4, &\notherID, &\ntag, &\ngcomm, &\n@@ -121,7 +122,7 @@ program main\ncall flush(stdout)\nab_sum = myid\nab_gather = sum(ab_ptr)\n- call MPI_Gather(ab_gather, 1, MPI_FLOAT, ab_sum, 1, MPI_FLOAT, 0, gcomm, ierr)\n+ call MPI_Gather(ab_gather, 1, MPI_REAL4, ab_sum, 1, MPI_REAL4, 0, gcomm, ierr)\nif (myid == 0) then\nif (abs(ab_sum(myid) - ab_sum(otherID)) > 1.0e-8) stop \"*** Wrong result ***\"\nend if\n" } ]
C++
MIT License
libocca/occa
[Fortran] Use mpi_f08 module to fix Intel compiler warnings (#539) Intel compiler version 19.1.0.20200306 (and above, presumably) complains: error #8889: Explicit declaration of the EXTERNAL attribute is required This can be solved by using the newer mpi_f08 module and accompanying newer datatypes.
378,361
06.12.2021 14:43:13
21,600
5f5ec0f1962b925a538eaae61a0fe3265fb5c2f3
Add non-blocking stream creation Add creating a non-blocking stream based on a stream property value "nonblocking" Current implementation applies to cuda and hip modes only An example is added to demonstrate the usage
[ { "change_type": "ADD", "old_path": null, "new_path": "examples/cpp/18_nonblocking_streams/.gitignore", "diff": "+main\n+main.o\n+main_c\n\\ No newline at end of file\n" }, { "change_type": "ADD", "old_path": null, "new_path": "examples/cpp/18_nonblocking_streams/CMakeLists.txt", "diff": "+compile_cpp_example_with_modes(nonblocking_streams main.cpp)\n+\n+add_custom_target(cpp_example_nonblocking_streams_okl ALL COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/powerOfPi.okl powerOfPi.okl)\n+add_dependencies(examples_cpp_nonblocking_streams cpp_example_nonblocking_streams_okl)\n" }, { "change_type": "ADD", "old_path": null, "new_path": "examples/cpp/18_nonblocking_streams/Makefile", "diff": "+\n+PROJ_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))\n+\n+ifndef OCCA_DIR\n+ include $(PROJ_DIR)/../../../scripts/build/Makefile\n+else\n+ include ${OCCA_DIR}/scripts/build/Makefile\n+endif\n+\n+#---[ COMPILATION ]-------------------------------\n+headers = $(wildcard $(incPath)/*.hpp) $(wildcard $(incPath)/*.tpp)\n+sources = $(wildcard $(srcPath)/*.cpp)\n+\n+objects = $(subst $(srcPath)/,$(objPath)/,$(sources:.cpp=.o))\n+\n+executables: ${PROJ_DIR}/main\n+\n+${PROJ_DIR}/main: $(objects) $(headers) ${PROJ_DIR}/main.cpp\n+ $(compiler) $(compilerFlags) -o ${PROJ_DIR}/main $(flags) $(objects) ${PROJ_DIR}/main.cpp $(paths) $(linkerFlags)\n+\n+$(objPath)/%.o:$(srcPath)/%.cpp $(wildcard $(subst $(srcPath)/,$(incPath)/,$(<:.cpp=.hpp))) $(wildcard $(subst $(srcPath)/,$(incPath)/,$(<:.cpp=.tpp)))\n+ $(compiler) $(compilerFlags) -o $@ $(flags) -c $(paths) $<\n+\n+clean:\n+ rm -f $(objPath)/*;\n+ rm -f ${PROJ_DIR}/main;\n+#=================================================\n" }, { "change_type": "ADD", "old_path": null, "new_path": "examples/cpp/18_nonblocking_streams/README.md", "diff": "+# Example: Non-blocking Streams\n+\n+GPU devices introduce `streams`, which potentially allow parallel queueing of instructions\n+\n+Especially with non-blocking streams created operations in those streams will not have implicit synchronizations with the default stream\n+\n+This example shows how to setup `occa::streams` with the non-blocking property\n+\n+# Compiling the Example\n+\n+```bash\n+make\n+```\n+\n+## Usage\n+\n+```\n+> ./main --help\n+\n+Usage: ./main [OPTIONS]\n+\n+Example showing the use of multiple non-blocking streams in a device\n+\n+Options:\n+ -d, --device Device properties (default: \"{mode: 'CUDA', device_id: 0}\")\n+ -h, --help Print usage\n+ -v, --verbose Compile kernels in verbose mode\n+```\n" }, { "change_type": "ADD", "old_path": null, "new_path": "examples/cpp/18_nonblocking_streams/main.cpp", "diff": "+#include <iostream>\n+\n+#include <occa.hpp>\n+\n+//---[ Internal Tools ]-----------------\n+// Note: These headers are not officially supported\n+// Please don't rely on it outside of the occa examples\n+#include <occa/internal/utils/cli.hpp>\n+//======================================\n+\n+\n+occa::json parseArgs(int argc, const char **argv);\n+\n+int main(int argc, const char **argv) {\n+ occa::json args = parseArgs(argc, argv);\n+\n+ occa::setDevice(occa::json::parse(args[\"options/device\"]));\n+\n+ const int n_streams = 8;\n+ int entries = 1<<20;\n+ int block = 64;\n+ int group = 1;\n+\n+ occa::memory o_x[n_streams];\n+ occa::memory o_x_d = occa::malloc<float>(1);\n+\n+ occa::json kernelProps({\n+ {\"defines/block\", block},\n+ {\"defines/group\", group},\n+ });\n+ occa::kernel powerOfPi = occa::buildKernel(\"powerOfPi.okl\",\n+ \"powerOfPi\",\n+ kernelProps);\n+\n+ occa::stream streams[n_streams];\n+ occa::json streamProps({\n+ {\"nonblocking\", true},\n+ });\n+ occa::stream default_stream = occa::getStream();\n+\n+ for (auto i = 0; i < n_streams; i++) {\n+ streams[i] = occa::createStream(streamProps);\n+\n+ o_x[i] = occa::malloc<float>(entries);\n+\n+ occa::setStream(streams[i]);\n+\n+ powerOfPi(o_x[i], entries);\n+\n+ occa::setStream(default_stream);\n+\n+ powerOfPi(o_x_d, 1);\n+ }\n+}\n+\n+occa::json parseArgs(int argc, const char **argv) {\n+ occa::cli::parser parser;\n+ parser\n+ .withDescription(\n+ \"Example showing the use of multiple device streams\"\n+ )\n+ .addOption(\n+ occa::cli::option('d', \"device\",\n+ \"Device properties (default: \\\"{mode: 'CUDA', device_id: 0}\\\")\")\n+ .withArg()\n+ .withDefaultValue(\"{mode: 'CUDA', device_id: 0}\")\n+ )\n+ .addOption(\n+ occa::cli::option('v', \"verbose\",\n+ \"Compile kernels in verbose mode\")\n+ );\n+\n+ occa::json args = parser.parseArgs(argc, argv);\n+ occa::settings()[\"kernel/verbose\"] = args[\"options/verbose\"];\n+\n+ return args;\n+}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "examples/cpp/18_nonblocking_streams/powerOfPi.okl", "diff": "+@kernel void powerOfPi(float* x,\n+ int entries) {\n+ for (int g = 0; g < group; g++; @outer) {\n+ for (int i = 0; i < block; ++i; @inner) {\n+ for (int j=i+g*block; j < entries; j+=block*group) {\n+ x[j] = sqrt(pow(3.14159,j));\n+ }\n+ }\n+ }\n+}\n" }, { "change_type": "MODIFY", "old_path": "examples/cpp/CMakeLists.txt", "new_path": "examples/cpp/CMakeLists.txt", "diff": "@@ -13,9 +13,9 @@ add_subdirectory(12_native_opencl_kernels)\nadd_subdirectory(13_openmp_interop)\nadd_subdirectory(14_cuda_interop)\n+add_subdirectory(18_nonblocking_streams)\nadd_subdirectory(20_native_dpcpp_kernel)\n# Don't force-compile OpenGL examples\n-# add_subdirectory(15_finite_difference)\n-# add_subdirectory(16_mandelbulb)\n-\n+# add_subdirectory(16_finite_difference)\n+# add_subdirectory(17_mandelbulb)\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "src/occa/internal/modes/cuda/device.cpp", "new_path": "src/occa/internal/modes/cuda/device.cpp", "diff": "@@ -138,8 +138,13 @@ namespace occa {\nsetCudaContext();\n+ if (props.get<bool>(\"nonblocking\", false)) {\n+ OCCA_CUDA_ERROR(\"Device: createStream - NonBlocking\",\n+ cuStreamCreate(&cuStream, CU_STREAM_NON_BLOCKING));\n+ } else {\nOCCA_CUDA_ERROR(\"Device: createStream\",\ncuStreamCreate(&cuStream, CU_STREAM_DEFAULT));\n+ }\nreturn new stream(this, props, cuStream);\n}\n" }, { "change_type": "MODIFY", "old_path": "src/occa/internal/modes/cuda/polyfill.hpp", "new_path": "src/occa/internal/modes/cuda/polyfill.hpp", "diff": "@@ -31,6 +31,7 @@ namespace occa {\nstatic const int CU_MEM_ATTACH_GLOBAL = 0;\nstatic const int CU_MEM_ATTACH_HOST = 0;\nstatic const int CU_STREAM_DEFAULT = 0;\n+ static const int CU_STREAM_NON_BLOCKING = 0;\nstatic const int CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR = 0;\nstatic const int CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR = 0;\n" }, { "change_type": "MODIFY", "old_path": "src/occa/internal/modes/hip/device.cpp", "new_path": "src/occa/internal/modes/hip/device.cpp", "diff": "@@ -122,8 +122,13 @@ namespace occa {\nOCCA_HIP_ERROR(\"Device: Setting Device\",\nhipSetDevice(deviceID));\n+ if (props.get<bool>(\"nonblocking\", false)) {\n+ OCCA_HIP_ERROR(\"Device: createStream - NonBlocking\",\n+ hipStreamCreateWithFlag(&hipStream, hipStreamNonBlocking));\n+ } else {\nOCCA_HIP_ERROR(\"Device: createStream\",\nhipStreamCreate(&hipStream));\n+ }\nreturn new stream(this, props, hipStream);\n}\n" }, { "change_type": "MODIFY", "old_path": "src/occa/internal/modes/hip/polyfill.hpp", "new_path": "src/occa/internal/modes/hip/polyfill.hpp", "diff": "@@ -30,6 +30,7 @@ namespace occa {\nstatic const int HIP_LAUNCH_PARAM_BUFFER_POINTER = 0;\nstatic const int HIP_LAUNCH_PARAM_BUFFER_SIZE = 0;\nstatic const int HIP_LAUNCH_PARAM_END = 0;\n+ static const int hipStreamNonBlocking = 0;\nclass hipDeviceProp_t {\npublic:\n@@ -274,6 +275,10 @@ namespace occa {\nreturn OCCA_HIP_IS_NOT_ENABLED;\n}\n+ inline hipError_t hipStreamCreateWithFlag(hipStream_t *phStream, unsigned int flags) {\n+ return OCCA_HIP_IS_NOT_ENABLED;\n+ }\n+\ninline hipError_t hipStreamDestroy(hipStream_t hStream) {\nreturn OCCA_HIP_IS_NOT_ENABLED;\n}\n" } ]
C++
MIT License
libocca/occa
Add non-blocking stream creation (#498) - Add creating a non-blocking stream based on a stream property value "nonblocking" - Current implementation applies to cuda and hip modes only - An example is added to demonstrate the usage
378,351
07.12.2021 10:58:13
21,600
2abc3e9e8c16c4f48581420852f19a504a9f53b9
Add the `@nobarrier` attribute to stop barriers from being automatically inserted between `@inner` loop blocks.
[ { "change_type": "MODIFY", "old_path": "src/occa/internal/lang/builtins/attributes.hpp", "new_path": "src/occa/internal/lang/builtins/attributes.hpp", "diff": "#include <occa/internal/lang/builtins/attributes/inner.hpp>\n#include <occa/internal/lang/builtins/attributes/kernel.hpp>\n#include <occa/internal/lang/builtins/attributes/maxInnerDims.hpp>\n+#include <occa/internal/lang/builtins/attributes/noBarrier.hpp>\n#include <occa/internal/lang/builtins/attributes/outer.hpp>\n#include <occa/internal/lang/builtins/attributes/restrict.hpp>\n#include <occa/internal/lang/builtins/attributes/shared.hpp>\n" }, { "change_type": "ADD", "old_path": null, "new_path": "src/occa/internal/lang/builtins/attributes/noBarrier.cpp", "diff": "+#include <occa/internal/lang/expr.hpp>\n+#include <occa/internal/lang/statement.hpp>\n+#include <occa/internal/lang/builtins/attributes/noBarrier.hpp>\n+\n+namespace occa {\n+ namespace lang {\n+ namespace attributes {\n+ //---[ @nobarrier ]-----------------------\n+ noBarrier::noBarrier() {}\n+\n+ const std::string& noBarrier::name() const {\n+ static std::string name_ = \"nobarrier\";\n+ return name_;\n+ }\n+\n+ bool noBarrier::forStatementType(const int sType) const {\n+ return (sType & statementType::for_);\n+ }\n+\n+ bool noBarrier::isValid(const attributeToken_t &attr) const {\n+ if (attr.kwargs.size()) {\n+ attr.printError(\"[@nobarrier] does not take kwargs\");\n+ return false;\n+ }\n+ if (attr.args.size()) {\n+ attr.printError(\"[@nobarrier] does not take arguments\");\n+ return false;\n+ }\n+ return true;\n+ }\n+ //==================================\n+ }\n+ }\n+}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "src/occa/internal/lang/builtins/attributes/noBarrier.hpp", "diff": "+#ifndef OCCA_INTERNAL_LANG_BUILTINS_ATTRIBUTES_NOBARRIER_HEADER\n+#define OCCA_INTERNAL_LANG_BUILTINS_ATTRIBUTES_NOBARRIER_HEADER\n+\n+#include <occa/internal/lang/attribute.hpp>\n+\n+namespace occa {\n+ namespace lang {\n+ namespace attributes {\n+ //---[ @nobarrier ]---------------\n+ class noBarrier : public attribute_t {\n+ public:\n+ noBarrier();\n+\n+ virtual const std::string& name() const;\n+\n+ virtual bool forStatementType(const int sType) const;\n+\n+ virtual bool isValid(const attributeToken_t &attr) const;\n+ };\n+ //================================\n+ }\n+ }\n+}\n+\n+#endif\n" }, { "change_type": "MODIFY", "old_path": "src/occa/internal/lang/modes/okl.cpp", "new_path": "src/occa/internal/lang/modes/okl.cpp", "diff": "@@ -391,6 +391,7 @@ namespace occa {\nparser.addAttribute<attributes::outer>();\nparser.addAttribute<attributes::shared>();\nparser.addAttribute<attributes::maxInnerDims>();\n+ parser.addAttribute<attributes::noBarrier>();\n}\nvoid setOklLoopIndices(functionDeclStatement &kernelSmnt) {\n" }, { "change_type": "MODIFY", "old_path": "src/occa/internal/lang/modes/withLauncher.cpp", "new_path": "src/occa/internal/lang/modes/withLauncher.cpp", "diff": "@@ -513,8 +513,9 @@ namespace occa {\n//Only apply barriers when needed in the last inner-loop\nif (isOuterMostInnerLoop(innerSmnt)\n- && (!isLastInnerLoop(innerSmnt) || isInsideLoop(innerSmnt)))\n- addBarriersAfterInnerLoop(innerSmnt);\n+ && (!isLastInnerLoop(innerSmnt) || isInsideLoop(innerSmnt))\n+ && !(innerSmnt.hasAttribute(\"nobarrier\"))\n+ ) addBarriersAfterInnerLoop(innerSmnt);\n});\n}\n" } ]
C++
MIT License
libocca/occa
Add the `@nobarrier` attribute to stop barriers from being automatically inserted between `@inner` loop blocks. (#544)
378,351
15.12.2021 11:55:37
21,600
7dd3c62ff093d0b9bed5318b44d38ddd9cf7baa4
Add oneAPI compilers (Intel/LLVM) to testing matrix.
[ { "change_type": "MODIFY", "old_path": ".github/workflows/build.yml", "new_path": ".github/workflows/build.yml", "diff": "@@ -44,6 +44,17 @@ jobs:\nCXXFLAGS: -Wno-uninitialized\nOCCA_COVERAGE: 0\n+ - name: \"[Ubuntu] CMake + Intel/LLVM\"\n+ os: ubuntu-latest\n+ CC: icx\n+ CXX: icpx\n+ CXXFLAGS: -Wno-uninitialized\n+ FC: ifx\n+ GCOV: gcov-9\n+ OCCA_COVERAGE: 1\n+ useCMake: true\n+ useoneAPI: true\n+\n- name: \"[MacOS] gcc-9\"\nos: macos-latest\nCC: gcc-9\n@@ -59,34 +70,81 @@ jobs:\nCXXFLAGS: -Wno-uninitialized\nOCCA_COVERAGE: 0\n+\nruns-on: ${{ matrix.os }}\nname: ${{ matrix.name }}\nenv:\nCC: ${{ matrix.CC }}\nCXX: ${{ matrix.CXX }}\n- CXXFLAGS: -O3 -Wall -pedantic -Wshadow -Wsign-compare -Wuninitialized -Wtype-limits -Wignored-qualifiers -Wempty-body -Wextra -Wno-unused-parameter -Werror -Wno-strict-aliasing ${{ matrix.CXXFLAGS }}\nFC: ${{ matrix.FC }}\n+ CXXFLAGS: -O3 -Wall -pedantic -Wshadow -Wsign-compare -Wuninitialized -Wtype-limits -Wignored-qualifiers -Wempty-body -Wextra -Wno-unused-parameter -Werror -Wno-strict-aliasing ${{ matrix.CXXFLAGS }}\n+ OCCA_CXXFLAGS: -O3\nGCOV: ${{ matrix.GCOV }}\nOCCA_COVERAGE: ${{ matrix.OCCA_COVERAGE }}\nOCCA_FORTRAN_ENABLED: ${{ matrix.OCCA_FORTRAN_ENABLED }}\n- OCCA_CXXFLAGS: -O3\nFORTRAN_EXAMPLES: ${{ matrix.OCCA_FORTRAN_ENABLED }}\nsteps:\n- uses: actions/checkout@v2\n+ - name: add oneAPI to apt\n+ if: ${{ matrix.useoneAPI }}\n+ shell: bash\n+ run: |\n+ cd /tmp\n+ wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB\n+ sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB\n+ rm GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB\n+ sudo add-apt-repository \"deb https://apt.repos.intel.com/oneapi all main\"\n+\n+ - name: install oneAPI dpcpp compiler\n+ if: ${{ matrix.useoneAPI }}\n+ shell: bash\n+ run: |\n+ sudo apt update\n+ sudo apt install intel-oneapi-compiler-dpcpp-cpp\n+\n- name: Compiler info\nif: ${{ !matrix.useCMake }}\nrun: make -j 16 info\n+ - name: CMake configure\n+ if: ${{ matrix.useCMake && !matrix.useoneAPI}}\n+ run: |\n+ cmake -S . -B build \\\n+ -DCMAKE_BUILD_TYPE=\"RelWithDebInfo\" \\\n+ -DCMAKE_INSTALL_PREFIX=install \\\n+ -DENABLE_TESTS=ON \\\n+ -DENABLE_EXAMPLES=ON\n+\n+ - name: CMake configure\n+ if: ${{ matrix.useCMake && matrix.useoneAPI}}\n+ env:\n+ OCCA_CC: ${{ matrix.CC }}\n+ OCCA_CXX: ${{ matrix.CXX }}\n+ run: |\n+ source /opt/intel/oneapi/setvars.sh\n+ cmake -S . -B build \\\n+ -DCMAKE_BUILD_TYPE=\"RelWithDebInfo\" \\\n+ -DCMAKE_INSTALL_PREFIX=install \\\n+ -DENABLE_TESTS=ON \\\n+ -DENABLE_EXAMPLES=ON \\\n+ -DCMAKE_PREFIX_PATH=\"/opt/intel/oneapi/compiler/latest/linux;/opt/intel/oneapi/compiler/latest/linux/include/sycl;/opt/intel/oneapi/compiler/latest/linux/compiler\"\n+\n- name: CMake build\n- if: ${{ matrix.useCMake }}\n+ if: ${{ matrix.useCMake && !matrix.useoneAPI}}\nrun: |\n- mkdir -p ${{runner.workspace}}/occa/build\n- cd ${{runner.workspace}}/occa/build\n- cmake -DENABLE_TESTS=ON -DENABLE_EXAMPLES=ON ${{runner.workspace}}/occa\n- make -j 16\n+ cmake --build build --parallel 16\n+\n+ - name: CMake build\n+ if: ${{ matrix.useCMake && matrix.useoneAPI}}\n+ env:\n+ OCCA_CC: ${{ matrix.CC }}\n+ OCCA_CXX: ${{ matrix.CXX }}\n+ run: |\n+ source /opt/intel/oneapi/setvars.sh\n+ cmake --build build --parallel 16\n- name: Compile library\nif: ${{ !matrix.useCMake }}\n@@ -105,10 +163,19 @@ jobs:\nrun: ./tests/run_examples\n- name: Run CTests\n- if: ${{ matrix.useCMake }}\n+ if: ${{ matrix.useCMake && !matrix.useoneAPI }}\n+ run: |\n+ ctest --test-dir build --progress --output-on-failure\n+\n+ - name: Run CTests\n+ if: ${{ matrix.useCMake && matrix.useoneAPI }}\n+ env:\n+ OCCA_CC: ${{ matrix.CC }}\n+ OCCA_CXX: ${{ matrix.CXX }}\nrun: |\n- cd ${{runner.workspace}}/occa/build\n- CTEST_OUTPUT_ON_FAILURE=1 make test\n+ source /opt/intel/oneapi/setvars.sh\n+ export SYCL_DEVICE_FILTER=opencl.cpu\n+ ctest --test-dir build --progress --output-on-failure\n- name: Upload code coverage\nif: ${{ matrix.OCCA_COVERAGE }}\n" }, { "change_type": "MODIFY", "old_path": "examples/CMakeLists.txt", "new_path": "examples/CMakeLists.txt", "diff": "macro(add_test_with_mode_and_nranks exe mode device nranks)\nif (${nranks} GREATER 1)\n- add_test(NAME ${exe}-${mode} COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${nranks} ./${exe} --verbose --device ${device})\n+ add_test(NAME ${exe}-${mode} COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${nranks} ./${exe} --verbose --device \"${device}\")\nelse()\n- add_test(NAME ${exe}-${mode} COMMAND ./${exe} --verbose --device ${device})\n+ add_test(NAME ${exe}-${mode} COMMAND ./${exe} --verbose --device \"${device}\")\nendif()\nset_property(TEST ${exe}-${mode} APPEND PROPERTY ENVIRONMENT OCCA_CACHE_DIR=${OCCA_BUILD_DIR}/occa)\nendmacro()\nmacro(add_test_with_modes_and_nranks exe nranks)\n- add_test_with_mode_and_nranks(${exe} serial \"{mode: 'Serial'}\" ${nranks})\n+ add_test_with_mode_and_nranks(${exe} serial \"{'mode': 'Serial'}\" ${nranks})\nif (OCCA_CUDA_ENABLED)\n- add_test_with_mode_and_nranks(${exe} cuda \"{mode: 'CUDA', device_id: 0}\" ${nranks})\n+ add_test_with_mode_and_nranks(${exe} cuda \"{'mode': 'CUDA':, 'device_id': 0}\" ${nranks})\nendif()\nif (OCCA_HIP_ENABLED)\n- add_test_with_mode_and_nranks(${exe} hip \"{mode: 'HIP', device_id: 0}\" ${nranks})\n+ add_test_with_mode_and_nranks(${exe} hip \"{'mode': 'HIP', 'device_id': 0}\" ${nranks})\nendif()\nif (OCCA_METAL_ENABLED)\n- add_test_with_mode_and_nranks(${exe} metal \"{mode: 'Metal', device_id: 0}\" ${nranks})\n+ add_test_with_mode_and_nranks(${exe} metal \"{'mode': 'Metal', 'device_id': 0}\" ${nranks})\nendif()\nif (OCCA_OPENCL_ENABLED)\n- add_test_with_mode_and_nranks(${exe} opencl \"{mode: 'OpenCL', platform_id: 0, device_id: 0}\" ${nranks})\n+ add_test_with_mode_and_nranks(${exe} opencl \"{'mode': 'OpenCL', 'platform_id': 0, 'device_id': 0}\" ${nranks})\nendif()\nif (OCCA_DPCPP_ENABLED)\n- add_test_with_mode_and_nranks(${exe} dpcpp \"{mode: 'dpcpp', platform_id: 0, device_id: 0}\" ${nranks})\n+ add_test_with_mode_and_nranks(${exe} dpcpp \"{'mode': 'dpcpp', 'platform_id': 0, 'device_id': 0}\" ${nranks})\nendif()\nif (OCCA_OPENMP_ENABLED)\n- add_test_with_mode_and_nranks(${exe} openmp \"{mode: 'OpenMP'}\" ${nranks})\n+ add_test_with_mode_and_nranks(${exe} openmp \"{'mode': 'OpenMP'}\" ${nranks})\nendif()\nendmacro()\n" }, { "change_type": "MODIFY", "old_path": "examples/cpp/20_native_dpcpp_kernel/main.cpp", "new_path": "examples/cpp/20_native_dpcpp_kernel/main.cpp", "diff": "@@ -23,7 +23,7 @@ int main(int argc, const char **argv) {\nfor (int i = 0; i < entries; ++i) {\na[i] = i;\n- b[i] = i;\n+ b[i] = 1-i;\nab[i] = 0;\n}\n@@ -56,6 +56,7 @@ int main(int argc, const char **argv) {\n// Launch device kernel\naddVectors(entries, o_a, o_b, o_ab);\n// Copy result to the host\n+ device.finish();\no_ab.copyTo(ab);\n// Assert values\n" }, { "change_type": "MODIFY", "old_path": "src/occa/internal/bin/occa.cpp", "new_path": "src/occa/internal/bin/occa.cpp", "diff": "#include <fstream>\n-#include <occa.hpp>\n+#include <occa/core.hpp>\n#include <occa/internal/bin/occa.hpp>\n#include <occa/internal/utils/env.hpp>\n@@ -282,7 +282,7 @@ namespace occa {\n}\nbool runInfo(const json &args) {\n- printModeInfo();\n+ occa::printModeInfo();\nreturn true;\n}\n" }, { "change_type": "MODIFY", "old_path": "src/occa/internal/lang/modes/dpcpp.cpp", "new_path": "src/occa/internal/lang/modes/dpcpp.cpp", "diff": "@@ -96,7 +96,7 @@ namespace occa\nroot.addFirst(\n*(new directiveStatement(\n&root,\n- directiveToken(root.source->origin, \"include <sycl.hpp>\"))));\n+ directiveToken(root.source->origin, \"include <CL/sycl.hpp>\"))));\n}\nvoid dpcppParser::addExtensions()\n" } ]
C++
MIT License
libocca/occa
Add oneAPI compilers (Intel/LLVM) to testing matrix. (#542)
378,351
20.12.2021 13:23:08
21,600
5945a752273fd68daba79f73098a0de3487fdf19
Update DPC++ build to handle recent updates to Intel's header files.
[ { "change_type": "MODIFY", "old_path": ".github/workflows/build.yml", "new_path": ".github/workflows/build.yml", "diff": "@@ -130,7 +130,7 @@ jobs:\n-DCMAKE_INSTALL_PREFIX=install \\\n-DENABLE_TESTS=ON \\\n-DENABLE_EXAMPLES=ON \\\n- -DCMAKE_PREFIX_PATH=\"/opt/intel/oneapi/compiler/latest/linux;/opt/intel/oneapi/compiler/latest/linux/include/sycl;/opt/intel/oneapi/compiler/latest/linux/compiler\"\n+ -DCMAKE_PREFIX_PATH=\"/opt/intel/oneapi/compiler/latest/linux;/opt/intel/oneapi/compiler/latest/linux/compiler\"\n- name: CMake build\nif: ${{ matrix.useCMake && !matrix.useoneAPI}}\n" }, { "change_type": "MODIFY", "old_path": "CMakeLists.txt", "new_path": "CMakeLists.txt", "diff": "@@ -170,6 +170,7 @@ if(ENABLE_DPCPP)\nset(OCCA_DPCPP_ENABLED 1)\nmessage(\"-- DPCPP include dirs: ${SYCL_INCLUDE_DIRS}\")\n+ message(\"-- DPCPP extension dirs: ${SYCL_EXT_DIRS}\")\nmessage(\"-- DPCPP libraries: ${SYCL_LIBRARIES}\")\n# Use our wrapper imported target OCCA::depends::DPCPP,\n" }, { "change_type": "MODIFY", "old_path": "cmake/FindDPCPP.cmake", "new_path": "cmake/FindDPCPP.cmake", "diff": "@@ -10,12 +10,29 @@ find_path(\nSYCL_INCLUDE_DIRS\nNAMES\nCL/sycl.hpp\n+ PATHS\n+ /opt/intel/oneapi/compiler/latest/linux\n+ ENV SYCL_ROOT\n+ PATH_SUFFIXES\n+ include/sycl\n+)\n+\n+find_path(\n+ SYCL_EXT_DIRS\n+ NAMES\n+ sycl/ext\n+ PATHS\n+ /opt/intel/oneapi/compiler/latest/linux\n+ ENV SYCL_ROOT\n)\nfind_library(\nSYCL_LIBRARIES\nNAMES\nsycl libsycl\n+ PATHS\n+ /opt/intel/oneapi/compiler/latest/linux\n+ ENV SYCL_ROOT\n)\ninclude(FindPackageHandleStandardArgs)\n@@ -23,6 +40,7 @@ find_package_handle_standard_args(\nDPCPP\nREQUIRED_VARS\nSYCL_INCLUDE_DIRS\n+ SYCL_EXT_DIRS\nSYCL_LIBRARIES\n)\n@@ -31,7 +49,7 @@ if(DPCPP_FOUND AND NOT TARGET OCCA::depends::DPCPP)\n# Put it in the OCCA namespace to make it clear that we created it.\nadd_library(OCCA::depends::DPCPP INTERFACE IMPORTED)\nset_target_properties(OCCA::depends::DPCPP PROPERTIES\n- INTERFACE_INCLUDE_DIRECTORIES \"${SYCL_INCLUDE_DIRS}\"\n+ INTERFACE_INCLUDE_DIRECTORIES \"${SYCL_INCLUDE_DIRS};${SYCL_EXT_DIRS}\"\nINTERFACE_LINK_LIBRARIES \"${SYCL_LIBRARIES}\"\n)\nendif()\n" }, { "change_type": "MODIFY", "old_path": "cmake/FindOpenCLWrapper.cmake", "new_path": "cmake/FindOpenCLWrapper.cmake", "diff": "if(NOT OPENCL_ROOT)\n# Search in user specified path first\nfind_path(OPENCL_ROOT\n- NAMES include/CL/cl.h\n+ NAMES CL/cl.h\nPATHS\nENV OPENCL_PATH\nDOC \"OPENCL root location\"\n@@ -15,8 +15,13 @@ if(NOT OPENCL_ROOT)\n# Now search in default path\nfind_path(OPENCL_ROOT\n- NAMES include/CL/cl.h\n- PATHS /usr/ /opt/rocm/opencl /usr/local/cuda\n+ NAMES CL/cl.h\n+ PATHS\n+ /usr\n+ /opt/rocm/opencl\n+ /usr/local/cuda\n+ /opt/intel/oneapi/compiler/latest/linux\n+ PATH_SUFFIXES sycl\nDOC \"OPENCL root location\")\nendif()\n" } ]
C++
MIT License
libocca/occa
Update DPC++ build to handle recent updates to Intel's header files. (#550)
378,351
20.12.2021 14:01:31
21,600
4ef3c3e9dc270ad5c55b4c3f44f853a3c3764bf7
Update namespace of local memory allocations.
[ { "change_type": "MODIFY", "old_path": "src/occa/internal/lang/expr/dpcppLocalMemoryNode.cpp", "new_path": "src/occa/internal/lang/expr/dpcppLocalMemoryNode.cpp", "diff": "@@ -25,7 +25,7 @@ namespace occa\nvoid dpcppLocalMemoryNode::print(printer &pout) const\n{\n- pout << \"*(sycl::group_local_memory_for_overwrite<\";\n+ pout << \"*(sycl::ext::oneapi::group_local_memory_for_overwrite<\";\npout << shared_type;\npout << \">(\";\npout << handler_name;\n" } ]
C++
MIT License
libocca/occa
Update namespace of local memory allocations. (#551)
378,361
12.01.2022 17:21:05
21,600
83b48a6d87a22fb55ae79412206d1dc3b14811fb
Fix cached file path to match with actual the file created when check for its existence
[ { "change_type": "MODIFY", "old_path": "src/occa/internal/io/cache.cpp", "new_path": "src/occa/internal/io/cache.cpp", "diff": "@@ -88,7 +88,6 @@ namespace occa {\nbool cachedFileIsComplete(const std::string &hashDir,\nconst std::string &filename) {\nstd::string successFile = hashDir;\n- successFile += \".success/\";\nsuccessFile += filename;\nreturn io::exists(successFile);\n" } ]
C++
MIT License
libocca/occa
Fix cached file path to match with actual the file created when check for its existence (#554)
378,351
22.02.2022 12:48:55
21,600
865d2977d7fe8d00289df5918d529c96f81dfbca
Improve test coverage for primitive types.
[ { "change_type": "MODIFY", "old_path": "src/types/primitive.cpp", "new_path": "src/types/primitive.cpp", "diff": "@@ -249,13 +249,8 @@ namespace occa {\ncase primitiveType::int64_ : str = occa::toString((int64_t) value.int64_); break;\ncase primitiveType::float_ : str = occa::toString(value.float_); break;\ncase primitiveType::double_ : str = occa::toString(value.double_); break;\n- default:\n- return \"NaN\";\n- }\n-\n- if ((str.find(\"inf\") != std::string::npos) ||\n- (str.find(\"INF\") != std::string::npos)) {\n- return str;\n+ case primitiveType::none :\n+ default: return \"\"; break;\n}\nif (type & (primitiveType::uint64_ |\n" }, { "change_type": "MODIFY", "old_path": "tests/src/types/primitive.cpp", "new_path": "tests/src/types/primitive.cpp", "diff": "#include <occa/types/primitive.hpp>\n#include <occa/internal/utils/sys.hpp>\n#include <occa/internal/utils/testing.hpp>\n+#include <limits>\nvoid testInit();\nvoid testLoad();\nvoid testBadParsing();\nvoid testToString();\n+void testSizeOf();\n+void testNot();\n+void testPositive();\n+void testNegative();\n+void testTilde();\n+void testLeftIncrement();\n+void testRightIncrement();\n+void testLeftDecrement();\n+void testRightDecrement();\nint main(const int argc, const char **argv) {\ntestInit();\ntestLoad();\ntestBadParsing();\ntestToString();\n+ testSizeOf();\n+ testNot();\n+ testPositive();\n+ testNegative();\n+ testTilde();\n+ testLeftIncrement();\n+ testRightIncrement();\n+ testLeftDecrement();\n+ testRightDecrement();\nreturn 0;\n}\n@@ -53,6 +72,10 @@ void testLoad() {\nASSERT_EQ(-15,\n(int) occa::primitive(\"-15\"));\n+ std::string fifteen{\"15\"};\n+ ASSERT_EQ(15, (int) occa::primitive(fifteen));\n+ ASSERT_EQ((int) -15, (int) occa::primitive::load(\"-15\",true));\n+\nASSERT_EQ(15,\n(int) occa::primitive(\"0xF\"));\nASSERT_EQ(15,\n@@ -62,14 +85,37 @@ void testLoad() {\nASSERT_EQ(-15,\n(int) occa::primitive(\"-0XF\"));\n- ASSERT_EQ(15,\n- (int) occa::primitive(\"0b1111\"));\n- ASSERT_EQ(15,\n- (int) occa::primitive(\"0B1111\"));\n- ASSERT_EQ(-15,\n- (int) occa::primitive(\"-0b1111\"));\n- ASSERT_EQ(-15,\n- (int) occa::primitive(\"-0B1111\"));\n+ ASSERT_EQ((uint8_t) 15,(uint8_t) occa::primitive(\"0b1111\"));\n+ ASSERT_EQ((uint8_t) 15,(uint8_t) occa::primitive(\"0B1111\"));\n+ ASSERT_EQ((int8_t) -15,(int8_t) occa::primitive(\"-0b1111\"));\n+ ASSERT_EQ((int8_t) -15,(int8_t) occa::primitive(\"-0B1111\"));\n+\n+ ASSERT_EQ((uint16_t) 15,\n+ (uint16_t) occa::primitive(\"0b00001111\"));\n+ ASSERT_EQ((uint16_t) 15,\n+ (uint16_t) occa::primitive(\"0B00001111\"));\n+ ASSERT_EQ((int16_t) -15,\n+ (int16_t) occa::primitive(\"-0b00001111\"));\n+ ASSERT_EQ((int16_t) -15,\n+ (int16_t) occa::primitive(\"-0B00001111\"));\n+\n+ ASSERT_EQ((uint32_t) 15,\n+ (uint32_t) occa::primitive(\"0b0000000000001111\"));\n+ ASSERT_EQ((uint32_t) 15,\n+ (uint32_t) occa::primitive(\"0B0000000000001111\"));\n+ ASSERT_EQ((int32_t) -15,\n+ (int32_t) occa::primitive(\"-0b0000000000001111\"));\n+ ASSERT_EQ((int32_t) -15,\n+ (int32_t) occa::primitive(\"-0B0000000000001111\"));\n+\n+ ASSERT_EQ((uint64_t) 15,\n+ (uint64_t) occa::primitive(\"0b00000000000000000000000000001111\"));\n+ ASSERT_EQ((uint64_t) 15,\n+ (uint64_t) occa::primitive(\"0B00000000000000000000000000001111\"));\n+ ASSERT_EQ((int64_t) -15,\n+ (int64_t) occa::primitive(\"-0b00000000000000000000000000001111\"));\n+ ASSERT_EQ((int64_t) -15,\n+ (int64_t) occa::primitive(\"-0B00000000000000000000000000001111\"));\nASSERT_EQ(15.01,\n(double) occa::primitive(\"15.01\"));\n@@ -111,6 +157,26 @@ void testLoad() {\nASSERT_EQ(-15.01,\n(double) occa::primitive(\"-150.1E-1\"));\n+ ASSERT_EQ(15.01,(double) occa::primitive(\"15.01\"));\n+ ASSERT_EQ(-15.01,(double) occa::primitive(\"-15.01\"));\n+\n+ ASSERT_EQ( (float) 1e-16 ,(float) occa::primitive(\"1e-16F\"));\n+ ASSERT_EQ( (float) 1.e-16 ,(float) occa::primitive(\"1.e-16F\"));\n+ ASSERT_EQ( (float) 15.01 ,(float) occa::primitive(\"1.501e1F\"));\n+ ASSERT_EQ( (float) -15.01 ,(float) occa::primitive(\"-1.501e1F\"));\n+ ASSERT_EQ( (float) 15.01 ,(float) occa::primitive(\"1.501E1F\"));\n+ ASSERT_EQ( (float) -15.01 ,(float) occa::primitive(\"-1.501E1F\"));\n+ ASSERT_EQ( (float) 1e-15 ,(float) occa::primitive(\"1e-15F\"));\n+ ASSERT_EQ( (float) 1.e-15 ,(float) occa::primitive(\"1.e-15F\"));\n+ ASSERT_EQ( (float) 15.01 ,(float) occa::primitive(\"1.501e+1F\"));\n+ ASSERT_EQ( (float) -15.01 ,(float) occa::primitive(\"-1.501e+1F\"));\n+ ASSERT_EQ( (float) 15.01 ,(float) occa::primitive(\"1.501E+1F\"));\n+ ASSERT_EQ( (float) -15.01 ,(float) occa::primitive(\"-1.501E+1F\"));\n+ ASSERT_EQ( (float) 15.01 ,(float) occa::primitive(\"150.1e-1F\"));\n+ ASSERT_EQ( (float) -15.01 ,(float) occa::primitive(\"-150.1e-1F\"));\n+ ASSERT_EQ( (float) 15.01 ,(float) occa::primitive(\"150.1E-1F\"));\n+ ASSERT_EQ( (float) -15.01 ,(float) occa::primitive(\"-150.1E-1F\"));\n+\nASSERT_TRUE(!!(occa::primitive(\"0x7f800000U\").type & occa::primitiveType::isUnsigned));\nASSERT_TRUE(!!(occa::primitive(\"0x7f800000L\").type & occa::primitiveType::int64_));\n@@ -165,6 +231,267 @@ void testToString() {\nASSERT_EQ(\"0x7f800000LL\",\nocca::primitive(\"0x7f800000LL\").toString());\n- ASSERT_EQ(\"NaN\",\n- occa::primitive(\"\").toString());\n+ ASSERT_EQ(\"1.2345f\",\n+ occa::primitive(\"1.2345f\").toString());\n+\n+ ASSERT_EQ(\"\",occa::primitive().toString());\n+}\n+\n+void testSizeOf() {\n+ ASSERT_EQ(sizeof(bool), occa::primitive(true) .sizeof_());\n+ ASSERT_EQ(sizeof(uint8_t), occa::primitive((uint8_t) 1) .sizeof_());\n+ ASSERT_EQ(sizeof(uint16_t), occa::primitive((uint16_t) 1) .sizeof_());\n+ ASSERT_EQ(sizeof(uint32_t), occa::primitive((uint32_t) 1) .sizeof_());\n+ ASSERT_EQ(sizeof(uint64_t), occa::primitive((uint64_t) 1) .sizeof_());\n+ ASSERT_EQ(sizeof(int8_t), occa::primitive((int8_t) 1) .sizeof_());\n+ ASSERT_EQ(sizeof(int16_t), occa::primitive((int16_t) 1) .sizeof_());\n+ ASSERT_EQ(sizeof(int32_t), occa::primitive((int32_t) 1) .sizeof_());\n+ ASSERT_EQ(sizeof(int64_t), occa::primitive((int64_t) 1) .sizeof_());\n+ ASSERT_EQ(sizeof(float), occa::primitive((float) 1) .sizeof_());\n+ ASSERT_EQ(sizeof(double), occa::primitive((double) 1) .sizeof_());\n+}\n+\n+void testNot() {\n+ ASSERT_EQ(false , (bool) occa::primitive::not_(true) );\n+ ASSERT_EQ((uint8_t) 0, (uint8_t) occa::primitive::not_((uint8_t) 1));\n+ ASSERT_EQ((uint16_t) 0, (uint16_t) occa::primitive::not_((uint16_t) 1));\n+ ASSERT_EQ((uint32_t) 0, (uint32_t) occa::primitive::not_((uint32_t) 1));\n+ ASSERT_EQ((uint64_t) 0, (uint64_t) occa::primitive::not_((uint64_t) 1));\n+ ASSERT_EQ((int8_t) 0, (int8_t) occa::primitive::not_((int8_t) 1));\n+ ASSERT_EQ((int16_t) 0, (int16_t) occa::primitive::not_((int16_t) 1));\n+ ASSERT_EQ((int32_t) 0, (int32_t) occa::primitive::not_((int32_t) 1));\n+ ASSERT_EQ((int64_t) 0, (int64_t) occa::primitive::not_((int64_t) 1));\n+}\n+\n+void testPositive() {\n+ ASSERT_EQ(true , (bool) occa::primitive::positive(true) );\n+ ASSERT_EQ((uint8_t) 1, (uint8_t) occa::primitive::positive((uint8_t) 1));\n+ ASSERT_EQ((uint16_t) 1, (uint16_t) occa::primitive::positive((uint16_t) 1));\n+ ASSERT_EQ((uint32_t) 1, (uint32_t) occa::primitive::positive((uint32_t) 1));\n+ ASSERT_EQ((uint64_t) 1, (uint64_t) occa::primitive::positive((uint64_t) 1));\n+ ASSERT_EQ((int8_t) 1, (int8_t) occa::primitive::positive((int8_t) 1));\n+ ASSERT_EQ((int16_t) 1, (int16_t) occa::primitive::positive((int16_t) 1));\n+ ASSERT_EQ((int32_t) 1, (int32_t) occa::primitive::positive((int32_t) 1));\n+ ASSERT_EQ((int64_t) 1, (int64_t) occa::primitive::positive((int64_t) 1));\n+ ASSERT_EQ((float) 1, (float) occa::primitive::positive((float) 1));\n+ ASSERT_EQ((double) 1, (double) occa::primitive::positive((double) 1));\n+\n+ ASSERT_EQ(false , (bool) occa::primitive::positive(false) );\n+ ASSERT_EQ((uint8_t) -1, (uint8_t) occa::primitive::positive((uint8_t) -1));\n+ ASSERT_EQ((uint16_t) -1, (uint16_t) occa::primitive::positive((uint16_t) -1));\n+ ASSERT_EQ((uint32_t) -1, (uint32_t) occa::primitive::positive((uint32_t) -1));\n+ ASSERT_EQ((uint64_t) -1, (uint64_t) occa::primitive::positive((uint64_t) -1));\n+ ASSERT_EQ((int8_t) -1, (int8_t) occa::primitive::positive((int8_t) -1));\n+ ASSERT_EQ((int16_t) -1, (int16_t) occa::primitive::positive((int16_t) -1));\n+ ASSERT_EQ((int32_t) -1, (int32_t) occa::primitive::positive((int32_t) -1));\n+ ASSERT_EQ((int64_t) -1, (int64_t) occa::primitive::positive((int64_t) -1));\n+ ASSERT_EQ((float) -1, (float) occa::primitive::positive((float) -1));\n+ ASSERT_EQ((double) -1, (double) occa::primitive::positive((double) -1));\n+}\n+\n+void testNegative() {\n+ ASSERT_EQ(true , (bool) occa::primitive::negative(true) );\n+ ASSERT_EQ((uint8_t) -1, (uint8_t) occa::primitive::negative((uint8_t) 1));\n+ ASSERT_EQ((uint16_t) -1, (uint16_t) occa::primitive::negative((uint16_t) 1));\n+ ASSERT_EQ((uint32_t) -1, (uint32_t) occa::primitive::negative((uint32_t) 1));\n+ ASSERT_EQ((uint64_t) -1, (uint64_t) occa::primitive::negative((uint64_t) 1));\n+ ASSERT_EQ((int8_t) -1, (int8_t) occa::primitive::negative((int8_t) 1));\n+ ASSERT_EQ((int16_t) -1, (int16_t) occa::primitive::negative((int16_t) 1));\n+ ASSERT_EQ((int32_t) -1, (int32_t) occa::primitive::negative((int32_t) 1));\n+ ASSERT_EQ((int64_t) -1, (int64_t) occa::primitive::negative((int64_t) 1));\n+ ASSERT_EQ((float) -1, (float) occa::primitive::negative((float) 1));\n+ ASSERT_EQ((double) -1, (double) occa::primitive::negative((double) 1));\n+\n+ ASSERT_EQ(false , (bool) occa::primitive::negative(false) );\n+ ASSERT_EQ((uint8_t) 1, (uint8_t) occa::primitive::negative((uint8_t) -1));\n+ ASSERT_EQ((uint16_t) 1, (uint16_t) occa::primitive::negative((uint16_t) -1));\n+ ASSERT_EQ((uint32_t) 1, (uint32_t) occa::primitive::negative((uint32_t) -1));\n+ ASSERT_EQ((uint64_t) 1, (uint64_t) occa::primitive::negative((uint64_t) -1));\n+ ASSERT_EQ((int8_t) 1, (int8_t) occa::primitive::negative((int8_t) -1));\n+ ASSERT_EQ((int16_t) 1, (int16_t) occa::primitive::negative((int16_t) -1));\n+ ASSERT_EQ((int32_t) 1, (int32_t) occa::primitive::negative((int32_t) -1));\n+ ASSERT_EQ((int64_t) 1, (int64_t) occa::primitive::negative((int64_t) -1));\n+ ASSERT_EQ((float) 1, (float) occa::primitive::negative((float) -1));\n+ ASSERT_EQ((double) 1, (double) occa::primitive::negative((double) -1));\n+}\n+\n+void testTilde() {\n+ ASSERT_EQ(false, (bool) occa::primitive::tilde(true));\n+ ASSERT_EQ(true , (bool) occa::primitive::tilde(false));\n+\n+ ASSERT_EQ(uint8_t(1), (uint8_t) occa::primitive::tilde(~(uint8_t(1))));\n+ ASSERT_EQ(int8_t(1), (int8_t) occa::primitive::tilde(~(int8_t(1))));\n+\n+ ASSERT_EQ(uint16_t(1), (uint16_t) occa::primitive::tilde(~(uint16_t(1))));\n+ ASSERT_EQ(int16_t(1), (int16_t) occa::primitive::tilde(~(int16_t(1))));\n+\n+ ASSERT_EQ(uint32_t(1), (uint32_t) occa::primitive::tilde(~(uint32_t(1))));\n+ ASSERT_EQ(int32_t(1), (int32_t) occa::primitive::tilde(~(int32_t(1))));\n+\n+ ASSERT_EQ(uint64_t(1), (uint64_t) occa::primitive::tilde(~(uint64_t(1))));\n+ ASSERT_EQ(int64_t(1), (int64_t) occa::primitive::tilde(~(int64_t(1))));\n+\n+ //Cannot apply tilde to floating point types.\n+ ASSERT_THROW(occa::primitive::tilde(1.2345f));\n+ ASSERT_THROW(occa::primitive::tilde(1.2345));\n+}\n+\n+void testLeftIncrement() {\n+ occa::primitive p(true);\n+ ASSERT_THROW(occa::primitive::leftIncrement(p));\n+\n+ p = occa::primitive((uint8_t) 7);\n+ ASSERT_EQ(uint8_t(8),(uint8_t) occa::primitive::leftIncrement(p));\n+\n+ p = occa::primitive((uint16_t) 7);\n+ ASSERT_EQ(uint16_t(8),(uint16_t) occa::primitive::leftIncrement(p));\n+\n+ p = occa::primitive((uint32_t) 7);\n+ ASSERT_EQ(uint32_t(8),(uint32_t) occa::primitive::leftIncrement(p));\n+\n+ p = occa::primitive((uint64_t) 7);\n+ ASSERT_EQ(uint64_t(8),(uint64_t) occa::primitive::leftIncrement(p));\n+\n+ p = occa::primitive((int8_t) 7);\n+ ASSERT_EQ(int8_t(8),(int8_t) occa::primitive::leftIncrement(p));\n+\n+ p = occa::primitive((int16_t) 7);\n+ ASSERT_EQ(int16_t(8),(int16_t) occa::primitive::leftIncrement(p));\n+\n+ p = occa::primitive((int32_t) 7);\n+ ASSERT_EQ(int32_t(8),(int32_t) occa::primitive::leftIncrement(p));\n+\n+ p = occa::primitive((int64_t) 7);\n+ ASSERT_EQ(int64_t(8),(int64_t) occa::primitive::leftIncrement(p));\n+\n+ p = occa::primitive((float) 7);\n+ ASSERT_EQ((float) 8,(float) occa::primitive::leftIncrement(p));\n+\n+ p = occa::primitive((double) 7);\n+ ASSERT_EQ((double) 8,(double) occa::primitive::leftIncrement(p));\n+}\n+\n+void testRightIncrement() {\n+ occa::primitive p(true);\n+ ASSERT_THROW(occa::primitive::rightIncrement(p));\n+\n+ p = occa::primitive((uint8_t) 7);\n+ occa::primitive::rightIncrement(p);\n+ ASSERT_EQ(uint8_t(8),(uint8_t) p);\n+\n+ p = occa::primitive((uint16_t) 7);\n+ occa::primitive::rightIncrement(p);\n+ ASSERT_EQ(uint16_t(8),(uint16_t) p);\n+\n+ p = occa::primitive((uint32_t) 7);\n+ occa::primitive::rightIncrement(p);\n+ ASSERT_EQ(uint32_t(8),(uint32_t) p);\n+\n+ p = occa::primitive((uint64_t) 7);\n+ occa::primitive::rightIncrement(p);\n+ ASSERT_EQ(uint64_t(8),(uint64_t) p);\n+\n+ p = occa::primitive((int8_t) 7);\n+ occa::primitive::rightIncrement(p);\n+ ASSERT_EQ(int8_t(8),(int8_t) p);\n+\n+ p = occa::primitive((int16_t) 7);\n+ occa::primitive::rightIncrement(p);\n+ ASSERT_EQ(int16_t(8),(int16_t) p);\n+\n+ p = occa::primitive((int32_t) 7);\n+ occa::primitive::rightIncrement(p);\n+ ASSERT_EQ(int32_t(8),(int32_t) p);\n+\n+ p = occa::primitive((int64_t) 7);\n+ occa::primitive::rightIncrement(p);\n+ ASSERT_EQ(int64_t(8),(int64_t) p);\n+\n+ p = occa::primitive(0.2345f);\n+ occa::primitive::rightIncrement(p);\n+ ASSERT_EQ(1.2345f,(float) p);\n+\n+ p = occa::primitive(0.2345);\n+ occa::primitive::rightIncrement(p);\n+ ASSERT_EQ(1.2345,(double) p);\n+}\n+\n+void testLeftDecrement() {\n+ occa::primitive p(true);\n+ ASSERT_THROW(occa::primitive::leftDecrement(p));\n+\n+ p = occa::primitive((uint8_t) 7);\n+ ASSERT_EQ(uint8_t(6),(uint8_t) occa::primitive::leftDecrement(p));\n+\n+ p = occa::primitive((uint16_t) 7);\n+ ASSERT_EQ(uint16_t(6),(uint16_t) occa::primitive::leftDecrement(p));\n+\n+ p = occa::primitive((uint32_t) 7);\n+ ASSERT_EQ(uint32_t(6),(uint32_t) occa::primitive::leftDecrement(p));\n+\n+ p = occa::primitive((uint64_t) 7);\n+ ASSERT_EQ(uint64_t(6),(uint64_t) occa::primitive::leftDecrement(p));\n+\n+ p = occa::primitive((int8_t) 7);\n+ ASSERT_EQ(int8_t(6),(int8_t) occa::primitive::leftDecrement(p));\n+\n+ p = occa::primitive((int16_t) 7);\n+ ASSERT_EQ(int16_t(6),(int16_t) occa::primitive::leftDecrement(p));\n+\n+ p = occa::primitive((int32_t) 7);\n+ ASSERT_EQ(int32_t(6),(int32_t) occa::primitive::leftDecrement(p));\n+\n+ p = occa::primitive((int64_t) 7);\n+ ASSERT_EQ(int64_t(6),(int64_t) occa::primitive::leftDecrement(p));\n+\n+ p = occa::primitive((float) 7);\n+ ASSERT_EQ((float) 6,(float) occa::primitive::leftDecrement(p));\n+\n+ p = occa::primitive((double) 7);\n+ ASSERT_EQ((double) 6,(double) occa::primitive::leftDecrement(p));\n+}\n+\n+void testRightDecrement() {\n+ occa::primitive p(true);\n+ ASSERT_THROW(occa::primitive::rightDecrement(p));\n+\n+ p = occa::primitive((uint8_t) 7);\n+ occa::primitive::rightDecrement(p);\n+ ASSERT_EQ(uint8_t(6),(uint8_t) p);\n+\n+ p = occa::primitive((uint16_t) 7);\n+ occa::primitive::rightDecrement(p);\n+ ASSERT_EQ(uint16_t(6),(uint16_t) p);\n+\n+ p = occa::primitive((uint32_t) 7);\n+ occa::primitive::rightDecrement(p);\n+ ASSERT_EQ(uint32_t(6),(uint32_t) p);\n+\n+ p = occa::primitive((uint64_t) 7);\n+ occa::primitive::rightDecrement(p);\n+ ASSERT_EQ(uint64_t(6),(uint64_t) p);\n+\n+ p = occa::primitive((int8_t) 7);\n+ occa::primitive::rightDecrement(p);\n+ ASSERT_EQ(int8_t(6),(int8_t) p);\n+\n+ p = occa::primitive((int16_t) 7);\n+ occa::primitive::rightDecrement(p);\n+ ASSERT_EQ(int16_t(6),(int16_t) p);\n+\n+ p = occa::primitive((int32_t) 7);\n+ occa::primitive::rightDecrement(p);\n+ ASSERT_EQ(int32_t(6),(int32_t) p);\n+\n+ p = occa::primitive((int64_t) 7);\n+ occa::primitive::rightDecrement(p);\n+ ASSERT_EQ(int64_t(6),(int64_t) p);\n+\n+ p = occa::primitive((float) 7);\n+ occa::primitive::rightDecrement(p);\n+ ASSERT_EQ((float) 6,(float) p);\n+\n+ p = occa::primitive((double) 7);\n+ occa::primitive::rightDecrement(p);\n+ ASSERT_EQ((double) 6 ,(double) p);\n}\n" } ]
C++
MIT License
libocca/occa
Improve test coverage for primitive types. (#545)