Пример #1
0
void *child_thread(void *data)
{
  struct control_info *pCntrl = (struct control_info *)data;
  char *pStart = NULL;
  int pages = 0;
  int i = 0, j = 0;
  int workload = pCntrl->workload;
  int rounds = pCntrl->rounds;

  fprintf(stderr, "%d : total rounds %d\n", getpid(), rounds);

  while (i < rounds) {
    fprintf(stderr, "%d : now rounds %d\n", getpid(), i);
    pthread_mutex_lock(&g_lock);
    pthread_mutex_unlock(&g_lock);

    /* Do specified work. */
    for (j = 0; j < workload; j++)
    {
      /* Do 1ms computation work. */
      unit_work();
    }
    i++;
    continue;
  }

  fprintf(stderr, "in the end, rounds %d\n", i);
}
Пример #2
0
static void* kernel_work(void *arg) {
    int idx;
    MemtestContext *ctx = (MemtestContext *)arg;
    if (pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &ctx->affinity_mask)) {
        fprintf(stderr, "Warning: Failed to set affinity of thread assigned to gpu %d[%s:%d]\n", ctx->id, __FILE__, __LINE__);
    }
    for (idx = 0; idx < ctx->shared_info->run_count; idx++)
        unit_work(ctx);
    return NULL;
}