Closed jezekr closed 1 year ago
Many thanks @jezekr ! Because Octave is free, it would be great to add test for your interface in the continuous integration scripts. This way, we can be sure it continues to work as intended over time.
I am a bit concerned that when I complie here, I get
Compiling mcutest gcc -c -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/octave-6.4.0/octave/.. -I/usr/include/octave-6.4.0/octave -fopenmp -g -O2 -ffile-prefix-map=/build/octave-LVK0E0/octave-6.4.0=. -flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -g -I. -I/usr/include/octave-6.4.0/octave/ -I/home/nimg/fortran/optrove_git/cutest/include -DMEX_DEBUG mcutest.c -o mcutest.o mcutest.c: In function ‘SparseVector’: mcutest.c:1982:8: warning: assignment to ‘int ’ from incompatible pointer type ‘mwIndex ’ {aka ‘long int ’} [-Wincompatible-pointer-types] 1982 | ir = mxGetIr(vector); | ^ mcutest.c:1983:10: warning: assignment to ‘int ’ from incompatible pointer type ‘mwIndex ’ {aka ‘long int ’} [-Wincompatible-pointer-types] 1983 | jptr = mxGetJc(vector); | ^ mcutest.c: In function ‘extractSparseVector’: mcutest.c:2019:8: warning: assignment to ‘int ’ from incompatible pointer type ‘mwIndex ’ {aka ‘long int ’} [-Wincompatible-pointer-types] 2019 | ir = mxGetIr(vector); | ^ mcutest.c:2020:10: warning: assignment to ‘int ’ from incompatible pointer type ‘mwIndex ’ {aka ‘long int ’} [-Wincompatible-pointer-types] 2020 | jptr = mxGetJc(vector); | ^ mcutest.c: In function ‘coordToMatlabSparse’: mcutest.c:2066:10: warning: assignment to ‘int ’ from incompatible pointer type ‘mwIndex ’ {aka ‘long int ’} [-Wincompatible-pointer-types] 2066 | ir = mxGetIr(matrix); / Array of length nnz / | ^ mcutest.c:2067:10: warning: assignment to ‘int ’ from incompatible pointer type ‘mwIndex ’ {aka ‘long int ’} [-Wincompatible-pointer-types] 2067 | jptr = mxGetJc(matrix); / Array of length ncol+1 /
Getting the correct tie between Mex types is always painful, particularly when Matlab kept changing its mind. It seems as if mxGetIr/mexJc in octave may not be long integers. Is this an issue ... it only seems to be a compiler warning
What was your command?
make -f $CUTEST/makefiles/pc64.lnx.gfo all in the $CUTEST/src/octave directory It looks as if mxGetIr/mexJc have a different type in octave than for Matlab.
Once I start octave (and having created a mcutest.mex file), I seem to have a further problem -
prob = cutest_setup() error: /home/nimg/problems/sif/mcutest.mex: failed to load: /home/nimg/problems/sif/mcutest.mex: undefined symbol: cutestudimsh error: called from cutest_setup at line 10 column 20
This may be related to the earlier issue?
mwIndex is defined in usr/include/$OCTAVE_VERSION/octave/mxarray.h
in my version I found: /*
but in every version of Octave it is different.
Have you enabled MATLAB functionalities when you installed CUTEST?
I have the same comment, but in octave-6.4.0 the file sets
typedef int64_t mwSize; typedef int64_t mwIndex; typedef int64_t mwSignedIndex;
Yes, everything is ok with Matlab.
You should not enable MATLAB functionalities. Please install CUTEST without enabling MATLAB functionalities.
Before you setup a problem always clear mcutest. This is necessary in Octave. Maybe I should add this to the documentary.
I am not sure I understand, octave generates mcutest.mex, while matlab generates mcutest.mexa64. What else should I remove (yes, this needs to be in the README)?
When I run your command I get Compiling mcutest /bin/cp mcutest.c /home/romana/OctaveWorkSpace/TEallFinal/TEprob/CUTEST/cutest/objects/pc64.lnx.gfo/double/mcutest.c cd /home/romana/OctaveWorkSpace/TEallFinal/TEprob/CUTEST/cutest/objects/pc64.lnx.gfo/double ; mkoctfile --mex -v -c -g -I/usr/include/octave-4.2.2/octave/ -I/home/romana/OctaveWorkSpace/TEallFinal/TEprob/CUTEST/cutest/include mcutest.c gcc -c -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/octave-4.2.2/octave/.. -I/usr/include/octave-4.2.2/octave -I/usr/include/hdf5/serial -pthread -fopenmp -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -g -I. -I/usr/include/octave-4.2.2/octave/ -I/home/romana/OctaveWorkSpace/TEallFinal/TEprob/CUTEST/cutest/include -DMEX_DEBUG mcutest.c -o mcutest.o /bin/rm -f /home/romana/OctaveWorkSpace/TEallFinal/TEprob/CUTEST/cutest/objects/pc64.lnx.gfo/double/mcutest.c [ OK ] CUTEst: octave (double precision version) compiled successfully
That's why I thought it must be in the makefile but I could not find the reason why it doesn't work. I have tested Octave 4,5, and 6. What I did was changing the compiler versions in install_cutest, MATLABGCC, MATLABGFORTRAN before I installed it.
This is an interface for Octave