(mode)
| 4 | describe('nested function'); |
| 5 | |
| 6 | function nestedSumABTest(mode) { |
| 7 | const gpu = new GPU({ mode }); |
| 8 | const f = gpu.createKernel(function(a, b) { |
| 9 | function custom_adder(a,b) { |
| 10 | return a+b; |
| 11 | } |
| 12 | |
| 13 | return custom_adder(a[this.thread.x], b[this.thread.x]); |
| 14 | }, { |
| 15 | output : [6] |
| 16 | }); |
| 17 | |
| 18 | assert.ok(f !== null, 'function generated test'); |
| 19 | |
| 20 | const a = [1, 2, 3, 5, 6, 7]; |
| 21 | const b = [4, 5, 6, 1, 2, 3]; |
| 22 | |
| 23 | const res = f(a,b); |
| 24 | const exp = [5, 7, 9, 6, 8, 10]; |
| 25 | |
| 26 | assert.deepEqual(Array.from(res), exp); |
| 27 | gpu.destroy(); |
| 28 | } |
| 29 | |
| 30 | test('nested_sum auto', () => { |
| 31 | nestedSumABTest(null); |
no test coverage detected
searching dependent graphs…