Mill Computing, Inc. Forums The Mill Architecture code examples?

  • Author
    Posts
  • goldbug
    Participant
    Post count: 53
    #2930 |

    Hi Ivan, I was wondering if you could provide some more code examples. In the pipeline video, you give a great explanation of how it works, and some idea of what instructions it will produce, but very little actual code. I was wondering if you could show how this code would compile:

    void mult(int *a, int c)
    {
       for (int i=0; i< c; i++) {
          a[i] = a[i] * 3;
       }
    }
    

    From the metadata talk, what would this compile to?

    void strcpy(char *src, char *dst) {
        char c;
        do {
           c = *(dst++) = *(src++);
        } while (c != 0);
    }
    
  • Ivan Godard
    Keymaster
    Post count: 689

    Somehow your several recent posts didn’t get put on my feed until this one sprung something loose. I’ll answer those others separately; sorry for the delay.

    Both of these codes involve loops, and to get good code on them requires that the specializer does software pipe-lining at a minimum, and auto-vectorization where relevant. The tool chain isn’t up to that yet. When it is we’ll do another mini-talk, and your codes might be the subject. No promises though 🙂

    • goldbug
      Participant
      Post count: 53

      I would gladly take the credit… if I came up with it. Those snippets came straight out of your talks. I was hopping that since you already looked into them you would have something already.

    • goldbug
      Participant
      Post count: 53

      Loops are hard to vectorize, the compiler needs to reason about the structure of the program in order to do that.

      Is pipelining easier or it is also a monster problem?

      • Ivan Godard
        Keymaster
        Post count: 689

        Pipelining is easier IMO, at least with SSA. You have a feasible linear schedule and simply lay it around the torus, so everything is done in scalar order. While an instruction may contain operations from different iterations, the arguments of those operations are unambiguously the ones that belong to that iteration so aliasing is not an issue, no more than it is with simple unrolling. The annoying part is the loop prologue and epilogue, and there we have hardware help.

You must be logged in to reply to this topic.