This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

EVE/VCOP/KernelC : Division operation have support or not ??

Hello,

I am writing program in kernel C. I need to division operation.

As there is no division operation available , tring to use right shift ( >>) for same.

But getting below error,

76.        diffOut = vin1 >> 2; // line in code

Error :-

"../practice1.k", line 76: error #26001-D: syntax error near 'vin1'
"../practice1.k", line 76: error #26001-D: syntax error near 'vin1'
"../practice1.k", line 76: error #26001-D: syntax error near ';'

So want to know that,

1. Is right shift support available ?

2. Is compiler doesn't support division operation because of result maybe in floating point ? (if so , right shift should work!!)

Any suggestion to do division operation!!

  • Hi Kajal,

       For right shift you need to do provide a negative shift to the left shift operator. So for example if you want to right shift by 2. Then you should do something like this :

    VShift = -2;

    diffOut = vin1 << VShift ; 

    Regards,

    Anshu

  • Hello Anshu,

    Above suggestion works fine.

    Just want to know, In c implementation, we cannot do shift operation with negative sign, so how it works in kernel C ??

    One more question,

    What is purpose of apply_sign() api in kernel C ?

    Regards,

    Kajal

  • Hi Kajal,

      Not all C instruction are available in kernel C and there are some instruction which are treated a bit differently as it is in this case with shift operator. Please refer section 1.10 of document SPRUHB9B.pdf which comes as part of arp32 compiler to know all the instruction supported by VCOP.

       What is purpose of apply_sign() api in kernel C ?

     Vdst = apply_sign(src1, src2);

               is equivalent to dst = (src1 == 0) ? 0 :((src1 > 0) ? src2 : –src2);

    Regards,

    Anshu

  • Hello Anshu,

    We do refer document SPRUHB9B.pdf.

    So,we know definition of apply_sign().

    Just want to know purpose of it, i didn't get anywhere in document.

    Regards,

    Kajal

  • Its just an operation to change the sign of a vector depending on another vector, which can be used depending on algorithms. I don't think any document would talk about the purpose of each instruction. I myself have not used this instruction but you can refer kernels\vlib\vcop_calc_inverse_structure_tensor_2x2\src_kernelC kernel to see where it is used.

    Regards,
    Anshu
  • Okay.
    Thank you.

    Regards,
    Kajal