Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ jobs:

test-stdBLAS:
runs-on: ubuntu-latest
container:
image: amklinv/mdspan-dependencies:latest
needs: build-stdblas

steps:
Expand Down
19 changes: 16 additions & 3 deletions examples/01_scale.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// Examples currently use parentheses (e.g., A(i,j))
// for the array access operator,
// instead of square brackets (e.g., A[i,j]).
// This must be defined before including any mdspan headers.
#define MDSPAN_USE_PAREN_OPERATOR 1

#include <experimental/linalg>

#include <iostream>
Expand All @@ -10,10 +16,14 @@
# include <execution>
#endif

// Make mdspan less verbose
using std::experimental::mdspan;
using std::experimental::extents;
using std::experimental::dynamic_extent;
#if defined(__cpp_lib_span)
#include <span>
using std::dynamic_extent;
#else
using std::experimental::dynamic_extent;
#endif

int main(int argc, char* argv[]) {
std::cout << "Scale" << std::endl;
Expand All @@ -23,7 +33,10 @@ int main(int argc, char* argv[]) {
std::vector<double> x_vec(N);

// Create and initialize mdspan
// With CTAD working we could do, GCC 11.1 works but some others are buggy
//
// With CTAD working we could do the following.
// GCC 11.1 works but some other compilers are buggy.
//
// mdspan x(x_vec.data(), N);
mdspan<double, extents<std::size_t, dynamic_extent>> x(x_vec.data(),N);
for(int i=0; i<x.extent(0); i++) x(i) = i;
Expand Down
14 changes: 12 additions & 2 deletions examples/02_matrix_vector_product_basic.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// Examples currently use parentheses (e.g., A(i,j))
// for the array access operator,
// instead of square brackets (e.g., A[i,j]).
// This must be defined before including any mdspan headers.
#define MDSPAN_USE_PAREN_OPERATOR 1

#include <experimental/linalg>

#include <iostream>
Expand All @@ -10,10 +16,14 @@
# include <execution>
#endif

// Make mdspan less verbose
using std::experimental::mdspan;
using std::experimental::extents;
using std::experimental::dynamic_extent;
#if defined(__cpp_lib_span)
#include <span>
using std::dynamic_extent;
#else
using std::experimental::dynamic_extent;
#endif

int main(int argc, char* argv[]) {
std::cout << "Matrix Vector Product Basic" << std::endl;
Expand Down
19 changes: 14 additions & 5 deletions examples/03_matrix_vector_product_mixedprec.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
// Examples currently use parentheses (e.g., A(i,j))
// for the array access operator,
// instead of square brackets (e.g., A[i,j]).
// This must be defined before including any mdspan headers.
#define MDSPAN_USE_PAREN_OPERATOR 1

#include <experimental/linalg>

#include <iostream>

// Make mdspan less verbose
using std::experimental::mdspan;
#if defined(__cpp_lib_span)
#include <span>
using std::dynamic_extent;
#else
using std::experimental::dynamic_extent;
#endif
using std::experimental::extents;
using std::experimental::dynamic_extent;
using std::full_extent; // not in experimental namespace
using std::experimental::mdspan;
using std::experimental::submdspan;
using std::experimental::full_extent;

int main(int argc, char* argv[]) {
std::cout << "Matrix Vector Product MixedPrec" << std::endl;
Expand Down Expand Up @@ -44,4 +54,3 @@ int main(int argc, char* argv[]) {
for(int i=0; i<y.extent(0); i+=5) std::cout << i << " " << y(i,1) << std::endl;
}
}

6 changes: 1 addition & 5 deletions tests/native/add.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
#include "gtest/gtest.h"
#include "./gtest_fixtures.hpp"

#include <experimental/linalg>
#include <experimental/mdspan>
#include <array>
#include <vector>

namespace {
using std::experimental::dynamic_extent;
using std::experimental::extents;
using std::experimental::mdspan;
using std::experimental::linalg::add;

TEST(BLAS1_add, vector_double)
Expand Down
8 changes: 1 addition & 7 deletions tests/native/conjugate_transposed.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
#include "gtest/gtest.h"
#include "./gtest_fixtures.hpp"

#include <experimental/linalg>
#include <experimental/mdspan>
#include <complex>
#include <vector>

namespace {
using std::experimental::dynamic_extent;
using std::experimental::extents;
using std::experimental::mdspan;
using std::experimental::linalg::conjugate_transposed;

TEST(conjugate_transposed, mdspan_complex_double)
Expand Down
9 changes: 1 addition & 8 deletions tests/native/conjugated.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
#include "gtest/gtest.h"
#include "./gtest_fixtures.hpp"

#include <experimental/linalg>
#include <experimental/mdspan>
#include <complex>
#include <vector>

namespace {
using std::experimental::dextents;
using std::experimental::dynamic_extent;
using std::experimental::extents;
using std::experimental::mdspan;
using std::experimental::linalg::conjugated;

template<class ValueType>
Expand Down
8 changes: 1 addition & 7 deletions tests/native/copy.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
#include "gtest/gtest.h"
#include "./gtest_fixtures.hpp"

#include <experimental/linalg>
#include <experimental/mdspan>
#include <complex>
#include <vector>

namespace {
using std::experimental::dynamic_extent;
using std::experimental::extents;
using std::experimental::mdspan;
using std::experimental::linalg::copy;

template<class Real>
Expand Down
7 changes: 1 addition & 6 deletions tests/native/dot.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#include "gtest/gtest.h"
#include "./gtest_fixtures.hpp"

#include <experimental/linalg>
#include <experimental/mdspan>
#include <vector>

// FIXME (mfh 2022/06/17) Temporarily disable calling the BLAS,
// to get PR testing workflow running with mdspan tag.
Expand All @@ -22,9 +20,6 @@ double ddot_wrapper (const int N, const double* DX,
#endif // 0

namespace {
using std::experimental::dynamic_extent;
using std::experimental::extents;
using std::experimental::mdspan;
using std::experimental::linalg::dot;
using std::experimental::linalg::dotc;

Expand Down
10 changes: 2 additions & 8 deletions tests/native/gemm.cpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
#include "gtest/gtest.h"
#include "./gtest_fixtures.hpp"

#include <experimental/linalg>
#include <experimental/mdspan>
#include <vector>
#include <iostream>

namespace {
using std::experimental::mdspan;
using std::experimental::dynamic_extent;
using std::experimental::extents;
using std::experimental::layout_left;
using std::experimental::linalg::explicit_diagonal;
using std::experimental::linalg::implicit_unit_diagonal;
using std::experimental::linalg::lower_triangle;
using std::experimental::linalg::matrix_product;
using std::experimental::linalg::scaled;
using std::experimental::linalg::scaled;
using std::experimental::linalg::transposed;
using std::experimental::linalg::upper_triangle;
using std::cout;
Expand Down
8 changes: 1 addition & 7 deletions tests/native/gemv.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
#include "gtest/gtest.h"
#include "./gtest_fixtures.hpp"

#include <experimental/linalg>
#include <experimental/mdspan>
#include <vector>
#include <iostream>

namespace {
using std::experimental::mdspan;
using std::experimental::dynamic_extent;
using std::experimental::extents;
using std::experimental::layout_left;
using std::experimental::linalg::matrix_vector_product;
using std::experimental::linalg::transposed;
using std::cout;
Expand Down
7 changes: 1 addition & 6 deletions tests/native/gemv_no_ambig.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#include "gtest/gtest.h"
#include "./gtest_fixtures.hpp"

#include <experimental/linalg>
#include <experimental/mdspan>
#include <vector>
#include <iostream>

#if (! defined(__GNUC__)) || (__GNUC__ > 9)
Expand All @@ -14,9 +12,6 @@

namespace {

using std::experimental::mdspan;
using std::experimental::extents;
using std::experimental::dynamic_extent;
using std::experimental::linalg::matrix_vector_product;
using std::experimental::linalg::scaled;

Expand Down
7 changes: 1 addition & 6 deletions tests/native/givens.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
#include "gtest/gtest.h"
#include "./gtest_fixtures.hpp"

#include <experimental/linalg>
#include <experimental/mdspan>
#include <limits>
#include <vector>

namespace {
using std::experimental::dynamic_extent;
using std::experimental::extents;
using std::experimental::mdspan;
using std::experimental::linalg::givens_rotation_setup;
using std::experimental::linalg::givens_rotation_apply;

Expand Down
33 changes: 26 additions & 7 deletions tests/native/gtest_fixtures.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,32 @@

#include "gtest/gtest.h"

// Tests currently use parentheses (e.g., A(i,j))
// for the array access operator,
// instead of square brackets (e.g., A[i,j]).
// This must be defined before including any mdspan headers.
#define MDSPAN_USE_PAREN_OPERATOR 1

#include <experimental/mdspan>
#include <complex>
#include <vector>

using std::experimental::default_accessor;
using std::dextents; // not in experimental namespace
#if defined(__cpp_lib_span)
#include <span>
using std::dynamic_extent;
#else
using std::experimental::dynamic_extent;
#endif
using std::experimental::extents;
using std::full_extent; // not in experimental namespace
using std::experimental::layout_left;
using std::experimental::layout_right;
using std::experimental::layout_stride;
using std::experimental::mdspan;
using std::experimental::submdspan;

using dbl_vector_t = mdspan<double, extents<std::size_t, dynamic_extent>>;
using cpx_vector_t = mdspan<std::complex<double>, extents<std::size_t, dynamic_extent>>;
constexpr ptrdiff_t NROWS(10);
Expand All @@ -64,8 +83,8 @@
storage(10),
v(storage.data(), 10)
{
v(0) = 0.5;
v(1) = 0.2;
v(0) = 0.5;
v(1) = 0.2;
v(2) = 0.1;
v(3) = 0.4;
v(4) = 0.8;
Expand All @@ -75,7 +94,7 @@
v(8) = 0.2;
v(9) = 0.9;
}

std::vector<double> storage;
dbl_vector_t v;
}; // end class unsigned_double_vector
Expand All @@ -88,8 +107,8 @@
storage(10),
v(storage.data(), 10)
{
v(0) = 0.5;
v(1) = 0.2;
v(0) = 0.5;
v(1) = 0.2;
v(2) = 0.1;
v(3) = 0.4;
v(4) = -0.8;
Expand All @@ -99,7 +118,7 @@
v(8) = 0.2;
v(9) = -0.9;
}

std::vector<double> storage;
dbl_vector_t v;
}; // end class signed_double_vector
Expand All @@ -119,7 +138,7 @@
v(3) = std::complex<double>(-0.3, 0.5);
v(4) = std::complex<double>( 0.2, -0.9);
}

std::vector<std::complex<double>> storage;
cpx_vector_t v;
}; // end class signed_double_vector
Expand Down
Loading