<commit_before>/* 
* File:    multiplex.c
* CVS:     $Id$
* Author:  <NAME>
*          <EMAIL>
* Mods:    <your name here>
*          <your email address>
*/  

/* This file tests the multiplex functionality, originally developed by 
   <NAME> of LLNL. */

#include "papi_test.h"

#define FLOPS 4000000
#define READS 4000
#define NUM 10
#define SUCCESS 1

extern void do_flops(int);
extern void do_reads(int);

extern int TESTS_QUIET; /* Declared in test_utils.c */

/* Event to use in all cases; initialized in init_papi() */

#if defined(sparc) && defined(sun) || defined(__ALPHA) && defined(__osf__)
const static unsigned int preset_PAPI_events[PAPI_MPX_DEF_DEG] = { PAPI_TOT_INS, PAPI_TOT_CYC, PAPI_L1_ICM, 0 };
#else
const static unsigned int preset_PAPI_events[PAPI_MPX_DEF_DEG] = { PAPI_TOT_INS, PAPI_TOT_CYC, PAPI_L1_DCM, 0 };
#endif

static unsigned int PAPI_events[PAPI_MPX_DEF_DEG] = { 0, };
static int PAPI_events_len;

#ifdef TEST_DRIVER
#define CPP_TEST_FAIL(string, retval) test_fail(__FILE__, __LINE__, string, retval)
#else
#define CPP_TEST_FAIL(function, retval) { fprintf(stderr,"%s:%d:%s:%d:%s:%s\n",__FILE__,__LINE__,function,retval,PAPI_strerror(retval),"$Id$"); test_fail(__FILE__, __LINE__, function, retval); }

#endif

void init_papi(unsigned int *out_events, int *len)
{
  int retval;
  int i, real_len = 0;
  const unsigned int *in_events = preset_PAPI_events;
 
  /* Initialize the library */
  retval = PAPI_library_init(PAPI_VER_CURRENT);
  if (retval != PAPI_VER_CURRENT)
    CPP_TEST_FAIL("PAPI_library_init",retval);

  /* Turn on automatic error reporting */
  retval = PAPI_set_debug(PAPI_VERB_ECONT);
  if (retval != PAPI_OK)
    CPP_TEST_FAIL("PAPI_set_debug",retval);

  for (i=0;in_events[i]!=0;i++)
    {
       char out[PAPI_MAX_STR_LEN];
      /* query and set up the right instruction to monitor */
      retval = PAPI_query_event(in_events[i]);
	if (retval == PAPI_OK) 
	{
	  out_events[real_len++] = in_events[i];
	  PAPI_event_code_to_name(in_events[i],out);
 	  if ( !TESTS_QUIET )
	  	printf("%s exists\n",out);
	if (real_len == *len)
	break;
	}
	else
	{
	  PAPI_event_code_to_name(in_events[i],out);
	  if ( !TESTS_QUIET )
	  	printf("%s does not exist\n",out);
	}
    }
  if (real_len < 1) 
    CPP_TEST_FAIL("No counters available",0);
  *len = real_len;
}

/* Tests that PAPI_multiplex_init does not mess with normal operation. */
<commit_msg>Tests should be totally quiet except for PASSED/SKIPPED/FAILED in TESTS_QUIET mode.<commit_after>/* 
* File:    multiplex.c
* CVS:     $Id$
* Author:  <NAME>
*          <EMAIL>
* Mods:    <your name here>
*          <your email address>
*/  

/* This file tests the multiplex functionality, originally developed by 
   <NAME> of LLNL. */

#include "papi_test.h"

#define FLOPS 4000000
#define READS 4000
#define NUM 10
#define SUCCESS 1

extern void do_flops(int);
extern void do_reads(int);

extern int TESTS_QUIET; /* Declared in test_utils.c */

/* Event to use in all cases; initialized in init_papi() */

#if defined(sparc) && defined(sun) || defined(__ALPHA) && defined(__osf__)
const static unsigned int preset_PAPI_events[PAPI_MPX_DEF_DEG] = { PAPI_TOT_INS, PAPI_TOT_CYC, PAPI_L1_ICM, 0 };
#else
const static unsigned int preset_PAPI_events[PAPI_MPX_DEF_DEG] = { PAPI_TOT_INS, PAPI_TOT_CYC, PAPI_L1_DCM, 0 };
#endif

static unsigned int PAPI_events[PAPI_MPX_DEF_DEG] = { 0, };
static int PAPI_events_len;

#ifdef TEST_DRIVER
#define CPP_TEST_FAIL(function, retval) { fprintf(stderr,"%s:%d:%s:%d:%s:%s\n",__FILE__,__LINE__,function,retval,PAPI_strerror(retval),"$Id$"); test_fail(__FILE__, __LINE__, function, retval); }
#else
#define CPP_TEST_FAIL(string, retval) test_fail(__FILE__, __LINE__, string, retval)
#endif

void init_papi(unsigned int *out_events, int *len)
{
  int retval;
  int i, real_len = 0;
  const unsigned int *in_events = preset_PAPI_events;
 
  /* Initialize the library */
  retval = PAPI_library_init(PAPI_VER_CURRENT);
  if (retval != PAPI_VER_CURRENT)
    CPP_TEST_FAIL("PAPI_library_init",retval);

  /* Turn on automatic error reporting */
  if ( !TESTS_QUIET ) {
     retval = PAPI_set_debug(PAPI_VERB_ECONT);
     if (retval != PAPI_OK)
    	CPP_TEST_FAIL("PAPI_set_debug",retval);
  }

  for (i=0;in_events[i]!=0;i++)
    {
       char out[PAPI_MAX_STR_LEN];
      /* query and set up the right instruction to monitor */
      retval = PAPI_query_event(in_events[i]);
	if (retval == PAPI_OK) 
	{
	  out_events[real_len++] = in_events[i];
	  PAPI_event_code_to_name(in_events[i],out);
 	  if ( !TESTS_QUIET )
	  	printf("%s exists\n",out);
	if (real_len == *len)
	break;
	}
	else
	{
	  PAPI_event_code_to_name(in_events[i],out);
	  if ( !TESTS_QUIET )
	  	printf("%s does not exist\n",out);
	}
    }
  if (real_len < 1) 
    CPP_TEST_FAIL("No counters available",0);
  *len = real_len;
}

/* Tests that PAPI_multiplex_init does not mess with normal operation. */

{'fraction_non_alphanumeric': 0.127859477124183, 'fraction_numerical': 0.00980392156862745, 'mean_word_length': 4.417035398230088, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 13, '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': '4518419', 'n_tokens_mistral': 1960, 'n_tokens_neox': 1882, 'n_words': 422}