mirror of
https://github.com/gpujs/gpu.js.git
synced 2026-01-18 16:04:10 +00:00
Tweak to test function
This commit is contained in:
parent
be3f065e21
commit
bad8f0403c
@ -1,21 +1,23 @@
|
||||
//
|
||||
// See: https://github.com/gpujs/gpu.js/issues/31
|
||||
//
|
||||
function nestedVarDeclare( mode ) {
|
||||
var gpu = new GPU();
|
||||
var f = gpu.createKernel(function() {
|
||||
var ret = 0.0;
|
||||
|
||||
// outer loop limit is effectively skipped in CPU
|
||||
for(var i=0; i<10; ++i) {
|
||||
// inner loop limit should be higher, to avoid infinite loops
|
||||
for(var i=0; i<20; ++i) {
|
||||
ret += 1;
|
||||
}
|
||||
function nestedVarDeclareFunction() {
|
||||
var ret = 0.0;
|
||||
|
||||
// outer loop limit is effectively skipped in CPU
|
||||
for(var i=0; i<10; ++i) {
|
||||
// inner loop limit should be higher, to avoid infinite loops
|
||||
for(var i=0; i<20; ++i) {
|
||||
ret += 1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}, {
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
function nestedVarDeclareTest( mode ) {
|
||||
var gpu = new GPU();
|
||||
var f = gpu.createKernel(nestedVarDeclareFunction, {
|
||||
dimensions : [1],
|
||||
mode : mode
|
||||
});
|
||||
@ -25,13 +27,34 @@ function nestedVarDeclare( mode ) {
|
||||
}
|
||||
|
||||
QUnit.test( "Issue #31 - nestedVarDeclare (auto)", function() {
|
||||
nestedVarDeclare(null);
|
||||
nestedVarDeclareTest(null);
|
||||
});
|
||||
|
||||
QUnit.test( "Issue #31 - nestedVarDeclare (GPU)", function() {
|
||||
nestedVarDeclare("gpu");
|
||||
nestedVarDeclareTest("gpu");
|
||||
});
|
||||
|
||||
QUnit.test( "Issue #31 - nestedVarDeclare (CPU)", function() {
|
||||
nestedVarDeclare("cpu");
|
||||
nestedVarDeclareTest("cpu");
|
||||
});
|
||||
|
||||
QUnit.test( "Issue #31 - nestedVarDeclare : AST handling", function() {
|
||||
var builder = new functionBuilder();
|
||||
builder.addFunction(null, nestedVarDeclareFunction);
|
||||
|
||||
QUnit.equal(
|
||||
builder.webglString_fromFunctionNames(["nestedVarDeclareFunction"]).replace(new RegExp("\n", "g"), ""),
|
||||
"float nestedVarDeclareFunction() {"+
|
||||
"float user_ret=0.0;"+
|
||||
";"+
|
||||
""+
|
||||
"for (float user_i=0.0;(user_i<10.0);++user_i){"+
|
||||
"for (user_i=0.0;(user_i<20.0);++user_i){"+
|
||||
"user_ret+=1.0;"+
|
||||
"}"+
|
||||
"}"+
|
||||
""+
|
||||
"return user_ret;"+
|
||||
"}"
|
||||
);
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user