Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

preprocess: Global variables do not have newlines #113

Open
ChrisCummins opened this issue Apr 25, 2017 · 0 comments
Open

preprocess: Global variables do not have newlines #113

ChrisCummins opened this issue Apr 25, 2017 · 0 comments

Comments

@ChrisCummins
Copy link
Owner

>>> print(clgen.preprocess("""
constant const float c = 3.5f;
#define DTYPE float
#define ALPHA(a) c * a

inline DTYPE ax(DTYPE x) { return ALPHA(x); }

kernel void saxpy( /* SAXPY kernel */
    global DTYPE *input1,
    global DTYPE *input2,
    const int nelem)
{
    unsigned int idx = get_global_id(0);
    // = ax + y
    if (idx < nelem) {
        input2[idx] += ax(input1[idx]); }}
"""))

Expected output:

constant const float Ga = 3.5f;

inline float A(float a) {
  return Ga * a;
}

kernel void B(global float* a, global float* b, const int c) {
  unsigned int d = get_global_id(0);

  if (d < c) {
    b[d] += A(a[d]);
  }
}

Actual output:

constant const float Ga = 3.5f; inline float A(float a) {
  return Ga * a;
}

kernel void B(global float* a, global float* b, const int c) {
  unsigned int d = get_global_id(0);

  if (d < c) {
    b[d] += A(a[d]);
  }
}
@ChrisCummins ChrisCummins added this to the 0.3.x Beta milestone Apr 25, 2017
@ChrisCummins ChrisCummins self-assigned this Apr 25, 2017
@ChrisCummins ChrisCummins changed the title rewriter: Global variables do not have newlines preprocess: Global variables do not have newlines Apr 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant