<commit_before>/* $Id: pcomp_subs2.c $ */

/* copyright (c) 1996, 1997, 1998, 1999, 2014 by <NAME> and
   The Rector & Visitors of the University of Virginia */

/* Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing,
   software distributed under this License is distributed on an "AS
   IS" BASIS, WITHOUT WRRANTIES OR CONDITIONS OF ANY KIND, either
   express or implied.  See the License for the specific language
   governing permissions and limitations under the License. 
*/

/* modified to do more initialization of work_info here, rather than
   in main() */

/* this file provides the same functions for PCOMPLIB as pthr_subs2.c does for COMP_THR */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <sys/types.h>
#ifdef UNIX
#include <unistd.h>
#endif
#include <signal.h>

#include "defs.h"
#include "structs.h"		/* mngmsg, libstruct */
#include "param.h"		/* pstruct, thr_str, buf_head, rstruct */
#include "thr_buf_structs.h"

#ifdef MPI_SRC
#include "mpi.h"
#endif

#include "msg.h"
#include "pcomp_bufs.h"
#define XTERNAL
#include "uascii.h"
#undef XTERNAL
#include "pthr_subs.h"

#ifdef DEBUG
unsigned long adler32(unsigned long, const unsigned char *, unsigned int);
#endif

static int next_worker_idx, num_workers_idle;
extern int g_worker;

/* used for debugging */
/*
int check_seq_range(unsigned char *aa1b, int n1, int nsq, char *);
*/

/* start the workers, nworkers == number of workers, not nodes */
void
init_thr(int nworkers, char *info_lib_range_p, const struct mngmsg *m_msp, struct pstruct *ppst,
	 unsigned char *aa0, struct mng_thr *m_bufi_p)
{
#ifdef MPI_SRC
  MPI_Status mpi_status;
  int int_msg_b[4];	/* general purpose buffer for integers */
#endif
  int node, snode;

  /* start the worker processes */

  if (work_q == NULL) {
    if ((work_q=(int *)calloc(nworkers, sizeof(int)))==NULL) {
      fprintf(stderr, " cannot allocate work_q[%d] structure\n",
	      nworkers);
      exit(1);
    }
    else {max_worker_q = nworkers;}
  }
  num_workers_idle = 0;

  /* setup thread buffer info */
  if (aa0 == NULL) {
    int_msg_b[0] = int_msg_b[1] = int_msg_b[2] = 0;
  }
  else {
    int_msg_b[0] = nworkers;
    int_msg_b[2] = m_bufi_p->max_chain_seqs;
    int_msg_b[3] = m_bufi_p->seq_buf_size;
  }

  /* send thread info */
  for (node=FIRSTNODE; node < nworkers+FIRSTNODE; node++) {

    MPI_Send(int_msg_b, 4, MPI_INT, node, STARTTYPE0, MPI_COMM_WORLD);
<commit_msg>fix int_buf_msg[1] problem reported by <NAME> 27-August-2015<commit_after>/* $Id: pcomp_subs2.c $ */

/* copyright (c) 1996, 1997, 1998, 1999, 2014 by <NAME> and
   The Rector & Visitors of the University of Virginia */

/* Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing,
   software distributed under this License is distributed on an "AS
   IS" BASIS, WITHOUT WRRANTIES OR CONDITIONS OF ANY KIND, either
   express or implied.  See the License for the specific language
   governing permissions and limitations under the License. 
*/

/* modified to do more initialization of work_info here, rather than
   in main() */

/* this file provides the same functions for PCOMPLIB as pthr_subs2.c does for COMP_THR */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <sys/types.h>
#ifdef UNIX
#include <unistd.h>
#endif
#include <signal.h>

#include "defs.h"
#include "structs.h"		/* mngmsg, libstruct */
#include "param.h"		/* pstruct, thr_str, buf_head, rstruct */
#include "thr_buf_structs.h"

#ifdef MPI_SRC
#include "mpi.h"
#endif

#include "msg.h"
#include "pcomp_bufs.h"
#define XTERNAL
#include "uascii.h"
#undef XTERNAL
#include "pthr_subs.h"

#ifdef DEBUG
unsigned long adler32(unsigned long, const unsigned char *, unsigned int);
#endif

static int next_worker_idx, num_workers_idle;
extern int g_worker;

/* used for debugging */
/*
int check_seq_range(unsigned char *aa1b, int n1, int nsq, char *);
*/

/* start the workers, nworkers == number of workers, not nodes */
void
init_thr(int nworkers, char *info_lib_range_p, const struct mngmsg *m_msp, struct pstruct *ppst,
	 unsigned char *aa0, struct mng_thr *m_bufi_p)
{
#ifdef MPI_SRC
  MPI_Status mpi_status;
  int int_msg_b[4];	/* general purpose buffer for integers */
#endif
  int node, snode;

  /* start the worker processes */

  if (work_q == NULL) {
    if ((work_q=(int *)calloc(nworkers, sizeof(int)))==NULL) {
      fprintf(stderr, " cannot allocate work_q[%d] structure\n",
	      nworkers);
      exit(1);
    }
    else {max_worker_q = nworkers;}
  }
  num_workers_idle = 0;

  /* setup thread buffer info */
  if (aa0 == NULL) {
    int_msg_b[0] = int_msg_b[1] = int_msg_b[2] = 0;
  }
  else {
    int_msg_b[0] = nworkers;
    int_msg_b[1] = m_bufi_p->max_buf2_res;
    int_msg_b[2] = m_bufi_p->max_chain_seqs;
    int_msg_b[3] = m_bufi_p->seq_buf_size;
  }

  /* send thread info */
  for (node=FIRSTNODE; node < nworkers+FIRSTNODE; node++) {

    MPI_Send(int_msg_b, 4, MPI_INT, node, STARTTYPE0, MPI_COMM_WORLD);

{'fraction_non_alphanumeric': 0.11756061719324026, 'fraction_numerical': 0.017817781043350477, 'mean_word_length': 3.874664279319606, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2049874', 'n_tokens_mistral': 2043, 'n_tokens_neox': 1954, 'n_words': 610}