Compare commits
23 Commits
6143d1ae73
...
openacc
| Author | SHA1 | Date | |
|---|---|---|---|
| 017cf43381 | |||
| 77e1aaabeb | |||
| 249f1c0b51 | |||
| 1d96800d45 | |||
| 9087e3af19 | |||
| 418fd9d389 | |||
| 895cd02778 | |||
| 8efa3d911e | |||
| 0fa24404e5 | |||
| 8f7d05efda | |||
| ad542fe856 | |||
| 658397ebd7 | |||
| 26e2f2d109 | |||
| 871471aae3 | |||
| 65a64f3f8c | |||
| 4f9f09e965 | |||
| 6dc943e10a | |||
| ed347ab0d9 | |||
| 8c5c47e208 | |||
| 6871372cac | |||
| 452c0fe001 | |||
| b636b89a64 | |||
| e59d298a01 |
@@ -13,7 +13,9 @@
|
|||||||
(format "%s/include/" root)
|
(format "%s/include/" root)
|
||||||
(format "%s/" root)
|
(format "%s/" root)
|
||||||
(format "%s/bench/" root)
|
(format "%s/bench/" root)
|
||||||
(format "%s/build/main/" root)))))
|
(format "%s/build/main/" root)))
|
||||||
|
(setq-local flycheck-clang-include-path
|
||||||
|
flycheck-gcc-include-path)))
|
||||||
(eval . (flycheck-mode))
|
(eval . (flycheck-mode))
|
||||||
(eval . (outline-minor-mode))
|
(eval . (outline-minor-mode))
|
||||||
(indent-tabs-mode . nil)
|
(indent-tabs-mode . nil)
|
||||||
|
|||||||
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
@@ -18,6 +18,8 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
compiler:
|
compiler:
|
||||||
|
- gcc12
|
||||||
|
- gcc11
|
||||||
- gcc11
|
- gcc11
|
||||||
- gcc10
|
- gcc10
|
||||||
- gcc9
|
- gcc9
|
||||||
|
|||||||
107
README.org
107
README.org
@@ -26,3 +26,110 @@ before the proper paper is released please contact me.
|
|||||||
|
|
||||||
In the mean time the code has been used in
|
In the mean time the code has been used in
|
||||||
[[https://aip.scitation.org/doi/10.1063/5.0074936][this publication]] and can therefore been cited.
|
[[https://aip.scitation.org/doi/10.1063/5.0074936][this publication]] and can therefore been cited.
|
||||||
|
|
||||||
|
* Building
|
||||||
|
|
||||||
|
Atrip uses autotools to build the system.
|
||||||
|
Autotools works by first creating a =configure= script from
|
||||||
|
a =configure.ac= file.
|
||||||
|
|
||||||
|
Atrip should be built out of source, this means that
|
||||||
|
you have to create a build directory other that the root
|
||||||
|
directory, for instance in the =build/tutorial= directory
|
||||||
|
|
||||||
|
#+begin_src sh :exports code
|
||||||
|
mkdir -p build/tutorial/
|
||||||
|
cd build/tutorial
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
First you have to build the =configure= script by doing
|
||||||
|
|
||||||
|
#+begin_src sh :dir build/tutorial :exports code :results raw drawer
|
||||||
|
../../bootstrap.sh
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
#+RESULTS:
|
||||||
|
:results:
|
||||||
|
|
||||||
|
Creating configure script
|
||||||
|
|
||||||
|
|
||||||
|
Now you can build by doing
|
||||||
|
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
../configure
|
||||||
|
make extern
|
||||||
|
make all
|
||||||
|
|
||||||
|
:end:
|
||||||
|
|
||||||
|
And then you can see the =configure= options
|
||||||
|
#+begin_src sh :dir build/tutorial :results raw drawer :eval no
|
||||||
|
../../configure --help
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
** Benches
|
||||||
|
|
||||||
|
The script =tools/configure-benches.sh= can be used to create
|
||||||
|
a couple of configurations for benches:
|
||||||
|
|
||||||
|
#+begin_src sh :exports results :results verbatim org :results verbatim drawer replace output
|
||||||
|
awk '/begin +doc/,/end +doc/ { print $NL }' tools/configure-benches.sh |
|
||||||
|
grep -v -e "begin \+doc" -e "end \+doc" |
|
||||||
|
sed "s/^# //; s/^# *$//; /^$/d"
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
#+RESULTS:
|
||||||
|
:results:
|
||||||
|
- default ::
|
||||||
|
This configuration uses a CPU code with dgemm
|
||||||
|
and without computing slices.
|
||||||
|
- only-dgemm ::
|
||||||
|
This only runs the computation part that involves dgemms.
|
||||||
|
- cuda-only-dgemm ::
|
||||||
|
This is the naive CUDA implementation compiling only the dgemm parts
|
||||||
|
of the compute.
|
||||||
|
- cuda-slices-on-gpu-only-dgemm ::
|
||||||
|
This configuration tests that slices reside completely on the gpu
|
||||||
|
and it should use a CUDA aware MPI implementation.
|
||||||
|
It also only uses the routines that involve dgemm.
|
||||||
|
:end:
|
||||||
|
|
||||||
|
In order to generate the benches just create a suitable directory for it
|
||||||
|
|
||||||
|
#+begin_src sh :eval no
|
||||||
|
mkdir -p build/benches
|
||||||
|
cd buid/benches
|
||||||
|
../../tools/configure-benches.sh CXX=g++ ...
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
and you will get a Makefile together with several project folders.
|
||||||
|
You can either configure all projects with =make all= or
|
||||||
|
then go in each folder.
|
||||||
|
|
||||||
|
Notice that you can give a path for ctf for all of them by doing
|
||||||
|
#+begin_src sh :eval no
|
||||||
|
../../tools/configure-benches.sh --with-ctf=/absolute/path/to/ctf
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
* Running benches
|
||||||
|
|
||||||
|
** Main benchmark
|
||||||
|
|
||||||
|
The main benchmark gets built in =bench/atrip= and is used to run an
|
||||||
|
atrip run with random tensors.
|
||||||
|
|
||||||
|
A common run of this script will be the following
|
||||||
|
|
||||||
|
#+begin_src sh
|
||||||
|
bench/atrip \
|
||||||
|
--no 100 \
|
||||||
|
--nv 1000 \
|
||||||
|
--mod 1 \
|
||||||
|
--% 0 \
|
||||||
|
--dist group \
|
||||||
|
--nocheckpoint \
|
||||||
|
--max-iterations 1000
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
|||||||
@@ -19,10 +19,22 @@ BENCHES_LDADD = $(ATRIP_LIB) $(ATRIP_CTF)
|
|||||||
## main entry point and bench
|
## main entry point and bench
|
||||||
##
|
##
|
||||||
bin_PROGRAMS += atrip
|
bin_PROGRAMS += atrip
|
||||||
atrip_SOURCES = test_main.cxx
|
atrip_SOURCES = main.cxx
|
||||||
atrip_CPPFLAGS = $(AM_CPPFLAGS)
|
atrip_CPPFLAGS = $(AM_CPPFLAGS)
|
||||||
atrip_LDADD = $(BENCHES_LDADD)
|
atrip_LDADD = $(BENCHES_LDADD)
|
||||||
|
|
||||||
|
atrip: main.cxx
|
||||||
|
$(NVCXX) -cuda \
|
||||||
|
-x cu -I../ \
|
||||||
|
$(MPILIBS) \
|
||||||
|
-I$(srcdir)/ \
|
||||||
|
$(AM_CPPFLAGS) \
|
||||||
|
$(DEFS) \
|
||||||
|
$(BENCHES_LDADD) \
|
||||||
|
$(AM_LDFLAGS) \
|
||||||
|
$< -o $@
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
if !WITH_CUDA
|
if !WITH_CUDA
|
||||||
##
|
##
|
||||||
|
|||||||
@@ -5,18 +5,20 @@
|
|||||||
#include <CLI11.hpp>
|
#include <CLI11.hpp>
|
||||||
|
|
||||||
#define _print_size(what, size) \
|
#define _print_size(what, size) \
|
||||||
if (rank == 0) { \
|
do { \
|
||||||
std::cout << #what \
|
if (rank == 0) { \
|
||||||
<< " => " \
|
std::cout << #what \
|
||||||
<< (double)size * elem_to_gb \
|
<< " => " \
|
||||||
<< "GB" \
|
<< (double)size * elem_to_gb \
|
||||||
<< std::endl; \
|
<< "GB" \
|
||||||
}
|
<< std::endl; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
MPI_Init(&argc, &argv);
|
MPI_Init(&argc, &argv);
|
||||||
|
|
||||||
size_t checkpoint_it;
|
size_t checkpoint_it, max_iterations;
|
||||||
int no(10), nv(100), itMod(-1), percentageMod(10);
|
int no(10), nv(100), itMod(-1), percentageMod(10);
|
||||||
float checkpoint_percentage;
|
float checkpoint_percentage;
|
||||||
bool
|
bool
|
||||||
@@ -30,6 +32,9 @@ int main(int argc, char** argv) {
|
|||||||
app.add_option("--no", no, "Occupied orbitals");
|
app.add_option("--no", no, "Occupied orbitals");
|
||||||
app.add_option("--nv", nv, "Virtual orbitals");
|
app.add_option("--nv", nv, "Virtual orbitals");
|
||||||
app.add_option("--mod", itMod, "Iteration modifier");
|
app.add_option("--mod", itMod, "Iteration modifier");
|
||||||
|
app.add_option("--max-iterations",
|
||||||
|
max_iterations,
|
||||||
|
"Maximum number of iterations to run");
|
||||||
app.add_flag("--keep-vppph", keepVppph, "Do not delete Vppph");
|
app.add_flag("--keep-vppph", keepVppph, "Do not delete Vppph");
|
||||||
app.add_flag("--nochrono", nochrono, "Do not print chrono");
|
app.add_flag("--nochrono", nochrono, "Do not print chrono");
|
||||||
app.add_flag("--rank-round-robin", rankRoundRobin, "Do rank round robin");
|
app.add_flag("--rank-round-robin", rankRoundRobin, "Do rank round robin");
|
||||||
@@ -45,14 +50,27 @@ int main(int argc, char** argv) {
|
|||||||
checkpoint_percentage,
|
checkpoint_percentage,
|
||||||
"Percentage for checkpoints");
|
"Percentage for checkpoints");
|
||||||
|
|
||||||
|
// Optional tensor files
|
||||||
|
std::string
|
||||||
|
ei_path, ea_path,
|
||||||
|
Tph_path, Tpphh_path,
|
||||||
|
Vpphh_path, Vhhhp_path, Vppph_path;
|
||||||
|
app.add_option("--ei", ei_path, "Path for ei");
|
||||||
|
app.add_option("--ea", ea_path, "Path for ea");
|
||||||
|
app.add_option("--Tpphh", Tpphh_path, "Path for Tpphh");
|
||||||
|
app.add_option("--Tph", Tph_path, "Path for Tph");
|
||||||
|
app.add_option("--Vpphh", Vpphh_path, "Path for Vpphh");
|
||||||
|
app.add_option("--Vhhhp", Vhhhp_path, "Path for Vhhhp");
|
||||||
|
app.add_option("--Vppph", Vppph_path, "Path for Vppph");
|
||||||
|
|
||||||
#if defined(HAVE_CUDA)
|
#if defined(HAVE_CUDA)
|
||||||
size_t ooo_threads = 0, ooo_blocks = 0;
|
size_t ooo_threads = 0, ooo_blocks = 0;
|
||||||
app.add_option("--ooo-blocks",
|
app.add_option("--ooo-blocks",
|
||||||
ooo_blocks,
|
ooo_blocks,
|
||||||
"CUDA: Number of blocks per block for kernels going through ooo tensors");
|
"CUDA: Number of blocks per block for kernels going through ooo tensors");
|
||||||
app.add_option("--ooo-threads",
|
app.add_option("--ooo-threads",
|
||||||
ooo_threads,
|
ooo_threads,
|
||||||
"CUDA: Number of threads per block for kernels going through ooo tensors");
|
"CUDA: Number of threads per block for kernels going through ooo tensors");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CLI11_PARSE(app, argc, argv);
|
CLI11_PARSE(app, argc, argv);
|
||||||
@@ -148,37 +166,64 @@ int main(int argc, char** argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<int> symmetries(4, NS)
|
std::vector<int>
|
||||||
, vo({nv, no})
|
symmetries(4, NS),
|
||||||
, vvoo({nv, nv, no, no})
|
vo({nv, no}),
|
||||||
, ooov({no, no, no, nv})
|
vvoo({nv, nv, no, no}),
|
||||||
, vvvo({nv, nv, nv, no})
|
ooov({no, no, no, nv}),
|
||||||
;
|
vvvo({nv, nv, nv, no});
|
||||||
|
|
||||||
CTF::Tensor<double>
|
CTF::Tensor<double>
|
||||||
ei(1, ooov.data(), symmetries.data(), world)
|
ei(1, ooov.data(), symmetries.data(), world),
|
||||||
, ea(1, vo.data(), symmetries.data(), world)
|
ea(1, vo.data(), symmetries.data(), world),
|
||||||
, Tph(2, vo.data(), symmetries.data(), world)
|
Tph(2, vo.data(), symmetries.data(), world),
|
||||||
, Tpphh(4, vvoo.data(), symmetries.data(), world)
|
Tpphh(4, vvoo.data(), symmetries.data(), world),
|
||||||
, Vpphh(4, vvoo.data(), symmetries.data(), world)
|
Vpphh(4, vvoo.data(), symmetries.data(), world),
|
||||||
, Vhhhp(4, ooov.data(), symmetries.data(), world)
|
Vhhhp(4, ooov.data(), symmetries.data(), world);
|
||||||
;
|
|
||||||
|
|
||||||
// initialize deletable tensors in heap
|
// initialize deletable tensors in heap
|
||||||
auto Vppph
|
auto Vppph
|
||||||
= new CTF::Tensor<double>(4, vvvo.data(), symmetries.data(), world);
|
= new CTF::Tensor<double>(4, vvvo.data(), symmetries.data(), world);
|
||||||
|
|
||||||
_print_size(Vabci, no*nv*nv*nv)
|
_print_size(Vabci, no*nv*nv*nv);
|
||||||
_print_size(Vabij, no*no*nv*nv)
|
_print_size(Vabij, no*no*nv*nv);
|
||||||
_print_size(Vijka, no*no*no*nv)
|
_print_size(Vijka, no*no*no*nv);
|
||||||
|
|
||||||
ei.fill_random(-40.0, -2);
|
if (ei_path.size()) {
|
||||||
ea.fill_random(2, 50);
|
ei.read_dense_from_file(ei_path.c_str());
|
||||||
Tpphh.fill_random(0, 1);
|
} else {
|
||||||
Tph.fill_random(0, 1);
|
ei.fill_random(-40.0, -2);
|
||||||
Vpphh.fill_random(0, 1);
|
}
|
||||||
Vhhhp.fill_random(0, 1);
|
if (ea_path.size()) {
|
||||||
Vppph->fill_random(0, 1);
|
ea.read_dense_from_file(ea_path.c_str());
|
||||||
|
} else {
|
||||||
|
ea.fill_random(2, 50);
|
||||||
|
}
|
||||||
|
if (Tpphh_path.size()) {
|
||||||
|
Tpphh.read_dense_from_file(Tpphh_path.c_str());
|
||||||
|
} else {
|
||||||
|
Tpphh.fill_random(0, 1);
|
||||||
|
}
|
||||||
|
if (Tph_path.size()) {
|
||||||
|
Tph.read_dense_from_file(Tph_path.c_str());
|
||||||
|
} else {
|
||||||
|
Tph.fill_random(0, 1);
|
||||||
|
}
|
||||||
|
if (Vpphh_path.size()) {
|
||||||
|
Vpphh.read_dense_from_file(Vpphh_path.c_str());
|
||||||
|
} else {
|
||||||
|
Vpphh.fill_random(0, 1);
|
||||||
|
}
|
||||||
|
if (Vhhhp_path.size()) {
|
||||||
|
Vhhhp.read_dense_from_file(Vhhhp_path.c_str());
|
||||||
|
} else {
|
||||||
|
Vhhhp.fill_random(0, 1);
|
||||||
|
}
|
||||||
|
if (Vppph_path.size()) {
|
||||||
|
Vppph->read_dense_from_file(Vppph_path.c_str());
|
||||||
|
} else {
|
||||||
|
Vppph->fill_random(0, 1);
|
||||||
|
}
|
||||||
|
|
||||||
atrip::Atrip::init(MPI_COMM_WORLD);
|
atrip::Atrip::init(MPI_COMM_WORLD);
|
||||||
const auto in
|
const auto in
|
||||||
@@ -199,6 +244,7 @@ int main(int argc, char** argv) {
|
|||||||
.with_iterationMod(itMod)
|
.with_iterationMod(itMod)
|
||||||
.with_percentageMod(percentageMod)
|
.with_percentageMod(percentageMod)
|
||||||
.with_tuplesDistribution(tuplesDistribution)
|
.with_tuplesDistribution(tuplesDistribution)
|
||||||
|
.with_maxIterations(max_iterations)
|
||||||
// checkpoint options
|
// checkpoint options
|
||||||
.with_checkpointAtEveryIteration(checkpoint_it)
|
.with_checkpointAtEveryIteration(checkpoint_it)
|
||||||
.with_checkpointAtPercentage(checkpoint_percentage)
|
.with_checkpointAtPercentage(checkpoint_percentage)
|
||||||
77
configure.ac
77
configure.ac
@@ -21,26 +21,6 @@ AC_ARG_ENABLE(shared,
|
|||||||
files (default=YES)]),
|
files (default=YES)]),
|
||||||
[], [enable_shared=yes])
|
[], [enable_shared=yes])
|
||||||
|
|
||||||
AC_ARG_ENABLE(
|
|
||||||
[slice],
|
|
||||||
[AS_HELP_STRING(
|
|
||||||
[--disable-slice],
|
|
||||||
[Disable the step of slicing tensors for CTF, this is useful for example for benchmarking or testing.])],
|
|
||||||
[atrip_dont_slice=1
|
|
||||||
AC_DEFINE([ATRIP_DONT_SLICE],1,[Wether CTF will slice tensors or skip the step])
|
|
||||||
],
|
|
||||||
[atrip_dont_slice=0]
|
|
||||||
)
|
|
||||||
|
|
||||||
AC_ARG_ENABLE(
|
|
||||||
[atrip_dgemm],
|
|
||||||
[AS_HELP_STRING(
|
|
||||||
[--disable-dgemm],
|
|
||||||
[Disable using dgemm for the doubles equations])],
|
|
||||||
[],
|
|
||||||
[AC_DEFINE([ATRIP_USE_DGEMM],1,[Use dgemm for the doubles equations])]
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
AC_ARG_ENABLE([docs],
|
AC_ARG_ENABLE([docs],
|
||||||
[AS_HELP_STRING([--enable-docs],
|
[AS_HELP_STRING([--enable-docs],
|
||||||
@@ -68,19 +48,60 @@ AM_CONDITIONAL([WITH_CLANG_CHECK], [test x${clang_check} = xYES])
|
|||||||
AC_ARG_ENABLE([cuda],
|
AC_ARG_ENABLE([cuda],
|
||||||
[AS_HELP_STRING([--enable-cuda],
|
[AS_HELP_STRING([--enable-cuda],
|
||||||
[Build with cuda])],
|
[Build with cuda])],
|
||||||
[WITH_CUDA=yes],
|
[WITH_CUDA=yes
|
||||||
[WITH_CUDA=no])
|
WITH_OPENACC=yes],
|
||||||
|
[WITH_CUDA=no])
|
||||||
AC_ARG_VAR([NVCC], [Path to the nvidia cuda compiler.])
|
AC_ARG_VAR([NVCC], [Path to the nvidia cuda compiler.])
|
||||||
AC_ARG_VAR([CUDA_LDFLAGS], [LDFLAGS to find libraries -lcuda, -lcudart, -lcublas.])
|
AC_ARG_VAR([CUDA_LDFLAGS], [LDFLAGS to find libraries -lcuda, -lcudart, -lcublas.])
|
||||||
AC_ARG_VAR([CUDA_CXXFLAGS], [CXXFLAGS to find the CUDA headers])
|
AC_ARG_VAR([CUDA_CXXFLAGS], [CXXFLAGS to find the CUDA headers])
|
||||||
|
|
||||||
|
dnl -----------------------------------------------------------------------
|
||||||
|
dnl ATRIP CPP DEFINES
|
||||||
|
dnl -----------------------------------------------------------------------
|
||||||
|
|
||||||
AC_ARG_WITH([atrip-debug],
|
AC_ARG_WITH([atrip-debug],
|
||||||
[AS_HELP_STRING([--with-atrip-debug],
|
[AS_HELP_STRING([--with-atrip-debug],
|
||||||
[Debug level for atrip, possible values: 1, 2, 3, 4])],
|
[Debug level for atrip, possible values:
|
||||||
|
1, 2, 3, 4])],
|
||||||
[AC_DEFINE([ATRIP_DEBUG],[atrip-debug],[Atrip debug level])],
|
[AC_DEFINE([ATRIP_DEBUG],[atrip-debug],[Atrip debug level])],
|
||||||
[AC_DEFINE([ATRIP_DEBUG],[1],[Atrip debug level])]
|
[AC_DEFINE([ATRIP_DEBUG],[1],[Atrip debug level])])
|
||||||
)
|
|
||||||
|
|
||||||
|
AC_ARG_ENABLE([atrip_dgemm],
|
||||||
|
[AS_HELP_STRING([--disable-dgemm],
|
||||||
|
[Disable using dgemm for the doubles equations])],
|
||||||
|
[],
|
||||||
|
[AC_DEFINE([ATRIP_USE_DGEMM],
|
||||||
|
1,
|
||||||
|
[Use dgemm for the doubles equations])])
|
||||||
|
|
||||||
|
ATRIP_DEF([slice], [disable],
|
||||||
|
[ATRIP_DONT_SLICE],
|
||||||
|
[Disable the step of slicing tensors for CTF, this is useful
|
||||||
|
for example for benchmarking or testing.])
|
||||||
|
|
||||||
|
ATRIP_DEF([only-dgemm], [enable],
|
||||||
|
[ATRIP_ONLY_DGEMM],
|
||||||
|
[Run only the parts of atrip that involve dgemm calls, this
|
||||||
|
is useful for benchmarking and testing the code, it is
|
||||||
|
intended for developers of Atrip.])
|
||||||
|
|
||||||
|
ATRIP_DEF([naive-slow], [enable],
|
||||||
|
[ATRIP_NAIVE_SLOW],
|
||||||
|
[Run slow but correct code for the mapping of (iteration,
|
||||||
|
rank) to tuple of the naive tuple distribution.])
|
||||||
|
|
||||||
|
ATRIP_DEF([sources-in-gpu], [enable],
|
||||||
|
[ATRIP_SOURCES_IN_GPU],
|
||||||
|
[When using CUDA, activate storing all sources (slices of
|
||||||
|
the input tensors) in the GPU. This means that a lot of GPUs
|
||||||
|
will be needed.])
|
||||||
|
|
||||||
|
ATRIP_DEF([cuda-aware-mpi], [enable],
|
||||||
|
[ATRIP_CUDA_AWARE_MPI],
|
||||||
|
[When using MPI, assume support for CUDA aware mpi by the
|
||||||
|
given MPI implementation.])
|
||||||
|
|
||||||
|
|
||||||
dnl -----------------------------------------------------------------------
|
dnl -----------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -144,8 +165,7 @@ AC_TYPE_SIZE_T
|
|||||||
dnl -----------------------------------------------------------------------
|
dnl -----------------------------------------------------------------------
|
||||||
dnl CHECK CTF
|
dnl CHECK CTF
|
||||||
if test xYES = x${BUILD_CTF}; then
|
if test xYES = x${BUILD_CTF}; then
|
||||||
AC_MSG_WARN([Sorry, building CTF not supported yet provide a build path
|
AC_MSG_WARN([You will have to do make ctf before building the project.])
|
||||||
with --with-ctf=path/to/ctf/installation])
|
|
||||||
else
|
else
|
||||||
CPPFLAGS="$CPPFLAGS -I${LIBCTF_CPATH}"
|
CPPFLAGS="$CPPFLAGS -I${LIBCTF_CPATH}"
|
||||||
LDFLAGS="$LDFLAGS -L${LIBCTF_LD_LIBRARY_PATH} -lctf"
|
LDFLAGS="$LDFLAGS -L${LIBCTF_LD_LIBRARY_PATH} -lctf"
|
||||||
@@ -163,6 +183,8 @@ if test x${WITH_CUDA} = xyes; then
|
|||||||
-----------------------
|
-----------------------
|
||||||
])
|
])
|
||||||
AC_CHECK_PROGS([NVCC], [nvcc])
|
AC_CHECK_PROGS([NVCC], [nvcc])
|
||||||
|
AC_CHECK_PROGS([NVCXX], [nvc++])
|
||||||
|
MPILIBS=$($MPICXX -show | awk '!($1="")')
|
||||||
AC_SUBST([CUDA_LDFLAGS])
|
AC_SUBST([CUDA_LDFLAGS])
|
||||||
AC_DEFINE([HAVE_CUDA],1,[Wether we are using CUDA])
|
AC_DEFINE([HAVE_CUDA],1,[Wether we are using CUDA])
|
||||||
# TODO: make sure to find cuda and cudart
|
# TODO: make sure to find cuda and cudart
|
||||||
@@ -208,6 +230,7 @@ AC_MSG_RESULT([
|
|||||||
ATRIP_LDFLAGS = $ATRIP_LDFLAGS
|
ATRIP_LDFLAGS = $ATRIP_LDFLAGS
|
||||||
BLAS = ${BLAS_LIBS}
|
BLAS = ${BLAS_LIBS}
|
||||||
LIBS = ${LIBS}
|
LIBS = ${LIBS}
|
||||||
|
MPILIBS = $MPILIBS
|
||||||
])
|
])
|
||||||
|
|
||||||
AC_OUTPUT
|
AC_OUTPUT
|
||||||
|
|||||||
56
etc/env/raven/cuda
vendored
Normal file
56
etc/env/raven/cuda
vendored
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
mods=(
|
||||||
|
cuda/11.6
|
||||||
|
intel/19.1.2
|
||||||
|
mkl/2020.4
|
||||||
|
impi/2019.8
|
||||||
|
autoconf/2.69
|
||||||
|
automake/1.15
|
||||||
|
libtool/2.4.6
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
module purge
|
||||||
|
module load ${mods[@]}
|
||||||
|
LIB_PATH="${CUDA_HOME}/lib64"
|
||||||
|
export CUDA_ROOT=${CUDA_HOME}
|
||||||
|
export CUDA_LDFLAGS="-L${LIB_PATH} -lcuda -L${LIB_PATH} -lcudart -L${LIB_PATH} -lcublas"
|
||||||
|
export CUDA_CXXFLAGS="-I${CUDA_HOME}/include"
|
||||||
|
|
||||||
|
export LD_LIBRARY_PATH="${MKL_HOME}/lib/intel64_lin:${LD_LIBRARY_PATH}"
|
||||||
|
|
||||||
|
BLAS_STATIC_PATH="$MKL_HOME/lib/intel64/libmkl_intel_lp64.a"
|
||||||
|
|
||||||
|
ls ${LIB_PATH}/libcublas.so
|
||||||
|
ls ${LIB_PATH}/libcudart.so
|
||||||
|
|
||||||
|
cat <<EOF
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
info
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
MKL_HOME = $MKL_HOME
|
||||||
|
BLAS_STATIC_PATH = $BLAS_STATIC_PATH
|
||||||
|
|
||||||
|
CUDA_ROOT = ${CUDA_HOME}
|
||||||
|
CUDA_LDFLAGS = "-L${LIB_PATH} -lcuda -L${LIB_PATH} -lcudart -L${LIB_PATH} -lcublas"
|
||||||
|
CUDA_CXXFLAGS = "-I${CUDA_HOME}/include"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Consider now runnng the following
|
||||||
|
|
||||||
|
../configure \\
|
||||||
|
--enable-cuda \\
|
||||||
|
--disable-slice \\
|
||||||
|
--with-blas="-L\$MKL_HOME/lib/intel64/ -lmkl_intel_lp64 -mkl" \\
|
||||||
|
CXX=mpiicpc \\
|
||||||
|
CC=mpiicc \\
|
||||||
|
MPICXX=mpiicpc
|
||||||
|
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
|
||||||
|
return
|
||||||
82
etc/env/raven/cuda-openacc
vendored
Normal file
82
etc/env/raven/cuda-openacc
vendored
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
mods=(
|
||||||
|
#cuda/11.6
|
||||||
|
nvhpcsdk/22 # for openacc
|
||||||
|
gcc/12
|
||||||
|
openmpi
|
||||||
|
mkl/2020.4
|
||||||
|
autoconf/2.69
|
||||||
|
automake/1.15
|
||||||
|
libtool/2.4.6
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
module purge
|
||||||
|
module load ${mods[@]}
|
||||||
|
|
||||||
|
LIB_PATH="${NVHPC_CUDA_HOME}/lib64"
|
||||||
|
export CUBLAS_LD_PATH="${NVHPC_ROOT}/math_libs/lib64/"
|
||||||
|
export CUDA_ROOT=${CUDA_HOME}
|
||||||
|
export CUDA_LDFLAGS="-L${LIB_PATH} -lcuda -L${LIB_PATH} -lcudart -L${CUBLAS_LD_PATH} -lcublas"
|
||||||
|
export CUDA_CXXFLAGS="-I${CUDA_HOME}/include"
|
||||||
|
|
||||||
|
export LD_LIBRARY_PATH="${MKL_HOME}/lib/intel64:${LD_LIBRARY_PATH}"
|
||||||
|
|
||||||
|
MPILIBS=$(mpicxx -show | awk '!($1="")')
|
||||||
|
export MPILIBS
|
||||||
|
export MPINVCXX="nv++ ${MPILIBS}"
|
||||||
|
|
||||||
|
ls ${CUBLAS_LD_PATH}/libcublas.so
|
||||||
|
ls ${LIB_PATH}/libcudart.so
|
||||||
|
|
||||||
|
#export OMPI_CC="nvc"
|
||||||
|
#export OMPI_CXX="nvc++"
|
||||||
|
|
||||||
|
BLAS_LDFLAGS="-L${PWD}/OpenBLAS-0.3.20/ -lopenblas"
|
||||||
|
_openblas_make () {
|
||||||
|
|
||||||
|
[[ -d OpenBLAS-0.3.20/ ]] || {
|
||||||
|
wget https://github.com/xianyi/OpenBLAS/releases/download/v0.3.20/OpenBLAS-0.3.20.tar.gz
|
||||||
|
tar xvzf OpenBLAS-0.3.20.tar.gz
|
||||||
|
cd OpenBLAS-0.3.20/
|
||||||
|
make FC=gfortran CC=gcc USE_OPENMP=1 NUM_THREADS=72 TARGET=SKYLAKEX
|
||||||
|
} && {
|
||||||
|
echo "Openblas built"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
( _openblas_make; )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
cat <<EOF
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
info
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
MKL_HOME = $MKL_HOME
|
||||||
|
BLAS_STATIC_PATH = $BLAS_STATIC_PATH
|
||||||
|
|
||||||
|
CUDA_ROOT = ${CUDA_HOME}
|
||||||
|
CUDA_LDFLAGS = "-L${LIB_PATH} -lcuda -L${LIB_PATH} -lcudart -L${LIB_PATH} -lcublas"
|
||||||
|
CUDA_CXXFLAGS = "-I${CUDA_HOME}/include"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Consider now runnng the following
|
||||||
|
|
||||||
|
../../configure \\
|
||||||
|
--enable-cuda \\
|
||||||
|
--disable-slice \\
|
||||||
|
--with-blas="${BLAS_LDFLAGS}" \\
|
||||||
|
CXX="gcc" \\
|
||||||
|
NVCC="\$MPINVCXX" \\
|
||||||
|
MPICXX="mpicxx"
|
||||||
|
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
|
||||||
|
return
|
||||||
8
etc/m4/atrip-def.m4
Normal file
8
etc/m4/atrip-def.m4
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
AC_DEFUN([ATRIP_DEF],
|
||||||
|
[AC_ARG_ENABLE([$1],
|
||||||
|
[AS_HELP_STRING([--$2-$1],
|
||||||
|
[$4])],
|
||||||
|
[AC_DEFINE([$3],
|
||||||
|
1,
|
||||||
|
[$4])])])
|
||||||
|
|
||||||
70
etc/m4/atrip_openacc.m4
Normal file
70
etc/m4/atrip_openacc.m4
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
# SYNOPSIS
|
||||||
|
#
|
||||||
|
# ATRIP_OPENACC([ACTION-SUCCESS], [ACTION-FAILURE])
|
||||||
|
#
|
||||||
|
# DESCRIPTION
|
||||||
|
#
|
||||||
|
# Check whether the given the -fopenacc flag works with the current language's compiler
|
||||||
|
# or gives an error.
|
||||||
|
#
|
||||||
|
# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
|
||||||
|
# success/failure.
|
||||||
|
#
|
||||||
|
# LICENSE
|
||||||
|
#
|
||||||
|
# Copyright (c) 2023 Alejandro Gallo <aamsgallo@gmail.com>
|
||||||
|
#
|
||||||
|
# Copying and distribution of this file, with or without modification, are
|
||||||
|
# permitted in any medium without royalty provided the copyright notice
|
||||||
|
# and this notice are preserved. This file is offered as-is, without any
|
||||||
|
# warranty.
|
||||||
|
|
||||||
|
AC_DEFUN([ATRIP_OPENACC],
|
||||||
|
[
|
||||||
|
AC_MSG_CHECKING([that the compiler works with the -fopenacc])
|
||||||
|
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_ATRIP_OPENACC_SOURCE])],
|
||||||
|
[
|
||||||
|
$1
|
||||||
|
AC_MSG_RESULT([yes])
|
||||||
|
],
|
||||||
|
[
|
||||||
|
$2
|
||||||
|
AC_MSG_ERROR([no])
|
||||||
|
])
|
||||||
|
])dnl DEFUN
|
||||||
|
|
||||||
|
m4_define([_ATRIP_OPENACC_SOURCE], [[
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <openacc.h>
|
||||||
|
|
||||||
|
#define SIZE 10
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
float matrix[SIZE * SIZE];
|
||||||
|
float result[SIZE * SIZE];
|
||||||
|
|
||||||
|
// Initialize the matrix with random values
|
||||||
|
for (int i = 0; i < SIZE * SIZE; i++) {
|
||||||
|
matrix[i] = rand() / (float)RAND_MAX;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma acc data \
|
||||||
|
copy(matrix[0:SIZE * SIZE]) \
|
||||||
|
copyout(result[0:SIZE * SIZE])
|
||||||
|
{
|
||||||
|
// Calculate the matrix multiplication
|
||||||
|
#pragma acc parallel loop collapse(2)
|
||||||
|
for (int i = 0; i < SIZE; i++) {
|
||||||
|
for (int j = 0; j < SIZE; j++) {
|
||||||
|
float sum = 0.0f;
|
||||||
|
for (int k = 0; k < SIZE; k++) {
|
||||||
|
sum += matrix[i * SIZE + k] * matrix[j * SIZE + k];
|
||||||
|
}
|
||||||
|
result[i * SIZE + j] = sum;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
]])
|
||||||
@@ -43,7 +43,7 @@
|
|||||||
# and this notice are preserved. This file is offered as-is, without any
|
# and this notice are preserved. This file is offered as-is, without any
|
||||||
# warranty.
|
# warranty.
|
||||||
|
|
||||||
#serial 14
|
#serial 15
|
||||||
|
|
||||||
dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro
|
dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro
|
||||||
dnl (serial version number 13).
|
dnl (serial version number 13).
|
||||||
@@ -189,7 +189,11 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_11], [[
|
|||||||
|
|
||||||
#error "This is not a C++ compiler"
|
#error "This is not a C++ compiler"
|
||||||
|
|
||||||
#elif __cplusplus < 201103L
|
// MSVC always sets __cplusplus to 199711L in older versions; newer versions
|
||||||
|
// only set it correctly if /Zc:__cplusplus is specified as well as a
|
||||||
|
// /std:c++NN switch:
|
||||||
|
// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
|
||||||
|
#elif __cplusplus < 201103L && !defined _MSC_VER
|
||||||
|
|
||||||
#error "This is not a C++11 compiler"
|
#error "This is not a C++11 compiler"
|
||||||
|
|
||||||
@@ -480,7 +484,7 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_14], [[
|
|||||||
|
|
||||||
#error "This is not a C++ compiler"
|
#error "This is not a C++ compiler"
|
||||||
|
|
||||||
#elif __cplusplus < 201402L
|
#elif __cplusplus < 201402L && !defined _MSC_VER
|
||||||
|
|
||||||
#error "This is not a C++14 compiler"
|
#error "This is not a C++14 compiler"
|
||||||
|
|
||||||
@@ -604,7 +608,7 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_17], [[
|
|||||||
|
|
||||||
#error "This is not a C++ compiler"
|
#error "This is not a C++ compiler"
|
||||||
|
|
||||||
#elif __cplusplus < 201703L
|
#elif __cplusplus < 201703L && !defined _MSC_VER
|
||||||
|
|
||||||
#error "This is not a C++17 compiler"
|
#error "This is not a C++17 compiler"
|
||||||
|
|
||||||
@@ -970,7 +974,7 @@ namespace cxx17
|
|||||||
|
|
||||||
} // namespace cxx17
|
} // namespace cxx17
|
||||||
|
|
||||||
#endif // __cplusplus < 201703L
|
#endif // __cplusplus < 201703L && !defined _MSC_VER
|
||||||
|
|
||||||
]])
|
]])
|
||||||
|
|
||||||
@@ -983,7 +987,7 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_20], [[
|
|||||||
|
|
||||||
#error "This is not a C++ compiler"
|
#error "This is not a C++ compiler"
|
||||||
|
|
||||||
#elif __cplusplus < 202002L
|
#elif __cplusplus < 202002L && !defined _MSC_VER
|
||||||
|
|
||||||
#error "This is not a C++20 compiler"
|
#error "This is not a C++20 compiler"
|
||||||
|
|
||||||
@@ -1000,6 +1004,6 @@ namespace cxx20
|
|||||||
|
|
||||||
} // namespace cxx20
|
} // namespace cxx20
|
||||||
|
|
||||||
#endif // __cplusplus < 202002L
|
#endif // __cplusplus < 202002L && !defined _MSC_VER
|
||||||
|
|
||||||
]])
|
]])
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ namespace atrip {
|
|||||||
ADD_ATTRIBUTE(bool, rankRoundRobin, false)
|
ADD_ATTRIBUTE(bool, rankRoundRobin, false)
|
||||||
ADD_ATTRIBUTE(bool, chrono, false)
|
ADD_ATTRIBUTE(bool, chrono, false)
|
||||||
ADD_ATTRIBUTE(bool, barrier, false)
|
ADD_ATTRIBUTE(bool, barrier, false)
|
||||||
ADD_ATTRIBUTE(int, maxIterations, 0)
|
ADD_ATTRIBUTE(size_t, maxIterations, 0)
|
||||||
ADD_ATTRIBUTE(int, iterationMod, -1)
|
ADD_ATTRIBUTE(int, iterationMod, -1)
|
||||||
ADD_ATTRIBUTE(int, percentageMod, -1)
|
ADD_ATTRIBUTE(int, percentageMod, -1)
|
||||||
ADD_ATTRIBUTE(TuplesDistribution, tuplesDistribution, NAIVE)
|
ADD_ATTRIBUTE(TuplesDistribution, tuplesDistribution, NAIVE)
|
||||||
|
|||||||
@@ -18,6 +18,12 @@
|
|||||||
#include <atrip/Slice.hpp>
|
#include <atrip/Slice.hpp>
|
||||||
#include <atrip/RankMap.hpp>
|
#include <atrip/RankMap.hpp>
|
||||||
|
|
||||||
|
#if defined(ATRIP_SOURCES_IN_GPU)
|
||||||
|
# define SOURCES_DATA(s) (s)
|
||||||
|
#else
|
||||||
|
# define SOURCES_DATA(s) (s).data()
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace atrip {
|
namespace atrip {
|
||||||
// Prolog:1 ends here
|
// Prolog:1 ends here
|
||||||
|
|
||||||
@@ -195,7 +201,7 @@ template <typename F=double>
|
|||||||
;
|
;
|
||||||
if (blank.info.state == Slice<F>::SelfSufficient) {
|
if (blank.info.state == Slice<F>::SelfSufficient) {
|
||||||
#if defined(HAVE_CUDA)
|
#if defined(HAVE_CUDA)
|
||||||
const size_t _size = sizeof(F) * sources[from.source].size();
|
const size_t _size = sizeof(F) * sliceSize;
|
||||||
// TODO: this is code duplication with downstairs
|
// TODO: this is code duplication with downstairs
|
||||||
if (freePointers.size() == 0) {
|
if (freePointers.size() == 0) {
|
||||||
std::stringstream stream;
|
std::stringstream stream;
|
||||||
@@ -212,12 +218,12 @@ template <typename F=double>
|
|||||||
WITH_CHRONO("cuda:memcpy:self-sufficient",
|
WITH_CHRONO("cuda:memcpy:self-sufficient",
|
||||||
_CHECK_CUDA_SUCCESS("copying mpi data to device",
|
_CHECK_CUDA_SUCCESS("copying mpi data to device",
|
||||||
cuMemcpyHtoD(blank.data,
|
cuMemcpyHtoD(blank.data,
|
||||||
(void*)sources[from.source].data(),
|
(void*)SOURCES_DATA(sources[from.source]),
|
||||||
sizeof(F) * sources[from.source].size()));
|
sizeof(F) * sliceSize));
|
||||||
))
|
))
|
||||||
|
|
||||||
#else
|
#else
|
||||||
blank.data = sources[from.source].data();
|
blank.data = SOURCES_DATA(sources[from.source]);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
if (freePointers.size() == 0) {
|
if (freePointers.size() == 0) {
|
||||||
@@ -396,15 +402,18 @@ template <typename F=double>
|
|||||||
, world(child_world)
|
, world(child_world)
|
||||||
, universe(global_world)
|
, universe(global_world)
|
||||||
, sliceLength(sliceLength_)
|
, sliceLength(sliceLength_)
|
||||||
|
, sliceSize(std::accumulate(sliceLength.begin(),
|
||||||
|
sliceLength.end(),
|
||||||
|
1UL, std::multiplies<size_t>()))
|
||||||
|
#if defined(ATRIP_SOURCES_IN_GPU)
|
||||||
|
, sources(rankMap.nSources())
|
||||||
|
#else
|
||||||
, sources(rankMap.nSources(),
|
, sources(rankMap.nSources(),
|
||||||
std::vector<F>
|
std::vector<F>(sliceSize))
|
||||||
(std::accumulate(sliceLength.begin(),
|
#endif
|
||||||
sliceLength.end(),
|
|
||||||
1UL, std::multiplies<size_t>())))
|
|
||||||
, name(name_)
|
, name(name_)
|
||||||
, sliceTypes(sliceTypes_)
|
, sliceTypes(sliceTypes_)
|
||||||
, sliceBuffers(nSliceBuffers)
|
, sliceBuffers(nSliceBuffers)
|
||||||
//, slices(2 * sliceTypes.size(), Slice<F>{ sources[0].size() })
|
|
||||||
{ // constructor begin
|
{ // constructor begin
|
||||||
|
|
||||||
LOG(0,"Atrip") << "INIT SliceUnion: " << name << "\n";
|
LOG(0,"Atrip") << "INIT SliceUnion: " << name << "\n";
|
||||||
@@ -412,7 +421,7 @@ template <typename F=double>
|
|||||||
for (auto& ptr: sliceBuffers) {
|
for (auto& ptr: sliceBuffers) {
|
||||||
#if defined(HAVE_CUDA)
|
#if defined(HAVE_CUDA)
|
||||||
const CUresult error =
|
const CUresult error =
|
||||||
cuMemAlloc(&ptr, sizeof(F) * sources[0].size());
|
cuMemAlloc(&ptr, sizeof(F) * sliceSize);
|
||||||
if (ptr == 0UL) {
|
if (ptr == 0UL) {
|
||||||
throw "UNSUFICCIENT MEMORY ON THE GRAPHIC CARD FOR FREE POINTERS";
|
throw "UNSUFICCIENT MEMORY ON THE GRAPHIC CARD FOR FREE POINTERS";
|
||||||
}
|
}
|
||||||
@@ -423,12 +432,12 @@ template <typename F=double>
|
|||||||
throw s.str();
|
throw s.str();
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
ptr = (DataPtr<F>)malloc(sizeof(F) * sources[0].size());
|
ptr = (DataPtr<F>)malloc(sizeof(F) * sliceSize);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
slices
|
slices
|
||||||
= std::vector<Slice<F>>(2 * sliceTypes.size(), { sources[0].size() });
|
= std::vector<Slice<F>>(2 * sliceTypes.size(), { sliceSize });
|
||||||
// TODO: think exactly ^------------------- about this number
|
// TODO: think exactly ^------------------- about this number
|
||||||
|
|
||||||
// initialize the freePointers with the pointers to the buffers
|
// initialize the freePointers with the pointers to the buffers
|
||||||
@@ -441,12 +450,12 @@ template <typename F=double>
|
|||||||
LOG(1,"Atrip") << "#slices " << slices.size() << "\n";
|
LOG(1,"Atrip") << "#slices " << slices.size() << "\n";
|
||||||
WITH_RANK << "#slices[0] " << slices[0].size << "\n";
|
WITH_RANK << "#slices[0] " << slices[0].size << "\n";
|
||||||
LOG(1,"Atrip") << "#sources " << sources.size() << "\n";
|
LOG(1,"Atrip") << "#sources " << sources.size() << "\n";
|
||||||
WITH_RANK << "#sources[0] " << sources[0].size() << "\n";
|
WITH_RANK << "#sources[0] " << sliceSize << "\n";
|
||||||
WITH_RANK << "#freePointers " << freePointers.size() << "\n";
|
WITH_RANK << "#freePointers " << freePointers.size() << "\n";
|
||||||
LOG(1,"Atrip") << "#sliceBuffers " << sliceBuffers.size() << "\n";
|
LOG(1,"Atrip") << "#sliceBuffers " << sliceBuffers.size() << "\n";
|
||||||
LOG(1,"Atrip") << "GB*" << np << " "
|
LOG(1,"Atrip") << "GB*" << np << " "
|
||||||
<< double(sources.size() + sliceBuffers.size())
|
<< double(sources.size() + sliceBuffers.size())
|
||||||
* sources[0].size()
|
* sliceSize
|
||||||
* 8 * np
|
* 8 * np
|
||||||
/ 1073741824.0
|
/ 1073741824.0
|
||||||
<< "\n";
|
<< "\n";
|
||||||
@@ -495,14 +504,13 @@ template <typename F=double>
|
|||||||
if (otherRank == info.from.rank) sendData_p = false;
|
if (otherRank == info.from.rank) sendData_p = false;
|
||||||
if (!sendData_p) return;
|
if (!sendData_p) return;
|
||||||
|
|
||||||
MPI_Isend( sources[info.from.source].data()
|
MPI_Isend((void*)SOURCES_DATA(sources[info.from.source]),
|
||||||
, sources[info.from.source].size()
|
sliceSize,
|
||||||
, traits::mpi::datatypeOf<F>()
|
traits::mpi::datatypeOf<F>(),
|
||||||
, otherRank
|
otherRank,
|
||||||
, tag
|
tag,
|
||||||
, universe
|
universe,
|
||||||
, &request
|
&request);
|
||||||
);
|
|
||||||
WITH_CRAZY_DEBUG
|
WITH_CRAZY_DEBUG
|
||||||
WITH_RANK << "sent to " << otherRank << "\n";
|
WITH_RANK << "sent to " << otherRank << "\n";
|
||||||
|
|
||||||
@@ -516,25 +524,26 @@ template <typename F=double>
|
|||||||
|
|
||||||
if (Atrip::rank == info.from.rank) return;
|
if (Atrip::rank == info.from.rank) return;
|
||||||
|
|
||||||
if (slice.info.state == Slice<F>::Fetch) {
|
if (slice.info.state == Slice<F>::Fetch) { // if-1
|
||||||
// TODO: do it through the slice class
|
// TODO: do it through the slice class
|
||||||
slice.info.state = Slice<F>::Dispatched;
|
slice.info.state = Slice<F>::Dispatched;
|
||||||
#if defined(HAVE_CUDA)
|
#if defined(HAVE_CUDA)
|
||||||
|
# if !defined(ATRIP_CUDA_AWARE_MPI) && defined(ATRIP_SOURCES_IN_GPU)
|
||||||
|
# error "You need CUDA aware MPI to have slices on the GPU"
|
||||||
|
# endif
|
||||||
slice.mpi_data = (F*)malloc(sizeof(F) * slice.size);
|
slice.mpi_data = (F*)malloc(sizeof(F) * slice.size);
|
||||||
MPI_Irecv( slice.mpi_data
|
MPI_Irecv(slice.mpi_data,
|
||||||
#else
|
#else
|
||||||
MPI_Irecv( slice.data
|
MPI_Irecv(slice.data,
|
||||||
#endif
|
#endif
|
||||||
, slice.size
|
slice.size,
|
||||||
, traits::mpi::datatypeOf<F>()
|
traits::mpi::datatypeOf<F>(),
|
||||||
, info.from.rank
|
info.from.rank,
|
||||||
, tag
|
tag,
|
||||||
, universe
|
universe,
|
||||||
, &slice.request
|
&slice.request);
|
||||||
//, MPI_STATUS_IGNORE
|
} // if-1
|
||||||
);
|
} // receive
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void unwrapAll(ABCTuple const& abc) {
|
void unwrapAll(ABCTuple const& abc) {
|
||||||
for (auto type: sliceTypes) unwrapSlice(type, abc);
|
for (auto type: sliceTypes) unwrapSlice(type, abc);
|
||||||
@@ -597,7 +606,12 @@ template <typename F=double>
|
|||||||
const MPI_Comm world;
|
const MPI_Comm world;
|
||||||
const MPI_Comm universe;
|
const MPI_Comm universe;
|
||||||
const std::vector<size_t> sliceLength;
|
const std::vector<size_t> sliceLength;
|
||||||
|
const size_t sliceSize;
|
||||||
|
#if defined(ATRIP_SOURCES_IN_GPU)
|
||||||
|
std::vector< DataPtr<F> > sources;
|
||||||
|
#else
|
||||||
std::vector< std::vector<F> > sources;
|
std::vector< std::vector<F> > sources;
|
||||||
|
#endif
|
||||||
std::vector< Slice<F> > slices;
|
std::vector< Slice<F> > slices;
|
||||||
typename Slice<F>::Name name;
|
typename Slice<F>::Name name;
|
||||||
const std::vector<typename Slice<F>::Type> sliceTypes;
|
const std::vector<typename Slice<F>::Type> sliceTypes;
|
||||||
|
|||||||
@@ -19,8 +19,14 @@
|
|||||||
namespace atrip {
|
namespace atrip {
|
||||||
|
|
||||||
template <typename F=double>
|
template <typename F=double>
|
||||||
|
static
|
||||||
void sliceIntoVector
|
void sliceIntoVector
|
||||||
( std::vector<F> &v
|
#if defined(ATRIP_SOURCES_IN_GPU)
|
||||||
|
( DataPtr<F> &source
|
||||||
|
#else
|
||||||
|
( std::vector<F> &source
|
||||||
|
#endif
|
||||||
|
, size_t sliceSize
|
||||||
, CTF::Tensor<F> &toSlice
|
, CTF::Tensor<F> &toSlice
|
||||||
, std::vector<int64_t> const low
|
, std::vector<int64_t> const low
|
||||||
, std::vector<int64_t> const up
|
, std::vector<int64_t> const up
|
||||||
@@ -44,18 +50,30 @@ namespace atrip {
|
|||||||
<< "\n";
|
<< "\n";
|
||||||
|
|
||||||
#ifndef ATRIP_DONT_SLICE
|
#ifndef ATRIP_DONT_SLICE
|
||||||
toSlice.slice( toSlice_.low.data()
|
toSlice.slice(toSlice_.low.data(),
|
||||||
, toSlice_.up.data()
|
toSlice_.up.data(),
|
||||||
, 0.0
|
0.0,
|
||||||
, origin
|
origin,
|
||||||
, origin_.low.data()
|
origin_.low.data(),
|
||||||
, origin_.up.data()
|
origin_.up.data(),
|
||||||
, 1.0);
|
1.0);
|
||||||
memcpy(v.data(), toSlice.data, sizeof(F) * v.size());
|
|
||||||
#else
|
#else
|
||||||
# pragma message("WARNING: COMPILING WITHOUT SLICING THE TENSORS")
|
# pragma message("WARNING: COMPILING WITHOUT SLICING THE TENSORS")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(ATRIP_SOURCES_IN_GPU)
|
||||||
|
WITH_CHRONO("cuda:sources",
|
||||||
|
_CHECK_CUDA_SUCCESS("copying sources data to device",
|
||||||
|
cuMemcpyHtoD(source,
|
||||||
|
toSlice.data,
|
||||||
|
sliceSize));
|
||||||
|
)
|
||||||
|
#else
|
||||||
|
memcpy(source.data(),
|
||||||
|
toSlice.data,
|
||||||
|
sizeof(F) * sliceSize);
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -80,16 +98,15 @@ namespace atrip {
|
|||||||
|
|
||||||
void sliceIntoBuffer(size_t it, CTF::Tensor<F> &to, CTF::Tensor<F> const& from) override
|
void sliceIntoBuffer(size_t it, CTF::Tensor<F> &to, CTF::Tensor<F> const& from) override
|
||||||
{
|
{
|
||||||
const int Nv = this->sliceLength[0]
|
|
||||||
, No = this->sliceLength[1]
|
|
||||||
, a = this->rankMap.find({static_cast<size_t>(Atrip::rank), it});
|
|
||||||
;
|
|
||||||
|
|
||||||
|
const int
|
||||||
|
Nv = this->sliceLength[0],
|
||||||
|
No = this->sliceLength[1],
|
||||||
|
a = this->rankMap.find({static_cast<size_t>(Atrip::rank), it});
|
||||||
|
|
||||||
sliceIntoVector<F>( this->sources[it]
|
sliceIntoVector<F>(this->sources[it], this->sliceSize,
|
||||||
, to, {0, 0, 0}, {Nv, No, No}
|
to, {0, 0, 0}, {Nv, No, No},
|
||||||
, from, {a, 0, 0, 0}, {a+1, Nv, No, No}
|
from, {a, 0, 0, 0}, {a+1, Nv, No, No});
|
||||||
);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,14 +135,13 @@ namespace atrip {
|
|||||||
void sliceIntoBuffer(size_t it, CTF::Tensor<F> &to, CTF::Tensor<F> const& from) override
|
void sliceIntoBuffer(size_t it, CTF::Tensor<F> &to, CTF::Tensor<F> const& from) override
|
||||||
{
|
{
|
||||||
|
|
||||||
const int No = this->sliceLength[0]
|
const int
|
||||||
, a = this->rankMap.find({static_cast<size_t>(Atrip::rank), it})
|
No = this->sliceLength[0],
|
||||||
;
|
a = this->rankMap.find({static_cast<size_t>(Atrip::rank), it});
|
||||||
|
|
||||||
sliceIntoVector<F>( this->sources[it]
|
sliceIntoVector<F>(this->sources[it], this->sliceSize,
|
||||||
, to, {0, 0, 0}, {No, No, No}
|
to, {0, 0, 0}, {No, No, No},
|
||||||
, from, {0, 0, 0, a}, {No, No, No, a+1}
|
from, {0, 0, 0, a}, {No, No, No, a+1});
|
||||||
);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -153,18 +169,17 @@ namespace atrip {
|
|||||||
|
|
||||||
void sliceIntoBuffer(size_t it, CTF::Tensor<F> &to, CTF::Tensor<F> const& from) override {
|
void sliceIntoBuffer(size_t it, CTF::Tensor<F> &to, CTF::Tensor<F> const& from) override {
|
||||||
|
|
||||||
const int Nv = this->sliceLength[0]
|
const int
|
||||||
, No = this->sliceLength[1]
|
Nv = this->sliceLength[0],
|
||||||
, el = this->rankMap.find({static_cast<size_t>(Atrip::rank), it})
|
No = this->sliceLength[1],
|
||||||
, a = el % Nv
|
el = this->rankMap.find({static_cast<size_t>(Atrip::rank), it}),
|
||||||
, b = el / Nv
|
a = el % Nv,
|
||||||
;
|
b = el / Nv;
|
||||||
|
|
||||||
|
|
||||||
sliceIntoVector<F>( this->sources[it]
|
sliceIntoVector<F>(this->sources[it], this->sliceSize,
|
||||||
, to, {0, 0}, {Nv, No}
|
to, {0, 0}, {Nv, No},
|
||||||
, from, {a, b, 0, 0}, {a+1, b+1, Nv, No}
|
from, {a, b, 0, 0}, {a+1, b+1, Nv, No});
|
||||||
);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,17 +206,17 @@ namespace atrip {
|
|||||||
|
|
||||||
void sliceIntoBuffer(size_t it, CTF::Tensor<F> &to, CTF::Tensor<F> const& from) override {
|
void sliceIntoBuffer(size_t it, CTF::Tensor<F> &to, CTF::Tensor<F> const& from) override {
|
||||||
|
|
||||||
const int Nv = from.lens[0]
|
const int
|
||||||
, No = this->sliceLength[1]
|
Nv = from.lens[0],
|
||||||
, el = this->rankMap.find({static_cast<size_t>(Atrip::rank), it})
|
No = this->sliceLength[1],
|
||||||
, a = el % Nv
|
el = this->rankMap.find({static_cast<size_t>(Atrip::rank), it}),
|
||||||
, b = el / Nv
|
a = el % Nv,
|
||||||
;
|
b = el / Nv;
|
||||||
|
|
||||||
sliceIntoVector<F>( this->sources[it]
|
|
||||||
, to, {0, 0}, {No, No}
|
sliceIntoVector<F>(this->sources[it], this->sliceSize,
|
||||||
, from, {a, b, 0, 0}, {a+1, b+1, No, No}
|
to, {0, 0}, {No, No},
|
||||||
);
|
from, {a, b, 0, 0}, {a+1, b+1, No, No});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -231,17 +246,16 @@ namespace atrip {
|
|||||||
void sliceIntoBuffer(size_t it, CTF::Tensor<F> &to, CTF::Tensor<F> const& from) override {
|
void sliceIntoBuffer(size_t it, CTF::Tensor<F> &to, CTF::Tensor<F> const& from) override {
|
||||||
// TODO: maybe generalize this with ABHH
|
// TODO: maybe generalize this with ABHH
|
||||||
|
|
||||||
const int Nv = from.lens[0]
|
const int
|
||||||
, No = this->sliceLength[1]
|
Nv = from.lens[0],
|
||||||
, el = this->rankMap.find({static_cast<size_t>(Atrip::rank), it})
|
No = this->sliceLength[1],
|
||||||
, a = el % Nv
|
el = this->rankMap.find({static_cast<size_t>(Atrip::rank), it}),
|
||||||
, b = el / Nv
|
a = el % Nv,
|
||||||
;
|
b = el / Nv;
|
||||||
|
|
||||||
sliceIntoVector<F>( this->sources[it]
|
sliceIntoVector<F>(this->sources[it], this->sliceSize,
|
||||||
, to, {0, 0}, {No, No}
|
to, {0, 0}, {No, No},
|
||||||
, from, {a, b, 0, 0}, {a+1, b+1, No, No}
|
from, {a, b, 0, 0}, {a+1, b+1, No, No});
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,11 @@
|
|||||||
|
#+quicklisp
|
||||||
|
(eval-when (:compile-toplevel :load-toplevel :execute)
|
||||||
|
(ql:quickload '(vgplot fiveam)))
|
||||||
|
|
||||||
|
(defpackage :naive-tuples
|
||||||
|
(:use :cl :vgplot))
|
||||||
|
(in-package :naive-tuples)
|
||||||
|
|
||||||
(defun tuples-atrip (nv)
|
(defun tuples-atrip (nv)
|
||||||
(declare (optimize (speed 3) (safety 0) (debug 0)))
|
(declare (optimize (speed 3) (safety 0) (debug 0)))
|
||||||
(loop :for a :below nv
|
(loop :for a :below nv
|
||||||
@@ -218,58 +226,3 @@
|
|||||||
cheaper
|
cheaper
|
||||||
(print (equal (nth i tuples)
|
(print (equal (nth i tuples)
|
||||||
cheaper)))))
|
cheaper)))))
|
||||||
|
|
||||||
(let* ((l 101)
|
|
||||||
(tuples (tuples-atrip l)))
|
|
||||||
(loop :for a below l
|
|
||||||
:do (print (let ((s (a-block-atrip a l))
|
|
||||||
(c (count-if (lambda (x) (eq (car x) a))
|
|
||||||
tuples)))
|
|
||||||
(list :a a
|
|
||||||
:size s
|
|
||||||
:real c
|
|
||||||
:? (eq c s))))))
|
|
||||||
|
|
||||||
(ql:quickload 'vgplot)
|
|
||||||
(import 'vgplot:plot)
|
|
||||||
(import 'vgplot:replot)
|
|
||||||
|
|
||||||
(let ((l 10))
|
|
||||||
(plot (mapcar (lambda (x) (getf x :size))
|
|
||||||
(loop :for a upto l
|
|
||||||
collect (list :a a :size (a-block a l))))
|
|
||||||
"penis"))
|
|
||||||
|
|
||||||
(let* ((l 50)
|
|
||||||
(tuples (tuples-half l)))
|
|
||||||
(loop :for a below l
|
|
||||||
:do (print (let ((s (a-block a l))
|
|
||||||
(c (count-if (lambda (x) (eq (car x) a))
|
|
||||||
tuples)))
|
|
||||||
(list :a a
|
|
||||||
:size s
|
|
||||||
:real c
|
|
||||||
:? (eq c s))))))
|
|
||||||
|
|
||||||
(defun range (from to) (loop for i :from from :to to collect i))
|
|
||||||
|
|
||||||
(defun half-again (i nv)
|
|
||||||
(let ((a-block-list (let ((ll (mapcar (lambda (i) (a-block i nv))
|
|
||||||
(range 0 (- nv 1)))))
|
|
||||||
(loop :for i :from 1 :to (length ll)
|
|
||||||
:collect
|
|
||||||
(reduce #'+
|
|
||||||
ll
|
|
||||||
:end i)))))
|
|
||||||
(loop :for blk :in a-block-list
|
|
||||||
:with a = 0
|
|
||||||
:with total-blk = 0
|
|
||||||
:if (eq 0 (floor i blk))
|
|
||||||
:do
|
|
||||||
(let ((i (mod i blk)))
|
|
||||||
(print (list i (- i total-blk) blk a))
|
|
||||||
(return))
|
|
||||||
:else
|
|
||||||
:do (progn
|
|
||||||
(incf a)
|
|
||||||
(setq total-blk blk)))))
|
|
||||||
|
|||||||
@@ -7,16 +7,17 @@ AM_CPPFLAGS = $(CTF_CPPFLAGS)
|
|||||||
lib_LIBRARIES = libatrip.a
|
lib_LIBRARIES = libatrip.a
|
||||||
|
|
||||||
libatrip_a_CPPFLAGS = -I$(top_srcdir)/include/
|
libatrip_a_CPPFLAGS = -I$(top_srcdir)/include/
|
||||||
libatrip_a_SOURCES = ./atrip/Blas.cxx ./atrip/Tuples.cxx ./atrip/DatabaseCommunicator.cxx
|
libatrip_a_SOURCES =
|
||||||
NVCC_FILES = ./atrip/Equations.cxx ./atrip/Complex.cxx ./atrip/Atrip.cxx
|
NVCC_FILES = ./atrip/Equations.cxx ./atrip/Complex.cxx ./atrip/Atrip.cxx
|
||||||
|
NVCC_FILES += ./atrip/Blas.cxx ./atrip/Tuples.cxx ./atrip/DatabaseCommunicator.cxx
|
||||||
if WITH_CUDA
|
if WITH_CUDA
|
||||||
NVCC_OBJS = $(patsubst %.cxx,%.nvcc.o,$(NVCC_FILES))
|
NVCC_OBJS = $(patsubst %.cxx,%.nvcc.o,$(NVCC_FILES))
|
||||||
libatrip_a_CPPFLAGS += $(CUDA_CXXFLAGS)
|
libatrip_a_CPPFLAGS += $(CUDA_CXXFLAGS)
|
||||||
libatrip_a_DEPENDENCIES = $(NVCC_OBJS)
|
libatrip_a_DEPENDENCIES = $(NVCC_OBJS)
|
||||||
libatrip_a_LIBADD = $(NVCC_OBJS)
|
libatrip_a_LIBADD = $(NVCC_OBJS)
|
||||||
%.nvcc.o: %.cxx
|
%.nvcc.o: %.cxx
|
||||||
$(NVCC) -c -x cu -ccbin="${MPICXX}" -I../ $(CPPFLAGS) $(CTF_CPPFLAGS) $(DEFS) $(libatrip_a_CPPFLAGS) $< -o $@
|
##$(NVCC) -c -x cu -ccbin="${MPICXX}" -I../ $(CPPFLAGS) $(CTF_CPPFLAGS) $(DEFS) $(libatrip_a_CPPFLAGS) $< -o $@
|
||||||
|
$(NVCXX) -cuda $(MPILIBS) -c -x cu -I../ $(CPPFLAGS) $(CTF_CPPFLAGS) $(DEFS) $(libatrip_a_CPPFLAGS) $< -o $@
|
||||||
|
|
||||||
#./atrip/Equations.o: ./atrip/Equations.cxx
|
#./atrip/Equations.o: ./atrip/Equations.cxx
|
||||||
# $(NVCC) -c -I../ $(CPPFLAGS) $(libatrip_a_CPPFLAGS) $< -o $@
|
# $(NVCC) -c -I../ $(CPPFLAGS) $(libatrip_a_CPPFLAGS) $< -o $@
|
||||||
|
|||||||
@@ -646,6 +646,9 @@ Atrip::Output Atrip::run(Atrip::Input<F> const& in) {
|
|||||||
|
|
||||||
// COMPUTE SINGLES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% {{{1
|
// COMPUTE SINGLES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% {{{1
|
||||||
OCD_Barrier(universe);
|
OCD_Barrier(universe);
|
||||||
|
#if defined(ATRIP_ONLY_DGEMM)
|
||||||
|
if (false)
|
||||||
|
#endif
|
||||||
if (!isFakeTuple(i)) {
|
if (!isFakeTuple(i)) {
|
||||||
WITH_CHRONO("oneshot-unwrap",
|
WITH_CHRONO("oneshot-unwrap",
|
||||||
WITH_CHRONO("unwrap",
|
WITH_CHRONO("unwrap",
|
||||||
@@ -678,6 +681,9 @@ Atrip::Output Atrip::run(Atrip::Input<F> const& in) {
|
|||||||
|
|
||||||
|
|
||||||
// COMPUTE ENERGY %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% {{{1
|
// COMPUTE ENERGY %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% {{{1
|
||||||
|
#if defined(ATRIP_ONLY_DGEMM)
|
||||||
|
if (false)
|
||||||
|
#endif
|
||||||
if (!isFakeTuple(i)) {
|
if (!isFakeTuple(i)) {
|
||||||
double tupleEnergy(0.);
|
double tupleEnergy(0.);
|
||||||
|
|
||||||
@@ -688,13 +694,10 @@ Atrip::Output Atrip::run(Atrip::Input<F> const& in) {
|
|||||||
|
|
||||||
// LOG(0, "AtripCUDA") << "doing energy " << i << "distinct " << distinct << "\n";
|
// LOG(0, "AtripCUDA") << "doing energy " << i << "distinct " << distinct << "\n";
|
||||||
WITH_CHRONO("energy",
|
WITH_CHRONO("energy",
|
||||||
/*
|
|
||||||
TODO: think about how to do this on the GPU in the best way possible
|
|
||||||
if ( distinct == 0)
|
if ( distinct == 0)
|
||||||
tupleEnergy = getEnergyDistinct<F>(epsabc, No, (F*)epsi, (F*)Tijk, (F*)Zijk);
|
tupleEnergy = getEnergyDistinct<F>(epsabc, No, (F*)epsi, (F*)Tijk, (F*)Zijk);
|
||||||
else
|
else
|
||||||
tupleEnergy = getEnergySame<F>(epsabc, No, (F*)epsi, (F*)Tijk, (F*)Zijk);
|
tupleEnergy = getEnergySame<F>(epsabc, No, (F*)epsi, (F*)Tijk, (F*)Zijk);
|
||||||
*/
|
|
||||||
)
|
)
|
||||||
|
|
||||||
#if defined(HAVE_OCD) || defined(ATRIP_PRINT_TUPLES)
|
#if defined(HAVE_OCD) || defined(ATRIP_PRINT_TUPLES)
|
||||||
@@ -767,6 +770,8 @@ Atrip::Output Atrip::run(Atrip::Input<F> const& in) {
|
|||||||
Atrip::chrono["iterations"].stop();
|
Atrip::chrono["iterations"].stop();
|
||||||
// ITERATION END %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%{{{1
|
// ITERATION END %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%{{{1
|
||||||
|
|
||||||
|
if (in.maxIterations != 0 && i >= in.maxIterations) break;
|
||||||
|
|
||||||
}
|
}
|
||||||
// END OF MAIN LOOP
|
// END OF MAIN LOOP
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,10 @@
|
|||||||
|
|
||||||
namespace atrip {
|
namespace atrip {
|
||||||
|
|
||||||
/* This function is really too slow, below are more performant
|
#if defined(ATRIP_NAIVE_SLOW)
|
||||||
functions to get tuples.
|
/*
|
||||||
|
* This function is really too slow, below are more performant
|
||||||
|
* functions to get tuples.
|
||||||
*/
|
*/
|
||||||
static
|
static
|
||||||
ABCTuples get_nth_naive_tuples(size_t Nv, size_t np, int64_t i) {
|
ABCTuples get_nth_naive_tuples(size_t Nv, size_t np, int64_t i) {
|
||||||
@@ -52,33 +54,26 @@ namespace atrip {
|
|||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
static
|
|
||||||
inline
|
|
||||||
size_t a_block_atrip(size_t a, size_t nv) {
|
|
||||||
return (nv - 1) * (nv - (a - 1))
|
|
||||||
- ((nv - 1) * nv) / 2
|
|
||||||
+ ((a - 1) * (a - 2)) / 2
|
|
||||||
- 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static
|
static
|
||||||
inline
|
inline
|
||||||
size_t a_block_sum_atrip(int64_t T, int64_t nv) {
|
size_t a_block_sum_atrip(int64_t T, int64_t nv) {
|
||||||
int64_t nv1 = nv - 1, tplus1 = T + 1;
|
const int64_t nv_min_1 = nv - 1, t_plus_1 = T + 1;
|
||||||
return tplus1 * nv1 * nv
|
return t_plus_1 * nv_min_1 * nv
|
||||||
+ nv1 * tplus1
|
+ nv_min_1 * t_plus_1
|
||||||
- (nv1 * (T * (T + 1)) / 2)
|
- (nv_min_1 * (T * t_plus_1) / 2)
|
||||||
- (tplus1 * (nv1 * nv) / 2)
|
- (t_plus_1 * (nv_min_1 * nv) / 2)
|
||||||
+ (((T * (T + 1) * (1 + 2 * T)) / 6) - 3 * ((T * (T + 1)) / 2)) / 2
|
// do not simplify this expression, only the addition of both parts
|
||||||
|
// is a pair integer, prepare to endure the consequences of
|
||||||
|
// simplifying otherwise
|
||||||
|
+ (((T * t_plus_1 * (1 + 2 * T)) / 6) - 3 * ((T * t_plus_1) / 2)) / 2
|
||||||
;
|
;
|
||||||
// + tplus1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
inline
|
inline
|
||||||
int64_t b_block_sum_atrip (int64_t a, int64_t T, int64_t nv) {
|
int64_t b_block_sum_atrip (int64_t a, int64_t T, int64_t nv) {
|
||||||
|
|
||||||
return nv * ((T - a) + 1)
|
return nv * ((T - a) + 1)
|
||||||
- (T * (T + 1) - a * (a - 1)) / 2
|
- (T * (T + 1) - a * (a - 1)) / 2
|
||||||
- 1;
|
- 1;
|
||||||
@@ -94,9 +89,6 @@ namespace atrip {
|
|||||||
a_sums.resize(nv);
|
a_sums.resize(nv);
|
||||||
for (size_t _i = 0; _i < nv; _i++) {
|
for (size_t _i = 0; _i < nv; _i++) {
|
||||||
a_sums[_i] = a_block_sum_atrip(_i, nv);
|
a_sums[_i] = a_block_sum_atrip(_i, nv);
|
||||||
/*
|
|
||||||
std::cout << Atrip::rank << ": " << _i << " " << a_sums[_i] << std::endl;
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,10 +106,6 @@ namespace atrip {
|
|||||||
std::vector<int64_t> b_sums(nv - a);
|
std::vector<int64_t> b_sums(nv - a);
|
||||||
for (size_t t = a, i=0; t < nv; t++) {
|
for (size_t t = a, i=0; t < nv; t++) {
|
||||||
b_sums[i++] = b_block_sum_atrip(a, t, nv);
|
b_sums[i++] = b_block_sum_atrip(a, t, nv);
|
||||||
/*
|
|
||||||
std::cout << Atrip::rank << ": b-sum " << i-1 << " "
|
|
||||||
<< ":a " << a << " :t " << t << " = " << b_sums[i-1] << std::endl;
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
int64_t b = a - 1, block_b = block_a;
|
int64_t b = a - 1, block_b = block_a;
|
||||||
for (const auto& sum: b_sums) {
|
for (const auto& sum: b_sums) {
|
||||||
@@ -141,6 +129,11 @@ namespace atrip {
|
|||||||
inline
|
inline
|
||||||
ABCTuples nth_atrip_distributed(int64_t it, size_t nv, size_t np) {
|
ABCTuples nth_atrip_distributed(int64_t it, size_t nv, size_t np) {
|
||||||
|
|
||||||
|
// If we are getting the previous tuples in the first iteration,
|
||||||
|
// then just return an impossible tuple, different from the FAKE_TUPLE,
|
||||||
|
// because if FAKE_TUPLE is defined as {0,0,0} slices thereof
|
||||||
|
// are actually attainable.
|
||||||
|
//
|
||||||
if (it < 0) {
|
if (it < 0) {
|
||||||
ABCTuples result(np, {nv, nv, nv});
|
ABCTuples result(np, {nv, nv, nv});
|
||||||
return result;
|
return result;
|
||||||
@@ -160,9 +153,6 @@ namespace atrip {
|
|||||||
for (size_t rank = 0; rank < np; rank++) {
|
for (size_t rank = 0; rank < np; rank++) {
|
||||||
const size_t
|
const size_t
|
||||||
global_iteration = tuples_per_rank * rank + it;
|
global_iteration = tuples_per_rank * rank + it;
|
||||||
/*
|
|
||||||
std::cout << Atrip::rank << ":" << "global_bit " << global_iteration << "\n";
|
|
||||||
*/
|
|
||||||
result[rank] = nth_atrip(global_iteration, nv);
|
result[rank] = nth_atrip(global_iteration, nv);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -248,38 +238,25 @@ namespace atrip {
|
|||||||
using Database = typename Slice<F>::Database;
|
using Database = typename Slice<F>::Database;
|
||||||
Database db;
|
Database db;
|
||||||
|
|
||||||
#ifdef NAIVE_SLOW
|
#ifdef ATRIP_NAIVE_SLOW
|
||||||
WITH_CHRONO("db:comm:naive:tuples",
|
WITH_CHRONO("db:comm:naive:tuples",
|
||||||
const auto tuples = get_nth_naive_tuples(nv,
|
const auto tuples = get_nth_naive_tuples(nv,
|
||||||
np,
|
np,
|
||||||
iteration);
|
iteration);
|
||||||
const auto prev_tuples = get_nth_naive_tuples(nv,
|
const auto prev_tuples = get_nth_naive_tuples(nv,
|
||||||
np,
|
np,
|
||||||
(int64_t)iteration - 1);
|
iteration - 1);
|
||||||
)
|
)
|
||||||
#else
|
#else
|
||||||
WITH_CHRONO("db:comm:naive:tuples",
|
WITH_CHRONO("db:comm:naive:tuples",
|
||||||
const auto tuples = nth_atrip_distributed((int64_t)iteration,
|
const auto tuples = nth_atrip_distributed(iteration,
|
||||||
nv,
|
nv,
|
||||||
np);
|
np);
|
||||||
const auto prev_tuples = nth_atrip_distributed((int64_t)iteration - 1,
|
const auto prev_tuples = nth_atrip_distributed(iteration - 1,
|
||||||
nv,
|
nv,
|
||||||
np);
|
np);
|
||||||
)
|
)
|
||||||
|
|
||||||
if (false)
|
|
||||||
for (size_t rank = 0; rank < np; rank++) {
|
|
||||||
std::cout << Atrip::rank << ":"
|
|
||||||
<< " :tuples< " << rank << ">" << iteration
|
|
||||||
<< " :abc " << tuples[rank][0]
|
|
||||||
<< ", " << tuples[rank][1]
|
|
||||||
<< ", " << tuples[rank][2] << "\n";
|
|
||||||
std::cout << Atrip::rank << ":"
|
|
||||||
<< " :prev-tuples< " << rank << ">" << iteration
|
|
||||||
<< " :abc-prev " << prev_tuples[rank][0]
|
|
||||||
<< ", " << prev_tuples[rank][1]
|
|
||||||
<< ", " << prev_tuples[rank][2] << "\n";
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (size_t rank = 0; rank < np; rank++) {
|
for (size_t rank = 0; rank < np; rank++) {
|
||||||
|
|||||||
@@ -151,12 +151,11 @@ namespace cuda {
|
|||||||
KJI
|
KJI
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Please the c++ type checker and template creator
|
* Please the c++ type checker and template creator
|
||||||
* in order to have an argument in the signature of
|
* in order to have an argument in the signature of
|
||||||
* the function that helps the compiler know which
|
* the function that helps the compiler know which
|
||||||
* instantiation it should take.
|
* instantiation it should take.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
template <typename F, reordering_t R>
|
template <typename F, reordering_t R>
|
||||||
struct reorder_proxy {};
|
struct reorder_proxy {};
|
||||||
@@ -183,15 +182,21 @@ namespace cuda {
|
|||||||
|
|
||||||
// [[file:~/cuda/atrip/atrip.org::*Energy][Energy:2]]
|
// [[file:~/cuda/atrip/atrip.org::*Energy][Energy:2]]
|
||||||
template <typename F>
|
template <typename F>
|
||||||
|
__MAYBE_DEVICE__
|
||||||
double getEnergyDistinct
|
double getEnergyDistinct
|
||||||
( F const epsabc
|
(F const epsabc,
|
||||||
, size_t const No
|
size_t const No,
|
||||||
, F* const epsi
|
F* const epsi,
|
||||||
, F* const Tijk
|
F* const Tijk,
|
||||||
, F* const Zijk
|
F* const Zijk) {
|
||||||
) {
|
|
||||||
constexpr size_t blockSize=16;
|
constexpr size_t blockSize=16;
|
||||||
F energy(0.);
|
F energy(0.);
|
||||||
|
#if defined(HAVE_CUDA)
|
||||||
|
#pragma acc kernels
|
||||||
|
for (size_t k(0); k < No; k++) {
|
||||||
|
for (size_t j(k); j < No; j++) {
|
||||||
|
for (size_t i(j); i < No; i++) {
|
||||||
|
#else
|
||||||
for (size_t kk=0; kk<No; kk+=blockSize){
|
for (size_t kk=0; kk<No; kk+=blockSize){
|
||||||
const size_t kend( std::min(No, kk+blockSize) );
|
const size_t kend( std::min(No, kk+blockSize) );
|
||||||
for (size_t jj(kk); jj<No; jj+=blockSize){
|
for (size_t jj(kk); jj<No; jj+=blockSize){
|
||||||
@@ -199,13 +204,14 @@ double getEnergyDistinct
|
|||||||
for (size_t ii(jj); ii<No; ii+=blockSize){
|
for (size_t ii(jj); ii<No; ii+=blockSize){
|
||||||
const size_t iend( std::min( No, ii+blockSize) );
|
const size_t iend( std::min( No, ii+blockSize) );
|
||||||
for (size_t k(kk); k < kend; k++){
|
for (size_t k(kk); k < kend; k++){
|
||||||
const F ek(epsi[k]);
|
|
||||||
const size_t jstart = jj > k ? jj : k;
|
const size_t jstart = jj > k ? jj : k;
|
||||||
for (size_t j(jstart); j < jend; j++){
|
for (size_t j(jstart); j < jend; j++){
|
||||||
F const ej(epsi[j]);
|
|
||||||
F const facjk = j == k ? F(0.5) : F(1.0);
|
|
||||||
size_t istart = ii > j ? ii : j;
|
size_t istart = ii > j ? ii : j;
|
||||||
for (size_t i(istart); i < iend; i++){
|
for (size_t i(istart); i < iend; i++){
|
||||||
|
#endif
|
||||||
|
const F ek(epsi[k]);
|
||||||
|
const F ej(epsi[j]);
|
||||||
|
const F facjk = j == k ? F(0.5) : F(1.0);
|
||||||
const F
|
const F
|
||||||
ei(epsi[i])
|
ei(epsi[i])
|
||||||
, facij = i == j ? F(0.5) : F(1.0)
|
, facij = i == j ? F(0.5) : F(1.0)
|
||||||
@@ -240,14 +246,17 @@ double getEnergyDistinct
|
|||||||
} // i
|
} // i
|
||||||
} // j
|
} // j
|
||||||
} // k
|
} // k
|
||||||
|
#if !defined(HAVE_CUDA)
|
||||||
} // ii
|
} // ii
|
||||||
} // jj
|
} // jj
|
||||||
} // kk
|
} // kk
|
||||||
|
#endif
|
||||||
return std::real(energy);
|
return std::real(energy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <typename F>
|
template <typename F>
|
||||||
|
__MAYBE_DEVICE__
|
||||||
double getEnergySame
|
double getEnergySame
|
||||||
( F const epsabc
|
( F const epsabc
|
||||||
, size_t const No
|
, size_t const No
|
||||||
@@ -257,6 +266,12 @@ double getEnergySame
|
|||||||
) {
|
) {
|
||||||
constexpr size_t blockSize = 16;
|
constexpr size_t blockSize = 16;
|
||||||
F energy = F(0.);
|
F energy = F(0.);
|
||||||
|
#if defined(HAVE_CUDA)
|
||||||
|
#pragma acc kernels
|
||||||
|
for (size_t k(0); k < No; k++) {
|
||||||
|
for (size_t j(k); j < No; j++) {
|
||||||
|
for (size_t i(j); i < No; i++) {
|
||||||
|
#else
|
||||||
for (size_t kk=0; kk<No; kk+=blockSize){
|
for (size_t kk=0; kk<No; kk+=blockSize){
|
||||||
const size_t kend( std::min( kk+blockSize, No) );
|
const size_t kend( std::min( kk+blockSize, No) );
|
||||||
for (size_t jj(kk); jj<No; jj+=blockSize){
|
for (size_t jj(kk); jj<No; jj+=blockSize){
|
||||||
@@ -264,13 +279,14 @@ double getEnergySame
|
|||||||
for (size_t ii(jj); ii<No; ii+=blockSize){
|
for (size_t ii(jj); ii<No; ii+=blockSize){
|
||||||
const size_t iend( std::min( ii+blockSize, No) );
|
const size_t iend( std::min( ii+blockSize, No) );
|
||||||
for (size_t k(kk); k < kend; k++){
|
for (size_t k(kk); k < kend; k++){
|
||||||
const F ek(epsi[k]);
|
|
||||||
const size_t jstart = jj > k ? jj : k;
|
const size_t jstart = jj > k ? jj : k;
|
||||||
for(size_t j(jstart); j < jend; j++){
|
for(size_t j(jstart); j < jend; j++){
|
||||||
const F facjk( j == k ? F(0.5) : F(1.0));
|
|
||||||
const F ej(epsi[j]);
|
|
||||||
const size_t istart = ii > j ? ii : j;
|
const size_t istart = ii > j ? ii : j;
|
||||||
for(size_t i(istart); i < iend; i++){
|
for(size_t i(istart); i < iend; i++){
|
||||||
|
#endif
|
||||||
|
const F facjk( j == k ? F(0.5) : F(1.0));
|
||||||
|
const F ek(epsi[k]);
|
||||||
|
const F ej(epsi[j]);
|
||||||
const F
|
const F
|
||||||
ei(epsi[i])
|
ei(epsi[i])
|
||||||
, facij ( i==j ? F(0.5) : F(1.0))
|
, facij ( i==j ? F(0.5) : F(1.0))
|
||||||
@@ -292,9 +308,11 @@ double getEnergySame
|
|||||||
} // i
|
} // i
|
||||||
} // j
|
} // j
|
||||||
} // k
|
} // k
|
||||||
|
#if !defined(HAVE_CUDA)
|
||||||
} // ii
|
} // ii
|
||||||
} // jj
|
} // jj
|
||||||
} // kk
|
} // kk
|
||||||
|
#endif
|
||||||
return std::real(energy);
|
return std::real(energy);
|
||||||
}
|
}
|
||||||
// Energy:2 ends here
|
// Energy:2 ends here
|
||||||
@@ -436,22 +454,20 @@ double getEnergySame
|
|||||||
, DataFieldType<F>* Tijk_
|
, DataFieldType<F>* Tijk_
|
||||||
) {
|
) {
|
||||||
|
|
||||||
const size_t a = abc[0], b = abc[1], c = abc[2]
|
const size_t NoNo = No*No;
|
||||||
, NoNo = No*No
|
|
||||||
;
|
|
||||||
|
|
||||||
DataFieldType<F>* Tijk = (DataFieldType<F>*)Tijk_;
|
DataFieldType<F>* Tijk = (DataFieldType<F>*)Tijk_;
|
||||||
|
|
||||||
#if defined(ATRIP_USE_DGEMM)
|
#if defined(ATRIP_USE_DGEMM)
|
||||||
#if defined(HAVE_CUDA)
|
#if defined(HAVE_CUDA)
|
||||||
#define REORDER(__II, __JJ, __KK) \
|
#define REORDER(__II, __JJ, __KK) \
|
||||||
reorder<<<bs, ths>>>(reorder_proxy< \
|
reorder<<<bs, ths>>>(reorder_proxy< \
|
||||||
DataFieldType<F>, \
|
DataFieldType<F>, \
|
||||||
__II ## __JJ ## __KK \
|
__II ## __JJ ## __KK \
|
||||||
>{}, \
|
>{}, \
|
||||||
No, \
|
No, \
|
||||||
Tijk, \
|
Tijk, \
|
||||||
_t_buffer);
|
_t_buffer)
|
||||||
#define DGEMM_PARTICLES(__A, __B) \
|
#define DGEMM_PARTICLES(__A, __B) \
|
||||||
atrip::xgemm<F>("T", \
|
atrip::xgemm<F>("T", \
|
||||||
"N", \
|
"N", \
|
||||||
@@ -481,11 +497,18 @@ double getEnergySame
|
|||||||
_t_buffer, \
|
_t_buffer, \
|
||||||
(int const*)&NoNo \
|
(int const*)&NoNo \
|
||||||
)
|
)
|
||||||
#define MAYBE_CONJ(_conj, _buffer) \
|
#define MAYBE_CONJ(_conj, _buffer) \
|
||||||
cuda::maybeConjugate<<< \
|
do { \
|
||||||
Atrip::kernelDimensions.ooo.blocks, \
|
cuda::maybeConjugate<<< \
|
||||||
Atrip::kernelDimensions.ooo.threads \
|
\
|
||||||
>>>((DataFieldType<F>*)_conj, (DataFieldType<F>*)_buffer, NoNoNo);
|
Atrip::kernelDimensions.ooo.blocks, \
|
||||||
|
\
|
||||||
|
Atrip::kernelDimensions.ooo.threads \
|
||||||
|
\
|
||||||
|
>>>((DataFieldType<F>*)_conj, \
|
||||||
|
(DataFieldType<F>*)_buffer, \
|
||||||
|
NoNoNo); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
// END CUDA ////////////////////////////////////////////////////////////////////
|
// END CUDA ////////////////////////////////////////////////////////////////////
|
||||||
@@ -500,7 +523,9 @@ double getEnergySame
|
|||||||
#define REORDER(__II, __JJ, __KK) \
|
#define REORDER(__II, __JJ, __KK) \
|
||||||
reorder(reorder_proxy<DataFieldType<F>, \
|
reorder(reorder_proxy<DataFieldType<F>, \
|
||||||
__II ## __JJ ## __KK >{}, \
|
__II ## __JJ ## __KK >{}, \
|
||||||
No, Tijk, _t_buffer);
|
No, \
|
||||||
|
Tijk, \
|
||||||
|
_t_buffer)
|
||||||
#define DGEMM_PARTICLES(__A, __B) \
|
#define DGEMM_PARTICLES(__A, __B) \
|
||||||
atrip::xgemm<F>("T", \
|
atrip::xgemm<F>("T", \
|
||||||
"N", \
|
"N", \
|
||||||
@@ -531,9 +556,13 @@ double getEnergySame
|
|||||||
_t_buffer, \
|
_t_buffer, \
|
||||||
(int const*)&NoNo \
|
(int const*)&NoNo \
|
||||||
)
|
)
|
||||||
#define MAYBE_CONJ(_conj, _buffer) \
|
#define MAYBE_CONJ(_conj, _buffer) \
|
||||||
for (size_t __i = 0; __i < NoNoNo; ++__i) \
|
do { \
|
||||||
_conj[__i] = maybeConjugate<F>(_buffer[__i]);
|
for (size_t __i = 0; __i < NoNoNo; ++__i) { \
|
||||||
|
_conj[__i] \
|
||||||
|
= maybeConjugate<F>(_buffer[__i]); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
F one{1.0}, m_one{-1.0}, zero{0.0};
|
F one{1.0}, m_one{-1.0}, zero{0.0};
|
||||||
@@ -552,8 +581,12 @@ double getEnergySame
|
|||||||
const size_t
|
const size_t
|
||||||
bs = Atrip::kernelDimensions.ooo.blocks,
|
bs = Atrip::kernelDimensions.ooo.blocks,
|
||||||
ths = Atrip::kernelDimensions.ooo.threads;
|
ths = Atrip::kernelDimensions.ooo.threads;
|
||||||
|
|
||||||
|
#if !defined(ATRIP_ONLY_DGEMM)
|
||||||
cuda::zeroing<<<bs, ths>>>((DataFieldType<F>*)_t_buffer, NoNoNo);
|
cuda::zeroing<<<bs, ths>>>((DataFieldType<F>*)_t_buffer, NoNoNo);
|
||||||
cuda::zeroing<<<bs, ths>>>((DataFieldType<F>*)_vhhh, NoNoNo);
|
cuda::zeroing<<<bs, ths>>>((DataFieldType<F>*)_vhhh, NoNoNo);
|
||||||
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
DataFieldType<F>* _t_buffer = (DataFieldType<F>*)malloc(NoNoNo * sizeof(F));
|
DataFieldType<F>* _t_buffer = (DataFieldType<F>*)malloc(NoNoNo * sizeof(F));
|
||||||
DataFieldType<F>* _vhhh = (DataFieldType<F>*)malloc(NoNoNo * sizeof(F));
|
DataFieldType<F>* _vhhh = (DataFieldType<F>*)malloc(NoNoNo * sizeof(F));
|
||||||
@@ -565,7 +598,7 @@ double getEnergySame
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Set Tijk to zero
|
// Set Tijk to zero
|
||||||
#ifdef HAVE_CUDA
|
#if defined(HAVE_CUDA) && !defined(ATRIP_ONLY_DGEMM)
|
||||||
WITH_CHRONO("double:reorder",
|
WITH_CHRONO("double:reorder",
|
||||||
cuda::zeroing<<<bs, ths>>>((DataFieldType<F>*)Tijk,
|
cuda::zeroing<<<bs, ths>>>((DataFieldType<F>*)Tijk,
|
||||||
NoNoNo);
|
NoNoNo);
|
||||||
@@ -577,43 +610,51 @@ double getEnergySame
|
|||||||
})
|
})
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(ATRIP_ONLY_DGEMM)
|
||||||
|
#undef MAYBE_CONJ
|
||||||
|
#undef REORDER
|
||||||
|
#define MAYBE_CONJ(a, b) do {} while(0)
|
||||||
|
#define REORDER(i, j, k) do {} while(0)
|
||||||
|
#endif
|
||||||
|
|
||||||
// HOLES
|
// HOLES
|
||||||
WITH_CHRONO("doubles:holes",
|
WITH_CHRONO("doubles:holes",
|
||||||
{
|
{
|
||||||
// VhhhC[i + k*No + L*NoNo] * TABhh[L + j*No]; H1
|
// VhhhC[i + k*No + L*NoNo] * TABhh[L + j*No]; H1
|
||||||
MAYBE_CONJ(_vhhh, VhhhC)
|
MAYBE_CONJ(_vhhh, VhhhC);
|
||||||
WITH_CHRONO("doubles:holes:1",
|
WITH_CHRONO("doubles:holes:1",
|
||||||
DGEMM_HOLES(_vhhh, TABhh, "N");
|
DGEMM_HOLES(_vhhh, TABhh, "N");
|
||||||
REORDER(I, K, J)
|
REORDER(I, K, J);
|
||||||
)
|
)
|
||||||
// VhhhC[j + k*No + L*NoNo] * TABhh[i + L*No]; H0
|
// VhhhC[j + k*No + L*NoNo] * TABhh[i + L*No]; H0
|
||||||
WITH_CHRONO("doubles:holes:2",
|
WITH_CHRONO("doubles:holes:2",
|
||||||
DGEMM_HOLES(_vhhh, TABhh, "T");
|
DGEMM_HOLES(_vhhh, TABhh, "T");
|
||||||
REORDER(J, K, I)
|
REORDER(J, K, I);
|
||||||
)
|
)
|
||||||
|
|
||||||
// VhhhB[i + j*No + L*NoNo] * TAChh[L + k*No]; H5
|
// VhhhB[i + j*No + L*NoNo] * TAChh[L + k*No]; H5
|
||||||
MAYBE_CONJ(_vhhh, VhhhB)
|
MAYBE_CONJ(_vhhh, VhhhB);
|
||||||
WITH_CHRONO("doubles:holes:3",
|
WITH_CHRONO("doubles:holes:3",
|
||||||
DGEMM_HOLES(_vhhh, TAChh, "N");
|
DGEMM_HOLES(_vhhh, TAChh, "N");
|
||||||
REORDER(I, J, K)
|
REORDER(I, J, K);
|
||||||
)
|
)
|
||||||
// VhhhB[k + j*No + L*NoNo] * TAChh[i + L*No]; H3
|
// VhhhB[k + j*No + L*NoNo] * TAChh[i + L*No]; H3
|
||||||
WITH_CHRONO("doubles:holes:4",
|
WITH_CHRONO("doubles:holes:4",
|
||||||
DGEMM_HOLES(_vhhh, TAChh, "T");
|
DGEMM_HOLES(_vhhh, TAChh, "T");
|
||||||
REORDER(K, J, I)
|
REORDER(K, J, I);
|
||||||
)
|
)
|
||||||
|
|
||||||
// VhhhA[j + i*No + L*NoNo] * TBChh[L + k*No]; H1
|
// VhhhA[j + i*No + L*NoNo] * TBChh[L + k*No]; H1
|
||||||
MAYBE_CONJ(_vhhh, VhhhA)
|
MAYBE_CONJ(_vhhh, VhhhA);
|
||||||
WITH_CHRONO("doubles:holes:5",
|
WITH_CHRONO("doubles:holes:5",
|
||||||
DGEMM_HOLES(_vhhh, TBChh, "N");
|
DGEMM_HOLES(_vhhh, TBChh, "N");
|
||||||
REORDER(J, I, K)
|
REORDER(J, I, K);
|
||||||
)
|
)
|
||||||
// VhhhA[k + i*No + L*NoNo] * TBChh[j + L*No]; H4
|
// VhhhA[k + i*No + L*NoNo] * TBChh[j + L*No]; H4
|
||||||
WITH_CHRONO("doubles:holes:6",
|
WITH_CHRONO("doubles:holes:6",
|
||||||
DGEMM_HOLES(_vhhh, TBChh, "T");
|
DGEMM_HOLES(_vhhh, TBChh, "T");
|
||||||
REORDER(K, I, J)
|
REORDER(K, I, J);
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -625,32 +666,32 @@ double getEnergySame
|
|||||||
// TAphh[E + i*Nv + j*NoNv] * VBCph[E + k*Nv]; P0
|
// TAphh[E + i*Nv + j*NoNv] * VBCph[E + k*Nv]; P0
|
||||||
WITH_CHRONO("doubles:particles:1",
|
WITH_CHRONO("doubles:particles:1",
|
||||||
DGEMM_PARTICLES(TAphh, VBCph);
|
DGEMM_PARTICLES(TAphh, VBCph);
|
||||||
REORDER(I, J, K)
|
REORDER(I, J, K);
|
||||||
)
|
)
|
||||||
// TAphh[E + i*Nv + k*NoNv] * VCBph[E + j*Nv]; P3
|
// TAphh[E + i*Nv + k*NoNv] * VCBph[E + j*Nv]; P3
|
||||||
WITH_CHRONO("doubles:particles:2",
|
WITH_CHRONO("doubles:particles:2",
|
||||||
DGEMM_PARTICLES(TAphh, VCBph);
|
DGEMM_PARTICLES(TAphh, VCBph);
|
||||||
REORDER(I, K, J)
|
REORDER(I, K, J);
|
||||||
)
|
)
|
||||||
// TCphh[E + k*Nv + i*NoNv] * VABph[E + j*Nv]; P5
|
// TCphh[E + k*Nv + i*NoNv] * VABph[E + j*Nv]; P5
|
||||||
WITH_CHRONO("doubles:particles:3",
|
WITH_CHRONO("doubles:particles:3",
|
||||||
DGEMM_PARTICLES(TCphh, VABph);
|
DGEMM_PARTICLES(TCphh, VABph);
|
||||||
REORDER(K, I, J)
|
REORDER(K, I, J);
|
||||||
)
|
)
|
||||||
// TCphh[E + k*Nv + j*NoNv] * VBAph[E + i*Nv]; P2
|
// TCphh[E + k*Nv + j*NoNv] * VBAph[E + i*Nv]; P2
|
||||||
WITH_CHRONO("doubles:particles:4",
|
WITH_CHRONO("doubles:particles:4",
|
||||||
DGEMM_PARTICLES(TCphh, VBAph);
|
DGEMM_PARTICLES(TCphh, VBAph);
|
||||||
REORDER(K, J, I)
|
REORDER(K, J, I);
|
||||||
)
|
)
|
||||||
// TBphh[E + j*Nv + i*NoNv] * VACph[E + k*Nv]; P1
|
// TBphh[E + j*Nv + i*NoNv] * VACph[E + k*Nv]; P1
|
||||||
WITH_CHRONO("doubles:particles:5",
|
WITH_CHRONO("doubles:particles:5",
|
||||||
DGEMM_PARTICLES(TBphh, VACph);
|
DGEMM_PARTICLES(TBphh, VACph);
|
||||||
REORDER(J, I, K)
|
REORDER(J, I, K);
|
||||||
)
|
)
|
||||||
// TBphh[E + j*Nv + k*NoNv] * VCAph[E + i*Nv]; P4
|
// TBphh[E + j*Nv + k*NoNv] * VCAph[E + i*Nv]; P4
|
||||||
WITH_CHRONO("doubles:particles:6",
|
WITH_CHRONO("doubles:particles:6",
|
||||||
DGEMM_PARTICLES(TBphh, VCAph);
|
DGEMM_PARTICLES(TBphh, VCAph);
|
||||||
REORDER(J, K, I)
|
REORDER(J, K, I);
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
183
tools/configure-benches.sh
Executable file
183
tools/configure-benches.sh
Executable file
@@ -0,0 +1,183 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Copyright (C) 2022 by Alejandro Gallo <aamsgallo@gmail.com>
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
flags=("${@}")
|
||||||
|
PROJECTS=()
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
#
|
||||||
|
## Check root directory
|
||||||
|
#
|
||||||
|
root_project=$(git rev-parse --show-toplevel)
|
||||||
|
configure=$root_project/configure
|
||||||
|
if [[ $(basename $PWD) == $(basename $root_project) ]]; then
|
||||||
|
cat <<EOF
|
||||||
|
|
||||||
|
You are trying to build in the root directory, create a build folder
|
||||||
|
and then configure.
|
||||||
|
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
$(readlink -f $0)
|
||||||
|
|
||||||
|
EOF
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
[[ -f $configure ]] || {
|
||||||
|
cat <<EOF
|
||||||
|
No configure script at $configure create it with bootstrap.sh or
|
||||||
|
|
||||||
|
autoreconf -vif
|
||||||
|
|
||||||
|
EOF
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
#
|
||||||
|
## Create configuration function
|
||||||
|
#
|
||||||
|
|
||||||
|
create_config () {
|
||||||
|
file=$1
|
||||||
|
name=$2
|
||||||
|
PROJECTS=(${PROJECTS[@]} "$name")
|
||||||
|
mkdir -p $name
|
||||||
|
cd $name
|
||||||
|
echo "> creating: $name"
|
||||||
|
cat <<SH > configure
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
# creator: $0
|
||||||
|
# date: $(date)
|
||||||
|
|
||||||
|
$root_project/configure $(cat $file | paste -s) \\
|
||||||
|
$(for word in "${flags[@]}"; do
|
||||||
|
printf " \"%s\"" "$word";
|
||||||
|
done)
|
||||||
|
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
SH
|
||||||
|
chmod +x configure
|
||||||
|
cd - > /dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# begin doc
|
||||||
|
#
|
||||||
|
# - default ::
|
||||||
|
# This configuration uses a CPU code with dgemm
|
||||||
|
# and without computing slices.
|
||||||
|
#
|
||||||
|
# end doc
|
||||||
|
|
||||||
|
tmp=`mktemp`
|
||||||
|
cat <<EOF > $tmp
|
||||||
|
--disable-slice
|
||||||
|
EOF
|
||||||
|
|
||||||
|
create_config $tmp default
|
||||||
|
rm $tmp
|
||||||
|
|
||||||
|
# begin doc
|
||||||
|
#
|
||||||
|
# - only-dgemm ::
|
||||||
|
# This only runs the computation part that involves dgemms.
|
||||||
|
#
|
||||||
|
# end doc
|
||||||
|
|
||||||
|
tmp=`mktemp`
|
||||||
|
cat <<EOF > $tmp
|
||||||
|
--disable-slice
|
||||||
|
--enable-only-dgemm
|
||||||
|
EOF
|
||||||
|
|
||||||
|
create_config $tmp only-dgemm
|
||||||
|
rm $tmp
|
||||||
|
|
||||||
|
# begin doc
|
||||||
|
#
|
||||||
|
# - cuda-only-dgemm ::
|
||||||
|
# This is the naive CUDA implementation compiling only the dgemm parts
|
||||||
|
# of the compute.
|
||||||
|
#
|
||||||
|
# end doc
|
||||||
|
|
||||||
|
tmp=`mktemp`
|
||||||
|
cat <<EOF > $tmp
|
||||||
|
--enable-cuda
|
||||||
|
--enable-only-dgemm
|
||||||
|
--disable-slice
|
||||||
|
EOF
|
||||||
|
|
||||||
|
create_config $tmp cuda-only-dgemm
|
||||||
|
rm $tmp
|
||||||
|
|
||||||
|
# begin doc
|
||||||
|
#
|
||||||
|
# - cuda-slices-on-gpu-only-dgemm ::
|
||||||
|
# This configuration tests that slices reside completely on the gpu
|
||||||
|
# and it should use a CUDA aware MPI implementation.
|
||||||
|
# It also only uses the routines that involve dgemm.
|
||||||
|
#
|
||||||
|
# end doc
|
||||||
|
|
||||||
|
tmp=`mktemp`
|
||||||
|
cat <<EOF > $tmp
|
||||||
|
--enable-cuda
|
||||||
|
--enable-sources-in-gpu
|
||||||
|
--enable-cuda-aware-mpi
|
||||||
|
--enable-only-dgemm
|
||||||
|
--disable-slice
|
||||||
|
EOF
|
||||||
|
|
||||||
|
create_config $tmp cuda-slices-on-gpu-only-dgemm
|
||||||
|
rm $tmp
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
#
|
||||||
|
## Create makefile
|
||||||
|
#
|
||||||
|
|
||||||
|
cat <<MAKE > Makefile
|
||||||
|
|
||||||
|
all: configure do
|
||||||
|
do: configure
|
||||||
|
|
||||||
|
configure: ${PROJECTS[@]/%/\/Makefile}
|
||||||
|
|
||||||
|
%/Makefile: %/configure
|
||||||
|
cd \$* && ./configure
|
||||||
|
|
||||||
|
do: ${PROJECTS[@]/%/\/src\/libatrip.a}
|
||||||
|
|
||||||
|
|
||||||
|
%/src/libatrip.a:
|
||||||
|
cd \$* && \$(MAKE)
|
||||||
|
|
||||||
|
|
||||||
|
.PHONY: configure do all
|
||||||
|
MAKE
|
||||||
|
|
||||||
|
cat <<EOF
|
||||||
|
|
||||||
|
Now you can do
|
||||||
|
|
||||||
|
make all
|
||||||
|
|
||||||
|
or go into one of the directories
|
||||||
|
${PROJECTS[@]}
|
||||||
|
and do
|
||||||
|
./configure
|
||||||
|
make
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
## Emacs stuff
|
||||||
|
# Local Variables:
|
||||||
|
# eval: (outline-minor-mode)
|
||||||
|
# outline-regexp: "############################################################"
|
||||||
|
# End:
|
||||||
Reference in New Issue
Block a user