标量
毕昇编译器是一个类C++的编译器,对于Host侧,标量的支持跟C++编译器是一致的。本章主要介绍毕昇编译器对于Device侧标量,以及因硬件平台的不同而产生的与Host侧的差异。
标量类型
毕昇编译器支持C++ 风格的标量类型,还支持部分非C++ 风格的标量类型,如下表所示:
类型 |
类型描述 |
备注 |
---|---|---|
bool |
boolean |
Device和Host侧均支持的类型 |
int8_t |
8-bit signed integer |
Device和Host侧均支持的类型 |
uint8_t |
8-bit unsigned integer |
Device和Host侧均支持的类型 |
int16_t |
16-bit signed integer |
Device和Host侧均支持的类型 |
uint16_t |
16-bit unsigned integer |
Device和Host侧均支持的类型 |
int32_t |
32-bit signed integer |
Device和Host侧均支持的类型 |
uint32_t |
32-bit unsigned integer |
Device和Host侧均支持的类型 |
int64_t |
64-bit signed integer |
Device和Host侧均支持的类型 |
uint64_t |
64-bit unsigned integer |
Device和Host侧均支持的类型 |
float32_t |
32-bit float |
Device侧支持类型,Host侧的支持情况与平台相关 |
float16_t |
16-bit half |
Device侧支持类型,Host侧的支持情况与平台相关 |
float64_t |
64-bit double |
Device侧不支持,Host侧的支持情况与平台相关 |
bfloat16_t |
16-bit bfloat16 |
Device侧只支持DMA类的操作,不支持运算。Host侧的支持情况与平台相关 |
标量操作符
毕昇编译器是一个类C++的编译器,因此它的标量操作符支持的类型同C++的操作符是类似的,支持的操作符和操作符的优先级同C++语言相同。本章只解释一些跟C++语言不同之处,供开发者编程参考。
- new,delete在Device侧不支持,Host侧支持,错误示例如下:
double* p = new double[]{1, 2, 3}; // not supported on device side auto p1 = new double[3][5]; // not supported on device side
- throw在Device侧不支持,Host侧支持。
- co_await,co_yield在Device侧不支持,Host侧支持。
- typeof 是C语言的特性,毕昇编译器不支持。