-
Notifications
You must be signed in to change notification settings - Fork 640
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
and fix a return on cpu when in graphic mode
- Loading branch information
1 parent
acc3651
commit 323a4e1
Showing
5 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>GPU.JS : Combine Kernels</title> | ||
<link rel="stylesheet" href="../../../node_modules/qunitjs/qunit/qunit.css"> | ||
|
||
<!-- gpu.js scripts --> | ||
<script src="../../../bin/gpu.js"></script> | ||
</head> | ||
<body> | ||
<div id="qunit"></div> | ||
<div id="qunit-fixture"></div> | ||
<script src="../../../node_modules/qunitjs/qunit/qunit.js"></script> | ||
<script src="../../src/features/combine-kernels.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
function combineKernels(mode) { | ||
var gpu = new GPU({ mode: mode }); | ||
|
||
var kernel1 = gpu.createKernel(function(a, b) { | ||
return a[this.thread.x] + b[this.thread.x]; | ||
}, { dimensions: [5] }); | ||
|
||
var kernel2 = gpu.createKernel(function(c, d) { | ||
return c[this.thread.x] * d[this.thread.x]; | ||
}, { dimensions: [5] }); | ||
|
||
return gpu.combineKernels(kernel1, kernel2, function(array1, array2, array3) { | ||
return kernel2(kernel1(array1, array2), array3); | ||
}); | ||
} | ||
|
||
QUnit.test( "combineKernels (auto)", function() { | ||
var superKernel = combineKernels(null); | ||
var result = QUnit.extend([], superKernel([1,2,3,4,5], [1,2,3,4,5], [1,2,3,4,5])); | ||
QUnit.assert.deepEqual(result, [2, 8, 18, 32, 50]); | ||
}); | ||
|
||
QUnit.test( "combineKernels (WebGL)", function() { | ||
var superKernel = combineKernels('webgl'); | ||
var result = QUnit.extend([], superKernel([1,2,3,4,5], [1,2,3,4,5], [1,2,3,4,5])); | ||
QUnit.assert.deepEqual(result, [2, 8, 18, 32, 50]); | ||
}); | ||
|
||
QUnit.test( "combineKernels (CPU)", function() { | ||
var superKernel = combineKernels('cpu'); | ||
var result = QUnit.extend([], superKernel([1,2,3,4,5], [1,2,3,4,5], [1,2,3,4,5])); | ||
QUnit.assert.deepEqual(result, [2, 8, 18, 32, 50]); | ||
}); | ||
|
||
console.log(combineKernels('gpu')([1,2,3,4,5], [1,2,3,4,5], [1,2,3,4,5])); |