To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit 17ee0544 authored by Donjan Rodic's avatar Donjan Rodic
Browse files

examples ordering

parent ab56a7ce
CC = g++
CFLAGS = -std=c++14 -Wall -Wextra -Wpedantic
CFLAGS += -O3 -march=native
LIBS = -lopenblas
.PHONY: all
all: blastest
blastest: blastest.cpp
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
// on euler, we load BLAS with
// module load openblas
#include <iostream>
#include <cblas.h>
// print row-major matrix
template<typename T>
void print_matrix(T mp, size_t n) {
for(size_t i = 0; i < n; ++i) {
for(size_t j = 0; j < n; ++j)
std::cout << ' ' << mp[i*n+j];
std::cout << std::endl;
}
}
int main() {
const int n = 2;
const int N = n*n;
using real_t = double;
real_t * A = new real_t[N],
* B = new real_t[N],
* C = new real_t[N];
for(size_t i = 0; i < N; ++i) {
A[i] = 1;
B[i] = i;
}
std::cout << "A=" << std::endl;
print_matrix(A, n);
std::cout << "B=" << std::endl;
print_matrix(B, n);
cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans,
n, n, n, 1.0, A, n, B, n, 1.0, C, n);
std::cout << "C=" << std::endl;
print_matrix(C, n);
delete[] A;
delete[] B;
delete[] C;
return 0;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment