Try harder to trigger ABI errors in short16 test case

// 32-byte vectors have different calling conventions on x86-64
// depending on whether AVX instructions are enabled or not. This is
// not encoded in the target triple. Test here whether the kernel
// library and kernels are built with compatible options.

// The failure mode is that convert_char16(short16) sets the upper 8
// vector elements to zero.

__attribute__((__noinline__))
char my_convert_char(short s)
{
  return convert_char(s);
}

__attribute__((__noinline__))
char2 my_convert_char2(short2 s2)
{
  return convert_char2(s2);
}

__attribute__((__noinline__))
char3 my_convert_char3(short3 s3)
{
  return convert_char3(s3);
}

__attribute__((__noinline__))
char4 my_convert_char4(short4 s4)
{
  return convert_char4(s4);
}

__attribute__((__noinline__))
char8 my_convert_char8(short8 s8)
{
  return convert_char8(s8);
}

__attribute__((__noinline__))
char16 my_convert_char16(short16 s16)
{
  return convert_char16(s16);
}

kernel void test_short16()
{
  short s = (short)(1);
  short2 s2 = (short2)(2);
  short3 s3 = (short3)(3);
  short4 s4 = (short4)(4);
  short8 s8 = (short8)(8);
  short16 s16 = (short16)(16);

  char c = my_convert_char(s);
  char2 c2 = my_convert_char2(s2);
  char3 c3 = my_convert_char3(s3);
  char4 c4 = my_convert_char4(s4);
  char8 c8 = my_convert_char8(s8);
  char16 c16 = my_convert_char16(s16);

  bool good = true;
  good = good && c == s;
  if (!good) {
    printf("char->short conversion failed\n");
    printf("  c=%d s=%d\n", c, s);
  }

  bool good2 = true;
  for (int i=0; i<2; ++i) good2 = good2 && c2[i] == s2[i];
  if (!good2) {
    printf("char2->short2 conversion failed\n");
    for (int i=0; i<2; ++i) printf("  c[%d]=%d s[%d]=%d\n", i, c2[i], i, s2[i]);
  }

  bool good3 = true;
  for (int i=0; i<3; ++i) good3 = good3 && c3[i] == s3[i];
  if (!good3) {
    printf("char3->short3 conversion failed\n");
    for (int i=0; i<3; ++i) printf("  c[%d]=%d s[%d]=%d\n", i, c3[i], i, s3[i]);
  }

  bool good4 = true;
  for (int i=0; i<4; ++i) good4 = good4 && c4[i] == s4[i];
  if (!good4) {
    printf("char4->short4 conversion failed\n");
    for (int i=0; i<4; ++i) printf("  c[%d]=%d s[%d]=%d\n", i, c4[i], i, s4[i]);
  }

  bool good8 = true;
  for (int i=0; i<8; ++i) good8 = good8 && c8[i] == s8[i];
  if (!good8) {
    printf("char8->short8 conversion failed\n");
    for (int i=0; i<8; ++i) printf("  c[%d]=%d s[%d]=%d\n", i, c8[i], i, s8[i]);
  }

  bool good16 = true;
  for (int i=0; i<16; ++i) good16 = good16 && c16[i] == s16[i];
  if (!good16) {
    printf("char16->short16 conversion failed\n");
    for (int i=0; i<16; ++i)
      printf("  c[%d]=%d s[%d]=%d\n", i, c16[i], i, s16[i]);
  }
}

// 32-byte vectors have different calling conventions on x86-64
// depending on whether AVX instructions are enabled or not. This is
// not encoded in the target triple. Test here whether the kernel
// library and kernels are built with compatible options.

// The failure mode is that convert_char16(short16) sets the upper 8
// vector elements to zero.

kernel void test_short16()
{
  short s = (short)(1);
  short2 s2 = (short2)(2);
  short3 s3 = (short3)(3);
  short4 s4 = (short4)(4);
  short8 s8 = (short8)(8);
  short16 s16 = (short16)(16);

  char c = convert_char(s);
  char2 c2 = convert_char2(s2);
  char3 c3 = convert_char3(s3);
  char4 c4 = convert_char4(s4);
  char8 c8 = convert_char8(s8);
  char16 c16 = convert_char16(s16);

  bool good = true;
  good = good && c == s;
  if (!good) {
    printf("char->short conversion failed\n");
    printf("  c=%d s=%d\n", c, s);
  }

  bool good2 = true;
  for (int i=0; i<2; ++i) good2 = good2 && c2[i] == s2[i];
  if (!good2) {
    printf("char2->short2 conversion failed\n");
    for (int i=0; i<2; ++i) printf("  c[%d]=%d s[%d]=%d\n", i, c2[i], i, s2[i]);
  }

  bool good3 = true;
  for (int i=0; i<3; ++i) good3 = good3 && c3[i] == s3[i];
  if (!good3) {
    printf("char3->short3 conversion failed\n");
    for (int i=0; i<3; ++i) printf("  c[%d]=%d s[%d]=%d\n", i, c3[i], i, s3[i]);
  }

  bool good4 = true;
  for (int i=0; i<4; ++i) good4 = good4 && c4[i] == s4[i];
  if (!good4) {
    printf("char4->short4 conversion failed\n");
    for (int i=0; i<4; ++i) printf("  c[%d]=%d s[%d]=%d\n", i, c4[i], i, s4[i]);
  }

  bool good8 = true;
  for (int i=0; i<8; ++i) good8 = good8 && c8[i] == s8[i];
  if (!good8) {
    printf("char8->short8 conversion failed\n");
    for (int i=0; i<8; ++i) printf("  c[%d]=%d s[%d]=%d\n", i, c8[i], i, s8[i]);
  }

  bool good16 = true;
  for (int i=0; i<16; ++i) good16 = good16 && c16[i] == s16[i];
  if (!good16) {
    printf("char16->short16 conversion failed\n");
    for (int i=0; i<16; ++i)
      printf("  c[%d]=%d s[%d]=%d\n", i, c16[i], i, s16[i]);
  }
}


sleef: scalars.cl, templates for a few scalar-argument functions

/* OpenCL built-in library: sleef-pocl/scalars.cl

   Copyright (c) 2017 Michal Babej / Tampere University of Technology

   Permission is hereby granted, free of charge, to any person obtaining a copy
   of this software and associated documentation files (the "Software"), to deal
   in the Software without restriction, including without limitation the rights
   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
   copies of the Software, and to permit persons to whom the Software is
   furnished to do so, subject to the following conditions:

   The above copyright notice and this permission notice shall be included in
   all copies or substantial portions of the Software.

   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
   THE SOFTWARE.
*/

#include "../templates.h"

DEFINE_EXPR_V_VS(fmax, fmax(a, (vtype)b))

DEFINE_EXPR_V_VS(fmin, fmin(a, (vtype)b))

DEFINE_EXPR_V_VI(ldexp, ldexp(a, (jtype)b))

error: pathspec 'lib/kernel/sleef-pocl/scalars.cl' did not match any file(s) known to git


Commit 190296 missed out the tests; add them now. Note that it actually tests
"long long" which is currently technically only "reserved for future" use in OpenCL, but
since clang in OpenCL mode supports it we may as well test the modifications to
the settings made for that type.

git-svn-id: ffe668792ed300d6c2daa1f6eba2e0aa28d7ec6c@190297 91177308-0d34-0410-b5e6-96231b3b80d8

// RUN: %clang_cc1 -x cl %s -verify
// expected-no-diagnostics

// Test the forced language options for OpenCL are set correctly.

__constant int v0[(sizeof(int) == 4) -1];
__constant int v1[(__alignof(int) == 4) -1];
__constant int v2[(sizeof(long) == 8) -1];
__constant int v3[(__alignof(long) == 8) -1];
__constant int v4[(sizeof(long long) == 16) -1];
__constant int v5[(__alignof(long long) == 16) -1];
__constant int v6[(sizeof(float) == 4) -1];
__constant int v7[(__alignof(float) == 4) -1];
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
__constant int v8[(sizeof(double)==8) -1];
__constant int v9[(__alignof(double)==8) -1];
#pragma OPENCL EXTENSION cl_khr_fp16 : enable
__constant int v10[(sizeof(half) == 2) -1];
__constant int v11[(__alignof(half) == 2) -1];

error: pathspec 'test/Misc/languageOptsOpenCL.cl' did not match any file(s) known to git


new shader for line drawing

new shader for line drawing

// simple kernel that copy in into out

static float luminosity(float4 col) {
    return 0.21f * col.x + 0.72f * col.y + 0.07f * col.z;
}

static float4 pattern(int2 loc) {
//    const int depth = (loc.x + loc.y) % 32;
    const int depth = 16;
    float a = ((float)((loc.x * 2 + loc.y) % depth) / (float)depth);
    float b = ((float)((loc.y * 2 + loc.x) % depth) / (float)depth);
    float c = ((float)((loc.x + loc.y) % depth) / (float)depth);
    return (float4)(a, b, c, 1.0f);
}

static float4 RGB2CMY(float4 rgb) {
    return (float4)(1.0f - rgb.x, 1.0f - rgb.y, 1.0f -rgb.z, 1.0f);
}

__kernel void video_image(
    __read_only image2d_t in,
    __write_only image2d_t out)
{
    const sampler_t format =
        CLK_NORMALIZED_COORDS_FALSE |
        CLK_FILTER_NEAREST |
        CLK_ADDRESS_CLAMP;
    const int2 d = (int2)(get_global_id(0), get_global_id(1));
    float4 col = read_imagef(in, format, d);
    // init output image
    float4 pat = pattern(d);
    float4 res = RGB2CMY(col) * pat;
    float4 oc = (float4)(
        (res.x > 0.5f) ? 1.0f : 0.0f,
        (res.y > 0.5f) ? 1.0f : 0.0f,
        (res.z > 0.5f) ? 1.0f : 0.0f,
        1.0f
        );
    write_imagef(out, d, RGB2CMY(oc));
}

error: pathspec 'sources/line_draw.cl' did not match any file(s) known to git


Finished part 2

Finished part 2

;;;
;;;
;;;

(trace dupfilter)
(trace dup)

(defun dupfilter (ele)
	(cond
		((listp ele)
			(reverse (dup ele '()))
		)
		((atom ele)
			ele
		)
		( T nil)
	)
)

(defun dup (lst results)
	(cond
		;; Base case
		((endp lst)  results)
		(
			(endp ( member (car lst) results :test 'equal))
			(dup ( cdr lst) (cons  (car lst) results))
		)
		(
			T
			(dup ( cdr lst) results )
		)
	)
)

;;	(cond
;;		((listp ele)
;;			(counter_helper ele)
;;		)
;;		((atom ele)
;;			NIL
;;		)
;;		( T nil)
;;	)
;;)

error: pathspec 'Project1/dupfilter.cl' did not match any file(s) known to git


some comments

some comments

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/beaylott/bagwacl.git/'


Fix Compilation Errors

Fix Compilation Errors

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/CLBplustree/CLBplustree.git/'


Fix some bugs

Fix some bugs


Added binary operations OpenCL device functions

/*******************************************************
 * Copyright (c) 2014, ArrayFire
 * All rights reserved.
 *
 * This file is distributed under 3-clause BSD license.
 * The complete license agreement can be obtained at:
 * http://arrayfire.com/licenses/BSD-3-Clause
 ********************************************************/

// ADD_OP
T bin_ADD_OP(T lhs, T rhs)
{
    return lhs + rhs;
}

To transform_ADD_OP(Ti in)
{
    return(To)(in);
}

// MUL_OP
T bin_MUL_OP(T lhs, T rhs)
{
    return lhs * rhs;
}

To transform_MUL_OP(Ti in)
{
    return(To)(in);
}

// SUB_OP
T bin_SUB_OP(T lhs, T rhs)
{
    return lhs - rhs;
}

To transform_SUB_OP(Ti in)
{
    return(To)(in);
}

// DIV_OP
T bin_DIV_OP(T lhs, T rhs)
{
    return lhs / rhs;
}

To transform_DIV_OP(Ti in)
{
    return(To)(in);
}

// MIN_OP
T bin_MIN_OP(T lhs, T rhs)
{
    return lhs < rhs ? lhs : rhs;
}

T transform_MIN_OP(T in)
{
    return in;
}

// MAX_OP
T bin_MAX_OP(T lhs, T rhs)
{
    return lhs > rhs ? lhs : rhs;
}

T transform_MAX_OP(T in)
{
    return in;
}

error: pathspec 'src/backend/opencl/kernel/ops.cl' did not match any file(s) known to git


WebSocket: pushing non-working eye kernel

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/beni55/furious.js.git/'


Added comments to cl_mc_kernel.cl

Added comments to cl_mc_kernel.cl

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/HongjianLi/idock.git/'


ocl structure

ocl structure

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/sncn-private/PCL-OCL.git/'


Ran dos2unix on byval_function_argument.cl.

union U
{
  uint a;
  uint b;
};

uint func(union U value)
{
  uint ret = value.a;
  value.b = 777;
  return ret;
}

kernel void byval_function_argument(global uint *output)
{
  union U u = {42};
  output[0] = func(u);
  output[1] = u.b;
}


added kernel for CPU

added kernel for CPU

/** maximum X per block (used in dimensions for blocks and amount of shared memory */
#define SHARED_X ${SHARED_X}
/** maximum Y per block (used in dimensions for blocks and amount of shared memory */
#define SHARED_Y ${SHARED_Y}

/** kernel contains a for-loop in which the score is calculated. */
#define DIAGONAL SHARED_X + SHARED_Y

/** amount of blocks across the X axis */
#define XdivSHARED_X (X/SHARED_X)
/** amount of blocks across the Y axis */
#define YdivSHARED_Y (Y/SHARED_Y)

#define WORKLOAD_X ${WORKLOAD_X}
#define WORKLOAD_Y ${WORKLOAD_Y}
#define WORKGROUP_X (SHARED_X/WORKLOAD_X)
#define WORKGROUP_Y (SHARED_Y/WORKLOAD_Y)

/** start of the alphabet, so scoringsmatrix index can be calculated */
#define characterOffset 'A'
/** character used to fill the sequence if length < X */
#define FILL_CHARACTER 'x'
#define FILL_SCORE -1E10

/** this value is used to allocate enough memory to store the starting points */
#define MAXIMUM_NUMBER_STARTING_POINTS (NUMBER_SEQUENCES*NUMBER_TARGETS*1000)

/**** Other definitions ****/

/** bit mask to get the negative value of a float, or to keep it negative */
#define SIGN_BIT_MASK 0x80000000

/* Scorings matrix for each sequence alignment */
typedef struct {
	float value[X+1][Y+1];
} ScoringsMatrix;

/* Scorings matrix for entire application */
typedef struct {
	ScoringsMatrix metaMatrix[NUMBER_SEQUENCES][NUMBER_TARGETS];
} GlobalMatrix;

typedef struct {
	float value[WORKGROUP_X][WORKGROUP_Y];
}  BlockMaxima;

typedef struct {
	BlockMaxima blockMaxima[XdivSHARED_X][YdivSHARED_Y];
} AlignMaxima;

/* Maximum matrix for entire application */
typedef struct {
	AlignMaxima alignMaxima[NUMBER_SEQUENCES][NUMBER_TARGETS];
} GlobalMaxima;

typedef struct {
	unsigned char value[X][Y];
} Direction;

typedef struct {
	Direction direction[NUMBER_SEQUENCES][NUMBER_TARGETS];
} GlobalDirection;

typedef struct {
	unsigned int sequence;
	unsigned int target;
	unsigned int blockX;
	unsigned int blockY;
	unsigned int valueX;
	unsigned int valueY;
	float score;
	float maxScore;
	float posScore;
} StartingPoint;

typedef struct {
	StartingPoint startingPoint[MAXIMUM_NUMBER_STARTING_POINTS];
} StartingPoints;

typedef struct {
	int s[1];
} Semaphore;

typedef struct {
	Semaphore semaphore[X][Y];
} Semaphores;

typedef struct {
	Semaphores semaphores[NUMBER_SEQUENCES][NUMBER_TARGETS];
} GlobalSemaphores;

__kernel void calculateScore(
		__global GlobalMatrix *matrix, unsigned int x, unsigned int y, unsigned int numberOfBlocks,
		__global char *sequences, __global char *targets, __global GlobalMaxima *globalMaxima, __global GlobalDirection *globalDirection,
		__global float *scoringsMatrix) {
	// calculate indices:
	//unsigned int yDIVnumSeq = (blockIdx.y/NUMBER_SEQUENCES);
	unsigned int blockx = x - get_group_id(1)/NUMBER_TARGETS;//0<=(get_group_id(1)/NUMBER_TARGETS)<numberOfBlocks
	unsigned int blocky = y + get_group_id(1)/NUMBER_TARGETS;//0<=(get_group_id(1)/NUMBER_TARGETS)<numberOfBlocks
	unsigned int tIDx = get_local_id(0);
	unsigned int tIDy = get_local_id(1);
	unsigned int bIDx = get_group_id(0);
	unsigned int bIDy = get_group_id(1)%NUMBER_TARGETS;///numberOfBlocks;

	float thread_max = 0.0;

		for (int i=0; i < WORKGROUP_X + WORKGROUP_Y; ++i) {
		if(i==tIDx+tIDy) {
			for(int j=0; j<WORKLOAD_X; j++) {

				unsigned int aIDx = tIDx*WORKLOAD_X + j + blockx * SHARED_X; //0<=alignmentIDx<X
				unsigned int aXM1 = aIDx;

				++aIDx; //1<=alignmentIDx<=X

				int seqIndex1 = tIDx * WORKLOAD_X + j + bIDx * X + blockx * SHARED_X;
				char s1 = sequences[seqIndex1];

				/** Number of target characters a single work-item is responsible for **/
				for(int k=0; k<WORKLOAD_Y; k++) {

					unsigned char direction = NO_DIRECTION;
					int seqIndex2 = tIDy*WORKLOAD_Y + k + bIDy * Y + blocky * SHARED_Y;
					char s2 = targets[seqIndex2];

					unsigned int aIDy = tIDy*WORKLOAD_Y + k + blocky * SHARED_Y; //0<=alignmentIDy<Y
					unsigned int aYM1 = aIDy;

					++aIDy; //1<=alignmentIDy<=Y

					float currentScore = 0.0;
					float ulS = 0.0;
					float lS = 0.0;
					float uS = 0.0;
					float innerScore = 0.0;

					int offset_x = s1-characterOffset;
					int offset_y = s2-characterOffset;

					innerScore = s1 == FILL_CHARACTER || s2 == FILL_CHARACTER ? FILL_SCORE : scoringsMatrix[(offset_y*SCORINGS_MAT_SIZE) + offset_x];
					ulS = (*matrix).metaMatrix[bIDx][bIDy].value[aXM1][aYM1] + innerScore;
					lS = (*matrix).metaMatrix[bIDx][bIDy].value[aXM1][aIDy] + gapScore;
					uS = (*matrix).metaMatrix[bIDx][bIDy].value[aIDx][aYM1] + gapScore;

					if (currentScore < lS) { // score comes from left
						currentScore = lS;
						direction = LEFT_DIRECTION;
					}
					if (currentScore < uS) { // score comes from above
						currentScore = uS;
						direction = UPPER_DIRECTION;
					}
					if (currentScore < ulS) { // score comes from upper left
						currentScore = ulS;
						direction = UPPER_LEFT_DIRECTION;
					}
					(*matrix).metaMatrix[bIDx][bIDy].value[aIDx][aIDy] = currentScore;
					(*globalDirection).direction[bIDx][bIDy].value[aXM1][aYM1] = direction;
					thread_max = fmax(currentScore, thread_max);

				}
			}

		}
		if(i-1==tIDx+tIDy) { //got a thread_maximum
			if(i==1) {
				//get the maximum value of surrounding blocks
				float maxPrev = 0.0;
				if (blockx && blocky) {
					maxPrev = fmax(fmax(globalMaxima->alignMaxima[bIDx][bIDy].blockMaxima[blockx-1][blocky-1].value[WORKGROUP_X-1][WORKGROUP_Y-1], globalMaxima->alignMaxima[bIDx][bIDy].blockMaxima[blockx-1][blocky].value[WORKGROUP_X-1][WORKGROUP_Y-1]), globalMaxima->alignMaxima[bIDx][bIDy].blockMaxima[blockx][blocky-1].value[WORKGROUP_X-1][WORKGROUP_Y-1]);
				}
				else if (blockx) {
					maxPrev = globalMaxima->alignMaxima[bIDx][bIDy].blockMaxima[blockx-1][blocky].value[WORKGROUP_X-1][WORKGROUP_Y-1];
				}
				else if (blocky) {
					maxPrev = globalMaxima->alignMaxima[bIDx][bIDy].blockMaxima[blockx][blocky-1].value[WORKGROUP_X-1][WORKGROUP_Y-1];
				}

				(*globalMaxima).alignMaxima[bIDx][bIDy].blockMaxima[blockx][blocky].value[0][0] = fmax(maxPrev, thread_max);
			} else if(!tIDx && tIDy) {
				(*globalMaxima).alignMaxima[bIDx][bIDy].blockMaxima[blockx][blocky].value[0][tIDy] = fmax((*globalMaxima).alignMaxima[bIDx][bIDy].blockMaxima[blockx][blocky].value[0][tIDy-1],thread_max);
			} else if(tIDx && !tIDy) {
				(*globalMaxima).alignMaxima[bIDx][bIDy].blockMaxima[blockx][blocky].value[tIDx][0] = fmax((*globalMaxima).alignMaxima[bIDx][bIDy].blockMaxima[blockx][blocky].value[tIDx-1][0],thread_max);
			} else if(tIDx && tIDy) {
				(*globalMaxima).alignMaxima[bIDx][bIDy].blockMaxima[blockx][blocky].value[tIDx][tIDy] = fmax((*globalMaxima).alignMaxima[bIDx][bIDy].blockMaxima[blockx][blocky].value[tIDx-1][tIDy], fmax(thread_max,(*globalMaxima).alignMaxima[bIDx][bIDy].blockMaxima[blockx][blocky].value[tIDx][tIDy-1]));
			}

		}
		barrier(CLK_LOCAL_MEM_FENCE);

	}

	if (tIDx==WORKGROUP_X-1 && tIDy==WORKGROUP_Y-1) {
		(*globalMaxima).alignMaxima[bIDx][bIDy].blockMaxima[blockx][blocky].value[tIDx][tIDy] = fmax(thread_max, fmax((*globalMaxima).alignMaxima[bIDx][bIDy].blockMaxima[blockx][blocky].value[tIDx-1][tIDy], (*globalMaxima).alignMaxima[bIDx][bIDy].blockMaxima[blockx][blocky].value[tIDx][tIDy-1]));
	}
}

__kernel void traceback(
		__global GlobalMatrix *matrix, unsigned int x, unsigned int y, unsigned int numberOfBlocks, __global GlobalMaxima *globalMaxima,
		__global GlobalDirection *globalDirection, volatile __global unsigned int *indexIncrement,
		__global StartingPoints *startingPoints, __global float *maxPossibleScore, int inBlock, __global GlobalSemaphores *globalSemaphores) {

		unsigned int blockx = x - get_group_id(1)/NUMBER_TARGETS;//0<=(get_group_id(1)/NUMBER_TARGETS)<numberOfBlocks
		unsigned int blocky = y + get_group_id(1)/NUMBER_TARGETS;//0<=(get_group_id(1)/NUMBER_TARGETS)<numberOfBlocks
		unsigned int tIDx = get_local_id(0);
		unsigned int tIDy = get_local_id(1);
		unsigned int bIDx = get_group_id(0);
		unsigned int bIDy = get_group_id(1)%NUMBER_TARGETS;///numberOfBlocks;

		float maximum = (*globalMaxima).alignMaxima[bIDx][bIDy].blockMaxima[XdivSHARED_X-1][YdivSHARED_Y-1].value[WORKGROUP_X-1][WORKGROUP_Y-1];

		if(maximum >= MINIMUM_SCORE) {
			float mpScore = maxPossibleScore[bIDx+inBlock];
			for(int i=WORKGROUP_X+WORKGROUP_Y-1; i>=0; --i) {
				if(i==tIDx+tIDy) {
					for(int j=WORKLOAD_X-1; j>=0; j--){
						unsigned int aIDx = tIDx*WORKLOAD_X + j + blockx * SHARED_X; //0<=alignmentIDx<X
						unsigned int aXM1 = aIDx;
						++aIDx; //1<=alignmentIDx<=X
						for(int k=WORKLOAD_Y-1; k>=0; k--) {
							unsigned int aIDy = tIDy*WORKLOAD_Y + k + blocky * SHARED_Y; //0<=alignmentIDy<Y
							unsigned int aYM1 = aIDy;
							++aIDy; //1<=alignmentIDy<=Y
							float score = (*matrix).metaMatrix[bIDx][bIDy].value[aIDx][aIDy];
							unsigned char direction = (*globalDirection).direction[bIDx][bIDy].value[aXM1][aYM1];
							if (direction == UPPER_LEFT_DIRECTION && score >= LOWER_LIMIT_SCORE * maximum && score >= mpScore) {
								// found starting point!
								unsigned int index = atom_inc(&indexIncrement[0]);
								// now copy this to host:
								StartingPoint start;
				                start.sequence = bIDx;
				                start.target = bIDy;
				                start.blockX = blockx;
				                start.blockY = blocky;
				                start.valueX = tIDx;
				                start.valueY = tIDy;
								start.score = (*matrix).metaMatrix[bIDx][bIDy].value[aIDx][aIDy];
								start.maxScore = maximum;
								start.posScore = mpScore;
								startingPoints->startingPoint[index] = start;
								//Mark this value
#ifdef NVIDIA
								(*matrix).metaMatrix[bIDx][bIDy].value[aIDx][aIDy] = __int_as_float(SIGN_BIT_MASK | __float_as_int(score);
#else
								(*matrix).metaMatrix[bIDx][bIDy].value[aIDx][aIDy] = as_float(SIGN_BIT_MASK | as_int(score));
#endif
							}
							score = (*matrix).metaMatrix[bIDx][bIDy].value[aIDx][aIDy];
							if (score < 0 && direction == UPPER_LEFT_DIRECTION) {
								score = (*matrix).metaMatrix[bIDx][bIDy].value[aIDx-1][aIDy-1];
								if (score == 0.0) {
									direction = STOP_DIRECTION;
									globalDirection->direction[bIDx][bIDy].value[aXM1][aYM1] = direction;
								}
								else {
									getSemaphore(&((*globalSemaphores).semaphores[bIDx][bIDy].semaphore[aXM1-1][aYM1-1].s[0]));
#ifdef NVIDIA
									(*matrix).metaMatrix[bIDx][bIDy].value[aIDx-1][aIDy-1] = __int_as_float(SIGN_BIT_MASK | __float_as_int(score));
#else
									(*matrix).metaMatrix[bIDx][bIDy].value[aIDx-1][aIDy-1] = as_float(SIGN_BIT_MASK | as_int(score));
#endif
									releaseSemaphore(&((*globalSemaphores).semaphores[bIDx][bIDy].semaphore[aXM1-1][aYM1-1].s[0]));
								}
							}
							if (score < 0 && direction == LEFT_DIRECTION) {
								score = (*matrix).metaMatrix[bIDx][bIDy].value[aIDx-1][aIDy];
								if (score == 0.0) {
									direction = STOP_DIRECTION;
									globalDirection->direction[bIDx][bIDy].value[aXM1][aYM1] = direction;
								}
								else {
									getSemaphore(&((*globalSemaphores).semaphores[bIDx][bIDy].semaphore[aXM1-1][aYM1].s[0]));
#ifdef NVIDIA
									(*matrix).metaMatrix[bIDx][bIDy].value[aIDx-1][aIDy] = __int_as_float(SIGN_BIT_MASK | __float_as_int(score));
#else
									(*matrix).metaMatrix[bIDx][bIDy].value[aIDx-1][aIDy] = as_float(SIGN_BIT_MASK | as_int(score));
#endif
									releaseSemaphore(&((*globalSemaphores).semaphores[bIDx][bIDy].semaphore[aXM1-1][aYM1].s[0]));
								}
							}
							if (score < 0 && direction == UPPER_DIRECTION) {
								score = (*matrix).metaMatrix[bIDx][bIDy].value[aIDx][aIDy-1];
								if (score == 0.0) {
									direction = STOP_DIRECTION;
									globalDirection->direction[bIDx][bIDy].value[aXM1][aYM1] = direction;
								}
								else {
									getSemaphore(&((*globalSemaphores).semaphores[bIDx][bIDy].semaphore[aXM1][aYM1-1].s[0]));
#ifdef NVIDIA
									(*matrix).metaMatrix[bIDx][bIDy].value[aIDx][aIDy-1] = __int_as_float(SIGN_BIT_MASK | __float_as_int(score));
#else
									(*matrix).metaMatrix[bIDx][bIDy].value[aIDx][aIDy-1] = as_float(SIGN_BIT_MASK | as_int(score));
#endif
									releaseSemaphore(&((*globalSemaphores).semaphores[bIDx][bIDy].semaphore[aXM1][aYM1-1].s[0]));
								}
							}

						}
					}

				}
				barrier(CLK_LOCAL_MEM_FENCE);
			}
		}
}

error: pathspec 'pyPaSWAS/Core/ocl/default_main_cpu.cl' did not match any file(s) known to git


Uncommented idock.cl

Uncommented idock.cl


Correct printf usage in test case

Correct printf usage in test case

kernel void test_kernel() {
  printf("global: %d-%d-%d\n",
           (int)get_global_id(0),
           (int)get_global_id(1),
           (int)get_global_id(2));
  printf("local: %d-%d-%d\n",
           (int)get_local_id(0),
           (int)get_local_id(1),
           (int)get_local_id(2));
}

kernel void test_kernel() {
  printf("global: %zd-%zd-%zd\n",
           get_global_id(0),
           get_global_id(1),
           get_global_id(2));
  printf("local: %zd-%zd-%zd\n",
           get_local_id(0),
           get_local_id(1),
           get_local_id(2));
}


implemented downsweep

implemented downsweep

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/Saytiras/Massively-Parallel-Algorithms.git/'


kernel function for LCALIF update sate - now includes traces and Vth rule adaptation

git-svn-id: 602a26e73ae9f2a14e2bb95676f2e137fcc39919@5717 7c0444ca-5550-0410-9008-faecdbe78eb5

#include "LIF_params.h"
#include "cl_random.hcl"

#ifndef PV_USE_OPENCL
#  include <math.h>
#  define EXP expf
#  define CL_KERNEL
#  define CL_MEM_GLOBAL
#  define CL_MEM_CONST
#  define CL_MEM_LOCAL
#else  /* compiling with OpenCL */
#  define EXP exp
#  define CL_KERNEL       __kernel
#  define CL_MEM_GLOBAL   __global
#  define CL_MEM_CONST    __constant
#  define CL_MEM_LOCAL    __local
#  include "conversions.hcl"
#  define CHANNEL_EXC   0
#  define CHANNEL_INH   1
#  define CHANNEL_INHB  2
#  define CHANNEL_GAP   3
#endif

//#undef USE_CLRANDOM
#ifndef USE_CLRANDOM
#  include "../utils/pv_random.h"
#endif

inline
float LIFGap_Vmem_derivative(
      const float Vmem,
      const float G_E,
      const float G_I,
      const float G_IB,
      const float G_Gap,
      const float V_E,
      const float V_I,
      const float V_IB,
      const float sum_gap,
      const float Vrest,
      const float tau) {
   float totalconductance = 1.0 + G_E + G_I + G_IB + sum_gap;
   float Vmeminf = (Vrest + V_E*G_E + V_I*G_I + V_IB*G_IB + G_Gap)/totalconductance;
   return totalconductance*(Vmeminf-Vmem)/tau;
}

//
// update the state of a LIFGap layer (spiking)
//
//    assume called with 1D kernel
//
// LCALIF_update_state_beginning uses a Heun scheme for V, using values of the conductances at both the beginning and end of the timestep.  Spikes in the input are applied at the beginning of the timestep.
//
CL_KERNEL
void LCALIF_update_state(
    const int numNeurons,
    const float time,
    const float dt,

    const int nx,
    const int ny,
    const int nf,
    const int nb,

    const float tau_LCA,
    const float tau_thr,
    const float targetRate,

    pvdata_t * integratedSpikeCount,

    CL_MEM_CONST LIF_params * params,
    CL_MEM_GLOBAL uint4 * rnd,
    CL_MEM_GLOBAL float * V,
    CL_MEM_GLOBAL float * Vth,
    CL_MEM_GLOBAL float * G_E,
    CL_MEM_GLOBAL float * G_I,
    CL_MEM_GLOBAL float * G_IB,
    CL_MEM_GLOBAL float * GSynHead,
//    CL_MEM_GLOBAL float * GSynExc,
//    CL_MEM_GLOBAL float * GSynInh,
//    CL_MEM_GLOBAL float * GSynInhB,
//    CL_MEM_GLOBAL float * GSynGap,
    CL_MEM_GLOBAL float * activity,

    const float sum_gap,
    CL_MEM_GLOBAL float * G_Gap)
{
   int k;

   const float exp_tauE    = EXP(-dt/params->tauE);
   const float exp_tauI    = EXP(-dt/params->tauI);
   const float exp_tauIB   = EXP(-dt/params->tauIB);
   const float exp_tauVth  = EXP(-dt/params->tauVth);

   const float dt_sec = .001 * dt;   // convert to seconds

#ifndef PV_USE_OPENCL

for (k = 0; k < nx*ny*nf; k++) {
#else
   k = get_global_id(0);
#endif

   int kex = kIndexExtended(k, nx, ny, nf, nb);

   //
   // kernel (nonheader part) begins here
   //

   // local param variables
   float tau, Vrest, VthRest, Vexc, Vinh, VinhB, deltaVth;

   // const float GMAX = 10.0;

   // local variables
   float l_activ;

   uint4 l_rnd = rnd[k];

   float l_V   = V[k];
   float l_Vth = Vth[k];

   // The correction factors to the conductances are so that if l_GSyn_* is the same every timestep,
   // then the asymptotic value of l_G_* will be l_GSyn_*
   float l_G_E  = G_E[k];
   float l_G_I  = G_I[k];
   float l_G_IB = G_IB[k];
   float l_G_Gap = G_Gap[k];

   CL_MEM_GLOBAL float * GSynExc = &GSynHead[CHANNEL_EXC*numNeurons];
   CL_MEM_GLOBAL float * GSynInh = &GSynHead[CHANNEL_INH*numNeurons];
   CL_MEM_GLOBAL float * GSynInhB = &GSynHead[CHANNEL_INHB*numNeurons];
   CL_MEM_GLOBAL float * GSynGap = &GSynHead[CHANNEL_GAP*numNeurons];
   float l_GSynExc  = GSynExc[k];
   float l_GSynInh  = GSynInh[k];
   float l_GSynInhB = GSynInhB[k];
   float l_GSynGap  = GSynGap[k];

   // define local param variables
   //
   tau        = params->tau;
   tau_LCA    = params->tau_LCA;
   tau_thr    = params->tau_thr;
   targetRate = params->targetRate;
   Vexc       = params->Vexc;
   Vinh       = params->Vinh;
   VinhB      = params->VinhB;
   Vrest      = params->Vrest;

   VthRest  = params->VthRest;
   deltaVth = params->deltaVth;

   // add noise
   //

#ifdef USE_CLRANDOM
   l_rnd = cl_random_get(l_rnd);
   if (cl_random_prob(l_rnd) < dt_sec*params->noiseFreqE) {
      l_rnd = cl_random_get(l_rnd);
      l_GSynExc = l_GSynExc + params->noiseAmpE*cl_random_prob(l_rnd);
   }

   l_rnd = cl_random_get(l_rnd);
   if (cl_random_prob(l_rnd) < dt_sec*params->noiseFreqI) {
      l_rnd = cl_random_get(l_rnd);
      l_GSynInh = l_GSynInh + params->noiseAmpI*cl_random_prob(l_rnd);
   }

   l_rnd = cl_random_get(l_rnd);
   if (cl_random_prob(l_rnd) < dt_sec*params->noiseFreqIB) {
      l_rnd = cl_random_get(l_rnd);
      l_GSynInhB = l_GSynInhB + params->noiseAmpIB*cl_random_prob(l_rnd);
   }
#else
   if (pv_random_prob() < dt_sec*params->noiseFreqE) {
      l_GSynExc = l_GSynExc + params->noiseAmpE*pv_random_prob();
   }

   if (pv_random_prob() < dt_sec*params->noiseFreqI) {
      l_GSynInh = l_GSynInh + params->noiseAmpI*pv_random_prob();
   }

   if (pv_random_prob() < dt_sec*params->noiseFreqIB) {
      l_GSynInhB = l_GSynInhB + params->noiseAmpIB*pv_random_prob();
   }
#endif

   const float GMAX = 10.0;

   // The portion of code below uses the newer method of calculating l_V.
   float G_E_initial, G_I_initial, G_IB_initial, G_E_final, G_I_final, G_IB_final;
   float dV1, dV2, dV;

   G_E_initial = l_G_E + l_GSynExc;
   G_I_initial = l_G_I + l_GSynInh;
   G_IB_initial = l_G_IB + l_GSynInhB;

   G_E_initial  = (G_E_initial  > GMAX) ? GMAX : G_E_initial;
   G_I_initial  = (G_I_initial  > GMAX) ? GMAX : G_I_initial;
   G_IB_initial = (G_IB_initial > GMAX) ? GMAX : G_IB_initial;

   G_E_final = G_E_initial*exp_tauE;
   G_I_final = G_I_initial*exp_tauI;
   G_IB_final = G_IB_initial*exp_tauIB;

   l_G_Gap = l_GSynGap;

   dV1 = LIFGap_Vmem_derivative(l_V, G_E_initial, G_I_initial, G_IB_initial, l_G_Gap, Vexc, Vinh, VinhB, sum_gap, Vrest, tau);
   dV2 = LIFGap_Vmem_derivative(l_V+dt*dV1, G_E_final, G_I_final, G_IB_final, l_G_Gap, Vexc, Vinh, VinhB, sum_gap, Vrest, tau);
   dV = (dV1+dV2)*0.5;
   l_V = l_V + dt*dV;

   l_G_E = G_E_final;
   l_G_I = G_I_final;
   l_G_IB = G_IB_final;

   //integratedSpikeCount is the trace activity of the neuron, with an exponential decay
   integratedSpikeCount[k] += activity[k] - (dt * integratedSpikeCount[k]/tau_LCA);

   //l_Vth updates according to traditional LIF rule in addition to the following slow threshold adaptation
   //   Theta += dt/tau_thr [int_spike_count/tau_lca - fo]
   //      tau_thr is slow update
   //      tau_lca is ~1/5 tau_thr, faster update for traces
   //      int_spike_count is trace
   //      fo is desired baseline spike rate
   l_Vth = VthRest + (l_Vth - VthRest)*exp_tauVth + (-dt/tau_thr * integratedSpikeCount[k]/tau_LCA - targetRate);

   bool fired_flag = (l_V > l_Vth);

   l_activ = fired_flag ? 1.0f             : 0.0f;
   l_V     = fired_flag ? Vrest            : l_V;
   l_Vth   = fired_flag ? l_Vth + deltaVth : l_Vth;
   l_G_IB  = fired_flag ? l_G_IB + 1.0f    : l_G_IB;

   //
   // These actions must be done outside of kernel
   //    1. set activity to 0 in boundary (if needed)
   //    2. update active indices
   //

   // store local variables back to global memory
   //
   rnd[k] = l_rnd;

   activity[kex] = l_activ;

   V[k]   = l_V;
   Vth[k] = l_Vth;

   G_E[k]  = l_G_E; // G_E_final;
   G_I[k]  = l_G_I; // G_I_final;
   G_IB[k] = l_G_IB; // G_IB_final;
   G_Gap[k] = l_G_Gap;

   GSynExc[k]  = 0.0f;
   GSynInh[k]  = 0.0f;
   GSynInhB[k] = 0.0f;
   GSynGap[k]  = 0.0f;

#ifndef PV_USE_OPENCL
   } // loop over k
#endif

}

error: pathspec 'src/kernels/LCALIF_update_state.cl' did not match any file(s) known to git


save, not finished yet

save, not finished yet

#include "common.h"

inline int stringCmp(__global char * buf1, __global char * buf2, int size){
        int i;
        int res = 0;
        for(i=0;i<size;i++){
                if(buf1[i] > buf2[i]){
                        res = 1;
                        break;
                }else if (buf1[i] < buf2[i]){
                        res = -1;
                        break;
                }
                if(buf1[i] == 0 && buf2[i] == 0)
                        break;
        }
        return res;
}

inline int testCon(__global char *buf1, __global char* buf2, int size, int type, int rel){
        int res = 1;
        if (type == INT){
                if(rel == EQ){
                        res = ( *((int*)buf1) == *(((int*)buf2)) );
                }else if (rel == GTH){
                        res = ( *((int*)buf1) > *(((int*)buf2)) );
                }else if (rel == LTH){
                        res = ( *((int*)buf1) < *(((int*)buf2)) );
                }else if (rel == GEQ){
                        res = ( *((int*)buf1) >= *(((int*)buf2)) );
                }else if (rel == LEQ){
                        res = ( *((int*)buf1) <= *(((int*)buf2)) );
                }

        }else if (type == FLOAT){
                if(rel == EQ){
                        res = ( *((float*)buf1) == *(((float*)buf2)) );
                }else if (rel == GTH){
                        res = ( *((float*)buf1) > *(((float*)buf2)) );
                }else if (rel == LTH){
                        res = ( *((float*)buf1) < *(((float*)buf2)) );
                }else if (rel == GEQ){
                        res = ( *((float*)buf1) >= *(((float*)buf2)) );
                }else if (rel == LEQ){
                        res = ( *((float*)buf1) <= *(((float*)buf2)) );
                }

        }else{
                int tmp = stringCmp(buf1,buf2,size);
                if(rel == EQ){
                        res = (tmp == 0);
                }else if (rel == GTH){
                        res = (tmp > 0);
                }else if (rel == LTH){
                        res = (tmp < 0);
                }else if (rel == GEQ){
                        res = (tmp >= 0);
                }else if (rel == LEQ){
                        res = (tmp <= 0);
                }
        }
        return res;
}

inline void memcpy_cl(__global char * dst, __global char * src, int length){

	for(int i=0;i<length;i++){
		dst[i] = src[i];
	}

}

__kernel void transform_dict_filter_and(__global int * dictFilter, __global char *fact, long tupleNum, int dNum,  __global int * filter, int byteNum){

	size_t stride = get_global_size(0);
	size_t offset = get_global_id(0);

        int numInt = (tupleNum * byteNum +sizeof(int) - 1) / sizeof(int) ;

        for(size_t i=offset; i<numInt; i += stride){
                int tmp = ((int *)fact)[i];
                unsigned long bit = 1;

                for(int j=0; j< sizeof(int)/byteNum; j++){
                        int t = (bit << ((j+1)*byteNum*8)) -1 - ((1<<(j*byteNum*8))-1);
                        int fkey = (tmp & t)>> (j*byteNum*8) ;
                        filter[i* sizeof(int)/byteNum + j] &= dictFilter[fkey];
                }
        }
}

__kernel void transform_dict_filter_or(__global int * dictFilter, __global char *fact, long tupleNum, int dNum,  __global int * filter,int byteNum){

	size_t stride = get_global_size(0);
	size_t offset = get_global_id(0);

        int numInt = (tupleNum * byteNum +sizeof(int) - 1) / sizeof(int) ;

        for(size_t i=offset; i<numInt; i += stride){
                int tmp = ((int *)fact)[i];
                unsigned long bit = 1;

                for(int j=0; j< sizeof(int)/byteNum; j++){
                        int t = (bit << ((j+1)*byteNum*8)) -1 - ((1<<(j*byteNum*8))-1);
                        int fkey = (tmp & t)>> (j*byteNum*8) ;
                        filter[i* sizeof(int)/byteNum + j] |= dictFilter[fkey];
                }
        }
}

__kernel void genScanFilter_dict_or(__global char *col, int colSize, int colType, int dNum, __global struct whereExp *where, __global int *dfilter){
	size_t stride = get_global_size(0);
	size_t tid = get_global_id(0);
        int con;

        struct dictHeader *dheader = (struct dictHeader *) col;

        for(size_t i=tid;i<dNum;i+=stride){
                int fkey = dheader->hash[i];
                con = testCon((char *)&fkey,where->content,colSize,colType,where->relation);
                dfilter[i] |= con;
        }
}

__kernel void genScanFilter_dict_and(__global char *col, int colSize, int colType, int dNum, __global struct whereExp *where, __global int *dfilter){
	size_t stride = get_global_size(0);
	size_t tid = get_global_id(0);
        int con;

        struct dictHeader *dheader = (struct dictHeader *) col;

        for(size_t i=tid;i<dNum;i+=stride){
                int fkey = dheader->hash[i];
                con = testCon((char *)&fkey,where->content,colSize,colType,where->relation);
                dfilter[i] &= con;
        }
}

__kernel void genScanFilter_rle(__global char *col, int colSize, int colType, long tupleNum, long tupleOffset, __global struct whereExp *where, int andOr, __global int * filter){
	size_t stride = get_global_size(0);
	size_t tid = get_global_id(0);
        int con;

        struct rleHeader *rheader = (struct rleHeader *) col;
        int dNum = rheader->dictNum;

        for(size_t i = tid; i<dNum; i += stride){
                int fkey = ((int *)(col+sizeof(struct rleHeader)))[i];
                int fcount = ((int *)(col+sizeof(struct rleHeader)))[i + dNum];
                int fpos = ((int *)(col+sizeof(struct rleHeader)))[i + 2*dNum];

                if((fcount + fpos) < tupleOffset)
                        continue;

                if(fpos >= (tupleOffset + tupleNum))
                        break;

                con = testCon((char *)&fkey,where->content,colSize,colType,where->relation);

                if(fpos < tupleOffset){
                        int tcount = fcount + fpos - tupleOffset;
                        if(tcount > tupleNum)
                                tcount = tupleNum;
                        for(int k=0;k<tcount;k++){
                                if(andOr == AND)
                                        filter[k] &= con;
                                else
                                        filter[k] |= con;
                        }

                }else if((fpos + fcount) > (tupleOffset + tupleNum)){
                        int tcount = tupleOffset + tupleNum - fpos ;
                        for(int k=0;k<tcount;k++){
                                if(andOr == AND)
                                        filter[fpos+k-tupleOffset] &= con;
                                else
                                        filter[fpos+k-tupleOffset] |= con;
                        }
                }else{
                        for(int k=0;k<fcount;k++){
                                if(andOr == AND)
                                        filter[fpos+k-tupleOffset] &= con;
                                else
                                        filter[fpos+k-tupleOffset] |= con;
                        }

                }
        }
}

__kernel void genScanFilter_and(__global char *col, int colSize, int  colType, long tupleNum, __global struct whereExp * where, __global int * filter){
	size_t stride = get_global_size(0);
	size_t tid = get_global_id(0);
        int con;

        for(size_t i = tid; i<tupleNum;i+=stride){
                con = testCon(col+colSize*i,where->content,colSize,colType,where->relation);
                filter[i] &= con;
        }
}

__kernel void genScanFilter_and_int_eq(__global char *col, long tupleNum, int where, __global int * filter){
	size_t stride = get_global_size(0);
	size_t tid = get_global_id(0);
        int con;

        for(size_t i = tid; i<tupleNum;i+=stride){
                con = ((int*)col)[i] == where;
                filter[i] &= con;
        }
}

__kernel void genScanFilter_and_float_eq(__global char *col, long tupleNum, float where, __global int * filter){
	size_t stride = get_global_size(0);
	size_t tid = get_global_id(0);
        int con;

        for(size_t i = tid; i<tupleNum;i+=stride){
                con = ((float*)col)[i] == where;
                filter[i] &= con;
        }
}

__kernel void genScanFilter_and_int_geq(__global char *col, long tupleNum, int where, __global int * filter){
	size_t stride = get_global_size(0);
	size_t tid = get_global_id(0);
        int con;

        for(size_t i = tid; i<tupleNum;i+=stride){
                con = ((int*)col)[i] >= where;
                filter[i] &= con;
        }
}

__kernel void genScanFilter_and_float_geq(__global char *col, long tupleNum, float where, __global int * filter){
	size_t stride = get_global_size(0);
	size_t tid = get_global_id(0);
        int con;

        for(size_t i = tid; i<tupleNum;i+=stride){
                con = ((float*)col)[i] >= where;
                filter[i] &= con;
        }
}

__kernel void genScanFilter_and_int_leq(__global char *col, long tupleNum, int where, __global int * filter){
	size_t stride = get_global_size(0);
	size_t tid = get_global_id(0);
        int con;

        for(size_t i = tid; i<tupleNum;i+=stride){
                con = ((int*)col)[i] <= where;
                filter[i] &= con;
        }
}

__kernel void genScanFilter_and_float_leq(__global char *col, long tupleNum, float where, __global int * filter){
	size_t stride = get_global_size(0);
	size_t tid = get_global_id(0);
        int con;

        for(size_t i = tid; i<tupleNum;i+=stride){
                con = ((float*)col)[i] <= where;
                filter[i] &= con;
        }
}

__kernel void genScanFilter_and_int_gth(__global char *col, long tupleNum, int where, __global int * filter){
	size_t stride = get_global_size(0);
	size_t tid = get_global_id(0);
        int con;

        for(size_t i = tid; i<tupleNum;i+=stride){
                con = ((int*)col)[i] > where;
                filter[i] &= con;
        }
}

__kernel void genScanFilter_and_float_gth(__global char *col, long tupleNum, float where, __global int * filter){
	size_t stride = get_global_size(0);
	size_t tid = get_global_id(0);
        int con;

        for(size_t i = tid; i<tupleNum;i+=stride){
                con = ((float*)col)[i] > where;
                filter[i] &= con;
        }
}

__kernel void genScanFilter_and_int_lth(__global char *col, long tupleNum, int where, __global int * filter){
	size_t stride = get_global_size(0);
	size_t tid = get_global_id(0);
        int con;

        for(size_t i = tid; i<tupleNum;i+=stride){
                con = ((int*)col)[i] < where;
                filter[i] &= con;
        }
}

__kernel void genScanFilter_and_float_lth(__global char *col, long tupleNum, float where, __global int * filter){
	size_t stride = get_global_size(0);
	size_t tid = get_global_id(0);
        int con;

        for(size_t i = tid; i<tupleNum;i+=stride){
                con = ((float*)col)[i] < where;
                filter[i] &= con;
        }
}

__kernel void genScanFilter_or(__global char *col, int colSize, int  colType, long tupleNum, __global struct whereExp * where, __global int * filter){
	size_t stride = get_global_size(0);
	size_t tid = get_global_id(0);
        int con;
        int rel = where->relation;

        for(size_t i = tid; i<tupleNum;i+=stride){
                con = testCon(col+colSize*i,where->content,colSize,colType, rel);
                filter[i] |= con;
        }
}

__kernel void genScanFilter_or_int_eq(__global char *col, long tupleNum, int where, __global int * filter){
	size_t stride = get_global_size(0);
	size_t tid = get_global_id(0);
        int con;

        for(size_t i = tid; i<tupleNum;i+=stride){
                con = ((int*)col)[i] == where;
                filter[i] |= con;
        }
}
__kernel void genScanFilter_or_float_eq(__global char *col, long tupleNum, float where, __global int * filter){
	size_t stride = get_global_size(0);
	size_t tid = get_global_id(0);
        int con;

        for(size_t i = tid; i<tupleNum;i+=stride){
                con = ((float*)col)[i] == where;
                filter[i] |= con;
        }
}
__kernel void genScanFilter_or_int_gth(__global char *col, long tupleNum, int where, __global int * filter){
	size_t stride = get_global_size(0);
	size_t tid = get_global_id(0);
        int con;

        for(size_t i = tid; i<tupleNum;i+=stride){
                con = ((int*)col)[i] > where;
                filter[i] |= con;
        }
}

__kernel void genScanFilter_or_float_gth(__global char *col, long tupleNum, float where, __global int * filter){
	size_t stride = get_global_size(0);
	size_t tid = get_global_id(0);
        int con;

        for(size_t i = tid; i<tupleNum;i+=stride){
                con = ((float*)col)[i] > where;
                filter[i] |= con;
        }
}

__kernel void genScanFilter_or_int_lth(__global char *col, long tupleNum, int where, __global int * filter){
	size_t stride = get_global_size(0);
	size_t tid = get_global_id(0);
        int con;

        for(size_t i = tid; i<tupleNum;i+=stride){
                con = ((int*)col)[i] < where;
                filter[i] |= con;
        }
}
__kernel void genScanFilter_or_float_lth(__global char *col, long tupleNum, float where, __global int * filter){
	size_t stride = get_global_size(0);
	size_t tid = get_global_id(0);
        int con;

        for(size_t i = tid; i<tupleNum;i+=stride){
                con = ((float*)col)[i] < where;
                filter[i] |= con;
        }
}
__kernel void genScanFilter_or_int_geq(__global char *col, long tupleNum, int where, __global int * filter){
	size_t stride = get_global_size(0);
	size_t tid = get_global_id(0);
        int con;

        for(size_t i = tid; i<tupleNum;i+=stride){
                con = ((int*)col)[i] >= where;
                filter[i] |= con;
        }
}
__kernel void genScanFilter_or_float_geq(__global char *col, long tupleNum, float where, __global int * filter){
	size_t stride = get_global_size(0);
	size_t tid = get_global_id(0);
        int con;

        for(size_t i = tid; i<tupleNum;i+=stride){
                con = ((float*)col)[i] >= where;
                filter[i] |= con;
        }
}

__kernel void genScanFilter_or_int_leq(__global char *col, long tupleNum, int where, __global int * filter){
	size_t stride = get_global_size(0);
	size_t tid = get_global_id(0);
        int con;

        for(size_t i = tid; i<tupleNum;i+=stride){
                con = ((int*)col)[i] <= where;
                filter[i] |= con;
        }
}
__kernel void genScanFilter_or_float_leq(__global char *col, long tupleNum, float where, __global int * filter){
	size_t stride = get_global_size(0);
	size_t tid = get_global_id(0);
        int con;

        for(size_t i = tid; i<tupleNum;i+=stride){
                con = ((float*)col)[i] <= where;
                filter[i] |= con;
        }
}

__kernel void countScanNum(__global int *filter, long tupleNum, __global int * count){
	size_t stride = get_global_size(0);
	size_t tid = get_global_id(0);
        int localCount = 0;

        for(size_t i = tid; i<tupleNum; i += stride){
                localCount += filter[i];
        }

        count[tid] = localCount;

}

__kernel void scan_dict_other(__global char *col, __global char * dict, int byteNum,int colSize, long tupleNum, __global int *psum, long resultNum, __global int * filter, __global char * result){

	size_t stride = get_global_size(0);
	size_t tid = get_global_id(0);
        struct dictHeader *dheader = (struct dictHeader*)dict;
        int pos = psum[tid] * colSize;

        for(size_t i = tid; i<tupleNum; i+= stride){
                if(filter[i] == 1){
                        int key = 0;
                        memcpy_cl(&key, col + sizeof(struct dictHeader) + i* dheader->bitNum/8, dheader->bitNum/8);
                        memcpy_cl(result+pos,&dheader->hash[key],colSize);
                        pos += colSize;
                }
        }
}

__kernel void scan_dict_int(__global char *col, __global char * dict,int byteNum,int colSize, long tupleNum, __global int *psum, long resultNum, __global int * filter, __global char * result){

	size_t stride = get_global_size(0);
	size_t tid = get_global_id(0);
        int localCount = psum[tid];
        struct dictHeader *dheader = (struct dictHeader*)dict;

        for(size_t i = tid; i<tupleNum; i+= stride){
                if(filter[i] == 1){
                        int key = 0;
                        memcpy_cl(&key, col + i*byteNum, byteNum);
                        ((int *)result)[localCount] = dheader->hash[key];
                        localCount ++;
                }
        }
}

__kernel void scan_other(__global char *col, int colSize, long tupleNum, __global int *psum, long resultNum, __global int * filter, __global char * result){
	size_t stride = get_global_size(0);
	size_t tid = get_global_id(0);
        int pos = psum[tid]  * colSize;

        for(size_t i = tid; i<tupleNum;i+=stride){

                if(filter[i] == 1){
                        memcpy_cl(result+pos,col+i*colSize,colSize);
                        pos += colSize;
                }
        }
}

__kernel void scan_int(__global char *col, int colSize, long tupleNum, __global int *psum, long resultNum, __global int * filter, __global char * result){
	size_t stride = get_global_size(0);
	size_t tid = get_global_id(0);
        int localCount = psum[tid] ;

        for(size_t i = tid; i<tupleNum;i+=stride){

                if(filter[i] == 1){
                        ((int*)result)[localCount] = ((int*)col)[i];
                        localCount ++;
                }
        }
}

__kernel void unpack_rle(__global char * fact, __global char * rle, long tupleNum, long tupleOffset, int dNum){

	size_t stride = get_global_size(0);
	size_t offset = get_global_id(0);

        for(size_t i=offset; i<dNum; i+=stride){

                int fvalue = ((int *)(fact+sizeof(struct rleHeader)))[i];
                int fcount = ((int *)(fact+sizeof(struct rleHeader)))[i + dNum];
                int fpos = ((int *)(fact+sizeof(struct rleHeader)))[i + 2*dNum];

                if((fcount + fpos) < tupleOffset)
                        continue;

                if(fpos >= (tupleOffset + tupleNum))
                        break;

                if(fpos < tupleOffset){
                        int tcount = fcount + fpos - tupleOffset;
                        if(tcount > tupleNum)
                                tcount = tupleNum;
                        for(int k=0;k<tcount;k++){
                                ((int*)rle)[k] = fvalue;
                        }

                }else if ((fpos + fcount) > (tupleOffset + tupleNum)){
                        int tcount = tupleNum  + tupleOffset - fpos;
                        for(int k=0;k<tcount;k++){
                                ((int*)rle)[fpos-tupleOffset + k] = fvalue;
                        }

                }else{
                        for(int k=0;k<fcount;k++){
                                ((int*)rle)[fpos-tupleOffset + k] = fvalue;
                        }
                }
        }
}

//The following kernels are for traditional hash joins

__kernel void count_hash_num(__global char *dim, long  inNum, __global int *num){
	size_t stride = get_global_size(0);
	size_t offset = get_global_id(0);

        for(size_t i=offset;i<inNum;i+=stride){
                int joinKey = ((int *)dim)[i];
                int hKey = joinKey & (HSIZE-1);
                atomic_add(&(num[hKey]),1);
        }
}

__kernel void build_hash_table(__global char *dim, long inNum, __global int *psum, __global char * bucket){

	size_t stride = get_global_size(0);
	size_t offset = get_global_id(0);

        for(size_t i=offset;i<inNum;i+=stride){
                int joinKey = ((int *) dim)[i];
                int hKey = joinKey & (HSIZE-1);
                int pos = atomic_add(&psum[hKey],1) * 2;
                ((int*)bucket)[pos] = joinKey;
                pos += 1;
                int dimId = i+1;
                ((int*)bucket)[pos] = dimId;
        }

}

__kernel void count_join_result_dict(__global int *num, __global int* psum, __global char* bucket, __global char* fact, int dNum, __global int* dictFilter){

	size_t stride = get_global_size(0);
	size_t offset = get_global_id(0);

        struct dictHeader *dheader;
        dheader = (struct dictHeader *) fact;

        for(size_t i=offset;i<dNum;i+=stride){
                int fkey = dheader->hash[i];
                int hkey = fkey &(HSIZE-1);
                int keyNum = num[hkey];

                for(int j=0;j<keyNum;j++){
                        int pSum = psum[hkey];
                        int dimKey = ((int *)(bucket))[2*j + 2*pSum];
                        int dimId = ((int *)(bucket))[2*j + 2*pSum + 1];
                        if( dimKey == fkey){
                                dictFilter[i] = dimId;
                                break;
                        }
                }
        }

}

__kernel void transform_dict_filter(__global int * dictFilter, __global char *fact, long tupleNum, int dNum,  __global int * filter){

	size_t stride = get_global_size(0);
	size_t offset = get_global_id(0);

        struct dictHeader *dheader;
        dheader = (struct dictHeader *) fact;

        int byteNum = dheader->bitNum/8;
        int numInt = (tupleNum * byteNum +sizeof(int) - 1) / sizeof(int)  ;

        for(size_t i=offset; i<numInt; i += stride){
                int tmp = ((int *)(fact + sizeof(struct dictHeader)))[i];

                for(int j=0; j< sizeof(int)/byteNum; j++){
                        int fkey = 0;
                        memcpy_cl(&fkey, ((char *)&tmp) + j*byteNum, byteNum);

                        filter[i* sizeof(int)/byteNum + j] = dictFilter[fkey];
                }
        }
}

__kernel void filter_count(long tupleNum, __global int * count, __global int * factFilter){

        int lcount = 0;
	size_t stride = get_global_size(0);
	size_t offset = get_global_id(0);

        for(size_t i=offset; i<tupleNum; i+=stride){
                if(factFilter[i] !=0)
                        lcount ++;
        }
        count[offset] = lcount;
}

__kernel void count_join_result_rle(__global int* num, __global int* psum, __global char* bucket, __global char* fact, long tupleNum, long tupleOffset,  __global int * factFilter){

	size_t stride = get_global_size(0);
	size_t offset = get_global_id(0);

        struct rleHeader *rheader = (struct rleHeader *)fact;
        int dNum = rheader->dictNum;

        for(size_t i=offset; i<dNum; i += stride){
                int fkey = ((int *)(fact+sizeof(struct rleHeader)))[i];
                int fcount = ((int *)(fact+sizeof(struct rleHeader)))[i + dNum];
                int fpos = ((int *)(fact+sizeof(struct rleHeader)))[i + 2*dNum];

                if((fcount + fpos) < tupleOffset)
                        continue;

                if(fpos >= (tupleOffset + tupleNum))
                        break;

                int hkey = fkey &(HSIZE-1);
                int keyNum = num[hkey];

                for(int j=0;j<keyNum;j++){

                        int pSum = psum[hkey];
                        int dimKey = ((int *)(bucket))[2*j + 2*pSum];
                        int dimId = ((int *)(bucket))[2*j + 2*pSum + 1];

                        if( dimKey == fkey){

                                if(fpos < tupleOffset){
                                        int tcount = fcount + fpos - tupleOffset;
                                        if(tcount > tupleNum)
                                                tcount = tupleNum;
                                        for(int k=0;k<tcount;k++)
                                                factFilter[k] = dimId;

                                }else if((fpos + fcount) > (tupleOffset + tupleNum)){
                                        int tcount = tupleOffset + tupleNum - fpos ;
                                        for(int k=0;k<tcount;k++)
                                                factFilter[fpos+k-tupleOffset] = dimId;
                                }else{
                                        for(int k=0;k<fcount;k++)
                                                factFilter[fpos+k-tupleOffset] = dimId;

                                }

                                break;
                        }
                }
        }

}

__kernel  void count_join_result(__global int* num, __global int* psum, __global char* bucket, __global char* fact, long inNum, __global int* count, __global int * factFilter){
        int lcount = 0;
	size_t stride = get_global_size(0);
	size_t offset = get_global_id(0);

        for(size_t i=offset;i<inNum;i+=stride){
                int fkey = ((int *)(fact))[i];
                int hkey = fkey &(HSIZE-1);
                int keyNum = num[hkey];

                for(int j=0;j<keyNum;j++){
                        int pSum = psum[hkey];
                        int dimKey = ((int *)(bucket))[2*j + 2*pSum];
                        int dimId = ((int *)(bucket))[2*j + 2*pSum + 1];
                        if( dimKey == fkey){
                                lcount ++;
                                factFilter[i] = dimId;
                                break;
                        }
                }
        }

        __syncthreads();
        count[offset] = lcount;
}

__kernel void rle_psum(__global int *count, __global char * fact,  long  tupleNum, long tupleOffset, __global int * filter){

	size_t offset = get_global_id(0);
	size_t stride = get_global_size(0);

        struct rleHeader *rheader = (struct rleHeader *) fact;
        int dNum = rheader->dictNum;

        for(size_t i= offset; i<dNum; i+= stride){

                int fcount = ((int *)(fact+sizeof(struct rleHeader)))[i + dNum];
                int fpos = ((int *)(fact+sizeof(struct rleHeader)))[i + 2*dNum];
                int lcount= 0;

                if((fcount + fpos) < tupleOffset)
                        continue;

                if(fpos >= (tupleOffset + tupleNum))
                        break;

                if(fpos < tupleOffset){
                        int tcount = fcount + fpos - tupleOffset;
                        if(tcount > tupleNum)
                                tcount = tupleNum;
                        for(int k=0;k<tcount;k++){
                                if(filter[k]!=0)
                                        lcount++;
                        }
                        count[i] = lcount;

                }else if ((fpos + fcount) > (tupleOffset + tupleNum)){
                        int tcount = tupleNum  + tupleOffset - fpos;
                        for(int k=0;k<tcount;k++){
                                if(filter[fpos-tupleOffset + k]!=0)
                                        lcount++;
                        }
                        count[i] = lcount;

                }else{
                        for(int k=0;k<fcount;k++){
                                if(filter[fpos-tupleOffset + k]!=0)
                                        lcount++;
                        }
                        count[i] = lcount;
                }
        }

}

__kernel void joinFact_rle(__global int *resPsum, __global char * fact,  int attrSize, long  tupleNum, long tupleOffset, __global int * filter, __global char * result){

	size_t startIndex = get_global_id(0);
	size_t stride = get_global_size(0);

        struct rleHeader *rheader = (struct rleHeader *) fact;
        int dNum = rheader->dictNum;

        for(size_t i = startIndex; i<dNum; i += stride){
                int fkey = ((int *)(fact+sizeof(struct rleHeader)))[i];
                int fcount = ((int *)(fact+sizeof(struct rleHeader)))[i + dNum];
                int fpos = ((int *)(fact+sizeof(struct rleHeader)))[i + 2*dNum];

                if((fcount + fpos) < tupleOffset)
                        continue;

                if(fpos >= (tupleOffset + tupleNum))
                        break;

                if(fpos < tupleOffset){
                        int tcount = fcount + fpos - tupleOffset;
                        int toffset = resPsum[i];
                        for(int j=0;j<tcount;j++){
                                if(filter[j] != 0){
                                        ((int*)result)[toffset] = fkey ;
                                        toffset ++;
                                }
                        }

                }else if ((fpos + fcount) > (tupleOffset + tupleNum)){
                        int tcount = tupleOffset + tupleNum - fpos;
                        int toffset = resPsum[i];
                        for(int j=0;j<tcount;j++){
                                if(filter[fpos-tupleOffset+j] !=0){
                                        ((int*)result)[toffset] = fkey ;
                                        toffset ++;
                                }
                        }

                }else{
                        int toffset = resPsum[i];
                        for(int j=0;j<fcount;j++){
                                if(filter[fpos-tupleOffset+j] !=0){
                                        ((int*)result)[toffset] = fkey ;
                                        toffset ++;
                                }
                        }
                }
        }

}

__kernel void joinFact_dict_other(__global int *resPsum, __global char * fact,  __global char *dict, int byteNum,int attrSize, long  num, __global int * filter, __global char * result){

	size_t startIndex = get_global_id(0);
	size_t stride = get_global_size(0);
        long localOffset = resPsum[startIndex] * attrSize;

        struct dictHeader *dheader = (struct dictHeader*)dict;

        for(size_t i=startIndex;i<num;i+=stride){
                if(filter[i] != 0){
                        int key = 0;
                        memcpy_cl(&key, fact + i* byteNum, byteNum);
                        memcpy_cl(result + localOffset, &dheader->hash[key], attrSize);
                        localOffset += attrSize;
                }
        }
}

__kernel void joinFact_dict_int(__global int *resPsum, __global char * fact, __global char *dict, int byteNum, int attrSize, long  num, __global int * filter, __global char * result){

	size_t startIndex = get_global_id(0);
	size_t stride = get_global_size(0);
        long localCount = resPsum[startIndex];

        struct dictHeader *dheader = (struct dictHeader*)dict;

        for(size_t i=startIndex;i<num;i+=stride){
                if(filter[i] != 0){
                        int key = 0;
                        memcpy_cl(&key, fact + i* byteNum, byteNum);
                        ((int*)result)[localCount] = dheader->hash[key];
                        localCount ++;
                }
        }
}

__kernel void joinFact_other(__global int *resPsum, __global char * fact,  int attrSize, long  num, __global int * filter, __global char * result){

	size_t startIndex = get_global_id(0);
	size_t stride = get_global_size(0);
        long localOffset = resPsum[startIndex] * attrSize;

        for(size_t i=startIndex;i<num;i+=stride){
                if(filter[i] != 0){
                        memcpy_cl(result + localOffset, fact + i*attrSize, attrSize);
                        localOffset += attrSize;
                }
        }
}

__kernel void joinFact_int(__global int *resPsum, __global char * fact,  int attrSize, long  num, __global int * filter, __global char * result){

	size_t startIndex = get_global_id(0);
	size_t stride = get_global_size(0);
        long localCount = resPsum[startIndex];

        for(size_t i=startIndex;i<num;i+=stride){
                if(filter[i] != 0){
                        ((int*)result)[localCount] = ((int *)fact)[i];
                        localCount ++;
                }
        }
}

__kernel void joinDim_rle(__global int *resPsum, __global char * dim, int attrSize, long tupleNum, long tupleOffset, __global int * filter, __global char * result){

	size_t startIndex = get_global_id(0);
	size_t stride = get_global_size(0);
        long localCount = resPsum[startIndex];

        struct rleHeader *rheader = (struct rleHeader *) dim;
        int dNum = rheader->dictNum;

        for(size_t i = startIndex; i<tupleNum; i += stride){
                int dimId = filter[i];
                if(dimId != 0){
                        for(int j=0;j<dNum;j++){
                                int dkey = ((int *)(dim+sizeof(struct rleHeader)))[j];
                                int dcount = ((int *)(dim+sizeof(struct rleHeader)))[j + dNum];
                                int dpos = ((int *)(dim+sizeof(struct rleHeader)))[j + 2*dNum];

                                if(dpos == dimId || ((dpos < dimId) && (dpos + dcount) > dimId)){
                                        ((int*)result)[localCount] = dkey ;
                                        localCount ++;
                                        break;
                                }

                        }
                }
        }
}

__kernel void joinDim_dict_other(__global int *resPsum, __global char * dim, __global char *dict, int byteNum, int attrSize, long num, __global int * filter, __global char * result){

	size_t startIndex = get_global_id(0);
	size_t stride = get_global_size(0);
        long localOffset = resPsum[startIndex] * attrSize;

        struct dictHeader *dheader = (struct dictHeader*)dict;

        for(size_t i=startIndex;i<num;i+=stride){
                int dimId = filter[i];
                if( dimId != 0){
                        int key = 0;
                        memcpy_cl(&key, dim + (dimId-1) * byteNum, byteNum);
                        memcpy_cl(result + localOffset, &dheader->hash[key], attrSize);
                        localOffset += attrSize;
                }
        }
}

__kernel void joinDim_dict_int(__global int *resPsum, __global char * dim, __global char *dict, int byteNum, int attrSize, long num, __global int * filter, __global char * result){

	size_t startIndex = get_global_id(0);
	size_t stride = get_global_size(0);
        long localCount = resPsum[startIndex];

        struct dictHeader *dheader = (struct dictHeader*)dict;

        for(size_t i=startIndex;i<num;i+=stride){
                int dimId = filter[i];
                if( dimId != 0){
                        int key = 0;
                        memcpy_cl(&key, dim + (dimId-1) * byteNum, byteNum);
                        ((int*)result)[localCount] = dheader->hash[key];
                        localCount ++;
                }
        }
}

__kernel void joinDim_int(__global int *resPsum, __global char * dim, int attrSize, long num, __global int * filter, __global char * result){

	size_t startIndex = get_global_id(0);
	size_t stride = get_global_size(0);
        long localCount = resPsum[startIndex];

        for(size_t i=startIndex;i<num;i+=stride){
                int dimId = filter[i];
                if( dimId != 0){
                        ((int*)result)[localCount] = ((int*)dim)[dimId-1];
                        localCount ++;
                }
        }
}

__kernel void joinDim_other(__global int *resPsum, __global char * dim, int attrSize, long num, __global int * filter, __global char * result){

	size_t startIndex = get_global_id(0);
	size_t stride = get_global_size(0);
        long localOffset = resPsum[startIndex] * attrSize;

        for(size_t i=startIndex;i<num;i+=stride){
                int dimId = filter[i];
                if( dimId != 0){
                        memcpy_cl(result + localOffset, dim + (dimId-1)* attrSize, attrSize);
                        localOffset += attrSize;
                }
        }
}

error: pathspec 'src/opencl/kernel.cl' did not match any file(s) known to git


Packet Select

Packet Select