Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to make floating point code work #408

Open
haresh-seenivasagan opened this issue Mar 15, 2024 · 0 comments
Open

Not able to make floating point code work #408

haresh-seenivasagan opened this issue Mar 15, 2024 · 0 comments

Comments

@haresh-seenivasagan
Copy link

haresh-seenivasagan commented Mar 15, 2024

I am trying to run a simple floating point c code on pulpino but i am facing an issue where floats are not being printed.
here is the code that i am trying to run :

#include <stdio.h>
int main() {
    float a =4.2;
    float b = 3.1;
    float c;
    float d;
    c = a+b ;
    d = a-b ;

    printf("Toplam=%f",c);
    printf("Fark=%f",d ); 
return 0;
}

and here is my cmake configuration

TARGET_C_FLAGS="-O3 -m32 -g -fsingle-precision-constant -mfpdouble=float -Werror=double-promotion"
GCC_MARCH="IMFDXpulpv2 -mhard-float"

I am using the https://github.com/pulp-platform/ri5cy_gnu_toolchain compiler with the FPU.
since i am adding the -Werror=double-promotion flag i am getting an error

`error: implicit conversion from 'float' to 'double' when passing argument to function [-Werror=double-promotion]`
I understand  that the error is originating because printf implicitly converts float to double when we use %f

 after removing that flag even though the make is successful ,The floats are not visible . Previously  only Toplam= was printed without the floats now i only see garbage characters no matter what i print `�Æ÷.`
 
 If i remove all other flags and only keep the mfpdouble=float flag then i am getting `error: insn does not satisfy its constraints:

}

^

(insn 43 20 21 2 (set (reg:DF 14 a4)

(reg:DF 47 fa5 [orig:79 D.2575 ] [79])) /home/har/Downloads/pulpino/sw/apps/helloworld/helloworld.c:14 342 {*movdf_hardfloat_rv32}

(`

I have no clue where i am going wrong here would appreciate any help and advice on what direction i should take to solve this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant