ArrayFire has a couple of features which sacrifice debugging in favor of speed. On of these features is the Just-in Time(JIT) compilation. The JIT allows us to create custom kernels at run-time and defer execution of those kernels until the data is necessary. This makes things difficult to debug because not all variables are updated when you want to look at the values in the debugger. This feature is a critical performance feature which would drastically hurt performance if it was turned off.

It is therefore necessary to debug at run-time. There are techniques you can use to debug an ArrayFire program. ArrayFire comes with an excellent graphics library which will allow you to visualize the data you are working on. For example you can view an image in your program by calling the image function.

If you need to get specific values of your data, you can use the print macro. This will print all the values on the console. Printing all the values might not be convenient if you are working on a large data-set. For this reason we have created a macro/function which will print the first eight(8) elements in an array along with its dimensions: