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

adjusted L8 to TP and TC #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

sbscholz
Copy link
Member

inserted Type Patterns and used Tensor Comprehensions.

@@ -78,13 +73,11 @@ int[*] escapeTime( complex[*] plane, int depth)
inline
Color8::color[.,.] intArrayToMonochrome( int[.,.] a)

Choose a reason for hiding this comment

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

Maybe add type patterns here as well?

Color8::color[n,m] intArrayToMonochrome( int[n,m] a)

@@ -69,13 +70,11 @@ inline int[*] escapeTime( complex[*] plane, int depth)
inline
Color8::color[.,.] intArrayToMonochrome( int[.,.] a)

Choose a reason for hiding this comment

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

Maybe add type patterns here as well?

Color8::color[n,m] intArrayToMonochrome( int[n,m] a)

#
# General Setup:
#
SAC2CFLAGS = -check ctb -v2 -O3

Choose a reason for hiding this comment

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

Add -ecc so that we don't get a warning:

Warning:
  Option -check c implies option -ecc.

d = with {
( .<= iv <= .) : clut[ a[ iv]];
} : genarray( shape(a), Color8::black());
return { iv -> clut[ a[ iv]] };

return( d);

Choose a reason for hiding this comment

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

return( d); needs to be deleted

} : genarray( shape( plane), toc(0));

return( times, values);
return { iv -> escapeTimeAndValue (plane[iv]) };

Choose a reason for hiding this comment

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

Does not compile for 3 reasons: parser cannot handle the implicated 2 return arguments, escapeTimeAndValue also needs depth, and iv will become an int[3] instead of int[2] as complex[m, n] is typedef'd to double[m, n, 2] currently. This works

    escape, values = { iv -> escapeTimeAndValue (plane[iv], depth) 
                          | iv < [m, n] };
    return (escape, values);

@thomas3494
Copy link

I cannot compile mandelbrot.sac, giving

Program reached impossible state at /home/thomas/repos/sac2c/src/libsac2c/typecheck/elim_alpha_types.c:442 -- new element type `double[*]' of array `_flat_91' does not match old type `double[+]' on the left hand side

(. <= iv <= .): pic[ iv / stretch];
} : genarray( shape(pic) * stretch, black());
return( res);
return { iv -> pic[ iv / stretch] | iv < shape(pic) * stretch };
}

/* Main ******************************************************************** */

Choose a reason for hiding this comment

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

plane does not have a fixed shape, as it increases during the do-while loop.

It is then used outside of this do-while loop in:

q, zoom_coords = getSelectionMulti( disp, [2,2]);
if (all( zoom_coords >= 0)) {
  cmin = [plane[ zoom_coords[[0]]]] ++ cmin;
  cmax = [plane[ zoom_coords[[1]]]] ++ cmax;
} else {
  cmin = all( shape(cmin) > 1) ? drop( [1], cmin) : cmin;
  cmax = all( shape(cmax) > 1) ? drop( [1], cmax) : cmax;
}

Which seems to be problematic.
Easiest fix would be to just recalculate plane with the correct shape, it is relatively cheap anyways.

q, zoom_coords = getSelectionMulti( disp, [2,2]);
if (all( zoom_coords >= 0)) {
  plane = genComplexArray(EXPAND * [YRES,XRES], cmin[0], cmax[0]);
  cmin = [plane[ zoom_coords[[0]]]] ++ cmin;
  cmax = [plane[ zoom_coords[[1]]]] ++ cmax;
} else {
  cmin = all( shape(cmin) > 1) ? drop( [1], cmin) : cmin;
  cmax = all( shape(cmax) > 1) ? drop( [1], cmax) : cmax;
}

Copy link
Member Author

Choose a reason for hiding this comment

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

???? as you correctly noticed, this is outside the do-loop..... so plane should be at maximum size here anyways.... how can this be "problematic"????

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.

3 participants