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

static_assert in header files #2

Closed
oka2 opened this issue Feb 2, 2017 · 13 comments
Closed

static_assert in header files #2

oka2 opened this issue Feb 2, 2017 · 13 comments

Comments

@oka2
Copy link

oka2 commented Feb 2, 2017

It seems vivado hls (v2016.4) does not recognize static_assert in header files Stencil.h and LineBuffer.h. It will give the following warning:

In file included from ./hls_target.h:8:
../../../include\Stencil.h:56:5: error: use of undeclared identifier 'static_assert'; did you mean 'static_cast'?
    static_assert(sizeof(T) * 8 == N, "bitcast_to_type parameters are incorrect.\n");
    ^
In file included from hls_target.cpp:3:
../../../include\Linebuffer.h:20:5: error: use of undeclared identifier 'static_assert'; did you mean 'static_cast'?
    static_assert(IMG_EXTENT_0 >= OUT_EXTENT_0, "image extent not is larger than output.");
    ^

and the errors:

Pragma processor failed: In file included from hls_target.cpp:1:
In file included from ./hls_target.h:8:
../../../include\Stencil.h:56:5: error: use of undeclared identifier 'static_assert'; did you mean 'static_cast'?
    static_assert(sizeof(T) * 8 == N, "bitcast_to_type parameters are incorrect.\n");
    ^
In file included from hls_target.cpp:3:
../../../include\Linebuffer.h:20:5: error: use of undeclared identifier 'static_assert'; did you mean 'static_cast'?
    static_assert(IMG_EXTENT_0 >= OUT_EXTENT_0, "image extent not is larger than output.");
    ^

Is this due to my version of Vivado_HLS or halide_hls? Help would be much appreciated! Thanks.

@jingpu
Copy link
Owner

jingpu commented Feb 3, 2017

Hi @oka2 ,

Could you try to include "-std=c++0x" flag for HLS synthesis, as "static_assert" is a relatively new feature in the C++ standard? This work for me on Vivado_HLS v2015.4. Unfortunately, I don't have the access to v2016.4.

By the way, I use the following script to setup the Vivado_HLS projects.
https://github.com/jingpu/Halide-HLS/blob/HLS/apps/hls_examples/hls_support/run_hls.tcl

Thanks,
Jing

@oka2
Copy link
Author

oka2 commented Feb 7, 2017

Im on a PC, is there a script for windows? The script returns errors because it is targeting linux.

@oka2
Copy link
Author

oka2 commented Feb 7, 2017

By the way it seems like the flags worked, but here is the error:

RUN_PATH=/mnt/c/Users/Omar/Halide-HLS/apps/hls_examples/bilateral_grid_hls \
        RUN_ARGS=/mnt/c/Users/Omar/Halide-HLS/apps/images/benchmark_8mp_gray.png \
        vivado_hls -f ../hls_support/run_hls.tcl -l vivado_hls.log
ERROR: /mnt/c/Xilinx/Vivado_HLS/2016.4/tps/lnx64/jre does not exist.
ERROR: Could not find 64-bit executable.
ERROR: /mnt/c/Xilinx/Vivado_HLS/2016.4/bin/unwrapped/lnx64.o/vivado_hls does not exist
make: *** [vivado_hls.log] Error 1

@oka2 oka2 closed this as completed Feb 7, 2017
@oka2 oka2 reopened this Feb 7, 2017
@sampsyo
Copy link

sampsyo commented Feb 7, 2017

Hey, @oka2—if you use triple-backticks ``` to enclose your code instead of single backticks, then line breaks will be preserved, which will make this kind of output more legible.

@jingpu
Copy link
Owner

jingpu commented Feb 7, 2017

@oka2 ,

The TCL script and the makefile in the example folders are all for Linux. You don't have to use them. I just want to point it out as a reference, since it includes all the necessary settings (C flags, link options, include folders, etc.). You can still use your original develop environment (e.g. GUI) with these settings configured.

For the error you showed latter, I guess it has something to do with your Vivado installation and environment. It seem to fail when you tried to start 'vivado_hls'.

@oka2
Copy link
Author

oka2 commented Feb 8, 2017

Ok I believe I am getting closer to compilation. I have made my own script following yours which can open the project, include all of the necessary files, and configure the solution. I still have issues with linking libraries in the csim_design call. No matter what I do, vivado won't recognize pipeline_native.o files as library flags. I have tried multiple syntaxes and multiple locations for the file. It seems Vivado looks for them in its msys folder because my lpng12 and lpthread work fine. The error is below. So I have two questions. How do I add object files as libraries? And what library is ldl in line 3 of the script you attached above?

INFO: [SIM 211-4] CSIM will launch GCC as the compiler.
   Compiling ../../../../run.cpp in release mode
   Compiling ../../../../pipeline_hls.cpp in release mode
   Compiling ../../../../hls_target.cpp in release mode
   Generating csim.exe
g++.exe: error: pipeline_native.o: No such file or directory
make: *** [csim.exe] Error 1
ERROR: [SIM 211-100] 'csim_design' failed: compilation error(s).
INFO: [SIM 211-3] *************** CSIM finish ***************
4
    while executing
"source [lindex $::argv 1] "
    ("uplevel" body line 1)
    invoked from within
"uplevel \#0 { source [lindex $::argv 1] } "```

@jingpu
Copy link
Owner

jingpu commented Feb 8, 2017

The log seems to suggest that pipeline_native.o is not found in your folder. Could you check if the file exists?
pipeline_native.o is supposed to be generated when you run ./pipeline (the Halide application).
See https://github.com/jingpu/Halide-HLS/blob/HLS/apps/hls_examples/gaussian_hls/Makefile#L17

ldl is the dynamic linking library. It is used because the PNG library is a dynamic linking library.
http://stackoverflow.com/questions/19146525/meaning-of-library-ldl-in-gcc

@oka2
Copy link
Author

oka2 commented Feb 14, 2017

I have the file for sure and all the other libraries work except pipeline_native. I even copied pipeline_native.o and its header file to the same places as the other libraries and their headers but it still did not work. Below is my script with some adjustments for Windows syntax. The problem comes from the csim_design line. I have a feeling its the syntax of adding the file but I have tried -lpipeline_native -lpipeline_native.o pipeline_native pipeline_native.o -pipeline_native and -pipeline_native.o but they all return an error of no such file. Do you have any other suggestions to fix or workaround this?

open_project -reset bi_grid_prj
set_top hls_target
add_files hls_target.cpp -cflags "-std=c++0x -I../../../hls_support"
add_files -tb pipeline_hls.cpp -cflags "-std=c++0x -I../hls_support -I../../../tools -I../../../include -I../../support"
add_files -tb run.cpp -cflags "-std=c++0x -I../hls_support -I../../../tools -I../../../include -I../../support"

open_solution -reset "solution1"
set_part {xc7z020clg484-1}
create_clock -period 10 -name default
#config_rom_infer -array_size_threshold 1024
config_bind -effort high
config_schedule -effort high

csim_design -O -ldflags {pipeline_native.o -lpthread -ldl -lpng12 } -argv {../../../benchmark_8mp_gray.png}

#csynth_design
#cosim_design
#export_design -rtl verilog -format ip_catalog

exit

@jingpu
Copy link
Owner

jingpu commented Feb 14, 2017

I recall this problem. The file included in -ldflags must use the absolute paths.
The problem is that when Vivado runs csim_design, it creates new folders and all relative paths will base on that new folders.
It is a pretty inconvenient design of their scripting interface.

@oka2
Copy link
Author

oka2 commented Feb 15, 2017

I put an absolute path (straight from my C drive and all) and now it says file format not recognized! Now I am thinking it has to do with 32 vs 64 bit linkers and .o files.

INFO: [SIM 211-2] *************** CSIM start ***************
WARNING: [SIM 211-51] HLS only supports CLANG compiler in Linux.
INFO: [SIM 211-4] CSIM will launch GCC as the compiler.
   Compiling ../../../../run.cpp in release mode
   Compiling ../../../../pipeline_hls.cpp in release mode
   Compiling ../../../../hls_target.cpp in release mode
   Generating csim.exe
c:/Users/Omar/Halide-HLS/apps/hls_examples/bilateral_grid_hls/pipeline_native.o: file not recognized: File format not recognized
collect2: ld returned 1 exit status
make: *** [csim.exe] Error 1
ERROR: [SIM 211-100] 'csim_design' failed: compilation error(s).
INFO: [SIM 211-3] *************** CSIM finish ***************
4
    while executing
"source [lindex $::argv 1] "
    ("uplevel" body line 1)
    invoked from within
"uplevel \#0 { source [lindex $::argv 1] } "

@jingpu
Copy link
Owner

jingpu commented Feb 15, 2017

Can you run out.png rule in the Makefile successfully? It also runs the C simulation, but using the plain GCC tool chain only (no Vivado stuffs). The information there may be helpful to isolate the problem.
https://github.com/jingpu/Halide-HLS/blob/HLS/apps/hls_examples/bilateral_grid_hls/Makefile#L23

@oka2
Copy link
Author

oka2 commented Mar 1, 2017

Hello jingpu! I wanted to sincerely thank you for all of your help. I have set up my own ubuntu virtual machine as it seemed that working with Windows was not getting anywhere. As of yesterday I successfully built Halide_HLS and synthesized a sample project in Vivado. The process for linux was streamlined and easy thanks to your work and documentation. Best of luck on future projects!

@oka2 oka2 closed this as completed Mar 1, 2017
@jingpu
Copy link
Owner

jingpu commented Mar 1, 2017

It is great to hear that! Thanks!

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

3 participants