Skip to content

Commit a39c5db

Browse files
committed
use pack ctor
1 parent c9a182c commit a39c5db

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

examples/boost-simd-dot.cpp

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ Value simd_dot(Value* first1, Value* last1, Value* first2)
1616
{
1717
using boost::simd::sum;
1818
using boost::simd::pack;
19-
using boost::simd::load;
2019

2120
typedef pack<Value> type;
2221
type tmp;
@@ -25,8 +24,8 @@ Value simd_dot(Value* first1, Value* last1, Value* first2)
2524
while (first1 != last1)
2625
{
2726
// Load current values from the datasets
28-
pack<Value> x1 = load<type>(first1);
29-
pack<Value> x2 = load<type>(first2);
27+
pack<Value> x1(first1);
28+
pack<Value> x2(first2);
3029

3130
// Computation
3231
tmp = tmp + x1 * x2;
@@ -48,24 +47,21 @@ double dot(NumericVector lhs, NumericVector rhs)
4847
vector_t b(rhs.begin(), rhs.end());
4948

5049
// call dot function
51-
double result = simd_dot(
52-
&a[0],
53-
&a[0] + a.size(),
54-
&b[0]
55-
);
50+
double result = simd_dot(&a[0], &a[0] + a.size(), &b[0]);
5651

5752
return result;
5853
}
5954

6055
/*** R
61-
lhs <- rnorm(10)
62-
rhs <- rnorm(10)
56+
n <- 1024
57+
lhs <- rnorm(n)
58+
rhs <- rnorm(n)
6359
result <- dot(lhs, rhs)
6460
all.equal(result, sum(lhs * rhs))
6561
6662
library(microbenchmark)
67-
lhs <- rnorm(1024 * 1000)
68-
rhs <- rnorm(1024 * 1000)
63+
lhs <- rnorm(n * 1000)
64+
rhs <- rnorm(n * 1000)
6965
microbenchmark(
7066
simd = dot(lhs, rhs),
7167
R = sum(lhs * rhs)

0 commit comments

Comments
 (0)