-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgwtables.c
More file actions
6178 lines (5059 loc) · 219 KB
/
gwtables.c
File metadata and controls
6178 lines (5059 loc) · 219 KB
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*----------------------------------------------------------------------
| gwtables.c
|
| This file contains the C routines to build sin/cos and weights tables
| that the FFT assembly code needs.
|
| Copyright 2002-2018 Mersenne Research, Inc. All rights reserved.
+---------------------------------------------------------------------*/
/* Include files */
#include <stdlib.h>
#include <math.h>
#include <memory.h>
#include "gwnum.h"
#include "gwtables.h"
#include "gwdbldbl.h"
#define USE_WPN4
#define USE_REDUCED_SINCOS_FFTS
#define round_to_cache_line(p) (void *) (((intptr_t)(p) + 63) & ~63)
#define bitset(a,i) { ((char *)a)[(i) >> 3] |= (1 << ((i) & 7)); }
/* Find the power of two greater than or equal to N. */
unsigned long pow_two_above_or_equal (
unsigned long n)
{
unsigned long result;
result = 1;
for (n = n - 1; n; n = n >> 1) result = result << 1;
return (result);
}
/*************************************************************/
/* AVX-512 FFT tables */
/*************************************************************/
/* Helper routine for two pass AVX-512 build routines */
static __inline int zr4dwpn_delay_count (gwhandle *gwdata)
{
/* Determine number of delay groups. In a standard radix-8 FFT, there is only one sin/cos */
/* group in the last pass 1 level. We reduce our memory usage by using a fixed sin/cos */
/* table in the first FFT levels and having multiple groups of sin/cos data in the last pass 1 level. */
/* I call these groups of sin/cos data in the last pass 1 level "delay groups". */
// if (gwdata->PASS1_SIZE == 80) return (5); // BUG - delay count of 5 is not working yet and may never work
if (gwdata->PASS1_SIZE == 192 || gwdata->PASS1_SIZE == 960 || gwdata->PASS1_SIZE == 1152 || gwdata->PASS1_SIZE == 1344 ||
gwdata->PASS1_SIZE == 1920 || gwdata->PASS1_SIZE == 2304 || gwdata->PASS1_SIZE == 3072) return (12); // BUG Could do 1536 this way instead -- will use less memory
return (8); // BUG: applies to pass1 size = 128, 640, 768, 896, 1024, 1280, 1536, 2048
}
/* This routine builds the sin/cos table used in pass 1 by the radix-8 DJB */
/* FFT with delayed sin/cos multiplies and with partial normalization. */
double *zr4dwpn_build_pass1_table (
gwhandle *gwdata, /* Handle initialized by gwsetup */
double *table) /* Pointer to the table to fill in */
{
struct gwasm_data *asm_data = (struct gwasm_data *) gwdata->asm_data;
unsigned long pass1_size, pass1_increment, delay_count;
unsigned long group, i, j, k, N, temp, upper_avx512_word;
/* Special code to initialize one-pass FFTs */
if (gwdata->PASS1_SIZE == 0) {
/* Output the 8 column multipliers and 8 inverse column multipliers used in real pass 1 wrapper routines. */
/* Unlike two-pass FFTs, the 1/FFTLEN correction is applied in the inverse group multiplier rather than the */
/* inverse column multiplier. This lets us save one clock in the unfft wrapper. */
if (!gwdata->ALL_COMPLEX_FFT) {
double *weights, *inverse_weights;
weights = table;
inverse_weights = weights + 8;
table = inverse_weights + 8;
for (i = 0; i < 8; i++) {
gwfft_weights3 (gwdata->dd_data, i, weights, inverse_weights, NULL);
weights++;
inverse_weights++;
}
}
/* For the all complex pass 1 FFT wrapper, we combine the premultiplier sine with the column weight to save a few clocks. */
/* In the all complex pass 1 unFFT wrapper, we must multiply the precomputed premultiplier sine * weight by 1/weight^2 to get */
/* the premultiplier sine * inverse column weight. */
/* Compute the roots-of-minus-one premultipliers. The root-of-minus-one premultiplier is for 2N, and a root-of-minus-one-of-2N is */
/* the same as a root unity for 4N. We output the cosine/sine value and the sine value premultiplied by the column weight. */
else {
double *inverse_weights, colweights[128];
/* Generate the 8 inverse column weights (squared) */
inverse_weights = table;
table = inverse_weights + 8;
for (i = 0; i < 8; i++) *inverse_weights++ = gwfft_weight_inverse_squared (gwdata->dd_data, i);
/* Generate the 8 column weights in a scratch area */
gwfft_colweights (gwdata->dd_data, &colweights, 8);
/* Generate the complex premultipliers times the column weights */
N = gwdata->FFTLEN / 2; /* Number of complex values */
upper_avx512_word = 8;
for (j = 0; j < gwdata->FFTLEN / 2; j += 8 * upper_avx512_word) {
gwsincos1plus01234567by8_colweighted (j, 1, N * 4, &colweights, table);
gwsincos1plus01234567by8_colweighted (j + upper_avx512_word, 1, N * 4, &colweights, table + 1);
gwsincos1plus01234567by8_colweighted (j + 2 * upper_avx512_word, 1, N * 4, &colweights, table + 2);
gwsincos1plus01234567by8_colweighted (j + 3 * upper_avx512_word, 1, N * 4, &colweights, table + 3);
gwsincos1plus01234567by8_colweighted (j + 4 * upper_avx512_word, 1, N * 4, &colweights, table + 4);
gwsincos1plus01234567by8_colweighted (j + 5 * upper_avx512_word, 1, N * 4, &colweights, table + 5);
gwsincos1plus01234567by8_colweighted (j + 6 * upper_avx512_word, 1, N * 4, &colweights, table + 6);
gwsincos1plus01234567by8_colweighted (j + 7 * upper_avx512_word, 1, N * 4, &colweights, table + 7);
table += 128;
}
}
/* Reserve space for the group multiplier fudge flags. There are FFTLEN fudge flags which takes FFTLEN / 8 bytes. */
/* One pass FFTs do not compress the fudge flags and one-eighth of the fudge flags are known to be zero and not output. */
/* For zero-padded FFTs, the fudge flags could be half the size, but we have not implemented that. */
table = (double *) ((char *) table + gwdata->FFTLEN / 8 * 7 / 8);
/* Reserve space for the big/little flags. There are FFTLEN big/lit flags which takes FFTLEN / 8 bytes. */
/* The big/lit flags will be compressed at an 8:1 ratio, thus FFTLEN / 64 bytes are needed. */
/* Rational FFTs have no big/lit table, zero-padded FFTs have a half-size big/lit table. */
gwdata->biglit_data_offset = (unsigned long) ((char *) table - (char *) gwdata->pass1_var_data);
if (gwdata->RATIONAL_FFT);
else if (gwdata->ZERO_PADDED_FFT) table = (double *) ((char *) table + gwdata->FFTLEN / 64 / 2);
else table = (double *) ((char *) table + gwdata->FFTLEN / 64);
/* Round memory usage to a multiple of the cache line size */
table = round_to_cache_line(table);
gwdata->pass1_var_data_size = (unsigned long) ((char *) table - (char *) gwdata->pass1_var_data);
/* Return address of the end of the table */
return (table);
}
/* Initialize some needed constants */
pass1_size = gwdata->PASS1_SIZE;
upper_avx512_word = gwdata->PASS2_SIZE;
pass1_increment = gwdata->PASS2_SIZE * 8;
/* Determine number of delay groups. In a standard radix-8 FFT, there is only one sin/cos */
/* group in the last pass 1 level. We reduce our memory usage by using a fixed sin/cos */
/* table in the first FFT levels and having multiple groups of sin/cos data in the last pass 1 level. */
/* I call these groups of sin/cos data in the last pass 1 level "delay groups". */
delay_count = zr4dwpn_delay_count (gwdata);
/* Loop through all the pass 1 groups in the same order the assembly code will process the groups. */
for (group = 0; group < upper_avx512_word; group += gwdata->PASS1_CACHE_LINES) {
pass1_size = gwdata->PASS1_SIZE;
pass1_size /= (delay_count * 2); /* Complex values we're generating sin/cos data for */
N = gwdata->PASS2_SIZE;
/* Output the sin/cos/premultiplier values for the radix-8 block that does the last 3 levels in pass 1. */
N = N * 8;
/* For the zr8_rsc_wpn_sgreg_eight_complex and zr8_rsc_wpn_sgreg_sixteen_reals building blocks output */
/* a separate table of column normalization values before the sin/cos data for the complex delay groups. */
/* The weights and inverse weights are output in separate tables so that we can group data in cache lines better. */
{
double *weights, *inverse_weights;
weights = table;
inverse_weights = weights + gwdata->PASS1_CACHE_LINES;
table = inverse_weights + gwdata->PASS1_CACHE_LINES;
for (i = 0; i < gwdata->PASS1_CACHE_LINES; i++) {
gwfft_weights3 (gwdata->dd_data, group + i, weights, NULL, inverse_weights);
weights++;
inverse_weights++;
}
}
/* Output the complex sin/cos values needed for a standard zr8sg_eight_complex_djbfft */
/* in the last pass 1 levels. At runtime, we compute the actual sin/cos values from these. */
for (i = 0; i < gwdata->PASS1_CACHE_LINES; i += 8) {
// Asm code swizzles the input so that upper_avx512_word is 1
temp = group + i;
gwsincos1234by8_raw (temp, N, table);
gwsincos1234by8_raw (temp + 1, N, table+1);
gwsincos1234by8_raw (temp + 2, N, table+2);
gwsincos1234by8_raw (temp + 3, N, table+3);
gwsincos1234by8_raw (temp + 4, N, table+4);
gwsincos1234by8_raw (temp + 5, N, table+5);
gwsincos1234by8_raw (temp + 6, N, table+6);
gwsincos1234by8_raw (temp + 7, N, table+7);
table += 64;
}
/* For the zr8sg_sixteen_reals_fft8 building block, output the extra */
/* sin/cos values needed for the sixteen_reals. */
if (!gwdata->ALL_COMPLEX_FFT) {
for (i = 0; i < gwdata->PASS1_CACHE_LINES; i += 8) {
//bug - would gwsincos1357by8 work here? If not, why not.
// Asm code swizzles the input so that upper_avx512_word is 1
temp = group + i;
gwsincos159Dby8 (temp, N*2, table);
gwsincos159Dby8 (temp + 1, N*2, table+1);
gwsincos159Dby8 (temp + 2, N*2, table+2);
gwsincos159Dby8 (temp + 3, N*2, table+3);
gwsincos159Dby8 (temp + 4, N*2, table+4);
gwsincos159Dby8 (temp + 5, N*2, table+5);
gwsincos159Dby8 (temp + 6, N*2, table+6);
gwsincos159Dby8 (temp + 7, N*2, table+7);
table += 64;
}
}
/* Output the sin/cos values for the complex delay groups -- specifically the zr8sg_rsc_eight_complex_fft8 macro. */
for (k = 0; k < delay_count; k++) {
if (k == 0 && !gwdata->ALL_COMPLEX_FFT) continue;
for (i = 0; i < gwdata->PASS1_CACHE_LINES; i += 8) {
unsigned long bigN, ktemp, actemp, avx512_word;
/* Work on each AVX-512 word */
for (avx512_word = 0; avx512_word < 8; avx512_word++) {
unsigned long final_group = group + i + avx512_word;
/* If this is an all-complex FFT, the roots of minus 1 (same as roots of FFTLEN*2) are */
/* split to reduce memory requirements. We apply part of the all-complex premultiplier here. */
if (gwdata->ALL_COMPLEX_FFT) {
bigN = gwdata->FFTLEN * 2;
actemp = final_group;
} else {
bigN = gwdata->FFTLEN;
actemp = 0;
}
/* Factor in the delayed part of the sin/cos multiplies from the first levels. In the first levels */
/* we use a fixed sin/cos table based only on j, leaving the group+i part to be applied here by */
/* creating delay_count table entries. */
if (gwdata->ALL_COMPLEX_FFT) {
if (k <= delay_count/2) ktemp = k * final_group * 4;
else ktemp = bigN - (delay_count - k) * final_group * 4;
}
else {
ktemp = k * final_group;
}
/* We now calculate the group all-complex premultiplier roots of minus 1 (same as roots of FFTLEN*2) */
/* combined with the delayed group multipliers. */
gwsincos1by8_raw (actemp + ktemp, bigN, table + avx512_word);
}
table += 16;
}
}
pass1_size /= 8;
/* For the zr12_twelve_complex_djbfft building block levels, output the sin/cos values. */
while (pass1_size == 12) {
N = N * 12;
/* Output the sin/cos data for the complex sections, (the zr12_twelve_complex_djbfft building block). */
for (j = 0; j < N / 12; j += pass1_increment) {
for (i = 0; i < gwdata->PASS1_CACHE_LINES; i++) {
temp = (group + j + i);
gwsincos123456by8 (temp, N, table);
gwsincos123456by8 (temp + upper_avx512_word, N, table+1);
gwsincos123456by8 (temp + 2 * upper_avx512_word, N, table+2);
gwsincos123456by8 (temp + 3 * upper_avx512_word, N, table+3);
gwsincos123456by8 (temp + 4 * upper_avx512_word, N, table+4);
gwsincos123456by8 (temp + 5 * upper_avx512_word, N, table+5);
gwsincos123456by8 (temp + 6 * upper_avx512_word, N, table+6);
gwsincos123456by8 (temp + 7 * upper_avx512_word, N, table+7);
table += 96;
/* The zr12_csc_twentyfour_real building blocks require extra sin/cos values. The twentyfour_real doubles N */
/* because the real part of the FFT is one level behind the complex part of the FFT. */
if (!gwdata->ALL_COMPLEX_FFT) {
gwsincos13579Bby8 (temp, N*2, table);
gwsincos13579Bby8 (temp + upper_avx512_word, N*2, table+1);
gwsincos13579Bby8 (temp + 2 * upper_avx512_word, N*2, table+2);
gwsincos13579Bby8 (temp + 3 * upper_avx512_word, N*2, table+3);
gwsincos13579Bby8 (temp + 4 * upper_avx512_word, N*2, table+4);
gwsincos13579Bby8 (temp + 5 * upper_avx512_word, N*2, table+5);
gwsincos13579Bby8 (temp + 6 * upper_avx512_word, N*2, table+6);
gwsincos13579Bby8 (temp + 7 * upper_avx512_word, N*2, table+7);
table += 96;
}
}
}
pass1_size /= 12;
}
/* For the zr10_ten_complex_djbfft building block levels, output the sin/cos values. */
while (pass1_size == 10) {
N = N * 10;
/* Output the sin/cos data for the complex sections, (the zr10_ten_complex_djbfft building block). */
for (j = 0; j < N / 10; j += pass1_increment) {
for (i = 0; i < gwdata->PASS1_CACHE_LINES; i++) {
temp = (group + j + i);
gwsincos12345by8 (temp, N, table);
gwsincos12345by8 (temp + upper_avx512_word, N, table+1);
gwsincos12345by8 (temp + 2 * upper_avx512_word, N, table+2);
gwsincos12345by8 (temp + 3 * upper_avx512_word, N, table+3);
gwsincos12345by8 (temp + 4 * upper_avx512_word, N, table+4);
gwsincos12345by8 (temp + 5 * upper_avx512_word, N, table+5);
gwsincos12345by8 (temp + 6 * upper_avx512_word, N, table+6);
gwsincos12345by8 (temp + 7 * upper_avx512_word, N, table+7);
table += 80;
/* The zr10_csc_twenty_real building blocks require extra sin/cos values. The twenty_real doubles N */
/* because the real part of the FFT is one level behind the complex part of the FFT. */
if (!gwdata->ALL_COMPLEX_FFT) {
gwsincos13579by8 (temp, N*2, table);
gwsincos13579by8 (temp + upper_avx512_word, N*2, table+1);
gwsincos13579by8 (temp + 2 * upper_avx512_word, N*2, table+2);
gwsincos13579by8 (temp + 3 * upper_avx512_word, N*2, table+3);
gwsincos13579by8 (temp + 4 * upper_avx512_word, N*2, table+4);
gwsincos13579by8 (temp + 5 * upper_avx512_word, N*2, table+5);
gwsincos13579by8 (temp + 6 * upper_avx512_word, N*2, table+6);
gwsincos13579by8 (temp + 7 * upper_avx512_word, N*2, table+7);
table += 80;
}
}
}
pass1_size /= 10;
}
/* For the zr5_five_complex_djbfft building block levels, output the sin/cos values. */
while (pass1_size % 5 == 0) {
N = N * 5;
/* Output the sin/cos data for the complex sections, (the zr5_five_complex_djbfft building block). */
for (j = 0; j < N / 5; j += pass1_increment) {
for (i = 0; i < gwdata->PASS1_CACHE_LINES; i++) {
temp = (group + j + i);
gwsincos12by8 (temp, N, table);
gwsincos12by8 (temp + upper_avx512_word, N, table+1);
gwsincos12by8 (temp + 2 * upper_avx512_word, N, table+2);
gwsincos12by8 (temp + 3 * upper_avx512_word, N, table+3);
gwsincos12by8 (temp + 4 * upper_avx512_word, N, table+4);
gwsincos12by8 (temp + 5 * upper_avx512_word, N, table+5);
gwsincos12by8 (temp + 6 * upper_avx512_word, N, table+6);
gwsincos12by8 (temp + 7 * upper_avx512_word, N, table+7);
table += 32;
/* The zr5_csc_ten_real building blocks require extra sin/cos values. The ten_real doubles N */
/* because the real part of the FFT is one level behind the complex part of the FFT. */
if (!gwdata->ALL_COMPLEX_FFT) {
gwsincos13by8 (temp, N*2, table);
gwsincos13by8 (temp + upper_avx512_word, N*2, table+1);
gwsincos13by8 (temp + 2 * upper_avx512_word, N*2, table+2);
gwsincos13by8 (temp + 3 * upper_avx512_word, N*2, table+3);
gwsincos13by8 (temp + 4 * upper_avx512_word, N*2, table+4);
gwsincos13by8 (temp + 5 * upper_avx512_word, N*2, table+5);
gwsincos13by8 (temp + 6 * upper_avx512_word, N*2, table+6);
gwsincos13by8 (temp + 7 * upper_avx512_word, N*2, table+7);
table += 32;
}
}
}
pass1_size /= 5;
}
/* For the zr6_six_complex_djbfft building block levels, output the sin/cos values. */
while (pass1_size % 6 == 0) {
N = N * 6;
/* Output the sin/cos data for the complex sections, (the zr6_six_complex_djbfft building block). */
for (j = 0; j < N / 6; j += pass1_increment) {
for (i = 0; i < gwdata->PASS1_CACHE_LINES; i++) {
temp = (group + j + i);
gwsincos123by8 (temp, N, table);
gwsincos123by8 (temp + upper_avx512_word, N, table+1);
gwsincos123by8 (temp + 2 * upper_avx512_word, N, table+2);
gwsincos123by8 (temp + 3 * upper_avx512_word, N, table+3);
gwsincos123by8 (temp + 4 * upper_avx512_word, N, table+4);
gwsincos123by8 (temp + 5 * upper_avx512_word, N, table+5);
gwsincos123by8 (temp + 6 * upper_avx512_word, N, table+6);
gwsincos123by8 (temp + 7 * upper_avx512_word, N, table+7);
table += 48;
/* The zr6_csc_twelve_real building blocks require extra sin/cos values. The twelve_real doubles N */
/* because the real part of the FFT is one level behind the complex part of the FFT. */
if (!gwdata->ALL_COMPLEX_FFT) {
gwsincos135by8 (temp, N*2, table);
gwsincos135by8 (temp + upper_avx512_word, N*2, table+1);
gwsincos135by8 (temp + 2 * upper_avx512_word, N*2, table+2);
gwsincos135by8 (temp + 3 * upper_avx512_word, N*2, table+3);
gwsincos135by8 (temp + 4 * upper_avx512_word, N*2, table+4);
gwsincos135by8 (temp + 5 * upper_avx512_word, N*2, table+5);
gwsincos135by8 (temp + 6 * upper_avx512_word, N*2, table+6);
gwsincos135by8 (temp + 7 * upper_avx512_word, N*2, table+7);
table += 48;
}
}
}
pass1_size /= 6;
}
/* For the zr7_seven_complex_djbfft building block levels, output the sin/cos values. */
while (pass1_size % 7 == 0) {
N = N * 7;
/* Output the sin/cos data for the complex sections, (the zr7_seven_complex_djbfft building block). */
/* Use the special7 version which multiplies sine values by .434^(2/3) which saves 2 clocks in 14 reals building block. */
for (j = 0; j < N / 7; j += pass1_increment) {
for (i = 0; i < gwdata->PASS1_CACHE_LINES; i++) {
temp = (group + j + i);
gwsincos123by8_special7 (temp, N, table);
gwsincos123by8_special7 (temp + upper_avx512_word, N, table+1);
gwsincos123by8_special7 (temp + 2 * upper_avx512_word, N, table+2);
gwsincos123by8_special7 (temp + 3 * upper_avx512_word, N, table+3);
gwsincos123by8_special7 (temp + 4 * upper_avx512_word, N, table+4);
gwsincos123by8_special7 (temp + 5 * upper_avx512_word, N, table+5);
gwsincos123by8_special7 (temp + 6 * upper_avx512_word, N, table+6);
gwsincos123by8_special7 (temp + 7 * upper_avx512_word, N, table+7);
table += 48;
/* The zr7_csc_fourteen_real building blocks require extra sin/cos values. The fourteen_real doubles N */
/* because the real part of the FFT is one level behind the complex part of the FFT. */
if (!gwdata->ALL_COMPLEX_FFT) {
gwsincos135by8_special7 (temp, N*2, table);
gwsincos135by8_special7 (temp + upper_avx512_word, N*2, table+1);
gwsincos135by8_special7 (temp + 2 * upper_avx512_word, N*2, table+2);
gwsincos135by8_special7 (temp + 3 * upper_avx512_word, N*2, table+3);
gwsincos135by8_special7 (temp + 4 * upper_avx512_word, N*2, table+4);
gwsincos135by8_special7 (temp + 5 * upper_avx512_word, N*2, table+5);
gwsincos135by8_special7 (temp + 6 * upper_avx512_word, N*2, table+6);
gwsincos135by8_special7 (temp + 7 * upper_avx512_word, N*2, table+7);
table += 48;
}
}
}
pass1_size /= 7;
}
/* For the zr16_sixteen_complex_djbfft building block levels, output the sin/cos values. */
while (pass1_size == 16) {
N = N * 16;
/* Output the sin/cos data for the complex sections, (the zr16_sixteen_complex_djbfft building block). */
for (j = 0; j < N / 16; j += pass1_increment) {
for (i = 0; i < gwdata->PASS1_CACHE_LINES; i++) {
temp = (group + j + i);
gwsincos12345678by8 (temp, N, table);
gwsincos12345678by8 (temp + upper_avx512_word, N, table+1);
gwsincos12345678by8 (temp + 2 * upper_avx512_word, N, table+2);
gwsincos12345678by8 (temp + 3 * upper_avx512_word, N, table+3);
gwsincos12345678by8 (temp + 4 * upper_avx512_word, N, table+4);
gwsincos12345678by8 (temp + 5 * upper_avx512_word, N, table+5);
gwsincos12345678by8 (temp + 6 * upper_avx512_word, N, table+6);
gwsincos12345678by8 (temp + 7 * upper_avx512_word, N, table+7);
table += 128;
/* The zr16_csc_thirtytwo_real building blocks require extra sin/cos values. The thirtytwo_real doubles N */
/* because the real part of the FFT is one level behind the complex part of the FFT. */
if (!gwdata->ALL_COMPLEX_FFT) {
gwsincos13579BDFby8 (temp, N*2, table);
gwsincos13579BDFby8 (temp + upper_avx512_word, N*2, table+1);
gwsincos13579BDFby8 (temp + 2 * upper_avx512_word, N*2, table+2);
gwsincos13579BDFby8 (temp + 3 * upper_avx512_word, N*2, table+3);
gwsincos13579BDFby8 (temp + 4 * upper_avx512_word, N*2, table+4);
gwsincos13579BDFby8 (temp + 5 * upper_avx512_word, N*2, table+5);
gwsincos13579BDFby8 (temp + 6 * upper_avx512_word, N*2, table+6);
gwsincos13579BDFby8 (temp + 7 * upper_avx512_word, N*2, table+7);
table += 128;
}
}
}
pass1_size /= 16;
}
/* For the zr8_eight_complex_djbfft building block levels, output the sin/cos values. */
while (pass1_size % 8 == 0) {
N = N * 8;
/* Output the sin/cos data for the complex sections, (the zr8_eight_complex_djbfft building block). */
for (j = 0; j < N / 8; j += pass1_increment) {
for (i = 0; i < gwdata->PASS1_CACHE_LINES; i++) {
temp = (group + j + i);
gwsincos1234by8 (temp, N, table);
gwsincos1234by8 (temp + upper_avx512_word, N, table+1);
gwsincos1234by8 (temp + 2 * upper_avx512_word, N, table+2);
gwsincos1234by8 (temp + 3 * upper_avx512_word, N, table+3);
gwsincos1234by8 (temp + 4 * upper_avx512_word, N, table+4);
gwsincos1234by8 (temp + 5 * upper_avx512_word, N, table+5);
gwsincos1234by8 (temp + 6 * upper_avx512_word, N, table+6);
gwsincos1234by8 (temp + 7 * upper_avx512_word, N, table+7);
#ifdef TRY_SQRT2_TO_REDUCE_ROUNDOFF
{
gwsincos1234by8_sqrthalf (temp, N, table);
gwsincos1234by8_sqrthalf (temp + upper_avx512_word, N, table+1);
gwsincos1234by8_sqrthalf (temp + 2 * upper_avx512_word, N, table+2);
gwsincos1234by8_sqrthalf (temp + 3 * upper_avx512_word, N, table+3);
gwsincos1234by8_sqrthalf (temp + 4 * upper_avx512_word, N, table+4);
gwsincos1234by8_sqrthalf (temp + 5 * upper_avx512_word, N, table+5);
gwsincos1234by8_sqrthalf (temp + 6 * upper_avx512_word, N, table+6);
gwsincos1234by8_sqrthalf (temp + 7 * upper_avx512_word, N, table+7);
}
#endif
table += 64;
/* The zr8_csc_sixteen_real building blocks require extra sin/cos values. The sixteen_real doubles N */
/* because the real part of the FFT is one level behind the complex part of the FFT. */
if (!gwdata->ALL_COMPLEX_FFT) {
gwsincos1357by8 (temp, N*2, table);
gwsincos1357by8 (temp + upper_avx512_word, N*2, table+1);
gwsincos1357by8 (temp + 2 * upper_avx512_word, N*2, table+2);
gwsincos1357by8 (temp + 3 * upper_avx512_word, N*2, table+3);
gwsincos1357by8 (temp + 4 * upper_avx512_word, N*2, table+4);
gwsincos1357by8 (temp + 5 * upper_avx512_word, N*2, table+5);
gwsincos1357by8 (temp + 6 * upper_avx512_word, N*2, table+6);
gwsincos1357by8 (temp + 7 * upper_avx512_word, N*2, table+7);
table += 64;
}
}
}
pass1_size /= 8;
}
/* Reserve space for the group multiplier fudge flags. There are pass1_size fudge flags, which takes pass1_size / 8 bytes. */
/* The fudge flags will be compressed at an 8:1 ratio, thus pass1_size / 64 bytes are needed. */
/* For zero-padded FFTs, the fudge flags could be half the size, but we have not implemented that. */
table = (double *) ((char *) table + gwdata->PASS1_SIZE * gwdata->PASS1_CACHE_LINES / 64);
/* Reserve space for the big/little flags. There are pass1_size big/lit flags, which takes pass1_size / 8 bytes. */
/* The big/lit flags will be compressed at an 8:1 ratio, thus pass1_size / 64 bytes are needed. */
/* Rational FFTs have no big/lit table, zero-padded FFTs have a half-size big/lit table. */
if (group == 0) gwdata->biglit_data_offset = (unsigned long) ((char *) table - (char *) gwdata->pass1_var_data);
if (gwdata->RATIONAL_FFT);
else if (gwdata->ZERO_PADDED_FFT) table = (double *) ((char *) table + gwdata->PASS1_SIZE * gwdata->PASS1_CACHE_LINES / 64 / 2);
else table = (double *) ((char *) table + gwdata->PASS1_SIZE * gwdata->PASS1_CACHE_LINES / 64);
/* Round pass 1 group's memory usage to a multiple of the cache line size */
/* Calculate the size of each pass 1 group's sin/cos/premult data for pass1_get_next_block */
table = round_to_cache_line(table);
if (group == 0) gwdata->pass1_var_data_size = (unsigned long) ((char *) table - (char *) gwdata->pass1_var_data);
}
/* Return address of the end of the table */
return (table);
}
/* This routine builds the fixed sin/cos table used in pass 1 of the radix-8 delayed DJB FFT. */
double *zr4dwpn_build_fixed_pass1_table (
gwhandle *gwdata, /* Handle initialized by gwsetup */
double *table) /* Pointer to the table to fill in */
{
unsigned long upper_avx512_word, pass1_increment, pass1_size, i, j, N, delay_count;
/* Initialize some needed constants */
upper_avx512_word = gwdata->PASS2_SIZE;
pass1_increment = 8 * gwdata->PASS2_SIZE;
pass1_size = gwdata->PASS1_SIZE;
delay_count = zr4dwpn_delay_count (gwdata);
/* Real FFTs output one shared set of sin/cos values for the first 16-reals or 24-reals FFT */
if (! gwdata->ALL_COMPLEX_FFT) {
N = gwdata->FFTLEN;
if (delay_count == 8) {
for (j = 0; j < N / 16; j += pass1_increment) {
for (i = 1; i <= 7; i++) { /* Create 7 twiddle factors */
gwsincos1by8 (i * j, N, table);
gwsincos1by8 (i * (j + upper_avx512_word), N, table+1);
gwsincos1by8 (i * (j + 2 * upper_avx512_word), N, table+2);
gwsincos1by8 (i * (j + 3 * upper_avx512_word), N, table+3);
gwsincos1by8 (i * (j + 4 * upper_avx512_word), N, table+4);
gwsincos1by8 (i * (j + 5 * upper_avx512_word), N, table+5);
gwsincos1by8 (i * (j + 6 * upper_avx512_word), N, table+6);
gwsincos1by8 (i * (j + 7 * upper_avx512_word), N, table+7);
table += 16;
}
}
N = N / 16;
}
if (delay_count == 12) {
for (j = 0; j < N / 24; j += pass1_increment) {
for (i = 1; i <= 11; i++) { /* Create 11 twiddle factors */
gwsincos1by8 (i * j, N, table);
gwsincos1by8 (i * (j + upper_avx512_word), N, table+1);
gwsincos1by8 (i * (j + 2 * upper_avx512_word), N, table+2);
gwsincos1by8 (i * (j + 3 * upper_avx512_word), N, table+3);
gwsincos1by8 (i * (j + 4 * upper_avx512_word), N, table+4);
gwsincos1by8 (i * (j + 5 * upper_avx512_word), N, table+5);
gwsincos1by8 (i * (j + 6 * upper_avx512_word), N, table+6);
gwsincos1by8 (i * (j + 7 * upper_avx512_word), N, table+7);
table += 16;
}
}
N = N / 24;
}
}
/* For all-complex FFTs, build the fixed roots-of-minus-one table and the DJB FFT sin/cos table. */
/* Output these values in the same order they will be used in the first levels of pass 1. */
else {
N = gwdata->FFTLEN / 2;
// BUG - delay count of 5 is not working yet
if (delay_count == 5) {
for (j = 0; j < N / 5; j += pass1_increment) {
/* Compute the roots-of-minus-one premultiplier. The root-of-minus-one */
/* premultiplier is for 2N, and a root-of-minus-one-of-2N is the same as */
/* a root unity for 4N. */
gwsincos1plus01234by8 (j, N / 5, N * 4, table);
gwsincos1plus01234by8 (j + upper_avx512_word, N / 5, N * 4, table + 1);
gwsincos1plus01234by8 (j + 2 * upper_avx512_word, N / 5, N * 4, table + 2);
gwsincos1plus01234by8 (j + 3 * upper_avx512_word, N / 5, N * 4, table + 3);
gwsincos1plus01234by8 (j + 4 * upper_avx512_word, N / 5, N * 4, table + 4);
gwsincos1plus01234by8 (j + 5 * upper_avx512_word, N / 5, N * 4, table + 5);
gwsincos1plus01234by8 (j + 6 * upper_avx512_word, N / 5, N * 4, table + 6);
gwsincos1plus01234by8 (j + 7 * upper_avx512_word, N / 5, N * 4, table + 7);
table += 80;
/* Output the fixed sin/cos DJB FFT entry */
gwsincos12by8 (j, N, table);
gwsincos12by8 (j + upper_avx512_word, N, table+1);
gwsincos12by8 (j + 2 * upper_avx512_word, N, table+2);
gwsincos12by8 (j + 3 * upper_avx512_word, N, table+3);
gwsincos12by8 (j + 4 * upper_avx512_word, N, table+4);
gwsincos12by8 (j + 5 * upper_avx512_word, N, table+5);
gwsincos12by8 (j + 6 * upper_avx512_word, N, table+6);
gwsincos12by8 (j + 7 * upper_avx512_word, N, table+7);
table += 32;
}
N = N / 5;
}
if (delay_count == 8) {
for (j = 0; j < N / 8; j += pass1_increment) {
/* Compute the roots-of-minus-one premultiplier. The root-of-minus-one premultiplier is */
/* for 2N, and a root-of-minus-one-of-2N is the same as a root unity for 4N. NOTE: We only */
/* output the cos/sin values, the sine value will be applied to the group multipliers later on. */
gwcos1plus01234567by8 (j, N / 8, N * 4, table);
gwcos1plus01234567by8 (j + upper_avx512_word, N / 8, N * 4, table + 1);
gwcos1plus01234567by8 (j + 2 * upper_avx512_word, N / 8, N * 4, table + 2);
gwcos1plus01234567by8 (j + 3 * upper_avx512_word, N / 8, N * 4, table + 3);
gwcos1plus01234567by8 (j + 4 * upper_avx512_word, N / 8, N * 4, table + 4);
gwcos1plus01234567by8 (j + 5 * upper_avx512_word, N / 8, N * 4, table + 5);
gwcos1plus01234567by8 (j + 6 * upper_avx512_word, N / 8, N * 4, table + 6);
gwcos1plus01234567by8 (j + 7 * upper_avx512_word, N / 8, N * 4, table + 7);
table += 64;
/* Output the fixed sin/cos DJB FFT entry */
gwsincos1234by8 (j, N, table);
gwsincos1234by8 (j + upper_avx512_word, N, table+1);
gwsincos1234by8 (j + 2 * upper_avx512_word, N, table+2);
gwsincos1234by8 (j + 3 * upper_avx512_word, N, table+3);
gwsincos1234by8 (j + 4 * upper_avx512_word, N, table+4);
gwsincos1234by8 (j + 5 * upper_avx512_word, N, table+5);
gwsincos1234by8 (j + 6 * upper_avx512_word, N, table+6);
gwsincos1234by8 (j + 7 * upper_avx512_word, N, table+7);
#ifdef TRY_SQRT2_TO_REDUCE_ROUNDOFF
{
gwsincos1234by8_sqrthalf (j, N, table);
gwsincos1234by8_sqrthalf (j + upper_avx512_word, N, table+1);
gwsincos1234by8_sqrthalf (j + 2 * upper_avx512_word, N, table+2);
gwsincos1234by8_sqrthalf (j + 3 * upper_avx512_word, N, table+3);
gwsincos1234by8_sqrthalf (j + 4 * upper_avx512_word, N, table+4);
gwsincos1234by8_sqrthalf (j + 5 * upper_avx512_word, N, table+5);
gwsincos1234by8_sqrthalf (j + 6 * upper_avx512_word, N, table+6);
gwsincos1234by8_sqrthalf (j + 7 * upper_avx512_word, N, table+7);
}
#endif
table += 64;
}
N = N / 8;
}
if (delay_count == 12) {
for (j = 0; j < N / 12; j += pass1_increment) {
/* Compute the roots-of-minus-one premultiplier. The root-of-minus-one premultiplier is */
/* for 2N, and a root-of-minus-one-of-2N is the same as a root unity for 4N. NOTE: We only */
/* output the cos/sin values, the sine value will be applied to the group multipliers later on. */
gwcos1plus0123456789ABby8 (j, N / 12, N * 4, table);
gwcos1plus0123456789ABby8 (j + upper_avx512_word, N / 12, N * 4, table + 1);
gwcos1plus0123456789ABby8 (j + 2 * upper_avx512_word, N / 12, N * 4, table + 2);
gwcos1plus0123456789ABby8 (j + 3 * upper_avx512_word, N / 12, N * 4, table + 3);
gwcos1plus0123456789ABby8 (j + 4 * upper_avx512_word, N / 12, N * 4, table + 4);
gwcos1plus0123456789ABby8 (j + 5 * upper_avx512_word, N / 12, N * 4, table + 5);
gwcos1plus0123456789ABby8 (j + 6 * upper_avx512_word, N / 12, N * 4, table + 6);
gwcos1plus0123456789ABby8 (j + 7 * upper_avx512_word, N / 12, N * 4, table + 7);
table += 96;
/* Output the fixed sin/cos DJB FFT entry */
gwsincos123456by8 (j, N, table);
gwsincos123456by8 (j + upper_avx512_word, N, table+1);
gwsincos123456by8 (j + 2 * upper_avx512_word, N, table+2);
gwsincos123456by8 (j + 3 * upper_avx512_word, N, table+3);
gwsincos123456by8 (j + 4 * upper_avx512_word, N, table+4);
gwsincos123456by8 (j + 5 * upper_avx512_word, N, table+5);
gwsincos123456by8 (j + 6 * upper_avx512_word, N, table+6);
gwsincos123456by8 (j + 7 * upper_avx512_word, N, table+7);
table += 96;
}
N = N / 12;
}
}
/* Return address of the end of the table */
return (table);
}
/* Build the sin/cos table used in all-complex pass 2 blocks in a traditional radix-8 FFT. */
double *zr4_build_pass2_complex_table (
gwhandle *gwdata, /* Handle initialized by gwsetup */
double *table) /* Pointer to the table to fill in */
{
unsigned long i, N;
N = gwdata->PASS2_SIZE;
/* If the pass 2 size is divisible by 5, then the initial levels do */
/* radix-5 steps which requires two sin/cos values. The first levels */
/* in pass 2 have an upper_avx512_word of one. */
if (gwdata->PASS2_SIZE != 640 && gwdata->PASS2_SIZE != 4480 && gwdata->PASS2_SIZE != 6400 &&
gwdata->PASS2_SIZE != 7680 && gwdata->PASS2_SIZE != 10240) {
while (N % 5 == 0) {
for (i = 0; i < N / 5; i += 8) {
gwsincos12by8 (i, N, table);
gwsincos12by8 (i+1, N, table+1);
gwsincos12by8 (i+2, N, table+2);
gwsincos12by8 (i+3, N, table+3);
gwsincos12by8 (i+4, N, table+4);
gwsincos12by8 (i+5, N, table+5);
gwsincos12by8 (i+6, N, table+6);
gwsincos12by8 (i+7, N, table+7);
table += 32;
}
N = N / 5;
if (N == 10*64) break; // For 5 * 10 * 64 pass 2 size
}
}
/* If the pass 2 size is divisible by 7, then the initial levels do radix-7 steps which requires three sin/cos values. */
/* The first levels in pass 2 have an upper_avx512_word of one. Use the special7 version which multiplies sine values */
/* by .434^(2/3) to save 2 clocks in 14 reals building block. */
while (N % 7 == 0) {
for (i = 0; i < N / 7; i += 8) {
gwsincos123by8_special7 (i, N, table);
gwsincos123by8_special7 (i+1, N, table+1);
gwsincos123by8_special7 (i+2, N, table+2);
gwsincos123by8_special7 (i+3, N, table+3);
gwsincos123by8_special7 (i+4, N, table+4);
gwsincos123by8_special7 (i+5, N, table+5);
gwsincos123by8_special7 (i+6, N, table+6);
gwsincos123by8_special7 (i+7, N, table+7);
table += 48;
}
N = N / 7;
}
/* If the pass 2 size is divisible by 10, then the initial levels do */
/* radix-10 steps which requires 5 sin/cos values. The first levels */
/* in pass 2 have an upper_avx512_word of one. */
while (N % 10 == 0) {
for (i = 0; i < N / 10; i += 8) {
gwsincos12345by8 (i, N, table);
gwsincos12345by8 (i+1, N, table+1);
gwsincos12345by8 (i+2, N, table+2);
gwsincos12345by8 (i+3, N, table+3);
gwsincos12345by8 (i+4, N, table+4);
gwsincos12345by8 (i+5, N, table+5);
gwsincos12345by8 (i+6, N, table+6);
gwsincos12345by8 (i+7, N, table+7);
table += 80;
}
N = N / 10;
}
/* If the pass 2 size is divisible by 12, then the initial levels do */
/* radix-12 steps which requires six sin/cos values. The first levels */
/* in pass 2 have an upper_avx512_word of one. */
while (N == 12*64 || N == 12*6*64 || N == 12*8*64 || N == 12*12*64 || N == 12*16*64) {
for (i = 0; i < N / 12; i += 8) {
gwsincos123456by8 (i, N, table);
gwsincos123456by8 (i+1, N, table+1);
gwsincos123456by8 (i+2, N, table+2);
gwsincos123456by8 (i+3, N, table+3);
gwsincos123456by8 (i+4, N, table+4);
gwsincos123456by8 (i+5, N, table+5);
gwsincos123456by8 (i+6, N, table+6);
gwsincos123456by8 (i+7, N, table+7);
table += 96;
}
N = N / 12;
}
/* If the pass 2 size is divisible by 6, then the initial levels do */
/* radix-6 steps which requires three sin/cos values. The first levels */
/* in pass 2 have an upper_avx512_word of one. */
while (N % 6 == 0) {
for (i = 0; i < N / 6; i += 8) {
gwsincos123by8 (i, N, table);
gwsincos123by8 (i+1, N, table+1);
gwsincos123by8 (i+2, N, table+2);
gwsincos123by8 (i+3, N, table+3);
gwsincos123by8 (i+4, N, table+4);
gwsincos123by8 (i+5, N, table+5);
gwsincos123by8 (i+6, N, table+6);
gwsincos123by8 (i+7, N, table+7);
table += 48;
}
N = N / 6;
}
/* For any radix-16 blocks, output eight sin/cos values */
while (N == 16*64 || N == 16*8*64 || N == 16*16*64) {
for (i = 0; i < N / 16; i += 8) {
gwsincos12345678by8 (i, N, table);
gwsincos12345678by8 (i+1, N, table+1);
gwsincos12345678by8 (i+2, N, table+2);
gwsincos12345678by8 (i+3, N, table+3);
gwsincos12345678by8 (i+4, N, table+4);
gwsincos12345678by8 (i+5, N, table+5);
gwsincos12345678by8 (i+6, N, table+6);
gwsincos12345678by8 (i+7, N, table+7);
table += 128;
}
N = N / 16;
}
/* For the remaining radix-8 blocks, output four sin/cos values */
while (N > 8) {
for (i = 0; i < N / 8; i += 8) {
gwsincos1234by8 (i, N, table);
gwsincos1234by8 (i+1, N, table+1);
gwsincos1234by8 (i+2, N, table+2);
gwsincos1234by8 (i+3, N, table+3);
gwsincos1234by8 (i+4, N, table+4);
gwsincos1234by8 (i+5, N, table+5);
gwsincos1234by8 (i+6, N, table+6);
gwsincos1234by8 (i+7, N, table+7);
#ifdef TRY_SQRT2_TO_REDUCE_ROUNDOFF
if (N > 64) {
gwsincos1234by8_sqrthalf (i, N, table);
gwsincos1234by8_sqrthalf (i+1, N, table+1);
gwsincos1234by8_sqrthalf (i+2, N, table+2);
gwsincos1234by8_sqrthalf (i+3, N, table+3);
gwsincos1234by8_sqrthalf (i+4, N, table+4);
gwsincos1234by8_sqrthalf (i+5, N, table+5);
gwsincos1234by8_sqrthalf (i+6, N, table+6);
gwsincos1234by8_sqrthalf (i+7, N, table+7);
}
#endif
table += 64;
}
N = N / 8;
}
/* Return address of the end of the table */
return (table);
}
/* Build the sin/cos table used in pass 2 of real FFTs */
double *zr4_build_pass2_real_table (
gwhandle *gwdata, /* Handle initialized by gwsetup */
double *table) /* Pointer to the table to fill in */
{
unsigned long avx512_increment, j, N;
/* All complex FFTs, don't need these tables */
if (gwdata->ALL_COMPLEX_FFT) return (table);
/* Init */
avx512_increment = 1;
N = gwdata->PASS2_SIZE;
/* Output sin/cos values for 10-real macros */
if (gwdata->PASS2_SIZE != 640 && gwdata->PASS2_SIZE != 4480 && gwdata->PASS2_SIZE != 6400 &&
gwdata->PASS2_SIZE != 7680 && gwdata->PASS2_SIZE != 10240) {
while (N % 5 == 0) {
for (j = 0; j < N / 5; j += 8) {
gwsincos13by8 (j, N*2, table);
gwsincos13by8 (j + avx512_increment, N*2, table+1);
gwsincos13by8 (j + 2*avx512_increment, N*2, table+2);
gwsincos13by8 (j + 3*avx512_increment, N*2, table+3);
gwsincos13by8 (j + 4*avx512_increment, N*2, table+4);
gwsincos13by8 (j + 5*avx512_increment, N*2, table+5);
gwsincos13by8 (j + 6*avx512_increment, N*2, table+6);
gwsincos13by8 (j + 7*avx512_increment, N*2, table+7);
table += 32;
}
N = N / 5;
if (N == 10*64) break;
}
}
/* Output sin/cos values for 14-real macros. Use the special7 version which multiplies sine values */
/* by .434^(2/3) to save 2 clocks in 14 reals building block. */
while (N % 7 == 0) {
for (j = 0; j < N / 7; j += 8) {
gwsincos135by8_special7 (j, N*2, table);
gwsincos135by8_special7 (j + avx512_increment, N*2, table+1);
gwsincos135by8_special7 (j + 2*avx512_increment, N*2, table+2);
gwsincos135by8_special7 (j + 3*avx512_increment, N*2, table+3);
gwsincos135by8_special7 (j + 4*avx512_increment, N*2, table+4);
gwsincos135by8_special7 (j + 5*avx512_increment, N*2, table+5);
gwsincos135by8_special7 (j + 6*avx512_increment, N*2, table+6);
gwsincos135by8_special7 (j + 7*avx512_increment, N*2, table+7);
table += 48;
}
N = N / 7;
}
/* Output sin/cos values for 20-real macros */
while (N % 10 == 0) {
for (j = 0; j < N / 10; j += 8) {
gwsincos13579by8 (j, N*2, table);
gwsincos13579by8 (j + avx512_increment, N*2, table+1);
gwsincos13579by8 (j + 2*avx512_increment, N*2, table+2);
gwsincos13579by8 (j + 3*avx512_increment, N*2, table+3);
gwsincos13579by8 (j + 4*avx512_increment, N*2, table+4);
gwsincos13579by8 (j + 5*avx512_increment, N*2, table+5);
gwsincos13579by8 (j + 6*avx512_increment, N*2, table+6);
gwsincos13579by8 (j + 7*avx512_increment, N*2, table+7);
table += 80;
}
N = N / 10;
}
/* Output sin/cos values for 24-real macros */
while (N == 12*64 || N == 12*6*64 || N == 12*8*64 || N == 12*12*64 || N == 12*16*64) {
for (j = 0; j < N / 12; j += 8) {
gwsincos13579Bby8 (j, N*2, table);
gwsincos13579Bby8 (j + avx512_increment, N*2, table+1);
gwsincos13579Bby8 (j + 2*avx512_increment, N*2, table+2);
gwsincos13579Bby8 (j + 3*avx512_increment, N*2, table+3);
gwsincos13579Bby8 (j + 4*avx512_increment, N*2, table+4);
gwsincos13579Bby8 (j + 5*avx512_increment, N*2, table+5);
gwsincos13579Bby8 (j + 6*avx512_increment, N*2, table+6);
gwsincos13579Bby8 (j + 7*avx512_increment, N*2, table+7);
table += 96;
}
N = N / 12;
}
/* Output sin/cos values for 12-real macros */
while (N % 6 == 0) {
for (j = 0; j < N / 6; j += 8) {
gwsincos135by8 (j, N*2, table);
gwsincos135by8 (j + avx512_increment, N*2, table+1);
gwsincos135by8 (j + 2*avx512_increment, N*2, table+2);
gwsincos135by8 (j + 3*avx512_increment, N*2, table+3);