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

Got error: array initializer must be an initializer list #153

Closed
inferrna opened this issue Oct 19, 2015 · 11 comments
Closed

Got error: array initializer must be an initializer list #153

inferrna opened this issue Oct 19, 2015 · 11 comments

Comments

@inferrna
Copy link

Got error using caffe OpenCL port BVLC/caffe#2610
Seems like clBLAS producing incorrect kernel.
Error message:

OpenCL error -11 on line 163 of /home/inferno/.dev/OpenCL/clBLAS/src/library/blas/xgemm.cc
clBuildProgram Failed
err = -11
Error: Failed to build program executable!

Build Log:

stringInput.cl:63:65: error: array initializer must be an initializer list`

Inside sgemm_Col_TN_B1_MX032_NX032_KX16_BRANCH_src kernel we see

float rC[2][2] = {(float)0};

Possible it caused because I tested it on data with input dimension 1x1 (trying to solve cosine problem) which is very non-standard fort most caffe and clBLAS using scenarios. Platforms tested - AMD and beignet (Intel® GPU)

@TimmyLiu
Copy link
Contributor

I cannot reproduce your error on my end (mostly because I did not build Caffe). One thing I am (pretty) sure is that with 1x1 matrix the above kernel won't be used. Anyway, can you give me a set of parameters to sgemm that causes this error?

@inferrna
Copy link
Author

I also got failed test RowMajor_SmallRange/GEMM.sgemm/0
https://gist.github.com/inferrna/230cf27802cfde04bf58
With same and other errors.

@TimmyLiu
Copy link
Contributor

Sounds like OpenCL compiler threw the errors. It is not test fail per se. But the compiler does not like the kernel generated. Is this an Intel graphic card?

@inferrna
Copy link
Author

Is this an Intel graphic card?

Yes, it is Beignet at Haswell i5-4200 GPU

@hughperkins
Copy link
Contributor

Same error, NVIDIA 940M

@hughperkins
Copy link
Contributor

Some of the errors I get:

OpenCL error -11 on line 163 of /home/user/git/DeepCL/clMathLibraries/clBLAS/src/library/blas/xgemm.cc
clBuildProgram Failed
err = -11
Error: Failed to build program executable!

Build Log:

<kernel>:63:65: error: array initializer must be an initializer list
  DATA_TYPE_STR rC[MICRO_TILE_NUM_ROWS][MICRO_TILE_NUM_COLS] = {0};
                                                                ^

OpenCL error -45 on line 187 of /home/user/git/DeepCL/clMathLibraries/clBLAS/src/library/blas/xgemm.cc
OpenCL error -48 on line 232 of /home/user/git/DeepCL/clMathLibraries/clBLAS/src/library/blas/xgemm.cc
OpenCL error -48 on line 232 of /home/user/git/DeepCL/clMathLibraries/clBLAS/src/library/blas/xgemm.cc
OpenCL error -48 on line 232 of /home/user/git/DeepCL/clMathLibraries/clBLAS/src/library/blas/xgemm.cc

@hughperkins
Copy link
Contributor

And the test code:

TEST(testClBlas, colMajorTransB) {
    EasyCL *cl = EasyCL::createForFirstGpuOtherwiseCpu();

    float A[] = {1, 3,
                 2, 7,
                 9, 5};
    float B[] = {3,
                 -1};

    float C[3];
    transpose(A, 3, 2);
    ClBlasInstance clblasInstance;
    CLWrapper *AWrap = cl->wrap(6, A);
    CLWrapper *BWrap = cl->wrap(2, B);
    CLWrapper *CWrap = cl->wrap(3, C);
    AWrap->copyToDevice();
    BWrap->copyToDevice();
    ClBlasHelper::Gemm(
        cl,
        clblasColumnMajor,
        clblasNoTrans, clblasTrans,
        3, 2, 1,
        1,
        AWrap, 0,
        BWrap, 0,
        0,
        CWrap, 0
    );
    CWrap->copyToHost();
    transpose(C, 1, 3);
    EXPECT_EQ(0, C[0]);
    EXPECT_EQ(-1, C[1]);
    EXPECT_EQ(22, C[2]);

    delete CWrap;
    delete BWrap;
    delete AWrap;

    delete cl;
}

@hughperkins
Copy link
Contributor

It's caused by line 213 of zgemm_gcn.cl:

  // registers
  DATA_TYPE_STR rC[MICRO_TILE_NUM_ROWS][MICRO_TILE_NUM_COLS]  = {0};

@hughperkins
Copy link
Contributor

Actually, I think it's in library/blas/AutoGemm, line 221:

    "  DATA_TYPE_STR rC[MICRO_TILE_NUM_ROWS][MICRO_TILE_NUM_COLS] = {0};" + endLine +

But changing this to:

    "  DATA_TYPE_STR rC[MICRO_TILE_NUM_ROWS][MICRO_TILE_NUM_COLS];" + endLine +

... I still get incorrect results, and some errors, eg:

[ RUN      ] testClBlas.colMajor
Using NVIDIA Corporation , OpenCL platform: NVIDIA CUDA
Using OpenCL device: GeForce 940M
initializing clblas
OpenCL error -38 on line 232 of /home/user/git/DeepCL/clMathLibraries/clBLAS/src/library/blas/xgemm.cc
OpenCL error -38 on line 232 of /home/user/git/DeepCL/clMathLibraries/clBLAS/src/library/blas/xgemm.cc
OpenCL error -38 on line 232 of /home/user/git/DeepCL/clMathLibraries/clBLAS/src/library/blas/xgemm.cc
OpenCL error -52 on line 239 of /home/user/git/DeepCL/clMathLibraries/clBLAS/src/library/blas/xgemm.cc
/home/user/git/DeepCL/test/testClBlas.cpp:215: Failure
Value of: C[0]
  Actual: 0.0320347
Expected: 0
/home/user/git/DeepCL/test/testClBlas.cpp:216: Failure
Value of: C[1]
  Actual: -0.0424018
Expected: -1
/home/user/git/DeepCL/test/testClBlas.cpp:217: Failure
Value of: C[2]
  Actual: -0.0419845
Expected: 22
clblas teardown
[  FAILED  ] testClBlas.colMajor (118 ms)

test case:

TEST(testClBlas, colMajor) {
    EasyCL *cl = EasyCL::createForFirstGpuOtherwiseCpu();

    float A[] = {1, 3,
                 2, 7,
                 9, 5};
    float B[] = {3,
                 -1};

    float C[3];
    transpose(A, 3, 2);
    transpose(B, 2, 1);
    ClBlasInstance clblasInstance;
    CLWrapper *AWrap = cl->wrap(6, A);
    CLWrapper *BWrap = cl->wrap(2, B);
    CLWrapper *CWrap = cl->wrap(3, C);
    AWrap->copyToDevice();
    BWrap->copyToDevice();
    ClBlasHelper::Gemm(
        cl,
        clblasColumnMajor,
        clblasNoTrans, clblasNoTrans,
        3, 2, 1,
        1,
        AWrap, 0,
        BWrap, 0,
        0,
        CWrap, 0
    );
    CWrap->copyToHost();
    transpose(C, 1, 3);
    EXPECT_EQ(0, C[0]);
    EXPECT_EQ(-1, C[1]);
    EXPECT_EQ(22, C[2]);

    delete CWrap;
    delete BWrap;
    delete AWrap;

    delete cl;
}

@hughperkins
Copy link
Contributor

Ah, changing KernelOpenCL.py like this gets rid of the incorrect results for some tests:

    "  DATA_TYPE_STR rC[MICRO_TILE_NUM_ROWS][MICRO_TILE_NUM_COLS] = { {0} };" + endLine +

Successful test results:

[ RUN      ] testClBlas.basic
Using NVIDIA Corporation , OpenCL platform: NVIDIA CUDA
Using OpenCL device: GeForce 940M
initializing clblas
clblas teardown
[       OK ] testClBlas.basic (418 ms)
[ RUN      ] testClBlas.transA
Using NVIDIA Corporation , OpenCL platform: NVIDIA CUDA
Using OpenCL device: GeForce 940M
1 2 9 
3 7 5 
initializing clblas
clblas teardown
[       OK ] testClBlas.transA (205 ms)
[ RUN      ] testClBlas.transB
Using NVIDIA Corporation , OpenCL platform: NVIDIA CUDA
Using OpenCL device: GeForce 940M
3 
-1 
initializing clblas
clblas teardown
[       OK ] testClBlas.transB (6017 ms)

Crashed test:

[ RUN      ] testClBlas.colMajor
Using NVIDIA Corporation , OpenCL platform: NVIDIA CUDA
Using OpenCL device: GeForce 940M
initializing clblas
OpenCL error -38 on line 232 of /home/user/git/DeepCL/clMathLibraries/clBLAS/src/library/blas/xgemm.cc
OpenCL error -38 on line 232 of /home/user/git/DeepCL/clMathLibraries/clBLAS/src/library/blas/xgemm.cc
OpenCL error -38 on line 232 of /home/user/git/DeepCL/clMathLibraries/clBLAS/src/library/blas/xgemm.cc
Segmentation fault

@hughperkins
Copy link
Contributor

(Note: for the remaining crashed tests, these are fixed in pull #163 These other crashes are for a different reason than this issue #153, it's because autogemm kernels are global, not per-context, and teardown doesnt reinitialize them to 0 either)

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

3 participants