ComputeLibrary icon indicating copy to clipboard operation
ComputeLibrary copied to clipboard

Perfomance difference winograd convolution on OpenCL versus NEON

Open Rares14324 opened this issue 7 years ago • 9 comments

Output of 'strings libarm_compute.so | grep arm_compute_version': arm_compute_version=v18.11 Build options: {'embed_kernels': '1', 'onpencl': '1', 'arch': 'arm64-v8a', 'neon': '1', 'validation_tests': '1', 'build': 'cross_compile', 'debug': '0', 'os': 'android', 'Werror': '0'} Git hash=3d2d44ef55ab6b08afda8be48301ce3c55c7bc67 Platform: arm64-v8a Operating System: Android

Problem description: I have implemented a partial convolution network which requires dilation and padding using the CLConvolutionLayer respectively NEConvolutionLayer classes. While running part of it for benchmarking purposes on Android I saw that the OpenCL version was aproximately 2 time slower than its Neon counterpart. Upon investigation I saw that for my network (because I gave paddings and dilation of sizes > 1) the winograd implementation is used when calling configure(...) method. My kernel is 3x3 in size. I tried to investigate by running the validations and see how they perform so that I can figure out what I did wrong but upon running them I saw the same thing, namely that OpenCL convolution with winograd take more that their Neon counterpart. I've attached the logs of that test results-conv3x3.log

My question would be is that normal ? (I expected at least similar execution times if not smaller for the OpenCL part). If that is indeed normal what can I do to improve the execution time on the CL version ?

Thank-you

Rares14324 avatar Feb 21 '19 12:02 Rares14324

Hi @Rares14324,

from your log file it seems you are running on Qualcomm GPU. Regarding the performance, although OpenCL is portable in terms of different platforms, unfortunately it might be not portable in terms of performance. Since the OpenCL kernels have been optimized for Mali-GPUs, it might slower on Qualcomm ones and than slower of the NEON functions.

Hope this can help,

gmiodice avatar Feb 21 '19 13:02 gmiodice

Thank-you for your response, however I have also tested with an S7 which has a mali gpu and the result was similar (in that OpenCL performs significantly worse than Neon). Sadly this log I have from development branch but if it is relevant I can upload one from 18.11 (I tested using this first on S7 so it was quickly at hand) s7_results_winograd.txt

Rares14324 avatar Feb 21 '19 13:02 Rares14324

Hi @Rares14324 , I noticed you are running the validation tests(/data/local/tmp/arm_compute_validation).

Could you try a real network example and see if this changes anything?

Thanks

giuseros avatar Feb 21 '19 13:02 giuseros

I did try running a custom network which makes use of this convolution. The results were the same (in that OpenCL ~ 2 times slower than Neon counterpart). I've chosen to run the validation (twice because I tuned the OpenCL kernels) because I thought it would be more easy for you to possibly look into internally. I can upload my network here if you believe to be insightful, though it might take a while to simply it and take out relevant code. Would you like me to do so ?

Rares14324 avatar Feb 21 '19 13:02 Rares14324

Hi @Rares14324 , I don't think it is necessary. Could you just give me the command you use to run the validation?

Best, Manuel

ManubARM avatar Feb 21 '19 13:02 ManubARM

Hi @ManubARM , the command line is:

adb shell /data/local/tmp/arm_compute_validation --enable-tuner --iterations=20 --json-file=/data/local/tmp/results-validation-winograd.json --threads=8 --tuner-file=/data/local/tmp/tuner-file-winograd.csv --filter="Conv3x3" --mode=PRECOMMIT --log-file=data/local/tmp/results-conv3x3.log  /data/local/tmp/data/data/
Seed = 2169728753

I basically followed the documentation copying the executable inside /data/local/tmp/ on my device. Thank-you for your effort and help.

Rares14324 avatar Feb 21 '19 14:02 Rares14324

Unfortunately it does seem that the S7 uses the old Midgard GPU architecture, and ACL is optimized for the newer one: Bifrost. So, if you can, check with a device that uses a G71, G72 or G76. In there you'll see the performance difference. If your device of reference is an S7 and performance is your main goal, you should consider a NEON implementation instead of an OpenCL one.

Also "arm_compute_validation" can be useful to get an insight of performance, but it is much better to use "arm_compute_benchmark" . One of the reasons is that "arm_compute_validation" consider also the time to compute the reference.

But it you check "arm_compute_benchmark" you will see "AlexNetWinogradLayer", "GoogLeNetInceptionV1WinogradLayer", etc.. These tests will just run a Winograd with the most common shapes of that particular network.

So here a couple of command examples considering AlexNet: ./arm_compute_benchmark --iterations=20 --threads=8 --filter="NEON/AlexNetWinogradLayer" ./arm_compute_benchmark --iterations=20 --threads=8 --filter="CL/AlexNetWinogradLayer"

Let us know, Manuel

ManubARM avatar Feb 21 '19 15:02 ManubARM

I borrowed a S8 device from my colleague and had it run the tests. Did them also with the S7. I found that on both devices, after tuning, the CL versions ran faster than NEON. This is in contrast with my findings on my custom network. I will need to profile deeper inside my network and see if I have missed anything, but you have given me a good direction to go from. Once I find the component which runs slower on OpenCL I can add it to the benchmark like you do with AlexNetWinogradLayer and have a reproducible and isolated example. It's going to take some time though to write it and come back with some results though. results-s7.log results-s8.log

Thank-you for your help.

Rares14324 avatar Feb 23 '19 07:02 Rares14324

Thank you @Rares14324 for posting your logs Closing this issue

ManubARM avatar Feb 25 '19 11:02 ManubARM