diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 81fff48..1e2800a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,6 +14,9 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Build & test aux functions + run: bash tools/test_stencil_aux.sh + - name: Build object files run: bash tools/crosscompile.sh diff --git a/stencils/aux_functions.c b/stencils/aux_functions.c index 97b28eb..3301687 100644 --- a/stencils/aux_functions.c +++ b/stencils/aux_functions.c @@ -12,7 +12,7 @@ __attribute__((noinline)) int floor_div(float arg1, float arg2) { return i; } -__attribute__((noinline)) float sqrt(float n) { +__attribute__((noinline)) float aux_sqrt(float n) { if (n < 0) return -1; float x = n; // initial guess @@ -25,12 +25,12 @@ __attribute__((noinline)) float sqrt(float n) { return x; } -__attribute__((noinline)) float sqrt2(float n) { +__attribute__((noinline)) float aux_sqrt2(float n) { return n * 20.5 + 4.5; } -__attribute__((noinline)) float get_42(float n) { - return n * + 42.0; +__attribute__((noinline)) float aux_get_42(float n) { + return n + 42.0; } float fast_pow_float(float base, float exponent) { @@ -49,8 +49,9 @@ float fast_pow_float(float base, float exponent) { int main() { // Test aux functions float a = 16.0f; - float sqrt_a = fast_sqrt(a); + float sqrt_a = aux_sqrt(a); float pow_a = fast_pow_float(a, 0.5f); - float sqrt2_a = fast_sqrt2(a); + float sqrt2_a = aux_sqrt2(a); + float g42 = aux_get_42(0.0f); return 0; } \ No newline at end of file diff --git a/stencils/generate_stencils.py b/stencils/generate_stencils.py index d26ee88..cf597bf 100644 --- a/stencils/generate_stencils.py +++ b/stencils/generate_stencils.py @@ -82,7 +82,7 @@ def get_cast(type1: str, type2: str, type_out: str) -> str: def get_func2(func_name: str, type1: str, type2: str) -> str: return f""" {stencil_func_prefix}void {func_name}_{type1}_{type2}({type1} arg1, {type2} arg2) {{ - result_float_{type2}({func_name}((float)arg1), arg2); + result_float_{type2}(aux_{func_name}((float)arg1), arg2); }} """ diff --git a/tools/test_stencil_aux.sh b/tools/test_stencil_aux.sh new file mode 100644 index 0000000..b4172b8 --- /dev/null +++ b/tools/test_stencil_aux.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +set -e +set -v + +mkdir -p bin +FILE=aux_functions +SRC=stencils/$FILE.c +DEST=bin +OPT=O3 + +mkdir -p $DEST + +# Compile native x86_64 +gcc -g -$OPT $SRC -o $DEST/$FILE +chmod +x $DEST/$FILE + +# Run +$DEST/$FILE \ No newline at end of file