This code testing gsl works fine:
import futhark
{.passL: "-lgsl -lgslcblas".}
importc:
"gsl/gsl_sf_bessel.h"
var
x = 5.0
y = gslSfBesselJ0(x)
echo "J=(", x, ") = ", y
but oddly, this does not:
import futhark
{.passL: "-lgsl -lgslcblas".}
importc:
"gsl/gsl_linalg.h"
var
a_data = @[ 0.18'f64, 0.60'f64, 0.57'f64, 0.96'f64, 0.41'f64, 0.24'f64, 0.99'f64, 0.58'f64, 0.14'f64, 0.30'f64, 0.97'f64, 0.66'f64, 0.51'f64, 0.13'f64, 0.19'f64, 0.85]
b_data = @[1.0'f64, 2.0'f64, 3.0'f64, 4.0'f64]
m = gsl_matrix_view_array(addr a_data[0], 4, 4)
echo "a_data =(", a_data, ")"
echo "b_data =(", b_data, ")"
This is the error I get:
/home/tkd/.nimble/pkgs/futhark-0.3.1/futhark.nim(440, 14) template/generic instantiation of `importcImpl` from here
/home/tkd/.choosenim/toolchains/nim-1.6.0/lib/pure/parsejson.nim(179, 8) Error: interpretation requires too many iterations; if you are sure this is not a bug in your code, compile with `--maxLoopIterationsVM:number` (current value: 10000000)
Thanks. That got rid of that problem but now it produces the error:
: undeclared identifier: 'gsl_matrix_view_array'
If it can find gslSfBesselJ0 in the first example above, I see no reason why it cannot fined gsl_matrix_view_array.
I have also tried specifying the path explicitly with the same result.
Thanks @ pietroppeter.
I was just using gsl to test Futharks' C ffi. Once @PMunch gets it to be 100% fully operational, I believe it would be more sustainable and better for maintenance than just wrapping a library (if one has the choice).
I see you're stepping on the same problem I faced when learning how to use futhark.
The general rule is that opir (first pass) reads the whole C code just lite clang would do, while futhark (second pass) generates wrappers only for the explicitly listed .h files to avoid excessive clutter.
TDK, also consider that a proper wrapper is a better solution for the community (AFAIK this is also araq's opinion), but I believe futhark is a great helper for this tast too.