@@ -95,27 +95,38 @@ std::tuple<double,double,ModuleBase::matrix> XC_Functional_Libxc::v_xc_libxc( /
9595 std::vector<double > vsigma ( nrxx * ((1 ==nspin)?1 :3 ) );
9696
9797 ModuleBase::timer::start (" Libxc" ," xc_lda/gga_exc_vxc" );
98- constexpr int nr_batch_size = 1024 ;
99- #ifdef _OPENMP
100- #pragma omp parallel for schedule(static, nr_batch_size)
101- #endif
102- for ( int ir_start = 0 ; ir_start < nrxx; ir_start += nr_batch_size )
98+ switch ( func.info ->family )
10399 {
104- const int ir_end = std::min (ir_start + nr_batch_size, nrxx);
105- const int nrxx_thread = ir_end - ir_start;
106-
107- switch ( func.info ->family )
100+ case XC_FAMILY_LDA:
108101 {
109- case XC_FAMILY_LDA:
102+ constexpr int nr_batch_size = 1024 ;
103+ #ifdef _OPENMP
104+ #pragma omp parallel for schedule(static, nr_batch_size)
105+ #endif
106+ for ( int ir_start = 0 ; ir_start < nrxx; ir_start += nr_batch_size )
107+ {
108+ const int ir_end = std::min (ir_start + nr_batch_size, nrxx);
109+ const int nrxx_thread = ir_end - ir_start;
110110 xc_lda_exc_vxc (
111111 &func,
112112 nrxx_thread,
113113 rho.data () + ir_start,
114114 exc.data () + ir_start,
115115 vrho.data () + ir_start * nspin );
116- break ;
117- case XC_FAMILY_GGA:
118- case XC_FAMILY_HYB_GGA:
116+ }
117+ break ;
118+ }
119+ case XC_FAMILY_GGA:
120+ case XC_FAMILY_HYB_GGA:
121+ {
122+ constexpr int nr_batch_size = 1024 ;
123+ #ifdef _OPENMP
124+ #pragma omp parallel for schedule(static, nr_batch_size)
125+ #endif
126+ for ( int ir_start = 0 ; ir_start < nrxx; ir_start += nr_batch_size )
127+ {
128+ const int ir_end = std::min (ir_start + nr_batch_size, nrxx);
129+ const int nrxx_thread = ir_end - ir_start;
119130 xc_gga_exc_vxc (
120131 &func,
121132 nrxx_thread,
@@ -124,10 +135,14 @@ std::tuple<double,double,ModuleBase::matrix> XC_Functional_Libxc::v_xc_libxc( /
124135 exc.data () + ir_start,
125136 vrho.data () + ir_start * nspin,
126137 vsigma.data () + ir_start * ((1 ==nspin)?1 :3 ) );
127- break ;
128- default :
129- throw std::domain_error (" func.info->family =" +std::to_string (func.info ->family )
130- +" unfinished in " +std::string (__FILE__)+" line " +std::to_string (__LINE__));
138+ }
139+ break ;
140+ }
141+ default :
142+ {
143+ throw std::domain_error (" func.info->family =" +std::to_string (func.info ->family )
144+ +" unfinished in " +std::string (__FILE__)+" line " +std::to_string (__LINE__));
145+
131146 }
132147 }
133148 ModuleBase::timer::end (" Libxc" ," xc_lda/gga_exc_vxc" );
0 commit comments