Discussion:
[Gc] Fwd: Re[2]: PATCH: Add x32 support to boehm-gc
(too old to reply)
Ivan Maidanski
2012-05-01 15:20:14 UTC
Permalink
Hi H.J.,

I've applied your patches both to bdwgc and libatomic_ops (and both to master and release branches).

Regards.
----
Date: Mon, 16 Apr 2012 09:37:30 -0700
Subject: [libatomic_ops] PATCH: Add x32 support
User-Agent: Mutt/1.5.21 (2010-09-15)
Hi,
Here are 2 small patches to add x32 support to libatomic_ops. X32 info
can be found at
https://sites.google.com/site/x32abi/
....
H.J.
Hans
-----Original Message-----
Sent: Monday, April 30, 2012 2:55 PM
To: Boehm, Hans
Cc: Ivan Maidanski
Subject: Re: PATCH: Add x32 support to boehm-gc
H.J. -
I can't find the earlier message.
Ivan - Did you get it?
I also only see one patch here.
Here are 2 patches for bdwgc.  I also submitted 2 x32 patches for
libatomic_ops.  Please let me know if I should also send 2
libatomic_ops patches to you.
Thanks.
H.J.
--
What I see here looks uncontroversial, in spite of the fact that I'm
not a fan of a third x86 Linux ABI.
Hans
-----Original Message-----
Sent: Sunday, April 29, 2012 10:28 AM
Subject: PATCH: Add x32 support to boehm-gc
Hi,
This patch adds x32 support to boehm-gc.  The same patch has been
sent to the boehm-gc mailing list. Tested on Linux/x32 and
Linux/x86-
64.
OK for trunk?
Thanks.
H.J.
Date: Mon, 16 Apr 2012 09:39:20 -0700
Subject: [bdwgc] PATCH: Add x32 support
User-Agent: Mutt/1.5.21 (2010-09-15)
Hi,
Here are 2 small patches to add x32 support to bdwgc.  X32 info can
be found at
https://sites.google.com/site/x32abi/
They are fully tested on Linux/x32 and Linux/x86-64.
Thanks.
H.J.
---
H.J. Lu
2012-05-01 15:40:28 UTC
Permalink
Post by Ivan Maidanski
Hi H.J.,
I've applied your patches both to bdwgc and libatomic_ops (and both to master and release branches).
Here is another libatomic_ops patch to define AO_T_IS_INT for x32,
similar to ILP32 on ia64.

Thanks.
--
H.J.
Ivan Maidanski
2012-05-01 16:08:27 UTC
Permalink
Hi H.J.,

Done.
Post by Ivan Maidanski
Post by Ivan Maidanski
Hi H.J.,
I've applied your patches both to bdwgc and libatomic_ops (and both to
master and release branches).
Here is another libatomic_ops patch to define AO_T_IS_INT for x32,
similar to ILP32 on ia64.
Thanks.
H.J. Lu
2012-05-01 16:16:46 UTC
Permalink
Hi Ivan,

Thanks.
Post by Ivan Maidanski
Hi H.J.,
Done.
Post by Ivan Maidanski
Post by Ivan Maidanski
Hi H.J.,
I've applied your patches both to bdwgc and libatomic_ops (and both to
master and release branches).
Here is another libatomic_ops patch to define AO_T_IS_INT for x32,
similar to ILP32 on ia64.
Thanks.
--
H.J.
Ivan Maidanski
2012-09-30 17:20:33 UTC
Permalink
Hi H.J.,

Could you please test this branch of libatomic_ops under x32: https://github.com/ivmai/libatomic_ops/tree/master-untested ?

This branch contain 2 commits (extra to "master" branch):
1) a fix for AO_compare_double_and_swap_double_full - it should use cmpxchg8b instead of cmpxchg16b for x32
2) code refactoring merging x86_64.h code into x86.h file

In particular, it's unclear to me whether PIC mode for x32 is the same as for x86.

Thank you.

Regards,
Ivan
Post by H.J. Lu
Hi Ivan,
Thanks.
Post by H.J. Lu
Hi H.J.,
Done.
Post by Ivan Maidanski
Post by Ivan Maidanski
Hi H.J.,
I've applied your patches both to bdwgc and libatomic_ops (and both to
master and release branches).
Here is another libatomic_ops patch to define AO_T_IS_INT for x32,
similar to ILP32 on ia64.
Thanks.
--
H.J.
H.J. Lu
2012-09-30 20:32:49 UTC
Permalink
Post by Ivan Maidanski
Hi H.J.,
https://github.com/ivmai/libatomic_ops/tree/master-untested ?
X32 is x86-64 with 32bit pointers and long.
Post by Ivan Maidanski
1) a fix for AO_compare_double_and_swap_double_full - it should use
cmpxchg8b instead of cmpxchg16b for x32
src/atomic_ops/sysdeps/standard_ao_double_t.h has

#if (defined(__x86_64__) && __GNUC__ >= 4) || defined(_WIN64)
# include <xmmintrin.h>
typedef __m128 double_ptr_storage;
#elif defined(_WIN32) && !defined(__GNUC__)
typedef unsigned __int64 double_ptr_storage;
#else
typedef unsigned long long double_ptr_storage;
#endif

# define AO_HAVE_DOUBLE_PTR_STORAGE

typedef union {
double_ptr_storage AO_whole;
struct {AO_t AO_v1; AO_t AO_v2;} AO_parts;
} AO_double_t;
#define AO_HAVE_double_t

This is incorrect for x32 sice AO_t is size_t, which is
32bit for x32. X32 has native support for 64-bit integer
operations. For x32, AO_double_t is 64bit integer and
we can use 64-bit cmpxchg. There is no need for
x32 AO_compare_double_and_swap_double_full,
which breaks 64bit integer into 2 32-bit integers.
Can you add a 64-bit version of atomic operations?
Post by Ivan Maidanski
2) code refactoring merging x86_64.h code into x86.h file
In particular, it's unclear to me whether PIC mode for x32 is the same as for x86.
That is incorrect. X32 PIC is identical to x86-64 PIC.
--
H.J.
Ivan Maidanski
2012-10-08 15:28:52 UTC
Permalink
Hi H.J.,

Fix AO_compare_double_and_swap_double_full for x32 in this branch: https://github.com/ivmai/libatomic_ops/tree/fix-double-cas-x32 (diff against master: https://github.com/ivmai/libatomic_ops/compare/master...fix-double-cas-x32)
Please test it.

In fact, gcc/x86.h defines only double_compare_and_swap for x32 and compare_double_and_swap_double is defined now in generalize.h.

(Sorry for the delay but I've applied a dozen of patches related to code refactoring, double_cas testing (and improvement of MS VC code) these days - https://github.com/ivmai/libatomic_ops/compare/c6dc43294bda5516dea392cd4d994cbd1a18288e...dcf66b7de2f053d4c27fe96e6c7587f1fb183209)



Regards,
Ivan
Post by Ivan Maidanski
Hi H.J,
Done both (in the same branch). Please retry.
I've implemented double CAS using __sync_bool_compare_and_swap (similar to
normal CAS on x86_64 starting from GCC 4.2). Please inspect the assembly
code for it (as you pointed out it should be cmpxchg but not cmpxchg8b).
Also, I don't add cast of __sync_bool_compare_and_swap result to int (I
assume the problem should be already fixed on GCC with x32 support - please
check that GCC does not report warnings in AO_double_compare_and_swap_full).
AO_compare_double_and_swap_double_full is wrong for x32. Why do we
need it for x32 since x32 has AO_double_compare_and_swap_full?
--
H.J.
H.J. Lu
2012-10-08 15:54:08 UTC
Permalink
A couple comments:

1. AO_double_compare_and_swap_full is wrong:

#elif defined(__ILP32__) || !defined(__x86_64__)
# include "../standard_ao_double_t.h"

/* X32 has native support for 64-bit integer operations (AO_double_t */
/* is a 64-bit integer and we could use 64-bit cmpxchg). */
/* This primitive is used by compare_double_and_swap_double_full. */
AO_INLINE int
AO_double_compare_and_swap_full(volatile AO_double_t *addr,
AO_double_t old_val, AO_double_t new_val)

This is only for x32. You should check

#elif defined(__ILP32__) && defined(__x86_64__)

2. Why is AO_int_fetch_and_add_full only defined for 64-bit x86-64?

AO_INLINE unsigned int
AO_int_fetch_and_add_full (volatile unsigned int *p, unsigned int incr)
{
unsigned int result;

__asm__ __volatile__ ("lock; xaddl %0, %1"
: "=r" (result), "=m" (*p)
: "0" (incr), "m" (*p)
: "memory");
return result;
}

works for ia32, x32 and x86-64.
Post by Ivan Maidanski
Hi H.J.,
https://github.com/ivmai/libatomic_ops/tree/fix-double-cas-x32 (diff against
https://github.com/ivmai/libatomic_ops/compare/master...fix-double-cas-x32)
Please test it.
In fact, gcc/x86.h defines only double_compare_and_swap for x32 and
compare_double_and_swap_double is defined now in generalize.h.
(Sorry for the delay but I've applied a dozen of patches related to code
refactoring, double_cas testing (and improvement of MS VC code) these days -
https://github.com/ivmai/libatomic_ops/compare/c6dc43294bda5516dea392cd4d994cbd1a18288e...dcf66b7de2f053d4c27fe96e6c7587f1fb183209)
Regards,
Ivan
Post by Ivan Maidanski
Hi H.J,
Done both (in the same branch). Please retry.
I've implemented double CAS using __sync_bool_compare_and_swap (similar to
normal CAS on x86_64 starting from GCC 4.2). Please inspect the assembly
code for it (as you pointed out it should be cmpxchg but not cmpxchg8b).
Also, I don't add cast of __sync_bool_compare_and_swap result to int (I
assume the problem should be already fixed on GCC with x32 support - please
check that GCC does not report warnings in
AO_double_compare_and_swap_full).
AO_compare_double_and_swap_double_full is wrong for x32. Why do we
need it for x32 since x32 has AO_double_compare_and_swap_full?
--
H.J.
--
H.J.
Ivan Maidanski
2012-10-01 12:54:25 UTC
Permalink
Hi H.J,

Done both (in the same branch). Please retry.

I've implemented double CAS using __sync_bool_compare_and_swap (similar to normal CAS on x86_64 starting from GCC 4.2). Please inspect the assembly code for it (as you pointed out it should be cmpxchg but not cmpxchg8b).
Also, I don't add cast of __sync_bool_compare_and_swap result to int (I assume the problem should be already fixed on GCC with x32 support - please check that GCC does not report warnings in AO_double_compare_and_swap_full).

Diff: https://github.com/ivmai/libatomic_ops/compare/47eb0ea6bf3...4d2f91e90e

Regards,
Ivan
Post by Ivan Maidanski
Hi H.J.,
https://github.com/ivmai/libatomic_ops/tree/master-untested ?
X32 is x86-64 with 32bit pointers and long.
Post by Ivan Maidanski
1) a fix for AO_compare_double_and_swap_double_full - it should use
cmpxchg8b instead of cmpxchg16b for x32
src/atomic_ops/sysdeps/standard_ao_double_t.h has
#if (defined(__x86_64__) && __GNUC__ >= 4) || defined(_WIN64)
# include <xmmintrin.h>
  typedef __m128 double_ptr_storage;
#elif defined(_WIN32) && !defined(__GNUC__)
  typedef unsigned __int64 double_ptr_storage;
#else
  typedef unsigned long long double_ptr_storage;
#endif
# define AO_HAVE_DOUBLE_PTR_STORAGE
typedef union {
    double_ptr_storage AO_whole;
    struct {AO_t AO_v1; AO_t AO_v2;} AO_parts;
} AO_double_t;
#define AO_HAVE_double_t
This is incorrect for x32 sice AO_t is size_t, which is
32bit for x32. X32 has native support for 64-bit integer
operations. For x32, AO_double_t is 64bit integer and
we can use 64-bit cmpxchg. There is no need for
x32 AO_compare_double_and_swap_double_full,
which breaks 64bit integer into 2 32-bit integers.
Can you add a 64-bit version of atomic operations?
Post by Ivan Maidanski
2) code refactoring merging x86_64.h code into x86.h file
In particular, it's unclear to me whether PIC mode for x32 is the same as
for x86.
That is incorrect. X32 PIC is identical to x86-64 PIC.
--
H.J.
_______________________________________________
Gc mailing list
Post by Ivan Maidanski
http://www.hpl.hp.com/hosted/linux/mail-archives/gc/
H.J. Lu
2012-10-01 13:30:57 UTC
Permalink
Post by Ivan Maidanski
Hi H.J,
Done both (in the same branch). Please retry.
I've implemented double CAS using __sync_bool_compare_and_swap (similar to
normal CAS on x86_64 starting from GCC 4.2). Please inspect the assembly
code for it (as you pointed out it should be cmpxchg but not cmpxchg8b).
Also, I don't add cast of __sync_bool_compare_and_swap result to int (I
assume the problem should be already fixed on GCC with x32 support - please
check that GCC does not report warnings in AO_double_compare_and_swap_full).
AO_compare_double_and_swap_double_full is wrong for x32. Why do we
need it for x32 since x32 has AO_double_compare_and_swap_full?
--
H.J.
Ivan Maidanski
2012-10-08 16:05:00 UTC
Permalink
Hi H.J.,
1. AO_double_compare_and_swap_full is wrong:
#elif defined(__ILP32__) || !defined(__x86_64__)
# include "../standard_ao_double_t.h"
  /* X32 has native support for 64-bit integer operations (AO_double_t */
  /* is a 64-bit integer and we could use 64-bit cmpxchg). */
  /* This primitive is used by compare_double_and_swap_double_full. */
  AO_INLINE int
  AO_double_compare_and_swap_full(volatile AO_double_t *addr,
                                  AO_double_t old_val, AO_double_t new_val)
This is only for x32. You should check
#elif defined(__ILP32__) && defined(__x86_64__)
No, the former is correct. Because this is not only for x32 but also for x86 (if gcc 4+ and AO_USE_SYNC_CAS_BUILTIN manually defined). I've tested it (and inspected -S output) with recent clang and recent gcc-4.4 .. 4.7. See this commit message: https://github.com/ivmai/libatomic_ops/commit/03de7740c21fe6e4a6bdd7af09d5ff5189d4d70e
2. Why is AO_int_fetch_and_add_full only defined for 64-bit x86-64?
  AO_INLINE unsigned int
  AO_int_fetch_and_add_full (volatile unsigned int *p, unsigned int incr)
  {
    unsigned int result;
    __asm__ __volatile__ ("lock; xaddl %0, %1"
                        : "=r" (result), "=m" (*p)
                        : "0" (incr), "m" (*p)
                        : "memory");
    return result;
  }
works for ia32, x32 and x86-64.For ia32 and x32, we define AO_T_IS_INT which force AO_int_fetch_and_add_full to be defined as AO_fetch_and_add_full in ao_t_is_int.h

Please run test_atomic and see it output whether AO_int_fetch_and_add_full is reported to be missing on X32. I'm sure it's not.

Does "make check" successfully pass all tests on X32?

Regards,
Ivan
Post by Ivan Maidanski
Hi H.J.,
https://github.com/ivmai/libatomic_ops/tree/fix-double-cas-x32 (diff against
https://github.com/ivmai/libatomic_ops/compare/master...fix-double-cas-x32)
Please test it.
In fact, gcc/x86.h defines only double_compare_and_swap for x32 and
compare_double_and_swap_double is defined now in generalize.h.
(Sorry for the delay but I've applied a dozen of patches related to code
refactoring, double_cas testing (and improvement of MS VC code) these days -
https://github.com/ivmai/libatomic_ops/compare/c6dc43294bda5516dea392cd4d994cbd1a18288e...dcf66b7de2f053d4c27fe96e6c7587f1fb183209)
Regards,
Ivan
Post by Ivan Maidanski
Hi H.J,
Done both (in the same branch). Please retry.
I've implemented double CAS using __sync_bool_compare_and_swap (similar to
normal CAS on x86_64 starting from GCC 4.2). Please inspect the assembly
code for it (as you pointed out it should be cmpxchg but not cmpxchg8b).
Also, I don't add cast of __sync_bool_compare_and_swap result to int (I
assume the problem should be already fixed on GCC with x32 support -
please
check that GCC does not report warnings in
AO_double_compare_and_swap_full).
AO_compare_double_and_swap_double_full is wrong for x32. Why do we
need it for x32 since x32 has AO_double_compare_and_swap_full?
--
H.J.
--
H.J.
H.J. Lu
2012-10-08 16:08:39 UTC
Permalink
Post by Ivan Maidanski
Hi H.J.,
#elif defined(__ILP32__) || !defined(__x86_64__)
# include "../standard_ao_double_t.h"
/* X32 has native support for 64-bit integer operations (AO_double_t */
/* is a 64-bit integer and we could use 64-bit cmpxchg). */
/* This primitive is used by compare_double_and_swap_double_full. */
AO_INLINE int
AO_double_compare_and_swap_full(volatile AO_double_t *addr,
AO_double_t old_val, AO_double_t new_val)
This is only for x32. You should check
#elif defined(__ILP32__) && defined(__x86_64__)
No, the former is correct. Because this is not only for x32 but also for x86
(if gcc 4+ and AO_USE_SYNC_CAS_BUILTIN manually defined). I've tested it
(and inspected -S output) with recent clang and recent gcc-4.4 .. 4.7. See
https://github.com/ivmai/libatomic_ops/commit/03de7740c21fe6e4a6bdd7af09d5ff5189d4d70e
I see.
Post by Ivan Maidanski
2. Why is AO_int_fetch_and_add_full only defined for 64-bit x86-64?
AO_INLINE unsigned int
AO_int_fetch_and_add_full (volatile unsigned int *p, unsigned int incr)
{
unsigned int result;
__asm__ __volatile__ ("lock; xaddl %0, %1"
: "=r" (result), "=m" (*p)
: "0" (incr), "m" (*p)
: "memory");
return result;
}
works for ia32, x32 and x86-64.
For ia32 and x32, we define AO_T_IS_INT which force
AO_int_fetch_and_add_full to be defined as AO_fetch_and_add_full in
ao_t_is_int.h
I see.
Post by Ivan Maidanski
Please run test_atomic and see it output whether AO_int_fetch_and_add_full
is reported to be missing on X32. I'm sure it's not.
Does "make check" successfully pass all tests on X32?
Yes, I got

make check-TESTS
make[3]: Entering directory
`/export/gnu/import/git/github/bdwgc/libatomic_ops/tests'
Missing: AO_compare_and_swap_double
Missing: AO_compare_and_swap_double_acquire
Missing: AO_compare_and_swap_double_release
Missing: AO_compare_and_swap_double_read
Missing: AO_compare_and_swap_double_write
Missing: AO_compare_and_swap_double_full
Missing: AO_compare_and_swap_double_release_write
Missing: AO_compare_and_swap_double_acquire_read
Testing add1/sub1
Succeeded
Testing store_release_write/load_acquire_read
Succeeded
Testing test_and_set
Succeeded
PASS: test_atomic
Testing add1/sub1
Succeeded
Testing store_release_write/load_acquire_read
Succeeded
Testing test_and_set
Succeeded
PASS: test_atomic_pthreads
About 1000000 pushes + 1000000 pops in 1 threads: 23 msecs
About 1000000 pushes + 1000000 pops in 2 threads: 119 msecs
About 1000000 pushes + 1000000 pops in 3 threads: 146 msecs
About 1000000 pushes + 1000000 pops in 4 threads: 179 msecs
PASS: test_stack
Performing 1000 reversals of 1000 element lists in 10 threads
Testing AO_malloc/AO_free
Succeeded
PASS: test_malloc
==================
All 4 tests passed
==================
make[3]: Leaving directory
`/export/gnu/import/git/github/bdwgc/libatomic_ops/tests'

Thanks.
--
H.J.
Alexander Herz
2012-10-09 14:02:53 UTC
Permalink
Hi,

I ran into some name clash problems with beohm c++ (somewhere a value
caled gc was defined).

As a fix I suggest to add GC_NAMESPACE define and the namespace boehmgc
as outlined in the gc_cpp.h attached.
It's really a minor change (doesn't affect anything else but this header
and it's optional). Would be nice to see it (or something similar) in
the official version.

Regards,
Alex
Ivan Maidanski
2012-10-10 20:12:18 UTC
Permalink
Hi Alexander,

Could you please fix and improve your patch so that I could commit it to v7.3?
1. Fix test_cpp.cc to make it compilable with -DGC_NAMESPACE
2. "//#pragma message ..." - I think it should be removed
3. Rename QUALIFY to GC_NS_QUALIFY
4. Q: gc_cpp.cc requires no changes, right?
5. Add commit log message

Thank you.

Regards,
Ivan
Hi,
I ran into some name clash problems with boehm c++ (somewhere a value
called gc was defined).
As a fix I suggest to add GC_NAMESPACE define and the namespace boehmgc
as outlined in the gc_cpp.h attached.
It's really a minor change (doesn't affect anything else but this header
and it's optional). Would be nice to see it (or something similar) in
the official version.
Regards,
Alex
Alexander Herz
2012-10-18 09:14:40 UTC
Permalink
Hi,

I tried to implement the suggested changes.
Since the tests have a linker problem on my system (ubuntu 10.04 64 bit)
I couldn't verify em.

Alex

On 09.10.2012 16:02, Ivan wrote:

Hi Alexander,

Could you please fix and improve your patch so that I could commit
it to v7.3?
1. Fix test_cpp.cc to make it compilable with -DGC_NAMESPACE
2. "//#pragma message ..." - I think it should be removed
3. Rename QUALIFY to GC_NS_QUALIFY
4. Q: gc_cpp.cc requires no changes, right?
5. Add commit log message

Thank you.

Regards,
Ivan
Ivan Maidanski
2012-10-20 12:29:54 UTC
Permalink
Hi Alexander,

With a minor changes, I've put your patch to https://github.com/ivmai/bdwgc (gc-7.3alpha3).

Diff: https://github.com/ivmai/bdwgc/compare/2c62153351...2079afcb06

Regards,
Ivan
Post by Ivan Maidanski
Hi,
I tried to implement the suggested changes.
Since the tests have a linker problem on my system (ubuntu 10.04
64 bit) I couldn't verify em.
Alex
On 09.10.2012 16:02, Ivan wrote:
Hi Alexander,
Could you please fix and improve your patch so that I could commit
it to v7.3?
1. Fix test_cpp.cc to make it compilable with -DGC_NAMESPACE
2. "//#pragma message ..." - I think it should be removed
3. Rename QUALIFY to GC_NS_QUALIFY
4. Q: gc_cpp.cc requires no changes, right?
5. Add commit log message
Thank you.
Regards,
Ivan
Post by Ivan Maidanski
_______________________________________________
Gc mailing list
Post by Ivan Maidanski
http://www.hpl.hp.com/hosted/linux/mail-archives/gc/
Ivan Maidanski
2012-10-13 10:27:23 UTC
Permalink
Hi H. J.,

Thank you.

I've merged these changes to master and back-ported fix for double-CAS on x32 to https://github.com/ivmai/libatomic_ops/tree/release-7_2 branch. Could you also test it please (just make sure that all tests pass)?

release-7_2 diff: https://github.com/ivmai/libatomic_ops/compare/0810914...72fd402

Regards,
Ivan
Post by Ivan Maidanski
Hi H.J.,
#elif defined(__ILP32__) || !defined(__x86_64__)
# include "../standard_ao_double_t.h"
/* X32 has native support for 64-bit integer operations (AO_double_t */
/* is a 64-bit integer and we could use 64-bit cmpxchg). */
/* This primitive is used by compare_double_and_swap_double_full. */
AO_INLINE int
AO_double_compare_and_swap_full(volatile AO_double_t *addr,
AO_double_t old_val, AO_double_t new_val)
This is only for x32. You should check
#elif defined(__ILP32__) && defined(__x86_64__)
No, the former is correct. Because this is not only for x32 but also for x86
(if gcc 4+ and AO_USE_SYNC_CAS_BUILTIN manually defined). I've tested it
(and inspected -S output) with recent clang and recent gcc-4.4 .. 4.7. See
https://github.com/ivmai/libatomic_ops/commit/03de7740c21fe6e4a6bdd7af09d5ff5189d4d70e
I see.
Post by Ivan Maidanski
2. Why is AO_int_fetch_and_add_full only defined for 64-bit x86-64?
AO_INLINE unsigned int
AO_int_fetch_and_add_full (volatile unsigned int *p, unsigned int incr)
{
unsigned int result;
__asm__ __volatile__ ("lock; xaddl %0, %1"
: "=r" (result), "=m" (*p)
: "0" (incr), "m" (*p)
: "memory");
return result;
}
works for ia32, x32 and x86-64.
For ia32 and x32, we define AO_T_IS_INT which force
AO_int_fetch_and_add_full to be defined as AO_fetch_and_add_full in
ao_t_is_int.h
I see.
Post by Ivan Maidanski
Please run test_atomic and see it output whether AO_int_fetch_and_add_full
is reported to be missing on X32. I'm sure it's not.
Does "make check" successfully pass all tests on X32?
Yes, I got
make check-TESTS
make[3]: Entering directory
`/export/gnu/import/git/github/bdwgc/libatomic_ops/tests'
Missing: AO_compare_and_swap_double
Missing: AO_compare_and_swap_double_acquire
Missing: AO_compare_and_swap_double_release
Missing: AO_compare_and_swap_double_read
Missing: AO_compare_and_swap_double_write
Missing: AO_compare_and_swap_double_full
Missing: AO_compare_and_swap_double_release_write
Missing: AO_compare_and_swap_double_acquire_read
Testing add1/sub1
Succeeded
Testing store_release_write/load_acquire_read
Succeeded
Testing test_and_set
Succeeded
PASS: test_atomic
Testing add1/sub1
Succeeded
Testing store_release_write/load_acquire_read
Succeeded
Testing test_and_set
Succeeded
PASS: test_atomic_pthreads
About 1000000 pushes + 1000000 pops in 1 threads: 23 msecs
About 1000000 pushes + 1000000 pops in 2 threads: 119 msecs
About 1000000 pushes + 1000000 pops in 3 threads: 146 msecs
About 1000000 pushes + 1000000 pops in 4 threads: 179 msecs
PASS: test_stack
Performing 1000 reversals of 1000 element lists in 10 threads
Testing AO_malloc/AO_free
Succeeded
PASS: test_malloc
==================
All 4 tests passed
==================
make[3]: Leaving directory
`/export/gnu/import/git/github/bdwgc/libatomic_ops/tests'
Thanks.
--
H.J.
_______________________________________________
Gc mailing list
Post by Ivan Maidanski
http://www.hpl.hp.com/hosted/linux/mail-archives/gc/
H.J. Lu
2012-10-13 21:53:01 UTC
Permalink
I got

[***@gnu-tools-1 libatomic_ops]$ make check
Making check in src
make[1]: Entering directory
`/export/gnu/import/git/github/bdwgc/libatomic_ops/src'
Making check in atomic_ops
make[2]: Entering directory
`/export/gnu/import/git/github/bdwgc/libatomic_ops/src/atomic_ops'
Making check in sysdeps
make[3]: Entering directory
`/export/gnu/import/git/github/bdwgc/libatomic_ops/src/atomic_ops/sysdeps'
make[3]: Nothing to be done for `check'.
make[3]: Leaving directory
`/export/gnu/import/git/github/bdwgc/libatomic_ops/src/atomic_ops/sysdeps'
make[3]: Entering directory
`/export/gnu/import/git/github/bdwgc/libatomic_ops/src/atomic_ops'
make[3]: Nothing to be done for `check-am'.
make[3]: Leaving directory
`/export/gnu/import/git/github/bdwgc/libatomic_ops/src/atomic_ops'
make[2]: Leaving directory
`/export/gnu/import/git/github/bdwgc/libatomic_ops/src/atomic_ops'
make[2]: Entering directory
`/export/gnu/import/git/github/bdwgc/libatomic_ops/src'
gcc -mx32 -DHAVE_CONFIG_H -I. -I../src -I../src -fPIC -g -O2
-DNDEBUG -MT atomic_ops.o -MD -MP -MF .deps/atomic_ops.Tpo -c -o
atomic_ops.o atomic_ops.c
mv -f .deps/atomic_ops.Tpo .deps/atomic_ops.Po
rm -f libatomic_ops.a
ar cru libatomic_ops.a atomic_ops.o
ranlib libatomic_ops.a
gcc -mx32 -DHAVE_CONFIG_H -I. -I../src -I../src -fPIC -g -O2
-DNDEBUG -MT atomic_ops_stack.o -MD -MP -MF .deps/atomic_ops_stack.Tpo
-c -o atomic_ops_stack.o atomic_ops_stack.c
mv -f .deps/atomic_ops_stack.Tpo .deps/atomic_ops_stack.Po
gcc -mx32 -DHAVE_CONFIG_H -I. -I../src -I../src -fPIC -g -O2
-DNDEBUG -MT atomic_ops_malloc.o -MD -MP -MF
.deps/atomic_ops_malloc.Tpo -c -o atomic_ops_malloc.o
atomic_ops_malloc.c
mv -f .deps/atomic_ops_malloc.Tpo .deps/atomic_ops_malloc.Po
rm -f libatomic_ops_gpl.a
ar cru libatomic_ops_gpl.a atomic_ops_stack.o atomic_ops_malloc.o
ranlib libatomic_ops_gpl.a
make[2]: Leaving directory
`/export/gnu/import/git/github/bdwgc/libatomic_ops/src'
make[1]: Leaving directory
`/export/gnu/import/git/github/bdwgc/libatomic_ops/src'
Making check in doc
make[1]: Entering directory
`/export/gnu/import/git/github/bdwgc/libatomic_ops/doc'
make[1]: Nothing to be done for `check'.
make[1]: Leaving directory
`/export/gnu/import/git/github/bdwgc/libatomic_ops/doc'
Making check in tests
make[1]: Entering directory
`/export/gnu/import/git/github/bdwgc/libatomic_ops/tests'
gcc -mx32 -DHAVE_CONFIG_H -I. -I../src -I../src -I../src -g -O2
-DNDEBUG list_atomic.c -E > list_atomic.i
make check-am
make[2]: Entering directory
`/export/gnu/import/git/github/bdwgc/libatomic_ops/tests'
make test_atomic test_atomic_pthreads test_stack test_malloc
make[3]: Entering directory
`/export/gnu/import/git/github/bdwgc/libatomic_ops/tests'
gcc -mx32 -DHAVE_CONFIG_H -I. -I../src -I../src -I../src -g -O2
-DNDEBUG -MT test_atomic.o -MD -MP -MF .deps/test_atomic.Tpo -c -o
test_atomic.o test_atomic.c
mv -f .deps/test_atomic.Tpo .deps/test_atomic.Po
gcc -mx32 -g -O2 -DNDEBUG -o test_atomic test_atomic.o -lpthread
../src/libatomic_ops.a
gcc -mx32 -DHAVE_CONFIG_H -I. -I../src -DAO_USE_PTHREAD_DEFS -I../src
-I../src -g -O2 -DNDEBUG -MT test_atomic_pthreads-test_atomic.o -MD
-MP -MF .deps/test_atomic_pthreads-test_atomic.Tpo -c -o
test_atomic_pthreads-test_atomic.o `test -f 'test_atomic.c' || echo
'./'`test_atomic.c
mv -f .deps/test_atomic_pthreads-test_atomic.Tpo
.deps/test_atomic_pthreads-test_atomic.Po
gcc -mx32 -g -O2 -DNDEBUG -o test_atomic_pthreads
test_atomic_pthreads-test_atomic.o -lpthread ../src/libatomic_ops.a
gcc -mx32 -DHAVE_CONFIG_H -I. -I../src -I../src -I../src -g -O2
-DNDEBUG -MT test_stack.o -MD -MP -MF .deps/test_stack.Tpo -c -o
test_stack.o test_stack.c
mv -f .deps/test_stack.Tpo .deps/test_stack.Po
gcc -mx32 -g -O2 -DNDEBUG -o test_stack test_stack.o -lpthread
../src/libatomic_ops_gpl.a ../src/libatomic_ops.a
gcc -mx32 -DHAVE_CONFIG_H -I. -I../src -I../src -I../src -g -O2
-DNDEBUG -MT test_malloc.o -MD -MP -MF .deps/test_malloc.Tpo -c -o
test_malloc.o test_malloc.c
mv -f .deps/test_malloc.Tpo .deps/test_malloc.Po
gcc -mx32 -g -O2 -DNDEBUG -o test_malloc test_malloc.o -lpthread
../src/libatomic_ops_gpl.a ../src/libatomic_ops.a
make[3]: Leaving directory
`/export/gnu/import/git/github/bdwgc/libatomic_ops/tests'
make check-TESTS
make[3]: Entering directory
`/export/gnu/import/git/github/bdwgc/libatomic_ops/tests'
Missing: AO_compare_and_swap_double
Missing: AO_nop_acquire
Missing: AO_store_acquire
Missing: AO_short_store_acquire
Missing: AO_char_store_acquire
Missing: AO_int_store_acquire
Missing: AO_compare_and_swap_double_acquire
Missing: AO_nop_release
Missing: AO_load_release
Missing: AO_short_load_release
Missing: AO_char_load_release
Missing: AO_int_load_release
Missing: AO_compare_and_swap_double_release
Missing: AO_store_read
Missing: AO_short_store_read
Missing: AO_char_store_read
Missing: AO_int_store_read
Missing: AO_compare_and_swap_double_read
Missing: AO_load_write
Missing: AO_short_load_write
Missing: AO_char_load_write
Missing: AO_int_load_write
Missing: AO_compare_and_swap_double_write
Missing: AO_compare_and_swap_double_full
Missing: AO_nop_release_write
Missing: AO_load_release_write
Missing: AO_short_load_release_write
Missing: AO_char_load_release_write
Missing: AO_int_load_release_write
Missing: AO_compare_and_swap_double_release_write
Missing: AO_nop_acquire_read
Missing: AO_store_acquire_read
Missing: AO_short_store_acquire_read
Missing: AO_char_store_acquire_read
Missing: AO_int_store_acquire_read
Missing: AO_compare_and_swap_double_acquire_read
Testing add1/sub1
Succeeded
Testing store_release_write/load_acquire_read
Succeeded
Testing test_and_set
Succeeded
PASS: test_atomic
Missing: AO_nop_acquire
Missing: AO_store_acquire
Missing: AO_short_store_acquire
Missing: AO_char_store_acquire
Missing: AO_int_store_acquire
Missing: AO_nop_release
Missing: AO_load_release
Missing: AO_short_load_release
Missing: AO_char_load_release
Missing: AO_int_load_release
Missing: AO_store_read
Missing: AO_short_store_read
Missing: AO_char_store_read
Missing: AO_int_store_read
Missing: AO_load_write
Missing: AO_short_load_write
Missing: AO_char_load_write
Missing: AO_int_load_write
Missing: AO_nop_release_write
Missing: AO_load_release_write
Missing: AO_short_load_release_write
Missing: AO_char_load_release_write
Missing: AO_int_load_release_write
Missing: AO_nop_acquire_read
Missing: AO_store_acquire_read
Missing: AO_short_store_acquire_read
Missing: AO_char_store_acquire_read
Missing: AO_int_store_acquire_read
Testing add1/sub1
Succeeded
Testing store_release_write/load_acquire_read
Succeeded
Testing test_and_set
Succeeded
PASS: test_atomic_pthreads
About 1000000 pushes + 1000000 pops in 1 threads: 26 msecs
About 1000000 pushes + 1000000 pops in 2 threads: 127 msecs
About 1000000 pushes + 1000000 pops in 3 threads: 154 msecs
About 1000000 pushes + 1000000 pops in 4 threads: 179 msecs
PASS: test_stack
Performing 1000 reversals of 1000 element lists in 10 threads
Testing AO_malloc/AO_free
Succeeded
PASS: test_malloc
==================
All 4 tests passed
==================
make[3]: Leaving directory
`/export/gnu/import/git/github/bdwgc/libatomic_ops/tests'
make[2]: Leaving directory
`/export/gnu/import/git/github/bdwgc/libatomic_ops/tests'
make[1]: Leaving directory
`/export/gnu/import/git/github/bdwgc/libatomic_ops/tests'
make[1]: Entering directory `/export/gnu/import/git/github/bdwgc/libatomic_ops'
make[1]: Nothing to be done for `check-am'.
make[1]: Leaving directory `/export/gnu/import/git/github/bdwgc/libatomic_ops'
Post by Ivan Maidanski
Hi H. J.,
Thank you.
I've merged these changes to master and back-ported fix for double-CAS on
x32 to https://github.com/ivmai/libatomic_ops/tree/release-7_2 branch. Could
you also test it please (just make sure that all tests pass)?
https://github.com/ivmai/libatomic_ops/compare/0810914...72fd402
Regards,
Ivan
Post by Ivan Maidanski
Hi H.J.,
#elif defined(__ILP32__) || !defined(__x86_64__)
# include "../standard_ao_double_t.h"
/* X32 has native support for 64-bit integer operations (AO_double_t */
/* is a 64-bit integer and we could use 64-bit cmpxchg). */
/* This primitive is used by compare_double_and_swap_double_full. */
AO_INLINE int
AO_double_compare_and_swap_full(volatile AO_double_t *addr,
AO_double_t old_val, AO_double_t new_val)
This is only for x32. You should check
#elif defined(__ILP32__) && defined(__x86_64__)
No, the former is correct. Because this is not only for x32 but also for x86
(if gcc 4+ and AO_USE_SYNC_CAS_BUILTIN manually defined). I've tested it
(and inspected -S output) with recent clang and recent gcc-4.4 .. 4.7. See
https://github.com/ivmai/libatomic_ops/commit/03de7740c21fe6e4a6bdd7af09d5ff5189d4d70e
I see.
Post by Ivan Maidanski
2. Why is AO_int_fetch_and_add_full only defined for 64-bit x86-64?
AO_INLINE unsigned int
AO_int_fetch_and_add_full (volatile unsigned int *p, unsigned int incr)
{
unsigned int result;
__asm__ __volatile__ ("lock; xaddl %0, %1"
: "=r" (result), "=m" (*p)
: "0" (incr), "m" (*p)
: "memory");
return result;
}
works for ia32, x32 and x86-64.
For ia32 and x32, we define AO_T_IS_INT which force
AO_int_fetch_and_add_full to be defined as AO_fetch_and_add_full in
ao_t_is_int.h
I see.
Post by Ivan Maidanski
Please run test_atomic and see it output whether AO_int_fetch_and_add_full
is reported to be missing on X32. I'm sure it's not.
Does "make check" successfully pass all tests on X32?
Yes, I got
make check-TESTS
make[3]: Entering directory
`/export/gnu/import/git/github/bdwgc/libatomic_ops/tests'
Missing: AO_compare_and_swap_double
Missing: AO_compare_and_swap_double_acquire
Missing: AO_compare_and_swap_double_release
Missing: AO_compare_and_swap_double_read
Missing: AO_compare_and_swap_double_write
Missing: AO_compare_and_swap_double_full
Missing: AO_compare_and_swap_double_release_write
Missing: AO_compare_and_swap_double_acquire_read
Testing add1/sub1
Succeeded
Testing store_release_write/load_acquire_read
Succeeded
Testing test_and_set
Succeeded
PASS: test_atomic
Testing add1/sub1
Succeeded
Testing store_release_write/load_acquire_read
Succeeded
Testing test_and_set
Succeeded
PASS: test_atomic_pthreads
About 1000000 pushes + 1000000 pops in 1 threads: 23 msecs
About 1000000 pushes + 1000000 pops in 2 threads: 119 msecs
About 1000000 pushes + 1000000 pops in 3 threads: 146 msecs
About 1000000 pushes + 1000000 pops in 4 threads: 179 msecs
PASS: test_stack
Performing 1000 reversals of 1000 element lists in 10 threads
Testing AO_malloc/AO_free
Succeeded
PASS: test_malloc
==================
All 4 tests passed
==================
make[3]: Leaving directory
`/export/gnu/import/git/github/bdwgc/libatomic_ops/tests'
Thanks.
--
H.J.
_______________________________________________
Gc mailing list
http://www.hpl.hp.com/hosted/linux/mail-archives/gc/
--
H.J.
Loading...