Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
60 lines (55 loc) · 1.94 KB

File metadata and controls

60 lines (55 loc) · 1.94 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
const { assert, skip, test, module: describe } = require('qunit');
const { GPU, HeadlessGLKernel, WebGLKernel, WebGL2Kernel, CPUKernel } = require('../../src');
describe('issue #91');
function getResult(mode) {
const A = [
[1, 2],
[3, 4],
[5, 6]
];
const B = [
[6, 5, 4],
[3, 2, 1]
];
const gpu = new GPU({ mode });
function multiply(b, a, y, x) {
let sum = 0;
for (let i = 0; i < 2; i++) {
sum += b[y][i] * a[i][x];
}
return sum;
}
const kernels = gpu.createKernelMap({
multiplyResult: multiply
}, function (a, b) {
return multiply(b, a, this.thread.y, this.thread.x);
})
.setOutput([2, 2]);
const result = kernels(A, B).result;
assert.deepEqual(Array.from(result[0]), [21,32]);
assert.deepEqual(Array.from(result[1]), [9,14]);
gpu.destroy();
return kernels;
}
(GPU.isWebGL2Supported || (GPU.isHeadlessGLSupported && HeadlessGLKernel.features.kernelMap) ? test : skip)("Issue #91 - type detection auto", () => {
getResult();
});
(GPU.isWebGL2Supported || (GPU.isHeadlessGLSupported && HeadlessGLKernel.features.kernelMap) ? test : skip)("Issue #91 - type detection gpu", () => {
getResult('gpu');
});
(GPU.isWebGLSupported ? test : skip)("Issue #91 - type detection webgl", () => {
const kernel = getResult('webgl');
assert.equal(kernel.kernel.constructor, WebGLKernel, 'kernel type is wrong');
});
(GPU.isWebGL2Supported ? test : skip)("Issue #91 - type detection webgl2", () => {
const kernel = getResult('webgl2');
assert.equal(kernel.kernel.constructor, WebGL2Kernel, 'kernel type is wrong');
});
(GPU.isHeadlessGLSupported ? test : skip)("Issue #91 - type detection headlessgl", () => {
const kernel = getResult('headlessgl');
assert.equal(kernel.kernel.constructor, HeadlessGLKernel, 'kernel type is wrong');
});
test("Issue #91 - type detection cpu", () => {
const kernel = getResult('cpu');
assert.equal(kernel.kernel.constructor, CPUKernel, 'kernel type is wrong');
});
Morty Proxy This is a proxified and sanitized view of the page, visit original site.