Skip to content

Commit ba74f25

Browse files
committed
Add amuse-ph4-sapporo2 package
1 parent 4b16c44 commit ba74f25

10 files changed

Lines changed: 278 additions & 2 deletions

File tree

src/amuse_ph4/Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ $(CODELIB):
2222

2323
.PHONY: $(CODELIB_SAPPORO)
2424
$(CODELIB_SAPPORO):
25-
$(MAKE) -C src -j $(CPU_COUNT) gpulib CXX='$(MPICXX)' CFLAGS='$(CFLAGS)' SAPPORO_LIBDIRS='$(SAPPORO_LIGHT_CFLAGS)' SAPPORO_LIBS='$(SAPPORO_LIGHT_LIBS)'
25+
$(MAKE) -C src -j $(CPU_COUNT) gpulib CXX='$(MPICXX)' CFLAGS='$(CFLAGS)'
2626

2727

2828
# Building the workers
@@ -42,6 +42,9 @@ ph4_worker: ph4_worker.o interface.o $(CODELIB)
4242
ph4_sapporo_worker: ph4_worker.o interface.o $(CODELIB_SAPPORO)
4343
$(MPICXX) -o $@ $(LDFLAGS) $^ $(LDLIBS) $(SAPPORO_LIGHT_LIBS)
4444

45+
ph4_sapporo2_worker: ph4_worker.o interface.o $(CODELIB_SAPPORO)
46+
$(MPICXX) -o $@ $(LDFLAGS) $^ $(LDLIBS) -lsapporoG6 $(SAPPORO2_LIBS)
47+
4548
%.o: %.cc
4649
$(MPICXX) -o $@ -c $(CFLAGS) $<
4750

@@ -51,6 +54,8 @@ amuse-ph4_contains: ph4_worker
5154

5255
amuse-ph4-sapporo_contains: ph4_sapporo_worker
5356

57+
amuse-ph4-sapporo2_contains: ph4_sapporo2_worker
58+
5459

5560
# Building and installing packages
5661
develop-%: %_contains
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
c c++ mpi sapporo2
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../..
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
[project]
2+
name = "amuse-ph4-sapporo2"
3+
dynamic = ["version"]
4+
requires-python = ">=3.7"
5+
dependencies = [
6+
"amuse-framework",
7+
"amuse-ph4"
8+
]
9+
10+
[build-system]
11+
requires = ["hatchling", "versioningit"]
12+
build-backend = "hatchling.build"
13+
14+
[tool.hatch.version]
15+
source = "versioningit"
16+
17+
[tool.versioningit.next-version]
18+
method = "smallest"
19+
20+
[tool.versioningit.format]
21+
distance = "{next_version}.dev{distance}+{vcs}{rev}"
22+
dirty = "{base_version}+d{build_date:%Y%m%d}"
23+
distance-dirty = "{next_version}.dev{distance}+{vcs}{rev}.d{build_date:%Y%m%d}"
24+
25+
[tool.versioningit.vcs]
26+
method = { module = "version_helper", value = "get_amuse_version", module-dir = "amuse_ph4/support/shared" }
27+
28+
[tool.hatch.build]
29+
skip-excluded-dirs = true
30+
31+
[tool.hatch.build.targets.wheel]
32+
include = ["amuse_ph4"]
33+
exclude = ["amuse_ph4/*"]
34+
artifacts = ["amuse_ph4/ph4_sapporo2_worker"]
35+
36+
[tool.pytest.ini_options]
37+
pythonpath = ["amuse_ph4/tests/", "../../../tests"]
38+
39+
testpaths = ["amuse_ph4/tests"]
40+
41+
# Test the installed package, and only GPU tests.
42+
addopts = "--import-mode=append -k gpu"
43+

src/amuse_ph4/src/grape.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ extern "C" {
2020
return g6_npipes_();
2121
}
2222

23+
int g6_get_nj_max()
24+
{
25+
return g6_get_nj_max_();
26+
}
27+
2328
int g6_set_tunit(double t)
2429
{
2530
return g6_set_tunit_(&t);

src/amuse_ph4/src/grape.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ extern "C" {
1414
int g6_npipes_();
1515
int g6_npipes();
1616

17+
int g6_get_nj_max_();
18+
int g6_get_nj_max();
19+
1720
int g6_set_tunit_(double*);
1821
int g6_set_tunit(double t);
1922

src/amuse_ph4/src/jdata.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434

3535
#ifdef GPU
3636
#include "grape.h"
37-
#include "sapporo.h"
3837
#endif
3938

4039
// AMUSE STOPPING CONDITIONS SUPPORT

src/amuse_ph4/support/config.mk.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,7 @@ FOUND_SAPPORO_LIGHT = @FOUND_SAPPORO_LIGHT@
2929
SAPPORO_LIGHT_CFLAGS = @SAPPORO_LIGHT_CFLAGS@
3030
SAPPORO_LIGHT_LIBS = @SAPPORO_LIGHT_LIBS@
3131

32+
FOUND_SAPPORO2 = @FOUND_SAPPORO2@
33+
SAPPORO2_CFLAGS = @SAPPORO2_CFLAGS@
34+
SAPPORO2_LIBS = @SAPPORO2_LIBS@
35+

src/amuse_ph4/support/configure

Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,9 @@ MPILIBS
622622
MPI_CLIBS
623623
MPI_CFLAGS
624624
MPICC
625+
FOUND_SAPPORO2
626+
SAPPORO2_LIBS
627+
SAPPORO2_CFLAGS
625628
FOUND_SAPPORO_LIGHT
626629
SAPPORO_LIGHT_LIBS
627630
SAPPORO_LIGHT_CFLAGS
@@ -720,6 +723,8 @@ STOPCOND_CFLAGS
720723
STOPCOND_LIBS
721724
SAPPORO_LIGHT_CFLAGS
722725
SAPPORO_LIGHT_LIBS
726+
SAPPORO2_CFLAGS
727+
SAPPORO2_LIBS
723728
MPICC
724729
MPICXX'
725730

@@ -1364,6 +1369,10 @@ Some influential environment variables:
13641369
C compiler flags for SAPPORO_LIGHT, overriding pkg-config
13651370
SAPPORO_LIGHT_LIBS
13661371
linker flags for SAPPORO_LIGHT, overriding pkg-config
1372+
SAPPORO2_CFLAGS
1373+
C compiler flags for SAPPORO2, overriding pkg-config
1374+
SAPPORO2_LIBS
1375+
linker flags for SAPPORO2, overriding pkg-config
13671376
MPICC MPI C compiler command
13681377
MPICXX MPI C++ compiler command
13691378
@@ -5256,6 +5265,211 @@ fi
52565265

52575266

52585267

5268+
amuse_save_LIBS="$LIBS"
5269+
amuse_save_LIB_CFLAGS="$SAPPORO2_CFLAGS"
5270+
amuse_save_LIB_LIBS="$SAPPORO2_LIBS"
5271+
amuse_save_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
5272+
5273+
# If we have an active virtualenv, make sure pkg-config searches it
5274+
if test "a${VIRTUAL_ENV}" != "a"
5275+
then
5276+
PKG_CONFIG_PATH="${VIRTUAL_ENV}/lib/pkgconfig:${PKG_CONFIG_PATH}"
5277+
fi
5278+
5279+
# All AMUSE libs export C symbols
5280+
ac_ext=c
5281+
ac_cpp='$CPP $CPPFLAGS'
5282+
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
5283+
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
5284+
ac_compiler_gnu=$ac_cv_c_compiler_gnu
5285+
5286+
5287+
# Search for the library, first directly then fall back to pkg-config
5288+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing numberOfGPUUsedBySapporo" >&5
5289+
printf %s "checking for library containing numberOfGPUUsedBySapporo... " >&6; }
5290+
if test ${ac_cv_search_numberOfGPUUsedBySapporo+y}
5291+
then :
5292+
printf %s "(cached) " >&6
5293+
else $as_nop
5294+
ac_func_search_save_LIBS=$LIBS
5295+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
5296+
/* end confdefs.h. */
5297+
5298+
/* Override any GCC internal prototype to avoid an error.
5299+
Use char because int might match the return type of a GCC
5300+
builtin and then its argument prototype would still apply. */
5301+
char numberOfGPUUsedBySapporo ();
5302+
int
5303+
main (void)
5304+
{
5305+
return numberOfGPUUsedBySapporo ();
5306+
;
5307+
return 0;
5308+
}
5309+
_ACEOF
5310+
for ac_lib in '' sapporo2
5311+
do
5312+
if test -z "$ac_lib"; then
5313+
ac_res="none required"
5314+
else
5315+
ac_res=-l$ac_lib
5316+
LIBS="-l$ac_lib $ac_func_search_save_LIBS"
5317+
fi
5318+
if ac_fn_c_try_link "$LINENO"
5319+
then :
5320+
ac_cv_search_numberOfGPUUsedBySapporo=$ac_res
5321+
fi
5322+
rm -f core conftest.err conftest.$ac_objext conftest.beam \
5323+
conftest$ac_exeext
5324+
if test ${ac_cv_search_numberOfGPUUsedBySapporo+y}
5325+
then :
5326+
break
5327+
fi
5328+
done
5329+
if test ${ac_cv_search_numberOfGPUUsedBySapporo+y}
5330+
then :
5331+
5332+
else $as_nop
5333+
ac_cv_search_numberOfGPUUsedBySapporo=no
5334+
fi
5335+
rm conftest.$ac_ext
5336+
LIBS=$ac_func_search_save_LIBS
5337+
fi
5338+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_numberOfGPUUsedBySapporo" >&5
5339+
printf "%s\n" "$ac_cv_search_numberOfGPUUsedBySapporo" >&6; }
5340+
ac_res=$ac_cv_search_numberOfGPUUsedBySapporo
5341+
if test "$ac_res" != no
5342+
then :
5343+
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
5344+
5345+
FOUND_SAPPORO2="yes"
5346+
SAPPORO2_LIBS="$LIBS"
5347+
SAPPORO2_CFLAGS=""
5348+
5349+
else $as_nop
5350+
5351+
5352+
pkg_failed=no
5353+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for SAPPORO2" >&5
5354+
printf %s "checking for SAPPORO2... " >&6; }
5355+
5356+
if test -n "$SAPPORO2_CFLAGS"; then
5357+
pkg_cv_SAPPORO2_CFLAGS="$SAPPORO2_CFLAGS"
5358+
elif test -n "$PKG_CONFIG"; then
5359+
if test -n "$PKG_CONFIG" && \
5360+
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"sapporo2\""; } >&5
5361+
($PKG_CONFIG --exists --print-errors "sapporo2") 2>&5
5362+
ac_status=$?
5363+
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
5364+
test $ac_status = 0; }; then
5365+
pkg_cv_SAPPORO2_CFLAGS=`$PKG_CONFIG --cflags "sapporo2" 2>/dev/null`
5366+
test "x$?" != "x0" && pkg_failed=yes
5367+
else
5368+
pkg_failed=yes
5369+
fi
5370+
else
5371+
pkg_failed=untried
5372+
fi
5373+
if test -n "$SAPPORO2_LIBS"; then
5374+
pkg_cv_SAPPORO2_LIBS="$SAPPORO2_LIBS"
5375+
elif test -n "$PKG_CONFIG"; then
5376+
if test -n "$PKG_CONFIG" && \
5377+
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"sapporo2\""; } >&5
5378+
($PKG_CONFIG --exists --print-errors "sapporo2") 2>&5
5379+
ac_status=$?
5380+
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
5381+
test $ac_status = 0; }; then
5382+
pkg_cv_SAPPORO2_LIBS=`$PKG_CONFIG --libs "sapporo2" 2>/dev/null`
5383+
test "x$?" != "x0" && pkg_failed=yes
5384+
else
5385+
pkg_failed=yes
5386+
fi
5387+
else
5388+
pkg_failed=untried
5389+
fi
5390+
5391+
5392+
5393+
if test $pkg_failed = yes; then
5394+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
5395+
printf "%s\n" "no" >&6; }
5396+
5397+
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
5398+
_pkg_short_errors_supported=yes
5399+
else
5400+
_pkg_short_errors_supported=no
5401+
fi
5402+
if test $_pkg_short_errors_supported = yes; then
5403+
SAPPORO2_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "sapporo2" 2>&1`
5404+
else
5405+
SAPPORO2_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "sapporo2" 2>&1`
5406+
fi
5407+
# Put the nasty error message in config.log where it belongs
5408+
echo "$SAPPORO2_PKG_ERRORS" >&5
5409+
5410+
5411+
FOUND_SAPPORO2="no"
5412+
5413+
elif test $pkg_failed = untried; then
5414+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
5415+
printf "%s\n" "no" >&6; }
5416+
5417+
FOUND_SAPPORO2="no"
5418+
5419+
else
5420+
SAPPORO2_CFLAGS=$pkg_cv_SAPPORO2_CFLAGS
5421+
SAPPORO2_LIBS=$pkg_cv_SAPPORO2_LIBS
5422+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
5423+
printf "%s\n" "yes" >&6; }
5424+
5425+
FOUND_SAPPORO2="yes"
5426+
5427+
fi
5428+
5429+
fi
5430+
5431+
5432+
ac_ext=c
5433+
ac_cpp='$CPP $CPPFLAGS'
5434+
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
5435+
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
5436+
ac_compiler_gnu=$ac_cv_c_compiler_gnu
5437+
5438+
5439+
PKG_CONFIG_PATH="$amuse_save_PKG_CONFIG_PATH"
5440+
LIBS="$amuse_save_LIBS"
5441+
5442+
# If we have an active CONDA environment, assume that the lib is coming from
5443+
# there and add an additional flag so that .mod files can be found. Only really
5444+
# needed for stopcond and forsockets, and hopefully conda-forge will give us a
5445+
# better solution soon.
5446+
if test "${FOUND_SAPPORO2}" == "yes" -a "x$CONDA_PREFIX" != "x"
5447+
then
5448+
SAPPORO2_CFLAGS="${SAPPORO2_CFLAGS} -I${CONDA_PREFIX}/include"
5449+
fi
5450+
5451+
# If the user overrode the variables, go with what they set instead of
5452+
# what we just detected.
5453+
if test "x$amuse_save_LIB_CFLAGS" != "x"
5454+
then :
5455+
5456+
SAPPORO2_CFLAGS="$amuse_save_LIB_CFLAGS"
5457+
5458+
fi
5459+
if test "x$amuse_save_LIB_LIBS" != "x"
5460+
then :
5461+
5462+
SAPPORO2_LIBS="$amuse_save_LIB_LIBS"
5463+
5464+
fi
5465+
5466+
5467+
5468+
5469+
5470+
5471+
5472+
52595473
# Find external dependencies
52605474
ac_ext=c
52615475
ac_cpp='$CPP $CPPFLAGS'

src/amuse_ph4/support/configure.ac

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ AS_IF([test $RANLIB = ":"], [AC_MSG_ERROR([ranlib command not found.])])
2727
# Find AMUSE libraries
2828
AMUSE_LIB_STOPCOND()
2929
AMUSE_LIB_SAPPORO_LIGHT()
30+
AMUSE_LIB_SAPPORO2()
3031

3132

3233
# Find external dependencies

0 commit comments

Comments
 (0)