예제 #1
0
/* <num_copies> <flush_bool> .outputpage - */
static int
zoutputpage(i_ctx_t *i_ctx_p)
{
    os_ptr op = osp;
    int code;

    check_type(op[-1], t_integer);
    check_type(*op, t_boolean);
    if (gs_debug[':']) {
	gs_main_instance *minst = get_minst_from_memory((gs_memory_t *)i_ctx_p->memory.current->non_gc_memory);

	print_resource_usage(minst, &(i_ctx_p->memory), "Outputpage start");
    }
#ifdef PSI_INCLUDED
    code = ps_end_page_top(imemory,
			   (int)op[-1].value.intval, op->value.boolval);
#else
    code = gs_output_page(igs, (int)op[-1].value.intval,
			  op->value.boolval);
#endif
    if (code < 0)
	return code;
    pop(2);
    if (gs_debug[':']) {
	gs_main_instance *minst = get_minst_from_memory((gs_memory_t *)i_ctx_p->memory.current->non_gc_memory);

	print_resource_usage(minst, &(i_ctx_p->memory), "Outputpage end");
    }
    return 0;
}
예제 #2
0
int main(int argc, char **argv) {
  uint64_t i, items_per_thread = NO_OF_ITEMS;
  int threads = 1;
  pthread_t t_th[MAX_THREADS];

  if(argc > 1) {
    threads = atoi(argv[1]);
    threads = threads > MAX_THREADS ? MAX_THREADS : threads;
  }
  if(argc > 2) {
    items_per_thread = atoi(argv[2]);
  }

  if(threads > 1) {
    items_per_thread = items_per_thread / threads;
  }

  fprintf(stderr, "benchmarking with %d threads (%lu items per thread)\n", threads, items_per_thread);

  print_resource_usage();

  /* writers */
  for(i=0; i<threads; i++) {
    rb_t_attrs *attrs = malloc(sizeof(rb_t_attrs)); /* unfreed */
    attrs->tno = i;
    attrs->items_per_loop = items_per_thread;
    attrs->mode = 0;

    if(pthread_create(&t_th[i], NULL, rb_t_thr, (void*)attrs)) {
      fprintf(stderr, "thread creation failed:\n");
      perror("pthread_create");
    }
  }

  for(i=0; i<threads; i++) {
    pthread_join(t_th[i], NULL);
  }

  print_resource_usage();

  /* readers */
  for(i=0; i<threads; i++) {
    rb_t_attrs *attrs = malloc(sizeof(rb_t_attrs)); /* unfreed */
    attrs->tno = i;
    attrs->items_per_loop = items_per_thread;
    attrs->mode = 1;

    if(pthread_create(&t_th[i], NULL, rb_t_thr, (void*)attrs)) {
      fprintf(stderr, "thread creation failed:\n");
      perror("pthread_create");
    }
  }

  for(i=0; i<threads; i++) {
    pthread_join(t_th[i], NULL);
  }

  return 0;
}
예제 #3
0
파일: proto_info.c 프로젝트: openucx/ucx
void print_ucp_info(int print_opts, ucs_config_print_flags_t print_flags,
                    uint64_t ctx_features, const ucp_ep_params_t *base_ep_params,
                    size_t estimated_num_eps, unsigned dev_type_bitmap,
                    const char *mem_size)
{
    ucp_config_t *config;
    ucs_status_t status;
    ucs_status_ptr_t status_ptr;
    ucp_context_h context;
    ucp_worker_h worker;
    ucp_params_t params;
    ucp_worker_params_t worker_params;
    ucp_ep_params_t ep_params;
    ucp_address_t *address;
    size_t address_length;
    resource_usage_t usage;
    ucp_ep_h ep;

    status = ucp_config_read(NULL, NULL, &config);
    if (status != UCS_OK) {
        return;
    }

    memset(&params, 0, sizeof(params));
    params.field_mask        = UCP_PARAM_FIELD_FEATURES |
                               UCP_PARAM_FIELD_ESTIMATED_NUM_EPS;
    params.features          = ctx_features;
    params.estimated_num_eps = estimated_num_eps;

    get_resource_usage(&usage);

    if (!(dev_type_bitmap & UCS_BIT(UCT_DEVICE_TYPE_SELF))) {
        ucp_config_modify(config, "SELF_DEVICES", "");
    }
    if (!(dev_type_bitmap & UCS_BIT(UCT_DEVICE_TYPE_SHM))) {
        ucp_config_modify(config, "SHM_DEVICES", "");
    }
    if (!(dev_type_bitmap & UCS_BIT(UCT_DEVICE_TYPE_NET))) {
        ucp_config_modify(config, "NET_DEVICES", "");
    }

    status = ucp_init(&params, config, &context);
    if (status != UCS_OK) {
        printf("<Failed to create UCP context>\n");
        goto out_release_config;
    }

    if ((print_opts & PRINT_MEM_MAP) && (mem_size != NULL)) {
        ucp_mem_print_info(mem_size, context, stdout);
    }

    if (print_opts & PRINT_UCP_CONTEXT) {
        ucp_context_print_info(context, stdout);
        print_resource_usage(&usage, "UCP context");
    }

    if (!(print_opts & (PRINT_UCP_WORKER|PRINT_UCP_EP))) {
        goto out_cleanup_context;
    }

    worker_params.field_mask  = UCP_WORKER_PARAM_FIELD_THREAD_MODE;
    worker_params.thread_mode = UCS_THREAD_MODE_MULTI;

    get_resource_usage(&usage);

    status = ucp_worker_create(context, &worker_params, &worker);
    if (status != UCS_OK) {
        printf("<Failed to create UCP worker>\n");
        goto out_cleanup_context;
    }

    if (print_opts & PRINT_UCP_WORKER) {
        ucp_worker_print_info(worker, stdout);
        print_resource_usage(&usage, "UCP worker");
    }

    if (print_opts & PRINT_UCP_EP) {
        status = ucp_worker_get_address(worker, &address, &address_length);
        if (status != UCS_OK) {
            printf("<Failed to get UCP worker address>\n");
            goto out_destroy_worker;
        }

        ep_params             = *base_ep_params;

        ep_params.field_mask |= UCP_EP_PARAM_FIELD_REMOTE_ADDRESS;
        ep_params.address     = address;

        status = ucp_ep_create(worker, &ep_params, &ep);
        ucp_worker_release_address(worker, address);
        if (status != UCS_OK) {
            printf("<Failed to create UCP endpoint>\n");
            goto out_destroy_worker;
        }

        ucp_ep_print_info(ep, stdout);

        status_ptr = ucp_disconnect_nb(ep);
        if (UCS_PTR_IS_PTR(status_ptr)) {
            do {
                ucp_worker_progress(worker);
                status = ucp_request_test(status_ptr, NULL);
            } while (status == UCS_INPROGRESS);
            ucp_request_release(status_ptr);
        }
    }

out_destroy_worker:
    ucp_worker_destroy(worker);
out_cleanup_context:
    ucp_cleanup(context);
out_release_config:
    ucp_config_release(config);
}