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

SCM Repository

[diderot] View of /branches/vis12-cl/rtest/tests/curl3d/curl3d.c
ViewVC logotype

View of /branches/vis12-cl/rtest/tests/curl3d/curl3d.c

Parent Directory Parent Directory | Revision Log Revision Log

Revision 2750 - (download) (as text) (annotate)
Wed Oct 1 23:35:54 2014 UTC (4 years, 9 months ago) by jhr
File size: 34649 byte(s)
  adding additiona regression tests from vis12 branch
/*! \file curl3d.c
 * Generated from curl3d.diderot.

 * COPYRIGHT (c) 2012 The Diderot Project (http://diderot-language.cs.uchicago.edu)
 * All rights reserved.

#include "Diderot/diderot.h"

static char *ProgramName = "curl3d.diderot";

typedef struct Diderot_struct_world Diderot_World_t;
typedef struct Diderot_struct_CURL Strand_CURL_t;
typedef struct {
    Diderot_int_t imgSizeX;
    Diderot_image3D_t *_t;
} Diderot_Globals_t;
struct Diderot_struct_world {
    const char *name;
    biffMsg *errors;
    bool verboseFlg;
    bool isArray;
    uint32_t nStrandTys;
    Strand_t *strandDesc;
    uint32_t nAxes;
    uint32_t *base;
    uint32_t *size;
    uint32_t numStrands;
    uint32_t numActive;
    uint8_t *status;
    Diderot_Globals_t *globals;
    Strand_CURL_t *state;
typedef struct {
} Diderot_Inputs_t;
static bool InitGlobals (Diderot_World_t *wrld)
    Diderot_Globals_t *glob = wrld->globals;
    glob->imgSizeX = 16;
    if (Diderot_LoadImage3D((WorldPrefix_t *)wrld, "../../data/const-curl3d.nrrd", &glob->_t)) return true;
    return false;
static bool FreeGlobals (Diderot_World_t *wrld)
    Diderot_Globals_t *glob = wrld->globals;
    return false;
static void InitDefaults (Diderot_Inputs_t *inp)
static void RegisterGlobalOpts (Diderot_Inputs_t *inp, Diderot_Options_t *opts)
static bool InitInputs (Diderot_World_t *wrld, Diderot_Inputs_t *inp)
    Diderot_Globals_t *glob = wrld->globals;
    return false;
struct Diderot_struct_CURL {
    vec3f_t out;
    vec3f_t pos;
    Diderot_real_t zz;
    Diderot_real_t yy;
    Diderot_real_t 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_t2_3;
    Diderot_real_t l_xx_4;
    Diderot_real_t l_yy_5;
    Diderot_real_t l_zz_6;
    l_t2_3 = (float)glob->imgSizeX-0.1e1f-0.0f;
    l_xx_4 = lerp(0.2e1f, 0.17e2f, ((float)p_xi_0-0.0f)/l_t2_3);
    l_yy_5 = lerp(0.2e1f, 0.17e2f, ((float)p_yi_1-0.0f)/l_t2_3);
    l_zz_6 = lerp(0.2e1f, 0.17e2f, ((float)p_zi_2-0.0f)/l_t2_3);
    self->xx = l_xx_4;
    self->yy = l_yy_5;
    self->zz = l_zz_6;
    self->pos = vec3(l_xx_4, l_yy_5, l_zz_6);
    self->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_7;
    vec3f_t l_nd_8;
    vec3f_t l_f_9;
    vec3i_t l_n_10;
    Diderot_int_t l_ix_11;
    Diderot_int_t l_t2_12;
    Diderot_int_t l_iy_13;
    Diderot_int_t l_t2_14;
    Diderot_int_t l_iz_15;
    Diderot_int_t l_t_16;
    Diderot_int_t l_t1_17;
    Diderot_int_t l_index_18;
    Diderot_int_t l_offp_19;
    float *l_imgBaseAddr_20;
    float *l_a_21;
    vec4f_t l_v00_22;
    Diderot_int_t l_iy_23;
    Diderot_int_t l_t1_24;
    Diderot_int_t l_index_25;
    Diderot_int_t l_offp_26;
    float *l_a_27;
    vec4f_t l_v10_28;
    Diderot_int_t l_iy_29;
    Diderot_int_t l_t1_30;
    Diderot_int_t l_index_31;
    Diderot_int_t l_offp_32;
    float *l_a_33;
    vec4f_t l_v20_34;
    Diderot_int_t l_iy_35;
    Diderot_int_t l_t1_36;
    Diderot_int_t l_index_37;
    Diderot_int_t l_offp_38;
    float *l_a_39;
    vec4f_t l_v30_40;
    Diderot_int_t l_iz_41;
    Diderot_int_t l_t_42;
    Diderot_int_t l_t1_43;
    Diderot_int_t l_index_44;
    Diderot_int_t l_offp_45;
    float *l_a_46;
    vec4f_t l_v01_47;
    Diderot_int_t l_t1_48;
    Diderot_int_t l_index_49;
    Diderot_int_t l_offp_50;
    float *l_a_51;
    vec4f_t l_v11_52;
    Diderot_int_t l_t1_53;
    Diderot_int_t l_index_54;
    Diderot_int_t l_offp_55;
    float *l_a_56;
    vec4f_t l_v21_57;
    Diderot_int_t l_t1_58;
    Diderot_int_t l_index_59;
    Diderot_int_t l_offp_60;
    float *l_a_61;
    vec4f_t l_v31_62;
    Diderot_int_t l_iz_63;
    Diderot_int_t l_t_64;
    Diderot_int_t l_t1_65;
    Diderot_int_t l_index_66;
    Diderot_int_t l_offp_67;
    float *l_a_68;
    vec4f_t l_v02_69;
    Diderot_int_t l_t1_70;
    Diderot_int_t l_index_71;
    Diderot_int_t l_offp_72;
    float *l_a_73;
    vec4f_t l_v12_74;
    Diderot_int_t l_t1_75;
    Diderot_int_t l_index_76;
    Diderot_int_t l_offp_77;
    float *l_a_78;
    vec4f_t l_v22_79;
    Diderot_int_t l_t1_80;
    Diderot_int_t l_index_81;
    Diderot_int_t l_offp_82;
    float *l_a_83;
    vec4f_t l_v32_84;
    Diderot_int_t l_iz_85;
    Diderot_int_t l_t_86;
    Diderot_int_t l_t1_87;
    Diderot_int_t l_index_88;
    Diderot_int_t l_offp_89;
    float *l_a_90;
    vec4f_t l_v03_91;
    Diderot_int_t l_t1_92;
    Diderot_int_t l_index_93;
    Diderot_int_t l_offp_94;
    float *l_a_95;
    vec4f_t l_v13_96;
    Diderot_int_t l_t1_97;
    Diderot_int_t l_index_98;
    Diderot_int_t l_offp_99;
    float *l_a_100;
    vec4f_t l_v23_101;
    Diderot_int_t l_t1_102;
    Diderot_int_t l_index_103;
    Diderot_int_t l_offp_104;
    float *l_a_105;
    vec4f_t l_v33_106;
    Diderot_real_t l_fz_107;
    vec4f_t l_a_108;
    vec4f_t l_a0_109;
    vec4f_t l_a1_110;
    vec4f_t l_a2_111;
    vec4f_t l_a3_112;
    vec4f_t l_hz_113;
    Diderot_real_t l_fy_114;
    vec4f_t l_a_115;
    vec4f_t l_hy_116;
    Diderot_real_t l_fx_117;
    vec4f_t l_a_118;
    vec4f_t l_a1_119;
    vec4f_t l_a2_120;
    vec4f_t l_dhx_121;
    vec4f_t l_dhy_122;
    vec4f_t l_hx_123;
    vec4f_t l_tv_124;
    vec4f_t l_tv_125;
    vec4f_t l_tv_126;
    vec4f_t l_tv_127;
    vec4f_t l_dhz_128;
    Diderot_int_t l_offp_129;
    float *l_a_130;
    vec4f_t l_v00_131;
    Diderot_int_t l_offp_132;
    float *l_a_133;
    vec4f_t l_v10_134;
    Diderot_int_t l_offp_135;
    float *l_a_136;
    vec4f_t l_v20_137;
    Diderot_int_t l_offp_138;
    float *l_a_139;
    vec4f_t l_v30_140;
    Diderot_int_t l_offp_141;
    float *l_a_142;
    vec4f_t l_v01_143;
    Diderot_int_t l_offp_144;
    float *l_a_145;
    vec4f_t l_v11_146;
    Diderot_int_t l_offp_147;
    float *l_a_148;
    vec4f_t l_v21_149;
    Diderot_int_t l_offp_150;
    float *l_a_151;
    vec4f_t l_v31_152;
    Diderot_int_t l_offp_153;
    float *l_a_154;
    vec4f_t l_v02_155;
    Diderot_int_t l_offp_156;
    float *l_a_157;
    vec4f_t l_v12_158;
    Diderot_int_t l_offp_159;
    float *l_a_160;
    vec4f_t l_v22_161;
    Diderot_int_t l_offp_162;
    float *l_a_163;
    vec4f_t l_v32_164;
    Diderot_int_t l_offp_165;
    float *l_a_166;
    vec4f_t l_v03_167;
    Diderot_int_t l_offp_168;
    float *l_a_169;
    vec4f_t l_v13_170;
    Diderot_int_t l_offp_171;
    float *l_a_172;
    vec4f_t l_v23_173;
    Diderot_int_t l_offp_174;
    float *l_a_175;
    vec4f_t l_v33_176;
    vec4f_t l_tv_177;
    vec4f_t l_tv_178;
    vec4f_t l_tv_179;
    vec4f_t l_tv_180;
    Diderot_int_t l_offp_181;
    float *l_a_182;
    vec4f_t l_v00_183;
    Diderot_int_t l_offp_184;
    float *l_a_185;
    vec4f_t l_v10_186;
    Diderot_int_t l_offp_187;
    float *l_a_188;
    vec4f_t l_v20_189;
    Diderot_int_t l_offp_190;
    float *l_a_191;
    vec4f_t l_v30_192;
    Diderot_int_t l_offp_193;
    float *l_a_194;
    vec4f_t l_v01_195;
    Diderot_int_t l_offp_196;
    float *l_a_197;
    vec4f_t l_v11_198;
    Diderot_int_t l_offp_199;
    float *l_a_200;
    vec4f_t l_v21_201;
    Diderot_int_t l_offp_202;
    float *l_a_203;
    vec4f_t l_v31_204;
    Diderot_int_t l_offp_205;
    float *l_a_206;
    vec4f_t l_v02_207;
    Diderot_int_t l_offp_208;
    float *l_a_209;
    vec4f_t l_v12_210;
    Diderot_int_t l_offp_211;
    float *l_a_212;
    vec4f_t l_v22_213;
    Diderot_int_t l_offp_214;
    float *l_a_215;
    vec4f_t l_v32_216;
    Diderot_int_t l_offp_217;
    float *l_a_218;
    vec4f_t l_v03_219;
    Diderot_int_t l_offp_220;
    float *l_a_221;
    vec4f_t l_v13_222;
    Diderot_int_t l_offp_223;
    float *l_a_224;
    vec4f_t l_v23_225;
    Diderot_int_t l_offp_226;
    float *l_a_227;
    vec4f_t l_v33_228;
    vec4f_t l_tv_229;
    vec4f_t l_tv_230;
    vec4f_t l_tv_231;
    vec4f_t l_tv_232;
    Diderot_Mat3x3_t l_m_233;
    l_x_7 = ToImageSpace3(glob->_t, self->pos);
    l_nd_8 = floor3(l_x_7);
    l_f_9 = l_x_7-l_nd_8;
    l_n_10 = vec3rtoi(l_nd_8);
    l_ix_11 = -1+((union3i_t)l_n_10).i[0];
    l_t2_12 = ((union3i_t)l_n_10).i[1];
    l_iy_13 = -1+l_t2_12;
    l_t2_14 = ((union3i_t)l_n_10).i[2];
    l_iz_15 = -1+l_t2_14;
    l_t_16 = 20*l_iz_15;
    l_t1_17 = l_iy_13+l_t_16;
    l_index_18 = l_ix_11+20*l_t1_17;
    l_offp_19 = 3*l_index_18;
    l_imgBaseAddr_20 = (float *)glob->_t->data;
    l_a_21 = l_imgBaseAddr_20+l_offp_19;
    float *vp_47 = l_a_21;
    l_v00_22 = vec4(vp_47[0], vp_47[3], vp_47[6], vp_47[9]);
    l_iy_23 = 0+l_t2_12;
    l_t1_24 = l_iy_23+l_t_16;
    l_index_25 = l_ix_11+20*l_t1_24;
    l_offp_26 = 3*l_index_25;
    l_a_27 = l_imgBaseAddr_20+l_offp_26;
    float *vp_46 = l_a_27;
    l_v10_28 = vec4(vp_46[0], vp_46[3], vp_46[6], vp_46[9]);
    l_iy_29 = 1+l_t2_12;
    l_t1_30 = l_iy_29+l_t_16;
    l_index_31 = l_ix_11+20*l_t1_30;
    l_offp_32 = 3*l_index_31;
    l_a_33 = l_imgBaseAddr_20+l_offp_32;
    float *vp_45 = l_a_33;
    l_v20_34 = vec4(vp_45[0], vp_45[3], vp_45[6], vp_45[9]);
    l_iy_35 = 2+l_t2_12;
    l_t1_36 = l_iy_35+l_t_16;
    l_index_37 = l_ix_11+20*l_t1_36;
    l_offp_38 = 3*l_index_37;
    l_a_39 = l_imgBaseAddr_20+l_offp_38;
    float *vp_44 = l_a_39;
    l_v30_40 = vec4(vp_44[0], vp_44[3], vp_44[6], vp_44[9]);
    l_iz_41 = 0+l_t2_14;
    l_t_42 = 20*l_iz_41;
    l_t1_43 = l_iy_13+l_t_42;
    l_index_44 = l_ix_11+20*l_t1_43;
    l_offp_45 = 3*l_index_44;
    l_a_46 = l_imgBaseAddr_20+l_offp_45;
    float *vp_43 = l_a_46;
    l_v01_47 = vec4(vp_43[0], vp_43[3], vp_43[6], vp_43[9]);
    l_t1_48 = l_iy_23+l_t_42;
    l_index_49 = l_ix_11+20*l_t1_48;
    l_offp_50 = 3*l_index_49;
    l_a_51 = l_imgBaseAddr_20+l_offp_50;
    float *vp_42 = l_a_51;
    l_v11_52 = vec4(vp_42[0], vp_42[3], vp_42[6], vp_42[9]);
    l_t1_53 = l_iy_29+l_t_42;
    l_index_54 = l_ix_11+20*l_t1_53;
    l_offp_55 = 3*l_index_54;
    l_a_56 = l_imgBaseAddr_20+l_offp_55;
    float *vp_41 = l_a_56;
    l_v21_57 = vec4(vp_41[0], vp_41[3], vp_41[6], vp_41[9]);
    l_t1_58 = l_iy_35+l_t_42;
    l_index_59 = l_ix_11+20*l_t1_58;
    l_offp_60 = 3*l_index_59;
    l_a_61 = l_imgBaseAddr_20+l_offp_60;
    float *vp_40 = l_a_61;
    l_v31_62 = vec4(vp_40[0], vp_40[3], vp_40[6], vp_40[9]);
    l_iz_63 = 1+l_t2_14;
    l_t_64 = 20*l_iz_63;
    l_t1_65 = l_iy_13+l_t_64;
    l_index_66 = l_ix_11+20*l_t1_65;
    l_offp_67 = 3*l_index_66;
    l_a_68 = l_imgBaseAddr_20+l_offp_67;
    float *vp_39 = l_a_68;
    l_v02_69 = vec4(vp_39[0], vp_39[3], vp_39[6], vp_39[9]);
    l_t1_70 = l_iy_23+l_t_64;
    l_index_71 = l_ix_11+20*l_t1_70;
    l_offp_72 = 3*l_index_71;
    l_a_73 = l_imgBaseAddr_20+l_offp_72;
    float *vp_38 = l_a_73;
    l_v12_74 = vec4(vp_38[0], vp_38[3], vp_38[6], vp_38[9]);
    l_t1_75 = l_iy_29+l_t_64;
    l_index_76 = l_ix_11+20*l_t1_75;
    l_offp_77 = 3*l_index_76;
    l_a_78 = l_imgBaseAddr_20+l_offp_77;
    float *vp_37 = l_a_78;
    l_v22_79 = vec4(vp_37[0], vp_37[3], vp_37[6], vp_37[9]);
    l_t1_80 = l_iy_35+l_t_64;
    l_index_81 = l_ix_11+20*l_t1_80;
    l_offp_82 = 3*l_index_81;
    l_a_83 = l_imgBaseAddr_20+l_offp_82;
    float *vp_36 = l_a_83;
    l_v32_84 = vec4(vp_36[0], vp_36[3], vp_36[6], vp_36[9]);
    l_iz_85 = 2+l_t2_14;
    l_t_86 = 20*l_iz_85;
    l_t1_87 = l_iy_13+l_t_86;
    l_index_88 = l_ix_11+20*l_t1_87;
    l_offp_89 = 3*l_index_88;
    l_a_90 = l_imgBaseAddr_20+l_offp_89;
    float *vp_35 = l_a_90;
    l_v03_91 = vec4(vp_35[0], vp_35[3], vp_35[6], vp_35[9]);
    l_t1_92 = l_iy_23+l_t_86;
    l_index_93 = l_ix_11+20*l_t1_92;
    l_offp_94 = 3*l_index_93;
    l_a_95 = l_imgBaseAddr_20+l_offp_94;
    float *vp_34 = l_a_95;
    l_v13_96 = vec4(vp_34[0], vp_34[3], vp_34[6], vp_34[9]);
    l_t1_97 = l_iy_29+l_t_86;
    l_index_98 = l_ix_11+20*l_t1_97;
    l_offp_99 = 3*l_index_98;
    l_a_100 = l_imgBaseAddr_20+l_offp_99;
    float *vp_33 = l_a_100;
    l_v23_101 = vec4(vp_33[0], vp_33[3], vp_33[6], vp_33[9]);
    l_t1_102 = l_iy_35+l_t_86;
    l_index_103 = l_ix_11+20*l_t1_102;
    l_offp_104 = 3*l_index_103;
    l_a_105 = l_imgBaseAddr_20+l_offp_104;
    float *vp_32 = l_a_105;
    l_v33_106 = vec4(vp_32[0], vp_32[3], vp_32[6], vp_32[9]);
    l_fz_107 = ((union3f_t)l_f_9).r[2];
    l_a_108 = vec4(l_fz_107+0.1e1f, l_fz_107, l_fz_107-0.1e1f, l_fz_107-0.2e1f);
    l_a0_109 = vec4(0.133333333333e1f, 0.666666666667e0f, 0.666666666667e0f, 0.133333333333e1f);
    l_a1_110 = vec4(-0.2e1f, 0.0f, 0.0f, 0.2e1f);
    l_a2_111 = vec4(0.1e1f, -0.1e1f, -0.1e1f, 0.1e1f);
    l_a3_112 = vec4(-0.166666666667e0f, 0.5e0f, -0.5e0f, 0.166666666667e0f);
    l_hz_113 = l_a0_109+l_a_108*(l_a1_110+l_a_108*(l_a2_111+l_a_108*l_a3_112));
    l_fy_114 = ((union3f_t)l_f_9).r[1];
    l_a_115 = vec4(l_fy_114+0.1e1f, l_fy_114, l_fy_114-0.1e1f, l_fy_114-0.2e1f);
    l_hy_116 = l_a0_109+l_a_115*(l_a1_110+l_a_115*(l_a2_111+l_a_115*l_a3_112));
    l_fx_117 = ((union3f_t)l_f_9).r[0];
    l_a_118 = vec4(l_fx_117+0.1e1f, l_fx_117, l_fx_117-0.1e1f, l_fx_117-0.2e1f);
    l_a1_119 = vec4(0.2e1f, -0.2e1f, -0.2e1f, 0.2e1f);
    l_a2_120 = vec4(-0.5e0f, 0.15e1f, -0.15e1f, 0.5e0f);
    l_dhx_121 = l_a1_110+l_a_118*(l_a1_119+l_a_118*l_a2_120);
    l_dhy_122 = l_a1_110+l_a_115*(l_a1_119+l_a_115*l_a2_120);
    l_hx_123 = l_a0_109+l_a_118*(l_a1_110+l_a_118*(l_a2_111+l_a_118*l_a3_112));
    l_tv_124 = vec4(dot4(l_v00_22, l_hx_123), dot4(l_v10_28, l_hx_123), dot4(l_v20_34, l_hx_123),
        dot4(l_v30_40, l_hx_123));
    l_tv_125 = vec4(dot4(l_v01_47, l_hx_123), dot4(l_v11_52, l_hx_123), dot4(l_v21_57, l_hx_123),
        dot4(l_v31_62, l_hx_123));
    l_tv_126 = vec4(dot4(l_v02_69, l_hx_123), dot4(l_v12_74, l_hx_123), dot4(l_v22_79, l_hx_123),
        dot4(l_v32_84, l_hx_123));
    l_tv_127 = vec4(dot4(l_v03_91, l_hx_123), dot4(l_v13_96, l_hx_123), dot4(l_v23_101, l_hx_123),
        dot4(l_v33_106, l_hx_123));
    l_dhz_128 = l_a1_110+l_a_108*(l_a1_119+l_a_108*l_a2_120);
    l_offp_129 = 1+l_offp_19;
    l_a_130 = l_imgBaseAddr_20+l_offp_129;
    float *vp_31 = l_a_130;
    l_v00_131 = vec4(vp_31[0], vp_31[3], vp_31[6], vp_31[9]);
    l_offp_132 = 1+l_offp_26;
    l_a_133 = l_imgBaseAddr_20+l_offp_132;
    float *vp_30 = l_a_133;
    l_v10_134 = vec4(vp_30[0], vp_30[3], vp_30[6], vp_30[9]);
    l_offp_135 = 1+l_offp_32;
    l_a_136 = l_imgBaseAddr_20+l_offp_135;
    float *vp_29 = l_a_136;
    l_v20_137 = vec4(vp_29[0], vp_29[3], vp_29[6], vp_29[9]);
    l_offp_138 = 1+l_offp_38;
    l_a_139 = l_imgBaseAddr_20+l_offp_138;
    float *vp_28 = l_a_139;
    l_v30_140 = vec4(vp_28[0], vp_28[3], vp_28[6], vp_28[9]);
    l_offp_141 = 1+l_offp_45;
    l_a_142 = l_imgBaseAddr_20+l_offp_141;
    float *vp_27 = l_a_142;
    l_v01_143 = vec4(vp_27[0], vp_27[3], vp_27[6], vp_27[9]);
    l_offp_144 = 1+l_offp_50;
    l_a_145 = l_imgBaseAddr_20+l_offp_144;
    float *vp_26 = l_a_145;
    l_v11_146 = vec4(vp_26[0], vp_26[3], vp_26[6], vp_26[9]);
    l_offp_147 = 1+l_offp_55;
    l_a_148 = l_imgBaseAddr_20+l_offp_147;
    float *vp_25 = l_a_148;
    l_v21_149 = vec4(vp_25[0], vp_25[3], vp_25[6], vp_25[9]);
    l_offp_150 = 1+l_offp_60;
    l_a_151 = l_imgBaseAddr_20+l_offp_150;
    float *vp_24 = l_a_151;
    l_v31_152 = vec4(vp_24[0], vp_24[3], vp_24[6], vp_24[9]);
    l_offp_153 = 1+l_offp_67;
    l_a_154 = l_imgBaseAddr_20+l_offp_153;
    float *vp_23 = l_a_154;
    l_v02_155 = vec4(vp_23[0], vp_23[3], vp_23[6], vp_23[9]);
    l_offp_156 = 1+l_offp_72;
    l_a_157 = l_imgBaseAddr_20+l_offp_156;
    float *vp_22 = l_a_157;
    l_v12_158 = vec4(vp_22[0], vp_22[3], vp_22[6], vp_22[9]);
    l_offp_159 = 1+l_offp_77;
    l_a_160 = l_imgBaseAddr_20+l_offp_159;
    float *vp_21 = l_a_160;
    l_v22_161 = vec4(vp_21[0], vp_21[3], vp_21[6], vp_21[9]);
    l_offp_162 = 1+l_offp_82;
    l_a_163 = l_imgBaseAddr_20+l_offp_162;
    float *vp_20 = l_a_163;
    l_v32_164 = vec4(vp_20[0], vp_20[3], vp_20[6], vp_20[9]);
    l_offp_165 = 1+l_offp_89;
    l_a_166 = l_imgBaseAddr_20+l_offp_165;
    float *vp_19 = l_a_166;
    l_v03_167 = vec4(vp_19[0], vp_19[3], vp_19[6], vp_19[9]);
    l_offp_168 = 1+l_offp_94;
    l_a_169 = l_imgBaseAddr_20+l_offp_168;
    float *vp_18 = l_a_169;
    l_v13_170 = vec4(vp_18[0], vp_18[3], vp_18[6], vp_18[9]);
    l_offp_171 = 1+l_offp_99;
    l_a_172 = l_imgBaseAddr_20+l_offp_171;
    float *vp_17 = l_a_172;
    l_v23_173 = vec4(vp_17[0], vp_17[3], vp_17[6], vp_17[9]);
    l_offp_174 = 1+l_offp_104;
    l_a_175 = l_imgBaseAddr_20+l_offp_174;
    float *vp_16 = l_a_175;
    l_v33_176 = vec4(vp_16[0], vp_16[3], vp_16[6], vp_16[9]);
    l_tv_177 = vec4(dot4(l_v00_131, l_hx_123), dot4(l_v10_134, l_hx_123), dot4(l_v20_137, l_hx_123),
        dot4(l_v30_140, l_hx_123));
    l_tv_178 = vec4(dot4(l_v01_143, l_hx_123), dot4(l_v11_146, l_hx_123), dot4(l_v21_149, l_hx_123),
        dot4(l_v31_152, l_hx_123));
    l_tv_179 = vec4(dot4(l_v02_155, l_hx_123), dot4(l_v12_158, l_hx_123), dot4(l_v22_161, l_hx_123),
        dot4(l_v32_164, l_hx_123));
    l_tv_180 = vec4(dot4(l_v03_167, l_hx_123), dot4(l_v13_170, l_hx_123), dot4(l_v23_173, l_hx_123),
        dot4(l_v33_176, l_hx_123));
    l_offp_181 = 2+l_offp_19;
    l_a_182 = l_imgBaseAddr_20+l_offp_181;
    float *vp_15 = l_a_182;
    l_v00_183 = vec4(vp_15[0], vp_15[3], vp_15[6], vp_15[9]);
    l_offp_184 = 2+l_offp_26;
    l_a_185 = l_imgBaseAddr_20+l_offp_184;
    float *vp_14 = l_a_185;
    l_v10_186 = vec4(vp_14[0], vp_14[3], vp_14[6], vp_14[9]);
    l_offp_187 = 2+l_offp_32;
    l_a_188 = l_imgBaseAddr_20+l_offp_187;
    float *vp_13 = l_a_188;
    l_v20_189 = vec4(vp_13[0], vp_13[3], vp_13[6], vp_13[9]);
    l_offp_190 = 2+l_offp_38;
    l_a_191 = l_imgBaseAddr_20+l_offp_190;
    float *vp_12 = l_a_191;
    l_v30_192 = vec4(vp_12[0], vp_12[3], vp_12[6], vp_12[9]);
    l_offp_193 = 2+l_offp_45;
    l_a_194 = l_imgBaseAddr_20+l_offp_193;
    float *vp_11 = l_a_194;
    l_v01_195 = vec4(vp_11[0], vp_11[3], vp_11[6], vp_11[9]);
    l_offp_196 = 2+l_offp_50;
    l_a_197 = l_imgBaseAddr_20+l_offp_196;
    float *vp_10 = l_a_197;
    l_v11_198 = vec4(vp_10[0], vp_10[3], vp_10[6], vp_10[9]);
    l_offp_199 = 2+l_offp_55;
    l_a_200 = l_imgBaseAddr_20+l_offp_199;
    float *vp_9 = l_a_200;
    l_v21_201 = vec4(vp_9[0], vp_9[3], vp_9[6], vp_9[9]);
    l_offp_202 = 2+l_offp_60;
    l_a_203 = l_imgBaseAddr_20+l_offp_202;
    float *vp_8 = l_a_203;
    l_v31_204 = vec4(vp_8[0], vp_8[3], vp_8[6], vp_8[9]);
    l_offp_205 = 2+l_offp_67;
    l_a_206 = l_imgBaseAddr_20+l_offp_205;
    float *vp_7 = l_a_206;
    l_v02_207 = vec4(vp_7[0], vp_7[3], vp_7[6], vp_7[9]);
    l_offp_208 = 2+l_offp_72;
    l_a_209 = l_imgBaseAddr_20+l_offp_208;
    float *vp_6 = l_a_209;
    l_v12_210 = vec4(vp_6[0], vp_6[3], vp_6[6], vp_6[9]);
    l_offp_211 = 2+l_offp_77;
    l_a_212 = l_imgBaseAddr_20+l_offp_211;
    float *vp_5 = l_a_212;
    l_v22_213 = vec4(vp_5[0], vp_5[3], vp_5[6], vp_5[9]);
    l_offp_214 = 2+l_offp_82;
    l_a_215 = l_imgBaseAddr_20+l_offp_214;
    float *vp_4 = l_a_215;
    l_v32_216 = vec4(vp_4[0], vp_4[3], vp_4[6], vp_4[9]);
    l_offp_217 = 2+l_offp_89;
    l_a_218 = l_imgBaseAddr_20+l_offp_217;
    float *vp_3 = l_a_218;
    l_v03_219 = vec4(vp_3[0], vp_3[3], vp_3[6], vp_3[9]);
    l_offp_220 = 2+l_offp_94;
    l_a_221 = l_imgBaseAddr_20+l_offp_220;
    float *vp_2 = l_a_221;
    l_v13_222 = vec4(vp_2[0], vp_2[3], vp_2[6], vp_2[9]);
    l_offp_223 = 2+l_offp_99;
    l_a_224 = l_imgBaseAddr_20+l_offp_223;
    float *vp_1 = l_a_224;
    l_v23_225 = vec4(vp_1[0], vp_1[3], vp_1[6], vp_1[9]);
    l_offp_226 = 2+l_offp_104;
    l_a_227 = l_imgBaseAddr_20+l_offp_226;
    float *vp_0 = l_a_227;
    l_v33_228 = vec4(vp_0[0], vp_0[3], vp_0[6], vp_0[9]);
    l_tv_229 = vec4(dot4(l_v00_183, l_hx_123), dot4(l_v10_186, l_hx_123), dot4(l_v20_189, l_hx_123),
        dot4(l_v30_192, l_hx_123));
    l_tv_230 = vec4(dot4(l_v01_195, l_hx_123), dot4(l_v11_198, l_hx_123), dot4(l_v21_201, l_hx_123),
        dot4(l_v31_204, l_hx_123));
    l_tv_231 = vec4(dot4(l_v02_207, l_hx_123), dot4(l_v12_210, l_hx_123), dot4(l_v22_213, l_hx_123),
        dot4(l_v32_216, l_hx_123));
    l_tv_232 = vec4(dot4(l_v03_219, l_hx_123), dot4(l_v13_222, l_hx_123), dot4(l_v23_225, l_hx_123),
        dot4(l_v33_228, l_hx_123));
    l_m_233[0].v = ToWorldSpace3(glob->_t,
                        vec4(dot4(l_v00_22, l_dhx_121), dot4(l_v10_28, l_dhx_121), dot4(l_v20_34, l_dhx_121),
                            dot4(l_v30_40, l_dhx_121))),
                        vec4(dot4(l_v01_47, l_dhx_121), dot4(l_v11_52, l_dhx_121), dot4(l_v21_57, l_dhx_121),
                            dot4(l_v31_62, l_dhx_121))),
                        vec4(dot4(l_v02_69, l_dhx_121), dot4(l_v12_74, l_dhx_121), dot4(l_v22_79, l_dhx_121),
                            dot4(l_v32_84, l_dhx_121))),
                        vec4(dot4(l_v03_91, l_dhx_121), dot4(l_v13_96, l_dhx_121), dot4(l_v23_101, l_dhx_121),
                            dot4(l_v33_106, l_dhx_121))))),
                vec4(dot4(l_dhy_122, l_tv_124), dot4(l_dhy_122, l_tv_125), dot4(l_dhy_122, l_tv_126),
                    dot4(l_dhy_122, l_tv_127))),
                vec4(dot4(l_hy_116, l_tv_124), dot4(l_hy_116, l_tv_125), dot4(l_hy_116, l_tv_126),
                    dot4(l_hy_116, l_tv_127)))));
    l_m_233[1].v = ToWorldSpace3(glob->_t,
                        vec4(dot4(l_v00_131, l_dhx_121), dot4(l_v10_134, l_dhx_121), dot4(l_v20_137, l_dhx_121),
                            dot4(l_v30_140, l_dhx_121))),
                        vec4(dot4(l_v01_143, l_dhx_121), dot4(l_v11_146, l_dhx_121), dot4(l_v21_149, l_dhx_121),
                            dot4(l_v31_152, l_dhx_121))),
                        vec4(dot4(l_v02_155, l_dhx_121), dot4(l_v12_158, l_dhx_121), dot4(l_v22_161, l_dhx_121),
                            dot4(l_v32_164, l_dhx_121))),
                        vec4(dot4(l_v03_167, l_dhx_121), dot4(l_v13_170, l_dhx_121), dot4(l_v23_173, l_dhx_121),
                            dot4(l_v33_176, l_dhx_121))))),
                vec4(dot4(l_dhy_122, l_tv_177), dot4(l_dhy_122, l_tv_178), dot4(l_dhy_122, l_tv_179),
                    dot4(l_dhy_122, l_tv_180))),
                vec4(dot4(l_hy_116, l_tv_177), dot4(l_hy_116, l_tv_178), dot4(l_hy_116, l_tv_179),
                    dot4(l_hy_116, l_tv_180)))));
    l_m_233[2].v = ToWorldSpace3(glob->_t,
                        vec4(dot4(l_v00_183, l_dhx_121), dot4(l_v10_186, l_dhx_121), dot4(l_v20_189, l_dhx_121),
                            dot4(l_v30_192, l_dhx_121))),
                        vec4(dot4(l_v01_195, l_dhx_121), dot4(l_v11_198, l_dhx_121), dot4(l_v21_201, l_dhx_121),
                            dot4(l_v31_204, l_dhx_121))),
                        vec4(dot4(l_v02_207, l_dhx_121), dot4(l_v12_210, l_dhx_121), dot4(l_v22_213, l_dhx_121),
                            dot4(l_v32_216, l_dhx_121))),
                        vec4(dot4(l_v03_219, l_dhx_121), dot4(l_v13_222, l_dhx_121), dot4(l_v23_225, l_dhx_121),
                            dot4(l_v33_228, l_dhx_121))))),
                vec4(dot4(l_dhy_122, l_tv_229), dot4(l_dhy_122, l_tv_230), dot4(l_dhy_122, l_tv_231),
                    dot4(l_dhy_122, l_tv_232))),
                vec4(dot4(l_hy_116, l_tv_229), dot4(l_hy_116, l_tv_230), dot4(l_hy_116, l_tv_231),
                    dot4(l_hy_116, l_tv_232)))));
    self->out = vec3(l_m_233[2].r[1]-l_m_233[1].r[2], l_m_233[0].r[2]-l_m_233[2].r[0], l_m_233[1].r[0]-l_m_233[0].r[1]);
static void CURL_Stabilize (Diderot_Globals_t *glob, Strand_CURL_t *self)
    self->out = self->out;
Strand_t Strand_CURL = {.name = "CURL",.stateSzb = sizeof(Strand_CURL_t),.update = (update_method_t)CURL_Update,.stabilize = (stabilize_method_t)CURL_Stabilize,};
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);
        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].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));
        if (nrrdSave("out.nrrd", nData, NULL)) {
            fprintf(stderr, "Error saving nrrd:\n%s\n", biffGetDone(NRRD));
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,};
// 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->verboseFlg	= false;
    wrld->nStrandTys	= 1;  /* FIXME */
    wrld->strandDesc	= &Strand_CURL;
    wrld->globals       = NEW(Diderot_Globals_t);

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

    wrld->sched		= NEW(Diderot_Sched_t);
    if (wrld->sched == 0) {
	biffMsgNix (wrld->errors);
	return 0;

    return wrld;


// Initialize the program's world
bool Diderot_Init (Diderot_World_t *wrld)
    if (Diderot_GetNumCPUs(&(wrld->sched->cpuInfo))
    || (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->numWorkers = wrld->sched->cpuInfo.numHWCores;
    wrld->sched->numActive = 0;
#else /* DIDEROT_TARGET_C */
    wrld->numActive = 0;

  // initialize the defined flags for the input globals
    Diderot_InitDefined (wrld);

    return false;

//! 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;
    wrld->sched->numActive = numStrands;
#else /* DIDEROT_TARGET_C */
    wrld->numActive = numStrands;
    wrld->status = NEWVEC(uint8_t, numStrands);
    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;
    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;

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

    return false;

} // AllocInitially
bool Diderot_Initially (Diderot_World_t *wrld)
    if (InitGlobals(wrld)) return true;
    Diderot_Globals_t *glob = wrld->globals;
    Diderot_int_t l__t_234;
    l__t_234 = glob->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_234-0+1,[2] = l__t_234-0+1,};
    if (AllocInitially(wrld, true, 3, base, size)) return true;
    // initially
    uint32_t ix = 0;
    for (Diderot_int_t i_zi_237 = 0; i_zi_237<=l__t_234; i_zi_237++)
        for (Diderot_int_t i_yi_236 = 0; i_yi_236<=l__t_234; i_yi_236++)
            for (Diderot_int_t i_xi_235 = 0; i_xi_235<=l__t_234; i_xi_235++) {
                CURL_InitState(glob, &wrld->state[ix], i_xi_235, i_yi_236, i_zi_237);
    return false;
//! 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)
    Diderot_Globals_t *glob = wrld->globals;

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

  // 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)) {
	    sts = CURL_Update(glob, self);
        switch (sts) {
          case DIDEROT_STABILIZE:
          // stabilize the strand's state.
            CURL_Stabilize (glob, self);
            wrld->status[i] = DIDEROT_STABLE;
          case DIDEROT_DIE:
            wrld->status[i] = DIDEROT_DIE;
            assert (sts == wrld->status[i]);
	if ((maxNSteps - limit) > maxStepsTaken)
	    maxStepsTaken = maxNSteps - limit;

    wrld->numActive = nActive;

    return maxStepsTaken;

} // Diderot_Run
//! shutdown and deallocate the world
void Diderot_Shutdown (Diderot_World_t *wrld)
    biffMsgNix (wrld->errors);
    FreeGlobals (wrld);
    FREE (wrld->globals);
    FREE (wrld->sched);

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

  // free state arrays
    FREE (wrld->inState);
    FREE (wrld->outState);
    FREE (wrld->state);
    FREE (wrld->status);

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

    FREE (wrld);

} // Diderot_Shutdown
//! 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 ();
	Diderot_Inputs_t inputs;
	InitDefaults (&inputs);
	Diderot_OptAddFlag (opts, "verbose", "enable runtime-system messages", &(wrld->verboseFlg));
	Diderot_OptAddFlag (opts, "timing", "enable execution timing", &timingFlg);
	Diderot_OptAddFlag (opts, "text", "enable text output", &printOutputFlg);
	RegisterGlobalOpts (&inputs, opts);
	Diderot_OptProcess (opts, argc, argv);
	Diderot_OptFree (opts);
	if (InitInputs (wrld, &inputs)) {
	    fprintf(stderr, "Error initializing inputs:\n%s\n", biffMsgStrGet(wrld->errors));

  // 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));

  // 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));

    if (wrld->verboseFlg)
        fprintf(stderr, "run with %d strands ...\n", wrld->numStrands);
    double t0 = airTime();
    uint32_t nSteps = Diderot_Run (wrld, 0);
    double totalTime = airTime() - t0;

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

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

    return 0;

} // main

ViewVC Help
Powered by ViewVC 1.0.0