-
Notifications
You must be signed in to change notification settings - Fork 0
/
omp_transfer_new.c
175 lines (146 loc) · 5.21 KB
/
omp_transfer_new.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#include "omp_transfer.h"
#ifdef __MIC__
#include <immintrin.h>
#endif
inline void transfer_omp_loop_reg(uintptr_t rbuf, uintptr_t sbuf, size_t size, HMPI_Request recv_req, HMPI_Request send_req){
int i = 0;
#pragma omp parallel
{
#pragma omp for
for (i = 0; i < size; i++) {
((char *) rbuf)[i] = ((char *) sbuf)[i];
}
}
}
inline void transfer_omp_loop_nontemp(uintptr_t rbuf, uintptr_t sbuf, size_t size, HMPI_Request recv_req, HMPI_Request send_req){
int N_DOUBLES_PER_BLOCK = (64/sizeof(char)) ;
size_t total = size / 64 ;
int i = 0;
//#pragma vector nontemporal
#pragma omp parallel for
for (i = 0; i < total; i++) {
__m512d v_b = _mm512_load_pd(sbuf+ N_DOUBLES_PER_BLOCK*i);
_mm512_storenrngo_pd(rbuf+ N_DOUBLES_PER_BLOCK*i, v_b);
}
}
void transfer_omp_loop(uintptr_t rbuf, uintptr_t sbuf, size_t size, HMPI_Request recv_req, HMPI_Request send_req){
//set number of threads dynamically
//load balance ploicy - depends on number of ranks
// OR speculative execution (running time/MPI time
omp_set_dynamic(0); // Explicitly disable dynamic teams
omp_set_num_threads(core_allocation_rank); // Use 4 threads for all consecutive parallel regions
#ifdef LB_POLICY_SPECULATIVE
//transfer by characters
#pragma omp parallel
{
#if HMPI_OMP_AFFINITY_AWARE == 1
// Work with teh set structure
cpu_set_t set;
CPU_ZERO(&set);
//bind allocated cores to threads
int k = 0 ;
for(k = core_allocation_start ; k < core_allocation_end ; k++)
CPU_SET(k, &set);
//actual binding/affinity setting take place here
pid_t tid = (pid_t) syscall(SYS_gettid);
sched_setaffinity(tid, sizeof(set), &set);
#endif
int i = 0;
#pragma omp for private(i)
for (i = 0; i < size; i++) {
((char *) rbuf)[i] = ((char *) sbuf)[i];
}
}
#else
#ifndef MIC_HMPI_OMP_NON_TEMPORAL
transfer_omp_loop_reg(rbuf, sbuf, size, recv_req, send_req);
#else
transfer_omp_loop_nontemp(rbuf, sbuf, size, recv_req, send_req);
#endif
#endif
}
/*
void transfer_omp_loop(uintptr_t rbuf, uintptr_t sbuf, size_t size, HMPI_Request recv_req, HMPI_Request send_req){
int N_DOUBLES_PER_BLOCK = (64/sizeof(char)) ;
size_t total = size / 64 ;
omp_set_dynamic(0); // Explicitly disable dynamic teams
omp_set_num_threads(120);
int i = 0;
#pragma omp parallel
{
// Work with teh set structure
cpu_set_t set;
CPU_ZERO(&set);
//bind allocated cores to threads
//int k = 0 ;
// for(k = core_allocation_start ; k < core_allocation_end ; k++)
// CPU_SET(k, &set);
//
CPU_SET(HMPI_COMM_WORLD->node_rank+1, &set);
//printf("comm rank : %d \n", HMPI_COMM_WORLD->node_rank);
//actual binding/affinity setting take place here
pid_t tid = (pid_t) syscall(SYS_gettid);
//sched_setaffinity(tid, sizeof(set), &set);
//sched_getaffinity(tid, sizeof(set), &set);
//int rank = 0;
//MPI_Comm_rank(MPI_COMM_WORLD, &rank);
//printf("Thread %d, tid %d, affinity %lu node_rank : %d \n", omp_get_thread_num(), tid, set, rank);
//#pragma vector nontemporal
#pragma omp for
for (i = 0; i < total; i++) {
__m512d v_b = _mm512_load_pd(sbuf+ N_DOUBLES_PER_BLOCK*i);
_mm512_storenrngo_pd(rbuf+ N_DOUBLES_PER_BLOCK*i, v_b);
}
}
}*/
/*
void transfer_omp_loop(uintptr_t rbuf, uintptr_t sbuf, size_t size, HMPI_Request recv_req, HMPI_Request send_req){
int N_DOUBLES_PER_BLOCK = (64/sizeof(char)) ;
size_t total = size / 64 ;
omp_set_dynamic(0); // Explicitly disable dynamic teams
omp_set_num_threads(120);
int i = 0;
//#pragma vector nontemporal
#pragma omp parallel for
for (i = 0; i < total; i++) {
__m512d v_b = _mm512_load_pd(sbuf+ N_DOUBLES_PER_BLOCK*i);
_mm512_storenrngo_pd(rbuf+ N_DOUBLES_PER_BLOCK*i, v_b);
}
}*/
/*
void transfer_omp_loop(uintptr_t rbuf, uintptr_t sbuf, size_t size, HMPI_Request recv_req, HMPI_Request send_req){
//set number of threads dynamically
//load balance ploicy - depends on number of ranks
// OR speculative execution (running time/MPI time
//omp_set_dynamic(0); // Explicitly disable dynamic teams
//omp_set_num_threads(core_allocation_rank); // Use 4 threads for all consecutive parallel regions
omp_set_num_threads(10); // Use 4 threads for all consecutive parallel regions
int i = 0 ;
#pragma vector nontemporal
#pragma simd
#pragma omp parallel for
for (i = 0; i < size; i++) {
((char *) rbuf)[i] = ((char *) sbuf)[i];
}
//transfer by characters
#pragma omp parallel
{
#if HMPI_OMP_AFFINITY_AWARE == 1
// Work with teh set structure
/cpu_set_t set;
CPU_ZERO(&set);
//bind allocated cores to threads
int k = 0 ;
for(k = core_allocation_start ; k < core_allocation_end ; k++)
CPU_SET(k, &set);
//actual binding/affinity setting take place here
pid_t tid = (pid_t) syscall(SYS_gettid);
sched_setaffinity(tid, sizeof(set), &set);
#endif
int i = 0;
#pragma omp for private(i)
for (i = 0; i < size; i++) {
((char *) rbuf)[i] = ((char *) sbuf)[i];
}
}
} */