[Maria-discuss] my_atomic_add64
Hello, I need my_atomic_add64 in mysql. Can i simple add following macros, or i need more advanced tricks? tsarev@main:/storage/project/percona/rtd_2$ diff -Nur ../rtd/c/include/my_atomic.h c/include/my_atomic.h --- ../rtd/c/include/my_atomic.h 2010-07-09 16:35:11.000000000 +0400 +++ c/include/my_atomic.h 2010-08-17 18:57:07.648819066 +0400 @@ -96,25 +96,30 @@ make_atomic_cas( 8) make_atomic_cas(16) make_atomic_cas(32) +make_atomic_cas(64) make_atomic_cas(ptr) make_atomic_add( 8) make_atomic_add(16) make_atomic_add(32) +make_atomic_add(64) make_atomic_load( 8) make_atomic_load(16) make_atomic_load(32) +make_atomic_load(64) make_atomic_load(ptr) make_atomic_store( 8) make_atomic_store(16) make_atomic_store(32) +make_atomic_store(64) make_atomic_store(ptr) make_atomic_swap( 8) make_atomic_swap(16) make_atomic_swap(32) +make_atomic_swap(64) make_atomic_swap(ptr) #undef make_atomic_add --- Oleg Tsarev, Software Engineer, Percona Inc.
Oleg Tsarev <zabivator@gmail.com> writes:
I need my_atomic_add64 in mysql.
Can i simple add following macros, or i need more advanced tricks?
tsarev@main:/storage/project/percona/rtd_2$ diff -Nur ../rtd/c/include/my_atomic.h c/include/my_atomic.h --- ../rtd/c/include/my_atomic.h 2010-07-09 16:35:11.000000000 +0400 +++ c/include/my_atomic.h 2010-08-17 18:57:07.648819066 +0400
I think you'll also need make_transparent_unions(32) #define U_32 int32 #define Uv_32 int32
@@ -96,25 +96,30 @@ make_atomic_cas( 8) make_atomic_cas(16) make_atomic_cas(32) +make_atomic_cas(64) make_atomic_cas(ptr)
...
My guess is it should work, at least on 64-bit platforms. I'm not sure that 32-bit CPUs generally provide 64-bit atomic operations. If not (which seems likely, really), you'll need to come up with something to handle this case. Note that the my_atomic stuff has the possibility to fallback to mutex locking when support is not available, so one way might be to make it use this fallback on 32-bit (taking a performance penalty, but 32-bit is getting less and less interesting by the day anyway). - Kristian.
I think the 80486 introduced the cmp8xchg instruction. On 17 Aug, 2010, at 9:25 am, Kristian Nielsen wrote:
Oleg Tsarev <zabivator@gmail.com> writes:
I need my_atomic_add64 in mysql.
Can i simple add following macros, or i need more advanced tricks?
tsarev@main:/storage/project/percona/rtd_2$ diff -Nur ../rtd/c/include/my_atomic.h c/include/my_atomic.h --- ../rtd/c/include/my_atomic.h 2010-07-09 16:35:11.000000000 +0400 +++ c/include/my_atomic.h 2010-08-17 18:57:07.648819066 +0400
I think you'll also need
make_transparent_unions(32) #define U_32 int32 #define Uv_32 int32
@@ -96,25 +96,30 @@ make_atomic_cas( 8) make_atomic_cas(16) make_atomic_cas(32) +make_atomic_cas(64) make_atomic_cas(ptr)
...
My guess is it should work, at least on 64-bit platforms.
I'm not sure that 32-bit CPUs generally provide 64-bit atomic operations. If not (which seems likely, really), you'll need to come up with something to handle this case. Note that the my_atomic stuff has the possibility to fallback to mutex locking when support is not available, so one way might be to make it use this fallback on 32-bit (taking a performance penalty, but 32-bit is getting less and less interesting by the day anyway).
- Kristian.
_______________________________________________ Mailing list: https://launchpad.net/~maria-discuss Post to : maria-discuss@lists.launchpad.net Unsubscribe : https://launchpad.net/~maria-discuss More help : https://help.launchpad.net/ListHelp
Antony T Curtis <atcurtis@mac.com> writes:
I think the 80486 introduced the cmp8xchg instruction.
It appears you are right. Oleg, it seems that MySQL 5.5 already implements a 64-bit atomic add for 32-bit x86 platforms. Check include/atomic/x86-gcc.h , it uses the cmpxchg8b instruction. - Kristian.
participants (3)
-
Antony T Curtis
-
Kristian Nielsen
-
Oleg Tsarev