 // compute the square of distance of the ith point and jth point
 __global__ void computeDist(int m, int n, int *V, int *D)
 {
-//	__shared__ int rowVector[TILE_DEPTH][TILE_WIDTH];
-//	__shared__ int colVector[TILE_DEPTH][TILE_WIDTH];
 	__shared__ int rowVector[TILE_WIDTH][TILE_DEPTH];
 	__shared__ int colVector[TILE_DEPTH][TILE_WIDTH];
 	__shared__ int dist[TILE_WIDTH][TILE_WIDTH];

	int s = blockDim.x/2;
//	int currentScale;
//	int last_s = s;
	int num;

	int indexBase = m;


   	int by = blockIdx.y;
	int tx = threadIdx.x;
	int ty = threadIdx.y;
	int row;
	int col;
//	int row = by*TILE_WIDTH+ty;
//	int col = bx*TILE_WIDTH+tx;
	int px;
	int py;	

	for(py=ty; py<TILE_WIDTH; py+=blockDim.y)
	{
	for(px=tx; px<TILE_WIDTH; px+=blockDim.x)
	{
	
	row = by*TILE_WIDTH+py;
	col = bx*TILE_WIDTH+px;
	dist[py][px] = 0;
	__syncthreads();

	for(int i=0; i<(int)(ceil((float)n/TILE_DEPTH)); i++)
	{
		for(int j=0; j<TILE_DEPTH; j++)
		{
			rowVector[py][j] = V[row*n+i*TILE_DEPTH+j];
		}
		for(int j=0; j<TILE_DEPTH; j++)
		{		
			colVector[j][px] = V[col*n+i*TILE_DEPTH+j];
		}
		__syncthreads();

		for(int j=0; j<TILE_DEPTH; j++)
		{
			dist[py][px] += (rowVector[py][j]-colVector[j][px])*(rowVector[py][j]-colVector[j][px]);
		}
		__syncthreads();
	}
	D[row*m+col] = dist[py][px];
	}
	}
}

__device__ void initSMem(int m, int k, int count, int *D, int *out)
