Displaying 2 results from an estimated 2 matches for "nb_loops".
2015 May 04
5
[LLVMdev] Memory Allocation Optimized away with new by not with ::operator new
...e> f_val(std::size_t i, std::size_t n) {
auto v = std::vector<double>(n);
for (std::size_t k = 0; k < v.size(); ++k) {
v[k] = static_cast<double>(i);
}
return v;
}
int main (int argc, char const *argv[])
{
const auto n = std::size_t{10};
const auto nb_loops = std::size_t{300000000};
auto v = std::vector<double>( n, 0.0 );
for (std::size_t i = 0; i < nb_loops; ++i) {
auto w = f_val(i, n);
for (std::size_t k = 0; k < v.size(); ++k) {
v[k] += w[k];
}
}
std::cout << v[0] << "...
2015 May 04
2
[LLVMdev] Memory Allocation Optimized away with new by not with ::operator new
...e> f_val(std::size_t i, std::size_t n) {
auto v = std::vector<double>(n);
for (std::size_t k = 0; k < v.size(); ++k) {
v[k] = static_cast<double>(i);
}
return v;
}
int main (int argc, char const *argv[])
{
const auto n = std::size_t{10};
const auto nb_loops = std::size_t{300000000};
auto v = std::vector<double>( n, 0.0 );
for (std::size_t i = 0; i < nb_loops; ++i) {
auto w = f_val(i, n);
for (std::size_t k = 0; k < v.size(); ++k) {
v[k] += w[k];
}
}
std::cout << v[0] << "...