Skip to content

Commit

Permalink
Revert "added workaround for broken asserts in HIP (at least on NVIDIA)"
Browse files Browse the repository at this point in the history
This reverts commit a2fc6b7.
  • Loading branch information
neworderofjamie committed Jan 15, 2025
1 parent 782aa5c commit d934e8d
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 25 deletions.
3 changes: 0 additions & 3 deletions include/genn/backends/cuda/backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,6 @@ class BACKEND_EXPORT Backend : public BackendCUDAHIP
const Type::ResolvedType &type, const std::string &name, VarLocation loc,
const std::string &countVarName) const final;

//! On backends which support it, generate a runtime assert
virtual void genAssert(CodeStream &os, const std::string &condition) const final;

virtual void genMakefilePreamble(std::ostream &os) const final;
virtual void genMakefileLinkRule(std::ostream &os) const final;
virtual void genMakefileCompileRule(std::ostream &os) const final;
Expand Down
3 changes: 0 additions & 3 deletions include/genn/backends/hip/backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,6 @@ class BACKEND_EXPORT Backend : public BackendCUDAHIP
const Type::ResolvedType &type, const std::string &name, VarLocation loc,
const std::string &countVarName) const final;

//! On backends which support it, generate a runtime assert
virtual void genAssert(CodeStream &os, const std::string &condition) const final;

virtual void genMakefilePreamble(std::ostream &os) const final;
virtual void genMakefileLinkRule(std::ostream &os) const final;
virtual void genMakefileCompileRule(std::ostream &os) const final;
Expand Down
3 changes: 3 additions & 0 deletions include/genn/genn/code_generator/backendCUDAHIP.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ class GENN_EXPORT BackendCUDAHIP : public BackendSIMT
//! Generate code to return amount of free 'device' memory in bytes
virtual void genReturnFreeDeviceMemoryBytes(CodeStream &os) const final;

//! On backends which support it, generate a runtime assert
virtual void genAssert(CodeStream &os, const std::string &condition) const final;

//! As well as host pointers, are device objects required?
virtual bool isArrayDeviceObjectRequired() const final{ return true; }

Expand Down
6 changes: 1 addition & 5 deletions src/genn/backends/cuda/backend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

// GeNN includes
#include "gennUtils.h"
#include "logging.h"
#include "type.h"

// GeNN code generator includes
Expand Down Expand Up @@ -397,11 +398,6 @@ void Backend::genLazyVariableDynamicAllocation(CodeStream &os, const Type::Resol
}
}
//--------------------------------------------------------------------------
void Backend::genAssert(CodeStream &os, const std::string &condition) const
{
os << "assert(" << condition << ");" << std::endl;
}
//--------------------------------------------------------------------------
void Backend::genMakefilePreamble(std::ostream &os) const
{
const std::string architecture = "sm_" + std::to_string(getChosenCUDADevice().major) + std::to_string(getChosenCUDADevice().minor);
Expand Down
14 changes: 0 additions & 14 deletions src/genn/backends/hip/backend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -390,20 +390,6 @@ void Backend::genLazyVariableDynamicAllocation(CodeStream &os, const Type::Resol
}
}
//--------------------------------------------------------------------------
void Backend::genAssert(CodeStream &os, const std::string &condition) const
{
#ifdef __HIP_PLATFORM_NVIDIA__
LOGW_BACKEND << "Asserts do not currently work correctly on HIP NVIDIA backend";
os << "if(!(" << condition << "))";
{
CodeStream::Scope b(os);
os << "printf(\"Assert failure\\n\");" << std::endl;
}
#else
os << "assert(" << condition << ");" << std::endl;
#endif
}
//--------------------------------------------------------------------------
void Backend::genMakefilePreamble(std::ostream &os) const
{
const std::string architecture = "sm_" + std::to_string(getChosenHIPDevice().major) + std::to_string(getChosenHIPDevice().minor);
Expand Down
6 changes: 6 additions & 0 deletions src/genn/genn/code_generator/backendCUDAHIP.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

// GeNN includes
#include "gennUtils.h"
#include "logging.h"
#include "type.h"

// GeNN code generator includes
Expand Down Expand Up @@ -1437,6 +1438,11 @@ void BackendCUDAHIP::genReturnFreeDeviceMemoryBytes(CodeStream &os) const
os << "return free;" << std::endl;
}
//--------------------------------------------------------------------------
void BackendCUDAHIP::genAssert(CodeStream &os, const std::string &condition) const
{
os << "assert(" << condition << ");" << std::endl;
}
//--------------------------------------------------------------------------
BackendCUDAHIP::MemorySpaces BackendCUDAHIP::getMergedGroupMemorySpaces(const ModelSpecMerged &modelMerged) const
{
// Get size of update group start ids (constant cache is precious so don't use for init groups
Expand Down

0 comments on commit d934e8d

Please sign in to comment.