Skip to content

Commit

Permalink
Tests pass on Windows with MSVC
Browse files Browse the repository at this point in the history
  • Loading branch information
Pencilcaseman committed Aug 28, 2023
1 parent bcd8d0b commit 4938b00
Show file tree
Hide file tree
Showing 8 changed files with 170 additions and 125 deletions.
65 changes: 9 additions & 56 deletions .github/workflows/continuous-integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
- os: ubuntu-latest
cc: ../llvm/bin/clang
cxx: ../llvm/bin/clang++
clangVer: "15.0"
blas: off
fftw: off
mpfr: on
Expand All @@ -30,39 +31,13 @@ jobs:
- os: ubuntu-latest
cc: ../llvm/bin/clang
cxx: ../llvm/bin/clang++
clangVer: "15.0"
blas: on
fftw: on
mpfr: on
cpp: 20
pretty: "LibRapid_Ubuntu_Clang_C++20_BLAS_FFTW_MPFR"

- os: ubuntu-latest
cc: gcc-9
cxx: g++-9
blas: off
fftw: off
mpfr: on
cpp: 20
pretty: "LibRapid_Ubuntu_Clang_C++20_MPFR"

- os: ubuntu-latest
cc: gcc-9
cxx: g++-9
blas: on
fftw: on
mpfr: on
cpp: 20
pretty: "LibRapid_Ubuntu_Clang_C++20_BLAS_FFTW_MPFR"

- os: ubuntu-latest
cc: gcc-9
cxx: g++-9
blas: off
fftw: off
mpfr: on
cpp: 23
pretty: "LibRapid_Ubuntu_Clang_C++23_MPFR"

- os: ubuntu-latest
cc: gcc-9
cxx: g++-9
Expand Down Expand Up @@ -147,6 +122,7 @@ jobs:
- os: macos-latest
cc: ../llvm/bin/clang
cxx: ../llvm/bin/clang++
clangVer: "15.0"
blas: off
fftw: off
mpfr: on
Expand All @@ -156,6 +132,7 @@ jobs:
- os: macos-latest
cc: ../llvm/bin/clang
cxx: ../llvm/bin/clang++
clangVer: "15.0"
blas: on
fftw: on
mpfr: on
Expand Down Expand Up @@ -201,6 +178,7 @@ jobs:
- os: windows-latest
cc: ../llvm/clang
cxx: ../llvm/clang++
clangVer: "15.0"
blas: off
fftw: off
mpfr: on
Expand All @@ -210,6 +188,7 @@ jobs:
- os: windows-latest
cc: ../llvm/clang
cxx: ../llvm/clang++
clangVer: "15.0"
blas: on
fftw: on
mpfr: on
Expand All @@ -219,6 +198,7 @@ jobs:
- os: windows-latest
cc: ./llvm/clang
cxx: ./llvm/clang++
clangVer: "15.0"
blas: off
fftw: off
mpfr: on
Expand All @@ -228,6 +208,7 @@ jobs:
- os: windows-latest
cc: ./llvm/clang
cxx: ./llvm/clang++
clangVer: "15.0"
blas: on
fftw: on
mpfr: on
Expand Down Expand Up @@ -279,7 +260,7 @@ jobs:
- name: Install Clang
uses: KyleMayes/install-llvm-action@v1
with:
version: "15.0"
version: ${{ matrix.clangVer }}
directory: "./llvm"
env: on

Expand Down Expand Up @@ -318,34 +299,6 @@ jobs:
cd buildRelease
ctest -C Release --output-on-failure
# - name: Store Debug Build
# uses: actions/upload-artifact@v3
# with:
# name: ${{ matrix.pretty }}_Debug
# path: buildDebug

# - name: Store Release Build
# uses: actions/upload-artifact@v3
# with:
# name: ${{ matrix.pretty }}_Release
# path: buildRelease

# Zip debug build before uploading
# - name: Zip build results before uploading
# uses: vimtor/[email protected]
# continue-on-error: true
# with:
# files: ./buildDebug ./buildRelease
# recursive: true
# dest: ${{ matrix.pretty }}.zip

# - name: Store Build Artifacts
# uses: actions/upload-artifact@v3
# continue-on-error: true
# with:
# name: ${{ matrix.pretty }}
# path: ${{ matrix.pretty }}.zip

quodona:
name: Run Qodana
needs: compile
Expand Down
2 changes: 1 addition & 1 deletion librapid/include/librapid/array/arrayContainer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ namespace librapid {
LIBRAPID_ALWAYS_INLINE
ArrayContainer<ShapeType_, StorageType_>::ArrayContainer(const Scalar &value) :
m_shape(detail::shapeFromFixedStorage(m_storage)),
m_size(m_shape.size()), m_storage(m_size) {
m_size(m_shape.size()), m_storage(value) {
static_assert(typetraits::IsFixedStorage<StorageType_>::value,
"For a compile-time-defined shape, "
"the storage type must be "
Expand Down
6 changes: 2 additions & 4 deletions librapid/include/librapid/array/arrayFromData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ namespace librapid {
for (size_t i = 0; i < data.size(); ++i) {
LIBRAPID_ASSERT(data[i].size() == newShape[1],
"Arrays must have consistent shapes");
for (size_t j = 0; j < data[i].size(); ++j) {
res(i, j) = data[i][j];
}
for (size_t j = 0; j < data[i].size(); ++j) { res(i, j) = data[i][j]; }
}
return res;
} else {
Expand All @@ -90,7 +88,7 @@ namespace librapid {
LIBRAPID_ASSERT(data.size() > 0, "Cannot create a zero-sized array"); \
std::vector<ArrayContainer> tmp(data.size()); \
int64_t index = 0; \
for (const auto &item : data) tmp[index++] = fromData(item); \
for (const auto &item : data) tmp[index++] = std::move(fromData(item)); \
auto zeroShape = tmp[0].shape(); \
for (int64_t i = 0; i < data.size(); ++i) \
LIBRAPID_ASSERT(tmp[i].shape().operator==(zeroShape), \
Expand Down
11 changes: 5 additions & 6 deletions librapid/include/librapid/array/generalArrayView.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,9 @@ namespace librapid {
using Reference = BaseType &;
using ConstReference = const BaseType &;
using Backend = typename typetraits::TypeInfo<BaseType>::Backend;
using StrideType = Stride;
using ShapeType = ArrayViewShapeType;
using StrideType = Stride<ShapeType>;
using StorageType = typename typetraits::TypeInfo<BaseType>::StorageType;
// using ArrayType = Array<Scalar, Backend>;
using ArrayType = array::ArrayContainer<ShapeType, StorageType>;
using Iterator = detail::ArrayIterator<GeneralArrayView>;

Expand Down Expand Up @@ -226,9 +225,9 @@ namespace librapid {
const auto stride = Stride(m_shape);
view.setShape(m_shape.subshape(1, ndim()));
if (ndim() == 1)
view.setStride(Stride({1}));
view.setStride(Stride<Shape>({1}));
else
view.setStride(stride.subshape(1, ndim()));
view.setStride(stride.substride(1, ndim()));
view.setOffset(m_offset + index * stride[0]);
return view;
}
Expand All @@ -245,9 +244,9 @@ namespace librapid {
const auto stride = Stride(m_shape);
view.setShape(m_shape.subshape(1, ndim()));
if (ndim() == 1)
view.setStride(Stride({1}));
view.setStride(Stride<Shape>({1}));
else
view.setStride(stride.subshape(1, ndim()));
view.setStride(stride.substride(1, ndim()));
view.setOffset(m_offset + index * stride[0]);
return view;
}
Expand Down
29 changes: 14 additions & 15 deletions librapid/include/librapid/array/shape.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ namespace librapid {
/// Return a Shape object with \p dims dimensions, all initialized to zero.
/// \param dims Number of dimensions
/// \return New Shape object
LIBRAPID_ALWAYS_INLINE static auto zeros(size_t dims) -> Shape;
LIBRAPID_ALWAYS_INLINE static auto zeros(int dims) -> Shape;

/// Return a Shape object with \p dims dimensions, all initialized to one.
/// \param dims Number of dimensions
/// \return New Shape object
LIBRAPID_ALWAYS_INLINE static auto ones(size_t dims) -> Shape;
LIBRAPID_ALWAYS_INLINE static auto ones(int dims) -> Shape;

/// Access an element of the Shape object
/// \tparam Index Typename of the index
Expand Down Expand Up @@ -127,8 +127,7 @@ namespace librapid {
/// \param start Starting index
/// \param end Ending index
/// \return Subshape
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto subshape(size_t start, size_t end) const
-> Shape;
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto subshape(int start, int end) const -> Shape;

/// Return the number of elements the Shape object represents
/// \return Number of elements
Expand All @@ -144,7 +143,8 @@ namespace librapid {

class MatrixShape {
public:
using SizeType = uint32_t;
using SizeType = uint32_t;
static constexpr size_t MaxDimensions = 2;

LIBRAPID_ALWAYS_INLINE MatrixShape() = default;

Expand Down Expand Up @@ -190,8 +190,7 @@ namespace librapid {

LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE constexpr auto ndim() const -> int;

LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto subshape(size_t start, size_t end) const
-> Shape;
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto subshape(int start, int end) const -> Shape;

LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto size() const -> size_t;

Expand All @@ -205,7 +204,8 @@ namespace librapid {

class VectorShape {
public:
using SizeType = uint32_t;
using SizeType = uint32_t;
static constexpr size_t MaxDimensions = 1;

LIBRAPID_ALWAYS_INLINE VectorShape() = default;

Expand Down Expand Up @@ -251,8 +251,7 @@ namespace librapid {

LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE constexpr auto ndim() const -> int;

LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto subshape(size_t start, size_t end) const
-> Shape;
LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto subshape(int start, int end) const -> Shape;

LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto size() const -> size_t;

Expand Down Expand Up @@ -310,14 +309,14 @@ namespace librapid {
return *this;
}

LIBRAPID_ALWAYS_INLINE auto Shape::zeros(size_t dims) -> Shape {
LIBRAPID_ALWAYS_INLINE auto Shape::zeros(int dims) -> Shape {
Shape res;
res.m_dims = dims;
for (size_t i = 0; i < dims; ++i) res.m_data[i] = 0;
return res;
}

LIBRAPID_ALWAYS_INLINE auto Shape::ones(size_t dims) -> Shape {
LIBRAPID_ALWAYS_INLINE auto Shape::ones(int dims) -> Shape {
Shape res;
res.m_dims = dims;
for (size_t i = 0; i < dims; ++i) res.m_data[i] = 1;
Expand Down Expand Up @@ -355,7 +354,7 @@ namespace librapid {

LIBRAPID_NODISCARD auto Shape::ndim() const -> int { return m_dims; }

LIBRAPID_NODISCARD auto Shape::subshape(size_t start, size_t end) const -> Shape {
LIBRAPID_NODISCARD auto Shape::subshape(int start, int end) const -> Shape {
LIBRAPID_ASSERT(start <= end, "Start index must be less than end index");
LIBRAPID_ASSERT(end <= m_dims,
"End index must be less than or equal to the number of dimensions");
Expand Down Expand Up @@ -498,7 +497,7 @@ namespace librapid {

LIBRAPID_ALWAYS_INLINE constexpr auto MatrixShape::ndim() const -> int { return 2; }

LIBRAPID_ALWAYS_INLINE auto MatrixShape::subshape(size_t start, size_t end) const -> Shape {
LIBRAPID_ALWAYS_INLINE auto MatrixShape::subshape(int start, int end) const -> Shape {
LIBRAPID_ASSERT(start <= end, "Start index must be less than end index");
LIBRAPID_ASSERT(end <= 2,
"End index must be less than or equal to the number of dimensions");
Expand Down Expand Up @@ -592,7 +591,7 @@ namespace librapid {

LIBRAPID_ALWAYS_INLINE constexpr auto VectorShape::ndim() const -> int { return 1; }

LIBRAPID_ALWAYS_INLINE auto VectorShape::subshape(size_t start, size_t end) const -> Shape {
LIBRAPID_ALWAYS_INLINE auto VectorShape::subshape(int start, int end) const -> Shape {
LIBRAPID_ASSERT(start <= end, "Start index must be less than end index");
LIBRAPID_ASSERT(end <= 1,
"End index must be less than or equal to the number of dimensions");
Expand Down
Loading

0 comments on commit 4938b00

Please sign in to comment.