justingardner / mgl

A suite of mex/m files for displaying psychophysics stimuli
http://justingardner.net/mgl
Other
18 stars 22 forks source link

mglResolution array size error #21

Closed rtraghavan closed 2 years ago

rtraghavan commented 7 years ago

I'm getting a very weird error. I compiled mgl 2.0 on a system using matlab 9.2, SDKs 10.11, and OS X 10.10.5. I tried a hack around the usual Objective C errors thrown up by the use of 10.11 (and its reliance on clang). In any case, most everything compiles with a few warnings. But now I can't for the life of me run mglOpen due to an error thrown up by mglResolution. Below is what happens when I recompile mglResolution

mglMake('mglResolution')

optf =

'-f /Volumes/Seagate_2TB/mgl/mgllib/clang_maci64.xml' 

NOTE the above is the hack, I copied the clang_maci64.xml file from matlab and added some the same flags in mexopts.sh into that file

(mglMake) Using -f /Volumes/Seagate_2TB/mgl/mgllib/clang_maci64.xml options for mex mex -f /Volumes/Seagate_2TB/mgl/mgllib/clang_maci64.xml /Volumes/Seagate_2TB/mgl/mgllib/mglResolution.c Building with 'Xcode with Clang'. In file included from /Volumes/Seagate_2TB/mgl/mgllib/mglResolution.c:17: /Volumes/Seagate_2TB/mgl/mgllib/mgl.h:250:65: warning: incompatible pointer types passing 'int [1]' to parameter of type 'const size_t ' (aka 'const unsigned long ') [-Wincompatible-pointer-types] mexPutVariable("global",MGL_GLOBAL_NAME,mxCreateStructArray(1,ndims,nfields, field_names)); ^~~~~ /Applications/MATLAB9.2.app/extern/include/matrix.h:961:52: note: passing argument to parameter 'dims' here mxCreateStructArray_730(size_t ndim, const size_t *dims, int nfields, const char *fieldnames); ^ /Volumes/Seagate_2TB/mgl/mgllib/mglResolution.c:113:35: warning: incompatible pointer types passing 'const int [2]' to parameter of type 'const size_t ' (aka 'const unsigned long ') [-Wincompatible-pointer-types] plhs[0] = mxCreateStructArray(1,outDims,6,fieldNames); ^~~ /Applications/MATLAB9.2.app/extern/include/matrix.h:961:52: note: passing argument to parameter 'dims' here mxCreateStructArray_730(size_t ndim, const size_t dims, int nfields, const char **fieldnames); ^ /Volumes/Seagate_2TB/mgl/mgllib/mglResolution.c:351:19: warning: 'CGDisplayModeCopyPixelEncoding' is deprecated: first deprecated in OS X 10.11 [-Wdeprecated-declarations] pixelEncoding = CGDisplayModeCopyPixelEncoding(displayMode); ^ /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CGDirectDisplay.h:174:34: note: 'CGDisplayModeCopyPixelEncoding' has been explicitly marked deprecated here CG_EXTERN CFStringRef __nullable CGDisplayModeCopyPixelEncoding( ^ 3 warnings generated.

MEX completed successfully.

Okay the mex file compiles with a few warnings, and I move onto running mglOpen and get thrown the following error

mglOpen(2,1280,960,120,32);

Error using mglResolution Requested 4294967297x1 (192.0GB) array exceeds maximum array size preference. Creation of arrays greater than this limit may take a long time and cause MATLAB to become unresponsive. See array size limit or preference panel for more information.

Error in mglOpen (line 66) displayResolution = mglResolution;

Have you ever seen anything like this. Do you think it's an error due to the warnings during compilation?

Thank you

rtraghavan commented 7 years ago

The solution to the problem was provided to me by L. Hallum at NYU. This was related to a warning thrown up when I tried to compile mglResolution.c

The fix, changing the following lines in mgl.h

ifndef _WIN64

define mwIndex int

define mwSize int

endif

to

ifndef _WIN64

ifndef __x86_64__

define mwIndex int

define mwSize int

endif

justingardner commented 2 years ago

Closing out - we are working on a new version of metal (based on metal) with new compilation scripts mglMakeMetal this will be the new default version of mgl for newer systems / matlab versions / OS versions