1010
1111namespace marov_count_letters {
1212
13- MarovCountLettersMPI::MarovCountLettersMPI (const InType & in) {
13+ MarovCountLettersMpi::MarovCountLettersMpi (const InType& in) {
1414 MPI_Comm_rank (MPI_COMM_WORLD , &proc_rank_);
1515 MPI_Comm_size (MPI_COMM_WORLD , &proc_size_);
1616
@@ -19,15 +19,15 @@ MarovCountLettersMPI::MarovCountLettersMPI(const InType &in) {
1919 GetOutput () = 0 ;
2020}
2121
22- bool MarovCountLettersMPI ::ValidationImpl () {
22+ bool MarovCountLettersMpi ::ValidationImpl () {
2323 return true ;
2424}
2525
26- bool MarovCountLettersMPI ::PreProcessingImpl () {
26+ bool MarovCountLettersMpi ::PreProcessingImpl () {
2727 return true ;
2828}
2929
30- bool MarovCountLettersMPI ::RunImpl () {
30+ bool MarovCountLettersMpi ::RunImpl () {
3131 std::string input_str;
3232 int str_len = 0 ;
3333
@@ -36,10 +36,10 @@ bool MarovCountLettersMPI::RunImpl() {
3636 str_len = static_cast <int >(input_str.size ());
3737 }
3838
39- // Рассылка длины строки всем процессам
39+ // Broadcast string length
4040 MPI_Bcast (&str_len, 1 , MPI_INT , 0 , MPI_COMM_WORLD );
4141
42- // Разделение данных между процессами
42+ // Split data between processes
4343 const int base = str_len / proc_size_;
4444 const int rem = str_len % proc_size_;
4545
@@ -61,21 +61,22 @@ bool MarovCountLettersMPI::RunImpl() {
6161 const int local_size = base + (proc_rank_ < rem ? 1 : 0 );
6262 std::vector<char > local_data (local_size);
6363
64- MPI_Scatterv (proc_rank_ == 0 ? const_cast <char *>(input_str.data ()) : nullptr ,
64+ MPI_Scatterv (proc_rank_ == 0 ? const_cast <char *>(input_str.data ()) : nullptr ,
6565 send_counts.data (), displs.data (), MPI_CHAR ,
6666 local_data.data (), local_size, MPI_CHAR , 0 , MPI_COMM_WORLD );
6767
68- // Подсчет буквенных символов локально
68+ // Count letter characters locally
6969 int local_count = 0 ;
7070 for (int i = 0 ; i < local_size; ++i) {
71- if (std::isalpha (static_cast <unsigned char >(local_data[i]))) {
71+ if (std::isalpha (static_cast <unsigned char >(local_data[i])) != 0 ) {
7272 local_count++;
7373 }
7474 }
7575
76- // Редукция - сумма всех локальных подсчетов
76+ // Reduction - sum of all local counts
7777 int global_count = 0 ;
78- MPI_Reduce (&local_count, &global_count, 1 , MPI_INT , MPI_SUM , 0 , MPI_COMM_WORLD );
78+ MPI_Reduce (&local_count, &global_count, 1 , MPI_INT , MPI_SUM , 0 ,
79+ MPI_COMM_WORLD );
7980
8081 if (proc_rank_ == 0 ) {
8182 GetOutput () = global_count;
@@ -84,7 +85,7 @@ bool MarovCountLettersMPI::RunImpl() {
8485 return true ;
8586}
8687
87- bool MarovCountLettersMPI ::PostProcessingImpl () {
88+ bool MarovCountLettersMpi ::PostProcessingImpl () {
8889 return true ;
8990}
9091
0 commit comments