Permalink
Browse files

Removed tabs

  • Loading branch information...
1 parent ce7eba9 commit 0db3438e8e5cc9a61d9d35ac0aace24e6ebb488d @ddemidov committed Nov 7, 2012
Showing with 6,053 additions and 6,017 deletions.
  1. +189 −187 examples/benchmark.cpp
  2. +40 −38 examples/cg.cpp
  3. +10 −8 examples/devlist.cpp
  4. +8 −6 examples/exclusive.cpp
  5. +15 −13 examples/symbolic.cpp
  6. +1,149 −1,147 examples/utests.cpp
  7. +39 −37 examples/vector.cpp
  8. +260 −258 vexcl/devlist.hpp
  9. +407 −405 vexcl/generator.hpp
  10. +568 −566 vexcl/multivector.hpp
  11. +742 −740 vexcl/operations.hpp
  12. +207 −205 vexcl/profiler.hpp
  13. +193 −191 vexcl/reduce.hpp
  14. +991 −989 vexcl/spmat.hpp
  15. +477 −475 vexcl/stencil.hpp
  16. +194 −192 vexcl/util.hpp
  17. +544 −542 vexcl/vector.hpp
  18. +20 −18 vexcl/vexcl.hpp
View
Oops, something went wrong.
View
@@ -9,12 +9,12 @@ typedef double real;
// Solve system of linear equations A u = f with conjugate gradients method.
// Input matrix is represented in CSR format (parameters row, col, and val).
void cg_gpu(
- const std::vector<size_t> &row, // Indices to col and val vectors.
- const std::vector<size_t> &col, // Column numbers of non-zero elements.
- const std::vector<real> &val, // Values of non-zero elements.
- const std::vector<real> &rhs, // Right-hand side.
- std::vector<real> &x // In: initial approximation; out: result.
- )
+ const std::vector<size_t> &row, // Indices to col and val vectors.
+ const std::vector<size_t> &col, // Column numbers of non-zero elements.
+ const std::vector<real> &val, // Values of non-zero elements.
+ const std::vector<real> &rhs, // Right-hand side.
+ std::vector<real> &x // In: initial approximation; out: result.
+ )
{
const size_t n = x.size();
@@ -37,23 +37,23 @@ void cg_gpu(
r = f - A * u;
for(uint iter = 0; max(fabs(r)) > 1e-8 && iter < n; iter++) {
- rho1 = sum(r * r);
+ rho1 = sum(r * r);
- if (iter == 0) {
- p = r;
- } else {
- real beta = rho1 / rho2;
- p = r + beta * p;
- }
+ if (iter == 0) {
+ p = r;
+ } else {
+ real beta = rho1 / rho2;
+ p = r + beta * p;
+ }
- q = A * p;
+ q = A * p;
- real alpha = rho1 / sum(p * q);
+ real alpha = rho1 / sum(p * q);
- u += alpha * p;
- r -= alpha * q;
+ u += alpha * p;
+ r -= alpha * q;
- rho2 = rho1;
+ rho2 = rho1;
}
// Get result to host.
@@ -77,24 +77,24 @@ int main() {
row.push_back(0);
for(size_t i = 0; i < n; i++) {
- if (i == 0 || i == n-1) {
- col.push_back(i);
- val.push_back(1);
- rhs.push_back(0);
- row.push_back(row.back() + 1);
- } else {
- col.push_back(i-1);
- val.push_back(-1/(h*h));
-
- col.push_back(i);
- val.push_back(2/(h*h));
-
- col.push_back(i+1);
- val.push_back(-1/(h*h));
-
- rhs.push_back(2);
- row.push_back(row.back() + 3);
- }
+ if (i == 0 || i == n-1) {
+ col.push_back(i);
+ val.push_back(1);
+ rhs.push_back(0);
+ row.push_back(row.back() + 1);
+ } else {
+ col.push_back(i-1);
+ val.push_back(-1/(h*h));
+
+ col.push_back(i);
+ val.push_back(2/(h*h));
+
+ col.push_back(i+1);
+ val.push_back(-1/(h*h));
+
+ rhs.push_back(2);
+ row.push_back(row.back() + 3);
+ }
}
std::vector<real> x(n, 0);
@@ -105,9 +105,11 @@ int main() {
// Compute actual residual.
double res = 0;
for(size_t i = 0; i < n; i++) {
- double y = i * h;
- res = std::max(res, fabs(x[i] - y * (1 - y)));
+ double y = i * h;
+ res = std::max(res, fabs(x[i] - y * (1 - y)));
}
std::cout << "res = " << res << std::endl;
}
+
+// vim: set et
View
@@ -6,13 +6,15 @@ int main() {
std::cout << "OpenCL devices:" << std::endl << std::endl;
auto dev = device_list(Filter::All);
for (auto d = dev.begin(); d != dev.end(); d++) {
- std::cout << " " << d->getInfo<CL_DEVICE_NAME>() << std::endl
- << " CL_PLATFORM_NAME = " << cl::Platform(d->getInfo<CL_DEVICE_PLATFORM>()).getInfo<CL_PLATFORM_NAME>() << std::endl
- << " CL_DEVICE_MAX_COMPUTE_UNITS = " << d->getInfo<CL_DEVICE_MAX_COMPUTE_UNITS>() << std::endl
- << " CL_DEVICE_HOST_UNIFIED_MEMORY = " << d->getInfo<CL_DEVICE_HOST_UNIFIED_MEMORY>() << std::endl
- << " CL_DEVICE_GLOBAL_MEM_SIZE = " << d->getInfo<CL_DEVICE_GLOBAL_MEM_SIZE>() << std::endl
- << " CL_DEVICE_LOCAL_MEM_SIZE = " << d->getInfo<CL_DEVICE_LOCAL_MEM_SIZE>() << std::endl
- << " CL_DEVICE_MAX_CLOCK_FREQUENCY = " << d->getInfo<CL_DEVICE_MAX_CLOCK_FREQUENCY>() << std::endl
- << std::endl;
+ std::cout << " " << d->getInfo<CL_DEVICE_NAME>() << std::endl
+ << " CL_PLATFORM_NAME = " << cl::Platform(d->getInfo<CL_DEVICE_PLATFORM>()).getInfo<CL_PLATFORM_NAME>() << std::endl
+ << " CL_DEVICE_MAX_COMPUTE_UNITS = " << d->getInfo<CL_DEVICE_MAX_COMPUTE_UNITS>() << std::endl
+ << " CL_DEVICE_HOST_UNIFIED_MEMORY = " << d->getInfo<CL_DEVICE_HOST_UNIFIED_MEMORY>() << std::endl
+ << " CL_DEVICE_GLOBAL_MEM_SIZE = " << d->getInfo<CL_DEVICE_GLOBAL_MEM_SIZE>() << std::endl
+ << " CL_DEVICE_LOCAL_MEM_SIZE = " << d->getInfo<CL_DEVICE_LOCAL_MEM_SIZE>() << std::endl
+ << " CL_DEVICE_MAX_CLOCK_FREQUENCY = " << d->getInfo<CL_DEVICE_MAX_CLOCK_FREQUENCY>() << std::endl
+ << std::endl;
}
}
+
+// vim: set et
@@ -6,12 +6,14 @@ int main() {
Context ctx( Filter::Exclusive(Filter::Env) );
if (ctx.size()) {
- std::cout
- << "Locked devices:" << std::endl
- << ctx << std::endl
- << "Press any key to exit: " << std::endl;
- std::cin.get();
+ std::cout
+ << "Locked devices:" << std::endl
+ << ctx << std::endl
+ << "Press any key to exit: " << std::endl;
+ std::cin.get();
} else {
- std::cout << "No available devices found." << std::endl;
+ std::cout << "No available devices found." << std::endl;
}
}
+
+// vim: set et
View
@@ -26,13 +26,13 @@ struct sys_func
const sym_value &R;
sys_func(value_type sigma, value_type b, const sym_value &R)
- : sigma(sigma), b(b), R(R) {}
+ : sigma(sigma), b(b), R(R) {}
void operator()( const sym_state &x , sym_state &dxdt , value_type t ) const
{
- dxdt[0] = sigma * (x[1] - x[0]);
- dxdt[1] = R * x[0] - x[1] - x[0] * x[2];
- dxdt[2] = x[0] * x[1] - b * x[2];
+ dxdt[0] = sigma * (x[1] - x[0]);
+ dxdt[1] = R * x[0] - x[1] - x[0] * x[2];
+ dxdt[2] = x[0] * x[1] - b * x[2];
}
};
@@ -55,9 +55,9 @@ int main( int argc , char **argv )
// State types that would become kernel parameters:
sym_state sym_S = {{
- sym_value::VectorParameter,
- sym_value::VectorParameter,
- sym_value::VectorParameter
+ sym_value::VectorParameter,
+ sym_value::VectorParameter,
+ sym_value::VectorParameter
}};
// Const kernel parameter.
@@ -74,16 +74,16 @@ int main( int argc , char **argv )
*/
// Symbolic stepper:
odeint::runge_kutta4<
- sym_state , value_type , sym_state , value_type ,
- odeint::range_algebra , odeint::default_operations
- > sym_stepper;
+ sym_state , value_type , sym_state , value_type ,
+ odeint::range_algebra , odeint::default_operations
+ > sym_stepper;
sys_func sys(10.0, 8.0 / 3.0, sym_R);
sym_stepper.do_step(std::ref(sys), sym_S, 0, dt);
auto kernel = vex::generator::build_kernel(ctx.queue(), "lorenz", body.str(),
- sym_S[0], sym_S[1], sym_S[2], sym_R
- );
+ sym_S[0], sym_S[1], sym_S[2], sym_R
+ );
// Real state initialization:
value_type Rmin = 0.1 , Rmax = 50.0 , dR = ( Rmax - Rmin ) / value_type( n - 1 );
@@ -101,9 +101,11 @@ int main( int argc , char **argv )
// Integration loop:
for(value_type t = 0; t < t_max; t += dt)
- kernel(X, Y, Z, R);
+ kernel(X, Y, Z, R);
std::vector< value_type > result( n );
vex::copy( X , result );
cout << result[0] << endl;
}
+
+// vim: set et
Oops, something went wrong.

0 comments on commit 0db3438

Please sign in to comment.