mirror of https://github.com/Nonannet/copapy.git
test for aux function added
This commit is contained in:
parent
ac6854ff9b
commit
82c324b1a6
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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);
|
||||
}}
|
||||
"""
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
Loading…
Reference in New Issue