Exemplo n.º 1
0
void stdint_summary() {
    printf("Summary of types in stdint.h\n");
    printf("|  Types   |Size(B)|    MAX   |    MIN    |\n");
    printf("----------------------------------------\n");
    printf("|%9s |%6ld |%9d |%10d |\n","int8_t",size(8),max(8),min(8));
    printf("|%9s |%6ld |%9d |%10d |\n","uint8_t",usize(8),umax(8),0);
    printf("|%9s |%6ld |%9d |%10d |\n","int16_t",size(16),max(16),min(16));
    printf("|%9s |%6ld |%9d |%10d |\n","uint16_t",usize(16),umax(16),0);
    printf("|%9s |%6ld | %.2e | %.2e |\n","int32_t",size(32),(double)max(32),(double)min(32));
    printf("|%9s |%6ld | %.2e | %9.2e |\n","uint32_t",usize(32),(double)umax(32),(double)0);
    printf("|%9s |%6ld | %.2e | %.2e |\n","int64_t",size(64),(double)max(64),(double)min(64));
    printf("|%9s |%6ld | %.2e | %9.2e |\n","uint64_t",usize(64),(double)umax(64),(double)0);
    
}
Exemplo n.º 2
0
static struct req_tgtd *conhash_select (struct loadbalance_vfptr *lbs, char *ubuf)
{
	struct conhash_lbs *cl = cont_of_conhash (lbs);
	int size = MIN (usize (ubuf), 16);

	return (struct req_tgtd *) consistent_hash_get (&cl->tgs, ubuf, size);
}
Exemplo n.º 3
0
Scene::Scene(GuiWidgets* _gw) :
gw(*_gw), 
is_visible(true),    // should be set to false when the window is iconified !!!!
is_initialized(false),
is_startCB_launched(false),
net_delay(500),
cycles(0),
hud(NULL)
{
  background = UBackground::black;
  addAttr(background);
  addAttr(usize(g.pref.width3D, g.pref.height3D));

  hudbox.addAttr(upos(1, 1)  // position relatively to the canvas : up left corner
                 + UOrient::vertical + UHalign::left
                 + UFont::small + UColor::yellow   // size & color of the text
                 );
  hudbox.add(hud_line1 + hud_line2 + hud_line3 + hud_line4 + hud_line5);
  add(hudbox);	// add the hudbox to the scene

  message.addAttr(UFont::bold + UFont::xx_large + UColor::orange + uhcenter() + uvcenter());
  message.add("Please wait, VReng is coming up...");
  add(uhflex() + uvflex() + message);
  
  // Paint and Resize functions:
  // - are callback functions (paintCB and resizeCB) if the Scene is a UBox 
  // - are redefinitions of paintGL and resizeGL if the Scene is a UGlcanvas
  addAttr(UOn::paint / ucall(this, &Scene::paintCB)
          + UOn::resize / ucall(this, &Scene::resizeCB));
}
Exemplo n.º 4
0
UBox& Messages::createMessagePanel(bool transparent)
{
  scrollpane.add(messages);
  scrollpane.showVScrollButtons(false);
  scrollpane.getHScrollbar()->show(false);

  UTextfield& tf = utextfield(usize(250) + entry + ucall(this, &Messages::actionCB));

  UBox& panel =
  ubox(UOrient::vertical  + uhflex()
       + uvflex()
       + scrollpane
       + ubottom()
       + uhbox(ulabel(UFont::bold + "Message: ")
               + uhflex()
               + tf
               + uright()
               + uitem(utip("Clear") + uassign(entry, "")
                       + UFont::bold + "C")
               + uitem(utip("Previous message") + ucall(this,-1,&Messages::getHistoryCB)
                       + USymbol::up)
               + uitem(utip("Next message") + ucall(this,+1,&Messages::getHistoryCB)
                       + USymbol::down)
               )
       );
  if (transparent) {
    tf.addAttr(UBackground::none + UColor::white);
    panel.addAttr(UColor::white);
  }
  return panel;
}
Exemplo n.º 5
0
void show_info_log(GLuint obj_id, PFNGLGETSHADERIVPROC glGet_iv, PFNGLGETSHADERINFOLOGPROC glGet_InfoLog) {
	GLint log_len;
	glGet_iv(obj_id, GL_INFO_LOG_LENGTH, &log_len);

	tl::Vec<char> buf;
	buf.reserve(usize(log_len) + 1);
	glGet_InfoLog(obj_id, log_len, NULL, buf.begin());
	buf.begin()[log_len] = 0;
	printf("%s\n", buf.begin());
}
Exemplo n.º 6
0
	void* alloc(usize size) {
		usize rounded_size = TL_ALIGN_SIZE(size, TL_REGION_MAX_ALIGN);

		if (usize(this->end - this->cur) >= rounded_size) {
			void* ret = this->cur;
			this->cur += rounded_size;
			return ret;
		}

		return this->alloc_fallback(rounded_size);
	}
Exemplo n.º 7
0
static VALUE rb_sp_recv (VALUE self, VALUE eid)
{
	int _eid = FIX2INT (eid);
	int rc;
	char *ubuf = 0;
	VALUE msg;

	if ((rc = sp_recv (_eid, &ubuf)))
		return Qnil;
	msg = rb_str_new (ubuf, usize (ubuf));
	rb_iv_set (msg, "@hdr", Data_Wrap_Struct (0, 0, ufree, ubuf));
	return msg;
}
Exemplo n.º 8
0
int main(int argc, char** argv) {
    int i;
    int eid;
    int count;
    int size;
    char* ubuf;
    int thr;
    double mbs;
    uint64_t st, lt;

    if (argc < 3) {
        printf("usage: thr_recver <bind-to> <msg-count>\n");
        return 0;
    }

    count = atoi(argv[2]);
    BUG_ON((eid = sp_endpoint(SP_REQREP, SP_REP)) < 0);
    BUG_ON(sp_listen(eid, argv[1]) < 0);

    BUG_ON(sp_recv(eid, &ubuf) != 0);
    size = 0;
    st = gettimeofms();

    while (count > 0) {
        BUG_ON(sp_recv(eid, &ubuf) != 0);
        count--;
        size += usize(ubuf);

        if (count) {
            ufree(ubuf);
        } else {
            BUG_ON(sp_send(eid, ubuf) != 0);
        }
    }

    lt = gettimeofms();

    thr = atoi(argv[2]) * 1000 / (lt - st);
    mbs = (double)(size * 8 / (lt - st)) / 1024;

    printf("message size: %d [B]\n", size);
    printf("throughput: %d [msg/s]\n", thr);
    printf("throughput: %.3f [Mb/s]\n", mbs);

    sp_close(eid);
    return 0;
}
Exemplo n.º 9
0
static VALUE rb_sp_send (VALUE self, VALUE eid, VALUE msg)
{
	int _eid = FIX2INT (eid);
	int rc;
	VALUE rb_hdr = 0;
	char *hdr = 0;
	char *ubuf = ualloc (RSTRING (msg)->len);

	memcpy (ubuf, RSTRING (msg)->ptr, usize (ubuf));

	/* How can i checking the valid rb_values, f*****g the ruby extension here
	 */
	if ((rb_hdr = rb_iv_get (msg, "@hdr")) != 4) {
		Data_Get_Struct (rb_hdr, char, hdr);
		if (hdr)
			uctl (hdr, SCOPY, ubuf);
	}
	if ((rc = sp_send (_eid, ubuf)))
		ufree (ubuf);
	return INT2FIX (rc);
}
Exemplo n.º 10
0
DefaultResources::DefaultResources(DevicePtr dptr) :
		_spirv(std::make_unique<SpirVData[]>(spirv_count)),
		_computes(std::make_unique<ComputeProgram[]>(compute_count)),
		_materials(std::make_unique<AssetPtr<Material>[]>(material_count)) {

	for(usize i = 0; i != spirv_count; ++i) {
		_spirv[i] = load_spirv(spirv_names[i]);
	}

	for(usize i = 0; i != compute_count; ++i) {
		_computes[i] = ComputeProgram(ComputeShader(dptr, _spirv[usize(compute_spirvs[i])]));
	}

	for(usize i = 0; i != material_count; ++i) {
		const auto& data = material_datas[i];
		_materials[i] = make_asset<Material>(dptr, MaterialData()
				.set_frag_data(_spirv[data.frag])
				.set_vert_data(_spirv[data.vert])
				.set_depth_tested(data.depth_tested)
				.set_culled(data.culled)
				.set_blended(data.blended)
			);
	}
}
Exemplo n.º 11
0
const AssetPtr<Material>& DefaultResources::operator[](Materials i) const {
	return _materials[usize(i)];
}
Exemplo n.º 12
0
const ComputeProgram& DefaultResources::operator[](ComputePrograms i) const {
	return _computes[usize(i)];
}
Exemplo n.º 13
0
const SpirVData& DefaultResources::operator[](SpirV i) const {
	return _spirv[usize(i)];
}
Exemplo n.º 14
0
		"depth_alpha.comp",
		"copy.comp",

		"tonemap.frag",
		"basic.frag",
		"skinned.frag",
		"textured.frag",
		"imgui.frag",

		"basic.vert",
		"skinned.vert",
		"screen.vert",
		"imgui.vert",
	};

static constexpr usize spirv_count = usize(SpirV::MaxSpirV);
static constexpr usize compute_count = usize(ComputePrograms::MaxComputePrograms);
static constexpr usize material_count = usize(Materials::MaxMaterials);

static_assert(sizeof(spirv_names) / sizeof(spirv_names[0]) == spirv_count);
static_assert(sizeof(compute_spirvs) / sizeof(compute_spirvs[0]) == compute_count);
static_assert(sizeof(material_datas) / sizeof(material_datas[0]) == material_count);


static SpirVData load_spirv(const char* name) {
	return SpirVData::deserialized(io::File::open(fmt("%.spv", name)).expected("Unable to open SPIR-V file."));
}