cs205-lecture-examples

Example codes used during Harvard CS205 lectures
git clone https://git.0xfab.ch/cs205-lecture-examples.git
Log | Files | Refs | README | LICENSE

f.ispc (304B)


      1 export uniform int f()
      2 {
      3     varying int a = {1, -1, 1, 1}; // vector (could omit `varying` as well)
      4     varying int b = {-1, -1, -1, -1}; // vector
      5 
      6     if (a < 0) {
      7         a = 0;
      8     } else {
      9         a += b;
     10     }
     11 
     12     uniform int x = 1; // scalar storage
     13     return x + reduce_add(a); // expect: 1
     14 }