<commit_before>#include <iostream>
#include <string>
#include <vector>
#include <mpi.h>
#include "BVshared.h"
#include "BVgene.h"

#define MASTER 0
#define TAG 0
const int MESSAGE_SIZE = 500;

int main(int argc, char *argv[]) {
  int rows = 4550, column_size = 69, i, my_rank, num_nodes, source, start_row,
      end_row, number_amount;
  double program_start = MPI_Wtime();
  std::string gene_name, message_str;
  char message[MESSAGE_SIZE];
  std::vector<std::vector<std::string>> vector =
      vectorize("NCI-60.csv", rows, column_size);
  std::vector<gene_expression> gene_expressions =
      gene_expression_vector(vector);

  MPI_Init(&argc, &argv);
  MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
  MPI_Comm_size(MPI_COMM_WORLD, &num_nodes);

  if (my_rank != MASTER) {
    // pick rows to process by rank
    end_row = my_rank * 10;
    if (end_row < rows) {
      start_row = end_row - 10;
      for (i = start_row; i < end_row; i++) {
        std::cout << i << " row processing" << std::endl;
        gene_result result = process(gene_expressions[i]);
        message_str = encode_gene_result(result);
        strcpy(message, message_str.c_str());
        MPI_Send(&message, message_str.size(), MPI_CHAR, MASTER, i,
                 MPI_COMM_WORLD);
      }
    }
  } else {
    MPI_Status status;
    std::vector<gene_result> gene_results;
    //std::map<int, std::string> gene_name_index = gene_index(gene_expressions);
    for (i = 0; i < rows; i++) {
      std::cout << i << " row waiting for processing" << std::endl;
      MPI_Irecv(&message, MESSAGE_SIZE, MPI_CHAR, source, i, MPI_COMM_WORLD,
               &status);
      MPI_Get_count(&status, MPI_CHAR, &number_amount);
      std::string message_str(message, number_amount);
      std::cout << i << " row done" << std::endl;
      gene_results.push_back(decode_gene_result(message_str));
    }
    double program_end = MPI_Wtime();
    double program_elapsed = program_end - program_start;

    std::cout.precision(10);
    for (i = 0; i < gene_results.size(); i++) {
      std::cout << gene_results[i].gene_name << ", " << gene_results[i].d_score
                << std::endl;
    }

    printf("Nodes, Message Size, Program Execution Time, %d,%lu,%f\n",
           num_nodes, sizeof(double), program_elapsed);
  }

  MPI_Finalize();

  return 0;
}<commit_msg>blocking<commit_after>#include <iostream>
#include <string>
#include <vector>
#include <mpi.h>
#include "BVshared.h"
#include "BVgene.h"

#define MASTER 0
#define TAG 0
const int MESSAGE_SIZE = 500;

int main(int argc, char *argv[]) {
  int rows = 4550, column_size = 69, i, my_rank, num_nodes, source, start_row,
      end_row, number_amount;
  double program_start = MPI_Wtime();
  std::string gene_name, message_str;
  char message[MESSAGE_SIZE];
  std::vector<std::vector<std::string>> vector =
      vectorize("NCI-60.csv", rows, column_size);
  std::vector<gene_expression> gene_expressions =
      gene_expression_vector(vector);

  MPI_Init(&argc, &argv);
  MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
  MPI_Comm_size(MPI_COMM_WORLD, &num_nodes);

  if (my_rank != MASTER) {
    // pick rows to process by rank
    end_row = my_rank * 10;
    if (end_row < rows) {
      start_row = end_row - 10;
      for (i = start_row; i < end_row; i++) {
        std::cout << i << " row processing" << std::endl;
        gene_result result = process(gene_expressions[i]);
        message_str = encode_gene_result(result);
        strcpy(message, message_str.c_str());
        MPI_Send(&message, message_str.size(), MPI_CHAR, MASTER, i,
                 MPI_COMM_WORLD);
      }
    }
  } else {
    MPI_Status status;
    std::vector<gene_result> gene_results;
    //std::map<int, std::string> gene_name_index = gene_index(gene_expressions);
    for (i = 0; i < rows; i++) {
      std::cout << i << " row waiting for processing" << std::endl;
      MPI_Recv(&message, MESSAGE_SIZE, MPI_CHAR, source, i, MPI_COMM_WORLD,
               &status);
      MPI_Get_count(&status, MPI_CHAR, &number_amount);
      std::string message_str(message, number_amount);
      std::cout << i << " row done" << std::endl;
      gene_results.push_back(decode_gene_result(message_str));
    }
    double program_end = MPI_Wtime();
    double program_elapsed = program_end - program_start;

    std::cout.precision(10);
    for (i = 0; i < gene_results.size(); i++) {
      std::cout << gene_results[i].gene_name << ", " << gene_results[i].d_score
                << std::endl;
    }

    printf("Nodes, Message Size, Program Execution Time, %d,%lu,%f\n",
           num_nodes, sizeof(double), program_elapsed);
  }

  MPI_Finalize();

  return 0;
}
{'fraction_non_alphanumeric': 0.14236559139784946, 'fraction_numerical': 0.00946236559139785, 'mean_word_length': 3.4422158548233046, 'pattern_counts': {'":': 0, '<': 81, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '743378', 'n_tokens_mistral': 1714, 'n_tokens_neox': 1611, 'n_words': 350}