Skip to content

Commit 6d495fb

Browse files
committed
remove abundant files
1 parent 9a1dbe1 commit 6d495fb

File tree

13 files changed

+264
-350
lines changed

13 files changed

+264
-350
lines changed

source/main.cpp

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,54 @@
22
// AUTHOR : mohan
33
// DATE : 2008-11-10
44
//==========================================================
5-
65
#include "driver.h"
76
#include "fftw3.h"
87
#include "module_base/parallel_global.h"
98
#include "module_io/parse_args.h"
109
#include "module_parameter/parameter.h"
11-
#include "module_basis/module_pw/module_fft/fft_bundle.h"
1210
#ifdef _OPENMP
1311
#include <omp.h>
1412
#endif
15-
#include "module_basis/module_pw/module_fft/test.cuh"
13+
1614
int main(int argc, char** argv)
1715
{
1816
/*
1917
read the arguement in the command-line,
2018
with "abacus -v", the program exit and returns version info,
2119
with no arguments, the program continues.
2220
*/
23-
std::cout << "FFT Bundle Example" << std::endl;
21+
ModuleIO::parse_args(argc, argv);
2422

25-
// Example usage of make_unique
26-
ModulePW::test();
27-
// Note: The following lines are commented out as they require specific FFT implementations
28-
// Uncomment and implement the FFT operations as needed
29-
30-
// auto fft_bundle = make_unique<FFT_Bundle>("gpu", "single");
31-
32-
// Initialize FFT parameters
33-
// fft_bundle->initfft(256, 256, 256, 64, 64, 1, 1, 1, false, false, false);
23+
/*
24+
read the mpi parameters in the command-line,
25+
initialize the mpi environment.
26+
*/
27+
int nproc = 1;
28+
int my_rank = 0;
29+
int nthread_per_proc = 1;
30+
Parallel_Global::read_pal_param(argc, argv, nproc, nthread_per_proc, my_rank);
31+
#ifdef _OPENMP
32+
// ref: https://www.fftw.org/fftw3_doc/Usage-of-Multi_002dthreaded-FFTW.html
33+
fftw_init_threads();
34+
fftw_plan_with_nthreads(omp_get_max_threads());
35+
#endif
36+
PARAM.set_pal_param(my_rank, nproc, nthread_per_proc);
3437

35-
// Perform FFT operations
36-
// std::complex<float> input[256];
37-
// std::complex<float> output[256];
38-
// fft_bundle->fftxyfor(input, output);
38+
/*
39+
main program for doing electronic structure calculations.
40+
*/
41+
Driver DD;
42+
DD.init();
3943

40-
std::cout << "FFT operation completed." << std::endl;
44+
/*
45+
After running mpi version of abacus, release the mpi resources.
46+
*/
47+
#ifdef __MPI
48+
Parallel_Global::finalize_mpi();
49+
#endif
50+
#ifdef _OPENMP
51+
fftw_cleanup_threads();
52+
#endif
4153

4254
return 0;
4355
}

source/module_basis/module_pw/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ if (USE_CUDA)
77
list (APPEND FFT_SRC
88
module_fft/fft_cuda.cpp
99
module_fft/fft_cuda_batch.cpp
10-
module_fft/test.cu
1110
)
1211
endif()
1312
if (USE_ROCM)

source/module_basis/module_pw/module_fft/fft_bundle.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ void FFT_Bundle::initfft(int nx_in,
101101
fft_double = make_unique<FFT_ROCM<double>>();
102102
fft_double->initfft(nx_in, ny_in, nz_in);
103103
#elif defined(__CUDA)
104-
std::cout<<"here is the set of the gpu"<<std::endl;
105104
fft_float = make_unique<FFT_CUDA<float>>();
106105
fft_float->initfft(nx_in, ny_in, nz_in);
107106
fft_double = make_unique<FFT_CUDA<double>>();
@@ -115,14 +114,13 @@ void FFT_Bundle::initfft(int nx_in,
115114
fft_double = make_unique<FFT_ROCM<double>>();
116115
fft_double->initfft(nx_in, ny_in, nz_in);
117116
#elif defined(__CUDA)
118-
std::cout<<"here is the set of the batch gpu"<<std::endl;
119117
fft_float = make_unique<FFT_CUDA_BATCH<float>>();
120118
fft_float->initfft(nx_in, ny_in, nz_in);
121119
fft_double = make_unique<FFT_CUDA_BATCH<double>>();
122120
fft_double->initfft(nx_in, ny_in, nz_in );
123121
#endif
124122
}else{
125-
// ModuleBase::WARNING_QUIT("FFT_Bundle", "Please set the device to cpu or gpu or dsp");
123+
ModuleBase::WARNING_QUIT("FFT_Bundle", "Please set the device to cpu or gpu or dsp");
126124
}
127125
}
128126

source/module_basis/module_pw/module_fft/test.cu

Lines changed: 0 additions & 106 deletions
This file was deleted.

source/module_basis/module_pw/module_fft/test.cuh

Lines changed: 0 additions & 5 deletions
This file was deleted.

source/module_basis/module_pw/pw_transform_k.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -491,14 +491,13 @@ void PW_Basis_K::real2recip_gpu(const std::complex<FPTYPE>* in,
491491

492492
const int startig = ik * this->npwk_max;
493493
const int npw_k = this->npwk[ik];
494-
std::cout << "real2recip_gpu: npw_k = " << npw_k << ", nxyz = " << this->nxyz << std::endl;
495494
set_real_to_recip_output_op<FPTYPE, base_device::DEVICE_GPU>()(npw_k,
496495
this->nxyz,
497496
add,
498497
factor,
499498
this->ig2ixyz_k + startig,
500499
this->fft_bundle.get_auxr_3d_data<FPTYPE>(),
501-
out,1);
500+
out);
502501
ModuleBase::timer::tick(this->classname, "real_to_recip gpu");
503502
}
504503
template <typename FPTYPE>
@@ -520,18 +519,16 @@ void PW_Basis_K::recip2real_gpu(const std::complex<FPTYPE>* in,
520519
const int startig = ik * this->npwk_max;
521520
const int npw_k = this->npwk[ik];
522521
set_3d_fft_box_op<FPTYPE, base_device::DEVICE_GPU>()(npw_k,
523-
nxyz,
524522
this->ig2ixyz_k + startig,
525523
in,
526-
this->fft_bundle.get_auxr_3d_data<FPTYPE>(),
527-
1);
524+
this->fft_bundle.get_auxr_3d_data<FPTYPE>());
528525
this->fft_bundle.fft3D_backward(this->fft_bundle.get_auxr_3d_data<FPTYPE>(), this->fft_bundle.get_auxr_3d_data<FPTYPE>());
529526

530527
set_recip_to_real_output_op<FPTYPE, base_device::DEVICE_GPU>()(this->nrxx,
531528
add,
532529
factor,
533530
this->fft_bundle.get_auxr_3d_data<FPTYPE>(),
534-
out,1);
531+
out);
535532

536533
ModuleBase::timer::tick(this->classname, "recip_to_real gpu");
537534
}

source/module_basis/module_pw/test_gpu/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ if (USE_CUDA)
33
AddTest(
44
TARGET pw_test_gpu
55
LIBS parameter ${math_libs} base planewave device FFTW3::FFTW3_FLOAT
6-
SOURCES pw_test.cpp pw_basis_k_batch.cpp
6+
SOURCES pw_test.cpp pw_basis_C2R.cpp pw_basis_C2C.cpp pw_basis_k_C2C.cpp pw_basis_k_batch.cpp
77
)
88
endif()
99

source/module_basis/module_pw/test_gpu/pw_basis_k_C2C.cpp

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -196,41 +196,41 @@ class PW_BASIS_K_GPU_TEST : public ::testing::Test
196196
}
197197
};
198198

199-
using MixedTypes = ::testing::Types<
199+
using MixedTypes = ::testing::Types<TypePair<float, base_device::DEVICE_GPU>,
200200
TypePair<double, base_device::DEVICE_GPU> >;
201201

202202
TYPED_TEST_CASE(PW_BASIS_K_GPU_TEST, MixedTypes);
203203

204-
// TYPED_TEST(PW_BASIS_K_GPU_TEST, Mixing)
205-
// {
206-
// using T = typename TestFixture::T;
207-
// using Device = typename TestFixture::Device;
208-
// ModulePW::PW_Basis_K pwtest;
209-
// pwtest.set_device("gpu");
210-
// pwtest.set_precision("mixing");
211-
// pwtest.fft_bundle.setfft("gpu", "mixing");
212-
// this->init(pwtest);
213-
// int startiz = pwtest.startz_current;
214-
// const int nx = pwtest.nx;
215-
// const int ny = pwtest.ny;
216-
// const int nz = pwtest.nz;
217-
// const int nplane = pwtest.nplane;
218-
// const int npwk = pwtest.npwk[0];
219-
// for (int ixy = 0; ixy < nx * ny; ++ixy)
220-
// {
221-
// const int offset = ixy * nz + startiz;
222-
// const int startz = ixy * nplane;
223-
// for (int iz = 0; iz < nplane; ++iz)
224-
// {
225-
// EXPECT_NEAR(this->tmp[offset + iz].real(), this->h_rhor[startz + iz].real(), 1e-4);
226-
// }
227-
// }
228-
// for (int ig = 0; ig < npwk; ++ig)
229-
// {
230-
// EXPECT_NEAR(this->h_rhog[ig].real(), this->h_rhogout[ig].real(), 1e-4);
231-
// EXPECT_NEAR(this->h_rhog[ig].imag(), this->h_rhogout[ig].imag(), 1e-4);
232-
// }
233-
// }
204+
TYPED_TEST(PW_BASIS_K_GPU_TEST, Mixing)
205+
{
206+
using T = typename TestFixture::T;
207+
using Device = typename TestFixture::Device;
208+
ModulePW::PW_Basis_K pwtest;
209+
pwtest.set_device("gpu");
210+
pwtest.set_precision("mixing");
211+
pwtest.fft_bundle.setfft("gpu", "mixing");
212+
this->init(pwtest);
213+
int startiz = pwtest.startz_current;
214+
const int nx = pwtest.nx;
215+
const int ny = pwtest.ny;
216+
const int nz = pwtest.nz;
217+
const int nplane = pwtest.nplane;
218+
const int npwk = pwtest.npwk[0];
219+
for (int ixy = 0; ixy < nx * ny; ++ixy)
220+
{
221+
const int offset = ixy * nz + startiz;
222+
const int startz = ixy * nplane;
223+
for (int iz = 0; iz < nplane; ++iz)
224+
{
225+
EXPECT_NEAR(this->tmp[offset + iz].real(), this->h_rhor[startz + iz].real(), 1e-4);
226+
}
227+
}
228+
for (int ig = 0; ig < npwk; ++ig)
229+
{
230+
EXPECT_NEAR(this->h_rhog[ig].real(), this->h_rhogout[ig].real(), 1e-4);
231+
EXPECT_NEAR(this->h_rhog[ig].imag(), this->h_rhogout[ig].imag(), 1e-4);
232+
}
233+
}
234234

235235
TYPED_TEST(PW_BASIS_K_GPU_TEST, FloatDouble)
236236
{
@@ -284,20 +284,20 @@ TYPED_TEST(PW_BASIS_K_GPU_TEST, convulution)
284284
ModulePW::PW_Basis_K pwtest;
285285
pwtest.set_device("gpu");
286286
pwtest.set_precision("mixing");
287-
// if (typeid(T) == typeid(float))
288-
// {
289-
// pwtest.fft_bundle.setfft("gpu", "single");
290-
// }
291-
// if (typeid(T) == typeid(double))
292-
// {
287+
if (typeid(T) == typeid(float))
288+
{
289+
pwtest.fft_bundle.setfft("gpu", "single");
290+
}
291+
if (typeid(T) == typeid(double))
292+
{
293293
std::cout << "Using double precision" << std::endl;
294294
pwtest.fft_bundle.setfft("gpu", "double");
295-
// }
296-
// else
297-
// {
298-
// cout << "Error: Unsupported type" << endl;
299-
// return;
300-
// }
295+
}
296+
else
297+
{
298+
cout << "Error: Unsupported type" << endl;
299+
return;
300+
}
301301
this->init(pwtest);
302302
int startiz = pwtest.startz_current;
303303
const int nx = pwtest.nx;

0 commit comments

Comments
 (0)