Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Why does my code run slow?

Name: Anonymous 2008-02-27 15:53

$ cat f1.f
      PROGRAM f
      implicit none

      integer H, I, J
      integer A(1024, 1024)

      do 10 H = 0, 30
         do 20 I = 1, 1024
            do 30 J = 1, 1024
               A(I,J) = 0
 30         continue
 20      continue
 10   continue

      end program f
$ time ./f1

real    0m3.086s
user    0m3.063s
sys    0m0.019s

$ cat f2.c
int main(void)
{
    int h, i, j, a[1024][1024];

    for (h = 0; h < 10; h++)
      for (i = 0; i < 1024; i++)
    for (j = 0; j < 1024; j++)
      a[i][j] = 0; // !!

    return 0;
  }

$ time ./f2

real    0m0.080s
user    0m0.072s
sys    0m0.008s

Why is the FORTRAN version almost as slow as Ruby, which is slow as fuck?

Name: Anonymous 2008-02-27 16:04

did you -funroll-loops?

Name: Anonymous 2008-02-27 16:06

did you -O3?

Name: Anonymous 2008-02-27 16:06

A(J,I) = 0

Name: Anonymous 2008-02-27 16:16

What the hell is -O3?

Name: Anonymous 2008-02-27 16:21

>>5
              / ̄∧_∧ ̄ ̄ ̄ // ̄\\
       __ ⊂/__(´∀` )__  /_⊃___| |\フ ヽ  CFLAGS JUST KICKED
   ,  ´_  /   / ̄ ̄ __ / ̄ ヽ    __ヽ ̄ ̄ |  IN, YO!
  /∠__/―/-。―/――∠_/__∧  |       | ∧_.| 
  ,========――´=============/⌒ヽ=|.=====| | ヽ ̄〕 
  | _   |GENTOO|    _  ″  |⌒| |/   __ /|  )ノ    vroom
  )_旧_∈≡≡≡≡∋_旧_″_|| ノ丿_ -――┘ 丿      vroom!
   \ \_ノ  ̄ ̄ ̄三三三\ \_ノ    三三三三 
    三三三三三三三三三三三三三三三三三三三三三三三三
       三三三三三三三三三三三三三三三三三三三三三三三
          三三三三三三三三三三三三三三三三三三三三三三三三三三
                  三三三三三三三三三三三三三三三三三三
                        三三三三三三三三三三三

Name: Anonymous 2008-02-27 19:20

I found a bug in gnu optimizing on gcc 3.1 the other day. i didnt report it because it's such an old compiler

Name: Anonymous 2008-02-27 20:57

>>6

back to /vip/, please

Name: Anonymous 2008-02-27 22:15

>>8

back to #sicp, please

Name: Anonymous 2008-02-27 22:37

>>7
plz elaborate

Name: Anonymous 2008-02-27 22:43

>>10

back to /b/, please

Name: Anonymous 2008-02-27 22:48

>>11

back to YTMND, please

Name: Anonymous 2008-02-27 23:08

>>12

back to ebaum's, please

Name: Anonymous 2008-02-28 0:39

>>13

back to gaia, please

Name: Anonymous 2008-02-28 0:50

>>9-14

Go to your room.

Name: Anonymous 2011-02-04 19:08

Name: Anonymous 2012-09-28 1:38

Name: Anonymous 2012-09-28 6:36

Fortran, in my /prog/?!

Valid Fortran:

      PROGRAMF
      IMPLICITNONE
      INTEGERH,I,J
      INTEGERA(1024,1024)
      DO10H=0,30
      DO20I=1,1024
      DO30J=1,1024
      A(I,J)=0
 30   CONTINUE
 20   CONTINUE
 10   CONTINUE
      ENDPROGRAMF

Its the anti-FIOC.

Name: Anonymous 2012-09-28 17:16

The outermost loop of the Fortran version performs 30 iterations, the C version does only 10.

Name: Anonymous 2013-09-01 13:33


 Much like cute flowers, anime girls bloom during spring. That's a goddamn ton of cartoons we're getting.

Name: Anonymous 2013-09-01 15:04


In general: decompose the logical units of your system into the smallest referentially transparent components possible, them implement them in modules. Global or local environments for sets of components (or inside components) might be mapped to monads. Use algebraic data types to describe core data structures. Share those definitions widely.

Don't change these.
Name: Email:
Entire Thread Thread List