Skip to content
Snippets Groups Projects

clrandom: Handle underaligned buffers (closes #6).

Merged Matt Wala requested to merge weaken-clrandom-alignment-assumptions into master
2 files
+ 97
4
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 10
4
@@ -286,8 +286,11 @@ class RanluxGenerator(object):
@@ -286,8 +286,11 @@ class RanluxGenerator(object):
unsigned long idx = get_global_id(0)*4;
unsigned long idx = get_global_id(0)*4;
while (idx + 4 < out_size)
while (idx + 4 < out_size)
{
{
*(global output_vec_t *) (output + idx) =
output_vec_t ran = GET_RANDOM_NUM(RANLUX_FUNC(&ranluxclstate));
GET_RANDOM_NUM(RANLUX_FUNC(&ranluxclstate));
output[idx] = ran.x;
 
output[idx + 1] = ran.y;
 
output[idx + 2] = ran.z;
 
output[idx + 3] = ran.w;
idx += 4*NUM_WORKITEMS;
idx += 4*NUM_WORKITEMS;
}
}
@@ -594,8 +597,11 @@ class Random123GeneratorBase(object):
@@ -594,8 +597,11 @@ class Random123GeneratorBase(object):
unsigned long idx = get_global_id(0)*4;
unsigned long idx = get_global_id(0)*4;
while (idx + 4 < out_size)
while (idx + 4 < out_size)
{
{
*(global output_vec_t *) (output + idx) =
output_vec_t ran = GET_RANDOM_NUM(gen_bits(&k, &c));
GET_RANDOM_NUM(gen_bits(&k, &c));
output[idx] = ran.x;
 
output[idx + 1] = ran.y;
 
output[idx + 2] = ran.z;
 
output[idx + 3] = ran.w;
idx += 4*get_global_size(0);
idx += 4*get_global_size(0);
}
}
Loading