<commit_before>// simulation/include.glsl is included here

#define BLOCKSIZE 512
#define HALFBLOCKSIZE 256

layout (local_size_x = HALFBLOCKSIZE) in;

layout (std430, binding = 0) buffer Data
{
	uint data[];
};

layout (std430, binding = 1) writeonly buffer BlockSums
{
	uint blocksums[];
};

shared uint temp[BLOCKSIZE];

const int n = BLOCKSIZE;

void main (void)
{
	int gid = int (gl_GlobalInvocationID.x);
	int lid = int (gl_LocalInvocationIndex);
	int offset = 1;
	
	temp[2 * lid] = data[2 * gid];
	temp[2 * lid + 1] = data[2 * gid + 1];
	
	for (int d = n >> 1; d > 0; d >>= 1)
	{
		barrier ();
		memoryBarrierShared ();
		
		if (lid < d)
		{
			int ai = offset * (2 * lid + 1) - 1;
			int bi = offset * (2 * lid + 2) - 1;
			
			temp[bi] += temp[ai]; 
		}
		offset *= 2;
	}
	
	if (lid == 0)
	{
		blocksums[gl_WorkGroupID.x] = temp[n - 1];
		temp[n - 1] = 0;
	}
	
	for (int d = 1; d < n; d *= 2)
	{
		offset >>= 1;
		barrier ();
		memoryBarrierShared ();
		
		if (lid < d)
		{
			int ai = offset * (2 * lid + 1) - 1;
			int bi = offset * (2 * lid + 2) - 1;
			
			uint t = temp[ai];
			temp[ai] = temp[bi];
			temp[bi] += t;
		}
	}
	
	barrier ();
	memoryBarrierShared ();
	
	data[2 * gid] = temp[2 * lid];
	data[2 * gid + 1] = temp[2 * lid + 1];
}<commit_msg>Conflict free offsets for radix blockscan.<commit_after>// simulation/include.glsl is included here

#define BLOCKSIZE 512
#define HALFBLOCKSIZE 256

layout (local_size_x = HALFBLOCKSIZE) in;

layout (std430, binding = 0) buffer Data
{
	uint data[];
};

layout (std430, binding = 1) writeonly buffer BlockSums
{
	uint blocksums[];
};

#define NUM_BANKS 16
#define LOG_NUM_BANKS 4
#define CONFLICT_FREE_OFFSET(n) ((n) >> LOG_NUM_BANKS)

shared uint temp[BLOCKSIZE + CONFLICT_FREE_OFFSET(BLOCKSIZE)];

const int n = BLOCKSIZE;

void main (void)
{
	int gid = int (gl_GlobalInvocationID.x);
	int lid = int (gl_LocalInvocationIndex);
	int offset = 1;
	
	int ai = lid;
	int bi = lid + (n/2);
	
	int bankOffsetA = CONFLICT_FREE_OFFSET(ai);
	int bankOffsetB = CONFLICT_FREE_OFFSET(bi);
	
	temp[ai + bankOffsetA] = data[gid];
	temp[bi + bankOffsetB] = data[gid + (n/2)];
	
	for (int d = n >> 1; d > 0; d >>= 1)
	{
		barrier ();
		memoryBarrierShared ();
		
		if (lid < d)
		{
			int ai = offset * (2 * lid + 1) - 1;
			int bi = offset * (2 * lid + 2) - 1;
			ai += CONFLICT_FREE_OFFSET(ai);
			bi += CONFLICT_FREE_OFFSET(bi);
			
			temp[bi] += temp[ai]; 
		}
		offset *= 2;
	}
	
	if (lid == 0)
	{
		blocksums[gl_WorkGroupID.x] = temp[n - 1 + CONFLICT_FREE_OFFSET(n-1)];
		temp[n - 1 + CONFLICT_FREE_OFFSET(n-1)] = 0;
	}
	
	for (int d = 1; d < n; d *= 2)
	{
		offset >>= 1;
		barrier ();
		memoryBarrierShared ();
		
		if (lid < d)
		{
			int ai = offset * (2 * lid + 1) - 1;
			int bi = offset * (2 * lid + 2) - 1;
			ai += CONFLICT_FREE_OFFSET(ai);
			bi += CONFLICT_FREE_OFFSET(bi);
			
			uint t = temp[ai];
			temp[ai] = temp[bi];
			temp[bi] += t;
		}
	}
	
	barrier ();
	memoryBarrierShared ();
	
	data[gid] = temp[ai + bankOffsetA];
	data[gid + (n/2)] = temp[bi + bankOffsetB];
}
{'fraction_non_alphanumeric': 0.16403681788297172, 'fraction_numerical': 0.03155818540433925, 'mean_word_length': 2.9213917525773194, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7128095', 'n_tokens_mistral': 1451, 'n_tokens_neox': 1242, 'n_words': 337}