? Editing: Post:21.body Save Delete Cancel
Content changed Sign & Publish new content


I hate everything and everyone.
Fuck the world, the people.
Fuck the children, women, men.
Fuck politics, war, peace, money.
Fuck bullshit and startups.
Fuck stupids.

Fuck you.

Follow in NewsfeedFollowing

Latest comments:

Add new post


21 hours ago · 2 min read 2
Read more

[C Unix] What is the opti ?

on Mar 07, 2016
#include <stdio.h>

int main() {
  long v = 0;
  for (long i = 0; i < 1000000000; i++) {
    v = (v + i % 2);
  printf("> %ld\n", v);
  return 0;

gcc -O3 main.c

Can't optimize this :(


user_name1 day ago
nabon Mar 08, 2016


but that was not the aim to make an optimizable sample. It was to show that the compiler cannot optimize every expression. I know too many people saying "fuck it, the compiler is magic, it will make it itself"

kostanewon Mar 08, 2016

Wow, something use -O3 optimization in 0net;)

It is very sad sample. Vectorization can't work this, because modern processors have not vector instructions for %. May be parallelization will be work, if you directly write OpenMP pragmas and change form of instructions...

pragma omp parallel for reduce(+:v)

for (long i = 0; i < 1000000000; i++) {
v += i % 2;

But I am highly recommend use more simple expression for max. performance:

pragma omp parallel for reduce(+:v)

for (long i = 1; i < 1000000000; i+=2) {
v += i;

This page is a snapshot of ZeroNet. Start your own ZeroNet for complete experience. Learn More