|
1 | 1 | # hipBLAS |
2 | | -hipBLAS is a BLAS marshalling library, with multiple supported backends. It sits between the application and a 'worker' BLAS library, marshalling inputs into the backend library and marshalling results back to the application. hipBLAS exports an interface that does not require the client to change, regardless of the chosen backend. Currently, hipBLAS supports [rocBLAS](https://github.com/ROCmSoftwarePlatform/rocBLAS) and [cuBLAS](https://developer.nvidia.com/cublas) as backends. |
| 2 | +hipBLAS is a BLAS marshalling library, with multiple supported backends. It sits between the application and a 'worker' BLAS library, marshalling inputs into the backend library and marshalling results back to the application. hipBLAS exports an interface that does not require the client to change, regardless of the chosen backend. Currently, hipBLAS supports [hipBLAS](https://github.com/ROCmSoftwarePlatform/hipBLAS) and [cuBLAS](https://developer.nvidia.com/cublas) as backends. |
| 3 | + |
| 4 | +## Installing pre-built packages |
| 5 | +Download pre-built packages either from [ROCm's package servers](https://rocm.github.io/install.html#installing-from-amd-rocm-repositories) or by clicking the github releases tab and manually downloading, which could be newer. Release notes are available for each release on the releases tab. |
| 6 | +* `sudo apt update && sudo apt install hipblas` |
| 7 | + |
| 8 | +## Quickstart hipBLAS build |
3 | 9 |
|
4 | | -## Building hipBLAS |
5 | 10 | #### Bash helper build script (Ubuntu only) |
6 | 11 | The root of this repository has a helper bash script `install.sh` to build and install hipBLAS on Ubuntu with a single command. It does not take a lot of options and hard-codes configuration that can be specified through invoking cmake directly, but it's a great way to get started quickly and can serve as an example of how to build/install. A few commands in the script need sudo access, so it may prompt you for a password. |
7 | 12 | * `./install -h` -- shows help |
8 | | -* `./install -id` -- common invocation (installs dependencies, builds and installs library) |
9 | | - |
10 | | -### Manual build (all supported platforms) |
11 | | -The build infrastructure for hipBLAS is based on [Cmake](https://cmake.org/) v3.5. This is the version of cmake available on ROCm supported platforms. Examples of installing cmake: |
12 | | -* Ubuntu: `sudo apt install cmake-qt-gui` |
13 | | -* Fedora: `sudo dnf install cmake-gui` |
14 | | - |
15 | | -### Library |
16 | | -If building the library on a ROCm platform, hipBLAS depends on a rocBLAS installation to be found. If building the library on a CUDA platform, hipBLAS depends on cuBLAS to be found. If cmake cannot find these dependencies automatically, the user can specify additional search locations through the CMAKE\_PREFIX\_PATH cmake configuration variable |
17 | | - |
18 | | -#### Configure and build steps |
19 | | -```bash |
20 | | -mkdir -p [HIPBLAS_BUILD_DIR]/release |
21 | | -cd [HIPBLAS_BUILD_DIR]/release |
22 | | -# Default install location is in /opt/rocm, define -DCMAKE_INSTALL_PREFIX=<path> to specify other |
23 | | -# Default build config is 'Release', define -DCMAKE_BUILD_TYPE=<config> to specify other |
24 | | -CXX=/opt/rocm/bin/hcc ccmake [HIPBLAS_SOURCE] |
25 | | -make -j$(nproc) |
26 | | -sudo make install # sudo required if installing into system directory such as /opt/rocm |
27 | | -``` |
| 13 | +* `./install -id` -- build library, build dependencies and install (-d flag only needs to be passed once on a system) |
28 | 14 |
|
29 | | -### hipBLAS clients |
30 | | -The repository contains source for a unit testing framework, which can be found in the clients subdir. |
| 15 | +## Manual build (all supported platforms) |
| 16 | +If you use a distro other than Ubuntu, or would like more control over the build process, the [hipblas build wiki](https://github.com/RadeonOpenCompute/hipBLAS/wiki/Build) has helpful information on how to configure cmake and manually build. |
31 | 17 |
|
32 | | -### Dependencies (only necessary for hipBLAS clients) |
33 | | -The hipBLAS unit tester introduces the following dependencies: |
34 | | -1. [boost](http://www.boost.org/) |
35 | | -2. [lapack](https://github.com/Reference-LAPACK/lapack-release) |
36 | | - * lapack itself brings a dependency on a fortran compiler |
37 | | -3. [googletest](https://github.com/google/googletest) |
| 18 | +### Functions supported |
| 19 | +A list of [exported functions](https://github.com/RadeonOpenCompute/hipBLAS/wiki/exported-functions) from hipblas can be found on the wiki |
38 | 20 |
|
39 | | -Linux distros typically have an easy installation mechanism for boost through the native package manager. |
| 21 | +## hipBLAS interface examples |
| 22 | +The hipBLAS interface is compatible with rocBLAS and cuBLAS-v2 APIs. Porting a CUDA application which originally calls the cuBLAS API to an application calling hipBLAS API should be relatively straightforward. For example, the hipBLAS SGEMV interface is |
40 | 23 |
|
41 | | -* Ubuntu: `sudo apt install libboost-program-options-dev` |
42 | | -* Fedora: `sudo dnf install boost-program-options` |
| 24 | +### GEMV API |
43 | 25 |
|
44 | | -Unfortunately, googletest and lapack are not as easy to install. Many distros do not provide a googletest package with pre-compiled libraries, and the lapack packages do not have the necessary cmake config files for cmake to configure linking the cblas library. hipBLAS provide a cmake script that builds the above dependencies from source. This is an optional step; users can provide their own builds of these dependencies and help cmake find them by setting the CMAKE\_PREFIX\_PATH definition. The following is a sequence of steps to build dependencies and install them to the cmake default /usr/local. |
45 | | - |
46 | | -#### (optional, one time only) |
47 | | -```bash |
48 | | -mkdir -p [ROCBLAS_BUILD_DIR]/release/deps |
49 | | -cd [ROCBLAS_BUILD_DIR]/release/deps |
50 | | -ccmake -DBUILD_BOOST=OFF [ROCBLAS_SOURCE]/deps # assuming boost is installed through package manager as above |
51 | | -make -j$(nproc) install |
| 26 | +```c |
| 27 | +hipblasStatus_t |
| 28 | +hipblasSgemv( hipblasHandle_t handle, |
| 29 | + hipblasOperation_t trans, |
| 30 | + int m, int n, const float *alpha, |
| 31 | + const float *A, int lda, |
| 32 | + const float *x, int incx, const float *beta, |
| 33 | + float *y, int incy ); |
52 | 34 | ``` |
53 | 35 |
|
54 | | -Once dependencies are available on the system, it is possible to configure the clients to build. This requires a few extra cmake flags to the library cmake configure script. If the dependencies are not installed into system defaults (like /usr/local ), you should pass the CMAKE\_PREFIX\_PATH to cmake to help find them. |
55 | | -* `-DCMAKE_PREFIX_PATH="<semicolon separated paths>"` |
56 | | -```bash |
57 | | -# Default install location is in /opt/rocm, use -DCMAKE_INSTALL_PREFIX=<path> to specify other |
58 | | -CXX=/opt/rocm/bin/hcc ccmake -DBUILD_CLIENTS_TESTS=ON -DBUILD_CLIENTS_BENCHMARKS=ON [ROCBLAS_SOURCE] |
59 | | -make -j$(nproc) |
60 | | -sudo make install # sudo required if installing into system directory such as /opt/rocm |
| 36 | +### Batched and strided GEMM API |
| 37 | +hipBLAS GEMM can process matrices in batches with regular strides. There are several permutations of these API's, the |
| 38 | +following is an example that takes everything |
| 39 | +
|
| 40 | +```c |
| 41 | +hipblasStatus_t |
| 42 | +hipblasSgemmStridedBatched( hipblasHandle_t handle, |
| 43 | + hipblasOperation_t transa, hipblasOperation_t transb, |
| 44 | + int m, int n, int k, const float *alpha, |
| 45 | + const float *A, int lda, long long bsa, |
| 46 | + const float *B, int ldb, long long bsb, const float *beta, |
| 47 | + float *C, int ldc, long long bsc, |
| 48 | + int batchCount); |
61 | 49 | ``` |
| 50 | + |
| 51 | +hipBLAS assumes matrices A and vectors x, y are allocated in GPU memory space filled with data. Users are |
| 52 | +responsible for copying data from/to the host and device memory. |
0 commit comments