Commit 00c87b37 by MORITA Kazutaka Committed by Tianqi Chen

[CODEGEN][SDACCEL] add support for specifying FPGA device name (#1448)

parent 4e29ec33
......@@ -6,7 +6,7 @@ from ..api import register_func
@register_func("tvm_callback_sdaccel_compile")
def compile_vhls(kernel_info):
def compile_vhls(kernel_info, device_name):
"""Compile Vivado HLS code for SDAccel.
Parameters
......@@ -15,6 +15,9 @@ def compile_vhls(kernel_info):
List of kernel information. The kernel information is a tuple of
function name and source code.
device_name : str
The name of the target device
Return
------
xclbin : bytearray
......@@ -28,6 +31,8 @@ def compile_vhls(kernel_info):
"sw_emu" if os.environ.get("XCL_EMULATION_MODE") else "hw")
advanced_params = ["--xp", "param:compiler.preserveHlsOutput=1",
"--xp", "param:compiler.generateExtraRunData=true"]
platform = device_name
if not platform:
platform = os.environ.get("XCL_PLATFORM", os.environ.get("AWS_PLATFORM"))
if platform is None:
......
......@@ -2,6 +2,7 @@
* Copyright (c) 2018 by Contributors
* \file codegen_vhls.cc
*/
#include <tvm/build_module.h>
#include <vector>
#include <string>
#include "./codegen_vhls.h"
......@@ -67,7 +68,7 @@ void CodeGenVivadoHLS::PreFunctionBody(LoweredFunc f) {
}
runtime::Module BuildSDAccel(Array<LoweredFunc> funcs) {
runtime::Module BuildSDAccel(Array<LoweredFunc> funcs, std::string target_str) {
using tvm::runtime::Registry;
bool output_ssa = false;
CodeGenVivadoHLS cg;
......@@ -94,7 +95,8 @@ runtime::Module BuildSDAccel(Array<LoweredFunc> funcs) {
std::string xclbin;
if (const auto* f = Registry::Get("tvm_callback_sdaccel_compile")) {
xclbin = (*f)(kernel_info).operator std::string();
Target target = Target::create(target_str);
xclbin = (*f)(kernel_info, target->device_name).operator std::string();
} else {
LOG(FATAL) << "Cannot compile Vivado HLS code.";
}
......@@ -103,7 +105,7 @@ runtime::Module BuildSDAccel(Array<LoweredFunc> funcs) {
TVM_REGISTER_API("codegen.build_sdaccel")
.set_body([](TVMArgs args, TVMRetValue* rv) {
*rv = BuildSDAccel(args[0]);
*rv = BuildSDAccel(args[0], args[1]);
});
} // namespace codegen
......
......@@ -40,6 +40,8 @@ def test_exp():
b.asnumpy(), np.exp(a.asnumpy()), rtol=1e-5)
check_device("sdaccel")
if "AWS_PLATFORM" in os.environ:
check_device("sdaccel -device=" + os.environ.get("AWS_PLATFORM"))
def test_multi_kernel():
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment