예제 #1
0
파일: int64.c 프로젝트: Abyss116/skynet
static int
int64_le(lua_State *L) {
	int64_t a = _int64(L,1);
	int64_t b = _int64(L,2);
	lua_pushboolean(L,a <= b);
	return 1;
}
예제 #2
0
파일: int64.c 프로젝트: Abyss116/skynet
static int
int64_sub(lua_State *L) {
	int64_t a = _int64(L,1);
	int64_t b = _int64(L,2);
	_pushint64(L, a-b);
	
	return 1;
}
예제 #3
0
파일: int64.c 프로젝트: Abyss116/skynet
static int
int64_add(lua_State *L) {
	int64_t a = _int64(L,1);
	int64_t b = _int64(L,2);
	_pushint64(L, a+b);
	
	return 1;
}
예제 #4
0
파일: int64.c 프로젝트: Abyss116/skynet
static int
int64_eq(lua_State *L) {
	// __eq metamethod can't be invoke by lightuserdata 
	int64_t a = _int64(L,1);
	int64_t b = _int64(L,2);
	lua_pushboolean(L,a == b);
	return 1;
}
예제 #5
0
파일: int64.c 프로젝트: Abyss116/skynet
static int
int64_mul(lua_State *L) {
	int64_t a = _int64(L,1);
	int64_t b = _int64(L,2);
	_pushint64(L, a * b);
	
	return 1;
}
예제 #6
0
파일: int64.c 프로젝트: Abyss116/skynet
static int
int64_mod(lua_State *L) {
	int64_t a = _int64(L,1);
	int64_t b = _int64(L,2);
	if (b == 0) {
		return luaL_error(L, "mod by zero");
	}
	_pushint64(L, a % b);
	
	return 1;
}
예제 #7
0
파일: int64.c 프로젝트: Abyss116/skynet
static int
int64_div(lua_State *L) {
	int64_t a = _int64(L,1);
	int64_t b = _int64(L,2);
	if (b == 0) {
		return luaL_error(L, "div by zero");
	}
	_pushint64(L, a / b);
	
	return 1;
}
예제 #8
0
파일: int64.c 프로젝트: Abyss116/skynet
static int
int64_new(lua_State *L) {
	int top = lua_gettop(L);
	int64_t n;
	switch(top) {
		case 0 : 
			lua_pushlightuserdata(L,NULL);
			break;
		case 1 :
			n = _int64(L,1);
			_pushint64(L,n);
			break;
		default: {
			int base = luaL_checkinteger(L,2);
			if (base < 2) {
				luaL_error(L, "base must be >= 2");
			}
			const char * str = luaL_checkstring(L, 1);
			n = strtoll(str, NULL, base);
			_pushint64(L,n);
			break;
		}
	}
	return 1;
}
예제 #9
0
파일: int64.c 프로젝트: Abyss116/skynet
static int
int64_pow(lua_State *L) {
	int64_t a = _int64(L,1);
	int64_t b = _int64(L,2);
	int64_t p;
	if (b > 0) {
		p = _pow64(a,b);
	} else if (b == 0) {
		p = 1;
	} else {
		return luaL_error(L, "pow by nagtive number %d",(int)b);
	} 
	_pushint64(L, p);

	return 1;
}
예제 #10
0
FilterOnesIterator& FilterOnesIterator::operator++()
{
	BHASSERT_WITH_NO_PERFORMANCE_IMPACT(valid);		// cannot iterate invalid iterator
	BHASSERT_WITH_NO_PERFORMANCE_IMPACT(packs_to_go==-1 || packs_to_go > packs_done);

	if(IsEndOfBlock()) {
		if(!IteratorBpp()) {
			valid = false;
			return *this;
		}
	} else
		iterator_n++; // now we are on the first suspected position - go forward if it is not 1

	bool found = false;
	while(!found) {
		if(cur_block_full) {
			found = true;
		} else if(cur_block_empty) { //Updating iterator can cause this
			if(!IteratorBpp()) {
				valid = false;
				return *this;
			}
		} else {
			found = FindOneInsidePack();
			if(!found) {
				if(!IteratorBpp()) {
					valid = false;
					return *this;
				}
			}
		}
	}
	cur_position = ((_int64(iterator_b)) << 16) + iterator_n;
	return *this;
}
예제 #11
0
void FilterOnesIterator::RewindToRow(const _int64 row)	// note: if row not exists , set IsValid() to false
{
	int pack = int(row >> 16);
	if(pack >= f->no_blocks ||
			(pack == f->no_blocks-1 && (row & 0xffff) >= f->no_of_bits_in_last_block))
		valid = false;
	else
		valid = true;
	BHASSERT_WITH_NO_PERFORMANCE_IMPACT(pack >= 0 && pack < f->no_blocks);

	iterator_b = prev_iterator_b = pack ;
	iterator_n = int(row & 0xffff);
	uchar stat = f->block_status[iterator_b];
	cur_block_full = (stat == f->FB_FULL);
	cur_block_empty = (stat == f->FB_EMPTY);
	buffer.Reset();			// random order - forget history
	if(cur_block_empty) {
		valid = false;
		return;
	}
	packs_done = 0;
	if(stat == f->FB_MIXED)
		if(!f->Get(row))
			valid = false;
		else
			ones_left_in_block = f->blocks[iterator_b]->no_set_bits;
	cur_position = ((_int64(iterator_b)) << 16) + iterator_n;
}
예제 #12
0
bool FilterOnesIterator::NextInsidePack()	// return false if we just restarted the pack after going to its end
{
	bool inside_pack = true;
	if(IsEndOfBlock()) {
		inside_pack = false;
		iterator_n = 0;
		prev_block = -1;
	} else
		iterator_n++; // now we are on the first suspected position - go forward if it is not 1
	bool found = false;
	while(!found) {
		if(cur_block_full) {
			found = true;
		} else if(cur_block_empty) { //Updating iterator can cause this
			return false;
		} else {
			found = FindOneInsidePack();
			if(!found) {
				inside_pack = false;
				iterator_n = 0;
				prev_block = -1;
			}
		}
	}
	cur_position = ((_int64(iterator_b)) << 16) + iterator_n;
	return inside_pack;
}
예제 #13
0
bool FilterOnesIterator::RewindToPack(int pack)
{
	// if SetNoPacksToGo() has been used, then RewindToPack can be done only to the previous pack
	assert(packs_to_go == -1 || pack == prev_iterator_b || pack == iterator_b);
	if(pack >= f->no_blocks)
		valid = false;
	else
		valid = true;
	if(iterator_b != pack)
		packs_done--;

	iterator_b = prev_iterator_b = pack;
	prev_block = pack;
	b = 0;
	bitsLeft = 0;
	lastn = -2;
	bln = 0; 
	iterator_n = 0;
	uchar stat = f->block_status[iterator_b];
	cur_block_full = (stat == f->FB_FULL);
	cur_block_empty = (stat == f->FB_EMPTY);
//	assert(buffer.Empty());			// random order - forget history, WARNING: may lead to omitting packs!
	buffer.Reset();
	if(cur_block_empty) {
		NextPack();
		return false;
	}
	if(!cur_block_full) {
		iterator_n = -1;
		FilterOnesIterator::operator++();
		ones_left_in_block = f->blocks[iterator_b]->no_set_bits;
	}
	cur_position = ((_int64(iterator_b)) << 16) + iterator_n;
	return true;
}
예제 #14
0
_int64 FilterOnesIterator::GetPackSizeLeft()	// how many 1-s in the current block left (including the current one)
{
	if(!valid)
		return 0;
	if(cur_block_full)
		return _int64(f->block_last_one[iterator_b]) + 1 - iterator_n;	BHASSERT_WITH_NO_PERFORMANCE_IMPACT(f->block_status[iterator_b] != f->FB_EMPTY);
	return ones_left_in_block;
}
예제 #15
0
void JoinerHashTable::Initialize(_int64 max_table_size, bool easy_roughable)
{
	// Input buffer format:		<key_1><key_2>...<key_n>
	// Table format:			<key_1><key_2>...<key_n><tuple_1>...<tuple_m><multiplier>
	if(max_table_size < 2)					// otherwise strange things may occur
		max_table_size = 2;
	if(initialized)
		return;
	AddTupleColumn(8);				// add multiplier column
	no_key_attr = int(encoder.size());
	no_attr = int(size.size());
	if(no_key_attr==0)
		return;
	if(no_attr - no_key_attr == 1)		// i.e. no tuple columns, just a multiplier
		for_count_only = true;

	column_offset 	= new int [no_attr];

	// Prepare buffers and mappings
	key_buf_width = 0;
	for(int i = 0; i < no_key_attr; i++) {
		encoder[i].SetPrimaryOffset(key_buf_width);
		key_buf_width += size[i];
	}
	key_buf_width = 4 * ( (key_buf_width + 3) / 4);				// e.g. 1->4, 12->12, 19->20
	total_width = key_buf_width;
	for(int i = no_key_attr; i < no_attr; i++) {
		column_offset[i] = total_width;
		total_width += size[i];
	}
	mult_offset = column_offset[no_attr - 1];

	/////////// create buffers ////////////////////
	if((max_table_size + 1) * total_width * 1.25 < 64 * MBYTE)
		no_rows = _int64((max_table_size + 1) * 1.25);	// make sure that rows_limit>=max_no_groups
	else {
		// for easy roughable case the buffer may be smaller
		no_rows = TrackableObject::MaxBufferSize(easy_roughable ? -3 : 0) / total_width;	// memory limitation
		if((max_table_size + 1) * 1.25 < no_rows)
			no_rows = _int64((max_table_size + 1) * 1.25);
	}

	// calculate vertical size (not dividable by a set of some prime numbers)
	if(no_rows < min_prime_not_in_table )				// too less rows => high collision probability
		no_rows = min_prime_not_in_table;
	else
		no_rows = (no_rows / min_prime_not_in_table + 1) * min_prime_not_in_table;

	// make sure that the size is not dividable by any of prime_steps
	bool increased = false;
	do {
		increased = false;
		for( int i = 0; i < prime_steps_no; i++ )
			if( no_rows % prime_steps[i] == 0 ) {
				increased = true;
				no_rows += min_prime_not_in_table;
				break;
			}
	} while(increased);
	rows_limit = _int64(no_rows * 0.9);	// rows_limit is used to determine whether the table is full

	t = (unsigned char*)alloc(((total_width / 4) * no_rows) * 4, BLOCK_TEMPORARY);	// no need to cache on disk
	input_buffer = (unsigned char*)new unsigned int [key_buf_width / 4];

	// initialize everything
	ClearAll();
	ConnectionInfo *m_conn = &ConnectionInfoOnTLS.Get();
	rccontrol.lock(m_conn->GetThreadID()) << "Hash join buffer initialized for up to " << no_rows << " rows, " 
										  << key_buf_width << "+" << total_width - key_buf_width << " bytes." << unlock;
	initialized = true;
}
////////////////////////////////////////////////////////////////////////////
// CHapticViewerView drawing
//
void CHapticViewerView::OnDraw(CDC* pDC)
{
    CHapticViewerDoc* pDoc = GetDocument();

    // Ceck pauseDraw to see if drawing should be paused to allow the user to 
    // respond to an error message box.
    if (pDoc->m_pauseDraw) return;

    Mesh* pObj = pDoc->getObj();

    wglMakeCurrent(m_hDC,m_hRC);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    if (pObj)
    {
        static double s_hlElapsed = 0.0;
        static double s_glElapsed = 0.0;
        static double s_totalElapsed = 0.0;
        static int s_hlTriCount = 0;
        static int s_glTriCount = 0;
    
        int hlTriCount = 0;
        int glTriCount = 0;
 
        double hlElapsed = 0.0;
        double glElapsed = 0.0;
        double totalElapsed = 0.0;

        // Manage how often to update performance number to avoid smearing.
        const double showPerfNumSec = 0.25;
    
        LARGE_INTEGER startHapticli, startGraphicli, startTotalli, endli;
        QueryPerformanceCounter(&startTotalli);
        QueryPerformanceCounter(&startHapticli);

        // Single pass render for both haptics and graphics.
        m_bSinglePassRender = m_bShapeDepthBuffer && !m_bHapticCameraView;

        //
        // draw haptic scene
        //
        hlTriCount = drawSceneHL(pObj);
        
        QueryPerformanceCounter(&endli);
        hlElapsed = double(_int64(endli.QuadPart - 
                                  startHapticli.QuadPart)) / g_liFreq.QuadPart;
        
        //
        // draw graphic scene
        //
        QueryPerformanceCounter(&startGraphicli);
        if (!m_bSinglePassRender)
        {
            // Use render produced by drawSceneHL (single pass render).
            glPushAttrib(GL_POLYGON_BIT);
            {
                if (m_bWireframe)
                {
                    glPolygonMode(GL_FRONT, GL_LINE);
                }

                const bool isHapticView = false;
                glTriCount = drawSceneGL(pObj, isHapticView);
            }
            glPopAttrib();

        }

        drawCursorGL();

        // Draw the frustum (if desired).
        if (m_bHapticCameraVisual)
        {
            glPushMatrix();
            glMultMatrixd(pObj->transform);

            drawFrustum(m_hapticCameraFrustum);

            glPopMatrix();
        }

        glFinish();
        QueryPerformanceCounter(&endli);
        glElapsed = double(_int64(endli.QuadPart - 
                                  startGraphicli.QuadPart)) / g_liFreq.QuadPart;

        totalElapsed = double(_int64(endli.QuadPart - 
                                     startTotalli.QuadPart)) / g_liFreq.QuadPart;

        // QueryPerformanceCounter(&endli);
        double perfElapsed = double(_int64(endli.QuadPart - 
                                           g_drawPerfli.QuadPart)) / g_liFreq.QuadPart;
        if ((perfElapsed > showPerfNumSec) && 
            (hlTriCount > 0 || glTriCount > 0))
        {
            QueryPerformanceCounter(&g_drawPerfli);
            s_hlElapsed = hlElapsed;
            s_glElapsed = glElapsed;
            s_totalElapsed = totalElapsed;
            s_hlTriCount = hlTriCount;
            s_glTriCount = glTriCount;
        }
        
        if (m_bPerformance)
        {
            drawPerformance(s_hlElapsed, s_glElapsed, s_totalElapsed, 
                            s_hlTriCount, s_glTriCount);
        }
    

        Invalidate(FALSE);
    }

    SwapBuffers(m_hDC);
}
예제 #17
0
파일: int64.c 프로젝트: Abyss116/skynet
static int
int64_len(lua_State *L) {
	int64_t a = _int64(L,1);
	lua_pushnumber(L,(lua_Number)a);
	return 1;
}
예제 #18
0
파일: int64.c 프로젝트: Abyss116/skynet
static int
int64_unm(lua_State *L) {
	int64_t a = _int64(L,1);
	_pushint64(L, -a);
	return 1;
}