DISTANCE(3clc)

πŸ“¦
version 1.0~svn33624 Β· 3 versions
, in ubuntu jammy, ubuntu noble

πŸ’– NAME πŸ’–

okay bestie, listen up β€” distance is literally THE vector distance girlie ✨ she tells you how far apart two points are, and she's serving it in every precision you could want:

float distance(floatn p0, floatn p1);

double distance(doublen p0, doublen p1);

half distance (gentype p0, gentype p1)
// if half extension enabled

no cap, those are the exact signatures, don't @ me 🫢


🌸 DESCRIPTION 🌸

So she returns the distance between p0 and p1. That's it, that's the whole vibe πŸ’…

But how tho? It's calculated as length(3clc)(p0 - p1) β€” yes bestie, she's just subtracting and then taking the length. Subtract the points, length the result, boom, distance. lowkey elegant, highkey iconic πŸ”₯


✨ NOTES ✨

okay here's the tea β˜• the built-in geometric functions (distance included) operate component-wise β€” the description is per-component, so think of it as each component doing its own lil thing 🌈

Quick glossary moment, no gatekeeping:

  • floatn is one of float, float2, float3, or float4
  • doublen is one of double, double2, double3, or double4

And these built-in geometric functions are implemented using the round to nearest even rounding mode. fr fr, that's the rounding mode, remember it πŸŽ€

Also she can be implemented using contractions like mad(3clc) or fma(3clc) β€” efficient queen πŸ‘‘

And if you extend with cl_khr_fp16(3clc), the generic type name gentype may indicate half and half{2|3|4} as arguments. yes, half{2|3|4} means half2, half3, half4 β€” the brace notation is doing the most but it's valid, iykyk πŸ’œ


πŸ“œ SPECIFICATION πŸ“œ

OpenCL Specification[1] β€” she's official, she's documented, she's in the book πŸ“–


πŸ¦‹ SEE ALSO πŸ¦‹


πŸ‘‘ AUTHORS πŸ‘‘

The Khronos Group β€” the actual main characters who wrote this πŸ’…


Copyright Β© 2007-2011 The Khronos Group Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and/or associated documentation files (the "Materials"), to deal in the Materials without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Materials, and to permit persons to whom the Materials are furnished to do so, subject to the condition that this copyright notice and permission notice shall be included in all copies or substantial portions of the Materials.

bestie that's the whole legal paragraph, I'm not paraphrasing it, I'm not summarising it, I'm not even breathing on it. verbatim. periodt πŸ’–

πŸŽ€ NOTES πŸŽ€

  1. OpenCL Specification β€” page 262, section 6.12.5 - Geometric Functions πŸ“š

and that's the whole page, bestie!! 🫢 this lil masterpiece comes to you from The Khronos Group, dated 01/14/2021, and it's filed under DISTANCE(3clc) in the OpenCL Manual ✨ go forth and compute your distances, you've got this πŸ’–πŸŒΈπŸ¦‹πŸ’…πŸ‘‘

πŸ“¦ where this page comes from