File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed
templates/vitis_accelerator Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -61,6 +61,24 @@ int main(int argc, char **argv) {
61
61
return EXIT_FAILURE;
62
62
}
63
63
64
+ std::string target_device = " myplatform" ;
65
+ auto device_type = target_device.substr (0 , target_device.size () - 17 );
66
+ std::cout << " Device type: " << device_type << std::endl;
67
+ std::cout << " xrt::device size " << sizeof (xrt::device) << std::endl;
68
+ for (int i = 0 ; i < sizeof (xrt::device); i++){
69
+ std::cout << " device[" << i << " ] name: " << xrt::device (i).get_info <xrt::info::device::name>() << " \n " ;
70
+ std::cout << " device[" << i << " ] bdf: " << xrt::device (i).get_info <xrt::info::device::bdf>() << " \n\n " ;
71
+ size_t found = xrt::device (i).get_info <xrt::info::device::name>().find (device_type);
72
+ if (found != std::string::npos){
73
+ std::cout << " Device: " << xrt::device (i).get_info <xrt::info::device::name>() << " found." << std::endl;
74
+ device_index = i;
75
+ std::cout << " Device index in loop: " <<device_index << std::endl;
76
+ break ;
77
+ }
78
+ else {
79
+ std::cout << " Device not found" << std::endl;
80
+ }
81
+ }
64
82
std::cout << " Open the device" << device_index << std::endl;
65
83
auto device = xrt::device (device_index);
66
84
std::cout << " Load the xclbin " << binaryFile << std::endl;
Original file line number Diff line number Diff line change @@ -113,6 +113,8 @@ def write_host(self, model):
113
113
Args:
114
114
model (ModelGraph): the hls4ml model.
115
115
"""
116
+ from hls4ml .backends import VitisAcceleratorConfig
117
+ vitis_accelerator_config = VitisAcceleratorConfig (model .config )
116
118
117
119
filedir = os .path .dirname (os .path .abspath (__file__ ))
118
120
f = open (os .path .join (filedir , '../templates/vitis_accelerator/myproject_host.cpp' ))
@@ -127,6 +129,8 @@ def write_host(self, model):
127
129
newline = line .replace ('myproject_kernel' , format (model .config .get_project_name (), '_kernel' ))
128
130
elif 'output_dir' in line :
129
131
newline = line .replace ('output_dir' , format (model .config .get_output_dir ()))
132
+ elif 'myplatform' in line :
133
+ newline = line .replace ('myplatform' , format (vitis_accelerator_config .get_platform ()))
130
134
else :
131
135
newline = line
132
136
fout .write (newline )
You can’t perform that action at this time.
0 commit comments