Skip to content

Commit d75568d

Browse files
authored
Merge pull request #43 from redhat-performance/add_size_check
Cap the size of the array based on the amount of freemem
2 parents 0ab52d3 + 062e8ba commit d75568d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

streams/streams_extra/run_stream

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,20 @@ build_images()
159159
continue
160160
fi
161161
fi
162+
total_freemem=`free -k | grep Mem: | awk '{print $7}'`
163+
free_mem=`echo \($total_freemem/100\)*90 | bc`
164+
#
165+
# We are using arrays of 8 byte elements, and there are 3 of them.
166+
#
167+
actual_mem_use=`echo $cache_size_kb*24 | bc`
168+
#
169+
# Do not build if the free_mem is less then the amount of memory
170+
# this array size requires.
171+
#
172+
if [[ $free_mem -lt $actual_mem_use ]]; then
173+
echo Requested size, ${cache_size_kb}K, is too large.
174+
continue
175+
fi
162176

163177
CC_CMD="gcc ${MOPT} -fopenmp -mcmodel=large ${optim_opt} -DSTREAM_ARRAY_SIZE=${use_cache} stream_omp_5_10.c -o ${stream} -fno-pic"
164178
echo $CC_CMD >> streams_build_options

0 commit comments

Comments
 (0)