diff --git a/src/core/Context.h b/src/core/Context.h old mode 100644 new mode 100755 index e4b060cc..66fd989c --- a/src/core/Context.h +++ b/src/core/Context.h @@ -27,7 +27,7 @@ namespace oclgrind Memory* getGlobalMemory() const; bool isThreadSafe() const; - void logError(const char* error, MessageType type = ERROR) const; + void logError(const char* error, MessageType type = OCLGRIND_ERROR) const; // Simulation callbacks void notifyInstructionExecuted(const WorkItem *workItem, diff --git a/src/core/KernelInvocation.cpp b/src/core/KernelInvocation.cpp old mode 100644 new mode 100755 index ede73f44..6525f9ac --- a/src/core/KernelInvocation.cpp +++ b/src/core/KernelInvocation.cpp @@ -172,7 +172,7 @@ void KernelInvocation::run(const Context *context, Kernel *kernel, << endl << err.what() << endl << "When allocating kernel constants for '" << kernel->getName() << "'"; - context->logError(info.str().c_str(), ERROR_FATAL); + context->logError(info.str().c_str(), OCLGRIND_ERROR_FATAL); return; } @@ -276,7 +276,7 @@ void KernelInvocation::runWorker() info << "OCLGRIND FATAL ERROR " << "(" << err.getFile() << ":" << err.getLine() << ")" << endl << err.what(); - m_context->logError(info.str().c_str(), ERROR_FATAL); + m_context->logError(info.str().c_str(), OCLGRIND_ERROR_FATAL); if (workerState.workGroup) delete workerState.workGroup; diff --git a/src/core/WorkGroup.cpp b/src/core/WorkGroup.cpp old mode 100644 new mode 100755 index b137a070..d2081a10 --- a/src/core/WorkGroup.cpp +++ b/src/core/WorkGroup.cpp @@ -124,7 +124,7 @@ size_t WorkGroup::async_copy( (itr->first.srcStride != copy.srcStride) || (itr->first.destStride != copy.destStride)) { - Context::Message msg(ERROR_DIVERGENCE, m_context); + Context::Message msg(OCLGRIND_ERROR_DIVERGENCE, m_context); msg << "Work-group divergence detected (async copy)" << endl << msg.INDENT << "Kernel: " << msg.CURRENT_KERNEL << endl @@ -179,7 +179,7 @@ void WorkGroup::clearBarrier() // Check for divergence if (m_barrier->workItems.size() != m_workItems.size()) { - Context::Message msg(ERROR_DIVERGENCE, m_context); + Context::Message msg(OCLGRIND_ERROR_DIVERGENCE, m_context); msg << "Work-group divergence detected (barrier)" << endl << msg.INDENT << "Kernel: " << msg.CURRENT_KERNEL << endl @@ -246,7 +246,7 @@ void WorkGroup::clearBarrier() // Check that all work-items registered the copy if (cItr->second.size() != m_workItems.size()) { - Context::Message msg(ERROR_DIVERGENCE, m_context); + Context::Message msg(OCLGRIND_ERROR_DIVERGENCE, m_context); msg << "Work-group divergence detected (async copy)" << endl << msg.INDENT << "Kernel: " << msg.CURRENT_KERNEL << endl @@ -384,7 +384,7 @@ void WorkGroup::notifyBarrier(WorkItem *workItem, if (divergence) { - Context::Message msg(ERROR_DIVERGENCE, m_context); + Context::Message msg(OCLGRIND_ERROR_DIVERGENCE, m_context); msg << "Work-group divergence detected (barrier)" << endl << msg.INDENT << "Kernel: " << msg.CURRENT_KERNEL << endl diff --git a/src/core/WorkItem.cpp b/src/core/WorkItem.cpp old mode 100644 new mode 100755 index c65dac4c..c11c11bd --- a/src/core/WorkItem.cpp +++ b/src/core/WorkItem.cpp @@ -1115,7 +1115,7 @@ INSTRUCTION(load) if (address & (alignment-1)) { m_context->logError("Invalid memory load - source pointer is " - "not aligned to the pointed type", ERROR_UNALIGNED); + "not aligned to the pointed type", OCLGRIND_ERROR_UNALIGNED); } // Load data @@ -1332,7 +1332,7 @@ INSTRUCTION(store) if (address & (alignment-1)) { m_context->logError("Invalid memory store - source pointer is " - "not aligned to the pointed type", ERROR_UNALIGNED); + "not aligned to the pointed type", OCLGRIND_ERROR_UNALIGNED); } // Store data diff --git a/src/core/WorkItemBuiltins.cpp b/src/core/WorkItemBuiltins.cpp old mode 100644 new mode 100755 index daa20d70..c170144e --- a/src/core/WorkItemBuiltins.cpp +++ b/src/core/WorkItemBuiltins.cpp @@ -280,7 +280,7 @@ namespace oclgrind size_t address = PARG(0); // Verify the address is 4-byte aligned if ((address & 0x3) != 0) { - workItem->m_context->logError("Unaligned address on atomic_add", ERROR_UNALIGNED); + workItem->m_context->logError("Unaligned address on atomic_add", OCLGRIND_ERROR_UNALIGNED); } uint32_t old = memory->atomic(AtomicAdd, address, UARG(1)); result.setUInt(old); @@ -294,7 +294,7 @@ namespace oclgrind size_t address = PARG(0); // Verify the address is 4-byte aligned if ((address & 0x3) != 0) { - workItem->m_context->logError("Unaligned address on atomic_and", ERROR_UNALIGNED); + workItem->m_context->logError("Unaligned address on atomic_and", OCLGRIND_ERROR_UNALIGNED); } uint32_t old = memory->atomic(AtomicAnd, address, UARG(1)); result.setUInt(old); @@ -308,7 +308,7 @@ namespace oclgrind size_t address = PARG(0); // Verify the address is 4-byte aligned if ((address & 0x3) != 0) { - workItem->m_context->logError("Unaligned address on atomic_cmpxchg", ERROR_UNALIGNED); + workItem->m_context->logError("Unaligned address on atomic_cmpxchg", OCLGRIND_ERROR_UNALIGNED); } uint32_t old = memory->atomicCmpxchg(address, UARG(1), UARG(2)); result.setUInt(old); @@ -322,7 +322,7 @@ namespace oclgrind size_t address = PARG(0); // Verify the address is 4-byte aligned if ((address & 0x3) != 0) { - workItem->m_context->logError("Unaligned address on atomic_dec", ERROR_UNALIGNED); + workItem->m_context->logError("Unaligned address on atomic_dec", OCLGRIND_ERROR_UNALIGNED); } uint32_t old = memory->atomic(AtomicDec, address); result.setUInt(old); @@ -336,7 +336,7 @@ namespace oclgrind size_t address = PARG(0); // Verify the address is 4-byte aligned if ((address & 0x3) != 0) { - workItem->m_context->logError("Unaligned address on atomic_dec", ERROR_UNALIGNED); + workItem->m_context->logError("Unaligned address on atomic_dec", OCLGRIND_ERROR_UNALIGNED); } uint32_t old = memory->atomic(AtomicInc, address); result.setUInt(old); @@ -350,7 +350,7 @@ namespace oclgrind size_t address = PARG(0); // Verify the address is 4-byte aligned if ((address & 0x3) != 0) { - workItem->m_context->logError("Unaligned address on atomic_max", ERROR_UNALIGNED); + workItem->m_context->logError("Unaligned address on atomic_max", OCLGRIND_ERROR_UNALIGNED); } uint32_t old = memory->atomic(AtomicMax, address, UARG(1)); result.setUInt(old); @@ -364,7 +364,7 @@ namespace oclgrind size_t address = PARG(0); // Verify the address is 4-byte aligned if ((address & 0x3) != 0) { - workItem->m_context->logError("Unaligned address on atomic_min", ERROR_UNALIGNED); + workItem->m_context->logError("Unaligned address on atomic_min", OCLGRIND_ERROR_UNALIGNED); } uint32_t old = memory->atomic(AtomicMin, address, UARG(1)); result.setUInt(old); @@ -378,7 +378,7 @@ namespace oclgrind size_t address = PARG(0); // Verify the address is 4-byte aligned if ((address & 0x3) != 0) { - workItem->m_context->logError("Unaligned address on atomic_or", ERROR_UNALIGNED); + workItem->m_context->logError("Unaligned address on atomic_or", OCLGRIND_ERROR_UNALIGNED); } uint32_t old = memory->atomic(AtomicOr, address, UARG(1)); result.setUInt(old); @@ -392,7 +392,7 @@ namespace oclgrind size_t address = PARG(0); // Verify the address is 4-byte aligned if ((address & 0x3) != 0) { - workItem->m_context->logError("Unaligned address on atomic_sub", ERROR_UNALIGNED); + workItem->m_context->logError("Unaligned address on atomic_sub", OCLGRIND_ERROR_UNALIGNED); } uint32_t old = memory->atomic(AtomicSub, address, UARG(1)); result.setUInt(old); @@ -406,7 +406,7 @@ namespace oclgrind size_t address = PARG(0); // Verify the address is 4-byte aligned if ((address & 0x3) != 0) { - workItem->m_context->logError("Unaligned address on atomic_xchg", ERROR_UNALIGNED); + workItem->m_context->logError("Unaligned address on atomic_xchg", OCLGRIND_ERROR_UNALIGNED); } uint32_t old = memory->atomic(AtomicXchg, address, UARG(1)); result.setUInt(old); @@ -420,7 +420,7 @@ namespace oclgrind size_t address = PARG(0); // Verify the address is 4-byte aligned if ((address & 0x3) != 0) { - workItem->m_context->logError("Unaligned address on atomic_xor", ERROR_UNALIGNED); + workItem->m_context->logError("Unaligned address on atomic_xor", OCLGRIND_ERROR_UNALIGNED); } uint32_t old = memory->atomic(AtomicXor, address, UARG(1)); result.setUInt(old); diff --git a/src/core/common.cpp b/src/core/common.cpp old mode 100644 new mode 100755 index 6f71fe2a..1b790882 --- a/src/core/common.cpp +++ b/src/core/common.cpp @@ -691,7 +691,7 @@ namespace oclgrind MessageType getMessageBaseType(MessageType type) { - return (MessageType)(type & 0b11); + return (MessageType)(type & 0x3); } FatalError::FatalError(const string& msg, const string& file, size_t line) diff --git a/src/core/common.h b/src/core/common.h old mode 100644 new mode 100755 index 6154f223..6ac3c134 --- a/src/core/common.h +++ b/src/core/common.h @@ -81,19 +81,19 @@ namespace oclgrind enum MessageType { // Base types - DEBUG = 0, - INFO = 1, - WARNING = 2, - ERROR = 3, + OCLGRIND_DEBUG = 0, + OCLGRIND_INFO = 1, + OCLGRIND_WARNING = 2, + OCLGRIND_ERROR = 3, // Special warning types - WARNING_UNINITIALIZED = WARNING + 4, + OCLGRIND_WARNING_UNINITIALIZED = OCLGRIND_WARNING + 4, // Special error types - ERROR_DIVERGENCE = ERROR + 4, - ERROR_INVALID_ACCESS = ERROR + 8, - ERROR_DATA_RACE = ERROR + 12, - ERROR_UNALIGNED = ERROR + 16, - ERROR_ARRAY_BOUNDS = ERROR + 20, - ERROR_FATAL = ERROR + 24, + OCLGRIND_ERROR_DIVERGENCE = OCLGRIND_ERROR + 4, + OCLGRIND_ERROR_INVALID_ACCESS = OCLGRIND_ERROR + 8, + OCLGRIND_ERROR_DATA_RACE = OCLGRIND_ERROR + 12, + OCLGRIND_ERROR_UNALIGNED = OCLGRIND_ERROR + 16, + OCLGRIND_ERROR_ARRAY_BOUNDS = OCLGRIND_ERROR + 20, + OCLGRIND_ERROR_FATAL = OCLGRIND_ERROR + 24, }; // 3-dimensional size diff --git a/src/plugins/InteractiveDebugger.cpp b/src/plugins/InteractiveDebugger.cpp old mode 100644 new mode 100755 index 498d9ffb..4f97b808 --- a/src/plugins/InteractiveDebugger.cpp +++ b/src/plugins/InteractiveDebugger.cpp @@ -199,7 +199,7 @@ void InteractiveDebugger::kernelEnd(const KernelInvocation *kernelInvocation) void InteractiveDebugger::log(MessageType type, const char *message) { - if (getMessageBaseType(type) == ERROR) + if (getMessageBaseType(type) == OCLGRIND_ERROR) m_forceBreak = true; } diff --git a/src/plugins/Logger.cpp b/src/plugins/Logger.cpp old mode 100644 new mode 100755 index eada28bd..91962215 --- a/src/plugins/Logger.cpp +++ b/src/plugins/Logger.cpp @@ -71,15 +71,15 @@ void Logger::log(MessageType type, const char *message) lock_guard lock(logMutex); // Limit number of errors/warning printed - if (!hasDiagnosticOption(type) && type != ERROR_FATAL) + if (!hasDiagnosticOption(type) && type != OCLGRIND_ERROR_FATAL) { return; } MessageType baseType = getMessageBaseType(type); - if (baseType == ERROR || baseType == WARNING) + if (baseType == OCLGRIND_ERROR || baseType == OCLGRIND_WARNING) { - if (m_numErrors == m_maxErrors && hasDiagnosticOption(INFO)) + if (m_numErrors == m_maxErrors && hasDiagnosticOption(OCLGRIND_INFO)) { *m_log << endl << "Oclgrind: " << m_numErrors << " errors generated - suppressing further errors" @@ -105,17 +105,17 @@ void Logger::enableDiagnosticOption(MessageType optType, bool status) void Logger::enableAllDiagnostics() { // Turn on generic groups - enableDiagnosticOption(INFO); - enableDiagnosticOption(DEBUG); - enableDiagnosticOption(WARNING); - enableDiagnosticOption(ERROR); + enableDiagnosticOption(OCLGRIND_INFO); + enableDiagnosticOption(OCLGRIND_DEBUG); + enableDiagnosticOption(OCLGRIND_WARNING); + enableDiagnosticOption(OCLGRIND_ERROR); // Turn on specific groups - enableDiagnosticOption(WARNING_UNINITIALIZED); - enableDiagnosticOption(ERROR_DIVERGENCE); - enableDiagnosticOption(ERROR_INVALID_ACCESS); - enableDiagnosticOption(ERROR_DATA_RACE); - enableDiagnosticOption(ERROR_UNALIGNED); - enableDiagnosticOption(ERROR_ARRAY_BOUNDS); + enableDiagnosticOption(OCLGRIND_WARNING_UNINITIALIZED); + enableDiagnosticOption(OCLGRIND_ERROR_DIVERGENCE); + enableDiagnosticOption(OCLGRIND_ERROR_INVALID_ACCESS); + enableDiagnosticOption(OCLGRIND_ERROR_DATA_RACE); + enableDiagnosticOption(OCLGRIND_ERROR_UNALIGNED); + enableDiagnosticOption(OCLGRIND_ERROR_ARRAY_BOUNDS); } void Logger::logBadDiagnosticOption(const char* opt, bool isInvalid) @@ -123,7 +123,7 @@ void Logger::logBadDiagnosticOption(const char* opt, bool isInvalid) std::stringstream msg; msg << (isInvalid ? "Invalid" : "Unknown") << " diagnostic option '" << opt << "'."; - log(WARNING, msg.str().c_str()); + log(OCLGRIND_WARNING, msg.str().c_str()); } bool Logger::parseDiagnosticOptions(char *options) @@ -174,40 +174,40 @@ bool Logger::parseDiagnosticOptions(char *options) } else if (!strcmp(opt_type, "generic")) { - enableDiagnosticOption(WARNING, isPositive); - enableDiagnosticOption(ERROR, isPositive); + enableDiagnosticOption(OCLGRIND_WARNING, isPositive); + enableDiagnosticOption(OCLGRIND_ERROR, isPositive); } else if (!strcmp(opt_type, "info")) { - enableDiagnosticOption(INFO, isPositive); + enableDiagnosticOption(OCLGRIND_INFO, isPositive); } else if (!strcmp(opt_type, "debug")) { - enableDiagnosticOption(DEBUG, isPositive); + enableDiagnosticOption(OCLGRIND_DEBUG, isPositive); } else if (!strcmp(opt_type, "uninitialized")) { - enableDiagnosticOption(WARNING_UNINITIALIZED, isPositive); + enableDiagnosticOption(OCLGRIND_WARNING_UNINITIALIZED, isPositive); } else if (!strcmp(opt_type, "divergence")) { - enableDiagnosticOption(ERROR_DIVERGENCE, isPositive); + enableDiagnosticOption(OCLGRIND_ERROR_DIVERGENCE, isPositive); } else if (!strcmp(opt_type, "invalid-access")) { - enableDiagnosticOption(ERROR_INVALID_ACCESS, isPositive); + enableDiagnosticOption(OCLGRIND_ERROR_INVALID_ACCESS, isPositive); } else if (!strcmp(opt_type, "data-race")) { - enableDiagnosticOption(ERROR_DATA_RACE, isPositive); + enableDiagnosticOption(OCLGRIND_ERROR_DATA_RACE, isPositive); } else if (!strcmp(opt_type, "unaligned")) { - enableDiagnosticOption(ERROR_UNALIGNED, isPositive); + enableDiagnosticOption(OCLGRIND_ERROR_UNALIGNED, isPositive); } else if (!strcmp(opt_type, "array-bounds")) { - enableDiagnosticOption(ERROR_ARRAY_BOUNDS, isPositive); + enableDiagnosticOption(OCLGRIND_ERROR_ARRAY_BOUNDS, isPositive); } else { diff --git a/src/plugins/MemCheck.cpp b/src/plugins/MemCheck.cpp old mode 100644 new mode 100755 index 74054045..9e968091 --- a/src/plugins/MemCheck.cpp +++ b/src/plugins/MemCheck.cpp @@ -47,7 +47,7 @@ void MemCheck::instructionExecuted(const WorkItem *workItem, info << "Index (" << index << ") exceeds static array size (" << size << ")"; - m_context->logError(info.str().c_str(), ERROR_ARRAY_BOUNDS); + m_context->logError(info.str().c_str(), OCLGRIND_ERROR_ARRAY_BOUNDS); } ptrType = ptrType->getArrayElementType(); @@ -119,7 +119,7 @@ void MemCheck::checkLoad(const Memory *memory, if (memory->getBuffer(address)->flags & CL_MEM_WRITE_ONLY) { - m_context->logError("Invalid read from write-only buffer", ERROR_INVALID_ACCESS); + m_context->logError("Invalid read from write-only buffer", OCLGRIND_ERROR_INVALID_ACCESS); } } @@ -134,14 +134,14 @@ void MemCheck::checkStore(const Memory *memory, if (memory->getBuffer(address)->flags & CL_MEM_READ_ONLY) { - m_context->logError("Invalid write to read-only buffer", ERROR_INVALID_ACCESS); + m_context->logError("Invalid write to read-only buffer", OCLGRIND_ERROR_INVALID_ACCESS); } } void MemCheck::logInvalidAccess(bool read, unsigned addrSpace, size_t address, size_t size) const { - Context::Message msg(ERROR_INVALID_ACCESS, m_context); + Context::Message msg(OCLGRIND_ERROR_INVALID_ACCESS, m_context); msg << "Invalid " << (read ? "read" : "write") << " of size " << size << " at " << getAddressSpaceName(addrSpace) diff --git a/src/plugins/RaceDetector.cpp b/src/plugins/RaceDetector.cpp old mode 100644 new mode 100755 index cc02767f..d8e3e290 --- a/src/plugins/RaceDetector.cpp +++ b/src/plugins/RaceDetector.cpp @@ -128,7 +128,7 @@ void RaceDetector::logRace(DataRaceType type, break; } - Context::Message msg(ERROR_DATA_RACE, m_context); + Context::Message msg(OCLGRIND_ERROR_DATA_RACE, m_context); msg << raceType << " data race at " << getAddressSpaceName(addrSpace) << " memory address 0x" << hex << address << endl diff --git a/src/plugins/Uninitialized.cpp b/src/plugins/Uninitialized.cpp old mode 100644 new mode 100755 index 307ef56a..b4b70f9b --- a/src/plugins/Uninitialized.cpp +++ b/src/plugins/Uninitialized.cpp @@ -166,7 +166,7 @@ void Uninitialized::checkState(const Memory *memory, void Uninitialized::logError(unsigned int addrSpace, size_t address) const { - Context::Message msg(WARNING_UNINITIALIZED, m_context); + Context::Message msg(OCLGRIND_WARNING_UNINITIALIZED, m_context); msg << "Uninitialized value read from " << getAddressSpaceName(addrSpace) << " memory address 0x" << hex << address << endl