[Issue 12891] add atomicFetchAdd and atomicFetchSub to core.atomic

2017-07-19 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=12891

--- Comment #14 from github-bugzi...@puremagic.com ---
Commit pushed to dmd-cxx at https://github.com/dlang/druntime

https://github.com/dlang/druntime/commit/c5f10192bb88255beec572bfc2e3510267ecd766
Merge pull request #1208 from jadbox/fetchmod

--


[Issue 12891] add atomicFetchAdd and atomicFetchSub to core.atomic

2015-06-17 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=12891

--- Comment #13 from github-bugzi...@puremagic.com ---
Commit pushed to stable at https://github.com/D-Programming-Language/druntime

https://github.com/D-Programming-Language/druntime/commit/c5f10192bb88255beec572bfc2e3510267ecd766
Merge pull request #1208 from jadbox/fetchmod

--


[Issue 12891] add atomicFetchAdd and atomicFetchSub to core.atomic

2015-06-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=12891

Andrei Alexandrescu and...@erdani.com changed:

   What|Removed |Added

Version|unspecified |D2

--


[Issue 12891] add atomicFetchAdd and atomicFetchSub to core.atomic

2015-04-13 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=12891

--- Comment #12 from github-bugzi...@puremagic.com ---
Commit pushed to master at https://github.com/D-Programming-Language/druntime

https://github.com/D-Programming-Language/druntime/commit/c5f10192bb88255beec572bfc2e3510267ecd766
Merge pull request #1208 from jadbox/fetchmod

fix Issue 12891: add atomicFetchAdd to core.atomic

--


[Issue 12891] add atomicFetchAdd and atomicFetchSub to core.atomic

2015-04-06 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=12891

--- Comment #11 from Jonathan Dunlap jad...@gmail.com ---
I've created a placeholder PR for this work below:
https://github.com/D-Programming-Language/druntime/pull/1208

Again, my current GH branch for this is here:
https://github.com/jadbox/druntime/tree/fetchmod

--


[Issue 12891] add atomicFetchAdd and atomicFetchSub to core.atomic

2015-04-06 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=12891

Jonathan Dunlap jad...@gmail.com changed:

   What|Removed |Added

   Assignee|nob...@puremagic.com|jad...@gmail.com

--- Comment #10 from Jonathan Dunlap jad...@gmail.com ---
I'm debating if we should remove the atomicFetchSub since it would simply be an
alias to atomicFetchAdd with negative sign on the modifier. Thoughts?

--


[Issue 12891] add atomicFetchAdd and atomicFetchSub to core.atomic

2015-04-06 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=12891

Jonathan Dunlap jad...@gmail.com changed:

   What|Removed |Added

 Status|NEW |ASSIGNED

--- Comment #9 from Jonathan Dunlap jad...@gmail.com ---
I resolved the issue by replacing the __traits(isSame, T, V1) with is(T ==
V1).

Okay my branch below seems to pass all the x64 unittests I've made for this. It
should also work for x86, but I haven't tested yet. Would someone want to
benchmark this?

--


[Issue 12891] add atomicFetchAdd and atomicFetchSub to core.atomic

2015-04-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=12891

--- Comment #8 from Jonathan Dunlap jad...@gmail.com ---
Thanks Martin for the gist sample, I've started to integrate in this branch:
https://github.com/jadbox/druntime/tree/fetchmod

Currently I'm having an issue where a static if check against
__traits(isSame,T,V1) is always resulting to false, even though it seems T and
V1 are the same in the unittests.

--


[Issue 12891] add atomicFetchAdd and atomicFetchSub to core.atomic

2015-04-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=12891

--- Comment #5 from Martin Nowak c...@dawg.eu ---
(In reply to Jonathan Dunlap from comment #4)
Depending on the size of mod you need to use a smaller register.

static if (V1.sizeof == 1) asm { mov AL, mod; }
static if (V1.sizeof == 2) asm { mov AX, mod; }
static if (V1.sizeof == 4) asm { mov EAX, mod; }
static if (V1.sizeof == 8) asm { mov RAX, mod; }

Likewise you need to load the pointer (ref) into a fitting register.

mov EDX, val; // x86
mov RDX, val; // x86_64

--


[Issue 12891] add atomicFetchAdd and atomicFetchSub to core.atomic

2015-04-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=12891

--- Comment #6 from Martin Nowak c...@dawg.eu ---
Created attachment 1508
  -- https://issues.dlang.org/attachment.cgi?id=1508action=edit
atomic fetch add for x64

Implementation of atomicOp!+= (fetch_add) for X86_64.

--


[Issue 12891] add atomicFetchAdd and atomicFetchSub to core.atomic

2015-04-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=12891

--- Comment #7 from Martin Nowak c...@dawg.eu ---
See attachment above or this gist
https://gist.github.com/MartinNowak/5111611ddc476eb49298 for a fetch_add
implementation on X86_64.

--


[Issue 12891] add atomicFetchAdd and atomicFetchSub to core.atomic

2015-03-31 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=12891

--- Comment #4 from Jonathan Dunlap jad...@gmail.com ---
I'm having an issue adding an asm block for the fast increment by operation.
It's been awhile since I've used asm productively so I'm probably missing
something simple.

HeadUnshared!(T) atomicOp(string op, T, V1)( ref shared T val, V1 mod ) pure
nothrow @nogc
if( __traits( compiles, mixin( *cast(T*)val ~ op ~ mod ) ) )
[]
get = set = atomicLoad!(MemoryOrder.raw)( val );

auto setptr = set;
static if(op == +=) {
  // qword ptr
  asm pure nothrow @nogc
  {
mov EAX, mod;//:678
mov EDX, setptr; //:679
lock; 
xadd [EDX], EAX;
  }
}

Error:
src/core/atomic.d(678): Error: bad type/size of operands 'mov'
src/core/atomic.d(679): Error: bad type/size of operands 'mov'

--


[Issue 12891] add atomicFetchAdd and atomicFetchSub to core.atomic

2015-03-30 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=12891

Martin Nowak c...@dawg.eu changed:

   What|Removed |Added

Summary|add atomicInc and atomicDec |add atomicFetchAdd and
   |to core.atomic  |atomicFetchSub to
   ||core.atomic

--