Skip to content

Commit

Permalink
Refs #478,#482, Enable stack alloc for s/dgemv_t.(revert 9798491)
Browse files Browse the repository at this point in the history
  • Loading branch information
xianyi committed Apr 21, 2015
1 parent 9da555e commit 847e19c
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions interface/gemv.c
Expand Up @@ -212,21 +212,17 @@ void CNAME(enum CBLAS_ORDER order,
// make it volatile because some gemv implementation (ex: dgemv_n.S)
// 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
//for gemv_n and gemv_t, try to allocate on stack
stack_alloc_size = m + n;
if(stack_alloc_size < 128)
//dgemv_n.S require a 128 bytes buffer
stack_alloc_size = 128;

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;
}
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);
buffer = stack_alloc_size ? stack_buffer : (FLOAT *)blas_memory_alloc(1);
// printf("stack_alloc_size=%d\n", stack_alloc_size);
#else
//Original OpenBLAS/GotoBLAS codes.
Expand Down Expand Up @@ -262,7 +258,7 @@ void CNAME(enum CBLAS_ORDER order,

#ifdef MAX_STACK_ALLOC
if(!stack_alloc_size){
blas_memory_free_nolock(buffer);
blas_memory_free(buffer);
}
#else
blas_memory_free(buffer);
Expand Down

0 comments on commit 847e19c

Please sign in to comment.