- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Use the FPGA queue in the main file test.cpp and call the function in gpu.cpp. The function uses the GPU queue. How to compile the file, the following compilation statement has an error: terminate called after throwing an instance of 'CL:: sycl:: runtime_ error'
Compile command:
dpcpp -DFPGA_EMULATOR \-fsycl-targets=spir64_fpga-unknown-unknown-sycldevice gpu.cpp \-c -o gpu.o
dpcpp -DFPGA_EMULATOR \-fsycl-targets=spir64_fpga-unknown-unknown-sycldevice,spir64-unknown-unknown-sycldevice test.cpp gpu.o -o test test.cpp gpu.hpp gpu.cpp
test.cpp
gpu.hpp
gpu.cpp
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Could you please follow the below steps:
1. Replace your build.sh file by the below commands:
dpcpp -DFPGA_EMULATOR gpu.cpp \-c -o gpu.o
dpcpp -DFPGA_EMULATOR test.cpp gpu.o -o test
2. Run build.sh and run.sh files:
qsub -l nodes=1:gpu:ppn=2 -d . build.sh
qsub -l nodes=1:gpu:ppn=2 -d . run.sh
Please find the attached result (Image.PNG) for reference.
Hope this helps. If you have any further issue, please let us know.
Thanks.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thank you for posting in Intel Communities.
Could you please share sample reproducer code and the complete steps, so that we can try out the same from our end?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
test.cpp
#include <stdio.h>
#include <stdlib.h>
#include "gpu.hpp"
#include <CL/sycl.hpp>
#include <CL/sycl/INTEL/fpga_extensions.hpp>
using namespace std;
using namespace cl::sycl;
int main(){
queue Q{ INTEL::fpga_emulator_selector{} };
std::cout << "Running on device: " << Q.get_device().get_info<info::device::name>() << "\n";
int size = 16;
int *data = (int *)malloc(sizeof(int)*size);
int *device_data = malloc_device<int>(size,Q);
for (int i = 0; i < size; i++) {
data[i] = i; printf("%d\t",data[i]);
} printf("\n");
Q.memcpy(device_data, data, sizeof(int) * size);
Q.submit([&](auto &h) {
h.parallel_for(range{ size_t(size) }, [=](id<1> i) {
device_data[i] = device_data[i] * 10;
});
});
Q.memcpy(data, device_data, sizeof(int) * size);
printf("the data on fpga is:\n");
for (int i = 0; i < size; i++) {
data[i] = i; printf("%d\t",data[i]);
} printf("\n");
addOnGpu();
free(data);
free(device_data,Q);
return 0;
}
gpu.hpp
#include <stdio.h>
#include <stdlib.h>
#include <CL/sycl.hpp>
#include <CL/sycl/INTEL/fpga_extensions.hpp>
using namespace std;
using namespace cl::sycl;
void addOnGpu();
gpu.cpp
#include "gpu.hpp"
using namespace std;
using namespace cl::sycl;
void addOnGpu(){
queue Q{ cl::sycl::gpu_selector{} };
//queue q{ INTEL::fpga_emulator_selector{} };
std::cout << "Running on GPU device: " << Q.get_device().get_info<info::device::name>() << "\n";
int size = 16;
int *data = (int *)malloc(sizeof(int)*size);
int *device_data = malloc_device<int>(size,Q);
for (int i = 0; i < size; i++) {
data[i] = i; printf("%d\t",data[i]);
} printf("\n");
Q.memcpy(device_data, data, sizeof(int) * size);
Q.submit([&](auto &h) {
h.parallel_for(range{ size_t(size) }, [=](id<1> i) {
device_data[i] = device_data[i] * 100;
});
});
Q.memcpy(data, device_data, sizeof(int) * size);
printf("the data on fpga is:\n");
for (int i = 0; i < size; i++) {
data[i] = i; printf("%d\t",data[i]);
} printf("\n");
//addOnGpu(data,size);
free(data);
free(device_data,Q);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
We have not heard back from you. Could you please give us an update?
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
test.cpp
#include <stdio.h>
#include <stdlib.h>
#include "gpu.hpp"
#include <CL/sycl.hpp>
#include <CL/sycl/INTEL/fpga_extensions.hpp>
using namespace std;
using namespace cl::sycl;
int main(){
queue Q{ INTEL::fpga_emulator_selector{} };
std::cout << "Running on device: " << Q.get_device().get_info<info::device::name>() << "\n";
int size = 16;
int *data = (int *)malloc(sizeof(int)*size);
int *device_data = malloc_device<int>(size,Q);
for (int i = 0; i < size; i++) {
data[i] = i; printf("%d\t",data[i]);
} printf("\n");
Q.memcpy(device_data, data, sizeof(int) * size);
Q.submit([&](auto &h) {
h.parallel_for(range{ size_t(size) }, [=](id<1> i) {
device_data[i] = device_data[i] * 10;
});
});
Q.memcpy(data, device_data, sizeof(int) * size);
printf("the data on fpga is:\n");
for (int i = 0; i < size; i++) {
data[i] = i; printf("%d\t",data[i]);
} printf("\n");
addOnGpu();
free(data);
free(device_data,Q);
return 0;
}
gpu.hpp
#include <stdio.h>
#include <stdlib.h>
#include <CL/sycl.hpp>
#include <CL/sycl/INTEL/fpga_extensions.hpp>
using namespace std;
using namespace cl::sycl;
void addOnGpu();
gpu.cpp
#include "gpu.hpp"
using namespace std;
using namespace cl::sycl;
void addOnGpu(){
queue Q{ cl::sycl::gpu_selector{} };
//queue q{ INTEL::fpga_emulator_selector{} };
std::cout << "Running on GPU device: " << Q.get_device().get_info<info::device::name>() << "\n";
int size = 16;
int *data = (int *)malloc(sizeof(int)*size);
int *device_data = malloc_device<int>(size,Q);
for (int i = 0; i < size; i++) {
data[i] = i; printf("%d\t",data[i]);
} printf("\n");
Q.memcpy(device_data, data, sizeof(int) * size);
Q.submit([&](auto &h) {
h.parallel_for(range{ size_t(size) }, [=](id<1> i) {
device_data[i] = device_data[i] * 100;
});
});
Q.memcpy(data, device_data, sizeof(int) * size);
printf("the data on fpga is:\n");
for (int i = 0; i < size; i++) {
data[i] = i; printf("%d\t",data[i]);
} printf("\n");
//addOnGpu(data,size);
free(data);
free(device_data,Q);
}
build.sh
dpcpp -DFPGA_EMULATOR \-fsycl-targets=spir64_fpga-unknown-unknown-sycldevice gpu.cpp \-c -o gpu.o
dpcpp -DFPGA_EMULATOR \-fsycl-targets=spir64_fpga-unknown-unknown-sycldevice,spir64-unknown-unknown-sycldevice test.cpp gpu.o -o test
run.sh
./test
The control command at the control panel end is:
qsub -l neednodes=1:fpga_compile:ppn=2,nodes=1:fpga_compile:ppn=2 -d . build.sh
qsub -l neednodes=1:fpga_compile:ppn=2,nodes=1:fpga_compile:ppn=2 -d . run.sh
Can't output correct results, what's the problem?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Could you share the error log and respective screenshot?
Also we are facing error while trying your command. So try the below commands.
qsub -l nodes=1:fpga_compile:ppn=2 -d . build.sh
qsub -l nodes=1:fpga_compile:ppn=2 -d . run.sh
If the issue still persists, please let us know.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There was still an error trying your command.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Could you please follow the below steps:
1. Replace your build.sh file by the below commands:
dpcpp -DFPGA_EMULATOR gpu.cpp \-c -o gpu.o
dpcpp -DFPGA_EMULATOR test.cpp gpu.o -o test
2. Run build.sh and run.sh files:
qsub -l nodes=1:gpu:ppn=2 -d . build.sh
qsub -l nodes=1:gpu:ppn=2 -d . run.sh
Please find the attached result (Image.PNG) for reference.
Hope this helps. If you have any further issue, please let us know.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you very much for your guidance. I finished the task successfully
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you very much for your guidance. I finished the task successfully
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thanks for accepting our solution. If you need any additional information, please post a new question as this thread will no longer be monitored by Intel.
Thanks.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page