EPFL-LAP / dynamatic

DHLS (Dynamic High-Level Synthesis) compiler based on MLIR
Other
64 stars 19 forks source link

Casting floats to double issue #161

Open murphe67 opened 1 month ago

murphe67 commented 1 month ago

In the ADMM integration test, the line: float u_bound = vdc * 0.5; causes the error:

./dynamatic;   set-src ./dynamatic/integration-test/admm/admm.c;   set-clock-period 4;   compile --simple-buffers ;   write-hdl --hdl vhdl;   simulate; #  synthesize;   exit
[INFO] Compiled source to affine
[INFO] Ran memory analysis
[INFO] Compiled affine to scf
[INFO] Compiled scf to cf
[INFO] Applied standard transformations to cf
[INFO] Applied Dynamatic transformations to cf
/home/emurphy/dynamatic-scripts/./dynamatic/integration-test/admm/out/comp/cf_dyn_transformed.mlir:5:10: error: failed to legalize operation 'arith.extf'
    %0 = arith.extf %arg0 {handshake.name = "extf0"} : f32 to f64
         ^
/home/emurphy/dynamatic-scripts/./dynamatic/integration-test/admm/out/comp/cf_dyn_transformed.mlir:5:10: note: see current operation: %14 = "arith.extf"(<<UNKNOWN SSA VALUE>>) {handshake.bb = 0 : ui32, handshake.name = "extf0"} : (f32) -> f64
[FATAL] Failed to compile cf to handshake

which I interpret as extending vdc (a float) to a double is not supported.

changing the 0.5 (implicit double) to 0.5f (explicit float) fixed the error, e.g.: float u_bound = vdc * 0.5f;

Jiahui17 commented 1 month ago

I think we do support this in the latest commit (after #134 )

BTW, I was not able to reproduce this using the branch in #160 after changing 0.5f to 0.5 (but I saw something different):

================================================================================
============== Dynamatic | Dynamic High-Level Synthesis Compiler ===============
======================== EPFL-LAP - v2.0.0 | March 2024 ========================
================================================================================

dynamatic> set-dynamatic-path ./dynamatic;   set-src ./dynamatic/integration-test/admm/admm.c;   set-clock-period 8;   compile --sharing --buffer-algorithm fpga20;   write-hdl --hdl verilog;   simulate;   exit
[INFO] Compiled source to affine
[INFO] Ran memory analysis
[INFO] Compiled affine to scf
[INFO] Compiled scf to cf
[INFO] Applied standard transformations to cf
[INFO] Applied Dynamatic transformations to cf
[INFO] Compiled cf to handshake
[INFO] Applied transformations to handshake
[INFO] Built kernel for profiling
[INFO] Ran kernel for profiling
loc("/home/jxu/Repositories/dhls-utils/./dynamatic/integration-test/admm/out/comp/cf_dyn_transformed.mlir":8:10): error: 'arith.negf' op Unknown operation!
[FATAL] Failed to profile cf-level
murphe67 commented 1 month ago

I'm seeing the same issue you're seeing on the other branch ("admm_circular_integration_test"), if that helps

Jiahui17 commented 2 weeks ago

@murphe67 Could you check this again in the current main? This bug is not reproduced on my end