Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Documentation: Additional optimization levels for ARM/Linux #6548

Merged
merged 1 commit into from
Aug 2, 2016

Conversation

leemgs
Copy link

@leemgs leemgs commented Aug 1, 2016

This instruction is to enable -Oz or -Ofast optimization level of clang on ARM/Linux.
Below is file-size comparison result of major components among -O3, -Oz,
and -Ofast on ARM/Linux-based Raspberry Pi2 board (Ubuntu/ARM 14.04 32bit).

* Linux/ARM: Release Build + O3(default): stripped , commit: 561b64d (Jul-26-2016)

-rwxr-xr-x 1 leemgs leemgs 18,472 Jul 27 16:14 corerun
-rwxr-xr-x 1 leemgs leemgs 1,512,828 Jul 27 18:33 libclrjit.so
-rwxr-xr-x 1 leemgs leemgs 4,525,328 Jul 27 18:33 libcoreclr.so
-rwxr--r-- 1 leemgs leemgs 29,696 Jul 27 00:55 ./mscorlib.dll
-rwxr--r-- 1 leemgs leemgs 2,211,840 Jul 27 00:54 ./System.Private.CoreLib.dll
Total: 8,298,164 bytes

* Linux/ARM: Release Build + Ofast: stripped , commit: 561b64d (Jul-26-2016)

-rwxr-xr-x 1 leemgs leemgs 18,496 Jul 26 05:00 ./corerun
-rwxr-xr-x 1 leemgs leemgs 1,512,844 Jul 26 04:59 ./libclrjit.so
-rwxr-xr-x 1 leemgs leemgs 4,525,360 Jul 26 04:59 ./libcoreclr.so
-rwxr--r-- 1 leemgs leemgs 29,696 Jul 26 00:49 ./mscorlib.dll
-rwxr--r-- 1 leemgs leemgs 2,211,840 Jul 26 00:48 ./System.Private.CoreLib.dll
Total: 8,298,236 bytes

* Linux/ARM: Release Build + Oz: stripped , commit: 561b64d (Jul-26-2016)

-rwxr-xr-x 1 leemgs leemgs 14,400 Jul 29 05:02 ./corerun
-rwxr-xr-x 1 leemgs leemgs 1,181,160 Jul 29 04:40 ./libclrjit.so
-rwxr-xr-x 1 leemgs leemgs 3,407,200 Jul 29 04:40 ./libcoreclr.so
-rwxr--r-- 1 leemgs leemgs 29,696 Jul 29 00:49 ./mscorlib.dll
-rwxr--r-- 1 leemgs leemgs 2,211,840 Jul 29 00:48 ./System.Private.CoreLib.dll
Total: 6,844,296 bytes

Signed-off-by: Geunsik Lim geunsik.lim@samsung.com

@leemgs
Copy link
Author

leemgs commented Aug 1, 2016

@jkotas , Could you review and merge this PR?

@leemgs
Copy link
Author

leemgs commented Aug 1, 2016

\CC: @parjong , @watere , @lemmaa , @seanshpark , @myungjoo

|To Disable Optimization| /Od | -O0 (debug build)|
|To Minimize Size| /O1 | -Oz |
|To Maximize Speed| /O2 | -Ofast |
|To Support Full Optimization| /Ox | -O3 (release build) |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does "Full Optimization" mean? I would remove this.

O3 and Ofast are very much the same in Clang. Also, I believe that Ox is actually less optimization than O2 in Microsoft compilers.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does "Full Optimization" mean? I would remove this.

When I checked the Ox flag from MS Visual Studio 2015, I thought that the meaning of the "Full Optimization" means optimization considering both speed and size. At that time, I could not find the exact meaning at https://msdn.microsoft.com/en-us/library/k1ack8f1.aspx

I would remove this.

I made a mistake. At that time I did not change the configuration of VS2015 from Debug to Release. I will remove that.

O3 and Ofast are very much the same in Clang.
Also, I believe that Ox is actually less optimization than O2 in Microsoft compilers.

https://www.freebsd.org/cgi/man.cgi?query=clang
-Ofast: Enables all the optimizations from -O3 along with other aggressive optimizations that may violate strict compliance with language standards.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

http://stackoverflow.com/questions/15548023/clang-optimization-levels has good summary.

The extra optimizations in Ofast vs. O3 are mostly around floating point math that is pretty much non-existent in CoreCLR.

This instruction is to enable -Ofast or -Oz optimization level of clang on ARM/Linux.
Below is file-size comparison result of major components among -O3, -Ofast,
and -Oz on ARM/Linux-based Raspberry Pi2 board (Ubuntu/ARM 14.04 32bit).

* Linux/ARM: Release Build + O3(default): stripped , commit: 561b64d (Jul-26-2016)
------------------------------------------------------------------------------------------------------------------
-rwxr-xr-x 1 leemgs leemgs     18,472 Jul 27 16:14 corerun
-rwxr-xr-x 1 leemgs leemgs  1,512,828 Jul 27 18:33 libclrjit.so
-rwxr-xr-x 1 leemgs leemgs  4,525,328 Jul 27 18:33 libcoreclr.so
-rwxr--r-- 1 leemgs leemgs     29,696 Jul 27 00:55 ./mscorlib.dll
-rwxr--r-- 1 leemgs leemgs  2,211,840 Jul 27 00:54 ./System.Private.CoreLib.dll
Total:   8,298,164 bytes

* Linux/ARM: Release Build + Ofast: stripped , commit: 561b64d (Jul-26-2016)
-------------------------------------------------------------------------------------------------------------
-rwxr-xr-x 1 leemgs leemgs    18,496 Jul 26 05:00 ./corerun
-rwxr-xr-x 1 leemgs leemgs 1,512,844 Jul 26 04:59 ./libclrjit.so
-rwxr-xr-x 1 leemgs leemgs 4,525,360 Jul 26 04:59 ./libcoreclr.so
-rwxr--r-- 1 leemgs leemgs    29,696 Jul 26 00:49 ./mscorlib.dll
-rwxr--r-- 1 leemgs leemgs 2,211,840 Jul 26 00:48 ./System.Private.CoreLib.dll
Total:   8,298,236 bytes

* Linux/ARM: Release Build + Oz: stripped , commit: 561b64d (Jul-26-2016)
---------------------------------------------------------------------------------------------------------
-rwxr-xr-x 1 leemgs leemgs    14,400 Jul 29 05:02 ./corerun
-rwxr-xr-x 1 leemgs leemgs 1,181,160 Jul 29 04:40 ./libclrjit.so
-rwxr-xr-x 1 leemgs leemgs 3,407,200 Jul 29 04:40 ./libcoreclr.so
-rwxr--r-- 1 leemgs leemgs    29,696 Jul 29 00:49 ./mscorlib.dll
-rwxr--r-- 1 leemgs leemgs 2,211,840 Jul 29 00:48 ./System.Private.CoreLib.dll
Total:  6,844,296 bytes

Signed-off-by: Geunsik Lim <geunsik.lim@samsung.com>
@leemgs leemgs force-pushed the upstream-optimization-Oz-Ofast branch from 6d867a7 to f657d42 Compare August 2, 2016 01:30
This instruction is to enable additional optimization levels such as -Oz and -Ofast on ARM/Linux. The below table shows what we have to enable for the code optimization of the CoreCLR run-time either the size or speed on embedded devices.

| **Content** | **Build Mode** | **Clang/LLVM (Linux)** |
| --- | --- | --- |
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jkotas I re-submitted new PR after applying your comments. Could you review this PR?

@jkotas
Copy link
Member

jkotas commented Aug 2, 2016

Thanks!

@jkotas jkotas merged commit 22c9f9e into dotnet:master Aug 2, 2016
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
…oreclr#6548)

This instruction is to enable -Ofast or -Oz optimization level of clang on ARM/Linux.
Below is file-size comparison result of major components among -O3, -Ofast,
and -Oz on ARM/Linux-based Raspberry Pi2 board (Ubuntu/ARM 14.04 32bit).

* Linux/ARM: Release Build + O3(default): stripped , commit: dotnet/coreclr@561b64d (Jul-26-2016)
------------------------------------------------------------------------------------------------------------------
-rwxr-xr-x 1 leemgs leemgs     18,472 Jul 27 16:14 corerun
-rwxr-xr-x 1 leemgs leemgs  1,512,828 Jul 27 18:33 libclrjit.so
-rwxr-xr-x 1 leemgs leemgs  4,525,328 Jul 27 18:33 libcoreclr.so
-rwxr--r-- 1 leemgs leemgs     29,696 Jul 27 00:55 ./mscorlib.dll
-rwxr--r-- 1 leemgs leemgs  2,211,840 Jul 27 00:54 ./System.Private.CoreLib.dll
Total:   8,298,164 bytes

* Linux/ARM: Release Build + Ofast: stripped , commit: dotnet/coreclr@561b64d (Jul-26-2016)
-------------------------------------------------------------------------------------------------------------
-rwxr-xr-x 1 leemgs leemgs    18,496 Jul 26 05:00 ./corerun
-rwxr-xr-x 1 leemgs leemgs 1,512,844 Jul 26 04:59 ./libclrjit.so
-rwxr-xr-x 1 leemgs leemgs 4,525,360 Jul 26 04:59 ./libcoreclr.so
-rwxr--r-- 1 leemgs leemgs    29,696 Jul 26 00:49 ./mscorlib.dll
-rwxr--r-- 1 leemgs leemgs 2,211,840 Jul 26 00:48 ./System.Private.CoreLib.dll
Total:   8,298,236 bytes

* Linux/ARM: Release Build + Oz: stripped , commit: dotnet/coreclr@561b64d (Jul-26-2016)
---------------------------------------------------------------------------------------------------------
-rwxr-xr-x 1 leemgs leemgs    14,400 Jul 29 05:02 ./corerun
-rwxr-xr-x 1 leemgs leemgs 1,181,160 Jul 29 04:40 ./libclrjit.so
-rwxr-xr-x 1 leemgs leemgs 3,407,200 Jul 29 04:40 ./libcoreclr.so
-rwxr--r-- 1 leemgs leemgs    29,696 Jul 29 00:49 ./mscorlib.dll
-rwxr--r-- 1 leemgs leemgs 2,211,840 Jul 29 00:48 ./System.Private.CoreLib.dll
Total:  6,844,296 bytes

Signed-off-by: Geunsik Lim <geunsik.lim@samsung.com>

Commit migrated from dotnet/coreclr@22c9f9e
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants