Skip to content

Commit

Permalink
--enable-propagate-signal, --with...default, less locks, omit UNUSED
Browse files Browse the repository at this point in the history
  • Loading branch information
vaeth committed Feb 21, 2017
1 parent 8e62c8a commit b098de3
Show file tree
Hide file tree
Showing 8 changed files with 204 additions and 95 deletions.
10 changes: 10 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# ChangeLog for chessproblem

*chessproblem-2.2
- Support --enable-propagate-signal: This is a different inter-thread
communication strategy which needs more memory and might perhaps be
faster, but can also be slower. It is a good strategy if there are
many bad last moves to try before a "winning" one is found.
- ./configure --with-max-parallel-default=...
- ./configure ----with-min-half-move-depth-default=...
- Micro-optimization: avoid atomic locks where unneeded
- Cleanup code: Avoid compiler UNUSED magic/attributes

*chessproblem-2.1
- Rework multithreading strategy:
- Use one Communication object common to all equally ranked threads:
Expand Down
16 changes: 10 additions & 6 deletions config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
/* Define if [[fallthrough]] can be used */
#undef HAVE_ATTRIBUTE_FALLTHROUGH

/* [Define if [[maybe_unused]] can be used] */
#undef HAVE_ATTRIBUTE_MAYBE_UNUSED

/* [Define if [[nodiscard]] can be used] */
#undef HAVE_ATTRIBUTE_NODISCARD

Expand All @@ -27,9 +24,6 @@
/* Define if __attribute__ ((pure)) can be used */
#undef HAVE_ATTRIBUTE_PURE

/* Define if __attribute__ ((unused)) can be used */
#undef HAVE_ATTRIBUTE_UNUSED

/* Define if __attribute__ ((warn_unused_result)) can be used */
#undef HAVE_ATTRIBUTE_WARN_UNUSED_RESULT

Expand Down Expand Up @@ -69,6 +63,12 @@
/* Define if __builtin_expect can be used */
#undef HAVE___BUILTIN_EXPECT

/* default maximal parallel threads if defined */
#undef MAX_PARALLEL_DEFAULT

/* default minimal half move depth for a new thread if defined */
#undef MIN_HALF_MOVE_DEPTH_DEFAULT

/* Define if multithreading is not wanted/possible */
#undef NO_CHESSPROBLEM_THREADS

Expand All @@ -93,6 +93,10 @@
/* Define to the version of this package. */
#undef PACKAGE_VERSION

/* Define if memory intensive (faster?/slower?) thread policy should be used
*/
#undef PROPAGATE_SIGNAL

/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS

Expand Down
76 changes: 37 additions & 39 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Martin V\"ath <martin@mvath.de>

dnl keep version in same line as AC_INIT for possible usage in scripts
AC_INIT([chessproblem], [2.1],
AC_INIT([chessproblem], [2.2],
[https://github.com/vaeth/chessproblem/issues/],
[chessproblem],
[https://github.com/vaeth/chessproblem/])
Expand Down Expand Up @@ -463,44 +463,6 @@ AS_IF([$attr_deprecated],
[1],
[[Define if __attribute__ ((deprecated("a"))) can be used]])])

# Check if [[maybe_unused]] works
AC_MSG_CHECKING([[whether [[maybe_unused]] can be used]])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
static int dummy(int i);
static int
dummy([[maybe_unused]] int i)
{ return 0; }
]], [[
return dummy(1);
]])],
[MV_MSG_RESULT([yes])
AS_VAR_SET([attr_maybe_unused], [:])],
[MV_MSG_RESULT([no])
AS_VAR_SET([attr_maybe_unused], [false])])
AS_IF([$attr_maybe_unused],
[AC_DEFINE([HAVE_ATTRIBUTE_MAYBE_UNUSED],
[1],
[[Define if [[maybe_unused]] can be used]])])

# Check if __attribute__ ((unused)) works
AC_MSG_CHECKING([whether __attribute__ ((unused)) can be used])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
static int dummy(int i);
static int
dummy(__attribute__ ((unused)) int i)
{ return 0; }
]], [[
return dummy(1);
]])],
[MV_MSG_RESULT([yes])
AS_VAR_SET([attr_unused], [:])],
[MV_MSG_RESULT([no])
AS_VAR_SET([attr_unused], [false])])
AS_IF([$attr_unused],
[AC_DEFINE([HAVE_ATTRIBUTE_UNUSED],
[1],
[Define if __attribute__ ((unused)) can be used])])

# Check if [[noreturn]] works
AC_MSG_CHECKING([[whether [[noreturn]] can be used]])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Expand Down Expand Up @@ -757,6 +719,42 @@ AS_IF([$support_multithreading],
AS_VAR_SET([MULTITHREAD_LIBS], [])])
AC_SUBST([MULTITHREAD_LIBS])

AC_MSG_CHECKING([maximal parallel threads default])
AC_ARG_WITH([max-parallel-default],
[AS_HELP_STRING([--with-max-parallel-default=STR],
[default maximal parallel threads])],
[AS_VAR_COPY([MAX_PARALLEL_DEFAULT], [withval])],
[AS_VAR_SET([MAX_PARALLEL_DEFAULT], [])])
MV_MSG_RESULT_VAR([MAX_PARALLEL_DEFAULT])
MV_IF_NONEMPTY([$MAX_PARALLEL_DEFAULT],
[AC_DEFINE_UNQUOTED([MAX_PARALLEL_DEFAULT],
[$MAX_PARALLEL_DEFAULT],
[default maximal parallel threads if defined])])

AC_MSG_CHECKING([minimal half move depth for a new thread])
AC_ARG_WITH([min-half-move-depth-default],
[AS_HELP_STRING([--with-min-half-move-depth-default=STR],
[default minimal half move depth for a new thread])],
[AS_VAR_COPY([MIN_HALF_MOVE_DEPTH_DEFAULT], [withval])],
[AS_VAR_SET([MIN_HALF_MOVE_DEPTH_DEFAULT], [])])
MV_MSG_RESULT_VAR([MIN_HALF_MOVE_DEPTH_DEFAULT])
MV_IF_NONEMPTY([$MIN_HALF_MOVE_DEPTH_DEFAULT],
[AC_DEFINE_UNQUOTED([MIN_HALF_MOVE_DEPTH_DEFAULT],
[$MIN_HALF_MOVE_DEPTH_DEFAULT],
[default minimal half move depth for a new thread if defined])])

AC_MSG_CHECKING([propagate-signal])
AC_ARG_ENABLE([propagate-signal],
[AS_HELP_STRING([--enable-propagate-signal],
[use memory intensive (faster?/slower?) thread policy])],
[MV_ENABLE([propagate_signal])],
[AS_VAR_SET([propagate_signal], [false])])
MV_MSG_RESULT_BIN([$propagate_signal])
AS_IF([$propagate_signal],
[AC_DEFINE([PROPAGATE_SIGNAL],
[1],
[Define if memory intensive (faster?/slower?) thread policy should be used])])

# Done!
AC_OUTPUT()

Expand Down
11 changes: 8 additions & 3 deletions contrib/make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ Available options are
-n Stop after ./configure, i.e. do not run make
-e Keep environment - do not modify LDFLAGS, CXXFLAGS, CFLAGS, CC
-w Enable warnings
-t No multithreading
-t With propagate-signal (for multithreading)
-T No multithreading
-o Enable optimization
-g Use clang++, setting CXX, filtering some flags (default if available)
-G Use default CXX (mnemonic: GNU)
Expand Down Expand Up @@ -91,6 +92,7 @@ quiet=false
dep_default=:
earlystop=false
keepenv=false
propagate_signal=:
multithreading=:
warnings=false
use_chown=false
Expand All @@ -105,15 +107,16 @@ debugging=false
command -v clang++ >/dev/null 2>&1 && clang=: || clang=false
dialect='enable'
OPTIND=1
while getopts 'qgGdnewtoCxXyYdc:j:rhH' opt
while getopts 'qgGdnewtToCxXyYdc:j:rhH' opt
do case $opt in
q) quiet=:;;
g) clang=:;;
G) clang=false;;
n) earlystop=:;;
e) keepenv=:;;
w) warnings=:;;
t) multithreading=false;;
t) propagate_signal=:;;
T) multithreading=false;;
o) optimization=:;;
C) use_ccache=false;;
x) recache=:;;
Expand Down Expand Up @@ -142,6 +145,8 @@ SetCcache
! $warnings || configure_extra=$configure_extra' --enable-warnings'
$multithreading && configure_extra=$configure_extra' --with-multithreading' \
|| configure_extra=$configure_extra' --without-multithreading'
! $propagate_signal \
|| configure_extra=$configure_extra' --with-propagate-signal'
$quiet && quietredirect='>/dev/null' || quietredirect=

if $use_chown
Expand Down
Loading

0 comments on commit b098de3

Please sign in to comment.