ComputeLibrary icon indicating copy to clipboard operation
ComputeLibrary copied to clipboard

Datatype QASMM8 is taking more time than F32 in ACL 19.05

Open krgor opened this issue 7 years ago • 4 comments

Output of 'strings libarm_compute.so | grep arm_compute_version': arm_compute_version=v19.05 Build options: {'embed_kernels': '1', 'gles_compute': '1', 'logging': '1', 'arch': 'arm64-v8a', 'opencl': '1', 'neon': '1', 'asserts': '1', 'debug': '0', 'os': 'android', 'Werror': '1'} Git hash=4ba87dbdc3b22220eba4a792c1f5c87e7a88c7af

Platform:

Operating System: Android 8.1

I am trying to move my graph to QASSM8 datatype from F32 and assuming that it should be faster with slight impact on accuracy. Contrary to this QASSM8 is taking more time than F32.

I have also tried with the example graph_mobilenet_v2 provided with ACL. I have calculated elapsed time for one run() and below are the results.

./graph_mobilenet_v2 --layout=NCHW --model-id=0 --type=F32 --target=CL --tuner-file=/data/cnn/tuner.file --enable-tuner --tuner-mode=Exhaustive 64 ms

./graph_mobilenet_v2 --layout=NCHW --model-id=0 --type=QASYMM8 --target=CL --tuner-file=/data/cnn/tuner.file --enable-tuner --tuner-mode=Exhaustive 120ms

Note I have excluded the time for setup and initial 5 runs. I will execute run() for 100 times and then taking an average. Below is my modified do_run() function of graph_mobilenet_v2: void do_run() override { struct timespec start, stop, start1;

	graph.run();
	graph.run();
	graph.run();
	graph.run();
	graph.run();

	clock_gettime(CLOCK_MONOTONIC, &start1);
	for(int i=0; i < 100; i++) {
		graph.run();
        }
	clock_gettime(CLOCK_MONOTONIC, &stop);

	std::cout << "run time for 100 iteration: " << (stop.tv_sec - start1.tv_sec) * 1e3 + (stop.tv_nsec - start1.tv_nsec) / 1e6 << " ms\n" << std::endl;
}

Questions

  1. Why QASSYM8 is taking more time than F32? Is this expected? Am I missing something?

Let me know if you want more details.

krgor avatar Jun 30 '19 08:06 krgor

Hi @krgor,

thanks for using ACL! :)

I had a look at the command used and I noticed the data layout passed to the example is not the recommended one. Rather than using NCHW, can you try to use NHWC? Also, could you tell us what GPU are you running on? For Mali-G71 and Mali-G76, I would expect better performance for QASYMM8 since we can use a dedicated instruction for this computation. In case of other GPUs, this instruction may not be available so the uplift could be significant reduced or/and similar to F32. The reason behind this reduced uplift is behind the GEMMLowp implementation would require to store the partial accumulations on int32 variables.

If you are profiling ACL, I can also suggest to have a look at our latest webinar on performance analysis. Below you can find the link:

https://pages.arm.com/webinar-performance-analysis-for-embedded-deep-learning-recording.html?_ga=2.201001129.646105822.1561922123-1818525636.1557823069

The webinar presents also the experimental benchmark test suite for ACL on the Linaro repo which can be used to better profile your networks. Hope this can help. Don not hesitate to write if you require any further information or you have feedback for our experimental benchmark test suite.

Thanks, Gian Marco

gmiodice avatar Jun 30 '19 19:06 gmiodice

@gmiodice ,

Thanks for you suggestions.

The Board has Mali-T860 MP4 GPU.

Below are the results with various combinations of data type and layout.

./graph_mobilenet_v2 --layout=NCHW --model-id=0 --type=F32 --target=CL --tuner-file=/data/cnn/tuner.file --enable-tuner --tuner-mode=Exhaustive 64 ms

./graph_mobilenet_v2 --layout=NCHW --model-id=0 --type=QASYMM8 --target=CL --tuner-file=/data/cnn/tuner.file --enable-tuner --tuner-mode=Exhaustive 120ms

./graph_mobilenet_v2 --layout=NHWC --model-id=0 --type=F32 --target=CL --tuner-file=/data/cnn/tuner.file --enable-tuner --tuner-mode=Exhaustive 57ms

./graph_mobilenet_v2 --layout=NHWC --model-id=0 --type=QASYMM8 --target=CL --tuner-file=/data/cnn/tuner.file --enable-tuner --tuner-mode=Exhaustive 97ms

NHWC seems to be better than NCHW but QASYMM8 is worse than F32. My understanding is that using QASYMM8 may take similar time compared to F32 if some of the operations are not supported by GPU but in any case it should not be taking more time than F32. Am I missing something?

Thanks for sharing webinar link. I will go through it and let you know if I will any more doubts.

krgor avatar Jul 03 '19 17:07 krgor

@gmiodice ,

I have gone through the seminar and as instructed, I have tried with benchmarking examples. Below is the output which explains my concern. This clearly shows that qasymm8 has very bad performance than f32.

QASYMM8 data-type

Version = arm_compute_version=v0.0-unreleased Build options: {'embed_kernels': '1', 'arch': 'arm64-v8a', 'opencl': '1', 'neon': '1', 'examples': '1', 'debug': '0', 'os': 'android', 'Werror': '0'} Git hash=d5462ff012b3398addb1140d5c52c65ea16a27a5 CommandLine = ./benchmark_graph_mobilenet --example_args=--target=cl,--type=qasymm8,--enable-tuner,--tuner-mode=Exhaustive,--tuner-file=/data/cnn/benchmark_tuner.file --iterations=10 CL_DEVICE_VERSION = OpenCL 1.2 v1.r18p0-01rel0.022056fe7b169c7e0d8547fe2747032d Iterations = 10 Running [0] 'Examples/benchmark_graph_mobilenet' Threads : 1 Target : CL Data type : QASYMM8 Data layout : NHWC Tuner enabled? : true Tuner mode : Exhaustive Tuner file : /data/cnn/benchmark_tuner.file Fast math enabled? : false

Wall clock/Wall clock time: AVG=142448.4444 us, STDDEV=1.83 %, MIN=139293.0000 us, MAX=145891.0000 us, MEDIAN=141632.0000 us Executed 1 test(s) (1 passed, 0 expected failures, 0 failed, 0 crashed, 0 disabled) in 10 second(s)

F32 data-type

Version = arm_compute_version=v0.0-unreleased Build options: {'embed_kernels': '1', 'arch': 'arm64-v8a', 'opencl': '1', 'neon': '1', 'examples': '1', 'debug': '0', 'os': 'android', 'Werror': '0'} Git hash=d5462ff012b3398addb1140d5c52c65ea16a27a5 CommandLine = ./benchmark_graph_mobilenet --example_args=--target=cl,--enable-tuner,--tuner-mode=Exhaustive,--tuner-file=/data/cnn/benchmark_tuner.file --iterations=10 CL_DEVICE_VERSION = OpenCL 1.2 v1.r18p0-01rel0.022056fe7b169c7e0d8547fe2747032d Iterations = 10 Running [0] 'Examples/benchmark_graph_mobilenet' Threads : 1 Target : CL Data type : F32 Data layout : NHWC Tuner enabled? : true Tuner mode : Exhaustive Tuner file : /data/cnn/benchmark_tuner.file Fast math enabled? : false

Wall clock/Wall clock time: AVG=71083.0000 us, STDDEV=3.88 %, MIN=65563.0000 us, MAX=74186.0000 us, MEDIAN=70181.0000 us Executed 1 test(s) (1 passed, 0 expected failures, 0 failed, 0 crashed, 0 disabled) in 5 second(s)

krgor avatar Jul 06 '19 15:07 krgor

Hi @krgor

This is expected because the GPU you are running the network has no support for the dot8 instruction. This instruction is present in mali-g71, mali-g76 and mali-g77.

https://developer.arm.com/ip-products/graphics-and-multimedia/mali-gpus/mali-t860-and-mali-t880-gpus https://www.arm.com/products/silicon-ip-multimedia/gpu/mali-g76

morgolock avatar Feb 14 '20 15:02 morgolock