Skip to content

Commit

Permalink
Fix some libraries caused conflicts (libdispatch v.s. nvml).
Browse files Browse the repository at this point in the history
  • Loading branch information
liuliu committed Jun 7, 2024
1 parent 78fedee commit e63fd6e
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 95 deletions.
172 changes: 86 additions & 86 deletions lib/configure
Original file line number Diff line number Diff line change
Expand Up @@ -3884,7 +3884,7 @@ printf "%s\n" "$ax_cv_check_cflags_fftw3_h" >&6; }
if test "x$ax_cv_check_cflags_fftw3_h" = xyes
then :
DEFINE_MACROS="$DEFINE_MACROS-D HAVE_FFTW3 "
MKLDFLAGS="$MKLDFLAGS-lfftw3 -lfftw3f -lpthread "
MKLDFLAGS="$MKLDFLAGS-lfftw3 -lfftw3f "
else $as_nop
:
Expand Down Expand Up @@ -4300,90 +4300,6 @@ if test -n "${OPENMP_CFLAGS}"; then
MKLDFLAGS="$MKLDFLAGS$OPENMP_CFLAGS "
fi
# only check dispatch if compiled with clang
if test $CC = clang; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking dispatch/dispatch.h presence" >&5
printf %s "checking dispatch/dispatch.h presence... " >&6; }
if test ${ax_cv_check_cflags_dispatch_dispatch_h+y}
then :
printf %s "(cached) " >&6
else $as_nop
ax_check_save_flags=$CFLAGS
CFLAGS="$CFLAGS dispatch/dispatch.h"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <dispatch/dispatch.h>
int
main (void)
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_cpp "$LINENO"
then :
ax_cv_check_cflags_dispatch_dispatch_h=yes
else $as_nop
ax_cv_check_cflags_dispatch_dispatch_h=no
fi
rm -f conftest.err conftest.i conftest.$ac_ext
CFLAGS=$ax_check_save_flags
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags_dispatch_dispatch_h" >&5
printf "%s\n" "$ax_cv_check_cflags_dispatch_dispatch_h" >&6; }
if test "x$ax_cv_check_cflags_dispatch_dispatch_h" = xyes
then :
DEFINE_MACROS="$DEFINE_MACROS-D USE_DISPATCH "
MKCFLAGS="$MKCFLAGS-fblocks "
else $as_nop
:
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dispatch_apply in -ldispatch" >&5
printf %s "checking for dispatch_apply in -ldispatch... " >&6; }
if test ${ac_cv_lib_dispatch_dispatch_apply+y}
then :
printf %s "(cached) " >&6
else $as_nop
ac_check_lib_save_LIBS=$LIBS
LIBS="-ldispatch $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
char dispatch_apply ();
int
main (void)
{
return dispatch_apply ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"
then :
ac_cv_lib_dispatch_dispatch_apply=yes
else $as_nop
ac_cv_lib_dispatch_dispatch_apply=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dispatch_dispatch_apply" >&5
printf "%s\n" "$ac_cv_lib_dispatch_dispatch_apply" >&6; }
if test "x$ac_cv_lib_dispatch_dispatch_apply" = xyes
then :
MKLDFLAGS="$MKLDFLAGS-ldispatch -lBlocksRuntime "
fi
fi
# check for SSE2 support only we don't enable NEON explicitly
if test "$neon_support" != yes; then
Expand Down Expand Up @@ -4590,7 +4506,7 @@ if [ -d "$cuda_prefix" ]; then
DEFINE_MACROS="$DEFINE_MACROS-D HAVE_CUDA "
# CUB requires stdc++, unfortunately.
MKLDFLAGS="$MKLDFLAGS-lcuda -lcudart -lcublas -lcurand -lstdc++ "
MKLDFLAGS="$MKLDFLAGS-lcudart -lcublas -lcurand -lstdc++ "
CPPFLAGS="$CPPFLAGS-I$cuda_prefix/include "
Expand Down Expand Up @@ -4742,6 +4658,90 @@ else
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
printf "%s\n" "no" >&6; }
# only check dispatch if compiled with clang and no cuda.
if test $CC = clang; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking dispatch/dispatch.h presence" >&5
printf %s "checking dispatch/dispatch.h presence... " >&6; }
if test ${ax_cv_check_cflags_dispatch_dispatch_h+y}
then :
printf %s "(cached) " >&6
else $as_nop
ax_check_save_flags=$CFLAGS
CFLAGS="$CFLAGS dispatch/dispatch.h"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <dispatch/dispatch.h>
int
main (void)
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_cpp "$LINENO"
then :
ax_cv_check_cflags_dispatch_dispatch_h=yes
else $as_nop
ax_cv_check_cflags_dispatch_dispatch_h=no
fi
rm -f conftest.err conftest.i conftest.$ac_ext
CFLAGS=$ax_check_save_flags
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags_dispatch_dispatch_h" >&5
printf "%s\n" "$ax_cv_check_cflags_dispatch_dispatch_h" >&6; }
if test "x$ax_cv_check_cflags_dispatch_dispatch_h" = xyes
then :
DEFINE_MACROS="$DEFINE_MACROS-D USE_DISPATCH "
MKCFLAGS="$MKCFLAGS-fblocks "
else $as_nop
:
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dispatch_apply in -ldispatch" >&5
printf %s "checking for dispatch_apply in -ldispatch... " >&6; }
if test ${ac_cv_lib_dispatch_dispatch_apply+y}
then :
printf %s "(cached) " >&6
else $as_nop
ac_check_lib_save_LIBS=$LIBS
LIBS="-ldispatch $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
char dispatch_apply ();
int
main (void)
{
return dispatch_apply ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"
then :
ac_cv_lib_dispatch_dispatch_apply=yes
else $as_nop
ac_cv_lib_dispatch_dispatch_apply=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dispatch_dispatch_apply" >&5
printf "%s\n" "$ac_cv_lib_dispatch_dispatch_apply" >&6; }
if test "x$ac_cv_lib_dispatch_dispatch_apply" = xyes
then :
MKLDFLAGS="$MKLDFLAGS-ldispatch -lBlocksRuntime "
fi
fi
fi
# check for MPS support
Expand Down
16 changes: 8 additions & 8 deletions lib/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ AC_MSG_CHECKING([fftw3])
AC_ARG_ENABLE(fftw3, [AS_HELP_STRING([--disable-fftw3], [disable FFTW3 (GPL License)])], [fftw3_enable=$enableval], [fftw3_enable="yes"])
if test "$fftw3_enable" != no; then
AX_CHECK_HEADER_PRESENCE([fftw3.h],
[AC_SUBST(DEFINE_MACROS, ["$DEFINE_MACROS-D HAVE_FFTW3 "]) AC_SUBST(MKLDFLAGS, ["$MKLDFLAGS-lfftw3 -lfftw3f -lpthread "])])
[AC_SUBST(DEFINE_MACROS, ["$DEFINE_MACROS-D HAVE_FFTW3 "]) AC_SUBST(MKLDFLAGS, ["$MKLDFLAGS-lfftw3 -lfftw3f "])])
else
AC_MSG_RESULT([disabled])
fi
Expand Down Expand Up @@ -135,12 +135,6 @@ if test -n "${OPENMP_CFLAGS}"; then
AC_SUBST(MKCFLAGS, ["$MKCFLAGS$OPENMP_CFLAGS "])
AC_SUBST(MKLDFLAGS, ["$MKLDFLAGS$OPENMP_CFLAGS "])
fi
# only check dispatch if compiled with clang
if test $CC = clang; then
AX_CHECK_HEADER_PRESENCE([dispatch/dispatch.h],
[AC_SUBST(DEFINE_MACROS, ["$DEFINE_MACROS-D USE_DISPATCH "]) AC_SUBST(MKCFLAGS, ["$MKCFLAGS-fblocks "])])
AC_CHECK_LIB(dispatch, dispatch_apply, [AC_SUBST(MKLDFLAGS, ["$MKLDFLAGS-ldispatch -lBlocksRuntime "])])
fi
# check for SSE2 support only we don't enable NEON explicitly
if test "$neon_support" != yes; then
AX_CHECK_HEADER_PRESENCE(xmmintrin.h,
Expand All @@ -165,7 +159,7 @@ AC_ARG_WITH(cuda, [AS_HELP_STRING([--with-cuda], [CUDA installation [ARG=/usr/lo
if [[ -d "$cuda_prefix" ]]; then
AC_SUBST(DEFINE_MACROS, ["$DEFINE_MACROS-D HAVE_CUDA "])
# CUB requires stdc++, unfortunately.
AC_SUBST(MKLDFLAGS, ["$MKLDFLAGS-lcuda -lcudart -lcublas -lcurand -lstdc++ "])
AC_SUBST(MKLDFLAGS, ["$MKLDFLAGS-lcudart -lcublas -lcurand -lstdc++ "])
AC_SUBST(CPPFLAGS, ["$CPPFLAGS-I$cuda_prefix/include "])
if [[ -d "$cuda_prefix/lib64" ]]; then
AC_SUBST(MKLDFLAGS, ["$MKLDFLAGS-L$cuda_prefix/lib64 "])
Expand Down Expand Up @@ -196,6 +190,12 @@ else
AC_SUBST(CUDA_COMPAT_LIB, [""])
AC_SUBST(CUDA_CMD_LIB, [""])
AC_MSG_RESULT(no)
# only check dispatch if compiled with clang and no cuda.
if test $CC = clang; then
AX_CHECK_HEADER_PRESENCE([dispatch/dispatch.h],
[AC_SUBST(DEFINE_MACROS, ["$DEFINE_MACROS-D USE_DISPATCH "]) AC_SUBST(MKCFLAGS, ["$MKCFLAGS-fblocks "])])
AC_CHECK_LIB(dispatch, dispatch_apply, [AC_SUBST(MKLDFLAGS, ["$MKLDFLAGS-ldispatch -lBlocksRuntime "])])
fi
fi

# check for MPS support
Expand Down
2 changes: 2 additions & 0 deletions lib/nnc/_ccv_nnc_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ struct ccv_nnc_stream_signal_s {

typedef struct {
// Empty, this will hold things such as NCCL communicator in subclass.
// Putting dummy because C / C++ treats empty struct differently.
int dummy;
} ccv_nnc_stream_resource_container_t;

struct ccv_nnc_stream_context_s {
Expand Down
2 changes: 1 addition & 1 deletion test/int/nnc/cudnn.tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -5377,7 +5377,7 @@ TEST_CASE("cudnn forward convolution transpose")
ccv_nnc_stream_context_free(stream_context);
ccv_nnc_tensor_t* c = ccv_nnc_tensor_new(0, CPU_TENSOR_NHWC(32F, BATCH_SIZE, INPUT_SIZE, INPUT_SIZE, INPUT_DIM), 0);
ccv_nnc_cmd_exec(move, ccv_nnc_no_hint, 0, TENSOR_LIST(gc), TENSOR_LIST(c), 0);
REQUIRE_ARRAY_EQ_WITH_TOLERANCE(float, b->data.f32, c->data.f32, BATCH_SIZE * INPUT_DIM * INPUT_SIZE * INPUT_SIZE, 1e-4, "output from cudnn should match from CPU");
REQUIRE_ARRAY_EQ_WITH_TOLERANCE(float, b->data.f32, c->data.f32, BATCH_SIZE * INPUT_DIM * INPUT_SIZE * INPUT_SIZE, 2e-4, "output from cudnn should match from CPU");
ccv_nnc_tensor_free(c);
ccv_nnc_tensor_free(gc);
ccv_nnc_tensor_free(bias);
Expand Down

0 comments on commit e63fd6e

Please sign in to comment.