Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: remove _kernelSynchronousExecutor #78

Closed
robertleeplummerjr opened this issue May 15, 2017 · 4 comments
Closed

Proposal: remove _kernelSynchronousExecutor #78

robertleeplummerjr opened this issue May 15, 2017 · 4 comments
Milestone

Comments

@robertleeplummerjr
Copy link
Member

Since GPU can create kernels, I don't see a need to relate a Kernel to the GPU in this manner.

@robertleeplummerjr
Copy link
Member Author

also remove execute and exec off GPU

@fuzzie360
Copy link
Member

Hmmm @PicoCreator were you using this for future async support? Maybe we can refactor the async API a little.

P.S. Sad to say that async webgl has not yet landed and webworker with local memory has not landed either. So looks like we can't fully utlize async support as of yet...

@robertleeplummerjr
Copy link
Member Author

This has less to do with sync/async, and more to do with unbinding the last created kernel from the GPU instance. I think it'd be ideal to put them somewhere on the gpu, like maybe .kernels = [], so it'd be a list of kernels that were created, but just not the last created one.

As for using promises, we can simply hijack how run is handled either by some method, or by a setting to achieve a promise.

for example:

const kernel = gpu.createKernel(function() {}, { async: true });
kernel().then(function() {});

There are ton's of different ways of doing this, but the idea would be that kernel remains a singleton, and isn't accessed by the GPU instance directly. In a way, this simplifies the current implementation like so:
Currently:

const gpu = new GPU();

const kernel0 = gpu.createKernel(function() {});
const kernel1 = gpu.createKernel(function() {});
const kernel2 = gpu.createKernel(function() {});

gpu.exec();

Here gpu.exec() causes kernel2() to be called, which in turn calls kernel2.run(). This is somewhat confusing, because we can create as many kernels as we like, and gpu.exec() will only call the last created one.
Someone (me) may wonder: Why the last? Is that last better than the others? Is the last now king of the others? Which is the last again? Wait, I thought the last was something else.

The proposal would be to only allow for this:

const gpu = new GPU();

const kernel0 = gpu.createKernel(function() {});
const kernel1 = gpu.createKernel(function() {});
const kernel2 = gpu.createKernel(function() {});

console.log(gpu.kernels[0] === kernel0); //--> true
console.log(gpu.kernels[1] === kernel1); //--> true
console.log(gpu.kernels[2] === kernel2); //--> true

kernel0();
kernel1();
kernel2();

@fuzzie360
Copy link
Member

Oh I see. It makes sense to keep exec only on the Kernel, but not the GPU class.

@PicoCreator I don't remember why exec is in GPU, do you remember why?

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

No branches or pull requests

2 participants