Skip to content

Commit

Permalink
add ivdep examp
Browse files Browse the repository at this point in the history
  • Loading branch information
archibate committed Dec 27, 2021
1 parent 2198ae5 commit 9c94455
Show file tree
Hide file tree
Showing 19 changed files with 32 additions and 6 deletions.
File renamed without changes.
6 changes: 6 additions & 0 deletions 04/5_loops/04_no_pointer_aliasing_ivdep/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
void func(float *a, float *b) {
#pragma GCC ivdep
for (int i = 0; i < 1024; i++) {
a[i] = b[i] + 1;
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include <cmath>

void func(float *__restrict a, float *__restrict b, float dt) {
for (int i = 0; i < 1024; i++) {
a[i] = a[i] + b[i] * (dt * dt);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include <cmath>

void func(float *__restrict a, float *__restrict b, float dt) {
float dt2 = dt * dt;
for (int i = 0; i < 1024; i++) {
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions 04/5_loops/07_loop_invariant_failed/.vim_localrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
" vim: ft=vim
nnoremap <silent> <F7> :wa<CR>:!make\|\|(echo -n .;read -n1)<CR><CR>
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include <cmath>

void func(float *__restrict a, float *__restrict b, float dt) {
for (int i = 0; i < 1024; i++) {
a[i] = a[i] + b[i] * dt * dt;
Expand Down
4 changes: 4 additions & 0 deletions 04/5_loops/07_loop_invariant_failed/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
set -e

gcc -fopenmp -O3 -fomit-frame-pointer -fverbose-asm -S main.cpp -o /tmp/main.S
vim /tmp/main.S
2 changes: 2 additions & 0 deletions 04/5_loops/08_loop_unrolling/.vim_localrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
" vim: ft=vim
nnoremap <silent> <F7> :wa<CR>:!make\|\|(echo -n .;read -n1)<CR><CR>
6 changes: 6 additions & 0 deletions 04/5_loops/08_loop_unrolling/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
void func(float *a) {
#pragma GCC unroll 4
for (int i = 0; i < 1024; i++) {
a[i] = 1;
}
}
8 changes: 8 additions & 0 deletions 04/5_loops/08_loop_unrolling/pseudo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
void func(float *a) {
for (int i = 0; i < 1024; i += 4) {
a[i + 0] = 1;
a[i + 1] = 1;
a[i + 2] = 1;
a[i + 3] = 1;
}
}
4 changes: 4 additions & 0 deletions 04/5_loops/08_loop_unrolling/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
set -e

gcc -fopenmp -O3 -fomit-frame-pointer -fverbose-asm -S main.cpp -o /tmp/main.S
vim /tmp/main.S
Binary file modified 04/slides.pptx
Binary file not shown.

0 comments on commit 9c94455

Please sign in to comment.