Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Ticket #1959 (closed enhancement: fixed)

Opened 14 years ago

Last modified 14 years ago

patch to make blip work in a stable way

Reported by: fawzi Assigned to: community
Priority: major Milestone: 1.0
Component: Tango Version: 0.99.9 Kai
Keywords: Cc:

Description

http://github.com/fawzi/blip/blob/master/tangoTrunk.patch is a patch with the changes I did to tango trunk to have a stable program when using blip. This patch contains also the patch of #1899

I release it with whatever licenses are needed for tango.

Attachments

tstAtomic.asm (4.6 kB) - added by fawzi on 07/24/10 14:29:18.
the assempler for the sample module on osx with dmd -O -inline -release
tangoTrunk.patch (21.3 kB) - added by mwarning on 07/26/10 13:10:45.

Change History

07/19/10 16:21:13 changed by mwarning

I've changed the license to "BSD style: $(LICENSE)" as for lack of a better idea.

07/20/10 22:45:19 changed by kris

need to resolve outstanding questions about the replacement Atomic module. Specifically with regard to how many calls are involved. Also, should we use 'naked' on the asm where that works?

07/23/10 01:15:51 changed by fawzi

As I said I don't see where the new atomic modules makes many calls, could you be more specific?

Places where I see more than 0 calls: high level functions: get/setFlag, but there the cost of the barrier probably shadows everything. One could try to put the barrier in the asm, but it is much less flexible, and I doubt you would gain something (a good compiler should inline the barrier op).

what does disturb you exactly? Is it the boolean returning atomicCASB? that should be inlined, I switched to an atomicCas that returns the original value by default because that is more efficient and safer to do loops like atomicOp (as h3r3tic made me realize), so it is a better primitive.

atomicOp/fallbacks I think that is as efficient as it can be without writing everything in assembler.

The basic functions are templates, on dmd I use asm blocks, as we discussed on the IRC the only thing that I see could be sone is using naked asm, but I don't know if that really improves the timings, and in any case I suspect that it will disallow inlining even more than asm blocks. (the prologue/epiloque cannot be removed).

07/24/10 05:02:41 changed by kris

have you looked at the disassembled code yet? As I'd said before, that's where the prior issues had shown up

07/24/10 14:26:40 changed by fawzi

I join the asm for

module tstAtomic;
import blip.sync.Atomic;
private extern(C) int printf(char*,...);
void main(){
    size_t i;
    
    atomicAdd(i,cast(size_t)1);
    if (atomicCAS(i,cast(size_t)0,cast(size_t)1)==1){
        printf("set back!\n");
    }
    flagSet(i,cast(size_t)4);
    flagGet(i);
}

to me it looks exactly as I would have guessed from the source. Yes flagGet/flagSet don't inline the call to the barrier (but even it it looks simple at asm level a barrier is slow, so inlining would not gain a lot. The rest seems to me pretty standard.

Were you looking at other functions?

07/24/10 14:29:18 changed by fawzi

  • attachment tstAtomic.asm added.

the assempler for the sample module on osx with dmd -O -inline -release

07/24/10 14:44:51 changed by fawzi

ehm assmbler :)

by the way compilation time of the Atomic module for me was at most 0.017s real time also on my old 1.82 intel core Duo laptop with 5400 rpm HD. (as expected, as it is mostly templates).

I have never seen that "it was the module that took longest to compile".

07/26/10 13:10:45 changed by mwarning

  • attachment tangoTrunk.patch added.

08/01/10 21:30:13 changed by mwarning

  • status changed from new to closed.
  • resolution set to fixed.

(In [5511]) fixes #1959 :: patch to make blip work in a stable way; big thanks to fawzi