<commit_before>/****************************/
/* THIS IS OPEN SOURCE CODE */
/****************************/

/* 
 * File:    multiplex.c
 * CVS:     $Id$
 * Author:  <NAME>
 * Mods:    <NAME>
 *          <EMAIL>
 *          <NAME>
 *          <EMAIL>
 *          <NAME>
 *          <EMAIL>
 *          <NAME>
 *          <EMAIL> 
 *	        <NAME>
 *	        <EMAIL>
 *          <NAME>
 *          <EMAIL>
 *	        <NAME>
 *	        <EMAIL>
 */

/* xxxx Will this stuff run unmodified on multiple components?
    What happens when several components are counting multiplexed?
*/

#define MPX_NONDECR
/* Nils Smeds */

/* This MPX update modifies the behaviour of the multiplexing in PAPI.
 * The previous versions of the multiplexing based the value returned
 * from PAPI_reads on the total counts achieved since the PAPI_start
 * of the multiplexed event. This count was used as the basis of the
 * extrapolation using the proportion of time that this particular
 * event was active to the total time the multiplexed event was
 * active. However, a typical usage of PAPI is to measure over
 * sections of code by starting the event once and by comparing
 * the values returned by subsequent calls to PAPI_read. The difference
 * in counts is used as the measure of occured events in the code
 * section between the calls. 
 *
 * When multiplexing is used in this fashion the time proportion used
 * for extrapolation might appear inconsistent. The time fraction used
 * at each PAPI_read is the total time fraction since PAPI_start. If the
 * counter values achieved in each multiplex of the event varies
 * largely, or if the time slices are varying in length, discrepancies
 * to the behaviour without multiplexing might occur.
 *
 * In this version the extrapolation is made on a local time scale. At
 * each completed time slice the event extrapolates the achieved count
 * to a extrapolated count for the time since this event was last sliced
 * out up to the current point in time. There will still be occasions
 * when two consecutive PAPI_read will yield decreasing results, but all
 * extrapolations are being made on time local data. If time slicing
 * varies or if the count rate varies this implementation is expected to
 * be more "accurate" in a loose and here unspecified meaning.
 *
 * The short description of the changes is that the running events has
 * new fields count_estimate, rate_estimate and prev_total_c. The mpx
 * events have had the meaning of start_values and stop_values modified
 * to mean extrapolated start value and extrapolated stop value.
 */

/* <NAME> */
/* Lawrence Livermore National Laboratory */
/* MPX Version 1.0
 * UCRL-CODE-2001-007
 *
 * This work was produced at the University of California, Lawrence
 * Livermore National Laboratory (UC LLNL) under contract no.
 * W-7405-ENG-48 (Contract 48) between the U.S. Department of Energy 
 * (DOE) and The Regents of the University of California (University) 
 * for the operation of UC LLNL. The rights of the Federal Government
 * are reserved under Contract 48 subject to the restrictions agreed
 * upon by the DOE and University as allowed under DOE Acquisition
 * Letter 97-1. 
 *  
 *  
 *  
 * DISCLAIMER
 *  
 * This work was prepared as an account of work sponsored by an agency
 * of the United States Government. Neither the United States Government
 * nor the University of California nor any of their employees, makes
 * any warranty, express or implied, or assumes any liability or
 * responsibility for the accuracy, completeness, or usefulness of any
 * information, apparatus, product, or process disclosed, or represents
 * that its use would not infringe privately-owned rights.  Reference
 * herein to any specific commercial products, process, or service by
 * trade name, trademark, manufacturer or otherwise does not necessarily
 * constitute or imply its endorsement, recommendation, or favoring by
 * the United States Government or the University of California. The
 * views and opinions of authors expressed herein do not necessarily
 * state or reflect those of the United States Government or the
 * University of California, and shall not be used for advertising or
 * product endorsement purposes.
 *
 *  
 * NOTIFICATION OF COMMERCIAL USE
 *  
 * Commercialization of this product is prohibited without notifying the
 * Department of Energy (DOE) or Lawrence Livermore National Laboratory
 * (LLNL).
 */

#include "papi.h"
#include "papi_internal.h"
#include "papi_memory.h"

#define MPX_MINCYC 25000

/* Globals for this file. */

/* List of threads that are multiplexing. */

static Threadlist *tlist = NULL;
static unsigned int randomseed;

/* Timer stuff */

#ifndef _WIN32
static sigset_t sigreset;
static struct itimerval itime;
const static struct itimerval itimestop = { { 0, 0 }, { 0, 0 } };
static struct sigaction oaction;
#else<commit_msg>Modified license language for John May's LLNL portion of this code to conform with BSD as provided by LLNL. Thanks, Bronis, for bird-dogging this.<commit_after>/****************************/
/* THIS IS OPEN SOURCE CODE */
/****************************/

/* 
 * File:    multiplex.c
 * CVS:     $Id$
 * Author:  <NAME>
 * Mods:    <NAME>
 *          <EMAIL>
 *          <NAME>
 *          <EMAIL>
 *          <NAME>
 *          <EMAIL>
 *          <NAME>
 *          <EMAIL> 
 *	        <NAME>
 *	        <EMAIL>
 *          <NAME>
 *          <EMAIL>
 *	        <NAME>
 *	        <EMAIL>
 */

/* xxxx Will this stuff run unmodified on multiple components?
    What happens when several components are counting multiplexed?
*/

#define MPX_NONDECR
/* <NAME> */

/* This MPX update modifies the behaviour of the multiplexing in PAPI.
 * The previous versions of the multiplexing based the value returned
 * from PAPI_reads on the total counts achieved since the PAPI_start
 * of the multiplexed event. This count was used as the basis of the
 * extrapolation using the proportion of time that this particular
 * event was active to the total time the multiplexed event was
 * active. However, a typical usage of PAPI is to measure over
 * sections of code by starting the event once and by comparing
 * the values returned by subsequent calls to PAPI_read. The difference
 * in counts is used as the measure of occured events in the code
 * section between the calls. 
 *
 * When multiplexing is used in this fashion the time proportion used
 * for extrapolation might appear inconsistent. The time fraction used
 * at each PAPI_read is the total time fraction since PAPI_start. If the
 * counter values achieved in each multiplex of the event varies
 * largely, or if the time slices are varying in length, discrepancies
 * to the behaviour without multiplexing might occur.
 *
 * In this version the extrapolation is made on a local time scale. At
 * each completed time slice the event extrapolates the achieved count
 * to a extrapolated count for the time since this event was last sliced
 * out up to the current point in time. There will still be occasions
 * when two consecutive PAPI_read will yield decreasing results, but all
 * extrapolations are being made on time local data. If time slicing
 * varies or if the count rate varies this implementation is expected to
 * be more "accurate" in a loose and here unspecified meaning.
 *
 * The short description of the changes is that the running events has
 * new fields count_estimate, rate_estimate and prev_total_c. The mpx
 * events have had the meaning of start_values and stop_values modified
 * to mean extrapolated start value and extrapolated stop value.
 */

/* 
Portions of the following code are
Copyright (c) 2009, Lawrence Livermore National Security, LLC.  
Produced at the Lawrence Livermore National Laboratory  
Written by <NAME>, <EMAIL>
LLNL-CODE-421124
All rights reserved.  
  
Redistribution and use in source and binary forms, with or
without modification, are permitted provided that the following
conditions are met:  
  
  Redistributions of source code must retain the above copyright
notice, this list of conditions and the disclaimer below. 

  Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the disclaimer (as
noted below) in the documentation and/or other materials provided
with the distribution. 

  Neither the name of the LLNS/LLNL nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.  
  
 
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED.  IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL
SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  LOSS OF USE, DATA,
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON  ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.  
  
  
Additional BSD Notice  
  
1. This notice is required to be provided under our contract with
the U.S.  Department of Energy (DOE).  This work was produced at
Lawrence Livermore National Laboratory under Contract No.
DE-AC52-07NA27344 with the DOE.  
  
2. Neither the United States Government nor Lawrence Livermore
National Security, LLC nor any of their employees, makes any
warranty, express or implied, or assumes any liability or
responsibility for the accuracy, completeness, or usefulness of
any information, apparatus, product, or process disclosed, or
represents that its use would not infringe privately-owned
rights.  
  
3.  Also, reference herein to any specific commercial products,
process, or services by trade name, trademark, manufacturer or
otherwise does not necessarily constitute or imply its
endorsement, recommendation, or favoring by the United States
Government or Lawrence Livermore National Security, LLC.  The
views and opinions of authors expressed herein do not necessarily
state or reflect those of the United States Government or
Lawrence Livermore National Security, LLC, and shall not be used
for advertising or product endorsement purposes.  
 */

#include "papi.h"
#include "papi_internal.h"
#include "papi_memory.h"

#define MPX_MINCYC 25000

/* Globals for this file. */

/* List of threads that are multiplexing. */

static Threadlist *tlist = NULL;
static unsigned int randomseed;

/* Timer stuff */

#ifndef _WIN32
static sigset_t sigreset;
static struct itimerval itime;
const static struct itimerval itimestop = { { 0, 0 }, { 0, 0 } };
static struct sigaction oaction;
#else
{'fraction_non_alphanumeric': 0.0620891161431702, 'fraction_numerical': 0.006026296566837107, 'mean_word_length': 3.704896907216495, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 37, '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': '1405640', 'n_tokens_mistral': 2943, 'n_tokens_neox': 2737, 'n_words': 1495}