bug-gmp
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Function mpz_gcd() works differently on HPUX and Linux - ia64


From: Prashanth PS
Subject: Function mpz_gcd() works differently on HPUX and Linux - ia64
Date: Tue, 14 Oct 2003 13:11:24 +0530
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624

Hi Team,

    I would like to discuss and resolve two issues I stumble upon when working with HPUX/ia64.

i)    I've been trying to install ans work with GMP on HPUX (ansi C Compiler) and Linux (Gnu C Compiler) on ia64 machines. Though installation and tests (including "make check") work fine with gcc/Linux, t-constants fails during the first phase ("make check"), with an error (5 out of 4 tests passed),

        PP_INVERTED == 21cfe6cfc938b36b, but pp_inverted_calc == 0

ii)  I also have a test program attached (test.c) which behaves/prints different values for the function mpz_gcd() on Linux and HPUX. I was just wondering if I was compiling it in an improper way of missed any definitions, I investigated for some time and found that the function __MPN() (probably) used bu mpz_gcd() was in assembly code (mpn/ia64/invert_limb.asm). Can you please have a look and comment on this problem,


Issue i) Description,

The compilation works just fine on Linux with Gcc. However with aCC/HPUX, the conversion of assembly file from invert_limb.asm to tmp-invert_limb.s and then to invert_limb.o does not work (bcoz of .section .rodata ). So I compiled invert_limb.o with "gcc -c -mlp64" and the rest of the GMP code with HPUX' ansi C Compiler.

The error when using aCC to compile invert_limb.o / invert_limb.lo is as below,

#  make invert_limb.lo

        /bin/sh ../libtool --mode=compile --tag=CC ../mpn/m4-ccas --m4="m4" cc -c -DHAVE_CONFIG_H -I. -I. -I.. -D__GMP_WITHIN_GMP -I..  -DOPERATION_`echo invert_limb | sed 's/_$//'`     -O  `test -f invert_limb.asm || echo './'`invert_limb.asm
../mpn/m4-ccas --m4=m4 cc -c -DHAVE_CONFIG_H -I. -I. -I.. -D__GMP_WITHIN_GMP -I.. -DOPERATION_invert_limb -O invert_limb.asm  -DPIC -o .libs/invert_limb.o
m4  -DHAVE_CONFIG_H -D__GMP_WITHIN_GMP -DOPERATION_invert_limb -DPIC invert_limb.asm >tmp-invert_limb.s
 cc -c -DHAVE_CONFIG_H -I. -I. -I.. -D__GMP_WITHIN_GMP -I.. -DOPERATION_invert_limb -O +DD64 +Ofast tmp-invert_limb.s -DPIC -o .libs/invert_limb.o
tmp-invert_limb.s:46: error 4044: '.rodata' is not a section
tmp-invert_limb.s:47: error 4013: no current section
tmp-invert_limb.s:48: error 4013: no current section
tmp-invert_limb.s:48: error 4013: no current section
tmp-invert_limb.s:49: error 4013: no current section
*** Error exit code 1
 
Stop.

The file invert_limb.asm is linked by configure(?) as "invert_limb.asm -> .././mpn/ia64/invert_limb.asm".

>From the compiler folks I undertand that HPUX/aCC (doesnot ??) understand/like the format ".section    .rodata". Hence this problem.


Issue ii) description,

The compile string used to compile test.c is,

cc -O +DD64 +Ofast -I. -I.. -L /usr/conf/lib -L /Gmp/gmp-4.1.2/.libs ../.libs/libgmp.so test.c -o test

The printed results are,

# ./test

first, mp_size= 1, mp_d=1
sec, mp_size=1, mp_d=0
gcd, mp_alloc=1, mp_size= 1, mp_d=1

first, mp_size= 0, mp_d=0
sec,   mp_size=1, mp_d=1
gcd,  mp_size= 1, mp_d=2

Exiting due to _mp_size=0
GCD returned = 2

So this says gcd(0,1) = 2 which is wrong. Can you please let me know your comments. In case you have some instrumentation or changes to test on HPUX/ia64, please feel free to contact me. I am hoping for a fast resolution to this issue (with your co-operation of course :-).

Req: Please donot share the test source with/on public distributions lists.

Thanks in advance,
Prashanth Sriram
#include <stdio.h>
#include <time.h>
#include "gmp.h"

main(int argc,char **argv)
{
        mpz_t final,gcd,sec,first,mod;
        long prime;


        mpz_init(mod);
        mpz_init(first);
        mpz_init(gcd);
        mpz_init(sec);
        mpz_init(final);
        mpz_set_ui(final,8888);

        prime=2;
        mpz_set_ui(mod,2);
        mpz_set_ui(first,prime);
        mpz_set_ui(sec,0);
        mpz_set_ui(gcd,1);

        while( (mpz_cmp(final,mod) >= 0) && (mpz_cmp_ui(gcd,1)==0) )
        {
                mpz_powm(sec,first,first,mod);
                mpz_sub_ui(first,first,1);
                mpz_gcd(gcd,first,sec);
                mpz_add_ui(mod,mod,1);

                printf("first, mp_alloc=%ld, mp_size= %ld, mp_d=%ld\n",
                first[0]._mp_alloc, first[0]._mp_size, first[0]._mp_d[0]);
                printf("sec, mp_size=%ld, mp_d=%ld\n",
                sec[0]._mp_alloc, sec[0]._mp_size, sec[0]._mp_d[0]);
                printf("gcd, mp_alloc=%ld, mp_size= %ld, mp_d=%ld\n",
                gcd[0]._mp_alloc, gcd[0]._mp_size, gcd[0]._mp_d[0]);

                if(! first[0]._mp_size ){ /* If I were to remove this I get 
floating exception for "prime=7"*/
                        printf("Exiting due to _mp_size=0\n");
                        break;
                }
        }
        printf("GCD returned = %ld\n", gcd[0]._mp_d[0]);
}


reply via email to

[Prev in Thread] Current Thread [Next in Thread]