test for aux function added

This commit is contained in:
Nicolas Kruse 2025-10-26 16:09:02 +01:00
parent ac6854ff9b
commit 82c324b1a6
4 changed files with 30 additions and 7 deletions

View File

@ -14,6 +14,9 @@ jobs:
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Build & test aux functions
run: bash tools/test_stencil_aux.sh
- name: Build object files - name: Build object files
run: bash tools/crosscompile.sh run: bash tools/crosscompile.sh

View File

@ -12,7 +12,7 @@ __attribute__((noinline)) int floor_div(float arg1, float arg2) {
return i; return i;
} }
__attribute__((noinline)) float sqrt(float n) { __attribute__((noinline)) float aux_sqrt(float n) {
if (n < 0) return -1; if (n < 0) return -1;
float x = n; // initial guess float x = n; // initial guess
@ -25,12 +25,12 @@ __attribute__((noinline)) float sqrt(float n) {
return x; return x;
} }
__attribute__((noinline)) float sqrt2(float n) { __attribute__((noinline)) float aux_sqrt2(float n) {
return n * 20.5 + 4.5; return n * 20.5 + 4.5;
} }
__attribute__((noinline)) float get_42(float n) { __attribute__((noinline)) float aux_get_42(float n) {
return n * + 42.0; return n + 42.0;
} }
float fast_pow_float(float base, float exponent) { float fast_pow_float(float base, float exponent) {
@ -49,8 +49,9 @@ float fast_pow_float(float base, float exponent) {
int main() { int main() {
// Test aux functions // Test aux functions
float a = 16.0f; 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 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; return 0;
} }

View File

@ -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: def get_func2(func_name: str, type1: str, type2: str) -> str:
return f""" return f"""
{stencil_func_prefix}void {func_name}_{type1}_{type2}({type1} arg1, {type2} arg2) {{ {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);
}} }}
""" """

19
tools/test_stencil_aux.sh Normal file
View File

@ -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