Skip to content

Commit

Permalink
Restored Windows compatability
Browse files Browse the repository at this point in the history
  • Loading branch information
mpflanzer committed Jun 22, 2015
1 parent 5978c88 commit 0e5cde0
Show file tree
Hide file tree
Showing 12 changed files with 63 additions and 63 deletions.
2 changes: 1 addition & 1 deletion src/core/Context.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/core/KernelInvocation.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/core/WorkGroup.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/core/WorkItem.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
22 changes: 11 additions & 11 deletions src/core/WorkItemBuiltins.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/core/common.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
22 changes: 11 additions & 11 deletions src/core/common.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/InteractiveDebugger.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
48 changes: 24 additions & 24 deletions src/plugins/Logger.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ void Logger::log(MessageType type, const char *message)
lock_guard<mutex> 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"
Expand All @@ -105,25 +105,25 @@ 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)
{
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)
Expand Down Expand Up @@ -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
{
Expand Down
8 changes: 4 additions & 4 deletions src/plugins/MemCheck.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}
}

Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/RaceDetector.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/Uninitialized.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0e5cde0

Please sign in to comment.