Skip to content

Commit

Permalink
Refs #478, #482. Fixed bug on previous commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
xianyi committed Apr 14, 2015
1 parent 9798481 commit fd9fd42
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions interface/gemv.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ void CNAME(enum CBLAS_ORDER order,
}

#endif

//printf("m=%d, n=%d, trans=%d, incx=%d, incy=%d, alpha=%f, beta=%f\n", m, n, trans, incx, incy, alpha, beta);
if ((m==0) || (n==0)) return;

lenx = n;
Expand All @@ -213,20 +213,21 @@ void CNAME(enum CBLAS_ORDER order,
// do not restore all register
volatile int stack_alloc_size = 0;
if (trans == 0) {
//for gemv_n, try to allocate on stack
//for gemv_t, use malloc

stack_alloc_size = m + n;
if(stack_alloc_size < 128)
//dgemv_n.S require a 128 bytes buffer
stack_alloc_size = 128;

if(stack_alloc_size > MAX_STACK_ALLOC / sizeof(FLOAT))
stack_alloc_size = 0;
FLOAT stack_buffer[stack_alloc_size];
buffer = stack_alloc_size ? stack_buffer : (FLOAT *)blas_memory_alloc_nolock(1);

}else{
//for gemv_t, only malloc
buffer = (FLOAT *)blas_memory_alloc_nolock(1);
}

FLOAT stack_buffer[stack_alloc_size];
buffer = stack_alloc_size ? stack_buffer : (FLOAT *)blas_memory_alloc_nolock(1);
// printf("stack_alloc_size=%d\n", stack_alloc_size);
#else
//Original OpenBLAS/GotoBLAS codes.
buffer = (FLOAT *)blas_memory_alloc(1);
Expand Down

0 comments on commit fd9fd42

Please sign in to comment.