cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

chevydevil
Adept II

warning expression has no effect

I got that warning for the coordinate of an image. 
Am I doing something wrong?

float4 af4(float4 f){ f.x = (isless(f.x,0.0f)) ? (f.x * (-1)) : f.x; f.y = (isless(f.y,0.0f)) ? (f.y * (-1)) : f.y; f.z = (isless(f.z,0.0f)) ? (f.z * (-1)) : f.z; return f; } typedef struct { float4 rl1, rl2; float m_v0, stiffnes_v, stiffnes_e, c; int4 mps; } tetra ; typedef struct { float4 mpPos, m_x0, m_f_ext, m_f_con, m_f_pen, velocity; int4 test; } masspoint; __kernel void force_calc(__global masspoint* _massPoints, __global tetra* _tetra, __write_only image2d_t image) { int id = get_global_id(0); __global tetra *t = &_tetra[id]; //get masspoint indices int mpid1 = t->mps.x; int mpid2 = t->mps.y; int mpid3 = t->mps.z; int mpid4 = t->mps.w; //get masspoints __global masspoint *m1 = &_massPoints[mpid1]; __global masspoint *m2 = &_massPoints[mpid2]; __global masspoint *m3 = &_massPoints[mpid3]; __global masspoint *m4 = &_massPoints[mpid4]; //calculate edges float4 l_ab, l_ac, l_ad, l_bc, l_bd, l_cd; l_ab = (m1->mpPos-m2->mpPos); l_ac = (m1->mpPos-m3->mpPos); l_ad = (m1->mpPos-m4->mpPos); l_bc = (m2->mpPos-m3->mpPos); l_bd = (m2->mpPos-m4->mpPos); l_cd = (m3->mpPos-m4->mpPos); //calculate edge forces float4 fe12, fe13, fe14, fe23, fe24, fe34; fe12 = t->stiffnes_e * (length(l_ab) - t->rl1.x) / length(l_ab) * l_ab; fe13 = t->stiffnes_e * (length(l_ac) - t->rl1.x) / length(l_ac) * l_ac; fe14 = t->stiffnes_e * (length(l_ad) - t->rl1.x) / length(l_ad) * l_ad; fe23 = t->stiffnes_e * (length(l_bc) - t->rl1.x) / length(l_bc) * l_bc; fe24 = t->stiffnes_e * (length(l_bd) - t->rl1.x) / length(l_bd) * l_bd; fe34 = t->stiffnes_e * (length(l_cd) - t->rl1.x) / length(l_cd) * l_cd; //calculate actual volume float v = dot(cross(m2->mpPos - m1->mpPos, m3->mpPos - m1->mpPos), m4->mpPos - m1->mpPos) / 6.0f; //calculate unit-length normals float4 n1, n2, n3, n4; n1 = normalize(cross(m3->mpPos - m2->mpPos, m4->mpPos - m2->mpPos)); n2 = normalize(cross(m3->mpPos - m1->mpPos, m4->mpPos - m1->mpPos)); n3 = normalize(cross(m2->mpPos - m1->mpPos, m4->mpPos - m1->mpPos)); n4 = normalize(cross(m2->mpPos - m1->mpPos, m3->mpPos - m1->mpPos)); //calculate volume preservation forces float4 fv1, fv2, fv3, fv4; fv1 = t->stiffnes_v * (v - t->m_v0) * n1; fv2 = t->stiffnes_v * (v - t->m_v0) * n2; fv3 = t->stiffnes_v * (v - t->m_v0) * n3; fv4 = t->stiffnes_v * (v - t->m_v0) * n4; int2 c1, c2, c3, c4; c1 = (t->mps.x, id); write_imagef(image, c1, (fv1+af4(fe12)+af4(fe13)+af4(fe14))); write_imagef(image, (mpid2, id), (fv2+af4(fe23)+af4(fe24)-af4(fe12))); write_imagef(image, (mpid3, id), (fv3+af4(fe34)-af4(fe13)-af4(fe23))); write_imagef(image, (mpid4, id), (fv4-af4(fe14)-af4(fe24)-af4(fe34))); }

0 Likes
2 Replies
Illusio
Journeyman III

Yeah. you have a slight syntax error when creating your vectors.(It's 6.1.6 Vector Literals in the standard btw)


The syntax is

int2 a;

a = (int2)(0,3);

When you omit the type in paranthesis you're actually specifying a comma separated sequence of operations, of which only the last one will generate a value. So the warning is basically similar to how the compiler would warn you of a possible typo if you wrote a statement like this:

myvar;

It just doesn't produce any effect whatsoever.

 

0 Likes

Hello. Thanks for the reply. Problem solved.

0 Likes