Alex

Introduction (Lecture 1)

CPUs

First C++ Program

#include <algorithm>
#include <print>
#include <vector>

int main() {
    std::vector<double> data = {1.0,2.0,3.0,4.0};
    // Default behaviour of reduce is to "+", however that is defined for your data type
    auto sum = std::reduce(data.begin(), data.end());
    std::print(std::stdout, "Sum: {}\n", sum);
    return 0;
}

HPX

// ...
hpx::execution::experimental::num_cores nc(2);
auto sum = hpx::reduce(hpx::execution::par.with(nc), data.begin(), data.end())
// ...

Equality vs Ordering