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

/* 
* File:    linux-memory.c
* Author:  <NAME>
*          <EMAIL>
*
* Mods:    <your name here>
*          <your email address>
*/

#ifdef __LINUX__
#include <limits.h>
#endif

#ifdef _WIN32
/* Define SUBSTRATE to map to linux-perfctr.h
 * since we haven't figured out how to assign a value 
 * to a label at make inside the Windows IDE */
#define SUBSTRATE "linux-perfctr.h"
#endif

#include "papi.h"
#include SUBSTRATE
#include "papi_internal.h"
#include "papi_protos.h"

#include <stdio.h>
static int init_amd(PAPI_hw_info_t * mem_info);
static short int init_amd_L2_assoc_inf(unsigned short int pattern);
static int init_intel(PAPI_hw_info_t * mem_info);
inline_static void cpuid(unsigned int *, unsigned int *, unsigned int *, unsigned int *);

int _papi_hwd_get_memory_info(PAPI_hw_info_t * mem_info, int cpu_type)
{
   int retval = 0;

   /*
      if ( !check_cpuid() ) {
      return PAPI_ESBSTR;
      }
    */

   /* Defaults to Intel which is *probably* a safe assumption -KSL */
   switch (cpu_type) {
#ifdef _WIN32
   case AMD:
#else
   case PERFCTR_X86_AMD_K7:
#endif
      retval = init_amd(mem_info);
      break;
#ifdef __x86_64__
   case PERFCTR_X86_AMD_K8:
      retval = init_amd(mem_info);
      break;
#endif
   default:
      retval = init_intel(mem_info);
      break;
   }
   DBG((stderr, "Detected L1: %d L2: %d  L3: %d\n",
        mem_info->L1_size, mem_info->L2_cache_size, mem_info->L3_cache_size));
   return retval;
}

/* Cache configuration for AMD AThlon/Duron */
static int init_amd(PAPI_hw_info_t * mem_info)
{
   unsigned int reg_eax, reg_ebx, reg_ecx, reg_edx;
   unsigned short int pattern;

   /*
    * Layout of CPU information taken from :
    * "AMD Processor Recognition Application Note", 20734W-1 November 2002 
    */

   DBG((stderr, "Initializing AMD (K7) memory\n"));
   /* AMD level 1 cache info */<commit_msg>Added support for opteron revision C to make ctests/mem_info work.<commit_after>/****************************/
/* THIS IS OPEN SOURCE CODE */
/****************************/

/* 
* File:    linux-memory.c
* Author:  <NAME>
*          <EMAIL>
*
* Mods:    <your name here>
*          <your email address>
*/

#ifdef __LINUX__
#include <limits.h>
#endif

#ifdef _WIN32
/* Define SUBSTRATE to map to linux-perfctr.h
 * since we haven't figured out how to assign a value 
 * to a label at make inside the Windows IDE */
#define SUBSTRATE "linux-perfctr.h"
#endif

#include "papi.h"
#include SUBSTRATE
#include "papi_internal.h"
#include "papi_protos.h"

#include <stdio.h>
static int init_amd(PAPI_hw_info_t * mem_info);
static short int init_amd_L2_assoc_inf(unsigned short int pattern);
static int init_intel(PAPI_hw_info_t * mem_info);
inline_static void cpuid(unsigned int *, unsigned int *, unsigned int *, unsigned int *);

int _papi_hwd_get_memory_info(PAPI_hw_info_t * mem_info, int cpu_type)
{
   int retval = 0;

   /*
      if ( !check_cpuid() ) {
      return PAPI_ESBSTR;
      }
    */

   /* Defaults to Intel which is *probably* a safe assumption -KSL */
   switch (cpu_type) {
#ifdef _WIN32
   case AMD:
#else
   case PERFCTR_X86_AMD_K7:
#endif
      retval = init_amd(mem_info);
      break;
#ifdef __x86_64__
   case PERFCTR_X86_AMD_K8:
   case PERFCTR_X86_AMD_K8C:
      retval = init_amd(mem_info);
      break;
#endif
   default:
      retval = init_intel(mem_info);
      break;
   }
   DBG((stderr, "Detected L1: %d L2: %d  L3: %d\n",
        mem_info->L1_size, mem_info->L2_cache_size, mem_info->L3_cache_size));
   return retval;
}

/* Cache configuration for AMD AThlon/Duron */
static int init_amd(PAPI_hw_info_t * mem_info)
{
   unsigned int reg_eax, reg_ebx, reg_ecx, reg_edx;
   unsigned short int pattern;

   /*
    * Layout of CPU information taken from :
    * "AMD Processor Recognition Application Note", 20734W-1 November 2002 
    */

   DBG((stderr, "Initializing AMD (K7) memory\n"));
   /* AMD level 1 cache info */
{'fraction_non_alphanumeric': 0.13500745897563401, 'fraction_numerical': 0.017652909000497267, 'mean_word_length': 3.41602634467618, 'pattern_counts': {'":': 0, '<': 15, '<?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': '1311687', 'n_tokens_mistral': 1522, 'n_tokens_neox': 1447, 'n_words': 395}