News for hackers. Stuff that matters.
Re:CPU Utilization is Wrong by nimos on Tuesday May 09, 2017 @05:08PM (#14303824)
Perf is fascinating to dive into. If you are using C and gcc you can use record/report that show you line by line and instruction by instruction where you are getting slowdowns.

One of my favorite school assignments was we were given an intentionally bad implementation of the Game of Life compiled with -O3 and trying to get it to run faster without changing compiler flags. It's sort of mind boggling how fast computers can do stuff if you can reduce the problem to fixed stride for loops over arrays that can be fully pipelined.

Re:CPU Utilization is Wrong by hendzen on Tuesday May 09, 2017 @09:41PM (#14305321)
If you think perf is impressive you should try Intel vTune. Has support for finding hot mutexes, all perf counters, and even generates neat graphs that show diagrams of synchronization points between multiple threads.
Re:CPU Utilization is Wrong by Martinsos on Thursday May 11, 2017 @10:15AM (#14316136)
Hi Hendzen, I found in one of your previous comments that you have set up your emacs to have full support for c++ projects, like auto-completion and reference following and similar. I have been using Emacs for a few years now, for js/python/html/C/C++/anything else and have just started working on a larger C++ project where intelligent auto completion and navigation would help a lot. Would you mind providing some more details on how you got it set up, maybe share your init.el file? It is a Cmake project, uses ninja as a generator. Thanks!
Re:CPU Utilization is Wrong by hendzen on Friday May 12, 2017 @05:46AM (#14322589)
I'm writing less C++ than I used to recently, but here's the basic setup I use:

1) Emacs prelude w/ helm enabled everywhere -https://github.com/bbatsov/prelude

2) Irony-mode for auto completion. Since you're using Cmake, you can just add CMAKE_EXPORT_COMPILE_COMMANDS to your invocation to output the needed metadata for completion to work. - https://github.com/Sarcasm/irony-mode

3) helm-flycheck for syntax checking https://github.com/yasuyk/helm-flycheck

4) For jump to definition I generally just use helm-ag (grep) , I never actually got this working to my satisfaction despite trying a few things like rtags (slow, unstable) and clang-ctags (promising but annoying to set up at the time).

5) For formatting I usually just enable clang-format on save w/ something like this (requires clang-format mode installed):

  (add-hook 'c++-mode-hook
    (lambda () (add-hook 'before-save-hook #'clang-format-buffer nil t)))
Re:CPU Utilization is Wrong by Asooka on Wednesday May 10, 2017 @10:03AM (#14308233)
Are there affordable options for non-enterprise customers? I use it at work, but we buy bulk licenses and I was under the impression that licenses start at several thousands per seat.
Re:CPU Utilization is Wrong by mdani on Wednesday May 10, 2017 @02:08AM (#14306220)
Second that. It is amazing for C and C++ code - but does not work well on VMs such as AWS or with Java code.
Re:CPU Utilization is Wrong by brendangregg on Wednesday May 10, 2017 @02:13AM (#14306241)
... I believe I was the first person to run vTune from an AWS EC2 guest. I'll share details when I can. :)
Re:CPU Utilization is Wrong by Someone on Tuesday May 09, 2017 @05:25PM (#14303926)
That's true and a nice exercise for a programming class, but if you "reduce the problem to fixed stride for loops over arrays that can be fully pipelined." to make the game of life as fast as possible, you're doing it wrong (for those who don't know about it: https://en.wikipedia.org/wiki/Hashlife)
Re:CPU Utilization is Wrong by tomovo on Tuesday May 09, 2017 @05:50PM (#14304097)
It's also true and nice for most modern game engines. I'm quite sure Game of life was just a subject for the exercise with the purpose to show that you can get major speedups without changing the algorithm - you don't always have a better one as backup.
Re:CPU Utilization is Wrong by nimos on Tuesday May 09, 2017 @05:48PM (#14304083)
Yeah for sure. We only had to calculate 1 or 2 iterations of the game and had a random seeded array as input and preallocated array we had to populate as output so there was a lot of optimization that wasn't worth it if you were actually looking to implement Game of Life, it was designed specifically to get you to think about computer system stuff.
Re:CPU Utilization is Wrong by adrianratnapala on Tuesday May 09, 2017 @08:02PM (#14304905)
Hashlife is impressive, but don't misread the above comment as saying it is "the" right way of doing it. Hashlife is good if there is lots of repetition (or sparseness).

There are many other optimisation strategies, with different trade-offs.