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

Vectorized RooChebychev #3

Closed
wants to merge 38 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
be0e0a1
[RF] Change evaluatePartition interface for test statistics.
hageboeck Feb 5, 2019
6fc86bf
[RF] Initial cleanups before touching RooVectorDataStore.
hageboeck Feb 5, 2019
fcc446b
Remove dead code in RooGaussian.
hageboeck Feb 6, 2019
8faeaec
Fix some typos in docs.
hageboeck Feb 7, 2019
9e6579b
WIP before sed-ing RooFit::DataBatch to RooSpan.
hageboeck Feb 8, 2019
e8419ca
Make pointees of span backport writable.
hageboeck Feb 15, 2019
ce406fa
[RF] Add a RooSpan to enable batched function evaluations.
hageboeck Feb 15, 2019
40f38fc
Add vdt math function to vectorised Gaussian prototype.
hageboeck Feb 18, 2019
c69d475
Further cleanups.
hageboeck Feb 22, 2019
fbae64c
Change batch evaluation interface.
hageboeck Mar 7, 2019
e85ef34
Vectorise exponential, extend its analytical integral.
hageboeck Apr 4, 2019
095fca8
Make Gaussian integral not return zero, but 1E-300 if it vanishes.
hageboeck Apr 4, 2019
d4bac30
Clean up RooAddition, RooConstraintSum of member iterators.
hageboeck Apr 4, 2019
2a8c311
Disable cout in ProdPdf, make RooUnitTest failures more informative.
hageboeck Apr 4, 2019
98e94de
Add `BatchMode` switch for fitTo to switch on BatchMode.
hageboeck Apr 4, 2019
c538089
Hacky batch&vector version for RooAddPdf.
hageboeck Apr 8, 2019
472e5f9
Add Pdf-local batch storage.
hageboeck Apr 23, 2019
0c9a580
[Mathmore] Vectorise Kahan summation algorithm.
hageboeck May 2, 2019
f0670a8
Fix computation errors in batch-local storage strategy.
hageboeck May 20, 2019
3743a80
[RF] Add generic evaluateBatch to RooAbsReal.
hageboeck Jul 3, 2019
2a28784
[RF] Change batch evaluation interface to begin+size indexing.
hageboeck Jul 8, 2019
3c04fea
[RF] Vectorise error checking in RooAbsPdf.
hageboeck Jul 11, 2019
5979147
[RF] Prevent empty names for RooAbsArgs.
hageboeck Jul 11, 2019
61af859
[RF] Make spans assignable.
hageboeck Jul 12, 2019
ccaf689
[RF] Make RooCmdArg printable.
hageboeck Jul 23, 2019
757b095
[RF] Replace legacy iterators in RooAbsOptTestStatistic.
hageboeck Jul 24, 2019
fdd27f5
[RF] Clean up public interface of RooAbsArg.
hageboeck Jul 26, 2019
dc3f35f
[RF] Add test for integral of RooExponential.
hageboeck Aug 2, 2019
ab01e11
[RF] Allow for devirtualisation of RooConstVar.
hageboeck Aug 2, 2019
af350d3
[RF] Clean up iterators in RooAddition and RooVectorDataStore.
hageboeck Aug 2, 2019
318874f
[RF] Add sanity checks for negative parameters in RooJohnson.
hageboeck Aug 5, 2019
3607ef2
[RF] Add dirty-state propagation to batch evaluations.
hageboeck Aug 6, 2019
8cd603f
[RF] Include custom preprocessing to batch computations.
hageboeck Aug 6, 2019
bef778f
[RF] Convert all BracketAdapters to double constants.
hageboeck Aug 7, 2019
757cc4b
[RF] Vectorised Landau PDF
Jul 26, 2019
58d8189
[RF] Create helper functions for finding actual batch size, ammend Ro…
Aug 8, 2019
e4ef8a7
[RF] Vectorized RooBukin.
Aug 9, 2019
c4f5c5f
[RF] Vectorized RooChebychev PDF.
Aug 13, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 43 additions & 39 deletions core/foundation/inc/ROOT/span.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include <stdexcept>
#include <memory>
#include <type_traits>
#include <vector>
#include <initializer_list>

namespace ROOT {
Expand Down Expand Up @@ -158,15 +157,16 @@ public:
/*
* types
*/
typedef T value_type;
typedef value_type const* pointer;
typedef value_type const* const_pointer;
typedef value_type const& reference;
typedef value_type const& const_reference;
typedef value_type const* iterator;
typedef value_type const* const_iterator;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T element_type;
typedef std::remove_cv<T> value_type;
typedef element_type * pointer;
typedef element_type const* const_pointer;
typedef element_type & reference;
typedef element_type const& const_reference;
typedef element_type * iterator;
typedef element_type const* const_iterator;
typedef ptrdiff_t difference_type;
typedef std::size_t index_type;
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;

Expand All @@ -182,56 +182,60 @@ public:

// Note:
// This constructor can't be constexpr because & operator can't be constexpr.
template<size_type N>
template<index_type N>
/*implicit*/ span(std::array<T, N> const& a) noexcept
: length_(N), data_(N > 0 ? a.data() : nullptr)
{}

// Note:
// This constructor can't be constexpr because & operator can't be constexpr.
template<size_type N>
template<index_type N>
/*implicit*/ span(T const (& a)[N]) noexcept
: length_(N), data_(N > 0 ? std::addressof(a[0]) : nullptr)
{
static_assert(N > 0, "Zero-length array is not permitted in ISO C++.");
}

/*implicit*/ span(std::vector<T> const& v) noexcept
/*implicit*/ span(std::vector<typename std::remove_cv<T>::type> const& v) noexcept
: length_(v.size()), data_(v.empty() ? nullptr : v.data())
{}

/*implicit*/ span(std::vector<typename std::remove_cv<T>::type> & v) noexcept
: length_(v.size()), data_(v.empty() ? nullptr : v.data())
{}

/*implicit*/ constexpr span(T const* a, size_type const n) noexcept
/*implicit*/ constexpr span(pointer a, index_type const n) noexcept
: length_(n), data_(a)
{}

template<
class InputIterator,
class = typename std::enable_if<
std::is_same<
T,
typename std::remove_cv<T>::type,
typename std::iterator_traits<InputIterator>::value_type
>::value
>::type
>
explicit span(InputIterator start, InputIterator last)
: length_(std::distance(start, last)), data_(start)
span(InputIterator start, InputIterator last)
: length_(std::distance(start, last)), data_(&*start)
{}

span(std::initializer_list<T> const& l)
: length_(l.size()), data_(std::begin(l))
{}

span& operator=(span const&) noexcept = delete;
span& operator=(span const&) noexcept = default;
span& operator=(span &&) noexcept = delete;

/*
* iterator interfaces
*/
constexpr const_iterator begin() const noexcept
constexpr iterator begin() const noexcept
{
return data_;
}
constexpr const_iterator end() const noexcept
constexpr iterator end() const noexcept
{
return data_ + length_;
}
Expand All @@ -243,11 +247,11 @@ public:
{
return end();
}
const_reverse_iterator rbegin() const
reverse_iterator rbegin() const
{
return {end()};
}
const_reverse_iterator rend() const
reverse_iterator rend() const
{
return {begin()};
}
Expand All @@ -263,34 +267,34 @@ public:
/*
* access
*/
constexpr size_type size() const noexcept
constexpr index_type size() const noexcept
{
return length_;
}
constexpr size_type length() const noexcept
constexpr index_type length() const noexcept
{
return size();
}
constexpr size_type max_size() const noexcept
constexpr index_type max_size() const noexcept
{
return size();
}
constexpr bool empty() const noexcept
{
return length_ == 0;
}
constexpr const_reference operator[](size_type const n) const noexcept
constexpr reference operator[](index_type const n) const noexcept
{
return *(data_ + n);
}
constexpr const_reference at(size_type const n) const
constexpr reference at(index_type const n) const
{
//Works only in C++14
//if (n >= length_) throw std::out_of_range("span::at()");
//return *(data_ + n);
return n >= length_ ? throw std::out_of_range("span::at()") : *(data_ + n);
}
constexpr const_pointer data() const noexcept
constexpr pointer data() const noexcept
{
return data_;
}
Expand All @@ -308,7 +312,7 @@ public:
*/
// slice with indices {{{
// check bound {{{
constexpr span<T> slice(check_bound_t, size_type const pos, size_type const slicelen) const
constexpr span<T> slice(check_bound_t, index_type const pos, index_type const slicelen) const
{
//Works only in C++14
//if (pos >= length_ || pos + slicelen >= length_) {
Expand All @@ -317,7 +321,7 @@ public:
//return span<T>{begin() + pos, begin() + pos + slicelen};
return pos >= length_ || pos + slicelen >= length_ ? throw std::out_of_range("span::slice()") : span<T>{begin() + pos, begin() + pos + slicelen};
}
constexpr span<T> slice_before(check_bound_t, size_type const pos) const
constexpr span<T> slice_before(check_bound_t, index_type const pos) const
{
//Works only in C++14
//if (pos >= length_) {
Expand All @@ -326,7 +330,7 @@ public:
//return span<T>{begin(), begin() + pos};
return pos >= length_ ? std::out_of_range("span::slice()") : span<T>{begin(), begin() + pos};
}
constexpr span<T> slice_after(check_bound_t, size_type const pos) const
constexpr span<T> slice_after(check_bound_t, index_type const pos) const
{
//Works only in C++14
//if (pos >= length_) {
Expand All @@ -337,15 +341,15 @@ public:
}
// }}}
// not check bound {{{
constexpr span<T> slice(size_type const pos, size_type const slicelen) const
constexpr span<T> slice(index_type const pos, index_type const slicelen) const
{
return span<T>{begin() + pos, begin() + pos + slicelen};
}
constexpr span<T> slice_before(size_type const pos) const
constexpr span<T> slice_before(index_type const pos) const
{
return span<T>{begin(), begin() + pos};
}
constexpr span<T> slice_after(size_type const pos) const
constexpr span<T> slice_after(index_type const pos) const
{
return span<T>{begin() + pos, end()};
}
Expand Down Expand Up @@ -406,9 +410,9 @@ public:
/*
* others
*/
template<class Allocator = std::allocator<T>>
template<class Allocator = std::allocator<typename std::remove_cv<T>::type>>
auto to_vector(Allocator const& alloc = Allocator{}) const
-> std::vector<T, Allocator>
-> std::vector<typename std::remove_cv<T>::type, Allocator>
{
return {begin(), end(), alloc};
}
Expand All @@ -428,8 +432,8 @@ private:
}

private:
size_type const length_;
const_pointer const data_;
index_type length_;
pointer data_;
};
// }}}
} // inline namespace __ROOT
Expand Down Expand Up @@ -554,7 +558,7 @@ span<T> make_view(T const (&a)[N])

template<class T>
inline constexpr
span<T> make_view(T const* p, typename span<T>::size_type const n)
span<T> make_view(T const* p, typename span<T>::index_type const n)
{
return span<T>{p, n};
}
Expand Down
Loading