From aa9046476cff2b2804381845fe19d5c2dbacea4f Mon Sep 17 00:00:00 2001 From: Robert Plummer Date: Wed, 25 Oct 2017 07:48:06 -0400 Subject: [PATCH] reproduced error --- test/html/issues/207-same-function-reuse.html | 18 +++++++++++ test/html/test-all.html | 1 + test/src/issues/207-same-function-reuse.js | 32 +++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 test/html/issues/207-same-function-reuse.html create mode 100644 test/src/issues/207-same-function-reuse.js diff --git a/test/html/issues/207-same-function-reuse.html b/test/html/issues/207-same-function-reuse.html new file mode 100644 index 00000000..b8f44816 --- /dev/null +++ b/test/html/issues/207-same-function-reuse.html @@ -0,0 +1,18 @@ + + + + + GPU.JS : Funky Function Support + + + + + + +
+
+ + + + + diff --git a/test/html/test-all.html b/test/html/test-all.html index 86001ceb..efe7b610 100644 --- a/test/html/test-all.html +++ b/test/html/test-all.html @@ -49,6 +49,7 @@ + diff --git a/test/src/issues/207-same-function-reuse.js b/test/src/issues/207-same-function-reuse.js new file mode 100644 index 00000000..217f1684 --- /dev/null +++ b/test/src/issues/207-same-function-reuse.js @@ -0,0 +1,32 @@ +function reuse(mode) { + var gpu = new GPU({ mode: mode }); + + var f = gpu.createKernel(function(a, b) { + function custom_adder(a,b) { + return a+b; + } + function some_fun_1(a,b) { + return custom_adder(a,b); + } + function some_fun_2(a,b) { + return custom_adder(a,b); + } + return some_fun_1(1,2)+some_fun_2(a[this.thread.x], b[this.thread.x]); + }, { + dimensions : [6] + }).setDebug(true).setOutput([6]); + + var a = [1, 2, 3, 5, 6, 7]; + var b = [4, 5, 6, 1, 2, 3]; + + var result = f(a,b); + assert.deepEqual(QUnit.extend([], result), [5,7,9,6,8,10]); +} + +QUnit.test('Issue #207 - same function reuse CPU', function() { + reuse('cpu'); +}); + +QUnit.test('Issue #207 - same function reuse GPU', function() { + reuse('gpu'); +}); \ No newline at end of file