Accelerate/LAPACK 32-bit float matrix inversion returns incorrect values (Haswell+10.11).

Originator:raphael
Number:rdar://23878162 Date Originated:14-Dec-2015 09:38 AM
Status:Open Resolved:
Product:OS X SDK Product Version:10.11.2 (15C50)
Classification:Serious Bug Reproducible:Always
 
Summary:
Accelerate/LAPACK 32-bit float matrix inversion returns incorrect values (Haswell+10.11).

Summary:
Accelerate/LAPACK 32-bit float matrix inversion returns incorrect values.

Steps to Reproduce:
I could not isolate the problem outside of our app, but I can provide steps to reproduce the problem inside of our app.

Here's the code leading to erroneous results:
template<>
	bool matrix<float>::invert()  {
		//assert(cols == rows);
		__CLPK_integer n = rows;
		__CLPK_integer *ipiv = new __CLPK_integer[n];
		__CLPK_integer nwork = n*n;
		float *work = new float[nwork];
		__CLPK_integer info;
		bool res = false;
		
		// There is a pb with non-4/8 multiple on AVX2 (Haswell) + 10.11 (float, double are OK). 
		//			print("mat");
		sgetrf_(&n,&n,values(),&n,ipiv,&info);
		if(info == 0) {
			sgetri_(&n,values(),&n,ipiv,work,&nwork,&info);
			res = (info == 0);
		}
		//			print("imat");
		
		delete[] ipiv;
		delete[] work;
		
		return res;
	}

To reproduce the problem in Prizmo:
- Unzip the provided app on an Haswell or more recent Mac (supposedly AVX2)
- Open Prizmo.app
- Menu > Help > Sample Documents > Open Text Document
- Notice the document preview appears all black instead of actual contents.


Expected Results:
- Actual document contents.

Actual Results:
- All black image. The inverted matrix mentioned above has a number of 'nan' lines instead of correct values, as compared to pre-Haswell CPUs (same code)

Regression:
- Problem occurs with Haswell or more recent CPU, running OS X 10.11.x
- No problem with pre-10.11
- No problem with pre-Haswell
- No problem with double version (dgetrf_ / dgetri_)

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!