UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

取消
显示结果 
搜索替代 
您的意思是: 
Visitor willyeyem5
Visitor
302 次查看
注册日期: ‎12-18-2018

SDAccel 編譯完 Project, 但不產生 .xclbin 檔 ?

Hi 大家好 :

我是 fpga 新手,

我用 OpenCL 編寫一個 Project, 

編譯可以過, 但卻不產生 .xclbin 檔,

FPGA build process using XOCC:

The kernel .xo files are linked with the hardware platform (.dsa) to create the FPGA binary (.xclbin). 

請問 : 無法產生 .xclbin 檔 , 有哪些原因呢 ?

Best Regards

willyeyem5

0 项奖励
8 条回复
Visitor willyeyem5
Visitor
295 次查看
注册日期: ‎12-18-2018

無法產生 .xclbin 檔 ?

Hi 您好 :

我用xilinx提供的project來編譯可以產生.xclbin檔,

但若自己create一個新的project來編譯就無法產生.xclbin檔,

請問這是為什呢 ?

Best Regards

willyeyem5

0 项奖励
Xilinx Employee
Xilinx Employee
274 次查看
注册日期: ‎07-17-2008

回复: SDAccel 編譯完 Project, 但不產生 .xclbin 檔 ?

请问你是选择哪一种模式,Software Emulation, Hardware Emulation还是System?在Build的过程中有报什么信息吗?

-------------------------------------------------------------------------
Don't forget to reply, kudo, and accept as solution.
-------------------------------------------------------------------------
0 项奖励
Visitor willyeyem5
Visitor
262 次查看
注册日期: ‎12-18-2018

回复: SDAccel 編譯完 Project, 但不產生 .xclbin 檔 ?

Hi 您好 :

(1) 我用的是 Emulation-SW 模式

(2) Build 編譯顯示訊息如下:

​_15:05:04 **** Build of configuration Emulation-SW for project prj_test_6 ****
make -j4 incremental
/opt/Xilinx_SDAccel/SDx/2018.2.xdf/bin/xcpp -DSDX_PLATFORM=xilinx_vcu1525_dynamic_5_1 -D__USE_XOPEN2K8 -I/opt/xilinx/xrt/include/ -I/opt/Xilinx_SDAccel/Vivado/2018.2.xdf/include/ -O0 -g -Wall -c -fmessage-length=0 -std=c++14 -DSDX_PLATFORM=xilinx_vcu1525_dynamic_5_1 -D__USE_XOPEN2K8 -I/opt/xilinx/xrt/include/ -I/opt/Xilinx_SDAccel/Vivado/2018.2.xdf/include/ -O0 -g -Wall -c -fmessage-length=0 -o "src/program_build.o" "../src/program_build.c"
/opt/Xilinx_SDAccel/SDx/2018.2.xdf/bin/xcpp -o "prj_test_6.exe" src/program_build.o -lxilinxopencl -lpthread -lrt -lstdc++ -L/opt/xilinx/xrt/lib/ -lxilinxopencl -lpthread -lrt -lstdc++ -L/opt/xilinx/xrt/lib/
/opt/Xilinx_SDAccel/SDx/2018.2.xdf/bin/emconfigutil --od . --nd 1 --platform xilinx_vcu1525_dynamic_5_1

****** configutil v2018.2.xdf (64-bit)
**** SW Build 2342198 on Tue Sep 25 18:17:42 MDT 2018
** Copyright 1986-2018 Xilinx, Inc. All Rights Reserved.

Platform repo paths:
/opt/Xilinx_SDAccel/SDx/2018.2.xdf/platforms
PlatformMgr contains the following platforms:
/opt/Xilinx_SDAccel/SDx/2018.2.xdf/platforms/xilinx_vcu1525_dynamic_5_1/xilinx_vcu1525_dynamic_5_1.xpfm
INFO: [ConfigUtil 60-895] Target platform: /opt/Xilinx_SDAccel/SDx/2018.2.xdf/platforms/xilinx_vcu1525_dynamic_5_1/xilinx_vcu1525_dynamic_5_1.xpfm
emulation configuration file `emconfig.json` is created in . directory

15:05:14 Build Finished (took 9s.637ms)

(3) 少了一個 lib 資料夾 (參見照片)

Best Regards

willyeyem52018-12-18 15-09-58 的螢幕擷圖.png

 

 

0 项奖励
Visitor willyeyem5
Visitor
257 次查看
注册日期: ‎12-18-2018

回复: SDAccel 編譯完 Project, 但不產生 .xclbin 檔 ?

Hi 您好 :

正常情況應該會用到XOCC來編譯kernel源文件,

但不知道為何我的Build過程似乎並沒有使用

XOCC來編譯kernel源文件, 不解 ?

Best Regards

willyeyem5

0 项奖励
Visitor willyeyem5
Visitor
234 次查看
注册日期: ‎12-18-2018

回复: SDAccel 編譯完 Project, 但不產生 .xclbin 檔 ?

Hi 您好 :

我 SDAccel 新Create 的 Project, 在編譯時, 有兩個問題 :

(1) kernel 源代碼好像沒有被編譯到, 不知道為何 ? 而 Xilinx 提供的 Project 並不會有這種問題? 這到底差別再哪裡?

(2) 新 Create 的 Project 會缺少一個 libs 資料夾? 這個資料夾(libs)的目的為何呢?

感謝您, many thanks.

Best Regards

willyeyem5

 

0 项奖励
Visitor willyeyem5
Visitor
229 次查看
注册日期: ‎12-18-2018

SDAccel 編譯完 Project, 但不產生 .xclbin 檔 ?

Hi 您好 :

我的源代碼僅有 : kernel_search.c 和 test.cl

(1) kernel_search.c

#define _CRT_SECURE_NO_WARNINGS
#define PROGRAM_FILE "test.cl"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>

#ifdef MAC
#include <OpenCL/cl.h>
#else
#include <CL/cl.h>
#endif

int main() {

/* Host/device data structures */
cl_platform_id platform;
cl_device_id device;
cl_context context;
cl_program program;
cl_int err;

/* Program/kernel data structures */
FILE *program_handle;
char *program_buffer, *program_log;
size_t program_size, log_size;
cl_kernel *kernels, found_kernel;
char kernel_name[20];
cl_uint i, num_kernels;

/* Access the first installed platform */
err = clGetPlatformIDs(1, &platform, NULL);
if(err < 0) {
perror("Couldn't find any platforms");
exit(1);
}

/* Access the first available device */
err = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 1, &device, NULL);
if(err == CL_DEVICE_NOT_FOUND) {
err = clGetDeviceIDs(platform, CL_DEVICE_TYPE_CPU, 1, &device, NULL);
}
if(err < 0) {
perror("Couldn't find any devices");
exit(1);
}

/* Create a context */
context = clCreateContext(NULL, 1, &device, NULL, NULL, &err);
if(err < 0) {
perror("Couldn't create a context");
exit(1);
}

/* Read program file and place content into buffer */
program_handle = fopen(PROGRAM_FILE, "r");
if(program_handle == NULL) {
perror("Couldn't find the program file");
exit(1);
}
fseek(program_handle, 0, SEEK_END);
program_size = ftell(program_handle);
rewind(program_handle);
program_buffer = (char*)malloc(program_size+1);
program_buffer[program_size] = '\0';
fread(program_buffer, sizeof(char), program_size, program_handle);
fclose(program_handle);

/* Create program from file */
program = clCreateProgramWithSource(context, 1,
(const char**)&program_buffer, &program_size, &err);
if(err < 0) {
perror("Couldn't create the program");
exit(1);
}
free(program_buffer);


/* Build program */
err = clBuildProgram(program, 0, NULL, NULL, NULL, NULL);
if(err < 0) {

/* Find size of log and print to std output */
clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG,
0, NULL, &log_size);
program_log = (char*) malloc(log_size+1);
program_log[log_size] = '\0';
clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG,
log_size+1, program_log, NULL);
printf("%s\n", program_log);
free(program_log);
exit(1);
}

/* Find out how many kernels are in the source file */
err = clCreateKernelsInProgram(program, 0, NULL, &num_kernels);
if(err < 0) {
perror("Couldn't find any kernels");
exit(1);
}

/* Create a kernel for each function */
kernels = (cl_kernel*) malloc(num_kernels * sizeof(cl_kernel));
clCreateKernelsInProgram(program, num_kernels, kernels, NULL);

/* Search for the named kernel */
for(i=0; i<num_kernels; i++) {
clGetKernelInfo(kernels[i], CL_KERNEL_FUNCTION_NAME,
sizeof(kernel_name), kernel_name, NULL);
if(strcmp(kernel_name, "mult") == 0) {
found_kernel = kernels[i];
printf("Found mult kernel at index %u.\n", i);
break;
}
}

for(i=0; i<num_kernels; i++)
clReleaseKernel(kernels[i]);
free(kernels);
clReleaseProgram(program);
clReleaseContext(context);
}

(2) test.cl

__kernel void add(__global float *a,
__global float *b,
__global float *c) {

*c = *a + *b;
}

__kernel void sub(__global float *a,
__global float *b,
__global float *c) {

*c = *a - *b;
}

__kernel void mult(__global float *a,
__global float *b,
__global float *c) {

*c = *a * *b;
}

__kernel void div(__global float *a,
__global float *b,
__global float *c) {

*c = *a / *b;
}

 

Best Regards

willyeyem5

 

0 项奖励
Visitor willyeyem5
Visitor
198 次查看
注册日期: ‎12-18-2018

回复: SDAccel 編譯完 Project, 但不產生 .xclbin 檔 ?

Hi 您好 :

 
我使用的是 xilinx 的源代碼, 但是 :
使用xilinx內建的Project可以產生.xclbin, 但如果自己create新Project, 就不行?
以下為xilinx內建的Project ?
 
2018-12-19 11-50-23 的螢幕擷圖.png 
0 项奖励
Visitor willyeyem5
Visitor
179 次查看
注册日期: ‎12-18-2018

回复: SDAccel 編譯完 Project, 但不產生 .xclbin 檔 ?

Hi 您好 :

我需要 .xclbin 檔, 

因為 clCreateProgramWithBinary API會用到 :

unsigned char *kernelbinary;
char *xclbin = argv[1];

printf("INFO: loading xclbin %s\n", xclbin);

int size=load_file_to_memory(xclbin, (char **) &kernelbinary);
size_t size_var = size;

cl_program program = clCreateProgramWithBinary(context, 1, &device_id, &size_var,
(const unsigned char **) &kernelbinary, &status, &err);

err = clBuildProgram(program, 0, NULL, NULL, NULL, NULL);

// Function
int load_file_to_memory(const char *filename, char **result)
{
uint size = 0;
FILE *f = fopen(filename, "rb");
if (f == NULL) {
*result = NULL;
return -1; // -1 means file opening fail
}
fseek(f, 0, SEEK_END);
size = ftell(f);
fseek(f, 0, SEEK_SET);
*result = (char *)malloc(size+1);
if (size != fread(*result, sizeof(char), size, f)) {
free(*result);
return -2; // -2 means file reading fail
}
fclose(f);
(*result)[size] = 0;
return size;
}

 所以,

麻煩幫忙一下解決這個問題, 感謝您, many thanks.

Best Regards

willyeyem5

0 项奖励