Converting Tcl Compilation Flow to XOCC

Starting with the 2016.3 release of SDAccel™, Tcl based compilation flow is no longer supported. Direct command line access via XOCC (and MakeFile) is the main entry point to use SDAccel services. This appendix provides guidance on how to convert Tcl based compilation script to XOCC based command line options. All examples in the SDAccel installation use Makefile/XCOCC for compilation and can be used as additional reference.

The following sections list Tcl commands and their equivalent XOCC options. All XOCC options need to be provided to the XCOCC command in a single command line.

Solution

  • Tcl

    create_solution -name example_alpha -dir . -force
  • XOCC

    XOCC does not require a solution to be explicitly created.

Host Code Management and Compilation

  • Tcl

    add_files "test-cl.c"
  • XOCC

    In XOCC flow, the host code is managed by the user and compiled with the xcpp command line or Makefile to generate host executable.

    xcpp is an SDAccel wrapper around the underlying system compiler / linkers (such as GCC/G++) to create a uniform frontend for the host computer compilation. One goal of the wrapper is to isolate from potential incompatibilities between preinstalled system compilers and the required SDAccel compiler versions.

    xcpp -g -Wall -DFPGA_DEVICE -I/opt/SDx/2017.4/runtime/include/1_2 -c test-cl.cpp -o test-cl.o
    xcpp  -L/opt/SDx/2017.4/runtime/lib/x86_64 -lxilinxopencl -llmx6.0 -lstdc++ test-cl.o -o mmult_ex
    

Device

  • Tcl

    add_device -vbnv xilinx:adm-pcie-7v3:1ddr:3.0
    set_property device_repo_paths /path/to/custom_dsa [current_solution]
    
  • XOCC

    --platform xilinx:adm-pcie-7v3:1ddr:3.0
    --xp prop:solution.device_repo_paths=/path/to/custom_dsa
    

Kernel Definition

  • Tcl

    create_kernel mmult -type clc
    add_files -kernel [get_kernels mmult] "mmult1.cl"
    
  • XOCC

    --kernel mmult mmul1.cl

Setting Kernel Compile Flags

  • Tcl

    set_property kernel_flags "-DUSE2DDR=1" [get_kernels mmult]
  • XOCC

    -DUSE2DDR=1

Binary Container Definition

  • Tcl

    create_opencl_binary bin_mmult
    set_property region "OCL_REGION_0" [get_opencl_binary bin_mmult]
    create_compute_unit -opencl_binary [get_opencl_binary bin_mmult] -kernel [get_kernels mmult] -name k1
    create_compute_unit -opencl_binary [get_opencl_binary bin_mmult] -kernel [get_kernels mmult] -name k2
    
  • XOCC

    --output bin_mmult.xclbin --nk mmult:2:k1.k2

Compile for Software Emulation

  • Tcl

    compile_emulation -flow cpu -opencl_binary [get_opencl_binary bin_mmult]
  • XOCC

    --target sw_emu

Compile for Hardware Emulation

  • Tcl

    compile_emulation -flow hardware -opencl_binary [get_opencl_binary bin_mmult]
  • XOCC

    --target hw_emu

Run CPU and Hardware emulation Emulation

Build System

  • Tcl

    build_system
  • XOCC

    --target hw

Report Estimate

  • Tcl

    report_estimate
  • XOCC

    --report estimate

Package System

  • Tcl

    package_system
  • XOCC

    XOCC does not have an equivalent option for package_system. Packaging of libraries and drivers for deployment is provided by another command, xbinst. Below is a simple command line example.

    xbinst -f xilinx:adm-pcie-7v3:1ddr:3.0 -d 7v3

Putting All Together

  • Tcl

    create_solution -name example_alpha -dir . -force
    add_device -vbnv xilinx:adm-pcie-7v3:1ddr:3.0
    
    create_kernel mmult -type clc
    add_files -kernel [get_kernels mmult] "mmult1.cl"
    set_property kernel_flags "-DUSE2DDR=1" [get_kernels mmult]
    
    create_opencl_binary bin_mmult
    set_property region "OCL_REGION_0" [get_opencl_binary bin_mmult]
    create_compute_unit -opencl_binary [get_opencl_binary bin_mmult] -kernel [get_kernels mmult] -name k1
    create_compute_unit -opencl_binary [get_opencl_binary bin_mmult] -kernel [get_kernels mmult] -name k2
    
    compile_emulation -flow cpu -opencl_binary [get_opencl_binary bin_mmult]
    run_emulation -flow cpu -args "bin_mmult.xclbin"
    
    compile_emulation -flow hardware -opencl_binary [get_opencl_binary bin_mmult]
    run_emulation -flow cpu -args "bin_mmult.xclbin"
    
    build_system
    
  • XOCC

    The following is the equivalent XOCC command line options of the Tcl commands above for compilation of Software emulation. Change --target sw_emu to --target hw_emu for compilation for hardware emulation or --target hw for compilation for system run.

    xocc --target sw_emu --platform xilinx:adm-pcie-7v3:1ddr:3.0 \
         -DUSE2DDR=1 \
         --output bin_mmult.xclbin --nk mmutl:2:k1.k2
         --kernel mmult mmul1.c