ComputeLibrary icon indicating copy to clipboard operation
ComputeLibrary copied to clipboard

Convolution Performance Issue

Open cyberfire opened this issue 9 years ago • 16 comments

Hi, guys I did a SINGLE Core performance comparison between Caffe with OpenBlas and ACL (17.05) on RK3399.
The results show ACL performance is much worse than Caffe under some convolution parameters.

A72 2G

ACL CAFFE RATIO REP INPUT(C/H/W) KERNEL(C/K/S/P) OUTPUT(C/H/W) 3156 2036 35.49 100 512/14/14 1000/1/1/0 1000/14/14 1248 856 31.41 100 16/56/56 64/3/1/1 64/56/56 652 436 33.13 100 64/56/56 64/1/1/0 64/56/56 428 172 59.81 100 256/28/28 32/1/1/0 32/28/28 444 208 53.15 100 192/28/28 64/1/1/0 64/28/28 600 288 52.00 100 256/28/28 64/1/1/0 64/28/28 560 296 47.14 100 192/28/28 96/1/1/0 96/28/28

A53 1.5G

ACL CAFFE RATIO REP INPUT(C/H/W) KERNEL(C/K/S/P) OUTPUT(C/H/W) 18292 5652 69.10 100 512/14/14 1000/1/1/0 1000/14/14 2232 2008 10.04 100 16/56/56 64/3/1/1 64/56/56 1424 988 30.62 100 64/56/56 64/1/1/0 64/56/56 1028 396 61.48 100 256/28/28 32/1/1/0 32/28/28 1000 560 44.00 100 192/28/28 64/1/1/0 64/28/28 1400 748 46.57 100 256/28/28 64/1/1/0 64/28/28 1232 828 32.79 100 192/28/28 96/1/1/0 96/28/28

The number under ACL/CAFFE is the time cost, in ms. REP is the repetition times of layer forwarding unsigned long start=get_cur_time(); for(int i=0;i<rep;i++) // FOR ACL: layer.run();
// FOR CAFFE: layer->Forward(blob_bottom_vec,blob_top_vec); unsigned long end=get_cur_time();

Are those results reasonable ?

Thanks,

Cyber

cyberfire avatar May 10 '17 03:05 cyberfire

Hello @cyberfire,

Looks like the kernels are small (1x1 convolutions) and with small stride(1). So, with our Convolution approach (im2col + GEMM) these shapes will actually decay to a GEMV operation which is not great. For such cases (1x1 convolution and small kernels) we are currently implementing a direct convolution approach which will hopefully provide better performance. Hope this helps.

GeorgeARM avatar May 10 '17 09:05 GeorgeARM

@cyberfire 16.0 has updated, you may test is with directConvolution when the kernel are 1x1 and 3x3

austingg avatar Jul 03 '17 09:07 austingg

@austingg Yes. I tested the direct convolution performance: it does help on some cases while becomes worse on the other cases.

Please see the table below CONV --- NON-DIRECT

ACL CAFFE RATIO REP INPUT(C/H/W) KERNEL(C/K/S/P) OUTPUT(C/H/W)
3027076 2183093 1.39 100 512/14/14 1000/1/1/0 1000/14/14
1355086 764951 1.77 100 16/56/56 64/3/1/1 64/56/56
701250 399853 1.75 100 64/56/56 64/1/1/0 64/56/56
372835 177643 2.10 100 256/28/28 32/1/1/0 32/28/28
443184 187062 2.37 100 192/28/28 64/1/1/0 64/28/28
560299 301355 1.86 100 256/28/28 64/1/1/0 64/28/28
598381 280527 2.13 100 192/28/28 96/1/1/0 96/28/28
ACL CAFFE RATIO REP INPUT(C/H/W) KERNEL(C/K/S/P) OUTPUT(C/H/W)
208024 19408 10.72 100 32/49/91 2/1/1/0 2/49/91
217889 22546 9.66 100 32/49/91 4/1/1/0 4/49/91
55464 9481 5.85 100 32/34/64 2/1/1/0 2/34/64
60839 10936 5.56 100 32/34/64 4/1/1/0 4/34/64
21960 4598 4.78 100 32/23/44 2/1/1/0 2/23/44
24218 5128 4.72 100 32/23/44 4/1/1/0 4/23/44
9873 2157 4.58 100 32/15/30 2/1/1/0 2/15/30
10853 2505 4.33 100 32/15/30 4/1/1/0 4/15/30
4011 941 4.26 100 32/ 9/20 2/1/1/0 2/ 9/20
4468 1116 4.00 100 32/ 9/20 4/1/1/0 4/ 9/20

CONV -- DIRECT

ACL CAFFE RATIO REP INPUT(C/H/W) KERNEL(C/K/S/P) OUTPUT(C/H/W)
9294862 2172196 4.28 100 512/14/14 1000/1/1/0 1000/14/14
982885 777518 1.26 100 16/56/56 64/3/1/1 64/56/56
979363 400213 2.45 100 64/56/56 64/1/1/0 64/56/56
456645 176172 2.59 100 256/28/28 32/1/1/0 32/28/28
681702 187145 3.64 100 192/28/28 64/1/1/0 64/28/28
924636 301827 3.06 100 256/28/28 64/1/1/0 64/28/28
1028264 281782 3.65 100 192/28/28 96/1/1/0 96/28/28
ACL CAFFE RATIO REP INPUT(C/H/W) KERNEL(C/K/S/P) OUTPUT(C/H/W)
24558 19570 1.25 100 32/49/91 2/1/1/0 2/49/91
48738 22701 2.15 100 32/49/91 4/1/1/0 4/49/91
10931 9664 1.13 100 32/34/64 2/1/1/0 2/34/64
22143 11046 2.00 100 32/34/64 4/1/1/0 4/34/64
5439 4615 1.18 100 32/23/44 2/1/1/0 2/23/44
10901 5140 2.12 100 32/23/44 4/1/1/0 4/23/44
2764 2169 1.27 100 32/15/30 2/1/1/0 2/15/30
5394 2473 2.18 100 32/15/30 4/1/1/0 4/15/30
1188 947 1.25 100 32/ 9/20 2/1/1/0 2/ 9/20
2339 1110 2.11 100 32/ 9/20 4/1/1/0 4/ 9/20

cyberfire avatar Jul 11 '17 02:07 cyberfire

Closing as this is too old. If there are still performance issues with the latest version of the library please create a new issue.

mpekatsoula avatar Sep 17 '18 13:09 mpekatsoula

Hi, Can you tell me how to test between caffe using openblas and ACL. In fact , I made a cblas_sgemm like openblas and I want to compare it's performance with ACL, How can I do?

knjwhn avatar Dec 17 '19 11:12 knjwhn

@knjwhn You could use CK-NNTest for that, which was specifically developed to compare the performance of ArmCL operators against alternative implementations (Caffe, TensorFlow).

psyhtest avatar Dec 17 '19 11:12 psyhtest

Thanks, and I wanna to compare my sgemm's performance with the sgemm in ArmCL, and I can't find the similar blas api in ArmCL, is the ArmCL use the gemm like ARM Performance Library? is there anyway to find the sgemm api in ArmCL , All I find is using sgemm.run() to call a sgemm.

@knjwhn You could use CK-NNTest for that, which was specifically developed to compare the performance of ArmCL operators against alternative implementations (Caffe, TensorFlow).

knjwhn avatar Dec 17 '19 11:12 knjwhn

@knjwhn That's how the gemm-armcl-opencl program from CK-NNTest does it: https://github.com/ctuning/ck-nntest/blob/master/program/gemm-armcl-opencl/gemm.cpp

psyhtest avatar Dec 17 '19 11:12 psyhtest

What's ARM Performance Library, by the way?

psyhtest avatar Dec 17 '19 11:12 psyhtest

Thanks, I will try it. ARM Performance Library is an optimized standard core math library for arm, and the infomation is on https://developer.arm.com/tools-and-software/server-and-hpc/compile/arm-compiler-for-linux/arm-performance-libraries

knjwhn avatar Dec 17 '19 11:12 knjwhn

Ah, right. I keep forgetting that Arm is an HPC company now :)

psyhtest avatar Dec 17 '19 12:12 psyhtest

Ah, right. I keep forgetting that Arm is an HPC company now :)

Sorry to bother you again , do you know the gemm implemention in ACL is same as the ARM Performance library? cause they are the same company in my thought.

knjwhn avatar Dec 18 '19 02:12 knjwhn

Yes, ARM (classic capitalization) and Arm (more recent capitalization) are the same company :). But I have no idea if the implementations are the same. They may different because they target different sectors (mobile vs HPC), or because they are done by different teams.

psyhtest avatar Dec 18 '19 08:12 psyhtest

Thanks a lot. I got it. and last question, where can I find the principle of the gemm implemention in ACL? like its it's method to achieve matrix multiplization. cause I didn't find in the introduction doc :).

knjwhn avatar Dec 18 '19 08:12 knjwhn

Surely you can get it from the (open) source code? :)

Note that implementations for the CPU and GPU are different (are there may be several variants of each now).

psyhtest avatar Dec 18 '19 08:12 psyhtest

Oh, Thanks. I will go for it :).

knjwhn avatar Dec 18 '19 09:12 knjwhn