<div dir="ltr">Hey,<br><div class="gmail_extra"><br><br><div class="gmail_quote">2013/12/9 Stephan Bergmann <span dir="ltr"><<a href="mailto:sbergman@redhat.com" target="_blank">sbergman@redhat.com</a>></span><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
I was trying to find out why on my MacBook recent master "make check" reproducibly fails CppunitTest_sc_opencl with<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
warn:sc.opencl:13647:1:sc/<u></u>source/core/opencl/<u></u>formulagroupcl.cxx:2737: CL_BUILD_PROGRAM_FAILURE, status -2, log "Error getting function data from server"<br>
</blockquote>
[...]<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
warn:sc.opencl:13647:1:sc/<u></u>source/core/opencl/<u></u>formulagroupcl.cxx:2737: CL_BUILD_PROGRAM_FAILURE, status -2, log "Error getting function data from server"<br>
</blockquote>
[...]<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
warn:sc.opencl:13647:1:sc/<u></u>source/core/opencl/<u></u>formulagroupcl.cxx:2737: CL_BUILD_PROGRAM_FAILURE, status -2, log "Error getting function data from server"<br>
</blockquote>
[...]<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
warn:sc.opencl:13647:1:sc/<u></u>source/core/opencl/<u></u>formulagroupcl.cxx:2737: CL_BUILD_PROGRAM_FAILURE, status -2, log "Error getting function data from server"<br>
</blockquote>
[...]<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
##Failure Location unknown## : Error<br>
Test name: ScOpenclTest::<u></u>testFinacialFormula<br>
uncaught exception of unknown type<br>
<br>
##Failure Location unknown## : Error<br>
Test name: ScOpenclTest::<u></u>testFinancialCoupdaysncFormula<br>
uncaught exception of unknown type<br>
<br>
##Failure Location unknown## : Error<br>
Test name: ScOpenclTest::<u></u>testFinacialYIELDFormula<br>
uncaught exception of unknown type<br>
<br>
##Failure Location unknown## : Error<br>
Test name: ScOpenclTest::<u></u>testFinacialPriceFormula<br>
uncaught exception of unknown type<br>
<br>
Failures !!!<br>
Run: 174 Failure total: 4 Failures: 0 Errors: 4<br>
</blockquote>
<br>
while just "make CppunitTest_sc_opencl" succeeds. Turns out the machine has two GPUs, a built-in Intel HD Graphics 4000 and an additional NVIDIA GeForce GT 650M, and that it apparently executes the OpenCL code on the latter (where it fails) only if there's enough graphics power demand, like in the case of a full (non-headless on Mac) "make check". (Though it looks like it doesn't suffice to disable "System Preferences... - Energy Saver - Automatic graphics switching" to make it use the NVIDIA GPU for the OpenCL code even in the "make CppunitTest_sc_opencl" scenario.)<br>
</blockquote><div><br></div><div>The selection code is based on a heuristic. We compile a small test program and rank the difference OpenCL devices/platforms based on the performance. So it might be normal that you see different results depending on the workload, ...<br>
<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
And using the NVIDIA GPU to compile some of the OpenCL programs apparently causes a CL_BUILD_PROGRAM_FAILURE from clBuildProgram. However, the "Error getting function data from server" program build log does not give much of a clue what's going wrong. (And inducing something like a syntax error into the OpenCL program code would result in a much more verbose log pointing out the compilation error, so it can't be something trivial like that.)<br>
<br>
The OpenCL program code in the first of the four failing cases is<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
#pragma OPENCL EXTENSION cl_khr_fp64: enable<br>
int isNan(double a) { return isnan(a); }<br>
double fsum_count(double a, double b, __private int *p) {<br>
bool t = isNan(a);<br>
(*p) += t?0:1;<br>
return t?b:a+b;<br>
}<br>
double fsum(double a, double b) { return isNan(a)?b:a+b; }<br>
double legalize(double a, double b) { return isNan(a)?b:a;}<br>
double fsub(double a, double b) { return a-b; }<br>
double fdiv(double a, double b) { return a/b; }<br>
double strequal(unsigned a, unsigned b) { return (a==b)?1.0:0; }<br>
double mcw_fmin(double a, double b) { return fmin(a, b); }<br>
double mcw_fmax(double a, double b) { return fmax(a, b); }<br>
bool IsLeapYear( int n );<br>
double coupdaybs( int nSettle,int nMat,int nFreq,int nBase);<br>
double coupdays(int nSettle,int nMat,int nFreq,int nBase);<br>
double coupdaysnc( int nSettle,int nMat,int nFreq,int nBase);<br>
double coupnum( int nSettle,int nMat,int nFreq,int nBase);<br>
double getPrice_(int nSettle, int nMat, double fRate, double fYield,<br>
double fRedemp, int nFreq, int nBase );<br>
double getYield_( int nNullDate, int nSettle, int nMat, double fCoup,double fPrice,double fRedemp, int nFreq, int nBase);<br>
int DateToDays( int nDay, int nMonth, int nYear );<br>
int DaysInMonth( int nMonth, int nYear );<br>
int GetDaysInYear( int nNullDate, int nDate, int nMode );<br>
int GetDaysInYears( int nYear1, int nYear2 );<br>
int GetNullDate(void);<br>
int getDaysInMonthRange( int nFrom, int nTo,int b30Days,int year);<br>
int getDaysInYearRange( int nFrom, int nTo,int b30Days );<br>
int getDiff(int rFrom,int rTo,int fDay,int fMonth,int fYear,int fbLastDayMode,int fbLastDay,int fb30Days,int fbUSMode,int fnDay,int tDay,int tMonth,int tYear,int tbLastDayMode,int tbLastDay,int tb30Days,int tbUSMode,int tnDay);<br>
int lcl_Getcoupdaybs(int nNullDate,int nSettle, int nMat,int nFreq,int nBase);<br>
int lcl_Getcoupdays(int nNullDate,int nSettle, int nMat,int nFreq,int nBase);<br>
int lcl_Getcoupnum(int nNullDate,int nSettle, int nMat,int nFreq);<br>
void DaysToDate( int nDays, int *rDay, int* rMonth, int* rYear );<br>
void ScaDate( int nNullDate, int nDate, int nBase,int *nOrigDay, int *nMonth,int *nYear,int *bLastDayMode,int *bLastDay,int *b30Days,int *bUSMode,int *nDay);<br>
void addMonths(int b30Days,int bLastDay,int *nDay,int nOrigDay,int *nMonth,int nMonthCount,int *year);<br>
bool IsLeapYear( int n )<br>
{<br>
return ( (( ( n % 4 ) == 0 ) && ( ( n % 100 ) != 0)) || ( ( n % 400 ) == 0 ) );<br>
}<br>
double coupdaybs( int nSettle,int nMat,int nFreq,int nBase)<br>
{<br>
int nNullDate=GetNullDate();<br>
return lcl_Getcoupdaybs(nNullDate, nSettle, nMat,nFreq, nBase);<br>
}<br>
double coupdays(int nSettle,int nMat,int nFreq,int nBase)<br>
{<br>
int nNullDate=GetNullDate();<br>
if( nBase == 1 )<br>
return lcl_Getcoupdays(nNullDate, nSettle, nMat,nFreq, nBase);<br>
else<br>
return (double)GetDaysInYear(0,0,<u></u>nBase)/nFreq;<br>
}<br>
double coupdaysnc( int nSettle,int nMat,int nFreq,int nBase)<br>
{<br>
int nNullDate=GetNullDate();<br>
if((nBase != 0) && (nBase != 4))<br>
{<br>
int aDate = nMat;<br>
int rDay=0,rMonth=0, rYear=0;int mDay=0,mMonth=0, mYear=0;int sDay=0,sMonth=0, sYear=0;<br>
int rbLastDayMode=0, rbLastDay=0,rb30Days=0,<u></u>rbUSMode=0,rnDay=0;<br>
int sbLastDayMode=0, sbLastDay=0,sb30Days=0,<u></u>sbUSMode=0,snDay=0;<br>
ScaDate( nNullDate,aDate,nBase,&rDay,&<u></u>rMonth,&rYear,&rbLastDayMode,&<u></u>rbLastDay,&rb30Days,&rbUSMode,<u></u>&rnDay);<br>
ScaDate( nNullDate,nSettle,nBase,&sDay,<u></u>&sMonth,&sYear,&sbLastDayMode,<u></u>&sbLastDay,&sb30Days,&<u></u>sbUSMode,&snDay);<br>
rYear= sYear;<br>
nSettle=nSettle+nNullDate;<br>
aDate=DateToDays( rDay,rMonth,rYear );<br>
if( aDate > nSettle )<br>
{<br>
rYear-= 1;<br>
aDate=DateToDays( rDay,rMonth,rYear );<br>
}<br>
while(aDate <= nSettle )<br>
{<br>
addMonths(rb30Days,rbLastDay,&<u></u>rnDay,rDay,&rMonth,12/nFreq,&<u></u>rYear);<br>
aDate=DateToDays( rDay,rMonth,rYear );<br>
}<br>
return getDiff( nSettle, aDate, sDay, sMonth, sYear, sbLastDayMode, sbLastDay, sb30Days, sbUSMode, snDay, rDay, rMonth, rYear, rbLastDayMode, rbLastDay, rb30Days, rbUSMode, rnDay);<br>
}<br>
else<br>
return coupdays(nSettle,nMat,nFreq,<u></u>nBase)- coupdaybs( nSettle,nMat,nFreq,nBase);<br>
}<br>
double coupnum( int nSettle,int nMat,int nFreq,int nBase)<br>
{<br>
int nNullDate=GetNullDate();<br>
return lcl_Getcoupnum(nNullDate,<u></u>nSettle,nMat,nFreq);<br>
}<br>
double getPrice_(int nSettle, int nMat, double fRate, double fYield,<br>
double fRedemp, int nFreq, int nBase )<br>
{<br>
double fFreq = nFreq;<br>
double fE = coupdays( nSettle, nMat, nFreq, nBase );<br>
double fDSC_E = coupdaysnc( nSettle, nMat, nFreq, nBase ) / fE;<br>
double fN = coupnum( nSettle, nMat, nFreq, nBase );<br>
double fA = coupdaybs( nSettle, nMat, nFreq, nBase );<br>
double fRet = fRedemp / ( pow( 1.0 + fYield / fFreq, fN - 1.0 + fDSC_E ) );<br>
fRet -= 100.0 * fRate / fFreq * fA / fE;<br>
double fT1 = 100.0 * fRate / fFreq;<br>
double fT2 = 1.0 + fYield / fFreq;<br>
for( double fK = 0.0 ; fK < fN ; fK+=1.0 )<br>
fRet += fT1 / pow( fT2, fK + fDSC_E );<br>
return fRet;<br>
}<br>
double getYield_( int nNullDate, int nSettle, int nMat, double fCoup,double fPrice,double fRedemp, int nFreq, int nBase )<br>
{<br>
double fRate = fCoup;<br>
double fPriceN = 0.0;<br>
double fYield1 = 0.0;<br>
double fYield2 = 1.0;<br>
double fPrice1 = getPrice_(nSettle, nMat, fRate, fYield1, fRedemp, nFreq, nBase );<br>
double fPrice2 = getPrice_(nSettle, nMat, fRate, fYield2, fRedemp, nFreq, nBase );<br>
double fYieldN = ( fYield2 - fYield1 ) * 0.5;<br>
for( unsigned int nIter = 0 ; nIter < 100 && fPriceN != fPrice ; nIter++ )<br>
{<br>
fPriceN = getPrice_(nSettle, nMat, fRate, fYieldN, fRedemp, nFreq, nBase );<br>
if( fPrice == fPrice1 )<br>
return fYield1;<br>
else if( fPrice == fPrice2 )<br>
return fYield2;<br>
else if( fPrice == fPriceN )<br>
return fYieldN;<br>
else if( fPrice < fPrice2 )<br>
{<br>
fYield2 *= 2.0;<br>
fPrice2 = getPrice_(nSettle, nMat, fRate, fYield2, fRedemp, nFreq, nBase );<br>
fYieldN = ( fYield2 - fYield1 ) * 0.5;<br>
}<br>
else<br>
{<br>
if( fPrice < fPriceN )<br>
{<br>
fYield1 = fYieldN;<br>
fPrice1 = fPriceN;<br>
}<br>
else<br>
{<br>
fYield2 = fYieldN;<br>
fPrice2 = fPriceN;<br>
}<br>
fYieldN = fYield2 - ( fYield2 - fYield1 ) * ( ( fPrice - fPrice2 ) / ( fPrice1 - fPrice2 ) );<br>
}<br>
}<br>
return fYieldN;<br>
}<br>
int DateToDays( int nDay, int nMonth, int nYear )<br>
{<br>
int nDays = ((int)nYear-1) * 365;<br>
nDays += ((nYear-1) / 4) - ((nYear-1) / 100) + ((nYear-1) / 400);<br>
for( int i = 1; i < nMonth; i++ )<br>
nDays += DaysInMonth(i,nYear);<br>
nDays += nDay;<br>
<br>
return nDays;<br>
}<br>
int DaysInMonth( int nMonth, int nYear )<br>
{<br>
int aDaysInMonth[12] = { 31, 28, 31, 30, 31, 30,<br>
31, 31, 30, 31, 30, 31 };<br>
<br>
if ( nMonth != 2 )<br>
return aDaysInMonth[nMonth-1];<br>
else<br>
{<br>
if ( IsLeapYear(nYear) )<br>
return aDaysInMonth[nMonth-1] + 1;<br>
else<br>
return aDaysInMonth[nMonth-1];<br>
}<br>
}<br>
int GetDaysInYear( int nNullDate, int nDate, int nMode )<br>
{<br>
switch( nMode )<br>
{<br>
case 0:<br>
case 2:<br>
case 4:<br>
return 360;<br>
case 1:<br>
{<br>
int nD=0, nM=0, nY=0;<br>
nDate += nNullDate;<br>
DaysToDate( nDate, &nD, &nM, &nY );<br>
return IsLeapYear( nY )? 366 : 365;<br>
}<br>
case 3:<br>
return 365;<br>
}<br>
}<br>
int GetDaysInYears( int nYear1, int nYear2 )<br>
{<br>
int nLeaps = 0;<br>
for( int n = nYear1 ; n <= nYear2 ; n++ )<br>
{<br>
if( IsLeapYear( n ) )<br>
nLeaps++;<br>
}<br>
int nSum = 1;<br>
nSum += nYear2;<br>
nSum -= nYear1;<br>
nSum *= 365;<br>
nSum += nLeaps;<br>
return nSum;<br>
}<br>
int GetNullDate(void)<br>
{<br>
return DateToDays(30,12,1899 );<br>
}<br>
int getDaysInMonthRange( int nFrom, int nTo,int b30Days,int year)<br>
{<br>
if( nFrom > nTo )<br>
return 0;<br>
int nRet = 0;<br>
if( b30Days )<br>
nRet = (nTo - nFrom + 1) * 30;<br>
else<br>
{<br>
for( int nMonthIx = nFrom; nMonthIx <= nTo; ++nMonthIx )<br>
nRet += b30Days ? 30 : DaysInMonth( nMonthIx, year );<br>
}<br>
return nRet;<br>
}<br>
int getDaysInYearRange( int nFrom, int nTo,int b30Days )<br>
{<br>
if( nFrom > nTo )<br>
return 0;<br>
return b30Days ? ((nTo - nFrom + 1) * 360) : GetDaysInYears( nFrom, nTo);<br>
}<br>
int getDiff(int rFrom,int rTo,int fDay,int fMonth,int fYear,int fbLastDayMode,int fbLastDay,int fb30Days,int fbUSMode,int fnDay,int tDay,int tMonth,int tYear,int tbLastDayMode,int tbLastDay,int tb30Days,int tbUSMode,int tnDay)<br>
{<br>
if(rFrom>rTo)<br>
{<br>
int d=fDay;fDay=tDay;tDay=d;<br>
int m=fMonth;fMonth=tMonth;tMonth=<u></u>m;<br>
int y=fYear;fYear=tYear;tYear=y;<br>
int a=fbLastDayMode;fbLastDayMode=<u></u>tbLastDayMode;tbLastDayMode=a;<br>
int b=fbLastDay;fbLastDay=<u></u>tbLastDay;tbLastDay=b;<br>
int c=fb30Days;fb30Days=tb30Days;<u></u>tb30Days=c;<br>
int e=fbUSMode;fbUSMode=tbUSMode;<u></u>tbUSMode=e;<br>
int f=fnDay;fnDay=tnDay;tnDay=f;<br>
}<br>
int nDiff=0;<br>
if( tb30Days )<br>
{<br>
if( tbUSMode )<br>
{<br>
if( ((fMonth == 2) || (fnDay < 30)) && (tDay == 31) )<br>
tnDay = 31;<br>
else if( (tMonth == 2) && tbLastDay )<br>
tnDay = DaysInMonth( 2, tYear );<br>
}<br>
else<br>
{<br>
if( (fMonth == 2) && (fnDay == 30) )<br>
fnDay = DaysInMonth( 2, fYear );<br>
if( (tMonth == 2) && (tnDay == 30) )<br>
tnDay = DaysInMonth( 2, tYear );<br>
}<br>
}<br>
if( (fYear < tYear) || ((fYear == tYear) && (fMonth < tMonth)) )<br>
{<br>
nDiff = (fb30Days? 30:DaysInMonth(fMonth,fYear) )- fnDay + 1;<br>
fDay = fnDay = 1;<br>
fbLastDay = 0;<br>
addMonths(fb30Days,fbLastDay,&<u></u>fnDay,fDay,&fMonth,1,&fYear);<br>
if( fYear < tYear )<br>
{<br>
nDiff += getDaysInMonthRange( fMonth, 12,fb30Days,fYear);<br>
addMonths(fb30Days,fbLastDay,&<u></u>fnDay,fDay,&fMonth,13-fMonth,&<u></u>fYear);<br>
nDiff += getDaysInYearRange( fYear, tYear - 1,fb30Days);<br>
fYear+=tYear - fYear;<br>
}<br>
nDiff += getDaysInMonthRange(fMonth, tMonth - 1,fb30Days ,fYear );<br>
addMonths(fb30Days,fbLastDay,&<u></u>fnDay,fDay,&fMonth,tMonth-<u></u>fMonth,&fYear);<br>
}<br>
nDiff += tnDay - fnDay;<br>
return nDiff > 0 ? nDiff : 0;<br>
}<br>
int lcl_Getcoupdaybs(int nNullDate,int nSettle, int nMat,int nFreq,int nBase)<br>
{<br>
int aDate = nMat;<br>
int rDay=0,rMonth=0, rYear=0;int mDay=0,mMonth=0, mYear=0;int sDay=0,sMonth=0, sYear=0;<br>
int rbLastDayMode=0, rbLastDay=0,rb30Days=0,<u></u>rbUSMode=0,rnDay=0;<br>
int sbLastDayMode=0, sbLastDay=0,sb30Days=0,<u></u>sbUSMode=0,snDay=0;<br>
ScaDate( nNullDate,aDate,nBase,&rDay,&<u></u>rMonth,&rYear,&rbLastDayMode,&<u></u>rbLastDay,&rb30Days,&rbUSMode,<u></u>&rnDay);<br>
ScaDate( nNullDate,nSettle,nBase,&sDay,<u></u>&sMonth,&sYear,&sbLastDayMode,<u></u>&sbLastDay,&sb30Days,&<u></u>sbUSMode,&snDay);<br>
rYear= sYear;<br>
nSettle=nSettle+nNullDate;<br>
aDate=DateToDays( rDay,rMonth,rYear );<br>
if( aDate < nSettle )<br>
{<br>
rYear+= 1;<br>
aDate=DateToDays( rDay,rMonth,rYear );<br>
}<br>
while(aDate > nSettle )<br>
{<br>
addMonths(rb30Days,rbLastDay,&<u></u>rnDay,rDay,&rMonth,-1*(12/<u></u>nFreq),&rYear);<br>
aDate=DateToDays( rDay,rMonth,rYear );<br>
}<br>
return getDiff( aDate, nSettle, rDay, rMonth, rYear, rbLastDayMode, rbLastDay, rb30Days, rbUSMode, rnDay, sDay, sMonth, sYear, sbLastDayMode,sbLastDay, sb30Days, sbUSMode, snDay);<br>
}<br>
int lcl_Getcoupdays(int nNullDate,int nSettle, int nMat,int nFreq,int nBase)<br>
{<br>
int aDate = nMat;<br>
int rDay=0,rMonth=0, rYear=0;int mDay=0,mMonth=0, mYear=0;int sDay=0,sMonth=0, sYear=0;<br>
int rbLastDayMode=0, rbLastDay=0,rb30Days=0,<u></u>rbUSMode=0,rnDay=0;<br>
int sbLastDayMode=0, sbLastDay=0,sb30Days=0,<u></u>sbUSMode=0,snDay=0;<br>
ScaDate( nNullDate,aDate,nBase,&rDay,&<u></u>rMonth,&rYear,&rbLastDayMode,&<u></u>rbLastDay,&rb30Days,&rbUSMode,<u></u>&rnDay);<br>
ScaDate( nNullDate,nSettle,nBase,&sDay,<u></u>&sMonth,&sYear,&sbLastDayMode,<u></u>&sbLastDay,&sb30Days,&<u></u>sbUSMode,&snDay);<br>
rYear= sYear;<br>
nSettle=nSettle+nNullDate;<br>
aDate=DateToDays( rDay,rMonth,rYear );<br>
if( aDate < nSettle )<br>
{<br>
rYear+= 1;<br>
aDate=DateToDays( rDay,rMonth,rYear );<br>
}<br>
while(aDate > nSettle )<br>
{<br>
addMonths(rb30Days,rbLastDay,&<u></u>rnDay,rDay,&rMonth,-1*(12/<u></u>nFreq),&rYear);<br>
aDate=DateToDays( rDay,rMonth,rYear );<br>
}<br>
int aNextDate=aDate;int aDay=rDay,aMonth=rMonth, aYear=rYear;<br>
int abLastDayMode=rbLastDayMode, abLastDay=rbLastDay,ab30Days=<u></u>rb30Days,abUSMode=rbUSMode,<u></u>anDay=rnDay;<br>
addMonths(ab30Days,abLastDay,&<u></u>anDay,aDay,&aMonth,12/nFreq,&<u></u>aYear);<br>
return getDiff( aDate, aNextDate, rDay, rMonth, rYear, rbLastDayMode, rbLastDay, rb30Days, rbUSMode, rnDay, aDay, aMonth, aYear, abLastDayMode,abLastDay, ab30Days, abUSMode, anDay);<br>
}<br>
int lcl_Getcoupnum(int nNullDate,int nSettle, int nMat,int nFreq)<br>
{<br>
int aDate = nMat;int rDay=0,rMonth=0, rYear=0;int mDay=0,mMonth=0, mYear=0;<br>
int sDay=0,sMonth=0, sYear=0;<br>
DaysToDate(aDate+nNullDate,&<u></u>rDay, &rMonth, &rYear );<br>
DaysToDate(nMat+nNullDate,&<u></u>mDay, &mMonth, &mYear );<br>
DaysToDate(nSettle+nNullDate,&<u></u>sDay, &sMonth, &sYear );<br>
rYear= sYear;<br>
nSettle=nSettle+nNullDate;<br>
aDate=DateToDays( rDay,rMonth,rYear );<br>
if( aDate < nSettle )<br>
rYear+= 1;<br>
int d=DateToDays( rDay,rMonth,rYear );<br>
int nMonthCount=-1*(12 / nFreq);<br>
while(d > nSettle )<br>
{<br>
int nNewMonth = nMonthCount + rMonth;<br>
if( nNewMonth > 12 )<br>
{<br>
--nNewMonth;<br>
rYear+=nNewMonth / 12;<br>
rMonth = nNewMonth % 12 + 1;<br>
}<br>
else if( nNewMonth < 1 )<br>
{<br>
rYear+= nNewMonth / 12 - 1;<br>
rMonth = nNewMonth % 12 + 12;<br>
}<br>
else<br>
rMonth = nNewMonth;<br>
d=DateToDays( rDay,rMonth,rYear );<br>
}<br>
int n=(mYear-rYear)*12+mMonth-<u></u>rMonth;<br>
n=n*nFreq/12;<br>
return n;<br>
}<br>
void DaysToDate( int nDays, int *rDay, int* rMonth, int* rYear )<br>
{<br>
<br>
int nTempDays;<br>
int i = 0;<br>
bool bCalc;<br>
do<br>
{<br>
nTempDays = nDays;<br>
*rYear = (int)((nTempDays / 365) - i);<br>
nTempDays -= ((int) *rYear -1) * 365;<br>
nTempDays -= (( *rYear -1) / 4) - (( *rYear -1) / 100) +((*rYear -1) / 400);<br>
bCalc = false;<br>
if ( nTempDays < 1 )<br>
{<br>
i++;<br>
bCalc = true;<br>
}<br>
else<br>
{<br>
if ( nTempDays > 365 )<br>
{<br>
if ( (nTempDays != 366) || !IsLeapYear( *rYear ) )<br>
{<br>
i--;<br>
bCalc = true;<br>
}<br>
}<br>
}<br>
}<br>
while ( bCalc );<br>
*rMonth = 1;<br>
while ( (int)nTempDays > DaysInMonth( *rMonth, *rYear ) )<br>
{<br>
nTempDays -= DaysInMonth( *rMonth, *rYear );<br>
*rMonth+=1;<br>
}<br>
*rDay = (int)nTempDays;<br>
}<br>
void ScaDate( int nNullDate, int nDate, int nBase,int *nOrigDay, int *nMonth,int *nYear,int *bLastDayMode,int *bLastDay,int *b30Days,int *bUSMode,int *nDay)<br>
{<br>
DaysToDate( nNullDate + nDate, nOrigDay, nMonth, nYear );<br>
*bLastDayMode = (nBase != 5);<br>
*bLastDay = (*nOrigDay >= DaysInMonth( *nMonth, *nYear ));<br>
*b30Days = (nBase == 0) || (nBase == 4);<br>
*bUSMode = (nBase == 0);<br>
if( *b30Days)<br>
{<br>
*nDay = min( *nOrigDay, 30);<br>
if( *bLastDay || (*nDay >=DaysInMonth( *nMonth, *nYear )) )<br>
*nDay = 30;<br>
}<br>
else<br>
{<br>
int nLastDay = DaysInMonth( *nMonth, *nYear );<br>
*nDay = *bLastDay ? nLastDay : min( *nOrigDay, nLastDay );<br>
}<br>
}<br>
void addMonths(int b30Days,int bLastDay,int *nDay,int nOrigDay,int *nMonth,int nMonthCount,int *year)<br>
{<br>
int nNewMonth = nMonthCount + *nMonth;<br>
if( nNewMonth > 12 )<br>
{<br>
--nNewMonth;<br>
*year+=nNewMonth / 12 ;<br>
*nMonth = ( nNewMonth % 12 ) + 1;<br>
}<br>
else if( nNewMonth < 1 )<br>
{<br>
*year+= nNewMonth / 12 - 1 ;<br>
*nMonth = nNewMonth % 12 + 12 ;<br>
}<br>
else<br>
*nMonth = nNewMonth ;<br>
if( b30Days )<br>
{<br>
*nDay = min( nOrigDay, 30);<br>
if( bLastDay || (*nDay >= DaysInMonth( *nMonth, *year )) )<br>
*nDay = 30;<br>
}<br>
else<br>
{<br>
int nLastDay = DaysInMonth( *nMonth, *year );<br>
*nDay = bLastDay ? nLastDay : min( nOrigDay, nLastDay );<br>
}<br>
}<br>
<br>
double tmp0_0_Yield(__global double *tmp0_0_0,__global double *tmp0_0_1,__global double *tmp0_0_2,__global double *tmp0_0_3,__global double *tmp0_0_4,__global double *tmp0_0_5,__global double *tmp0_0_6) {<br>
double tmp = 0;<br>
int gid0 = get_global_id(0);<br>
double tmp000;<br>
double tmp001;<br>
double tmp002;<br>
double tmp003;<br>
double tmp004;<br>
double tmp005;<br>
double tmp006;<br>
int buffer_tmp000_len = 11;<br>
int buffer_tmp001_len = 11;<br>
int buffer_tmp002_len = 11;<br>
int buffer_tmp003_len = 11;<br>
int buffer_tmp004_len = 11;<br>
int buffer_tmp005_len = 11;<br>
int buffer_tmp006_len = 11;<br>
if(gid0>=buffer_tmp000_len || isNan((gid0 < 11?tmp0_0_0[gid0]:NAN)))<br>
tmp000 = 0;<br>
else<br>
tmp000 = (gid0 < 11?tmp0_0_0[gid0]:NAN);<br>
if(gid0>=buffer_tmp001_len || isNan((gid0 < 11?tmp0_0_1[gid0]:NAN)))<br>
tmp001 = 0;<br>
else<br>
tmp001 = (gid0 < 11?tmp0_0_1[gid0]:NAN);<br>
if(gid0>=buffer_tmp002_len || isNan((gid0 < 11?tmp0_0_2[gid0]:NAN)))<br>
tmp002 = 0;<br>
else<br>
tmp002 = (gid0 < 11?tmp0_0_2[gid0]:NAN);<br>
if(gid0>=buffer_tmp003_len || isNan((gid0 < 11?tmp0_0_3[gid0]:NAN)))<br>
tmp003 = 0;<br>
else<br>
tmp003 = (gid0 < 11?tmp0_0_3[gid0]:NAN);<br>
if(gid0>=buffer_tmp004_len || isNan((gid0 < 11?tmp0_0_4[gid0]:NAN)))<br>
tmp004 = 0;<br>
else<br>
tmp004 = (gid0 < 11?tmp0_0_4[gid0]:NAN);<br>
if(gid0>=buffer_tmp005_len || isNan((gid0 < 11?tmp0_0_5[gid0]:NAN)))<br>
tmp005 = 0;<br>
else<br>
tmp005 = (gid0 < 11?tmp0_0_5[gid0]:NAN);<br>
if(gid0>=buffer_tmp006_len || isNan((gid0 < 11?tmp0_0_6[gid0]:NAN)))<br>
tmp006 = 0;<br>
else<br>
tmp006 = (gid0 < 11?tmp0_0_6[gid0]:NAN);<br>
tmp = getYield_(GetNullDate(),<u></u>tmp000,tmp001,tmp002,tmp003,<u></u>tmp004,tmp005,tmp006);<br>
return tmp;<br>
}<br>
double tmp0_nop(__global double *tmp0_0_0, __global double *tmp0_0_1, __global double *tmp0_0_2, __global double *tmp0_0_3, __global double *tmp0_0_4, __global double *tmp0_0_5, __global double *tmp0_0_6) {<br>
double tmp = 0;<br>
int gid0 = get_global_id(0);<br>
double tmpBottom;<br>
tmp = tmp0_0_Yield(tmp0_0_0, tmp0_0_1, tmp0_0_2, tmp0_0_3, tmp0_0_4, tmp0_0_5, tmp0_0_6);<br>
return tmp;<br>
}<br>
__kernel void DynamicKernel_nop_Yield(__<u></u>global double *result, __global double *tmp0_0_0, __global double *tmp0_0_1, __global double *tmp0_0_2, __global double *tmp0_0_3, __global double *tmp0_0_4, __global double *tmp0_0_5, __global double *tmp0_0_6) {<br>
int gid0 = get_global_id(0);<br>
result[gid0] = tmp0_nop(tmp0_0_0,tmp0_0_1,<u></u>tmp0_0_2,tmp0_0_3,tmp0_0_4,<u></u>tmp0_0_5,tmp0_0_6);<br>
}<br>
</blockquote>
<br>
and some experimentation revealed that replacing the call<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
return getDiff( nSettle, aDate, sDay, sMonth, sYear, sbLastDayMode, sbLastDay, sb30Days, sbUSMode, snDay, rDay, rMonth, rYear, rbLastDayMode, rbLastDay, rb30Days, rbUSMode, rnDay);<br>
</blockquote>
<br>
towards the end of the definition of coupdaysnc with<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
return 0.0;<br>
</blockquote>
<br>
prevents the build failure (though the test now trivially fails with a wrong result, of course).<br>
<br>
However, I have no idea what's wrong there. OpenCL forbids recursive functions, but this doesn't look like it is (indirectly) recursive. Maybe it is a problem of the NVIDIA GPU rather than our code?<br>
<br></blockquote><div><br></div><div>It looks like another broken OpenCL compiler. So basically I'd need from you the output of clinfo if available or otherwise the generated file of <a href="http://dev-www.libreoffice.org/opencl/Linux/">http://dev-www.libreoffice.org/opencl/Linux/</a> which hopefully runs on Mac as well. I'll use these information to block broken compilers. However it will take me some time to implement that because "OpenCL device selection 2.0" no longer uses the code for disabling devices.<br>
<br></div><div>Regards,<br></div><div>Markus<br></div></div></div></div>