[Openmp-commits] [openmp] 68b88ae - [libomptarget] Improve dlwrap compile time error diagnostic
Jon Chesterfield via Openmp-commits
openmp-commits at lists.llvm.org
Thu May 20 12:33:48 PDT 2021
Author: Jon Chesterfield
Date: 2021-05-20T20:33:36+01:00
New Revision: 68b88ae6701a840f5badb8ec0492602b953e8f8a
URL: https://github.com/llvm/llvm-project/commit/68b88ae6701a840f5badb8ec0492602b953e8f8a
DIFF: https://github.com/llvm/llvm-project/commit/68b88ae6701a840f5badb8ec0492602b953e8f8a.diff
LOG: [libomptarget] Improve dlwrap compile time error diagnostic
[libomptarget] Improve dlwrap compile time error diagnostic
The dlwrap interface takes an explict arity, e.g. DLWRAP(cuAlloc, 2);
This probably can't be eliminated as it controls the argument list of an
external symbol, not an inline header function. If the arity given is too
big, the error from clang referring to the line is in the middle of
implementation details.
/usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/tuple:1277:7: error: static_assert failed
due to requirement '0UL < tuple_size<std::tuple<>>::value' "tuple index is in range"
static_assert(__i < tuple_size<tuple<>>::value,
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/tuple:1260:7: ...
/usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/tuple:1260:7: ...
/home/amd/llvm-project/openmp/libomptarget/include/dlwrap.h:93:27 ...
/home/amd/llvm-project/openmp/libomptarget/plugins/cuda/dynamic_cuda/cuda.cpp:34:1: note: in
instantiation of template class 'dlwrap::trait<cudaError_enum (*)(unsigned long *, unsigned
long)>::arg<2>' requested here
DLWRAP(cuMemAlloc, 3);
^
/home/amd/llvm-project/openmp/libomptarget/include/dlwrap.h:51:31: ...
/home/amd/llvm-project/openmp/libomptarget/include/dlwrap.h:166:3: ...
/home/amd/llvm-project/openmp/libomptarget/include/dlwrap.h:133:3: ...
/home/amd/llvm-project/openmp/libomptarget/include/dlwrap.h:186:37: ...
If the arity is too small, the diagnostic is better:
cuda/dynamic_cuda/cuda.cpp:34:1: error: too few
arguments to function call, expected 2, have 1
DLWRAP(cuMemAlloc, 1);
This patch changes the diagnostic to:
cuda/dynamic_cuda/cuda.cpp:34:1: error:
static_assert failed due to requirement '1 == trait<cudaError_enum (*)(unsigned long *, unsigned
long)>::nargs' "Arity Error"
DLWRAP(cuMemAlloc, 1);
or
cuda/dynamic_cuda/cuda.cpp:34:1: error:
static_assert failed due to requirement '3 == trait<cudaError_enum (*)(unsigned long *, unsigned
long)>::nargs' "Arity Error"
DLWRAP(cuMemAlloc, 3);
Reviewed By: tianshilei1992
Differential Revision: https://reviews.llvm.org/D102858
Added:
Modified:
openmp/libomptarget/include/dlwrap.h
Removed:
################################################################################
diff --git a/openmp/libomptarget/include/dlwrap.h b/openmp/libomptarget/include/dlwrap.h
index 9e078b34ca577..5ba453a6c3fed 100644
--- a/openmp/libomptarget/include/dlwrap.h
+++ b/openmp/libomptarget/include/dlwrap.h
@@ -158,6 +158,7 @@ constexpr std::array<const char *, N> static getSymbolArray(
return reinterpret_cast<T::FunctionType>(P); \
} \
}; \
+ static_assert(ARITY == trait<decltype(&SYMBOL)>::nargs, "Arity Error"); \
}
#define DLWRAP_IMPL(SYMBOL, ARITY) \
More information about the Openmp-commits
mailing list