Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
16556 Discussions

DE5_NET OpenCL support on Ubuntu 16.10

Altera_Forum
Honored Contributor II
3,180 Views

I'm trying to use the OpenCL SDK for the Terasic DE5_Net board. 

I'm using the BSP provided by Terasic in their website.  

 

But I start having (at least) two differences with the expected setup. 

 

1) I am using the latest Quartus and OpenCL SDK Versions (Version 17.0.2 Build 602). 

2) I am using an Ubuntu 16.10 with a 4.8.0-59-generic kernel version 

 

Apparently the first point is not problematic. 

 

The second point is more troublesome. 

 

When you try to compile the board kernel driver (>aocl install) the compilation crashes because the get_user_pages function (from mm.h) has less parameters in newer kernels. I have tried to implement the missing function (with more parameters) getting inspiration from older kernel sources. See the implementation below 

// @author David Castells-Rufas 

// In new kernels (> 4.6) get_user_pages use current task info, 

// so go to the more complete function. I get some inspiration from 

// http://elixir.free-electrons.com/linux/v4.6/source/mm/nommu.c#l162 

long get_user_pages_old_kernel(struct task_struct *tsk, struct mm_struct *mm, 

unsigned long start, unsigned long nr_pages, 

int write, int force, struct page **pages, 

struct vm_area_struct **vmas) 

int flags = 0; 

 

 

if (write) 

flags |= FOLL_WRITE; 

if (force) 

flags |= FOLL_FORCE; 

 

 

return __get_user_pages(tsk, mm, start, nr_pages, flags, 

pages, vmas, NULL); 

 

 

 

When I do this, the driver compiles but when I execute I get some errors and the system finally crash.  

With this [failing] driver you can still do >aocl diagnose (without parameters) but when you try ">aocl diagnose acl0" the system starts transferring memory, and the application detects a lot of memory errors... 

Transferring 8192 KBs in 16 512 KB blocks ... 

Error! Mismatch at element 1008: 3f0 != 1efbf0, xor = 001ef800 

Error! Mismatch at element 1009: 55b1a2e9 != 1229541c, xor = 4798f6f5 

... 

 

 

To solve these issues I have looked for a debian package with a kernel having the get_user_pages function with the long list of parameters. I found it to be 4.4.0-24-generic. So I installed it and recompiled the driver against it. 

 

After rebooting my system using the 4.4.0 kernel the OpenCL driver works and ">aocl diagnose acl0" runs smoothly.  

However I would like to work with the newer kernel as it has other implications (for other drivers). 

 

 

Anyone knows whether there are drivers adapted to newer Linux Kernels? 

Or whether anyone has tried to do it or either Altera/Intel or Terasic have internal people working on that? 

 

Thanks !
0 Kudos
8 Replies
Altera_Forum
Honored Contributor II
1,476 Views

Terasic only officially supports CentOS 7 right now, you should not use any other OS unless you are willing to dig through and manually fix all the problems you will face like what you mentioned above. There reason why they specifically stick to CentOS is that they don't want to spend their resources on keeping the driver updated for the quickly-changing kernels on Debian/Ubuntu/etc. Needless to say, you will not receive any support from Teraisc unless you use a supported OS, either; the first thing they will tell you is to switch to a supported OS. 

 

Furthermore, Terasic has not released a BSP for Quartus v17.0.2 yet. Even though their v16.1 BSP might work with the newer Quartus on their Stratix V board (but definitely not the Arria 10 one), I recommend sticking with Quartus v16.1.2 to avoid more headaches.
0 Kudos
Altera_Forum
Honored Contributor II
1,476 Views

With the help of Michal Hocko, and Lorenzo Stoakes I found the solution! 

Thank you so much guys!! 

 

In some newer kernels (I am using 4.8) you can simply use get_user_pages_remote instead get_user_pages. 

For some kernels, the parameter list is exactly the same!! 

 

Be carefull, than recent kernels have a slightly different parameter list, but that I guess that can be easily adapted. 

To be able to support both (4.4) and (4.8) kernels I modifyed the code as follows... 

 

# if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0) 

ret = get_user_pages(target_task, target_task->mm, 

start_page + got * PAGE_SIZE, 

num_pages - got, 

1, 1, 

p + got, vma); 

# else 

ret = get_user_pages_remote(target_task, target_task->mm, 

start_page + got * PAGE_SIZE, 

num_pages - got, 

1,1, p+got, 

vma); 

# endif 

 

 

Now ">aocl diagnose acl0" seems to be working smoothly on 4.8 !!
0 Kudos
Altera_Forum
Honored Contributor II
1,476 Views

Yes, you are right HRZ.  

But that's the great thing about Open Source software, the community can help Terasic and Intel to support newer kernels. 

See my auto-response.
0 Kudos
Altera_Forum
Honored Contributor II
1,476 Views

Great, I am glad you got it to work in the end.

0 Kudos
Altera_Forum
Honored Contributor II
1,476 Views

Hi, 

 

Always stick to the published operating system requirement, Ubuntu is not yet a supported operating system. 

 

http://dl.altera.com/requirements/17.0/ 

 

Regards, 

CloseCL 

(This message was posted on behalf of Intel Corporation)
0 Kudos
Altera_Forum
Honored Contributor II
1,476 Views

Now I switched to Ubuntu 17.10, new update in https://github.com/davidcastells/alteraopenclpcidriver

0 Kudos
Altera_Forum
Honored Contributor II
1,476 Views

Now that AOCL 17.1 support Ubuntu 16.04.2, and the aclpci_cmd.c file uses get_user_pages_remote for newer kernels,  

aocl install still crashed with Ubuntu 16.04.3: 

Building driver for BSP with name a10_ref make: Entering directory '/usr/src/linux-headers-4.13.0-37-generic' CC /tmp/opencl_driver_8bc8zu/aclpci_queue.o CC /tmp/opencl_driver_8bc8zu/aclpci.o /tmp/opencl_driver_8bc8zu/aclpci.c: In function ‘aclpci_irq’: /tmp/opencl_driver_8bc8zu/aclpci.c:343:17: error: implicit declaration of function ‘send_sig_info’ int ret = send_sig_info(aclpci->signal_number, &aclpci->signal_info, aclp ^ cc1: some warnings being treated as errors scripts/Makefile.build:308: recipe for target '/tmp/opencl_driver_8bc8zu/aclpci.o' failed make: *** Error 1 Makefile:1550: recipe for target '_module_/tmp/opencl_driver_8bc8zu' failed make: *** Error 2 make: Leaving directory '/usr/src/linux-headers-4.13.0-37-generic' aocl install: failed.  

Board: Arria 10GX 

Is it because I'm using Ubuntu 16.04.3 instead of 16.04.2 (rollback seems like a pain in the butt so I haven't try it yet) 

Anyone have idea how to solve this? Thanks!
0 Kudos
EBozo
Beginner
1,476 Views

This happened to me and my solution is

Add #include <linux/sched/signal.h> to the aclpci.h file.

The location of the prototype, send_sig_info, changed, which is not in linux/sched.h anymore for the newer kernel, so that it failed to compile.

0 Kudos
Reply