__half22float2
Applicability
Product |
Supported |
|---|---|
Atlas 350 Accelerator Card |
√ |
x |
|
x |
|
x |
|
x |
|
x |
|
x |
Function Usage
Converts the two components of half2 to float values, fills them into float2, and returns the result.
Prototype
1 | inline float2 __half22float2(const half2 x) |
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
x |
Input |
Source operand. |
Returns
Result of converting the two components of half2 to float values and filling them into float2
Restrictions
For SIMT programming, this API is not supported.
Examples
For SIMD and SIMT programming:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | // Use small vectors to improve data movement efficiency. __simt_vf__ __launch_bounds__(1024) inline void simt_half22float2(__gm__ half2* input, __gm__ float2* output, uint32_t input_total_length) { uint32_t idx = blockIdx.x * blockDim.x + threadIdx.x; // Each thread processes one piece of half2 data, that is, two pieces of half data. Therefore, threads with idx greater than or equal to input_total_length/2 do not process data. if (idx >= input_total_length / 2) { return; } output[idx] = __half22float2(input[idx]); } __global__ __vector__ void cast_kernel(__gm__ half* input, __gm__ float* output, uint32_t input_total_length) { asc_vf_call<simt_half22float2>(dim3(1024), (__gm__ half2*)input, (__gm__ float2*)output, input_total_length); } |
Parent topic: Type Conversion