Skip to content

BLAS1 is pointless #5

@jeffhammond

Description

@jeffhammond

Instead of calling DAXPY, you can use STL like this to do the same thing:

      std::transform( std::begin(A), std::end(A), std::begin(C), std::begin(A),
                      [scalar](auto&& x, auto&& y) {
                           return x + scalar * y; // A[i] += scalar * C[i]
                      }
      );

You can use std::reduce, std::inner_product, and std::transform_reduce for inner products. I can write examples if you want.

The reason is that this is idiomatic C++, but also, having the code visible to the C++ compiler rather than via a BLAS library can make optimization better in some cases. There are also GPU implications I can discuss another time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions