Skip to content
Open
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
53 changes: 53 additions & 0 deletions .github/workflows/builtin-blas-macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: builtin-blas-macos
on:
pull_request:
workflow_dispatch:

jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2

- name: configure OS
run: |
# os level stuff
set -x
brew install googletest

- name: install Random123
run: |
cd ..
git clone https://github.com/DEShawResearch/Random123.git
cd Random123/
mkdir -p `pwd`/../Random123-install/include
cp -rp include/Random123 `pwd`/../Random123-install/include/

- name: build and test RandBLAS (release)
run: |
cd ..
mkdir RandBLAS-build
cd RandBLAS-build
cmake -DCMAKE_BUILD_TYPE=Release \
-DRandBLAS_BLAS_BACKEND=builtin \
-DRandom123_DIR=`pwd`/../Random123-install/include/ \
-DCMAKE_INSTALL_PREFIX=`pwd`/../RandBLAS-install \
-DCMAKE_BINARY_DIR=`pwd` \
`pwd`/../RandBLAS
make -j2 install
ctest --output-on-failure

- name: build and test RandBLAS (Debug/asan)
run: |
cd ..
mkdir RandBLAS-asan-build
cd RandBLAS-asan-build
cmake -DCMAKE_BUILD_TYPE=Debug \
-DSANITIZE_ADDRESS=ON \
-DRandBLAS_BLAS_BACKEND=builtin \
-DRandom123_DIR=`pwd`/../Random123-install/include/ \
-DCMAKE_INSTALL_PREFIX=`pwd`/../RandBLAS-install \
-DCMAKE_BINARY_DIR=`pwd` \
`pwd`/../RandBLAS
make -j2 install
ctest --output-on-failure
7 changes: 7 additions & 0 deletions CMake/MKL_sparse.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ features while still using MKL through BLAS++." ON)

message(STATUS "Checking for MKL sparse BLAS ...")

if (NOT RandBLAS_HAS_BLASPP)
message(STATUS " Disabled: builtin BLAS backend does not support MKL sparse")
set(RandBLAS_HAS_MKL FALSE CACHE BOOL "Set if MKL sparse BLAS is available" FORCE)
message(STATUS "Checking for MKL sparse BLAS ... ${RandBLAS_HAS_MKL}")
return()
endif()

if (NOT RandBLAS_USE_MKL_SPARSE)
message(STATUS " Disabled by user (RandBLAS_USE_MKL_SPARSE=OFF)")
set(RandBLAS_HAS_MKL FALSE CACHE BOOL "Set if MKL sparse BLAS is available" FORCE)
Expand Down
11 changes: 7 additions & 4 deletions CMake/RandBLASConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ set(RandBLAS_VERSION_PATCH "@RandBLAS_VERSION_PATCH@")
set(RandBLAS_COMMITS_SINCE_RELEASE "@RandBLAS_COMMITS_SINCE_RELEASE@")
set(RandBLAS_COMMIT_HASH "@RandBLAS_COMMIT_HASH@")

# BLAS++
if (NOT blaspp_DIR)
set(blaspp_DIR @blaspp_DIR@)
# BLAS backend
set(RandBLAS_HAS_BLASPP @RandBLAS_HAS_BLASPP@)
if (RandBLAS_HAS_BLASPP)
if (NOT blaspp_DIR)
set(blaspp_DIR @blaspp_DIR@)
endif ()
find_dependency(blaspp)
endif ()
find_dependency(blaspp)

# Random123
if (NOT Random123_DIR)
Expand Down
18 changes: 17 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,24 @@ enable_testing()
include(rb_build_options)
include(rb_version)

# Select BLAS backend
set(RandBLAS_BLAS_BACKEND "blaspp" CACHE STRING
"BLAS backend: 'blaspp' (requires BLAS++) or 'builtin' (RandBLAS built-in)")
set_property(CACHE RandBLAS_BLAS_BACKEND PROPERTY STRINGS blaspp builtin)

# find dependencies
find_package(blaspp REQUIRED)
if(RandBLAS_BLAS_BACKEND STREQUAL "blaspp")
find_package(blaspp REQUIRED)
set(RandBLAS_HAS_BLASPP TRUE CACHE BOOL "Set if using BLAS++ backend" FORCE)
message(STATUS "BLAS backend: blaspp")
elseif(RandBLAS_BLAS_BACKEND STREQUAL "builtin")
set(RandBLAS_HAS_BLASPP FALSE CACHE BOOL "Set if using BLAS++ backend" FORCE)
message(STATUS "BLAS backend: builtin (RandBLAS built-in)")
else()
message(FATAL_ERROR "Unknown RandBLAS_BLAS_BACKEND='${RandBLAS_BLAS_BACKEND}'. "
"Valid values: blaspp, builtin")
endif()

find_package(Random123 REQUIRED)
#include(Random123)
include(OpenMP)
Expand Down
14 changes: 0 additions & 14 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,6 @@ make -j install # might need "sudo make -j install"
ctest # run unit tests (only if GTest was found by CMake)
```

If you're running macOS, then it may be necessary to specify
an additional flag to CMake
```shell
-DCMAKE_CXX_FLAGS="-D __APPLE__"
```
This flag is needed to avoid compiler errors with the "sincosf" and "sincos"
functions in "random_gen.hh".

Here are the conceptual meanings of the recipe's other build flags:

* `-Dblaspp_DIR=X` means `X` is the directory containing the file `blasppConfig.cmake`.
Expand Down Expand Up @@ -160,9 +152,3 @@ If performance matters to you then you should inspect the
information that's printed to screen when you run ``cmake`` for the BLAS++ installation.
Save that information somewhere while you're setting up your RandBLAS
development environment.

[An earlier version](https://github.com/BallisticLA/RandBLAS/blob/9d0a03fa41fd7c126b252002a54c2f2562fae31a/INSTALL.md#5-tips)
of this installation guide had specific recommendations for configuring BLAS++ and LAPACK++ on Intel machines.
Those recommendations may be useful to you if you're having a hard time getting these libraries setup correctly.
We removed those recommendations from this guide, since they encouraged a somewhat bad practice of installing BLAS++
and LAPACK++ to a system-wide location (under ``/opt/``) instead of a location that's used for one project.
5 changes: 4 additions & 1 deletion RandBLAS/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@

set(RandBLAS_libs blaspp Random123)
set(RandBLAS_libs Random123)
if (RandBLAS_HAS_BLASPP)
list(PREPEND RandBLAS_libs blaspp)
endif()
if (RandBLAS_HAS_OpenMP)
list(APPEND RandBLAS_libs OpenMP::OpenMP_CXX)
endif()
Expand Down
5 changes: 2 additions & 3 deletions RandBLAS/base.hh
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,17 @@
#include "RandBLAS/config.h"
#include "RandBLAS/random_gen.hh"

#include <blas.hh>
#include "RandBLAS/blas_facade.hh"
#include <utility>
#include <cstring>
#include <cstdint>
#include <iostream>
#include <sstream>

#if defined(RandBLAS_HAS_OpenMP)
#include <omp.h>
#endif

#include<iostream>


/// code common across the project
namespace RandBLAS {
Expand Down
45 changes: 45 additions & 0 deletions RandBLAS/blas_backend/builtin.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright, 2024. See LICENSE for copyright holder information.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// (1) Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// (2) Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// (3) Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.

#pragma once

/// @file
///
/// Aggregating header for RandBLAS' built-in blas:: implementations.
/// Provides the enumerations and routines used by RandBLAS when BLAS++ is
/// not available:
/// Enumerations: Layout, Op, Uplo, Diag, Side
/// Level 1: scal, copy, axpy, dot, nrm2
/// Level 2: gemv, ger
/// Level 3: gemm, syrk, symm, trmm, trsm

#include "RandBLAS/blas_backend/enums.hh"
#include "RandBLAS/blas_backend/level1.hh"
#include "RandBLAS/blas_backend/gemm.hh"
#include "RandBLAS/blas_backend/level2.hh"
#include "RandBLAS/blas_backend/level3.hh"
49 changes: 49 additions & 0 deletions RandBLAS/blas_backend/enums.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright, 2024. See LICENSE for copyright holder information.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// (1) Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// (2) Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// (3) Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.

#pragma once

/// @file
///
/// blas:: enum types used by RandBLAS' built-in BLAS backend.
/// Values match BLAS++ and standard CBLAS character codes, so code compiled
/// with either backend agrees on the underlying representation.

namespace blas {

// ---------------------------------------------------------------------------
// Enumerations (values match BLAS++ / standard CBLAS character codes)
// ---------------------------------------------------------------------------

enum class Layout : char { ColMajor = 'C', RowMajor = 'R' };
enum class Op : char { NoTrans = 'N', Trans = 'T', ConjTrans = 'C' };
enum class Uplo : char { Upper = 'U', Lower = 'L' };
enum class Diag : char { NonUnit = 'N', Unit = 'U' };
enum class Side : char { Left = 'L', Right = 'R' };

} // namespace blas
Loading
Loading