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

smarter object definitions #145

Merged
merged 1 commit into from
May 26, 2015
Merged

smarter object definitions #145

merged 1 commit into from
May 26, 2015

Conversation

ntessore
Copy link
Contributor

This PR allows for a more straightforward definition of objects. Take a look at the new SIS lens:

// singular isothermal sphere
// follows Schneider, Kochanek, Wambsganss (2006)

type = LENS;

params
{
    { "x" },
    { "y" },
    { "r" }
};

data
{
    float2 x; // lens position
    float r;  // Einstein radius
};

static float2 deflection(constant data* this, float2 x)
{
    // SIS deflection
    return this->r*normalize(x - this->x);
}

static void set(global data* this, float x, float y, float r)
{
    // lens position
    this->x = (float2)(x, y);

    // Einstein radius
    this->r = r;
}

The following changes have been introduced:

  • Objects live in the objects folder, to separate them from the main kernels.
  • The name of the object need not be repeated inside the definition, for a more object-oriented feel.
  • Separate functions for deflection and brightness (necessary for Mass follows light source / lens #101).

#define FOREGROUND(x, a) static float foreground_##x(constant struct x* x, a)

// macro to simplify setter function for object
#define SET(x, ...) static void set_##x(global struct x* x, __VA_ARGS__)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variadic macro is not actually supported by the OpenCL standard. However, it works in Apple's implementation. We must check whether this is true also for other implementations before we can merge this.

@ntessore ntessore force-pushed the nt/object-definitions branch from 3fe5e60 to 7128459 Compare May 15, 2015 12:53
@ntessore ntessore changed the title smarter object definitions [WIP] smarter object definitions May 19, 2015
@ntessore
Copy link
Contributor Author

I have marked this work in progress for now.

@ntessore ntessore force-pushed the nt/object-definitions branch from 7128459 to 4670845 Compare May 23, 2015 14:43
@ntessore ntessore changed the title [WIP] smarter object definitions smarter object definitions May 23, 2015
@ntessore
Copy link
Contributor Author

This is ready for merging now. There is no longer any use of non-standard variadic macros, and the overall style is much nicer, I think.

@ntessore ntessore force-pushed the nt/object-definitions branch from 4670845 to 1f252ee Compare May 23, 2015 16:00
@ntessore ntessore force-pushed the nt/object-definitions branch from 1f252ee to 39c5a22 Compare May 26, 2015 09:11
fabiobg83 added a commit that referenced this pull request May 26, 2015
@fabiobg83 fabiobg83 merged commit a5ba99e into master May 26, 2015
@fabiobg83 fabiobg83 deleted the nt/object-definitions branch May 26, 2015 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants