Exemplo n.º 1
0
def test_NormalizeIdentifiers_global_variable_reference():
    """Test that global variable reference is renamed."""
    assert opencl.NormalizeIdentifiers("""
const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;

kernel void A() {
  sampler_t a = sampler;
}
""") == """
Exemplo n.º 2
0
def test_NormalizeIdentifiers_opencl_global_sampler_reference():
    """Test that global sampler variable references are rewritten."""
    assert opencl.NormalizeIdentifiers("""
constant sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;
constant float2 vec = (float2)(0, 0);

float interpolate(read_only image2d_t image) {
  return read_imageui(image, sampler, vec).x;
}
""") == """
Exemplo n.º 3
0
def test_NormalizeIdentifiers_small_opencl_program():
    """Test that rewriter performs as expected for a small OpenCL program."""
    assert """
void kernel A(global int* a) {
  int b = 0;
  a[get_global_id(0)] = b;
}
""" == opencl.NormalizeIdentifiers("""
void kernel foo(global int* bar) {
  int car = 0;
  bar[get_global_id(0)] = car;
}
""")
Exemplo n.º 4
0
def test_NormalizeIdentifiers_opencl_regression_test():
    """An input file which triggered a rewrite failure in an earlier version."""
    assert opencl.NormalizeIdentifiers("""
constant sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;

inline int interpolate(const float x, const float y, read_only image2d_t image) {
  const float ix = floor(x);
  const float dx = x - ix;

  const float iy = floor(y);
  const float dy = y - iy;

  const float intensity =
      read_imageui(image, sampler, (float2)(ix, iy)).x * (1 - dx) * (1 - dy)
      + read_imageui(image, sampler, (float2)(ix+1, iy)).x * dx * (1 - dy)
      + read_imageui(image, sampler, (float2)(ix, iy+1)).x * (1 - dx) * dy
      + read_imageui(image, sampler, (float2)(ix+1, iy+1)).x * dx * dy;

  return intensity;
}
""") == """
Exemplo n.º 5
0
def test_NormalizeIdentifiers_global_variable():
    """Test that global variable is renamed."""
    assert opencl.NormalizeIdentifiers("""
sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;
const int foo = 0;
""") == """