build, benchdnn: disable no_ref_memory for sanitizer validation

This commit is contained in:
Dmitrii Zarukin
2025-05-16 14:58:37 -07:00
committed by Dmitry Zarukin
parent ad13577684
commit eee549c5ff
2 changed files with 19 additions and 1 deletions

View File

@ -335,6 +335,7 @@ elseif(UNIX OR MINGW)
message(STATUS
"Using Clang ${DNNL_ENABLED_CLANG_SANITIZER} "
"sanitizer (experimental!)")
append(CMAKE_CCXX_SANITIZER_FLAGS "-DDNNL_ENABLED_CLANG_SANITIZER")
append(CMAKE_CCXX_SANITIZER_FLAGS "-g")
# Already enabled for x64
if(NOT DNNL_TARGET_ARCH STREQUAL "X64")

View File

@ -34,6 +34,22 @@ static const std::string benchdnn_url
static const std::string doc_url = benchdnn_url + "/doc/";
namespace parser_utils {
// Current definition works only through the build system. It can be generalized
// through C++11 `__has_feature` macro, but not every sanitizer has a macro
// to check against.
//
// The function disables `no_ref_memory` modifier for sanitizers testing because
// many legit places in the library can't work with completely overflowed
// values, like int32 zero-point values.
bool has_clang_sanitizers() {
#if defined(DNNL_ENABLED_CLANG_SANITIZER)
return true;
#else
return false;
#endif
}
std::string get_pattern(const std::string &option_name, bool with_args) {
std::string s = std::string("--") + option_name;
if (with_args) s += "=";
@ -1294,7 +1310,8 @@ static bool parse_mode(
case 'r':
case 'R':
mode = bench_mode_t::exec;
bench_mode_modifier |= mode_modifier_t::no_ref_memory;
if (!parser_utils::has_clang_sanitizers())
bench_mode_modifier |= mode_modifier_t::no_ref_memory;
break;
case 'c':
case 'C': mode = bench_mode_t::corr; break;