(mode)
| 309 | |
| 310 | describe('features: add custom private'); |
| 311 | function addCustomPrivate(mode) { |
| 312 | const gpu = new GPU({ mode }); |
| 313 | |
| 314 | const kernel = gpu.createKernel(function(a, b) { |
| 315 | function customAdder(a, b) { |
| 316 | let sum = 0; |
| 317 | for (let i = 0; i < this.output.x; i++) { |
| 318 | sum += a[this.thread.x] + b[this.thread.x]; |
| 319 | } |
| 320 | return sum; |
| 321 | } |
| 322 | return customAdder(a, b); |
| 323 | }, { |
| 324 | output : [6], |
| 325 | }); |
| 326 | |
| 327 | assert.ok(kernel !== null, 'function generated test'); |
| 328 | |
| 329 | const a = [1, 2, 3, 5, 6, 7]; |
| 330 | const b = [1, 1, 1, 1, 1, 1]; |
| 331 | |
| 332 | const result = kernel(a,b); |
| 333 | const expected = [12, 18, 24, 36, 42, 48]; |
| 334 | |
| 335 | assert.deepEqual(Array.from(result), expected); |
| 336 | gpu.destroy(); |
| 337 | } |
| 338 | |
| 339 | test('auto', () => { |
| 340 | addCustomPrivate(null); |
no test coverage detected
searching dependent graphs…