Developer Guide and Reference

ID 767253
Date 10/31/2024
Public
Document Table of Contents

Basic Arithmetic Operations and Simple Math Functions

The compiler supports the following basic arithmetic operations and simple math functions:

cpolarf

Description: Returns a complex number with a magnitude of rho and a phase angle of theta.

Calling Interface:

float __complex__ cpolarf(float rho, float theta)

cpolar

Description: Returns a complex number with a magnitude of rho and phase angle of theta.

In standard CPU programming, the C99 standard library provides a set of functions supporting complex number arithmetic. You can include <complex.h> to use them. These complex math functions are provided in SYCL device code.

Calling Interface:

double __complex__ __devicelib_cpolar(double rho, double theta)

__divsc3, __divdc3

Description: Returns the quotient of (a + ib) / (c + id). During compilation, the compiler may insert reference to these two functions in your code and the linker resolves the undefined reference later.

Calling Interface:

float __complex__ __divsc3(float __a, float __b, float __c, float __d)
double __complex__ __divdc3(double __a, double __b, double __c, double __d)

__mulsc3, __muldc3

Description: Returns the product of a + ib and c + id.

Calling Interface:

float __complex__ __mulsc3(float __a, float __b, float __c, float __d)
double __complex__ __muldc3(double __a, double __b, double __c, double __d)

labs, llabs

Description: Computes the absolute value of the integer number x for long and long long types. In normal CPU programming, the C standard library provides functions to return absolute value for integer values, these functions are declared in <stdlib.h>. The compiler supports these functions in SYCL device code.

Calling Interface:

int abs(int x)
long labs(long x)
long long llabs(long long x)

ldiv, lldiv

Description: Computes both the quotient and the remainder of the division of the numerator x by the denominator y. The returned type has the following definitions:

struct div_t { int quot; int rem; };
struct ldiv_t { long quot; long rem; };
struct lldiv_t { long long quot; long long rem; };

Calling Interface:

div_t div(int x, int y)
ldiv_t ldiv(long x, long y)
lldiv_t lldiv(long long x, long long y)