Skip to content

Commit

Permalink
Consistency improvements (#749)
Browse files Browse the repository at this point in the history
* more housekeeping and cleanup
  • Loading branch information
mkstoyanov authored Nov 22, 2024
1 parent da43858 commit 15edef9
Show file tree
Hide file tree
Showing 67 changed files with 626 additions and 1,176 deletions.
28 changes: 27 additions & 1 deletion .github/workflows/build-ubuntu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
# some BALS is required, makes little sense to skip HDF5 (can't output anything)
strategy:
matrix:
prec: [float, double, float\;double]
prec: [float, double]
compiler: [clang++-14, g++-11]
runs-on: ubuntu-22.04
steps:
Expand All @@ -36,6 +36,31 @@ jobs:
if: failure()
working-directory: ${{runner.workspace}}/asgard/build/Testing/Temporary
run: cat LastTest.log
asgard-allprec:
# g++-11 using both precisions
runs-on: ubuntu-22.04
steps:
- name: Git checkout
uses: actions/checkout@v4
- name: Makedir
working-directory: ${{runner.workspace}}/asgard
run: cmake -E make_directory build
- name: Configure
working-directory: ${{runner.workspace}}/asgard/build
run: cmake -DCMAKE_BUILD_TYPE=Release
-DASGARD_PRECISIONS="float;double"
-DASGARD_RECOMMENDED_DEFAULTS=ON
../
- name: Build
working-directory: ${{runner.workspace}}/asgard/build
run: make -j VERBOSE=1
- name: Test
working-directory: ${{runner.workspace}}/asgard/build
run: make test
- name: Show Log
if: failure()
working-directory: ${{runner.workspace}}/asgard/build/Testing/Temporary
run: cat LastTest.log
asgard-mpi:
# basic MPI build using default settings
runs-on: ubuntu-22.04
Expand Down Expand Up @@ -83,6 +108,7 @@ jobs:
- name: Configure
working-directory: ${{runner.workspace}}/asgard/build
run: cmake -DCMAKE_BUILD_TYPE=Release
-DASGARD_PRECISIONS=double
-DASGARD_RECOMMENDED_DEFAULTS=ON
../
- name: Build
Expand Down
18 changes: 9 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ else()
register_project (Catch2
CATCH2
https://github.com/catchorg/Catch2.git
v3.1.0
v3.3.0
)
endif()

Expand Down Expand Up @@ -94,7 +94,7 @@ cmake_dependent_option (ASGARD_USE_GPU_MEM_LIMIT "Allow the ability to limit the
option (ASGARD_USE_MPI "Optional distributed computing support for asgard" OFF)

option (ASGARD_USE_PYTHON "Optional Python tool for post-processing, plotting and quick prototyping" OFF)
option (ASGARD_IO_HIGHFIVE "Use the HighFive HDF5 header library for I/O" OFF)
option (ASGARD_USE_HIGHFIVE "Use the HighFive HDF5 header library for I/O" OFF)

option (ASGARD_BUILD_OPENBLAS "Download and build our own OpenBLAS" OFF)
option (ASGARD_BUILD_HDF5 "Download and build our own HDF5/HighFive" OFF)
Expand Down Expand Up @@ -133,9 +133,9 @@ endif()
set(ASGARD_SCRIPTS_DIR "${CMAKE_SOURCE_DIR}/scripts/")

#Enable HighFive IO if any of the following variables are defined
if(NOT ASGARD_IO_HIGHFIVE)
if(ASGARD_HDF5_PATH OR ASGARD_BUILD_HDF5 OR ASGARD_HIGHFIVE_PATH OR ASGARD_USE_PYTHON)
set(ASGARD_IO_HIGHFIVE ON CACHE BOOL "" FORCE)
if(NOT ASGARD_USE_HIGHFIVE)
if(ASGARD_BUILD_HDF5 OR ASGARD_USE_PYTHON)
set(ASGARD_USE_HIGHFIVE ON CACHE BOOL "" FORCE)
endif()
endif()

Expand Down Expand Up @@ -372,7 +372,7 @@ set (components
asgard_transformations
)

if (ASGARD_IO_HIGHFIVE)
if (ASGARD_USE_HIGHFIVE)
list (APPEND components asgard_io)
endif ()

Expand Down Expand Up @@ -424,8 +424,8 @@ target_link_libraries (libasgard
$<$<BOOL:${MPI_CXX_FOUND}>:MPI::MPI_CXX>
$<$<BOOL:${LINALG_FOUND}>:asgard::LINALG>
$<$<BOOL:${OpenMP_CXX_FOUND}>:OpenMP::OpenMP_CXX>
$<$<BOOL:${ASGARD_IO_HIGHFIVE}>:asgard_highfive>
$<$<BOOL:${ASGARD_IO_HIGHFIVE}>:asgard_hdf5>
$<$<BOOL:${ASGARD_USE_HIGHFIVE}>:asgard_highfive>
$<$<BOOL:${ASGARD_USE_HIGHFIVE}>:asgard_hdf5>
)
target_include_directories (libasgard
PUBLIC
Expand Down Expand Up @@ -604,7 +604,7 @@ if (ASGARD_BUILD_TESTS)
ASGARD_USE_MPI
ASGARD_USE_CUDA
ASGARD_USE_PYTHON
ASGARD_IO_HIGHFIVE
ASGARD_USE_HIGHFIVE
ASGARD_USE_TIMER)
message(STATUS " ${_opt}=${${_opt}}")
endforeach()
Expand Down
4 changes: 2 additions & 2 deletions asgard-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ target_link_libraries (asgard::LINALG
$<$<BOOL:${LAPACK_FOUND}>:LAPACK::LAPACK>
)

if (@ASGARD_IO_HIGHFIVE@)
if (@ASGARD_USE_HIGHFIVE@)
enable_language (C)
endif()

Expand All @@ -53,7 +53,7 @@ set(asgard_OPENMP_FOUND "@ASGARD_USE_OPENMP@")
set(asgard_MPI_FOUND "@ASGARD_USE_MPI@")
set(asgard_CUDA_FOUND "@ASGARD_USE_CUDA@")
set(asgard_PYTHON_FOUND "@ASGARD_USE_PYTHON@")
set(asgard_HDF5_FOUND "@ASGARD_IO_HIGHFIVE@")
set(asgard_HDF5_FOUND "@ASGARD_USE_HIGHFIVE@")

set(_asgard_modules "")
foreach(_asgard_module OPENMP MPI CUDA)
Expand Down
2 changes: 1 addition & 1 deletion contrib/asgard_io.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ endfunction()
# header-only library for a c++ interface into libhdf5
# included in the asgard repo at contrib/HighFive
###############################################################################
if (ASGARD_IO_HIGHFIVE)
if (ASGARD_USE_HIGHFIVE)

# first we need HDF5
enable_language (C)
Expand Down
2 changes: 1 addition & 1 deletion doxygen/basic_usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ provided asgard module or use the Python-MATLAB integration. This requires CMake
options
```
-D ASGARD_USE_PYTHON=ON
-D ASGARD_IO_HIGHFIVE=ON
-D ASGARD_USE_HIGHFIVE=ON
```

The data stored in the HDF5 file is in sparse grid hierarchical format, full
Expand Down
4 changes: 2 additions & 2 deletions doxygen/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ CMake uses out-of-source build, clone the repo and build in a subfolder
-D CMAKE_CXX_FLAGS="-march=native -mtune=native" \
-D ASGARD_USE_OPENMP=ON \
-D ASGARD_USE_PYTHON=ON \
-D ASGARD_IO_HIGHFIVE=ON \
-D ASGARD_USE_HIGHFIVE=ON \
-D ASGARD_PRECISIONS=double \
..
cmake --build . -j
Expand All @@ -74,7 +74,7 @@ The BLAS/LAPACK acceleration needs a flag to enable the most recent mode.
-D CMAKE_CXX_FLAGS="-march=native -mtune=native -DACCELERATE_NEW_LAPACK" \
-D ASGARD_USE_OPENMP=OFF \
-D ASGARD_USE_PYTHON=ON \
-D ASGARD_IO_HIGHFIVE=ON \
-D ASGARD_USE_HIGHFIVE=ON \
-D ASGARD_BUILD_HDF5=ON \
-D ASGARD_PRECISIONS=double \
..
Expand Down
2 changes: 1 addition & 1 deletion examples/continuity_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ class example_continuity2d : public asgard::PDE<precision>
static precision get_dt(asgard::dimension<precision> const &dim)
{
precision const x_range = dim.domain_max - dim.domain_min;
precision const dx = x_range / asgard::fm::two_raised_to(dim.get_level());
precision const dx = x_range / asgard::fm::ipow2(dim.get_level());
// return dx; this will be scaled by CFL
// from command line
return dx;
Expand Down
2 changes: 1 addition & 1 deletion examples/inputs_1d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class example_sinwaves : public asgard::PDE<precision>
static precision get_dt(asgard::dimension<precision> const &dim)
{
precision const x_range = dim.domain_max - dim.domain_min;
precision const dx = x_range / asgard::fm::two_raised_to(dim.get_level());
precision const dx = x_range / asgard::fm::ipow2(dim.get_level());
// return dx; this will be scaled by CFL
// from command line
return dx;
Expand Down
3 changes: 2 additions & 1 deletion python/asgard_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@

__enable_float__ = ("@ASGARD_ENABLE_FLOAT@" == "ON")
__enable_double__ = ("@ASGARD_ENABLE_DOUBLE@" == "ON")
__enable_highfive__ = ("@ASGARD_IO_HIGHFIVE@" == "ON")

__enable_highfive__ = ("@ASGARD_USE_HIGHFIVE@" == "ON")
16 changes: 8 additions & 8 deletions src/asgard_basis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ fk::matrix<R> operator_two_scale(int const degree, int const num_levels)
expect(num_levels > 1);

int const pdof = degree + 1;
int const max_level = fm::two_raised_to(num_levels);
int const max_level = fm::ipow2(num_levels);

// this is to get around unused warnings
// because can't unpack only some args w structured binding (until c++20)
Expand All @@ -197,7 +197,7 @@ fk::matrix<R> operator_two_scale(int const degree, int const num_levels)
fmwt.set_submatrix(pdof * (i + max_level / 2), 2 * pdof * i, g_block);
}

fk::matrix<R> fmwt_comp = eye<R>(pdof * max_level, pdof * max_level);
fk::matrix<R> fmwt_comp = eye<R>(pdof * max_level);

int const n = std::floor(std::log2(max_level));
for (int j = 1; j <= n; j++)
Expand All @@ -209,7 +209,7 @@ fk::matrix<R> operator_two_scale(int const degree, int const num_levels)
}
else
{
int const cn = fm::two_raised_to(n - j + 1) * pdof;
int const cn = fm::ipow2(n - j + 1) * pdof;

std::fill(cfmwt.begin(), cfmwt.end(), 0.0);
cfmwt.set_submatrix(cn, cn, eye<R>(pdof * max_level - cn));
Expand Down Expand Up @@ -257,18 +257,18 @@ wavelet_transform<P, resrc>::wavelet_transform(int const max_level_in,

auto const [h0, h1, g0, g1] = generate_multi_wavelets<P>(degree);

int const fmwt_size = pdof * fm::two_raised_to(max_level);
int const fmwt_size = pdof * fm::ipow2(max_level);

std::vector<fk::matrix<P>> block_builder(max_level * 2);

fk::matrix<P> g_mat(pdof, fmwt_size);
fk::matrix<P> h_mat = fk::matrix<P>(pdof, fmwt_size)
.set_submatrix(0, 0, eye<P>(pdof, pdof));
.set_submatrix(0, 0, eye<P>(pdof));

// main loop - build the blocks with small gemms
for (auto j = max_level - 1; j >= 0; --j)
{
auto const num_cells = fm::two_raised_to(j);
auto const num_cells = fm::ipow2(j);
auto const block_ncols = fmwt_size / num_cells;
auto const ncols_h = block_ncols / 2;

Expand Down Expand Up @@ -364,7 +364,7 @@ fk::matrix<P, mem_type::owner, resrc> wavelet_transform<P, resrc>::apply(

int pdof = degree + 1;

auto const op_size = fm::two_raised_to(level) * pdof;
auto const op_size = fm::ipow2(level) * pdof;
if (transform_side == basis::side::right)
{
expect(coefficients.ncols() == op_size);
Expand Down Expand Up @@ -434,7 +434,7 @@ fk::matrix<P, mem_type::owner, resrc> wavelet_transform<P, resrc>::apply(

for (auto i = 0; i < level; ++i)
{
auto const num_cells = fm::two_raised_to(i);
auto const num_cells = fm::ipow2(i);
auto const cell_size = op_size / num_cells;

auto const &current_block = dense_blocks_[block_offset + i * 2];
Expand Down
11 changes: 5 additions & 6 deletions src/asgard_basis_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,16 +254,15 @@ void test_fmwt_application(int const level, int const degree)

for (auto l = 2; l <= forward_transform.max_level; ++l)
{
auto const degrees_freedom =
fm::two_raised_to(l) * (forward_transform.degree + 1);
auto const to_transform = [&gen, degrees_freedom]() {
fk::matrix<P> matrix(degrees_freedom, degrees_freedom);
auto const dof = fm::ipow2(l) * (forward_transform.degree + 1);
auto const to_transform = [&gen, dof]() {
fk::matrix<P> matrix(dof, dof);
std::generate(matrix.begin(), matrix.end(), gen);
return matrix;
}();

auto const to_transform_v = [&gen, degrees_freedom]() {
fk::vector<P> vector(degrees_freedom);
auto const to_transform_v = [&gen, dof]() {
fk::vector<P> vector(dof);
std::generate(vector.begin(), vector.end(), gen);
return vector;
}();
Expand Down
2 changes: 1 addition & 1 deletion src/asgard_batch_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ TEMPLATE_TEST_CASE("kron", "[kron]", test_precs)
&m) { return i * m.nrows(); });

fk::vector<TestType> const correct(std::vector<TestType>(
y_size, x_size * fm::two_raised_to(matrices.size() - 1) * 3));
y_size, x_size * fm::ipow2(matrices.size() - 1) * 3));

test_kron<TestType, resource::device>(matrices, x_device, correct);
}
Expand Down
4 changes: 2 additions & 2 deletions src/asgard_boundary_conditions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ compute_left_boundary_condition(g_func_type<P> g_func, g_func_type<P> dv_func,
int const level = dim.get_level();
int const degree = dim.get_degree();

P const total_cells = fm::two_raised_to(level);
P const total_cells = fm::ipow2(level);

P const domain_per_cell = domain_extent / total_cells;

Expand Down Expand Up @@ -314,7 +314,7 @@ compute_right_boundary_condition(g_func_type<P> g_func, g_func_type<P> dv_func,
int const level = dim.get_level();
int const degree = dim.get_degree();

P const total_cells = fm::two_raised_to(level);
P const total_cells = fm::ipow2(level);

P const domain_per_cell = domain_extent / total_cells;

Expand Down
2 changes: 1 addition & 1 deletion src/asgard_build_info.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#define GIT_COMMIT_SUMMARY "@GIT_COMMIT_SUMMARY@"
#define BUILD_TIME "@BUILD_TIME@"

#cmakedefine ASGARD_IO_HIGHFIVE
#cmakedefine ASGARD_USE_HIGHFIVE
#cmakedefine ASGARD_USE_TIMER
#cmakedefine ASGARD_USE_CUDA
#cmakedefine ASGARD_USE_GPU_MEM_LIMIT
Expand Down
4 changes: 2 additions & 2 deletions src/asgard_coefficients.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void generate_coefficients(dimension<P> const &dim, partial_term<P> const &pterm
}();

// setup jacobi of variable x and define coeff_mat
auto const num_cells = fm::two_raised_to(level);
auto const num_cells = fm::ipow2(level);

auto const grid_spacing = (dim.domain_max - dim.domain_min) / num_cells;
//auto const degrees_freedom_1d = (dim.get_degree() + 1) * num_cells;
Expand Down Expand Up @@ -448,7 +448,7 @@ void generate_coefficients(dimension<P> const &dim, partial_term<P> const &pterm
}();

// setup jacobi of variable x and define coeff_mat
auto const num_cells = fm::two_raised_to(level);
auto const num_cells = fm::ipow2(level);

auto const grid_spacing = (dim.domain_max - dim.domain_min) / num_cells;
int const nblock = (dim.get_degree() + 1) * (dim.get_degree() + 1);
Expand Down
2 changes: 1 addition & 1 deletion src/asgard_dimension.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct dimension

for (int i = 0; i <= level_; ++i)
{
auto const max_dof = fm::two_raised_to(i) * (degree + 1);
auto const max_dof = fm::ipow2(i) * (degree + 1);
expect(max_dof < INT_MAX);
this->mass_.push_back(eye<P>(max_dof));
}
Expand Down
10 changes: 5 additions & 5 deletions src/asgard_discretization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ discretization_manager<precision>::discretization_manager(
<< GIT_COMMIT_SUMMARY << '\n';
node_out() << "This executable was built on " << BUILD_TIME << '\n';

#ifdef ASGARD_IO_HIGHFIVE
#ifdef ASGARD_USE_HIGHFIVE
if (not options.restart_file.empty())
{
node_out() << "--- restarting from a file ---\n";
Expand Down Expand Up @@ -93,7 +93,7 @@ discretization_manager<precision>::discretization_manager(
reset_moments();

// -- setup output file and write initial condition
#ifdef ASGARD_IO_HIGHFIVE
#ifdef ASGARD_USE_HIGHFIVE
if (not options.restart_file.empty())
{
restart_data<precision> data = read_output(
Expand Down Expand Up @@ -338,20 +338,20 @@ void discretization_manager<precision>::ode_sv(imex_flag imflag,
template<typename precision>
void discretization_manager<precision>::save_snapshot(std::filesystem::path const &filename) const
{
#ifdef ASGARD_IO_HIGHFIVE
#ifdef ASGARD_USE_HIGHFIVE
fk::vector<precision> fstate(state);
write_output(*pde, moments, fstate, time_, time_step_, fstate.size(),
grid.get_table(), "", filename);
#else
ignore(filename);
throw std::runtime_error("save_snapshot() requires CMake option -DASGARD_IO_HIGHFIVE=ON");
throw std::runtime_error("save_snapshot() requires CMake option -DASGARD_USE_HIGHFIVE=ON");
#endif
}

template<typename precision>
void discretization_manager<precision>::checkpoint() const
{
#ifdef ASGARD_IO_HIGHFIVE
#ifdef ASGARD_USE_HIGHFIVE
if (pde->is_output_step(time_step_))
{
if (high_verbosity())
Expand Down
4 changes: 2 additions & 2 deletions src/asgard_discretization.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "asgard_moment.hpp"
#include "asgard_solver.hpp"

#ifdef ASGARD_IO_HIGHFIVE
#ifdef ASGARD_USE_HIGHFIVE
#include "asgard_io.hpp"
#endif

Expand Down Expand Up @@ -260,7 +260,7 @@ class discretization_manager
int const level = pde->get_dimensions()[0].get_level();
precision const min = pde->get_dimensions()[0].domain_min;
precision const max = pde->get_dimensions()[0].domain_max;
int const N_elements = fm::two_raised_to(level);
int const N_elements = fm::ipow2(level);

int const quad_dense_size = dense_dim_size(ASGARD_NUM_QUADRATURE - 1, level);

Expand Down
Loading

0 comments on commit 15edef9

Please sign in to comment.