Re: [brlcad-devel] OpenCL code query "bn_poly_t"

2017-03-20 Thread Shailesh Tripathi
Shailesh Tripathi
B.Tech. Part-IV
Electronics Engineering
IIT-BHU (Varanasi)

On Tue, Mar 21, 2017 at 2:51 AM, Vasco Alexandre da Silva Costa <
vasco.co...@gmail.com> wrote:

> On Mon, Mar 20, 2017 at 2:54 PM, Shailesh Tripathi <
> shailesh.tripathi.ec...@itbhu.ac.in> wrote:
>
>> Hello,
>> A few more doubts!
>>
>> 1. For the NEAR_ZERO function in "common.cl", the epsilon value used
>> should be *"RT_PCOEFF_TOL"* or  *"RT_DOT_TOL"?  *Basically, what are
>> these two different tolerance value for?
>>
>
> The maximum error value depends on the operations performed.
>

It is used to check if the imaginary part of the root is zero (in hrt.c), "*if
(NEAR_ZERO(complex[j].im, RT_***_TOL))".  *In this case which one needs to
be used and why?

>
> 2. In the "part", "rhc" and "rpc" codes, in place of "*segp->seg_in"* and
>> "*segp->seg_out", hits[0] and hits[1] *are used in the kernels. But in
>> the "*hrt*" code, these variables are not used. Would it be correct to
>> define these in the kernels? If yes, should it be linked the same way as in
>> other files?
>>
>
> HEART (hrt) primitives can have 4 ray-primitive intersection points
> similar to the TORUS (tor) primitive. IIRC all the other primitives you
> mentioned can only have 2 intersection points. So the intersections are
> processed differently.
>
>
>>
>> 3.  In "common.cl", *'bn_complex_t' *is defined but '*bn_poly_t' *is
>> not. So I I defined it in "common.cl" itself.
>>
>
> 'bn_poly_t' is not defined because it isn't necessary for our purposes and
> it wastes memory. Regardless of the kind of polynomial it always allocates
> as much memory as if it was a 6th order polynomial. See how 'tor_shot.cl'
> uses the solver for an example. You just allocate a double array with the
> required size and then pass it together with the polynomial length to the
> solver.
>

I will study the code and get back to you.
Thanks for your help :)

>
> --
> Vasco Alexandre da Silva Costa
> PhD in Computer Engineering (Computer Graphics)
> Instituto Superior Técnico/University of Lisbon, Portugal
>
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
BRL-CAD Developer mailing list
brlcad-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/brlcad-devel


Re: [brlcad-devel] OpenCL code query "bn_poly_t"

2017-03-20 Thread Vasco Alexandre da Silva Costa
On Mon, Mar 20, 2017 at 2:54 PM, Shailesh Tripathi <
shailesh.tripathi.ec...@itbhu.ac.in> wrote:

> Hello,
> A few more doubts!
>
> 1. For the NEAR_ZERO function in "common.cl", the epsilon value used
> should be *"RT_PCOEFF_TOL"* or  *"RT_DOT_TOL"?  *Basically, what are
> these two different tolerance value for?
>

The maximum error value depends on the operations performed.

2. In the "part", "rhc" and "rpc" codes, in place of "*segp->seg_in"*
and "*segp->seg_out",
> hits[0] and hits[1] *are used in the kernels. But in  the "*hrt*" code,
> these variables are not used. Would it be correct to define these in the
> kernels? If yes, should it be linked the same way as in other files?
>

HEART (hrt) primitives can have 4 ray-primitive intersection points similar
to the TORUS (tor) primitive. IIRC all the other primitives you mentioned
can only have 2 intersection points. So the intersections are processed
differently.


>
> 3.  In "common.cl", *'bn_complex_t' *is defined but '*bn_poly_t' *is not.
> So I I defined it in "common.cl" itself.
>

'bn_poly_t' is not defined because it isn't necessary for our purposes and
it wastes memory. Regardless of the kind of polynomial it always allocates
as much memory as if it was a 6th order polynomial. See how 'tor_shot.cl'
uses the solver for an example. You just allocate a double array with the
required size and then pass it together with the polynomial length to the
solver.

-- 
Vasco Alexandre da Silva Costa
PhD in Computer Engineering (Computer Graphics)
Instituto Superior Técnico/University of Lisbon, Portugal
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
BRL-CAD Developer mailing list
brlcad-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/brlcad-devel


Re: [brlcad-devel] OpenCL code query "bn_poly_t"

2017-03-20 Thread Shailesh Tripathi
Hello,
A few more doubts!

1. For the NEAR_ZERO function in "common.cl", the epsilon value used should
be *"RT_PCOEFF_TOL"* or  *"RT_DOT_TOL"?  *Basically, what are these two
different tolerance value for?

2. In the "part", "rhc" and "rpc" codes, in place of "*segp->seg_in"*
and "*segp->seg_out",
hits[0] and hits[1] *are used in the kernels. But in  the "*hrt*" code,
these variables are not used. Would it be correct to define these in the
kernels? If yes, should it be linked the same way as in other files?

3.  In "common.cl", *'bn_complex_t' *is defined but '*bn_poly_t' *is not.
So I I defined it in "common.cl" itself.

Regards
Shailesh




On Mon, Mar 20, 2017 at 2:37 PM, Vasco Alexandre da Silva Costa <
vasco.co...@gmail.com> wrote:

> On Sun, Mar 19, 2017 at 6:41 PM, Shailesh Tripathi , B.Tech., Electronics
> Engg., IIT (BHU), Varanasi (INDIA) 
> wrote:
>
>> Hello,
>> While writing the.cl file, I got stuck at a data type "*bn_poly_t*" and "
>> *bn_complex_t*". To use this in kernels, can these definitions be
>> imported or do I need to define these structures in the .cl file itself. Is
>> there a way to import these, or if not, defining them would not be any
>> issue. :)
>>
>
> The necessary types are defined in the include file "common.cl", which
> should also be included in the existing sample primitive implementations
> like 'ehy_shot.cl'.
>

In "common.cl", *'bn_complex_t' *is defined but '*bn_poly_t' *is not. So I
I defined it in "common.cl" itself.

>
> --
> Vasco Alexandre da Silva Costa
> PhD in Computer Engineering (Computer Graphics)
> Instituto Superior Técnico/University of Lisbon, Portugal
>
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
BRL-CAD Developer mailing list
brlcad-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/brlcad-devel


Re: [brlcad-devel] OpenCL code query "bn_poly_t"

2017-03-20 Thread Shailesh Tripathi
Hey Vasco,
Thanks a lot :)
That was a lot of knowledge in a single go :)
I will try these out and I hope to complete the task correctly ASAP  :)

Regards
Shailesh

Shailesh Tripathi
B.Tech. Part-IV
Electronics Engineering
IIT-BHU (Varanasi)

On Mon, Mar 20, 2017 at 2:59 PM, Vasco Alexandre da Silva Costa <
vasco.co...@gmail.com> wrote:

> On Sun, Mar 19, 2017 at 10:13 PM, Shailesh Tripathi , B.Tech., Electronics
> Engg., IIT (BHU), Varanasi (INDIA) 
> wrote:
>
>> ...
>> 1. How to use these functions '*rt_poly_roots', 'bu_log'*, *'bn_pr_roots'
>> *and '*VPRINT*' in the kernels (.cl file)
>>
>
> No text manipulation and text output functions (e.g. bu_log, bn_pr_roots,
> etc) are supported on the OpenCL library right now. So you can just comment
> those out.
> OpenCL does have a native library 'printf' function but in my experience,
> back when I implemented the OpenCL librt port, the implementation of the
> function is highly flaky on GPUs to say the least.
>
> 'rt_poly_roots' is available. It's implemented in 'solver.cl', and the
> function definition is at 'common.cl'.
>
>
>> 2. Why are functions like '*RT_GET_SEG' *eliminated in the the kenels
>> and how does *'BU_LIST_INSERT(&(seghead->l), &(segp->l));* ' be
>> equivalent to '*do_segp(res, idx, [0], [1]);' *?
>>
>
> You can just access struct members directly.
>
> As for the linked list manipulation functions, OpenCL does not support
> device side dynamic memory allocation. The data structures are currently
> passed as fixed size arrays allocated from the CPU side.
>
> --
> Vasco Alexandre da Silva Costa
> PhD in Computer Engineering (Computer Graphics)
> Instituto Superior Técnico/University of Lisbon, Portugal
>
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
BRL-CAD Developer mailing list
brlcad-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/brlcad-devel


Re: [brlcad-devel] OpenCL code query "bn_poly_t"

2017-03-20 Thread Vasco Alexandre da Silva Costa
Most of the vector macros are available as standard OpenCL operators or
functions. You can get a listing of those here:
https://www.khronos.org/files/opencl-1-2-quick-reference-card.pdf

e.g. VSCALE(a, b, c) can be replaced with a = b * c

So yes you can use translate the code like you mentioned.

On Sun, Mar 19, 2017 at 9:37 PM, Shailesh Tripathi , B.Tech., Electronics
Engg., IIT (BHU), Varanasi (INDIA) 
wrote:

> Also,
> For scalar multiplication VSCALE() is used in the C code. Can I simply use
> multiplication operator (*) in the kernel as VSCALE in unavailable in
> OpenCL.
> C code:
> *VSCALE(norm_pprime, dprime, VDOT(pprime, dprime));*
> OpenCL code:
>
> * norm_pprime = dprime * dot(pprime, dprime);*
> Regards
> Shailesh
>
> Shailesh Tripathi
> B.Tech. Part-III
> Electronics Engineering
> IIT-BHU (Varanasi)
>
> On Mon, Mar 20, 2017 at 12:11 AM, Shailesh Tripathi , B.Tech., Electronics
> Engg., IIT (BHU), Varanasi (INDIA) 
> wrote:
>
>> Hello,
>> While writing the.cl file, I got stuck at a data type "*bn_poly_t*" and "
>> *bn_complex_t*". To use this in kernels, can these definitions be
>> imported or do I need to define these structures in the .cl file itself. Is
>> there a way to import these, or if not, defining them would not be any
>> issue. :)
>>
>> Regards
>> Shailesh
>>
>>
>> Shailesh Tripathi
>> B.Tech. Part-III
>> Electronics Engineering
>> IIT-BHU (Varanasi)
>>
>
>
> 
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> ___
> BRL-CAD Developer mailing list
> brlcad-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/brlcad-devel
>
>


-- 
Vasco Alexandre da Silva Costa
PhD in Computer Engineering (Computer Graphics)
Instituto Superior Técnico/University of Lisbon, Portugal
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
BRL-CAD Developer mailing list
brlcad-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/brlcad-devel


Re: [brlcad-devel] OpenCL code query "bn_poly_t"

2017-03-20 Thread Vasco Alexandre da Silva Costa
On Sun, Mar 19, 2017 at 6:41 PM, Shailesh Tripathi , B.Tech., Electronics
Engg., IIT (BHU), Varanasi (INDIA) 
wrote:

> Hello,
> While writing the.cl file, I got stuck at a data type "*bn_poly_t*" and "
> *bn_complex_t*". To use this in kernels, can these definitions be
> imported or do I need to define these structures in the .cl file itself. Is
> there a way to import these, or if not, defining them would not be any
> issue. :)
>

The necessary types are defined in the include file "common.cl", which
should also be included in the existing sample primitive implementations
like 'ehy_shot.cl'.

-- 
Vasco Alexandre da Silva Costa
PhD in Computer Engineering (Computer Graphics)
Instituto Superior Técnico/University of Lisbon, Portugal
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
BRL-CAD Developer mailing list
brlcad-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/brlcad-devel


Re: [brlcad-devel] OpenCL code query "bn_poly_t"

2017-03-19 Thread Shailesh Tripathi , B.Tech., Electronics Engg., IIT (BHU), Varanasi (INDIA)
Hello,
Sorry for flooding the list with so many questions :/ Last set for queries
for the day :)

1. How to use these functions '*rt_poly_roots', 'bu_log'*, *'bn_pr_roots' *and
'*VPRINT*' in the kernels (.cl file)
2. Why are functions like '*RT_GET_SEG' *eliminated in the the kenels and
how does *'BU_LIST_INSERT(&(seghead->l), &(segp->l));* ' be equivalent
to '*do_segp(res,
idx, [0], [1]);' *?

Thanks in advance :)

Regards
Shailesh

Shailesh Tripathi
B.Tech. Part-III
Electronics Engineering
IIT-BHU (Varanasi)

On Mon, Mar 20, 2017 at 3:07 AM, Shailesh Tripathi , B.Tech., Electronics
Engg., IIT (BHU), Varanasi (INDIA) 
wrote:

> Also,
> For scalar multiplication VSCALE() is used in the C code. Can I simply use
> multiplication operator (*) in the kernel as VSCALE in unavailable in
> OpenCL.
> C code:
> *VSCALE(norm_pprime, dprime, VDOT(pprime, dprime));*
> OpenCL code:
>
> * norm_pprime = dprime * dot(pprime, dprime);*
> Regards
> Shailesh
>
> Shailesh Tripathi
> B.Tech. Part-III
> Electronics Engineering
> IIT-BHU (Varanasi)
>
> On Mon, Mar 20, 2017 at 12:11 AM, Shailesh Tripathi , B.Tech., Electronics
> Engg., IIT (BHU), Varanasi (INDIA) 
> wrote:
>
>> Hello,
>> While writing the.cl file, I got stuck at a data type "*bn_poly_t*" and "
>> *bn_complex_t*". To use this in kernels, can these definitions be
>> imported or do I need to define these structures in the .cl file itself. Is
>> there a way to import these, or if not, defining them would not be any
>> issue. :)
>>
>> Regards
>> Shailesh
>>
>>
>> Shailesh Tripathi
>> B.Tech. Part-III
>> Electronics Engineering
>> IIT-BHU (Varanasi)
>>
>
>
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
BRL-CAD Developer mailing list
brlcad-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/brlcad-devel