Re: [HACKERS] GIN FailedAssertions on Itanium2 with Intel

2006-09-04 Thread Bruce Momjian

I suggest you test for the Intel compiler, and if it is there, make the
static variable volatile, and add a comment about why that is being
done.

---

Sergey E. Koposov wrote:
 On Sat, 2 Sep 2006, Bruce Momjian wrote:
 
  Teodor Sigaev wrote:
  What does that option do? Is it practical to enable it for the entire
  backend?
   From docs:
  Disables inline expansion of standard library or intrinsic functions.
 
  And isn't this a straightforward compiler bug they should be notified
  about?
  What's a choice? Now I see 3:
  1) -O1
  2) volatile
  3) -nolib_inline
 
  IMHO, only -O1 is guarantee for other possible places... But I'm not 
  familiar
  enough with such kinds of bugs.
 
  My guess is that the compiler writers saw you calling a libc function,
  and assumed that library could not modify the file static variable,
  forgetting that the libc function can call back into the original file.
 
  Can you detect the Itanium compiler and optimization levels via
  preprocessor symbols, and test for that, and throw an #error?
 
 No, it's impossible.
 Unfortunately the __OPTIMIZE__ preproc. symbol of icc doesn't allow to 
 distinguish between different optimization levels. (only between -O0 and 
 anything else).
 
 Regards,
   Sergey
 
 ***
 Sergey E. Koposov
 Max Planck Institute for Astronomy/Sternberg Astronomical Institute
 Tel: +49-6221-528-349
 Web: http://lnfm1.sai.msu.ru/~math
 E-mail: [EMAIL PROTECTED]
 
 ---(end of broadcast)---
 TIP 4: Have you searched our list archives?
 
http://archives.postgresql.org

-- 
  Bruce Momjian   [EMAIL PROTECTED]
  EnterpriseDBhttp://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +

---(end of broadcast)---
TIP 3: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faq


Re: [HACKERS] GIN FailedAssertions on Itanium2 with Intel compiler

2006-09-03 Thread Sergey E. Koposov

On Sat, 2 Sep 2006, Bruce Momjian wrote:


Teodor Sigaev wrote:

What does that option do? Is it practical to enable it for the entire
backend?

 From docs:
Disables inline expansion of standard library or intrinsic functions.


And isn't this a straightforward compiler bug they should be notified
about?

What's a choice? Now I see 3:
1) -O1
2) volatile
3) -nolib_inline

IMHO, only -O1 is guarantee for other possible places... But I'm not familiar
enough with such kinds of bugs.


My guess is that the compiler writers saw you calling a libc function,
and assumed that library could not modify the file static variable,
forgetting that the libc function can call back into the original file.

Can you detect the Itanium compiler and optimization levels via
preprocessor symbols, and test for that, and throw an #error?


No, it's impossible.
Unfortunately the __OPTIMIZE__ preproc. symbol of icc doesn't allow to 
distinguish between different optimization levels. (only between -O0 and 
anything else).


Regards,
Sergey

***
Sergey E. Koposov
Max Planck Institute for Astronomy/Sternberg Astronomical Institute
Tel: +49-6221-528-349
Web: http://lnfm1.sai.msu.ru/~math
E-mail: [EMAIL PROTECTED]

---(end of broadcast)---
TIP 4: Have you searched our list archives?

  http://archives.postgresql.org


Re: [HACKERS] GIN FailedAssertions on Itanium2 with Intel

2006-09-02 Thread Bruce Momjian
Teodor Sigaev wrote:
  What does that option do? Is it practical to enable it for the entire
  backend?
  From docs:
 Disables inline expansion of standard library or intrinsic functions.
 
  And isn't this a straightforward compiler bug they should be notified
  about?
 What's a choice? Now I see 3:
 1) -O1
 2) volatile
 3) -nolib_inline
 
 IMHO, only -O1 is guarantee for other possible places... But I'm not familiar 
 enough with such kinds of bugs.

My guess is that the compiler writers saw you calling a libc function,
and assumed that library could not modify the file static variable,
forgetting that the libc function can call back into the original file.

Can you detect the Itanium compiler and optimization levels via
preprocessor symbols, and test for that, and throw an #error?

-- 
  Bruce Momjian   [EMAIL PROTECTED]
  EnterpriseDBhttp://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +

---(end of broadcast)---
TIP 6: explain analyze is your friend


Re: [HACKERS] GIN FailedAssertions on Itanium2 with Intel compiler

2006-09-01 Thread Teodor Sigaev
Huh, it's a over-optimization by icc on Itanium. With -00 or -02 there 
is no any problem, only -O2 produces such effect. The problem is in code 


Sorry, right With -00 or -01 there is no any problem

--
Teodor Sigaev   E-mail: [EMAIL PROTECTED]
   WWW: http://www.sigaev.ru/

---(end of broadcast)---
TIP 6: explain analyze is your friend


Re: [HACKERS] GIN FailedAssertions on Itanium2 with Intel compiler

2006-09-01 Thread Teodor Sigaev

% icc -O2 -o 1 1.c  ./1
CALL cmp
SET SI = 1
BUG: SI==0
% icc -O1 -o 1 1.c  ./1
CALL cmp
SET SI = 1
OK


BTW, this example works correct with -nolib-inline 
(http://www.intel.com/software/products/compilers/clin/docs/main_cls/mergedprojects/copts_cls/ccpp_options/option_nolib_inline.htm):

% icc -O2 -nolib_inline  -o 1 1.c ./1
CALL cmp
SET SI = 1
OK

PS Have anybody any thoughts about workaround?
--
Teodor Sigaev   E-mail: [EMAIL PROTECTED]
   WWW: http://www.sigaev.ru/

---(end of broadcast)---
TIP 9: In versions below 8.0, the planner will ignore your desire to
  choose an index scan if your joining column's datatypes do not
  match


Re: [HACKERS] GIN FailedAssertions on Itanium2 with Intel compiler

2006-09-01 Thread Martijn van Oosterhout
On Fri, Sep 01, 2006 at 03:10:44PM +0400, Teodor Sigaev wrote:
 BTW, this example works correct with -nolib-inline 
 (http://www.intel.com/software/products/compilers/clin/docs/main_cls/mergedprojects/copts_cls/ccpp_options/option_nolib_inline.htm):
 % icc -O2 -nolib_inline  -o 1 1.c ./1
 CALL cmp
 SET SI = 1
 OK
 
 PS Have anybody any thoughts about workaround?

What does that option do? Is it practical to enable it for the entire
backend?

And isn't this a straightforward compiler bug they should be notified
about?

Sounds like the -fno-strict-aliasing option for gcc, the compiler is
making some assumptions about the code that arn't true, so we tell the
compiler not to do that.

Have a nice day,
-- 
Martijn van Oosterhout   kleptog@svana.org   http://svana.org/kleptog/
 From each according to his ability. To each according to his ability to 
 litigate.


signature.asc
Description: Digital signature


Re: [HACKERS] GIN FailedAssertions on Itanium2 with Intel compiler

2006-09-01 Thread Teodor Sigaev

What does that option do? Is it practical to enable it for the entire
backend?

From docs:
Disables inline expansion of standard library or intrinsic functions.


And isn't this a straightforward compiler bug they should be notified
about?

What's a choice? Now I see 3:
1) -O1
2) volatile
3) -nolib_inline

IMHO, only -O1 is guarantee for other possible places... But I'm not familiar 
enough with such kinds of bugs.


--
Teodor Sigaev   E-mail: [EMAIL PROTECTED]
   WWW: http://www.sigaev.ru/

---(end of broadcast)---
TIP 9: In versions below 8.0, the planner will ignore your desire to
  choose an index scan if your joining column's datatypes do not
  match


Re: [HACKERS] GIN FailedAssertions on Itanium2 with Intel compiler

2006-08-31 Thread Teodor Sigaev
Huh, it's a over-optimization by icc on Itanium. With -00 or -02 there is no any 
problem, only -O2 produces such effect. The problem is in code at lines 125-172 
in ginutils.c:


static bool needUnique = false;

int cmpFunc(...) {
...
if (...) needUnique = true;
...
}
...
needUnique = false;
qsort(, cmpFunc);
if (needUnique) 

And, needUnique was setted to true in last call of cmpFunc (by accident, in 
fact), so between last call and checking of needUnique there isn't any call of 
function. Insertion after qsort() any call (elog, for example) solves the problem.


If needUnique is marked as volatile, all is ok too. But this way doesn't seem 
to me as reasonable, because there is a lot of places with potentially the same 
problem... and thats may cause unpredictable failures. May be, better way is 
limiting optimization level on Itanium with icc.






--
Teodor Sigaev   E-mail: [EMAIL PROTECTED]
   WWW: http://www.sigaev.ru/

---(end of broadcast)---
TIP 5: don't forget to increase your free space map settings


Re: [HACKERS] GIN FailedAssertions on Itanium2 with Intel compiler

2006-08-31 Thread Teodor Sigaev

Simple illustration:

#include stdio.h
#include stdlib.h

static char SI = 0;

static int
cmp(const void *a, const void *b) {
puts(CALL cmp);
if ( *(int*)a == *(int*)b ) {
puts(SET SI = 1);
SI = 1;
return 0;
}
return ( *(int*)a  *(int*)b ) ? 1 : -1;
}

int
main(int argn, char *argv[]) {
int a[]={43,43};

SI = 0;
qsort(a, sizeof(a)/sizeof(int),  sizeof(int), cmp);

if ( SI )
puts(OK);
else
puts(BUG: SI==0);

return 0;
}


% icc -O2 -o 1 1.c  ./1
CALL cmp
SET SI = 1
BUG: SI==0
% icc -O1 -o 1 1.c  ./1
CALL cmp
SET SI = 1
OK


--
Teodor Sigaev   E-mail: [EMAIL PROTECTED]
   WWW: http://www.sigaev.ru/

---(end of broadcast)---
TIP 6: explain analyze is your friend


[HACKERS] GIN FailedAssertions on Itanium2 with Intel compiler

2006-08-30 Thread Sergey E. Koposov

Hello -hackers,

I see a make check failures on Itanium2 platform with Intel Compiler 
with CVS HEAD. A failure is coming for GIN.


The problem is coming at the assertion at ginbulk.c:62
TRAP: FailedAssertion(!(res != 0), File: ginbulk.c, Line: 62)

during the index creation from the regr. tests
CREATE INDEX ii on array_index_op_test using gin(i);

The backtraces before the assertion (unfortunately from intel debugger...):

(idb) bt 
#0  0x4014d370 in ginChooseElem (accum=0x3, heapptr=0x182, entries=0x120012, nentry=16384, low=2, high=16, offset=8192) at ginbulk.c:62

#1  0x4014cd00 in ginChooseElem (accum=0x3, heapptr=0x182, 
entries=0x120012, nentry=16384, low=2, high=16, offset=8192) at 
ginbulk.c:168
#2  0x4014c790 in ginInsertRecordBA (accum=0x3, heapptr=0x182, 
entries=0x120012, nentry=16384) at ginbulk.c:192
#3  0x40123380 in ginBuildCallback (index=0x3, htup=0x182, 
values=0x120012, isnull=0x4000 no value, tupleIsAlive=2 '\002', 
state=0x180010) at gininsert.c:203
#4  0x40174ee0 in IndexBuildHeapScan (heapRelation=0x3, 
indexRelation=0x182, indexInfo=0x120012, callback=0x4000, 
callback_state=0x182) at index.c:1534
#5  0x40124ea0 in ginbuild (fcinfo=0x3) at gininsert.c:311
#6  0x406eaf00 in OidFunctionCall3 (functionId=3, arg1=1649267441666, 
arg2=77309411346, arg3=16384) at fmgr.c:1460
#7  0x40177390 in reindex_relation (relid=3, toast_too=2 '\002') at 
index.c:1282
#8  0x40172700 in index_create (heapRelationId=3, 
indexRelationName=0x182 no value, indexRelationId=18, 
indexInfo=0x4000, accessMethodObjectId=2, tableSpaceId=16, classObjectId=0x2000, 
reloptions=1649267441666, isprimary=0 '\000', isconstraint=0 '\000', 
allow_system_table_mods=0 '\000', skip_build=0 '\000', concurrent=0 '\000') at 
index.c:782
---Type return to continue, or q return to quit---
#9  0x40270df0 in DefineIndex (heapRelation=0x3, indexRelationName=0x182 no 
value, indexRelationId=18, accessMethodName=0x4000 no value, 
tableSpaceName=0x182 no value, attributeList=0x180010, predicate=0x2000, 
rangetable=0x182, options=0x0, unique=0 '\000', primary=0 '\000', isconstraint=0 '\000', 
is_alter_table=0 '\000', check_rights=1 '\001', skip_build=0 '\000', quiet=0 '\000', concurrent=0 
'\000') at indexcmds.c:440
#10 0x4051b3b0 in ProcessUtility (parsetree=0x3, params=0x182, 
dest=0x120012, completionTag=0x4000 no value) at utility.c:789
#11 0x40518100 in PortalRunMulti (portal=0x3, dest=0x182, 
altdest=0x120012, completionTag=0x4000 no value) at pquery.c:1062
#12 0x40516f90 in PortalRun (portal=0x3, count=1649267441666, 
dest=0x120012, altdest=0x4000, completionTag=0x182 no value) at 
pquery.c:700
#13 0x4050e770 in exec_simple_query (query_string=0x3 no value) at 
postgres.c:1003
#14 0x4050bc20 in PostgresMain (argc=3, argv=0x182, 
username=0x120012 no value) at postgres.c:3263
#15 0x4045fc20 in BackendRun (port=0x3) at postmaster.c:2848
#16 0x4045ea80 in ServerLoop () at postmaster.c:2485
#17 0x4045c310 in PostmasterMain (argc=3, argv=0x182) at 
postmaster.c:950
#18 0x4035a0b0 in main (argc=3, argv=0x182) at main.c:187

(idb) bt full
#0  0x4014d370 in ginChooseElem (accum=0x3, heapptr=0x182, 
entries=0x120012, nentry=16384, low=2, high=16, offset=8192) at ginbulk.c:62
middle=Info: symbol middle is defined but not allocated (optimized away)
no value
pos=Info: symbol pos is defined but not allocated (optimized away)
no value
#1  0x4014cd00 in ginChooseElem (accum=0x3, heapptr=0x182, 
entries=0x120012, nentry=16384, low=2, high=16, offset=8192) at 
ginbulk.c:168
middle=Info: symbol middle is defined but not allocated (optimized away)
no value
pos=Info: symbol pos is defined but not allocated (optimized away)
no value
#2  0x4014c790 in ginInsertRecordBA (accum=0x3, heapptr=0x182, 
entries=0x120012, nentry=16384) at ginbulk.c:192
i=Info: symbol i is defined but not allocated (optimized away)
no value
nbit=Info: symbol nbit is defined but not allocated (optimized away)
no value
offset=Info: symbol offset is defined but not allocated (optimized away)
no value
#3  0x40123380 in ginBuildCallback (index=0x3, htup=0x182, 
values=0x120012, isnull=0x4000 no value, tupleIsAlive=2 '\002', 
state=0x180010) at gininsert.c:203
---Type return to continue, or q return to quit---
buildstate=Info: symbol buildstate is defined but not allocated 
(optimized away)
no value
oldCtx=Info: symbol oldCtx is defined but not allocated (optimized away)
no value
#4  0x40174ee0 in IndexBuildHeapScan (heapRelation=0x3, 
indexRelation=0x182, indexInfo=0x120012,