Skip to content

Commit 1dd22cc

Browse files
author
Your Name
committed
tidy
1 parent 6da5776 commit 1dd22cc

File tree

1 file changed

+3
-4
lines changed
  • content/learning-paths/servers-and-cloud-computing/cplusplus_compilers_flags

1 file changed

+3
-4
lines changed

content/learning-paths/servers-and-cloud-computing/cplusplus_compilers_flags/4.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,25 +141,24 @@ For a more manageable overview, you can enable basic optimization information (`
141141

142142
First, to see what part of our source code was optimised between levels 1 and 2 we can run the following commands to see if our vectorisable loop was indeed vectorised.
143143

144-
145144
```bash
146145
g++ -O1 vectorizable_loop.cpp -o level_1 -fopt-info-vec
147146
```
148147

149-
Running the `-O1` flag led showed no terminal output indicating no vectorisation was performed.
148+
Running the `-O1` flag led showed no terminal output indicating no vectorisation was performed. Next, run the command below with the `-O2` flag.
150149

151150
```bash
152151
g++ -O2 vectorizable_loop.cpp -o level_2 -fopt-info-vec
153152
```
154153

155-
Conversely, the `-O2` flag enables our loop to be vectorised as can be seen from the output below.
154+
This time the `-O2` flag enables our loop to be vectorised as can be seen from the output below.
156155

157156
```output
158157
vectorizable_loop.cpp:13:30: optimized: loop vectorized using 16 byte vectors
159158
/usr/include/c++/13/bits/stl_algobase.h:930:22: optimized: loop vectorized using 16 byte vectors
160159
```
161160

162-
Second, to see what optimisations were performed and missed between level 2 and level 3, we can direct the terminal output from all optimisations (`-fopt-info`) to a text file with the commands below.
161+
To see what optimisations were performed and missed between level 2 and level 3, we could direct the terminal output from all optimisations (`-fopt-info`) to a text file with the commands below.
163162

164163
```bash
165164
g++ -O2 vectorizable_loop.cpp -o level_2 -fopt-info 2>&1 | tee level2.txt

0 commit comments

Comments
 (0)