0

I have got very similar problem to this one stated here : Intel CPU OpenCL in Mono killed by SIGXCPU (Ubuntu)

Essentially, I have a very simple C# application using OpenCL (through OpenCL.Net wrapper, but it shouldn't make a difference as it is merely wrapping native functions and nothing more). In the code I just build kernel and then allocate a big array of floats.

To be more specific my platform: It is Ubuntu 12.04, OpenCL 1.1 (with CUDA) and mono 3.0.3.

Problem: When running my code through mono i get CPU LIMIT EXCEEDED error

Few things:

  • If I set a breakpoint (in monodevelop) somewhere between building the kernel and allocation it works..
  • Changing array size to small one also makes it work

Strace doesn't show anything useful. I tried also passing a callback to ClBuildProgram (to note: if I comment out line with ClBuildProgram it works).

Any ideas?

Community
  • 1
  • 1
kudkudak
  • 496
  • 3
  • 7
  • Looking at the post you linked to and your finding that using a smaller problem size makes the problem disappear, I suspect that you have hit the maximum time allowed for an OpenCL kernel. On Windows, there are registry entries to control that timeout. On Linux, I am not sure, but stopping the X window system might help. Users of CUDA on Linux suffer the same problem so there is likely to be a solution lying around on the Nvidia forums. – chippies Jul 27 '13 at 11:12
  • Thanks for your answer, well it wasn't that because this creation is on CPU side. However it triggers GC (see below) – kudkudak Jul 29 '13 at 10:47

1 Answers1

0

That's what worked for me in the end.

There is a major problem with mono - it uses SIGXCPU for GC handling (which is strange btw). Unfortunately OpenCL uses it as well so it conflicts.

Workaround is to modify mono code.

Go to source directory and grep -r SIGXCPU . In my mono (3.0.3) there were 2 imporant files

./libgc/pthread_stop_world.c:# define SIG_THR_RESTART SIGXCPU

./mono/metadata/sgen-os-posix.c:const static int restart_signal_num = SIGXCPU;

Replace SIGXCPU with SIGWINCH and recompile. One note is that I am not sure if it didn't break something, but for now looks OK and OpenCL problem is gone. If it breaks something (like gui) replace SIGWINCH with different signal that you have (signals.h for signals defs)

kudkudak
  • 496
  • 3
  • 7