From 3e65ed4d410fb72848c41789a5753b5d2daed3bf Mon Sep 17 00:00:00 2001 From: Fazli Sapuan Date: Sun, 28 Feb 2016 15:14:19 +0800 Subject: [PATCH 1/3] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a2558df7..204cb808 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ The created function is a regular JavaScript function, you can use it like regul ```js myFunc(); -// Result: [0, 1, 2, 3, ... 100] +// Result: [0, 1, 2, 3, ... 99] ``` Note: Instead of creating an object, you can use the chainable shortcut methods as a neater way of specificying options. @@ -81,7 +81,7 @@ var myFunc = gpu.createKernel(function() { }).dimensions([100]); myFunc(); -// Result: [0, 1, 2, 3, ... 100] +// Result: [0, 1, 2, 3, ... 99] ``` ### Accepting Input From ec9c3304e2ee78b36a2c8b4bdcfafee7917c1868 Mon Sep 17 00:00:00 2001 From: Fazli Sapuan Date: Sun, 28 Feb 2016 16:03:01 +0800 Subject: [PATCH 2/3] Add loopMaxIterations option --- src/backend/fallback.js | 5 +++++ src/backend/functionBuilder.js | 22 ++++++++++++-------- src/backend/functionNode.js | 4 ++-- src/backend/functionNode_webgl.js | 34 ++++++++++++++++++++----------- src/backend/glsl.js | 9 ++++++-- test/src/features/for_loop.js | 3 ++- 6 files changed, 51 insertions(+), 26 deletions(-) diff --git a/src/backend/fallback.js b/src/backend/fallback.js index f05ba43e..20411038 100644 --- a/src/backend/fallback.js +++ b/src/backend/fallback.js @@ -167,6 +167,11 @@ return ret; }; + ret.loopMaxIterations = function(max) { + opt.loopMaxIterations = max; + return ret; + }; + ret.wraparound = function() { opt.wraparound = false; return ret; diff --git a/src/backend/functionBuilder.js b/src/backend/functionBuilder.js index 04388b4a..c02845dc 100644 --- a/src/backend/functionBuilder.js +++ b/src/backend/functionBuilder.js @@ -64,7 +64,7 @@ var functionBuilder = (function() { /// /// Returns: /// {[String,...]} Returning list of function names that is traced. Including itself. - function traceFunctionCalls( functionName, retList ) { + function traceFunctionCalls( functionName, retList, opt ) { functionName = functionName || "kernel"; retList = retList || []; @@ -76,9 +76,9 @@ var functionBuilder = (function() { } else { retList.push(functionName); - fNode.getWebglFunctionString(); //ensure JS trace is done + fNode.getWebglFunctionString(opt); //ensure JS trace is done for(var i=0; i Date: Sun, 28 Feb 2016 16:03:16 +0800 Subject: [PATCH 3/3] Add loopMaxIterations option --- src/backend/functionNode_webgl.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/backend/functionNode_webgl.js b/src/backend/functionNode_webgl.js index 1a617956..23132338 100644 --- a/src/backend/functionNode_webgl.js +++ b/src/backend/functionNode_webgl.js @@ -348,7 +348,6 @@ var functionNode_webgl = (function() { if (forNode.test.right.type == "Identifier" && forNode.test.operator == "<") { - console.log(opt.loopMaxIterations); if (opt.loopMaxIterations === undefined) { console.warn("Warning: loopMaxIterations is not set! Using default of 100 which may result in unintended behavior."); console.warn("Set loopMaxIterations or use a for loop of fixed length to silence this message.");