fixstars/clpy

Support half

Opened this issue · 5 comments

vorj commented

Related to #264 .

We should support half type regardless of whether the environment supports cl_khr_fp16 or not.

@vorj Do you mean that you want to implement all half operations with software functions? How much do you need it? I think it's reasonable to give up half support if the device doesn't support the extensions for it.

vorj commented

@LWisteria

Do you mean that you want to implement all half operations with software functions?

Yes, and I think that we can implement almost of them like float_to_half(float_operation(half_to_float(half_value))) .
The exception is nextafter , but this has been already implemented.

I think it's reasonable to give up half support if the device doesn't support the extensions for it.

I thought so when we had no idea to solve the issue, but now I have an idea, and it's worth to try to get ClPy's features closer to CuPy's ones I think.

ybsh commented

Talked with @LWisteria about who should work on this issue .
We agreed that this task is more appropriate for an intern, considering this task seems to require a fair amount of time, and I'm not currently very sure if I can spare as much time.
I will continue the performance improvement issue: #153

@vorj OK, I understand that you want to use Ultima to convert a + b where a and b are half to f2h(h2f(a)+h2f(b)), right?

Then, how will you deal rounding errors etc? f2h(h2f(a)+h2f(b)) does not exactly match native a+b.

vorj commented

@LWisteria

I understand that you want to use Ultima to convert a + b where a and b are half to f2h(h2f(a)+h2f(b)), right?

Yes, that's it.

how will you deal rounding errors etc?

That's the problem. I'm still thinking about it.
Well, I have a question. Although currently we calculate sqrt(int8_value) as f2h(sqrt(i2f(int8_value))) , does the casting in this situation have no problem?

Or we can use some open source software implementation of half as an alternative option. However, even this option requires member function support to ultima, and I don't know the half implementation supporting for not only arithmetic operator but also mathmatical functions since my investigation is insufficient.