Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

LLVM additions #136

Merged
merged 14 commits into from
May 11, 2021
9 changes: 9 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ jobs:
- run:
name: Build and test
command: bash ./tools/circleci_focal_gcc9_llvm10_conda_asan.sh
focal_gcc9_llvm11_conda_asan:
docker:
- image: circleci/buildpack-deps:focal
steps:
- checkout
- run:
name: Build and test
command: bash ./tools/circleci_focal_gcc9_llvm11_conda_asan.sh

workflows:
version: 2.1
Expand All @@ -34,3 +42,4 @@ workflows:
- focal_gcc9_conda_asan
- focal_gcc9_conda_coverage
- focal_gcc9_llvm10_conda_asan
- focal_gcc9_llvm11_conda_asan
2 changes: 2 additions & 0 deletions doc/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Changelog
New
~~~

- Add an LLVM-based vectorised solver for Kepler's equation
(`#136 <https://github.com/bluescarni/heyoka/pull/136>`__).
- Add an LLVM ``while`` loop function
(`#135 <https://github.com/bluescarni/heyoka/pull/135>`__).

Expand Down
2 changes: 1 addition & 1 deletion doc/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ a comprehensive continuous integration pipeline, which includes:

heyoka has the following **mandatory** dependencies:

* the `LLVM <https://llvm.org/>`__ compiler infrastructure library, version 10 or 11,
* the `LLVM <https://llvm.org/>`__ compiler infrastructure library (version >= 10),
* the `Boost <https://www.boost.org/>`__ C++ libraries (version >= 1.60),
* the `{fmt} <https://fmt.dev/latest/index.html>`__ library,
* the `spdlog <https://github.com/gabime/spdlog>`__ library.
Expand Down
37 changes: 37 additions & 0 deletions include/heyoka/detail/llvm_helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,20 @@
#ifndef HEYOKA_DETAIL_LLVM_HELPERS_HPP
#define HEYOKA_DETAIL_LLVM_HELPERS_HPP

#include <heyoka/config.hpp>

#include <cstdint>
#include <functional>
#include <initializer_list>
#include <string>
#include <type_traits>
#include <typeinfo>
#include <utility>
#include <vector>

#include <heyoka/detail/fwd_decl.hpp>
#include <heyoka/detail/llvm_fwd.hpp>
#include <heyoka/detail/type_traits.hpp>
#include <heyoka/detail/visibility.hpp>

namespace heyoka::detail
Expand All @@ -43,6 +48,8 @@ inline llvm::Type *to_llvm_vector_type(llvm::LLVMContext &c, std::uint32_t batch
return make_vector_type(to_llvm_type<T>(c), batch_size);
}

HEYOKA_DLL_PUBLIC std::string llvm_mangle_type(llvm::Type *);

HEYOKA_DLL_PUBLIC llvm::Value *load_vector_from_memory(ir_builder &, llvm::Value *, std::uint32_t);
HEYOKA_DLL_PUBLIC void store_vector_to_memory(ir_builder &, llvm::Value *, llvm::Value *);

Expand Down Expand Up @@ -90,6 +97,36 @@ HEYOKA_DLL_PUBLIC llvm::Value *make_global_zero_array(llvm::Module &, llvm::Arra

HEYOKA_DLL_PUBLIC llvm::Value *call_extern_vec(llvm_state &, llvm::Value *, const std::string &);

// Math helpers.
HEYOKA_DLL_PUBLIC std::pair<llvm::Value *, llvm::Value *> llvm_sincos(llvm_state &, llvm::Value *);
HEYOKA_DLL_PUBLIC llvm::Value *llvm_modulus(llvm_state &, llvm::Value *, llvm::Value *);
HEYOKA_DLL_PUBLIC llvm::Value *llvm_abs(llvm_state &, llvm::Value *);

HEYOKA_DLL_PUBLIC llvm::Function *llvm_add_inv_kep_E_dbl(llvm_state &, std::uint32_t);
HEYOKA_DLL_PUBLIC llvm::Function *llvm_add_inv_kep_E_ldbl(llvm_state &, std::uint32_t);

#if defined(HEYOKA_HAVE_REAL128)

HEYOKA_DLL_PUBLIC llvm::Function *llvm_add_inv_kep_E_f128(llvm_state &, std::uint32_t);

#endif

template <typename T>
inline llvm::Function *llvm_add_inv_kep_E(llvm_state &s, std::uint32_t batch_size)
{
if constexpr (std::is_same_v<T, double>) {
return llvm_add_inv_kep_E_dbl(s, batch_size);
} else if constexpr (std::is_same_v<T, long double>) {
return llvm_add_inv_kep_E_ldbl(s, batch_size);
#if defined(HEYOKA_HAVE_REAL128)
} else if constexpr (std::is_same_v<T, mppp::real128>) {
return llvm_add_inv_kep_E_f128(s, batch_size);
#endif
} else {
static_assert(always_false_v<T>, "Unhandled type.");
}
}

} // namespace heyoka::detail

#endif
Loading