Skip to content

Commit

Permalink
don't use cblas anymore, but the same blas interface as plearn.
Browse files Browse the repository at this point in the history
  • Loading branch information
nouiz committed Jul 7, 2009
1 parent f176ec4 commit 48f7a12
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
12 changes: 10 additions & 2 deletions speedtest/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ CFLAGS=-Wall -fPIC -O3
LIBCBLAS=~bastienf/.NOBACKUP/CBLAS/lib/${OSARCH}/libcblas.a

LIBBLAS=-lblas ${LIBCBLAS}
LIBGOTO=-lgoto -lgfortran ${LIBCBLAS}
#LIBGOTO=-lgoto -lgfortran ${LIBCBLAS}
LIBGOTO=-lgoto -lgfortran -I~/PLearn
LIBATLAS=-lcblas -lf77blas -latlas -lg2c
LIBMKL=-lmkl -lvml ${LIBCBLAS}
LIBMKLPT=-lmkl -lvml -lguide -lpthread ${LIBCBLAS}
Expand All @@ -12,7 +13,8 @@ ACMLBASE=/u/lisa/local/acml-3-6-1beta/gfortran64
ACMLBASE=/u/lisa/local/acml-3-6-0/gfortran32
LIBACML= ${LIBCBLAS} ${ACMLBASE}/lib/libacml.a -lgfortran
LIBACMLPT= ${LIBCBLAS} ${ACMLBASE}_mp/lib/libacml_mp.a -lg2c -lgfortran
LIBNVIDIA=-L/u/bastienf/NVIDIA_CUDA_SDK/cuda/lib -L/u/bastienf/NVIDIA_CUDA_SDK/lib/ -I/u/bastienf/NVIDIA_CUDA_SDK/cuda/include/ -lcuda -lcudart -lGL -lGLU -lcublas -l cutil
LIBNVIDIA=-L/u/bastienf/NVIDIA_CUDA_SDK/cuda/lib -L/u/bastienf/NVIDIA_CUDA_SDK/lib/ -I/u/bastienf/NVIDIA_CUDA_SDK/cuda/include/ -lcuda -lcudart -lGL -lGLU -lcublas
#-l cutil

all: xgemm

Expand Down Expand Up @@ -85,6 +87,12 @@ xgemm-sgemm-nvidia: xgemm.c
xgemm-sgemm-nvidia-compare: xgemm.c
${CC} ${CFLAGS} -m32 -o $@ -DUSEFLOAT $< ${LIBNVIDIA} -DNVIDIA -DCOMPARE

xgemm-sgemm-nvidia-64: xgemm.c
${CC} ${CFLAGS} -m64 -o $@ -DUSEFLOAT $< ${LIBNVIDIA} -DNVIDIA

xgemm-sgemm-nvidia-compare-64: xgemm.c
${CC} ${CFLAGS} -m64 -o $@ -DUSEFLOAT $< ${LIBNVIDIA} -DNVIDIA -DCOMPARE

xgemv: xgemv-blas xgemv-blas-compare xgemv-cxgemm xgemv-goto xgemv-goto-compare xgemv-nvidia xgemv-nvidia-compare xgemv-sgemv-goto xgemv-dgemv-goto xgemv-sgemv-blas xgemv-dgemv-blas
true

Expand Down
21 changes: 12 additions & 9 deletions speedtest/xgemm.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@
/* Includes, cuda */
#include <cublas.h>
#else
/* Includes, cblas */
#include <gsl/gsl_cblas.h>
#include <plearn/math/blas_proto.h>
#endif
#ifdef USEDOUBLE
typedef double real;
#define cblas_xgemm cblas_dgemm
// typedef double real;
#define real double
#define xgemm_ dgemm_
#elif USEFLOAT
typedef float real;
#define cblas_xgemm cblas_sgemm
// typedef float real;
#define real float
#define xgemm_ sgemm_
#else
#error "USEDOUBLE or USEFLOAT must be defined"
#endif
Expand All @@ -34,7 +35,7 @@ static void c_xgemm(int M, int N, int K, const real alpha, const real *A,
int k;
for (i = 0; i < M; ++i) {
for (j = 0; j < N; ++j) {
float prod = 0;
real prod = 0;
for (k = 0; k < K; ++k) {
prod += A[i * K + k] * B[k * N + j];
}
Expand Down Expand Up @@ -146,7 +147,7 @@ int main(int argc, char** argv)
c_xgemm(M,N,K, alpha, h_A, h_B, beta, h_C);
h_C_ref = h_C;
/* Allocate host memory for reading back the result from device memory */
h_C = (float*)malloc(NC * sizeof(h_C[0]));
h_C = (real*)malloc(NC * sizeof(h_C[0]));
if (h_C == 0) {
fprintf (stderr, "!!!! host memory allocation error (C)\n");
return EXIT_FAILURE;
Expand Down Expand Up @@ -174,8 +175,10 @@ int main(int argc, char** argv)
for (int i=0;i<NBITER;i++)
c_xgemm(M,N,K, alpha, h_A, h_B, beta, h_C);
#else
char transa='N', transb='N';
for (int i=0;i<NBITER;i++)
cblas_xgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, M,N,K, alpha, h_A, K, h_B, N, beta, h_C, N);
sgemm_(&transb, &transa, &N, &M, &K, &alpha, h_B, &N, h_A, &K, &beta, h_C, &N);

#endif
#ifdef COMPARE
/* Check result against reference */
Expand Down

0 comments on commit 48f7a12

Please sign in to comment.