Skip to content

Commit 2a7e08f

Browse files
bibikaroleksandr-pavlyk
authored andcommitted
out-of-place native FFT: move buffer alloc inside timing
1 parent e8016d9 commit 2a7e08f

9 files changed

Lines changed: 45 additions & 55 deletions

‎native/fft2_cdp-out-c.c‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,15 @@ int main() {
5959
mkl_free(re_vec);
6060
mkl_free(im_vec);
6161

62-
buf = (MKL_Complex16 *) mkl_malloc(N * sizeof(MKL_Complex16), 64);
63-
assert(buf);
64-
6562
warm_up_threads();
6663

6764
for(si=0; si < samps; time_tot=0, si++) {
6865

6966
t0 = moment_now();
7067

68+
buf = (MKL_Complex16 *) mkl_malloc(N * sizeof(MKL_Complex16), 64);
69+
assert(buf);
70+
7171
status = DftiCreateDescriptor(
7272
&hand,
7373
DFTI_DOUBLE,
@@ -115,16 +115,14 @@ int main() {
115115
status = DftiFreeDescriptor(&hand);
116116
assert(status == 0);
117117

118+
mkl_free(buf);
119+
118120
t1 = moment_now();
119121
time_tot += t1 - t0;
120122

121123
printf("%.5g\n", seconds_from_moment(time_tot));
122124
}
123125

124-
#include "print_buf.inc"
125-
126-
mkl_free(buf);
127-
128126
err = vslDeleteStream(&stream);
129127
assert(err == VSL_STATUS_OK);
130128

‎native/fft2_cdp-out-nc.c‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,16 @@ int main() {
6363
strides[1] = N2;
6464
strides[2] = 1;
6565

66-
buf = (MKL_Complex16 *) mkl_malloc(N * sizeof(MKL_Complex16), 64);
67-
assert(buf);
68-
6966
warm_up_threads();
7067

7168
for(si=0; si < samps; time_tot=0, si++) {
7269

7370
for(it = -1; it <reps; it++) {
7471
t0 = moment_now();
7572

73+
buf = (MKL_Complex16 *) mkl_malloc(N * sizeof(MKL_Complex16), 64);
74+
assert(buf);
75+
7676
status = DftiCreateDescriptor(
7777
&hand,
7878
DFTI_DOUBLE,
@@ -104,6 +104,8 @@ int main() {
104104
status = DftiFreeDescriptor(&hand);
105105
assert(status == 0);
106106

107+
mkl_free(buf);
108+
107109
t1 = moment_now();
108110

109111
if (it >= 0) time_tot += t1 - t0;
@@ -112,10 +114,6 @@ int main() {
112114
printf("%.5g\n", seconds_from_moment(time_tot));
113115
}
114116

115-
#include "print_buf.inc"
116-
117-
mkl_free(buf);
118-
119117
err = vslDeleteStream(&stream);
120118
assert(err == VSL_STATUS_OK);
121119

‎native/fft3_cdp-out-nc.c‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,6 @@ int main() {
5959
mkl_free(re_vec);
6060
mkl_free(im_vec);
6161

62-
buf = (MKL_Complex16 *) mkl_malloc(N * sizeof(MKL_Complex16), 64);
63-
assert(buf);
64-
6562
strides[0] = 0;
6663
strides[1] = N3 * N2;
6764
strides[2] = N3;
@@ -75,6 +72,9 @@ int main() {
7572

7673
t0 = moment_now();
7774

75+
buf = (MKL_Complex16 *) mkl_malloc(N * sizeof(MKL_Complex16), 64);
76+
assert(buf);
77+
7878
status = DftiCreateDescriptor(
7979
&hand,
8080
DFTI_DOUBLE,
@@ -105,17 +105,15 @@ int main() {
105105
status = DftiFreeDescriptor(&hand);
106106
assert(status == 0);
107107

108+
mkl_free(buf);
109+
108110
t1 = moment_now();
109111
if(it >= 0) time_tot += t1 - t0;
110112
}
111113

112114
printf("%.5g\n", seconds_from_moment(time_tot));
113115
}
114116

115-
#include "print_buf.inc"
116-
117-
mkl_free(buf);
118-
119117
err = vslDeleteStream(&stream);
120118
assert(err == VSL_STATUS_OK);
121119

‎native/fft_cdp-out-c.c‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ int main() {
5151
mkl_free(re_vec);
5252
mkl_free(im_vec);
5353

54-
buf = (MKL_Complex16 *) mkl_malloc(N * sizeof(MKL_Complex16), 64);
55-
assert(buf);
56-
5754
warm_up_threads();
5855

5956
for(si=0; si < samps; time_tot=0, si++) {
6057

6158
t0 = moment_now();
6259

60+
buf = (MKL_Complex16 *) mkl_malloc(N * sizeof(MKL_Complex16), 64);
61+
assert(buf);
62+
6363
status = DftiCreateDescriptor(
6464
&hand,
6565
DFTI_DOUBLE,
@@ -94,18 +94,17 @@ int main() {
9494
status = DftiFreeDescriptor(&hand);
9595
assert(status == 0);
9696

97+
mkl_free(buf);
98+
9799
t1 = moment_now();
98100
time_tot += t1 - t0;
99101

100102
printf("%.5g\n", seconds_from_moment(time_tot));
101103
}
102104

103-
#include "print_buf.inc"
104-
105105
err = vslDeleteStream(&stream);
106106
assert(err == VSL_STATUS_OK);
107107

108-
mkl_free(buf);
109108
mkl_free(x);
110109

111110
return 0;

‎native/fft_cdp-out-nc.c‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@ int main() {
5151
mkl_free(re_vec);
5252
mkl_free(im_vec);
5353

54-
buf = (MKL_Complex16 *) mkl_malloc(N * sizeof(MKL_Complex16), 64);
55-
assert(buf);
56-
5754
warm_up_threads();
5855

5956
for(si=0; si < samps; time_tot=0, si++) {
@@ -62,6 +59,9 @@ int main() {
6259

6360
t0 = moment_now();
6461

62+
buf = (MKL_Complex16 *) mkl_malloc(N * sizeof(MKL_Complex16), 64);
63+
assert(buf);
64+
6565
status = DftiCreateDescriptor(
6666
&hand,
6767
DFTI_DOUBLE,
@@ -82,19 +82,18 @@ int main() {
8282
status = DftiFreeDescriptor(&hand);
8383
assert(status == 0);
8484

85+
mkl_free(buf);
86+
8587
t1 = moment_now();
8688
if (it >= 0) time_tot += t1 - t0;
8789
}
8890

8991
printf("%.5g\n", seconds_from_moment(time_tot));
9092
}
9193

92-
#include "print_buf.inc"
93-
9494
err = vslDeleteStream(&stream);
9595
assert(err == VSL_STATUS_OK);
9696

97-
mkl_free(buf);
9897
mkl_free(x);
9998

10099
return 0;

‎native/fft_rdp-out-c.c‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ int main() {
3535
err = vdRngGaussian(VSL_RNG_METHOD_GAUSSIAN_ICDF, stream, N, x, d_zero, d_one);
3636
assert(err == VSL_STATUS_OK);
3737

38-
buf = (MKL_Complex16 *) mkl_malloc(N * sizeof(MKL_Complex16), 64);
39-
assert(buf);
40-
4138
warm_up_threads();
4239

4340
for(si = 0; si < samps; time_tot=0, si++) {
4441
t0 = moment_now();
4542

43+
buf = (MKL_Complex16 *) mkl_malloc(N * sizeof(MKL_Complex16), 64);
44+
assert(buf);
45+
4646
status = DftiCreateDescriptor(
4747
&hand,
4848
DFTI_DOUBLE,
@@ -89,6 +89,8 @@ int main() {
8989
status = DftiFreeDescriptor(&hand);
9090
assert(status == 0);
9191

92+
mkl_free(buf);
93+
9294
t1 = moment_now();
9395
time_tot += t1 - t0;
9496

@@ -100,7 +102,6 @@ int main() {
100102
err = vslDeleteStream(&stream);
101103
assert(err == VSL_STATUS_OK);
102104

103-
mkl_free(buf);
104105
mkl_free(x);
105106

106107
return 0;

‎native/fft_rdp-out-nc.c‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ int main() {
2929
err = vslNewStream(&stream, VSL_BRNG_MT19937, SEED);
3030
assert(err == VSL_STATUS_OK);
3131

32-
x = (double *) mkl_malloc(N * sizeof(double), 64);
33-
assert(x);
34-
3532
err = vdRngGaussian(VSL_RNG_METHOD_GAUSSIAN_ICDF, stream, N, x, d_zero, d_one);
3633
assert(err == VSL_STATUS_OK);
3734

@@ -46,6 +43,9 @@ int main() {
4643

4744
t0 = moment_now();
4845

46+
x = (double *) mkl_malloc(N * sizeof(double), 64);
47+
assert(x);
48+
4949
status = DftiCreateDescriptor(
5050
&hand,
5151
DFTI_DOUBLE,
@@ -77,6 +77,8 @@ int main() {
7777
status = DftiFreeDescriptor(&hand);
7878
assert(status == 0);
7979

80+
mkl_free(buf);
81+
8082
t1 = moment_now();
8183

8284
if (it >= 0) time_tot += t1 - t0;
@@ -85,12 +87,9 @@ int main() {
8587
printf("%.5g\n", seconds_from_moment(time_tot));
8688
}
8789

88-
#include "print_buf.inc"
89-
9090
err = vslDeleteStream(&stream);
9191
assert(err == VSL_STATUS_OK);
9292

93-
mkl_free(buf);
9493
mkl_free(x);
9594

9695
return 0;

‎native/fft_rdp2-out-c.c‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ int main() {
3535
y = (double *) mkl_malloc(N * sizeof(double), 64);
3636
assert(y);
3737

38-
buf = (MKL_Complex16 *) mkl_malloc(N * sizeof(MKL_Complex16), 64);
39-
assert(buf);
40-
4138
err = vdRngGaussian(VSL_RNG_METHOD_GAUSSIAN_ICDF, stream, N, x, d_zero, d_one);
4239
assert(err == VSL_STATUS_OK);
4340

@@ -47,6 +44,9 @@ int main() {
4744

4845
t0 = moment_now();
4946

47+
buf = (MKL_Complex16 *) mkl_malloc(N * sizeof(MKL_Complex16), 64);
48+
assert(buf);
49+
5050
status = DftiCreateDescriptor(
5151
&hand,
5252
DFTI_DOUBLE,
@@ -105,18 +105,17 @@ int main() {
105105
status = DftiFreeDescriptor(&hand);
106106
assert(status == 0);
107107

108+
mkl_free(buf);
109+
108110
t1 = moment_now();
109111
time_tot += t1 - t0;
110112

111113
printf("%.5g\n", seconds_from_moment(time_tot));
112114
}
113115

114-
#include "print_buf.inc"
115-
116116
err = vslDeleteStream(&stream);
117117
assert(err == VSL_STATUS_OK);
118118

119-
mkl_free(buf);
120119
mkl_free(y);
121120
mkl_free(x);
122121

‎native/rfft_rdp-out-c.c‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ int main() {
3535
err = vdRngGaussian(VSL_RNG_METHOD_GAUSSIAN_ICDF, stream, N, x, d_zero, d_one);
3636
assert(err == VSL_STATUS_OK);
3737

38-
buf = (MKL_Complex16 *) mkl_malloc(N * sizeof(MKL_Complex16), 64);
39-
assert(buf);
40-
4138
warm_up_threads();
4239

4340
for(si = 0; si < samps; time_tot=0, si++) {
4441
t0 = moment_now();
4542

43+
buf = (MKL_Complex16 *) mkl_malloc(N * sizeof(MKL_Complex16), 64);
44+
assert(buf);
45+
4646
status = DftiCreateDescriptor(
4747
&hand,
4848
DFTI_DOUBLE,
@@ -81,18 +81,17 @@ int main() {
8181
status = DftiFreeDescriptor(&hand);
8282
assert(status == 0);
8383

84+
mkl_free(buf);
85+
8486
t1 = moment_now();
8587
time_tot += t1 - t0;
8688

8789
printf("%.5g\n", seconds_from_moment(time_tot));
8890
}
8991

90-
#include "print_buf.inc"
91-
9292
err = vslDeleteStream(&stream);
9393
assert(err == VSL_STATUS_OK);
9494

95-
mkl_free(buf);
9695
mkl_free(x);
9796

9897
return 0;

0 commit comments

Comments
 (0)