-
Notifications
You must be signed in to change notification settings - Fork 662
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Upgrade gpu-mock.js to latest 100% code coverage tested
fix: Added tests for building kernels with "dev" mode feat: Added a `.toArray()` method on `Input`, for usage with "dev" mode fix: `Input.size` to reflect exactly what was sent in, rather than make up dimensions that aren't there fix: `KernelArgument.dimensions` to fill in missing dimensions from size fix: Only safe declarations when using a literal
- Loading branch information
1 parent
8283290
commit 5605504
Showing
17 changed files
with
1,311 additions
and
261 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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,147 @@ | ||
const { assert, skip, test, module: describe, only } = require('qunit'); | ||
const { GPU, input } = require('../../src'); | ||
|
||
describe('features: dev mode'); | ||
|
||
test('works with integer', () => { | ||
const gpu = new GPU({ mode: 'dev' }); | ||
const kernel = gpu.createKernel(function(value) { | ||
return value; | ||
}, { output: [1] }); | ||
assert.deepEqual(kernel(1), new Float32Array([1])); | ||
gpu.destroy(); | ||
}); | ||
|
||
test('works with float', () => { | ||
const gpu = new GPU({ mode: 'dev' }); | ||
const kernel = gpu.createKernel(function(value) { | ||
return value; | ||
}, { output: [1] }); | ||
assert.deepEqual(kernel(1.5), new Float32Array([1.5])); | ||
gpu.destroy(); | ||
}); | ||
|
||
test('works with array', () => { | ||
const gpu = new GPU({ mode: 'dev' }); | ||
const kernel = gpu.createKernel(function(value) { | ||
return value[this.thread.x]; | ||
}, { output: [4] }); | ||
assert.deepEqual(kernel([1,2,3,4]), new Float32Array([1,2,3,4])); | ||
gpu.destroy(); | ||
}); | ||
|
||
test('works with matrix', () => { | ||
const gpu = new GPU({ mode: 'dev' }); | ||
const kernel = gpu.createKernel(function(value) { | ||
return value[this.thread.y][this.thread.x]; | ||
}, { output: [4, 2] }); | ||
assert.deepEqual(kernel( | ||
[ | ||
[1,2,3,4], | ||
[5,6,7,8] | ||
] | ||
), [ | ||
new Float32Array([1,2,3,4]), | ||
new Float32Array([5,6,7,8]), | ||
]); | ||
gpu.destroy(); | ||
}); | ||
|
||
test('works with cube', () => { | ||
const gpu = new GPU({ mode: 'dev' }); | ||
const kernel = gpu.createKernel(function(value) { | ||
return value[this.thread.z][this.thread.y][this.thread.x]; | ||
}, { output: [4, 2, 2] }); | ||
assert.deepEqual(kernel( | ||
[ | ||
[ | ||
[1,2,3,4], | ||
[5,6,7,8] | ||
], | ||
[ | ||
[9,10,11,12], | ||
[13,14,15,16] | ||
] | ||
] | ||
), [ | ||
[ | ||
new Float32Array([1,2,3,4]), | ||
new Float32Array([5,6,7,8]), | ||
],[ | ||
new Float32Array([9,10,11,12]), | ||
new Float32Array([13,14,15,16]), | ||
] | ||
]); | ||
gpu.destroy(); | ||
}); | ||
|
||
test('works with input array', () => { | ||
const gpu = new GPU({ mode: 'dev' }); | ||
const kernel = gpu.createKernel(function(value) { | ||
return value[this.thread.x]; | ||
}, { output: [4] }); | ||
assert.deepEqual(kernel(input([1,2,3,4], [4])), new Float32Array([1,2,3,4])); | ||
gpu.destroy(); | ||
}); | ||
|
||
test('works with input matrix', () => { | ||
const gpu = new GPU({ mode: 'dev' }); | ||
const kernel = gpu.createKernel(function(value) { | ||
return value[this.thread.y][this.thread.x]; | ||
}, { output: [4, 2] }); | ||
assert.deepEqual(kernel(input([1,2,3,4,5,6,7,8], [4, 2])), [ | ||
new Float32Array([1,2,3,4]), | ||
new Float32Array([5,6,7,8]), | ||
]); | ||
gpu.destroy(); | ||
}); | ||
|
||
test('works with input cube', () => { | ||
const gpu = new GPU({ mode: 'dev' }); | ||
const kernel = gpu.createKernel(function(value) { | ||
return value[this.thread.z][this.thread.y][this.thread.x]; | ||
}, { output: [4, 2, 2] }); | ||
assert.deepEqual(kernel( | ||
input([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16], [4,2,2]) | ||
), [ | ||
[ | ||
new Float32Array([1,2,3,4]), | ||
new Float32Array([5,6,7,8]), | ||
],[ | ||
new Float32Array([9,10,11,12]), | ||
new Float32Array([13,14,15,16]), | ||
] | ||
]); | ||
gpu.destroy(); | ||
}); | ||
|
||
test('works with texture', () => { | ||
const texture = ((new GPU()).createKernel(function (cube) { | ||
return cube[this.thread.z][this.thread.y][this.thread.x]; | ||
}, { output: [4,2,2], pipeline: true }))([ | ||
[ | ||
new Float32Array([1,2,3,4]), | ||
new Float32Array([5,6,7,8]), | ||
],[ | ||
new Float32Array([9,10,11,12]), | ||
new Float32Array([13,14,15,16]), | ||
] | ||
]); | ||
assert.ok(texture.constructor.name.match('Texture')); | ||
const gpu = new GPU({ mode: 'dev' }); | ||
const kernel = gpu.createKernel(function(value) { | ||
return value[this.thread.z][this.thread.y][this.thread.x]; | ||
}, { output: [4, 2, 2] }); | ||
assert.deepEqual(kernel( | ||
texture | ||
), [ | ||
[ | ||
new Float32Array([1,2,3,4]), | ||
new Float32Array([5,6,7,8]), | ||
],[ | ||
new Float32Array([9,10,11,12]), | ||
new Float32Array([13,14,15,16]), | ||
] | ||
]); | ||
gpu.destroy(); | ||
}); |
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