<commit_before>#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "delay.h"
#include "queue.h"

static long nops;
static queue_t q;
static handle_t * hds;

void init(int nprocs, int logn) {

  /** Use 10^7 as default input size. */
  if (logn == 0) logn = 7;

  /** Compute the number of ops to perform. */
  nops = 1;
  int i;
  for (i = 0; i < logn; ++i) {
    nops *= 10;
  }

  printf("  Number of operations: %d\n", nops);

  hds = malloc(sizeof(handle_t [nprocs]));
  queue_init(&q, nprocs);
}

void thread_init(int id, int nprocs) {
  queue_register(&q, &hds[id]);
}

void * benchmark(int id, int nprocs) {
  void * val = (void *) (intptr_t) (id + 1);
  handle_t * th = &hds[id];

  delay_t state;
  delay_init(&state, id);

  int i;
  for (i = 0; i < nops / nprocs; ++i) {
    enqueue(&q, th, val);
    delay_exec(&state);

    dequeue(&q, th);
    delay_exec(&state);
  }

  return val;
}

int verify() { return 1; }<commit_msg>Use aligned memory for queue and handles.<commit_after>#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "delay.h"
#include "queue.h"

static long nops;
static queue_t * q;
static handle_t ** hds;

void init(int nprocs, int logn) {

  /** Use 10^7 as default input size. */
  if (logn == 0) logn = 7;

  /** Compute the number of ops to perform. */
  nops = 1;
  int i;
  for (i = 0; i < logn; ++i) {
    nops *= 10;
  }

  printf("  Number of operations: %d\n", nops);

  q = aligned_alloc(PAGE_SIZE, sizeof(queue_t));
  queue_init(q, nprocs);

  hds = aligned_alloc(PAGE_SIZE, sizeof(handle_t * [nprocs]));
}

void thread_init(int id, int nprocs) {
  hds[id] = aligned_alloc(PAGE_SIZE, sizeof(handle_t));
  queue_register(q, hds[id]);
}

void * benchmark(int id, int nprocs) {
  void * val = (void *) (intptr_t) (id + 1);
  handle_t * th = hds[id];

  delay_t state;
  delay_init(&state, id);

  int i;
  for (i = 0; i < nops / nprocs; ++i) {
    enqueue(q, th, val);
    delay_exec(&state);

    dequeue(q, th);
    delay_exec(&state);
  }

  return val;
}

int verify() { return 1; }
{'fraction_non_alphanumeric': 0.17047110247693054, 'fraction_numerical': 0.011656143759106362, 'mean_word_length': 3.256198347107438, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 9, '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': '7603130', 'n_tokens_mistral': 885, 'n_tokens_neox': 836, 'n_words': 237}