Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPU.js kernel functions not running in unit tests in Angular 7.1 #663

Closed
evanakm opened this issue Jan 12, 2021 · 2 comments
Closed

GPU.js kernel functions not running in unit tests in Angular 7.1 #663

evanakm opened this issue Jan 12, 2021 · 2 comments

Comments

@evanakm
Copy link

evanakm commented Jan 12, 2021

I am trying to integrate a piece of TypeScript code which works fine as a standalone Angular project into a larger project. All unit tests were working before, but for some reason, all the unit tests involving running GPU.js kernel functions are now failing. Stepping through the code reveals that the failure happens when the kernel function is called. This is a representative example, but it fails in the same way with all instances of running a GPU.js kernel function.

Angular 7.1
GPU.js 2.10.4
Typescript 3.1.1

This was previously working, and works in a standalone project, but is not functioning anymore:

export class GLFunctionService {
    private m_gpu: GPU;
​
    public constructor() {        
        if (GPU.isGPUSupported) {
            console.log('GPU Supported');
            this.m_gpu = new GPU({ mode: 'gpu' });
        } else {
            console.log('GPU Not Supported');
            this.m_gpu = new GPU({ mode: 'cpu' });
        }
    }

    public testBasicFunction() {
        const kernel = this.m_gpu.createKernel(this.func_basic).setOutput([3, 3]);
        const result: KernelOutput = kernel() as number[][];
        return result;
    }

    private readonly func_basic: KernelFunction = function (): any {
        return this.thread.x + this.thread.y;
    };

}

And in the .spec file

    const glfs = new GLFunctionService();

    describe("basic kernel function wrapped in GLFunctionService class", () => {

        const result = glfs.testBasicFunction();

        it("should have the expected matrix entries", () => {
            expect(result[2][0]).toEqual(2);
            expect(result[2][1]).toEqual(3);
        });
        
    })

However, it works if I replicate the logic using lambdas in the .spec file itself. So this works:

    const m_gpu = new GPU({ mode: 'gpu' });

    describe("basic kernel function", () => {
        const func_basic: KernelFunction = function (): any {
            return this.thread.x + this.thread.y;
        };

        const kernel = m_gpu.createKernel(func_basic).setOutput([3, 3]);
        const result: KernelOutput = kernel() as number[][];

        it("should have the expected matrix entries", () => {
            expect(result[2][0]).toEqual(2);
            expect(result[2][1]).toEqual(3);
        })  
    })

Error message:

Chrome 87.0.4280 (Windows 10.0.0) debugging GPU.js basic kernel function wrapped in GLFunctionService class encountered a declaration exception FAILED  
        Error: Unexpected expression on line 1, position 57:
         ov_o7z5aoq2b.s[78]
            at WebGL2FunctionNode.astErrorOutput (C:/ICAExpress/iConnectAccess/Python/blu-ring-viewer/node_modules/gpu.js/dist/gpu-browser.js:7893:1)   
            at WebGL2FunctionNode.getMemberExpressionDetails (C:/ICAExpress/iConnectAccess/Python/blu-ring-viewer/node_modules/gpu.js/dist/gpu-browser.js:8239:1)
            at WebGL2FunctionNode.astMemberExpression (C:/ICAExpress/iConnectAccess/Python/blu-ring-viewer/node_modules/gpu.js/dist/gpu-browser.js:12608:6)
            at WebGL2FunctionNode.astGeneric (C:/ICAExpress/iConnectAccess/Python/blu-ring-viewer/node_modules/gpu.js/dist/gpu-browser.js:7870:1)       
            at WebGL2FunctionNode.astUpdateExpression (C:/ICAExpress/iConnectAccess/Python/blu-ring-viewer/node_modules/gpu.js/dist/gpu-browser.js:8039:1)
            at WebGL2FunctionNode.astGeneric (C:/ICAExpress/iConnectAccess/Python/blu-ring-viewer/node_modules/gpu.js/dist/gpu-browser.js:7866:1)       
            at WebGL2FunctionNode.astExpressionStatement (C:/ICAExpress/iConnectAccess/Python/blu-ring-viewer/node_modules/gpu.js/dist/gpu-browser.js:7955:1)
            at WebGL2FunctionNode.astGeneric (C:/ICAExpress/iConnectAccess/Python/blu-ring-viewer/node_modules/gpu.js/dist/gpu-browser.js:7836:1)       
            at WebGL2FunctionNode.astFunction (C:/ICAExpress/iConnectAccess/Python/blu-ring-viewer/node_modules/gpu.js/dist/gpu-browser.js:11792:1)     
            at WebGL2FunctionNode.astFunctionExpression (C:/ICAExpress/iConnectAccess/Python/blu-ring-viewer/node_modules/gpu.js/dist/gpu-browser.js:7928:1)
Chrome 87.0.4280 (Windows 10.0.0): Executed 24 of 128 (8 FAILED) (0 secs / 0.043 secs)
Chrome 87.0.4280 (Windows 10.0.0) debugging GPU.js basic kernel function wrapped in GLFunctionService class encountered a declaration exception FAILED  
        Error: Unexpected expression on line 1, position 57:
         ov_o7z5aoq2b.s[78]
            at WebGL2FunctionNode.astErrorOutput (C:/ICAExpress/iConnectAccess/Python/blu-ring-viewer/node_modules/gpu.js/dist/gpu-browser.js:7893:1)   
            at WebGL2FunctionNode.getMemberExpressionDetails (C:/ICAExpress/iConnectAccess/Python/blu-ring-viewer/node_modules/gpu.js/dist/gpu-browser.js:8239:1)
            at WebGL2FunctionNode.astMemberExpression (C:/ICAExpress/iConnectAccess/Python/blu-ring-viewer/node_modules/gpu.js/dist/gpu-browser.js:12608:6)
            at WebGL2FunctionNode.astGeneric (C:/ICAExpress/iConnectAccess/Python/blu-ring-viewer/node_modules/gpu.js/dist/gpu-browser.js:7870:1)       
            at WebGL2FunctionNode.astUpdateExpression (C:/ICAExpress/iConnectAccess/Python/blu-ring-viewer/node_modules/gpu.js/dist/gpu-browser.js:8039:1)
            at WebGL2FunctionNode.astGeneric (C:/ICAExpress/iConnectAccess/Python/blu-ring-viewer/node_modules/gpu.js/dist/gpu-browser.js:7866:1)       
            at WebGL2FunctionNode.astExpressionStatement (C:/ICAExpress/iConnectAccess/Python/blu-ring-viewer/node_modules/gpu.js/dist/gpu-browser.js:7955:1)
            at WebGL2FunctionNode.astGeneric (C:/ICAExpress/iConnectAccess/Python/blu-ring-viewer/node_modules/gpu.js/dist/gpu-browser.js:7836:1)       
            at WebGL2FunctionNode.astFunction (C:/ICAExpress/iConnectAccess/Python/blu-ring-viewer/node_modules/gpu.js/dist/gpu-browser.js:11792:1)     
            at WebGL2FunctionNode.astFunctionExpression (C:/ICAExpress/iConnectAccess/Python/blu-ring-viewer/node_modules/gpu.js/dist/gpu-browser.js:792
@robertleeplummerjr
Copy link
Member

The problem is istanbul. Use v8 code coverage instead. I've ranted and ranted and am just dismissed to those devs as to how to easily solve this from their end.

@robertleeplummerjr
Copy link
Member

For continuity: gotwarlost/istanbul#922 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants