fangq / mmc

Mesh-based Monte Carlo (MMC)
Other
40 stars 32 forks source link

Running "make oct" fails #16

Closed alexpattyn closed 6 years ago

alexpattyn commented 6 years ago

OS: Fedora Silverblue 28 CPU: AMD® Ryzen 5 1600 six-core processor × 12 GPU: Radeon RX 580 Series (POLARIS10 / DRM 3.26.0 / 4.18.8-200.fc28.x86_64, LLVM 6.0.1) With GNU Octave 4.4.1

See: https://github.com/flathub/org.octave.Octave/issues/33

From the provided link it seems like there is an error making mmc.mex with octave 4.4.1 when running system(make oct) From within Octave.

Building bin/mmc
CC=cc CXX=g++ LFLAGS='-fopenmp' LDFLAGS='' CPPFLAGS='-c -Wall -g -fno-strict-aliasing -m64 -DMMC_USE_SSE -DHAVE_SSE2 -msse -msse2 -msse3 -mssse3 -msse4.1 -O3 -fopenmp  -fPIC -DMCX_CONTAINER -DUSE_OS_TIMER -std=c++11'  mkoctfile  --mex mmclab.cpp -I../src -o bin/mmc built/posix_randr.o built/simpmesh.o built/tettracing.o built/mcx_utils.o built/tictoc.o built/mmc.o built/mmc_host.o built/cjson/cJSON.o -o ../mmclab/mmc
mmclab.cpp: In function ‘void mexFunction(int, mxArray**, int, constmxArray**)’:
mmclab.cpp:273:95: error: cannot convert ‘dimtype* {aka int*}’ to ‘const mwSize* {aka const long int*}’ for argument ‘2’ to ‘mxArray* mxCreateNumericArray(mwSize, const mwSize*, mxClassID, mxComplexity)’
 ,jstruct,0, mxCreateNumericArray(3,fielddim,mxSINGLE_CLASS,mxREAL));
                                                                  ^
mmclab.cpp:279:103: error: cannot convert ‘dimtype* {aka int*}’ to ‘const mwSize* {aka const long int*}’ for argument ‘2’ to ‘mxArray* mxCreateNumericArray(mwSize, const mwSize*, mxClassID, mxComplexity)’
 ,jstruct,0, mxCreateNumericArray(2,fielddim,mxSINGLE_CLASS,mxREAL));
                                                                  ^
mmclab.cpp:284:115: error: cannot convert ‘dimtype* {aka int*}’ to ‘const mwSize* {aka const long int*}’ for argument ‘2’ to ‘mxArray* mxCreateNumericArray(mwSize, const mwSize*, mxClassID, mxComplexity)’
 ],jstruct,0, mxCreateNumericArray(2,fielddim,mxUINT8_CLASS,mxREAL));
                                                                  ^
mmclab.cpp:350:101: error: cannot convert ‘dimtype* {aka int*}’ to ‘const mwSize* {aka const long int*}’ for argument ‘2’ to ‘mxArray* mxCreateNumericArray(mwSize, const mwSize*, mxClassID, mxComplexity)’
 ,jstruct,0, mxCreateNumericArray(4,fielddim,mxDOUBLE_CLASS,mxREAL));
                                                                  ^
mmclab.cpp:352:105: error: cannot convert ‘dimtype* {aka int*}’ to ‘const mwSize* {aka const long int*}’ for argument ‘2’ to ‘mxArray* mxCreateNumericArray(mwSize, const mwSize*, mxClassID, mxComplexity)’
 ,jstruct,0, mxCreateNumericArray(2,fielddim,mxDOUBLE_CLASS,mxREAL));
                                                                  ^
mmclab.cpp: In function ‘void mmc_set_field(const mxArray*, const mxArray*, int, mcconfig*, tetmesh*)’:
mmclab.cpp:438:38: error: cannot convert ‘const mwSize* {aka const long int*}’ to ‘const dimtype* {aka const int*}’ in assignment
         arraydim=mxGetDimensions(item);
                                      ^
mmclab.cpp:450:38: error: cannot convert ‘const mwSize* {aka const long int*}’ to ‘const dimtype* {aka const int*}’ in assignment
         arraydim=mxGetDimensions(item);
                                      ^
mmclab.cpp:463:38: error: cannot convert ‘const mwSize* {aka const long int*}’ to ‘const dimtype* {aka const int*}’ in assignment
         arraydim=mxGetDimensions(item);
                                      ^
mmclab.cpp:474:38: error: cannot convert ‘const mwSize* {aka const long int*}’ to ‘const dimtype* {aka const int*}’ in assignment
         arraydim=mxGetDimensions(item);
                                      ^
mmclab.cpp:487:38: error: cannot convert ‘const mwSize* {aka const long int*}’ to ‘const dimtype* {aka const int*}’ in assignment
         arraydim=mxGetDimensions(item);
                                      ^
mmclab.cpp:498:38: error: cannot convert ‘const mwSize* {aka const long int*}’ to ‘const dimtype* {aka const int*}’ in assignment
         arraydim=mxGetDimensions(item);
                                      ^
mmclab.cpp:510:38: error: cannot convert ‘const mwSize* {aka const long int*}’ to ‘const dimtype* {aka const int*}’ in assignment
         arraydim=mxGetDimensions(item);
                                      ^
mmclab.cpp:565:38: error: cannot convert ‘const mwSize* {aka const long int*}’ to ‘const dimtype* {aka const int*}’ in assignment
         arraydim=mxGetDimensions(item);
                                      ^
mmclab.cpp:613:38: error: cannot convert ‘const mwSize* {aka const long int*}’ to ‘const dimtype* {aka const int*}’ in assignment
         arraydim=mxGetDimensions(item);
                                      ^
mmclab.cpp:630:38: error: cannot convert ‘const mwSize* {aka const long int*}’ to ‘const dimtype* {aka const int*}’ in assignment
         arraydim=mxGetDimensions(item);
                                      ^
mmclab.cpp:638:31: error: cannot convert ‘const mwSize* {aka const long int*}’ to ‘const dimtype* {aka const int*}’ in assignment
  arraydim=mxGetDimensions(item);
                               ^
make: *** [../commons/Makefile_common.mk:180: bin/mmc] Error 1
ans =  2
mtmiller commented 6 years ago

Seems to be a problem with this section of mmclab.cpp:

#if (! defined MX_API_VER) || (MX_API_VER < 0x07300000)
    typedef int dimtype;                              //! MATLAB before 2017 uses int as the dimension array
#else
    typedef size_t dimtype;                           //! MATLAB after 2017 uses size_t as the dimension array
#endif

Instead of a custom typedef, this should be using mwSize, which is declared by both Matlab and Octave to represent the integer used for array sizes. In Octave 4.2 and older, mwSize was int, but in Octave 4.4, mwSize is now int64_t.

alexpattyn commented 6 years ago

@mtmiller So just go ahead and change

#if (! defined MX_API_VER) || (MX_API_VER < 0x07300000)
    typedef int dimtype;                              //! MATLAB before 2017 uses int as the dimension array
#else
    typedef size_t dimtype;                           //! MATLAB after 2017 uses size_t as the dimension array
#endif

to ...

#if (! defined MX_API_VER) || (MX_API_VER < 0x07300000)
    mwSize int dimtype;                              //! MATLAB before 2017 uses int as the dimension array
#else
    mwSize size_t dimtype;                           //! MATLAB after 2017 uses size_t as the dimension array
#endif

Sorry I am not too familiar with writing C/C++.

mtmiller commented 6 years ago

@koenigjaeger Answered with #17.