-
Notifications
You must be signed in to change notification settings - Fork 1
/
assign_pkmemory.c
61 lines (43 loc) · 1.82 KB
/
assign_pkmemory.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
/*
1;95;0cint prep_c2c(){
nx = n2;
overdensity = (fftw_complex*) fftw_malloc(n0*n1*n2*sizeof(*overdensity));
smooth_overdensity = (fftw_complex*) fftw_malloc(n0*n1*n2*sizeof(*overdensity)); // 1d: N input elements -> N/2 + 1 output elements.
H_k = (fftw_complex*) fftw_malloc(n0*n1*nx*sizeof(*H_k));
plan = fftw_plan_dft_3d(n0, n1, n2, overdensity, H_k, FFTW_FORWARD, FFTW_ESTIMATE); // FFTW_ESTIMATE, FFTW_MEASURE, FFTW_PATIENT, //FFTW_EXHAUSTIVE.
return 0;
}
*/
int prep_r2c(){
nx = n2/2 + 1;
overdensity = (double*) fftw_malloc(n0*n1*n2*sizeof(*overdensity)); // here overdensity is a double, rather than complex.
// smooth_overdensity = (double*) fftw_malloc(n0*n1*n2*sizeof(*smooth_overdensity));
H_k = (fftw_complex*) fftw_malloc(n0*n1*nx*sizeof(*H_k)); // returns half the array, along the fastest memory change direction: x.
// FFTW_ESTIMATE, FFTW_MEASURE, FFTW_PATIENT, FFTW_EXHAUSTIVE.
plan = fftw_plan_dft_r2c_3d(n0, n1, n2, overdensity, H_k, FFTW_MEASURE); // r2c is always forward.
return 0;
}
int prep_x2c(){
// fftw_import_wisdom_from_filename("/home/mjw/HOD_MockRun/wisdom/wisdom.dat");
// prep_c2c();
prep_r2c();
// fftw_export_wisdom_to_filename("/home/mjw/HOD_MockRun/wisdom/wisdom.dat");
for(j=0; j<n0*n1*n2; j++) overdensity[j] = 0.0;
/*
for(j=0; j<n0*n1*n2; j++){
overdensity[j][0] = 0.0;
overdensity[j][1] = 0.0;
}
*/
regress_mem(&flat);
// regress_mem(&half);
// regress_mem(&quart);
walltime("Wall time after pk array malloc");
return 0;
}
int regress_mem(regress* inst){
inst->kind = calloc(n0*n1*nx, sizeof(int));
inst->kLi = calloc(n0*n1*nx, sizeof(double));
inst->kM2 = calloc(n0*n1*nx, sizeof(double));
return 0;
}