Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Makefile.system
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,10 @@ ifdef SANITY_CHECK
CCOMMON_OPT += -DSANITY_CHECK -DREFNAME=$(*F)f$(BU)
endif

ifdef MAX_STACK_ALLOC
CCOMMON_OPT += -DMAX_STACK_ALLOC=$(MAX_STACK_ALLOC)
endif

#
# Architecture dependent settings
#
Expand Down
16 changes: 15 additions & 1 deletion interface/gemv.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,18 @@ void CNAME(enum CBLAS_ORDER order,
if (incx < 0) x -= (lenx - 1) * incx;
if (incy < 0) y -= (leny - 1) * incy;

#ifdef MAX_STACK_ALLOC
int 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(1);
#else
buffer = (FLOAT *)blas_memory_alloc(1);
#endif

#ifdef SMP

Expand Down Expand Up @@ -237,7 +248,10 @@ void CNAME(enum CBLAS_ORDER order,
}
#endif

blas_memory_free(buffer);
#ifdef MAX_STACK_ALLOC
if(!stack_alloc_size)
#endif
blas_memory_free(buffer);

FUNCTION_PROFILE_END(1, m * n + m + n, 2 * m * n);

Expand Down
13 changes: 12 additions & 1 deletion interface/ger.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,15 @@ void CNAME(enum CBLAS_ORDER order,
if (incy < 0) y -= (n - 1) * incy;
if (incx < 0) x -= (m - 1) * incx;

#ifdef MAX_STACK_ALLOC
int stack_alloc_size = m;
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(1);
#else
buffer = (FLOAT *)blas_memory_alloc(1);
#endif

#ifdef SMPTEST
nthreads = num_cpu_avail(2);
Expand All @@ -190,7 +198,10 @@ void CNAME(enum CBLAS_ORDER order,
}
#endif

blas_memory_free(buffer);
#ifdef MAX_STACK_ALLOC
if(!stack_alloc_size)
#endif
blas_memory_free(buffer);

FUNCTION_PROFILE_END(1, m * n + m + n, 2 * m * n);

Expand Down
2 changes: 1 addition & 1 deletion kernel/x86_64/sgemv_t_4.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ int CNAME(BLASLONG m, BLASLONG n, BLASLONG dummy1, FLOAT alpha, FLOAT *a, BLASLO
if ( n < 1 ) return(0);

xbuffer = buffer;
ytemp = buffer + NBMAX;
ytemp = buffer + (m < NBMAX ? m : NBMAX);

n0 = n / NBMAX;
n1 = (n % NBMAX) >> 2 ;
Expand Down