Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] View of /branches/vis15/src/tests/rtest/tests/curl3d/curl3d.c
ViewVC logotype

View of /branches/vis15/src/tests/rtest/tests/curl3d/curl3d.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4102 - (download) (as text) (annotate)
Wed Jun 29 22:03:51 2016 UTC (3 years, 3 months ago) by jhr
File size: 38092 byte(s)
adding regression tests
/*---------- begin c-util/fragments/exec-hdr.in ----------*/
/*! \file curl3d.c
 *
 * Generated from curl3d.diderot.
 */

/*
 * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
 *
 * COPYRIGHT (c) 2015 The University of Chicago
 * All rights reserved.
 */

#define DIDEROT_STANDALONE_EXEC
#define DIDEROT_SINGLE_PRECISION
#define DIDEROT_INT
#define DIDEROT_TARGET_C
#include "Diderot/diderot.h"

static char *ProgramName = "curl3d";

typedef struct Diderot_struct_world Diderot_World_t;
typedef struct Diderot_struct_CURL Strand_CURL_t;

/* stages of execution of a program */
typedef enum {
  POST_NEW = 0,		/* world allocated, but not initialized */
  POST_INIT = 1,	/* Init function has been called */
  POST_INITIALLY = 2,	/* globals and strands have been initialized */
  RUNNING = 3,		/* program is running */
  DONE = 4		/* program has terminated */
} ExecutionState_t;

/*---------- end c-util/fragments/exec-hdr.in ----------*/
#define DIDEROT_NO_INPUTS
typedef struct {
    Diderot_int_t gv_imgSizeX;
    Diderot_int_t gv_imgSizeY;
    Diderot_int_t gv_imgSizeZ;
    Diderot_image3D_t *gv__t;
} Diderot_Globals_t;
struct Diderot_struct_world {
    const char *name;
    biffMsg *errors;
    ExecutionState_t stage;
    bool verboseFlg;
    bool isArray;
    uint32_t nStrandTys;
    Strand_t *strandDesc;
    uint32_t nAxes;
    uint32_t *base;
    uint32_t *size;
    uint32_t numStrands;
    double runTime;
    uint32_t numActive;
    uint8_t *status;
    Diderot_Globals_t *globals;
    Strand_CURL_t *state;
};
static bool InitGlobals (Diderot_World_t *wrld)
{
    Diderot_Globals_t *glob = wrld->globals;
    Diderot_image3D_t *l__t_233;
    if (Diderot_LoadImage3D((WorldPrefix_t *)wrld, "../../data/const-curl3d.nrrd", &l__t_233)) {
        return true;
    }
    glob->gv_imgSizeX = 16;
    glob->gv_imgSizeY = 16;
    glob->gv_imgSizeZ = 16;
    glob->gv__t = l__t_233;
    return false;
}
static bool FreeGlobals (Diderot_World_t *wrld)
{
    Diderot_Globals_t *glob = wrld->globals;
    Diderot_FreeImage3D((WorldPrefix_t *)wrld, glob->gv__t);
    return false;
}
struct Diderot_struct_CURL {
    vec3f_t sv_out;
    vec3f_t sv_pos;
    Diderot_real_t sv_zz;
    Diderot_real_t sv_yy;
    Diderot_real_t sv_xx;
};
static void CURL_InitState (Diderot_Globals_t *glob, Strand_CURL_t *self, Diderot_int_t p_xi_0, Diderot_int_t p_yi_1, Diderot_int_t p_zi_2)
{
    Diderot_real_t l_xx_3;
    Diderot_real_t l_yy_4;
    Diderot_real_t l_zz_5;
    l_xx_3 = lerp(0.2e1f, 0.17e2f, ((float)p_xi_0-0.0f)/((float)glob->gv_imgSizeX-0.1e1f-0.0f));
    l_yy_4 = lerp(0.2e1f, 0.17e2f, ((float)p_yi_1-0.0f)/((float)glob->gv_imgSizeY-0.1e1f-0.0f));
    l_zz_5 = lerp(0.2e1f, 0.17e2f, ((float)p_zi_2-0.0f)/((float)glob->gv_imgSizeZ-0.1e1f-0.0f));
    self->sv_xx = l_xx_3;
    self->sv_yy = l_yy_4;
    self->sv_zz = l_zz_5;
    self->sv_pos = vec3(l_xx_3, l_yy_4, l_zz_5);
    self->sv_out = vec3(0.0f, 0.0f, 0.0f);
}
static StrandStatus_t CURL_Update (Diderot_Globals_t *glob, Strand_CURL_t *self)
{
    vec3f_t l_x_6;
    vec3f_t l_nd_7;
    vec3f_t l_f_8;
    vec3i_t l_n_9;
    Diderot_int_t l_ix_10;
    Diderot_int_t l_t2_11;
    Diderot_int_t l_iy_12;
    Diderot_int_t l_t2_13;
    Diderot_int_t l_iz_14;
    Diderot_int_t l_t_15;
    Diderot_int_t l_t1_16;
    Diderot_int_t l_index_17;
    Diderot_int_t l_offp_18;
    float *l_imgBaseAddr_19;
    float *l_a_20;
    vec4f_t l_v00_21;
    Diderot_int_t l_iy_22;
    Diderot_int_t l_t1_23;
    Diderot_int_t l_index_24;
    Diderot_int_t l_offp_25;
    float *l_a_26;
    vec4f_t l_v10_27;
    Diderot_int_t l_iy_28;
    Diderot_int_t l_t1_29;
    Diderot_int_t l_index_30;
    Diderot_int_t l_offp_31;
    float *l_a_32;
    vec4f_t l_v20_33;
    Diderot_int_t l_iy_34;
    Diderot_int_t l_t1_35;
    Diderot_int_t l_index_36;
    Diderot_int_t l_offp_37;
    float *l_a_38;
    vec4f_t l_v30_39;
    Diderot_int_t l_iz_40;
    Diderot_int_t l_t_41;
    Diderot_int_t l_t1_42;
    Diderot_int_t l_index_43;
    Diderot_int_t l_offp_44;
    float *l_a_45;
    vec4f_t l_v01_46;
    Diderot_int_t l_t1_47;
    Diderot_int_t l_index_48;
    Diderot_int_t l_offp_49;
    float *l_a_50;
    vec4f_t l_v11_51;
    Diderot_int_t l_t1_52;
    Diderot_int_t l_index_53;
    Diderot_int_t l_offp_54;
    float *l_a_55;
    vec4f_t l_v21_56;
    Diderot_int_t l_t1_57;
    Diderot_int_t l_index_58;
    Diderot_int_t l_offp_59;
    float *l_a_60;
    vec4f_t l_v31_61;
    Diderot_int_t l_iz_62;
    Diderot_int_t l_t_63;
    Diderot_int_t l_t1_64;
    Diderot_int_t l_index_65;
    Diderot_int_t l_offp_66;
    float *l_a_67;
    vec4f_t l_v02_68;
    Diderot_int_t l_t1_69;
    Diderot_int_t l_index_70;
    Diderot_int_t l_offp_71;
    float *l_a_72;
    vec4f_t l_v12_73;
    Diderot_int_t l_t1_74;
    Diderot_int_t l_index_75;
    Diderot_int_t l_offp_76;
    float *l_a_77;
    vec4f_t l_v22_78;
    Diderot_int_t l_t1_79;
    Diderot_int_t l_index_80;
    Diderot_int_t l_offp_81;
    float *l_a_82;
    vec4f_t l_v32_83;
    Diderot_int_t l_iz_84;
    Diderot_int_t l_t_85;
    Diderot_int_t l_t1_86;
    Diderot_int_t l_index_87;
    Diderot_int_t l_offp_88;
    float *l_a_89;
    vec4f_t l_v03_90;
    Diderot_int_t l_t1_91;
    Diderot_int_t l_index_92;
    Diderot_int_t l_offp_93;
    float *l_a_94;
    vec4f_t l_v13_95;
    Diderot_int_t l_t1_96;
    Diderot_int_t l_index_97;
    Diderot_int_t l_offp_98;
    float *l_a_99;
    vec4f_t l_v23_100;
    Diderot_int_t l_t1_101;
    Diderot_int_t l_index_102;
    Diderot_int_t l_offp_103;
    float *l_a_104;
    vec4f_t l_v33_105;
    Diderot_real_t l_fz_106;
    vec4f_t l_a_107;
    vec4f_t l_a0_108;
    vec4f_t l_a1_109;
    vec4f_t l_a2_110;
    vec4f_t l_a3_111;
    vec4f_t l_hz_112;
    Diderot_real_t l_fy_113;
    vec4f_t l_a_114;
    vec4f_t l_hy_115;
    Diderot_real_t l_fx_116;
    vec4f_t l_a_117;
    vec4f_t l_a1_118;
    vec4f_t l_a2_119;
    vec4f_t l_dhx_120;
    vec4f_t l_dhy_121;
    vec4f_t l_hx_122;
    vec4f_t l_tv_123;
    vec4f_t l_tv_124;
    vec4f_t l_tv_125;
    vec4f_t l_tv_126;
    vec4f_t l_dhz_127;
    Diderot_int_t l_offp_128;
    float *l_a_129;
    vec4f_t l_v00_130;
    Diderot_int_t l_offp_131;
    float *l_a_132;
    vec4f_t l_v10_133;
    Diderot_int_t l_offp_134;
    float *l_a_135;
    vec4f_t l_v20_136;
    Diderot_int_t l_offp_137;
    float *l_a_138;
    vec4f_t l_v30_139;
    Diderot_int_t l_offp_140;
    float *l_a_141;
    vec4f_t l_v01_142;
    Diderot_int_t l_offp_143;
    float *l_a_144;
    vec4f_t l_v11_145;
    Diderot_int_t l_offp_146;
    float *l_a_147;
    vec4f_t l_v21_148;
    Diderot_int_t l_offp_149;
    float *l_a_150;
    vec4f_t l_v31_151;
    Diderot_int_t l_offp_152;
    float *l_a_153;
    vec4f_t l_v02_154;
    Diderot_int_t l_offp_155;
    float *l_a_156;
    vec4f_t l_v12_157;
    Diderot_int_t l_offp_158;
    float *l_a_159;
    vec4f_t l_v22_160;
    Diderot_int_t l_offp_161;
    float *l_a_162;
    vec4f_t l_v32_163;
    Diderot_int_t l_offp_164;
    float *l_a_165;
    vec4f_t l_v03_166;
    Diderot_int_t l_offp_167;
    float *l_a_168;
    vec4f_t l_v13_169;
    Diderot_int_t l_offp_170;
    float *l_a_171;
    vec4f_t l_v23_172;
    Diderot_int_t l_offp_173;
    float *l_a_174;
    vec4f_t l_v33_175;
    vec4f_t l_tv_176;
    vec4f_t l_tv_177;
    vec4f_t l_tv_178;
    vec4f_t l_tv_179;
    Diderot_int_t l_offp_180;
    float *l_a_181;
    vec4f_t l_v00_182;
    Diderot_int_t l_offp_183;
    float *l_a_184;
    vec4f_t l_v10_185;
    Diderot_int_t l_offp_186;
    float *l_a_187;
    vec4f_t l_v20_188;
    Diderot_int_t l_offp_189;
    float *l_a_190;
    vec4f_t l_v30_191;
    Diderot_int_t l_offp_192;
    float *l_a_193;
    vec4f_t l_v01_194;
    Diderot_int_t l_offp_195;
    float *l_a_196;
    vec4f_t l_v11_197;
    Diderot_int_t l_offp_198;
    float *l_a_199;
    vec4f_t l_v21_200;
    Diderot_int_t l_offp_201;
    float *l_a_202;
    vec4f_t l_v31_203;
    Diderot_int_t l_offp_204;
    float *l_a_205;
    vec4f_t l_v02_206;
    Diderot_int_t l_offp_207;
    float *l_a_208;
    vec4f_t l_v12_209;
    Diderot_int_t l_offp_210;
    float *l_a_211;
    vec4f_t l_v22_212;
    Diderot_int_t l_offp_213;
    float *l_a_214;
    vec4f_t l_v32_215;
    Diderot_int_t l_offp_216;
    float *l_a_217;
    vec4f_t l_v03_218;
    Diderot_int_t l_offp_219;
    float *l_a_220;
    vec4f_t l_v13_221;
    Diderot_int_t l_offp_222;
    float *l_a_223;
    vec4f_t l_v23_224;
    Diderot_int_t l_offp_225;
    float *l_a_226;
    vec4f_t l_v33_227;
    vec4f_t l_tv_228;
    vec4f_t l_tv_229;
    vec4f_t l_tv_230;
    vec4f_t l_tv_231;
    Diderot_Mat3x3_t l_m_232;
    l_x_6 = ToImageSpace3(glob->gv__t, self->sv_pos);
    l_nd_7 = floor3(l_x_6);
    l_f_8 = l_x_6-l_nd_7;
    l_n_9 = vec3rtoi(l_nd_7);
    l_ix_10 = -1+((union3i_t)l_n_9).i[0];
    l_t2_11 = ((union3i_t)l_n_9).i[1];
    l_iy_12 = -1+l_t2_11;
    l_t2_13 = ((union3i_t)l_n_9).i[2];
    l_iz_14 = -1+l_t2_13;
    l_t_15 = 20*l_iz_14;
    l_t1_16 = l_iy_12+l_t_15;
    l_index_17 = l_ix_10+20*l_t1_16;
    l_offp_18 = 3*l_index_17;
    l_imgBaseAddr_19 = (float *)glob->gv__t->data;
    l_a_20 = l_imgBaseAddr_19+l_offp_18;
    float *vp_47 = l_a_20;
    l_v00_21 = vec4(vp_47[0], vp_47[3], vp_47[6], vp_47[9]);
    l_iy_22 = 0+l_t2_11;
    l_t1_23 = l_iy_22+l_t_15;
    l_index_24 = l_ix_10+20*l_t1_23;
    l_offp_25 = 3*l_index_24;
    l_a_26 = l_imgBaseAddr_19+l_offp_25;
    float *vp_46 = l_a_26;
    l_v10_27 = vec4(vp_46[0], vp_46[3], vp_46[6], vp_46[9]);
    l_iy_28 = 1+l_t2_11;
    l_t1_29 = l_iy_28+l_t_15;
    l_index_30 = l_ix_10+20*l_t1_29;
    l_offp_31 = 3*l_index_30;
    l_a_32 = l_imgBaseAddr_19+l_offp_31;
    float *vp_45 = l_a_32;
    l_v20_33 = vec4(vp_45[0], vp_45[3], vp_45[6], vp_45[9]);
    l_iy_34 = 2+l_t2_11;
    l_t1_35 = l_iy_34+l_t_15;
    l_index_36 = l_ix_10+20*l_t1_35;
    l_offp_37 = 3*l_index_36;
    l_a_38 = l_imgBaseAddr_19+l_offp_37;
    float *vp_44 = l_a_38;
    l_v30_39 = vec4(vp_44[0], vp_44[3], vp_44[6], vp_44[9]);
    l_iz_40 = 0+l_t2_13;
    l_t_41 = 20*l_iz_40;
    l_t1_42 = l_iy_12+l_t_41;
    l_index_43 = l_ix_10+20*l_t1_42;
    l_offp_44 = 3*l_index_43;
    l_a_45 = l_imgBaseAddr_19+l_offp_44;
    float *vp_43 = l_a_45;
    l_v01_46 = vec4(vp_43[0], vp_43[3], vp_43[6], vp_43[9]);
    l_t1_47 = l_iy_22+l_t_41;
    l_index_48 = l_ix_10+20*l_t1_47;
    l_offp_49 = 3*l_index_48;
    l_a_50 = l_imgBaseAddr_19+l_offp_49;
    float *vp_42 = l_a_50;
    l_v11_51 = vec4(vp_42[0], vp_42[3], vp_42[6], vp_42[9]);
    l_t1_52 = l_iy_28+l_t_41;
    l_index_53 = l_ix_10+20*l_t1_52;
    l_offp_54 = 3*l_index_53;
    l_a_55 = l_imgBaseAddr_19+l_offp_54;
    float *vp_41 = l_a_55;
    l_v21_56 = vec4(vp_41[0], vp_41[3], vp_41[6], vp_41[9]);
    l_t1_57 = l_iy_34+l_t_41;
    l_index_58 = l_ix_10+20*l_t1_57;
    l_offp_59 = 3*l_index_58;
    l_a_60 = l_imgBaseAddr_19+l_offp_59;
    float *vp_40 = l_a_60;
    l_v31_61 = vec4(vp_40[0], vp_40[3], vp_40[6], vp_40[9]);
    l_iz_62 = 1+l_t2_13;
    l_t_63 = 20*l_iz_62;
    l_t1_64 = l_iy_12+l_t_63;
    l_index_65 = l_ix_10+20*l_t1_64;
    l_offp_66 = 3*l_index_65;
    l_a_67 = l_imgBaseAddr_19+l_offp_66;
    float *vp_39 = l_a_67;
    l_v02_68 = vec4(vp_39[0], vp_39[3], vp_39[6], vp_39[9]);
    l_t1_69 = l_iy_22+l_t_63;
    l_index_70 = l_ix_10+20*l_t1_69;
    l_offp_71 = 3*l_index_70;
    l_a_72 = l_imgBaseAddr_19+l_offp_71;
    float *vp_38 = l_a_72;
    l_v12_73 = vec4(vp_38[0], vp_38[3], vp_38[6], vp_38[9]);
    l_t1_74 = l_iy_28+l_t_63;
    l_index_75 = l_ix_10+20*l_t1_74;
    l_offp_76 = 3*l_index_75;
    l_a_77 = l_imgBaseAddr_19+l_offp_76;
    float *vp_37 = l_a_77;
    l_v22_78 = vec4(vp_37[0], vp_37[3], vp_37[6], vp_37[9]);
    l_t1_79 = l_iy_34+l_t_63;
    l_index_80 = l_ix_10+20*l_t1_79;
    l_offp_81 = 3*l_index_80;
    l_a_82 = l_imgBaseAddr_19+l_offp_81;
    float *vp_36 = l_a_82;
    l_v32_83 = vec4(vp_36[0], vp_36[3], vp_36[6], vp_36[9]);
    l_iz_84 = 2+l_t2_13;
    l_t_85 = 20*l_iz_84;
    l_t1_86 = l_iy_12+l_t_85;
    l_index_87 = l_ix_10+20*l_t1_86;
    l_offp_88 = 3*l_index_87;
    l_a_89 = l_imgBaseAddr_19+l_offp_88;
    float *vp_35 = l_a_89;
    l_v03_90 = vec4(vp_35[0], vp_35[3], vp_35[6], vp_35[9]);
    l_t1_91 = l_iy_22+l_t_85;
    l_index_92 = l_ix_10+20*l_t1_91;
    l_offp_93 = 3*l_index_92;
    l_a_94 = l_imgBaseAddr_19+l_offp_93;
    float *vp_34 = l_a_94;
    l_v13_95 = vec4(vp_34[0], vp_34[3], vp_34[6], vp_34[9]);
    l_t1_96 = l_iy_28+l_t_85;
    l_index_97 = l_ix_10+20*l_t1_96;
    l_offp_98 = 3*l_index_97;
    l_a_99 = l_imgBaseAddr_19+l_offp_98;
    float *vp_33 = l_a_99;
    l_v23_100 = vec4(vp_33[0], vp_33[3], vp_33[6], vp_33[9]);
    l_t1_101 = l_iy_34+l_t_85;
    l_index_102 = l_ix_10+20*l_t1_101;
    l_offp_103 = 3*l_index_102;
    l_a_104 = l_imgBaseAddr_19+l_offp_103;
    float *vp_32 = l_a_104;
    l_v33_105 = vec4(vp_32[0], vp_32[3], vp_32[6], vp_32[9]);
    l_fz_106 = ((union3f_t)l_f_8).r[2];
    l_a_107 = vec4(l_fz_106+0.1e1f, l_fz_106, l_fz_106-0.1e1f, l_fz_106-0.2e1f);
    l_a0_108 = vec4(0.133333333333e1f, 0.666666666667e0f, 0.666666666667e0f, 0.133333333333e1f);
    l_a1_109 = vec4(-0.2e1f, 0.0f, 0.0f, 0.2e1f);
    l_a2_110 = vec4(0.1e1f, -0.1e1f, -0.1e1f, 0.1e1f);
    l_a3_111 = vec4(-0.166666666667e0f, 0.5e0f, -0.5e0f, 0.166666666667e0f);
    l_hz_112 = l_a0_108+l_a_107*(l_a1_109+l_a_107*(l_a2_110+l_a_107*l_a3_111));
    l_fy_113 = ((union3f_t)l_f_8).r[1];
    l_a_114 = vec4(l_fy_113+0.1e1f, l_fy_113, l_fy_113-0.1e1f, l_fy_113-0.2e1f);
    l_hy_115 = l_a0_108+l_a_114*(l_a1_109+l_a_114*(l_a2_110+l_a_114*l_a3_111));
    l_fx_116 = ((union3f_t)l_f_8).r[0];
    l_a_117 = vec4(l_fx_116+0.1e1f, l_fx_116, l_fx_116-0.1e1f, l_fx_116-0.2e1f);
    l_a1_118 = vec4(0.2e1f, -0.2e1f, -0.2e1f, 0.2e1f);
    l_a2_119 = vec4(-0.5e0f, 0.15e1f, -0.15e1f, 0.5e0f);
    l_dhx_120 = l_a1_109+l_a_117*(l_a1_118+l_a_117*l_a2_119);
    l_dhy_121 = l_a1_109+l_a_114*(l_a1_118+l_a_114*l_a2_119);
    l_hx_122 = l_a0_108+l_a_117*(l_a1_109+l_a_117*(l_a2_110+l_a_117*l_a3_111));
    l_tv_123 = vec4(dot4(l_v00_21, l_hx_122), dot4(l_v10_27, l_hx_122), dot4(l_v20_33, l_hx_122),
        dot4(l_v30_39, l_hx_122));
    l_tv_124 = vec4(dot4(l_v01_46, l_hx_122), dot4(l_v11_51, l_hx_122), dot4(l_v21_56, l_hx_122),
        dot4(l_v31_61, l_hx_122));
    l_tv_125 = vec4(dot4(l_v02_68, l_hx_122), dot4(l_v12_73, l_hx_122), dot4(l_v22_78, l_hx_122),
        dot4(l_v32_83, l_hx_122));
    l_tv_126 = vec4(dot4(l_v03_90, l_hx_122), dot4(l_v13_95, l_hx_122), dot4(l_v23_100, l_hx_122),
        dot4(l_v33_105, l_hx_122));
    l_dhz_127 = l_a1_109+l_a_107*(l_a1_118+l_a_107*l_a2_119);
    l_offp_128 = 1+l_offp_18;
    l_a_129 = l_imgBaseAddr_19+l_offp_128;
    float *vp_31 = l_a_129;
    l_v00_130 = vec4(vp_31[0], vp_31[3], vp_31[6], vp_31[9]);
    l_offp_131 = 1+l_offp_25;
    l_a_132 = l_imgBaseAddr_19+l_offp_131;
    float *vp_30 = l_a_132;
    l_v10_133 = vec4(vp_30[0], vp_30[3], vp_30[6], vp_30[9]);
    l_offp_134 = 1+l_offp_31;
    l_a_135 = l_imgBaseAddr_19+l_offp_134;
    float *vp_29 = l_a_135;
    l_v20_136 = vec4(vp_29[0], vp_29[3], vp_29[6], vp_29[9]);
    l_offp_137 = 1+l_offp_37;
    l_a_138 = l_imgBaseAddr_19+l_offp_137;
    float *vp_28 = l_a_138;
    l_v30_139 = vec4(vp_28[0], vp_28[3], vp_28[6], vp_28[9]);
    l_offp_140 = 1+l_offp_44;
    l_a_141 = l_imgBaseAddr_19+l_offp_140;
    float *vp_27 = l_a_141;
    l_v01_142 = vec4(vp_27[0], vp_27[3], vp_27[6], vp_27[9]);
    l_offp_143 = 1+l_offp_49;
    l_a_144 = l_imgBaseAddr_19+l_offp_143;
    float *vp_26 = l_a_144;
    l_v11_145 = vec4(vp_26[0], vp_26[3], vp_26[6], vp_26[9]);
    l_offp_146 = 1+l_offp_54;
    l_a_147 = l_imgBaseAddr_19+l_offp_146;
    float *vp_25 = l_a_147;
    l_v21_148 = vec4(vp_25[0], vp_25[3], vp_25[6], vp_25[9]);
    l_offp_149 = 1+l_offp_59;
    l_a_150 = l_imgBaseAddr_19+l_offp_149;
    float *vp_24 = l_a_150;
    l_v31_151 = vec4(vp_24[0], vp_24[3], vp_24[6], vp_24[9]);
    l_offp_152 = 1+l_offp_66;
    l_a_153 = l_imgBaseAddr_19+l_offp_152;
    float *vp_23 = l_a_153;
    l_v02_154 = vec4(vp_23[0], vp_23[3], vp_23[6], vp_23[9]);
    l_offp_155 = 1+l_offp_71;
    l_a_156 = l_imgBaseAddr_19+l_offp_155;
    float *vp_22 = l_a_156;
    l_v12_157 = vec4(vp_22[0], vp_22[3], vp_22[6], vp_22[9]);
    l_offp_158 = 1+l_offp_76;
    l_a_159 = l_imgBaseAddr_19+l_offp_158;
    float *vp_21 = l_a_159;
    l_v22_160 = vec4(vp_21[0], vp_21[3], vp_21[6], vp_21[9]);
    l_offp_161 = 1+l_offp_81;
    l_a_162 = l_imgBaseAddr_19+l_offp_161;
    float *vp_20 = l_a_162;
    l_v32_163 = vec4(vp_20[0], vp_20[3], vp_20[6], vp_20[9]);
    l_offp_164 = 1+l_offp_88;
    l_a_165 = l_imgBaseAddr_19+l_offp_164;
    float *vp_19 = l_a_165;
    l_v03_166 = vec4(vp_19[0], vp_19[3], vp_19[6], vp_19[9]);
    l_offp_167 = 1+l_offp_93;
    l_a_168 = l_imgBaseAddr_19+l_offp_167;
    float *vp_18 = l_a_168;
    l_v13_169 = vec4(vp_18[0], vp_18[3], vp_18[6], vp_18[9]);
    l_offp_170 = 1+l_offp_98;
    l_a_171 = l_imgBaseAddr_19+l_offp_170;
    float *vp_17 = l_a_171;
    l_v23_172 = vec4(vp_17[0], vp_17[3], vp_17[6], vp_17[9]);
    l_offp_173 = 1+l_offp_103;
    l_a_174 = l_imgBaseAddr_19+l_offp_173;
    float *vp_16 = l_a_174;
    l_v33_175 = vec4(vp_16[0], vp_16[3], vp_16[6], vp_16[9]);
    l_tv_176 = vec4(dot4(l_v00_130, l_hx_122), dot4(l_v10_133, l_hx_122), dot4(l_v20_136, l_hx_122),
        dot4(l_v30_139, l_hx_122));
    l_tv_177 = vec4(dot4(l_v01_142, l_hx_122), dot4(l_v11_145, l_hx_122), dot4(l_v21_148, l_hx_122),
        dot4(l_v31_151, l_hx_122));
    l_tv_178 = vec4(dot4(l_v02_154, l_hx_122), dot4(l_v12_157, l_hx_122), dot4(l_v22_160, l_hx_122),
        dot4(l_v32_163, l_hx_122));
    l_tv_179 = vec4(dot4(l_v03_166, l_hx_122), dot4(l_v13_169, l_hx_122), dot4(l_v23_172, l_hx_122),
        dot4(l_v33_175, l_hx_122));
    l_offp_180 = 2+l_offp_18;
    l_a_181 = l_imgBaseAddr_19+l_offp_180;
    float *vp_15 = l_a_181;
    l_v00_182 = vec4(vp_15[0], vp_15[3], vp_15[6], vp_15[9]);
    l_offp_183 = 2+l_offp_25;
    l_a_184 = l_imgBaseAddr_19+l_offp_183;
    float *vp_14 = l_a_184;
    l_v10_185 = vec4(vp_14[0], vp_14[3], vp_14[6], vp_14[9]);
    l_offp_186 = 2+l_offp_31;
    l_a_187 = l_imgBaseAddr_19+l_offp_186;
    float *vp_13 = l_a_187;
    l_v20_188 = vec4(vp_13[0], vp_13[3], vp_13[6], vp_13[9]);
    l_offp_189 = 2+l_offp_37;
    l_a_190 = l_imgBaseAddr_19+l_offp_189;
    float *vp_12 = l_a_190;
    l_v30_191 = vec4(vp_12[0], vp_12[3], vp_12[6], vp_12[9]);
    l_offp_192 = 2+l_offp_44;
    l_a_193 = l_imgBaseAddr_19+l_offp_192;
    float *vp_11 = l_a_193;
    l_v01_194 = vec4(vp_11[0], vp_11[3], vp_11[6], vp_11[9]);
    l_offp_195 = 2+l_offp_49;
    l_a_196 = l_imgBaseAddr_19+l_offp_195;
    float *vp_10 = l_a_196;
    l_v11_197 = vec4(vp_10[0], vp_10[3], vp_10[6], vp_10[9]);
    l_offp_198 = 2+l_offp_54;
    l_a_199 = l_imgBaseAddr_19+l_offp_198;
    float *vp_9 = l_a_199;
    l_v21_200 = vec4(vp_9[0], vp_9[3], vp_9[6], vp_9[9]);
    l_offp_201 = 2+l_offp_59;
    l_a_202 = l_imgBaseAddr_19+l_offp_201;
    float *vp_8 = l_a_202;
    l_v31_203 = vec4(vp_8[0], vp_8[3], vp_8[6], vp_8[9]);
    l_offp_204 = 2+l_offp_66;
    l_a_205 = l_imgBaseAddr_19+l_offp_204;
    float *vp_7 = l_a_205;
    l_v02_206 = vec4(vp_7[0], vp_7[3], vp_7[6], vp_7[9]);
    l_offp_207 = 2+l_offp_71;
    l_a_208 = l_imgBaseAddr_19+l_offp_207;
    float *vp_6 = l_a_208;
    l_v12_209 = vec4(vp_6[0], vp_6[3], vp_6[6], vp_6[9]);
    l_offp_210 = 2+l_offp_76;
    l_a_211 = l_imgBaseAddr_19+l_offp_210;
    float *vp_5 = l_a_211;
    l_v22_212 = vec4(vp_5[0], vp_5[3], vp_5[6], vp_5[9]);
    l_offp_213 = 2+l_offp_81;
    l_a_214 = l_imgBaseAddr_19+l_offp_213;
    float *vp_4 = l_a_214;
    l_v32_215 = vec4(vp_4[0], vp_4[3], vp_4[6], vp_4[9]);
    l_offp_216 = 2+l_offp_88;
    l_a_217 = l_imgBaseAddr_19+l_offp_216;
    float *vp_3 = l_a_217;
    l_v03_218 = vec4(vp_3[0], vp_3[3], vp_3[6], vp_3[9]);
    l_offp_219 = 2+l_offp_93;
    l_a_220 = l_imgBaseAddr_19+l_offp_219;
    float *vp_2 = l_a_220;
    l_v13_221 = vec4(vp_2[0], vp_2[3], vp_2[6], vp_2[9]);
    l_offp_222 = 2+l_offp_98;
    l_a_223 = l_imgBaseAddr_19+l_offp_222;
    float *vp_1 = l_a_223;
    l_v23_224 = vec4(vp_1[0], vp_1[3], vp_1[6], vp_1[9]);
    l_offp_225 = 2+l_offp_103;
    l_a_226 = l_imgBaseAddr_19+l_offp_225;
    float *vp_0 = l_a_226;
    l_v33_227 = vec4(vp_0[0], vp_0[3], vp_0[6], vp_0[9]);
    l_tv_228 = vec4(dot4(l_v00_182, l_hx_122), dot4(l_v10_185, l_hx_122), dot4(l_v20_188, l_hx_122),
        dot4(l_v30_191, l_hx_122));
    l_tv_229 = vec4(dot4(l_v01_194, l_hx_122), dot4(l_v11_197, l_hx_122), dot4(l_v21_200, l_hx_122),
        dot4(l_v31_203, l_hx_122));
    l_tv_230 = vec4(dot4(l_v02_206, l_hx_122), dot4(l_v12_209, l_hx_122), dot4(l_v22_212, l_hx_122),
        dot4(l_v32_215, l_hx_122));
    l_tv_231 = vec4(dot4(l_v03_218, l_hx_122), dot4(l_v13_221, l_hx_122), dot4(l_v23_224, l_hx_122),
        dot4(l_v33_227, l_hx_122));
    l_m_232[0].v = ToWorldSpace3(glob->gv__t,
        vec3(
            dot4(l_hz_112,
                vec4(
                    dot4(l_hy_115,
                        vec4(dot4(l_v00_21, l_dhx_120), dot4(l_v10_27, l_dhx_120), dot4(l_v20_33, l_dhx_120),
                            dot4(l_v30_39, l_dhx_120))),
                    dot4(l_hy_115,
                        vec4(dot4(l_v01_46, l_dhx_120), dot4(l_v11_51, l_dhx_120), dot4(l_v21_56, l_dhx_120),
                            dot4(l_v31_61, l_dhx_120))),
                    dot4(l_hy_115,
                        vec4(dot4(l_v02_68, l_dhx_120), dot4(l_v12_73, l_dhx_120), dot4(l_v22_78, l_dhx_120),
                            dot4(l_v32_83, l_dhx_120))),
                    dot4(l_hy_115,
                        vec4(dot4(l_v03_90, l_dhx_120), dot4(l_v13_95, l_dhx_120), dot4(l_v23_100, l_dhx_120),
                            dot4(l_v33_105, l_dhx_120))))),
            dot4(l_hz_112,
                vec4(dot4(l_dhy_121, l_tv_123), dot4(l_dhy_121, l_tv_124), dot4(l_dhy_121, l_tv_125),
                    dot4(l_dhy_121, l_tv_126))),
            dot4(l_dhz_127,
                vec4(dot4(l_hy_115, l_tv_123), dot4(l_hy_115, l_tv_124), dot4(l_hy_115, l_tv_125),
                    dot4(l_hy_115, l_tv_126)))));
    l_m_232[1].v = ToWorldSpace3(glob->gv__t,
        vec3(
            dot4(l_hz_112,
                vec4(
                    dot4(l_hy_115,
                        vec4(dot4(l_v00_130, l_dhx_120), dot4(l_v10_133, l_dhx_120), dot4(l_v20_136, l_dhx_120),
                            dot4(l_v30_139, l_dhx_120))),
                    dot4(l_hy_115,
                        vec4(dot4(l_v01_142, l_dhx_120), dot4(l_v11_145, l_dhx_120), dot4(l_v21_148, l_dhx_120),
                            dot4(l_v31_151, l_dhx_120))),
                    dot4(l_hy_115,
                        vec4(dot4(l_v02_154, l_dhx_120), dot4(l_v12_157, l_dhx_120), dot4(l_v22_160, l_dhx_120),
                            dot4(l_v32_163, l_dhx_120))),
                    dot4(l_hy_115,
                        vec4(dot4(l_v03_166, l_dhx_120), dot4(l_v13_169, l_dhx_120), dot4(l_v23_172, l_dhx_120),
                            dot4(l_v33_175, l_dhx_120))))),
            dot4(l_hz_112,
                vec4(dot4(l_dhy_121, l_tv_176), dot4(l_dhy_121, l_tv_177), dot4(l_dhy_121, l_tv_178),
                    dot4(l_dhy_121, l_tv_179))),
            dot4(l_dhz_127,
                vec4(dot4(l_hy_115, l_tv_176), dot4(l_hy_115, l_tv_177), dot4(l_hy_115, l_tv_178),
                    dot4(l_hy_115, l_tv_179)))));
    l_m_232[2].v = ToWorldSpace3(glob->gv__t,
        vec3(
            dot4(l_hz_112,
                vec4(
                    dot4(l_hy_115,
                        vec4(dot4(l_v00_182, l_dhx_120), dot4(l_v10_185, l_dhx_120), dot4(l_v20_188, l_dhx_120),
                            dot4(l_v30_191, l_dhx_120))),
                    dot4(l_hy_115,
                        vec4(dot4(l_v01_194, l_dhx_120), dot4(l_v11_197, l_dhx_120), dot4(l_v21_200, l_dhx_120),
                            dot4(l_v31_203, l_dhx_120))),
                    dot4(l_hy_115,
                        vec4(dot4(l_v02_206, l_dhx_120), dot4(l_v12_209, l_dhx_120), dot4(l_v22_212, l_dhx_120),
                            dot4(l_v32_215, l_dhx_120))),
                    dot4(l_hy_115,
                        vec4(dot4(l_v03_218, l_dhx_120), dot4(l_v13_221, l_dhx_120), dot4(l_v23_224, l_dhx_120),
                            dot4(l_v33_227, l_dhx_120))))),
            dot4(l_hz_112,
                vec4(dot4(l_dhy_121, l_tv_228), dot4(l_dhy_121, l_tv_229), dot4(l_dhy_121, l_tv_230),
                    dot4(l_dhy_121, l_tv_231))),
            dot4(l_dhz_127,
                vec4(dot4(l_hy_115, l_tv_228), dot4(l_hy_115, l_tv_229), dot4(l_hy_115, l_tv_230),
                    dot4(l_hy_115, l_tv_231)))));
    self->sv_out = vec3(l_m_232[2].r[1]-l_m_232[1].r[2], l_m_232[0].r[2]-l_m_232[2].r[0],
        l_m_232[1].r[0]-l_m_232[0].r[1]);
    return DIDEROT_STABILIZE;
}
static void CURL_Stabilize (Diderot_Globals_t *glob, Strand_CURL_t *self)
{
    self->sv_out = self->sv_out;
}
Strand_t Strand_CURL = {.name = "CURL",.stateSzb = sizeof(Strand_CURL_t),.update = (update_method_t)CURL_Update,.stabilize = (stabilize_method_t)CURL_Stabilize,};
char *Outfile = "out.nrrd";
static void RegisterOutputOpts (Diderot_Options_t *opts)
{
    Diderot_OptAddString(opts, "o,output", "specify output-file file", &Outfile, true);
}
/*---------- begin c-util/fragments/nrrd-save-helper.in ----------*/
/* helper function for saving output to nrrd file */
STATIC_INLINE int NrrdSaveHelper (const char *stem, const char *suffix, const char *ext, Nrrd *nData)
{
    size_t len = strlen(stem) + strlen(suffix) + strlen(ext) + 2;
    char *buf = (char *)malloc(strlen(stem) + strlen(suffix) + strlen(ext) + 1);
    if (buf == 0)
	return 1;
    snprintf(buf, len, "%s%s.%s", stem, suffix, ext);
    int sts = nrrdSave (buf, nData, NULL);
    free (buf);
    return 0;
}
/*---------- end c-util/fragments/nrrd-save-helper.in ----------*/
bool Diderot_OutputGet_out (Diderot_World_t *wrld, Nrrd *nData)
{
    // Compute sizes of nrrd file
    size_t sizes[4];
    sizes[0] = 3;
    sizes[1] = wrld->size[2];
    sizes[2] = wrld->size[1];
    sizes[3] = wrld->size[0];
    // Allocate nData nrrd
    if (nrrdMaybeAlloc_nva(nData, nrrdTypeFloat, 4, sizes)!=0) {
        char *msg = biffGetDone(NRRD);
        biffMsgAdd(wrld->errors, msg);
        FREE(msg);
        return true;
    }
    // copy data to output nrrd
    char *cp = (char *)nData->data;
    for (uint32_t i = 0; i<wrld->numStrands; i++) {
        memcpy(cp, &wrld->state[i].sv_out, 3*sizeof(float));
        cp += 3*sizeof(float);
    }
    nData->axis[0].kind = nrrdKind3Vector;
    nData->axis[1].kind = nrrdKindSpace;
    nData->axis[2].kind = nrrdKindSpace;
    nData->axis[3].kind = nrrdKindSpace;
    return false;
}
static void WriteOutput (Diderot_World_t *wrld)
{
    Nrrd *nData;
    nData = nrrdNew();
    if (Diderot_OutputGet_out(wrld, nData)) {
        fprintf(stderr, "Error getting nrrd data:\n%s\n", biffMsgStrGet(wrld->errors));
        exit(1);
    }
    else if (nrrdSave(Outfile, nData, NULL)) {
        fprintf(stderr, "Error saving nrrd:\n%s\n", biffGetDone(NRRD));
        exit(1);
    }
    nrrdNuke(nData);
}
static void PrintOutput (Diderot_World_t *wrld)
{
    Nrrd *nData;
    FILE *outS;
}
static const int32_t NumStrands = 1;
Strand_t *Diderot_Strands[1] = {[0] = &Strand_CURL,};
/*---------- begin c-target/fragments/init.in ----------*/
// Allocate the program's world
//
Diderot_World_t *Diderot_New ()
{
    Diderot_World_t *wrld = NEW(Diderot_World_t);
    if (wrld == 0)
        return 0;

    wrld->name          = ProgramName;
    wrld->errors        = biffMsgNew("DIDEROT");

    if (wrld->errors == 0) {
        FREE (wrld);
        return 0;
    }

    wrld->stage         = POST_NEW;
    wrld->verboseFlg    = false;
    wrld->nStrandTys    = 1;  /* FIXME */
    wrld->strandDesc    = &Strand_CURL;
    wrld->runTime       = 0.0;

#ifndef DIDEROT_NO_GLOBALS
    wrld->globals       = NEW(Diderot_Globals_t);
    if (wrld->globals == 0) {
        biffMsgNix (wrld->errors);
        FREE (wrld);
        return 0;
    }
#endif

#ifdef DIDEROT_TARGET_PARALLEL
    wrld->sched         = NEW(Diderot_Sched_t);
    if ((wrld->sched == 0) 
    || Diderot_GetNumCPUs(&(wrld->sched->cpuInfo))) {
        biffMsgNix (wrld->errors);
        FREE(wrld->globals);
        FREE(wrld);
        return 0;
    }
    wrld->sched->numWorkers = wrld->sched->cpuInfo.numHWCores;
#endif

    return wrld;

}

// Initialize the program's world
//
bool Diderot_Init (Diderot_World_t *wrld)
{
    if (wrld->stage != POST_NEW) {
        biffMsgAdd (wrld->errors, "multiple calls to Diderot_Init");
        return true;
    }

#ifdef DIDEROT_TARGET_PARALLEL
  // initialize synchronization structures
    if ((pthread_mutex_init (&(wrld->sched->lock), 0) != 0)
    || (pthread_cond_init (&(wrld->sched->barrier), 0) != 0)
    || (pthread_cond_init (&(wrld->sched->runWait), 0) != 0)) {
        biffMsgAdd (wrld->errors, "unable to initialize scheduler structures");
        return true;
    }
    wrld->sched->numActive = 0;
#else /* DIDEROT_TARGET_C */
    wrld->numActive = 0;
#endif

#if !defined(DIDEROT_STANDALONE_EXEC) && !defined(DIDEROT_NO_INPUTS)
  // initialize the defined flags for the input globals
    Diderot_InitDefined (wrld);
#endif

    wrld->stage = POST_INIT;

    return false;

}
/*---------- end c-target/fragments/init.in ----------*/
/*---------- begin c-target/fragments/alloc.in ----------*/
//! allocate the initial strands and initialize the rest of the world structure.
static bool AllocInitially (
    Diderot_World_t *wrld,      // world
    bool isArray,               // is the initialization an array or collection?
    uint32_t nAxes,             // depth of iteration nesting
    uint32_t *base,             // nAxes array of base indices
    uint32_t *size)             // nAxes array of iteration sizes
{
    wrld->isArray = isArray;
    wrld->nAxes = nAxes;
    wrld->base = NEWVEC(uint32_t, nAxes);
    wrld->size = NEWVEC(uint32_t, nAxes);
    size_t numStrands = 1;
    for (uint32_t i = 0;  i < wrld->nAxes;  i++) {
        numStrands *= size[i];
        wrld->base[i] = base[i];
        wrld->size[i] = size[i];
    }

    if (wrld->verboseFlg) {
        fprintf (stderr, "AllocInitially: %d", size[0]);
        for (uint32_t i = 1;  i < nAxes;  i++) fprintf(stderr, " x %d", size[i]);
        fprintf (stderr, "\n");
    }

  // allocate the strand state pointers
    wrld->numStrands = numStrands;
#ifdef DIDEROT_TARGET_PARALLEL
    wrld->sched->numActive = numStrands;
#else /* DIDEROT_TARGET_C */
    wrld->numActive = numStrands;
#endif
    wrld->status = NEWVEC(uint8_t, numStrands);
#ifdef DIDEROT_DUAL_STATE
    wrld->inState = NEWVEC(Strand_CURL_t *, numStrands);
    wrld->outState = NEWVEC(Strand_CURL_t *, numStrands);
    if ((wrld->inState == 0) || (wrld->outState == 0) || (wrld->status == 0)) {
        biffMsgAdd (wrld->errors, "unable to allocate strand states\n");
        return true;
    }
#else
    wrld->state = NEWVEC(Strand_CURL_t, numStrands);
    if ((wrld->state == 0) || (wrld->status == 0)) {
        biffMsgAdd (wrld->errors, "unable to allocate strand states\n");
        return true;
    }
#endif

  // initialize strand state pointers etc.
    for (size_t i = 0;  i < numStrands;  i++) {
#ifdef DIDEROT_DUAL_STATE
        wrld->inState[i] = NEW(Strand_CURL_t);
        wrld->outState[i] = NEW(Strand_CURL_t);
#endif
        wrld->status[i] = DIDEROT_ACTIVE;
    }

    return false;

} // AllocInitially
/*---------- end c-target/fragments/alloc.in ----------*/
bool Diderot_Initially (Diderot_World_t *wrld)
{
    if (InitGlobals(wrld)) {
        return true;
    }
    Diderot_Globals_t *glob = wrld->globals;
    Diderot_int_t l__t_234;
    Diderot_int_t l__t_235;
    Diderot_int_t l__t_236;
    l__t_234 = glob->gv_imgSizeZ-1;
    l__t_235 = glob->gv_imgSizeY-1;
    l__t_236 = glob->gv_imgSizeX-1;
    // allocate initial block of strands
    uint32_t base[3] = {[0] = 0,[1] = 0,[2] = 0,};
    uint32_t size[3] = {[0] = l__t_234-0+1,[1] = l__t_235-0+1,[2] = l__t_236-0+1,};
    if (AllocInitially(wrld, true, 3, base, size)) {
        return true;
    }
    // initially
    uint32_t ix = 0;
    for (Diderot_int_t i_zi_239 = 0; i_zi_239<=l__t_234; i_zi_239++) {
        for (Diderot_int_t i_yi_238 = 0; i_yi_238<=l__t_235; i_yi_238++) {
            for (Diderot_int_t i_xi_237 = 0; i_xi_237<=l__t_236; i_xi_237++) {
                CURL_InitState(glob, &wrld->state[ix], i_xi_237, i_yi_238, i_zi_239);
                ix++;
            }
        }
    }
    wrld->stage = POST_INITIALLY;
    return false;
}
/*---------- begin c-target/fragments/seq-run-nobsp.in ----------*/
//! Run the Diderot program (sequential version without BSP semantics)
//! \param wrld the world-state of the Diderot program
//! \param maxNSteps the limit on the number of super steps; 0 means unlimited
//! \return the number of steps taken.
uint32_t Diderot_Run (Diderot_World_t *wrld, uint32_t maxNSteps)
{
    if (wrld->stage < POST_INITIALLY) {
	biffMsgAdd (wrld->errors, "attempt to run uninitialized program");
	return 0;
    }
    wrld->stage = RUNNING;    

#ifndef DIDEROT_NO_GLOBALS
    Diderot_Globals_t *glob = wrld->globals;
#endif

    if (maxNSteps == 0) maxNSteps = 0xffffffff;  // essentially unlimited

    double t0 = airTime();

  // iterate until all strands are stable
    if (wrld->verboseFlg) fprintf(stderr, "run with %d strands ...\n", wrld->numStrands);
    uint32_t nActive = wrld->numActive;
    uint32_t maxStepsTaken = 0;
    for (int i = 0;  i < wrld->numStrands;  i++) {
	uint32_t nSteps = 0;
	uint32_t limit = maxNSteps;
	StrandStatus_t sts = wrld->status[i];
	Strand_CURL_t *self = &wrld->state[i];
	while ((! sts) && (limit-- > 0)) {
#ifdef DIDEROT_NO_GLOBALS
	    sts = CURL_Update(self);
#else
	    sts = CURL_Update(glob, self);
#endif
        }
        switch (sts) {
          case DIDEROT_STABILIZE:
          // stabilize the strand's state.
#ifdef DIDEROT_NO_GLOBALS
            CURL_Stabilize (self);
#else
            CURL_Stabilize (glob, self);
#endif
            wrld->status[i] = DIDEROT_STABLE;
            nActive--;
            break;
          case DIDEROT_DIE:
            wrld->status[i] = DIDEROT_DIE;
            nActive--;
            break;
          default:
            assert (sts == wrld->status[i]);
            break;
        }
	if ((maxNSteps - limit) > maxStepsTaken)
	    maxStepsTaken = maxNSteps - limit;
    }

    wrld->numActive = nActive;

    t0 = airTime() - t0;
    if (wrld->verboseFlg) {
        fprintf (stderr, "done in %f seconds\n", t0);
    }
    wrld->runTime += t0;

    if (wrld->numActive == 0)
	wrld->stage = DONE;

    return maxStepsTaken;

} // Diderot_Run
/*---------- end c-target/fragments/seq-run-nobsp.in ----------*/
/*---------- begin c-target/fragments/shutdown.in ----------*/
//! shutdown and deallocate the world
void Diderot_Shutdown (Diderot_World_t *wrld)
{
    biffMsgNix (wrld->errors);
#ifndef DIDEROT_NO_GLOBALS
    FreeGlobals (wrld);
    FREE (wrld->globals);
#endif
#ifdef DIDEROT_TARGET_PARALLEL
    FREE (wrld->sched);
#endif

#ifdef DIDEROT_DUAL_STATE
  // free strand objects
    for (int i = 0;  i < wrld->numStrands;  i++) {
	FREE (wrld->inState[i]);
	FREE (wrld->outState[i]);
    }
#endif

  // free state arrays
#ifdef DIDEROT_DUAL_STATE
    FREE (wrld->inState);
    FREE (wrld->outState);
#else
    FREE (wrld->state);
#endif
    FREE (wrld->status);

  // free axis info
    FREE (wrld->base);
    FREE (wrld->size);

    FREE (wrld);

} // Diderot_Shutdown
/*---------- end c-target/fragments/shutdown.in ----------*/
/*---------- begin c-target/fragments/seq-main.in ----------*/
//! Main function for sequential C target
//
int main (int argc, const char **argv)
{
    bool        timingFlg = false;      //! true if timing computation
    bool        printOutputFlg = false; //! true if output is in text format

  // create the world
    Diderot_World_t *wrld = Diderot_New();
    if (wrld == 0)
        exit (1);

  // handle command-line options
    {
	Diderot_Options_t *opts = Diderot_OptNew ();
#ifndef DIDEROT_NO_INPUTS
	Diderot_Inputs_t inputs;
	InitDefaults (&inputs);
#endif
	Diderot_OptAddFlag (opts, "v,verbose", "enable runtime-system messages", &(wrld->verboseFlg));
	Diderot_OptAddFlag (opts, "t,timing", "enable execution timing", &timingFlg);
//	Diderot_OptAddFlag (opts, "T,text", "enable text output", &printOutputFlg);
#ifndef DIDEROT_NO_INPUTS
	RegisterGlobalOpts (&inputs, opts);
#endif
	RegisterOutputOpts (opts);
	Diderot_OptProcess (opts, argc, argv);
	Diderot_OptFree (opts);
#ifndef DIDEROT_NO_INPUTS
	if (InitInputs (wrld, &inputs)) {
	    fprintf(stderr, "Error initializing inputs:\n%s\n", biffMsgStrGet(wrld->errors));
	    exit(1);
	}
#endif
    }

  // initialize scheduler stuff
    if (wrld->verboseFlg)
        fprintf (stderr, "initializing world ...\n");
    if (Diderot_Init (wrld)) {
        fprintf(stderr, "Error initializing world:\n%s\n", biffMsgStrGet(wrld->errors));
        exit(1);
    }

  // run the generated global initialization code
    if (wrld->verboseFlg)
        fprintf (stderr, "initializing globals ...\n");
    if (Diderot_Initially (wrld)) {
        fprintf(stderr, "Error in global initialization:\n%s\n", biffMsgStrGet(wrld->errors));
        exit(1);
    }

    if (wrld->verboseFlg)
        fprintf(stderr, "run with %d strands ...\n", wrld->numStrands);
    uint32_t nSteps = Diderot_Run (wrld, 0);
    if (wrld->errors->errNum > 0) {
        fprintf(stderr, "Error during execution:\n%s\n", biffMsgStrGet(wrld->errors));
        exit(1);
    }

    if (wrld->verboseFlg)
        fprintf (stderr, "done: %d steps, in %f seconds\n", nSteps, wrld->runTime);
    else if (timingFlg)
        printf ("usr=%f\n", wrld->runTime);

  // output the final strand states
    if (printOutputFlg)
        PrintOutput (wrld);
    else
        WriteOutput (wrld);
    
    Diderot_Shutdown (wrld);

    return 0;

} // main
/*---------- end c-target/fragments/seq-main.in ----------*/

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0