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

String support? #50

Closed
PicoCreator opened this issue Oct 2, 2016 · 5 comments
Closed

String support? #50

PicoCreator opened this issue Oct 2, 2016 · 5 comments

Comments

@PicoCreator
Copy link
Contributor

PicoCreator commented Oct 2, 2016

@Drulac would be interested. If we get for loops with variables done =P

See: https://gitter.im/gpujs/gpu.js muhaha

@Drulac
Copy link
Contributor

Drulac commented Oct 2, 2016

I made this little code to try perf on a method :

var gpu = new GPU();

var add = gpu.createKernel(function(){
    var a = 0;
    for(var i=0; i < 100000000000; ++i)
    {
        if(i < 100)
        {
            a = a + 1;
        }else{
            break;
        }
    }
    return a;
}).dimensions([1]);

function bench()
{
    add.mode("GPU");
    console.time("GPU");
    console.log(add());
    console.timeEnd("GPU");

    add.mode("CPU");
    console.time("CPU");
    console.log(add());
    console.timeEnd("CPU");
}

bench result :

bench();
GPU: 107.860ms
CPU: 3.080ms
bench();
GPU: 2.212ms
CPU: 2.339ms
bench();
GPU: 1.749ms
CPU: 2.439ms
bench();
GPU: 1.607ms
CPU: 2.013ms
bench();
GPU: 1.963ms
CPU: 2.250ms

@fuzzie360
Copy link
Member

@PicoCreator we already have loops with variables

var add = gpu.createKernel(function(){
    var a = 0; var b = 100;
    for(var i=0; i < b; i++)
    {
        a = a + 1;
    }
    return a;
}).dimensions([1]).loopMaxIterations(100000000000);

function bench()
{
    add.mode("GPU");
    console.time("GPU");
    console.log(add());
    console.timeEnd("GPU");

    add.mode("CPU");
    console.time("CPU");
    console.log(add());
    console.timeEnd("CPU");
}

@PicoCreator
Copy link
Contributor Author

PicoCreator commented Oct 3, 2016

@fuzzie360 bows

@Drulac, would that be good enough? : Now you just need to be able to create fixed arrays in GPU/JS code right?

@Drulac
Copy link
Contributor

Drulac commented Oct 3, 2016

This doesn't work I think (I havent the time to test)

var add = gpu.createKernel(function(b){
    var a = 0;
    for(var i=0; i < b; i++)
    {
        a = a + 1;
    }
    return a;
}).dimensions([1]).loopMaxIterations(100000000000);

function bench()
{
    add.mode("GPU");
    console.time("GPU");
    console.log(add(100));
    console.timeEnd("GPU");

    add.mode("CPU");
    console.time("CPU");
    console.log(add(100));
    console.timeEnd("CPU");
}

@fuzzie360
Copy link
Member

Closing this issue because the code snippet works fine now

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

No branches or pull requests

3 participants