Open ziggyJ opened 10 years ago
I removed -O3 flag in Android.mk file, and now it reports
F/libc ( 4776): ./src/lib/math/matrix_gemm.cpp:424: void cblas_sgemm_fixed(int, int, int, int, int, int, jpfloatt, void, jpfloat_t, jpfloat_t, int, int, jpfloatt, int, jpfloat_t, jpfloat_t*, int): assertion "(k % 8) == 0" failed F/libc ( 4776): Fatal signal 6 (SIGABRT) at 0x000012a8 (code=-6), thread 4776 (com.example.cam)
more logs, it seems k=363 that cause the crash.
I/stderr ( 9110): matrix_correlate[GEMM](input=[Buffer prepareInput_output - %281, 224, 224, 3%29, 32 bits per element, range %280.000000-1.000000%29], kernels=[Buffer None - %2896, 363%29, 16 bits per element, range %28-0.393412-0.419856%29], kernelWidth=11, kernelCount=96, stride=4) I/stderr ( 9110): patches_into_rows(input=[Buffer prepareInput_output - (1, 224, 224, 3), 32 bits per element, range (0.000000-1.000000)], kernelWidth=11, stride=4) I/stderr ( 9110): patches_into_rows() result=[Buffer None - (1, 3025, 363), 32 bits per element, range (0.000000-1.000000)]
I believe the cause is likely the NEON optimized code running past the end of the buffer on 'odd-sized' matrices. I've had luck on other platforms with Eigen's GEMM as an alternative, I will take a look at this again once I have an Android device handy, but you could try compiling with that instead.
Do you mean that I need to remove -DUSE_NEON flag? It seems that the current android build has already used Eigen's GEMM. I can see LOCAL_CFLAGS := -DUSE_EIGEN_GEMM -DUSE_NEON in Android.mk
From memory I believe so, but I don't have an Android dev environment handy to try it to be sure.
I remove -DUSE_NEON and it works! Just a bit slower (~20% I think) than enable NEON optimized code.
Thank you for the help.
I found the crash dump in the log. It seem crash occurs when it frees the matrix in the function cblas_sgemm_fixed.
I set libc.debug.malloc to 10 and it reported rear guard mismatch for 20bytes.
It seems some codes in cblas_sgemm_fixed function corrupt the allocated memory. The AndroidExample does not crash on Android 4.1 and 4.4 but I can still see Rear guard mismatch msg, so it means that the memory is still corrupted, but it is lucky that the app does not crash.
The following is the crash dump.