Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • sac2c sac2c
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 395
    • Issues 395
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 27
    • Merge requests 27
  • Deployments
    • Deployments
    • Releases
  • Wiki
    • Wiki
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • sac-group
  • sac2csac2c
  • Issues
  • #2437
Closed
Open
Created Sep 03, 2024 by Thomas Koopman@thomasDeveloper

Structs: Undefined variable in generated C code / -check t lacks shape factor info

The following program, when compiled with check -tc, version 1.3.3-MijasCosta-1246-g5b3f4

use Structures: all except {zero, sel};
import Structures: {zero, sel};
use StdIO: all;

struct Body {
  double x;
  double y;
  double z;
};

inline
struct Body add(struct Body a, struct Body b)
{
  res = Body {a.x + b.x, a.y + b.y, a.z + b.z};
  return res;
}

inline
struct Body acc(struct Body b1, struct Body b2, double m)
{
   return add(b2, b1);
}

noinline
struct Body[B]
acc_v(struct Body[B] p1, struct Body[B] p2, double[B] ms)
{
  return with {(. <= iv <= .): with {
                              ([0] <= jv < [B]): acc(p1[iv], p2[jv], ms[jv]);
                               }: fold(add, zero(Body {0d, 0d, 0d}));
              }: genarray([B], zero(Body {0d, 0d, 0d}));
}

noinline
struct Body[d:shp] id(struct Body[d:shp] x)
{
  return x;
}

noinline
double[d:shp] id(double[d:shp] x)
{
  return x;
}

int main()
{
    n = 1000;
    p1 = id(with {
         }: genarray([n], zero( Body {0d, 0d, 0d})));
    p2 = id(with {
         }: genarray([n], zero( Body {0d, 0d, 0d})));
    m = id(genarray([n], 1d));

    p3 = acc_v(p1, p2, m);

    return toi(p3[0].x);
}

complains about shape variables being undefined in SAC_ASSURE_TYPE_LINE macro's. Variables like SAC_SACp_emal_6843__icc_2800_shpfac0.

Edited Sep 03, 2024 by Sven-Bodo Scholz
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking