Skip to content
This repository has been archived by the owner on Jul 5, 2020. It is now read-only.

output size is 16 times bigger than input??? #26

Open
vincenzoml opened this issue Nov 25, 2017 · 1 comment
Open

output size is 16 times bigger than input??? #26

vincenzoml opened this issue Nov 25, 2017 · 1 comment

Comments

@vincenzoml
Copy link

vincenzoml commented Nov 25, 2017

Hi, perhaps it's me not understanding how to use turbo.js, but I have the following test program, which produces an array of size 256, whereas I would expect it to produce an array of size 16 by reading (perhaps in a wrong way) the docs. Indeed that's because in "alloc" there is a line reading "data: new Float32Array(ns * 16)", and the values of sz and ns are the same when sz is a power of two. Could you clarify or maybe this is actually a bug?


    let k = 16
    var input = turbojs.alloc(k)

    var t0 = window.performance.now()
    for (let i = 0; i < k; i++) input.data[i] = i
    var t1 = window.performance.now()
    console.log(t1 - t0)

    t0 = window.performance.now()
    turbojs.run(input, `
      void main(void) {
        commit(read());
      }
      `)
    t1 = window.performance.now()
    console.log(t1 - t0)
  }

  console.log(input.data)
@vincenzoml
Copy link
Author

vincenzoml commented Nov 25, 2017

Update: if you replace your "1.386" constant in alloc with "log(4)" then allocation fails with an error, that's because "ns" gets assigned a different result if you use log(4) instead of 1.386 when sz is 16 (try just that in chrome's javascript console!). Why do you need a power of 4-sized texture anyway?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant