flat assembler
Message board for the users of flat assembler.

Index > Main > Finding max clique size and C++ is better than asm.

Goto page Previous  1, 2, 3, 4  Next
Author
Thread Post new topic Reply to topic
redsock



Joined: 09 Oct 2009
Posts: 438
Location: Australia
redsock 19 Apr 2016, 00:59
Tyler wrote:
...What do you and your friend think? Am I an alright C/C++ guy? I think I'm above average, but I know average ain't so good either. I passed a technical interview on the subject, at least. Razz
Your code is legible, though I am not sure I agree entirely with your logic/flow constructs. Too small a sample and insufficient information to judge your programming skills in general Smile If that code took you 6 months to write, hahah, well, you get the idea.

As for my opinion on the title of this thread regarding whether C++ is better than asm or not, all programming languages are efficiency tradeoffs. Programmer friendly typically comes with lots of efficiency penalties (array bounds checking, arithmetic overflow conditions, the list goes on and on).

I think you should keep your $60 bux and play more with the compiler(s) you use and their own assembly outputs Smile Smile

The discussion I was having earlier was about specific architecture optimisations, and your exercise was a perfect example. In it, g++ with your compiler flags does the following with your adj5 array references:
Code:
        movsxd rdi,edi
        movsxd rsi,esi
        lea    rax,[rdi+rdi*2]
        lea    rax,[rdi+rax*4]
        lea    rax,[rdi+rax*4]
        add    rsi,rax
        mov    eax,DWORD PTR [rsi*4+0x405ce0]
        test   eax,eax
        setne  al
        ret
    
And the interesting conversation-worthy part of this is that on Ivy Bridge (and the same for many others), despite the native choice, g++ thinks that the very long dependency chain there is better than a multiply instruction. After a quick look in Agner Fog's instruction tables, a mul is clearly a better choice here.

Further to that, the movsxds are there because your HLL constructs force it to assume that the values can be negative (signed integers versus otherwise).

To sum that all up in a nutshell: your position that "C++ is better" on an performance level is patently false. That being said, it is possible to write C with the mindset of assembly language and get far closer to hand-written assembler performance, but it doesn't look so programmer friendly when that exercise is done Wink The compiler can never know your intent Smile hahah, fun stuff.

Cheers

Edit: As my colleague just pointed out, I should state there is much more "wrong" with the code fragment listed above. For example, the compiler obviously doesn't know your tables are full of zeroes and ones for example, etc. If we were writing it in assembler, we'd just set the return value from the table directly, instead of having two additional dependency chained instructions before the return, etc. etc. Just more examples again of how HLL's can only go so far. hehe

_________________
2 Ton Digital - https://2ton.com.au/
Post 19 Apr 2016, 00:59
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20632
Location: In your JS exploiting you and your system
revolution 19 Apr 2016, 01:49
For a task that runs in only 0.35s the timing is very fragile and subject to the whims of OS clocking controls and background tasks stealing cycles. If this thing runs all day everyday then it might be a worthwhile goal to make it 5% faster (and thus one can buy 5% fewer machines and save some $) but otherwise ... ?

Aside: It is always possible to find some HLL task that performs equally as well as the asm version. Usually something that it cache unfriendly and uses sparse arrays will be almost impossible to make any significant improvement by using asm. But some tasks can be made hugely faster than any HLL compiler could ever hope achieve when one can exploit the internal CPU instructions and data paths to the fullest. Choose your optimising tasks with caution. Choose to put your time into those areas where the gain will be most.


Last edited by revolution on 19 Apr 2016, 04:24; edited 1 time in total
Post 19 Apr 2016, 01:49
View user's profile Send private message Visit poster's website Reply with quote
redsock



Joined: 09 Oct 2009
Posts: 438
Location: Australia
redsock 19 Apr 2016, 01:59
revolution: agreed fully Smile

Boy did I open a can of worms stepping into this thread, haha... so my colleague asked me to actually analyze the adj5 function from a runtime perspective and to justify in real numbers by previous statement about whether or not a mul is really going to be better.

Hahah, sure enough, gcc's 3 separate lea instructions as it turns out is the same basic cycle counts, but here is the official note taking as I walked through it (annotated gcc output, and then my rewritten version that does the same thing). I think it is particularly interesting that sometimes compilers have a tendency to be "too fancy" for their own good.

Compiler optimized gcc adj5 function again (noting this is specific to Ivy Bridge):
Code:
        movsxd rdi,edi                          ; sign extend edi, latency 2, recip 0.5
        movsxd rsi,esi                          ; sign extend esi, latency 2, recip 0.5
                ; 2 core clocks in until rdi is sign extended
        lea    rax,[rdi+rdi*2]                  ; rax = rdi * 3, latency 1, recip 0.5
                ; 3 core clocks here
        lea    rax,[rdi+rax*4]                  ; rax = (rax * 4) + rdi, or rdi * 13, latency 1, recip 0.5
                ; 4 core clocks here
        lea    rax,[rdi+rax*4]                  ; rax = (rax * 4) + rdi, or rdi * 53, latency 1, recip 0.5
                ; 5 core clocks here
        add    rsi,rax                          ; + rsi, latency 1, recip 0.33
                ; 6 core clocks here
        mov    eax,DWORD PTR [rsi*4+0x405ce0]   ; load dword from table into eax, latency 2, recip 0.5
                ; wait 2 more for the result, so now we are at 8 core clocks
        test   eax,eax                          ; test eax, latency 1, recip 0.33
                ; 9 core clocks
        setne  al                               ; setnz al, latency 1, recip 0.5
                ; 10, although the ret will go before the result is ready
                ; also, is there a partial register penalty for using the 8bit here?
        ret 
    
And a rewritten version that does the same thing:
Code:
        imul    rax, rdi, 53                    ; rax = rdi * 53, latency 3, recip 1
                ; 3 core clocks until rax has our result
        add     rax, rsi                        ; + rsi, latency , recip 0.33
                ; 4 core clocks here
        mov     eax, [rax*4+0x405ce0]
                ; latency for the load is 2, but since the result won't be used until after the return
                ; its somewhere between 4.5 and 6 core clocks before we bail out.
        ret    


Smile A hopefully amusing walk down optimising compilers lane.

Cheers again

_________________
2 Ton Digital - https://2ton.com.au/
Post 19 Apr 2016, 01:59
View user's profile Send private message Reply with quote
Tyler



Joined: 19 Nov 2009
Posts: 1216
Location: NC, USA
Tyler 19 Apr 2016, 02:54
revolution, I ran this for 2 weeks (or maybe more, it's been a while) on our school server, utilizing 12 cores. There was more to it then -- I stripped out all the nasty multithreading code I wrote then and am planning on rewriting it better, faster, and cleaner before I put this thing on my resume and post it to my github.
Post 19 Apr 2016, 02:54
View user's profile Send private message Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 13367
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 0010456
sleepsleep 19 Apr 2016, 04:08
you guys are so awesome & cool!
Post 19 Apr 2016, 04:08
View user's profile Send private message Reply with quote
Tyler



Joined: 19 Nov 2009
Posts: 1216
Location: NC, USA
Tyler 19 Apr 2016, 04:44
sleepsleep, you seem like you enjoy learning a lot. You should check out some MooCs and learn this stuff. You can get a pretty high quality CS education for free on the internet these days.

Check this out: https://github.com/open-source-society/computer-science

They even tell you what order to do the classes in. If you took all of these, you would know way more than me and almost every CS graduate in the US.
Post 19 Apr 2016, 04:44
View user's profile Send private message Reply with quote
redsock



Joined: 09 Oct 2009
Posts: 438
Location: Australia
redsock 19 Apr 2016, 07:42
Tyler, I meant to say thanks for putting this up Smile It was a fun diversion earlier today for me both conversationally, as well as my running at the mouth here in the thread.

Are you going to proceed with it? And if so, are you going to restructure the baseline code and/or test data?

Cheers

_________________
2 Ton Digital - https://2ton.com.au/
Post 19 Apr 2016, 07:42
View user's profile Send private message Reply with quote
redsock



Joined: 09 Oct 2009
Posts: 438
Location: Australia
redsock 19 Apr 2016, 22:07
Spent some this morning over my morning coffee and reworked your C++ version.

None of the changes I made affect any of its previous functionality.

On my machine, this reworked version is 2.2X faster than your original C++.

https://ideone.com/u3sMA5

_________________
2 Ton Digital - https://2ton.com.au/
Post 19 Apr 2016, 22:07
View user's profile Send private message Reply with quote
Tyler



Joined: 19 Nov 2009
Posts: 1216
Location: NC, USA
Tyler 19 Apr 2016, 23:10
Sorry for the radio silence today. I had to finish a project for a deadline.

What restructuring would you like for me to do? You mean compiling them separately and then linking them? Sure.

I'll post another test case when I get back on my laptop (posting from phone rn). I can get you one that takes a couple minutes with my version. (Well, I can give you test cases that will run longer than either of us will live, but I think a couple minutes is more like what you want, right?)
Post 19 Apr 2016, 23:10
View user's profile Send private message Reply with quote
Tyler



Joined: 19 Nov 2009
Posts: 1216
Location: NC, USA
Tyler 20 Apr 2016, 17:59
As promised:

Code:
tyler@smsng:~/Desktop/graph2$ time echo 233 | ./graph
int connects[129][129] = {
  {0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,1,1,0,1,1,1,1,0,1,0,0,0,1,1,1,0,1,1,1,1,1,1,1,1,0,1,1,0,1,0,1,1,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,1,1,0,1,1,1},
  {1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,0,0,1,1,1,1,0,1,0,0,1,1,1,1,1,1,1,0,1,0,0,1,0,0,1,1,0,1,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,1,0,1,1,1,0,0,1,0,0,0,1,0,1,1,1,1,1,1,0,0,1,1,0,1,0,1,1,0,1,1,1,0,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1},
  {1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,1,1,0,1,1,1,1,0,0,0,1,1,1,1,1,0,0,1,1,1,1,1,1,1,0,1,1,0,1,0,0,1,1,0,1,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,0,1,0,1,1,1,0,0,0,0,1,0,1,1,1,1,1,1,1,1,0,0,1,1,0,1,1,1,0,0,1,1,1,0,1,1,1,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1},
  {1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,1,1,0,1,1,1,1,0,1,0,0,0,1,1,1,0,1,1,1,1,1,1,1,1,0,1,1,0,1,0,1,1,1,0,0,0,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,0,0,0,1,1,1,0,1,0,1,1,0,1,1,1,1,1,1,1,1,0,1,1,1,0,0,0,1,0,1,1,1,1,0,1,1,1,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0}}
233: 19 129

real    18m9.681s
user    18m9.520s
sys     0m0.044s
    
Post 20 Apr 2016, 17:59
View user's profile Send private message Reply with quote
Tyler



Joined: 19 Nov 2009
Posts: 1216
Location: NC, USA
Tyler 20 Apr 2016, 18:02
I could've "chrt -f 99"'ed it, but meh. That tends to mess up my wifi and require a reboot to fit it. (Proprietary Intel garbage.) At this long of a runtime, I doubt it matters that much.
Post 20 Apr 2016, 18:02
View user's profile Send private message Reply with quote
redsock



Joined: 09 Oct 2009
Posts: 438
Location: Australia
redsock 20 Apr 2016, 20:50
Did you see my 4th post back? I think my reworking your C++ version and achieving more than double the speed for the same logic/conditionals kinda moots the point of the original exercise, don't you?

_________________
2 Ton Digital - https://2ton.com.au/
Post 20 Apr 2016, 20:50
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4227
Location: vpcmpistri
bitRAKE 20 Apr 2016, 21:59
Thanks for the larger example - will make timing easier.

Here is the macro I've been using in FASM to convert into binary arrays:
Code:
MACRO adjacency name,[bit_array*] {
  COMMON
    adjacency@lines = 0
  FORWARD
    adjacency@lines = adjacency@lines + 1
  COMMON
    _ALIGN_ 64,4,<db 0> ; waste of a cacheline
    dd adjacency@lines
    name: ; non sized label
    name#.width = ((adjacency@lines + 63) AND (0-64))/8 ; width in bytes
  FORWARD
    gather@nodes=0
    gather@dq=0
    IRPS bit,bit_array \{
      gather@dq = gather@dq + (bit shl (gather@nodes mod 64))
      gather@nodes = gather@nodes + 1
      IF 0 = (gather@nodes mod 64)
        dq gather@dq
        gather@dq=0
      END IF
    \}
    IF 0 <> (gather@nodes mod 64)
      dq gather@dq
      gather@dq = 0
    END IF
    IF gather@nodes <> adjacency@lines
      ERR "ERROR: Non-square Adjacency matrix!"
    END IF
}



adjacency Adj9, \
  < 0 1 1 1 0 0 1 1 1 >, \
  < 1 0 1 1 0 0 0 1 1 >, \
  < 1 1 0 1 1 1 0 0 1 >, \
  < 1 1 1 0 1 1 1 0 0 >, \
  < 0 0 1 1 0 1 1 0 0 >, \
  < 0 0 1 1 1 0 1 1 1 >, \
  < 1 0 0 1 1 1 0 1 1 >, \
  < 1 1 0 0 0 1 1 0 1 >, \
  < 1 1 1 0 0 1 1 1 0 >



MACRO _ALIGN_ base*,delta=0,fill=<db 0> {
  WHILE ((($-$$)+delta) and (base-1)) <> 0
    fill
  END WHILE
}    
There are node sets on the internet of millions of nodes - solved in very fast times. I'm assuming these are special in some way?

https://turing.cs.hbg.psu.edu/txn131/clique.html


Last edited by bitRAKE on 20 Apr 2016, 22:17; edited 2 times in total
Post 20 Apr 2016, 21:59
View user's profile Send private message Visit poster's website Reply with quote
redsock



Joined: 09 Oct 2009
Posts: 438
Location: Australia
redsock 20 Apr 2016, 22:11
Your original C++:
Code:
# perf stat ./original_129
17

 Performance counter stats for './original_129':

    1786268.847372      task-clock (msec)         #    1.000 CPUs utilized          
             3,345      context-switches          #    0.002 K/sec                  
                 6      cpu-migrations            #    0.000 K/sec                  
                98      page-faults               #    0.000 K/sec                  
 5,591,899,252,212      cycles                    #    3.130 GHz                     [83.34%]
 2,153,264,209,241      stalled-cycles-frontend   #   38.51% frontend cycles idle    [83.34%]
   550,463,187,942      stalled-cycles-backend    #    9.84% backend  cycles idle    [66.68%]
10,480,382,952,859      instructions              #    1.87  insns per cycle        
                                                  #    0.21  stalled cycles per insn [83.34%]
 2,473,668,996,377      branches                  # 1384.825 M/sec                   [83.31%]
    24,697,103,636      branch-misses             #    1.00% of all branches         [83.34%]

    1785.662685113 seconds time elapsed    
My reworked C++ of the same:
Code:
# perf stat ./reworked_129
17

 Performance counter stats for './reworked_129':

     707960.713577      task-clock (msec)         #    1.000 CPUs utilized          
             1,622      context-switches          #    0.002 K/sec                  
                 3      cpu-migrations            #    0.000 K/sec                  
                98      page-faults               #    0.000 K/sec                  
 2,212,800,549,865      cycles                    #    3.126 GHz                     [83.34%]
   922,318,587,393      stalled-cycles-frontend   #   41.68% frontend cycles idle    [83.34%]
   325,403,542,656      stalled-cycles-backend    #   14.71% backend  cycles idle    [66.68%]
 4,423,565,094,776      instructions              #    2.00  insns per cycle        
                                                  #    0.21  stalled cycles per insn [83.34%]
   915,235,112,899      branches                  # 1292.777 M/sec                   [83.30%]
    15,808,946,453      branch-misses             #    1.73% of all branches         [83.34%]

     707.691934200 seconds time elapsed    
Looking at the compiler output, a handwritten assembler version of the same would go faster still... Smile

Cheers

_________________
2 Ton Digital - https://2ton.com.au/
Post 20 Apr 2016, 22:11
View user's profile Send private message Reply with quote
redsock



Joined: 09 Oct 2009
Posts: 438
Location: Australia
redsock 20 Apr 2016, 22:13
bitRAKE: That is cool, thanks for sharing
Post 20 Apr 2016, 22:13
View user's profile Send private message Reply with quote
Tyler



Joined: 19 Nov 2009
Posts: 1216
Location: NC, USA
Tyler 20 Apr 2016, 22:28
Damn, that's crazy. Are there any guiding principles that helped you do that or just permuting the code and timing it?
Post 20 Apr 2016, 22:28
View user's profile Send private message Reply with quote
Tyler



Joined: 19 Nov 2009
Posts: 1216
Location: NC, USA
Tyler 20 Apr 2016, 22:32
Oh, wait, you removed the std::function stuff. I bet that was a massive part of the speedup. I did know that would help. I just chose not to do it.

What I'm more interested in is how you knew to rewrite the loops like that. One of my professors, who did compiler optimization for his dissertation, says gotos are horrible for optimization because it ruins invariants. What the principle behind how you use them and avoid this?
Post 20 Apr 2016, 22:32
View user's profile Send private message Reply with quote
redsock



Joined: 09 Oct 2009
Posts: 438
Location: Australia
redsock 20 Apr 2016, 22:53
Smile Guiding principles for general optimisation in no particular order:
    - If the logic flow looks like spaghetti at first glance, it likely means it is also that way for the compiler/cpu
    - are there obvious programmer mistakes in any loop constructs?
    - can it be reduced?
    - does sign matter?
Your inlined function here is a classic example (and one that is quite common):
Code:
        for(int i = 0;i < len;i++){
                //cout << "Comparing with " << nodes[chain[i]] << "." << endl;
                if(i == node || !adj(subgraph[i], node)) {
                        return false;
                }
        }
        return true;    
So here, for every single loop iteration, you are checking to see whether i == node, which can be reduced and removed entirely from the loop by starting with:
Code:
        if (node < len)
                return 0;    
As I did in the reworked version. It is worth restating that the compiler cannot ever know your intent, and while it is good at catching a lot of programmer lax, convincing it to output the same as my function is much more difficult (for the compiler).

I didn't spend a great deal of time or anything, just reading and "recompiling" your C++ into C++ Wink The real optimisations (in assembly language) start after I am satisfied that the HLL rendition and/or prototype is as good as it can be represented in whatever language I am working with. I wasn't interested in reducing the algorithm complexity or anything, but just looking at the code itself.

Re: gotos in code, in my experience, any loop construct ultimately ends up in either a conditional or direct jump. In this case, the target of the goto is also the target of a loop entry, so does not affect the outcome whatsoever. Small-ish switch/case statements end up in the same basket and gotos don't affect them either IMO.

$0.02 thusly Smile

_________________
2 Ton Digital - https://2ton.com.au/
Post 20 Apr 2016, 22:53
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20632
Location: In your JS exploiting you and your system
revolution 21 Apr 2016, 01:44
I still haven't figured out why so many people believe that gotos are "evil" or "horrible" or <some other bad thing>. IMO there is nothing wrong with gotos, not everything fits neatly into if/else/end structures.

And besides, "case" is a just a goto in disguise so FU whoever it was that first claimed gotos are evil Razz
Post 21 Apr 2016, 01:44
View user's profile Send private message Visit poster's website Reply with quote
Tyler



Joined: 19 Nov 2009
Posts: 1216
Location: NC, USA
Tyler 21 Apr 2016, 02:38
Their great for faking exception handling in C (and apparently also good for hand optimizing), and he does admit that they're useful in some cases, but they also eliminate the possibility for the compiler to know things it otherwise would have known thus eliminating optimizations the compiler otherwise would have exploited. (Yeah, I do see the irony here that redsock beat the compiler with goto's. He out compiler'ed the compiler.) Generally I would agree with you, but this (compiler optimization) is this professor's thing. I actually argued your point with him and got the concession they can be useful in some cases, but that they should be avoided unless strictly necessary. And that's reasonable. Let the compiler handle the optimization unless you have a really hot codepath. The "gotos are always and absolutely evil" is an overly strict application of a solid general rule with few exceptions.

revolution wrote:
And besides, "case" is a just a goto in disguise so FU whoever it was that first claimed gotos are evil
Yeah, that Dijkstra guy, he was sssoooooo dumb, amiright? Razz

http://www.u.arizona.edu/~rubinson/copyright_violations/Go_To_Considered_Harmful.html
Post 21 Apr 2016, 02:38
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2, 3, 4  Next

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.