Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initial support for hpx #341

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
744b2a3
initial support for hpx
ct-clmsn Nov 6, 2023
78216af
adding hpx to cmake
ct-clmsn Nov 7, 2023
a6464f7
fixed cmake issue
ct-clmsn Nov 7, 2023
7b8e590
corrections for linking/loading
ct-clmsn Dec 5, 2023
e0fe01f
fixed variable spelling
ct-clmsn Dec 5, 2023
cf33f60
added environment variable
ct-clmsn Dec 5, 2023
0e5cb7e
added missing hpx libraries to mpi-bench
ct-clmsn Dec 5, 2023
c07076b
fixed typing error
ct-clmsn Dec 6, 2023
524d096
fixed memory allocation performance issue
ct-clmsn Dec 8, 2023
8d7a58e
fixed memory allocation performance issue
ct-clmsn Dec 8, 2023
5629bbc
fixed possible thread scheduling issue
ct-clmsn Dec 8, 2023
ead1a6e
alternative to pkg-config added
ct-clmsn Dec 9, 2023
3f42610
alternative to pkg-config added
ct-clmsn Dec 9, 2023
4720423
fixed bug with pkgconfig detection
ct-clmsn Dec 11, 2023
a4c93b9
updated hpx calls
ct-clmsn Dec 11, 2023
8a77963
fixed runtime initialization
ct-clmsn Dec 11, 2023
36aa011
rollback to hpx v1.9 call to run_as*
ct-clmsn Dec 11, 2023
6a9a26f
added threading hooks for planner
ct-clmsn Dec 27, 2023
bcbb63b
unrolled the parallel loop so the initial thread does work
ct-clmsn Dec 28, 2023
4117af1
rm'd extraneous ';' and changed planner_hooks_installed to a bool
ct-clmsn Dec 29, 2023
e3ea503
added missing header file
ct-clmsn Jan 3, 2024
b94050b
semaphore fix
Jan 5, 2024
25eae8b
added rv64g (riscv 64 bit) cycle counter
ct-clmsn Mar 5, 2024
0d8d86a
error in assembly, referenced wrong storage variable
ct-clmsn Mar 5, 2024
f80f68a
updated copyright in file to include authors
ct-clmsn Mar 5, 2024
642462f
used preferred pseudo-instruction
ct-clmsn Mar 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ option (BUILD_SHARED_LIBS "Build shared libraries" ON)
option (BUILD_TESTS "Build tests" ON)

option (ENABLE_OPENMP "Use OpenMP for multithreading" OFF)
option (ENABLE_HPX "Use HPX for multithreading" OFF)
option (ENABLE_THREADS "Use pthread for multithreading" OFF)
option (WITH_COMBINED_THREADS "Merge thread library" OFF)

Expand Down Expand Up @@ -122,13 +123,24 @@ if (Threads_FOUND)
set (HAVE_THREADS TRUE)
endif ()

if(ENABLE_OPENMP AND ENABLE_HPX)
message(FATAL "OpenMP and HPX cannot be enabled at the same time")
endif ()

if (ENABLE_OPENMP)
find_package (OpenMP)
endif ()
if (OPENMP_FOUND)
set (HAVE_OPENMP TRUE)
endif ()

if (ENABLE_HPX)
find_package (HPX)
endif ()
if (HPX_FOUND)
set (HAVE_HPX TRUE)
endif ()

include (CheckCCompilerFlag)

if (ENABLE_SSE)
Expand Down Expand Up @@ -257,6 +269,7 @@ set(fftw_par_SOURCE

set (fftw_threads_SOURCE ${fftw_par_SOURCE} threads/threads.c)
set (fftw_omp_SOURCE ${fftw_par_SOURCE} threads/openmp.c)
set (fftw_hpx_SOURCE ${fftw_par_SOURCE} threads/hpx.cpp)


include_directories (.)
Expand Down Expand Up @@ -365,6 +378,16 @@ if (OPENMP_FOUND)
target_compile_options (${fftw3_lib}_omp PRIVATE ${OpenMP_C_FLAGS})
endif ()

if (HPX_FOUND)
add_library (${fftw3_lib}_hpx SHARED ${fftw_hpx_SOURCE})
target_include_directories (${fftw3_lib}_hpx INTERFACE $<INSTALL_INTERFACE:include>)
target_link_libraries (${fftw3_lib}_hpx PUBLIC HPX::hpx)
target_link_libraries (${fftw3_lib}_hpx ${fftw3_lib})
target_link_libraries (${fftw3_lib}_hpx ${CMAKE_THREAD_LIBS_INIT})
list (APPEND subtargets ${fftw3_lib}_hpx)
target_compile_options (${fftw3_lib}_hpx PRIVATE HPX::hpx)
endif ()

foreach(subtarget ${subtargets})
set_target_properties (${subtarget} PROPERTIES SOVERSION 3.6.9 VERSION 3)
install (TARGETS ${subtarget}
Expand Down
52 changes: 52 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ AC_LIBTOOL_WIN32_DLL
AC_PROG_LIBTOOL
AC_PROG_RANLIB
AC_PROG_CPP
AC_PROG_CXX

AC_CHECK_PROG(OCAMLBUILD, ocamlbuild, ocamlbuild)

Expand Down Expand Up @@ -677,6 +678,56 @@ if test "$enable_openmp" = "yes"; then
AX_OPENMP([], [AC_MSG_ERROR([don't know how to enable OpenMP])])
fi

AC_ARG_ENABLE(hpx, [AC_HELP_STRING([--enable-hpx],[use HPX for parallelism])], enable_hpx=$enableval, enable_hpx=no)

if test "$enable_hpx" = "yes"; then
AC_SUBST(HPX_LIBS)
AC_SUBST(HPX_CFLAGS)

AC_CHECK_PROG(HAS_PKGCONFIG, pkg-config, yes, no, [], [])

if test "$HAS_PKGCONFIG" = "yes"; then
AC_SUBST(hpxcompfound)

PKG_CHECK_EXISTS([hpx_component],[hpxcompfound=yes],[hpxcompfound=no])

if test "$hpxcompfound" = "no"; then
PKG_CHECK_EXISTS([hpx_component_relwithdebinfo],[],[
AC_MSG_ERROR([required library HPX not found, check PKG_CONFIG_PATH])
])
PKG_CHECK_MODULES([HPX], [hpx_component_relwithdebinfo])
else
PKG_CHECK_MODULES([HPX], [hpx_component])
fi

AC_SUBST(HPX_CXXFLAGS, ["$HPX_CFLAGS"])
AC_DEFINE(HAVE_HPX,1,[Define to enable HPX])
else
AC_LANG_PUSH([C++])

AC_SUBST(HAVE_HPX_HPP)
AC_CHECK_HEADER(hpx/hpx.hpp,[HAVE_HPX_HPP=1],[HAVE_HPX_HPP=0])
if test "$HAVE_HPX_HPP" = "0"; then
AC_MSG_ERROR([required HPX not found, check CXXFLAGS])
fi

AC_SUBST(HAVE_HPX)
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([#include <hpx/hpx.hpp>],
[hpx::init(); hpx::finalize();])],
[HAVE_HPX=1],
[HAVE_HPX=0])

if test "$HAVE_HPX" = "0"; then
AC_MSG_ERROR([required library HPX not found, check LD_LIBRARY_PATH])
fi

HPX_LIBS="-lhpx -lhpx_core"
AC_LANG_POP([C++])
fi

fi

AC_ARG_ENABLE(threads, [AC_HELP_STRING([--enable-threads],[compile FFTW SMP threads library])], enable_threads=$enableval, enable_threads=no)

if test "$enable_threads" = "yes"; then
Expand Down Expand Up @@ -721,6 +772,7 @@ fi
AC_SUBST(THREADLIBS)
AM_CONDITIONAL(THREADS, test "$enable_threads" = "yes")
AM_CONDITIONAL(OPENMP, test "$enable_openmp" = "yes")
AM_CONDITIONAL(HPX, test "$enable_hpx" = "yes")
AM_CONDITIONAL(SMP, test "$enable_threads" = "yes" -o "$enable_openmp" = "yes")
AM_CONDITIONAL(COMBINED_THREADS, test x"$with_combined_threads" = xyes)

Expand Down
24 changes: 24 additions & 0 deletions kernel/cycle.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* Copyright (c) 2003, 2007-14 Matteo Frigo
* Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology
* Copyright (c) 2024 Christopher Taylor, Tactical Computing Labs, LLC
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
Expand Down Expand Up @@ -562,3 +563,26 @@ static inline ticks getticks(void)
INLINE_ELAPSED(inline)
#define HAVE_TICK_COUNTER
#endif

/*----------------------------------------------------------------*/
/*
* RISC_V 64-bit cycle counter (RV64G)
*/
#if defined(__riscv) && (__riscv_xlen == 64) && !defined(HAVE_TICK_COUNTER)

typedef unsigned long ticks;

static __inline__ ticks getticks(void)
{
unsigned long cycles;

__asm__ __volatile__ ("rdcycle %0" : "=r" (cycles));

/* no input, nothing else clobbered */
return cycles;
}

INLINE_ELAPSED(inline)
#define HAVE_TICK_COUNTER

#endif
5 changes: 4 additions & 1 deletion mpi/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,14 @@ mpi_bench_CFLAGS = $(PTHREAD_CFLAGS)
if !COMBINED_THREADS
LIBFFTWTHREADS = $(top_builddir)/threads/libfftw3@PREC_SUFFIX@_threads.la
endif
else
endif
if OPENMP
mpi_bench_CFLAGS = $(OPENMP_CFLAGS)
LIBFFTWTHREADS = $(top_builddir)/threads/libfftw3@PREC_SUFFIX@_omp.la
endif
if HPX
mpi_bench_CFLAGS = $(HPX_CXXFLAGS)
LIBFFTWTHREADS = $(HPX_LIBS) $(top_builddir)/threads/libfftw3@PREC_SUFFIX@_hpx.la
endif

mpi_bench_SOURCES = mpi-bench.c $(top_srcdir)/tests/fftw-bench.c $(top_srcdir)/tests/hook.c
Expand Down
28 changes: 25 additions & 3 deletions threads/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,22 @@ else
FFTWOMPLIB =
endif

if HPX
FFTWHPXLIB = libfftw3@PREC_SUFFIX@_hpx.la
else
FFTWHPXLIB =
endif

if THREADS
if COMBINED_THREADS
noinst_LTLIBRARIES = libfftw3@PREC_SUFFIX@_threads.la
else
endif
if OPENMP
lib_LTLIBRARIES = libfftw3@PREC_SUFFIX@_threads.la $(FFTWOMPLIB)
endif
else
lib_LTLIBRARIES = $(FFTWOMPLIB)
if HPX
lib_LTLIBRARIES = libfftw3@PREC_SUFFIX@_threads.la $(FFTWHPXLIB)
endif
endif

libfftw3@PREC_SUFFIX@_threads_la_SOURCES = api.c conf.c threads.c \
Expand All @@ -26,6 +34,7 @@ if !COMBINED_THREADS
libfftw3@PREC_SUFFIX@_threads_la_LIBADD = ../libfftw3@[email protected]
endif

if OPENMP
libfftw3@PREC_SUFFIX@_omp_la_SOURCES = api.c conf.c openmp.c \
threads.h dft-vrank-geq1.c ct.c rdft-vrank-geq1.c hc2hc.c \
vrank-geq1-rdft2.c f77api.c f77funcs.h
Expand All @@ -34,3 +43,16 @@ libfftw3@PREC_SUFFIX@_omp_la_LDFLAGS = -version-info @SHARED_VERSION_INFO@
if !COMBINED_THREADS
libfftw3@PREC_SUFFIX@_omp_la_LIBADD = ../libfftw3@[email protected]
endif
endif

if HPX
libfftw3@PREC_SUFFIX@_hpx_la_SOURCES = api.c conf.c hpx.cpp \
threads.h dft-vrank-geq1.c ct.c rdft-vrank-geq1.c hc2hc.c \
vrank-geq1-rdft2.c f77api.c f77funcs.h
libfftw3@PREC_SUFFIX@_hpx_la_CXXFLAGS = $(HPX_CXXFLAGS)
libfftw3@PREC_SUFFIX@_hpx_la_CFLAGS = $(AM_CFLAGS)
libfftw3@PREC_SUFFIX@_hpx_la_LDFLAGS = -version-info @SHARED_VERSION_INFO@
if !COMBINED_THREADS
libfftw3@PREC_SUFFIX@_hpx_la_LIBADD = ../libfftw3@[email protected]
endif
endif
Loading