| ... | @@ -2,21 +2,21 @@ Programming language: |
... | @@ -2,21 +2,21 @@ Programming language: |
|
|
* static codes `st-wslda`: [C99](https://en.wikipedia.org/wiki/C99) standard
|
|
* static codes `st-wslda`: [C99](https://en.wikipedia.org/wiki/C99) standard
|
|
|
* time dependent codes `td-wslda`: mixture of [C99](https://en.wikipedia.org/wiki/C99) and [CUDA](https://en.wikipedia.org/wiki/CUDA).
|
|
* time dependent codes `td-wslda`: mixture of [C99](https://en.wikipedia.org/wiki/C99) and [CUDA](https://en.wikipedia.org/wiki/CUDA).
|
|
|
|
|
|
|
|
In general CUDA is compatible with C99. Thus, in practice when editing files (*predefines.h*, *problem-definition.h* or *logger.h*) you can use C language irrespectively to code variants (`st` or `td`). There is only one exception related to function `delta_ext` in *problem-definition.h* file. It declaration is
|
|
In general, CUDA is compatible with C99. Thus, in practice when editing files (*predefines.h*, *problem-definition.h* or *logger.h*) you can use C language irrespectively to code variants (`st` or `td`). There is only one exception related to function `delta_ext` in *problem-definition.h* file. It declaration is
|
|
|
* static codes `st-wslda`:
|
|
* static codes `st-wslda`:
|
|
|
```c
|
|
```c
|
|
|
double complex delta_ext(int ix, int iy, int iz, int it, double complex delta, double *params, size_t extra_data_size, void *extra_data)
|
|
double complex delta_ext(int ix, int iy, int iz, int it, double complex delta, double *params, size_t extra_data_size, void *extra_data)
|
|
|
```
|
|
```
|
|
|
* time dependent codes `td-wslda`:
|
|
* time-dependent codes `td-wslda`:
|
|
|
```cuda
|
|
```cuda
|
|
|
__device__ Complex delta_ext(int ix, int iy, int iz, int it, Complex delta, double *params, size_t extra_data_size, void *extra_data)
|
|
__device__ Complex delta_ext(int ix, int iy, int iz, int it, Complex delta, double *params, size_t extra_data_size, void *extra_data)
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
The change arises from incompatibility of complex type in C99 and CUDA. Namely:
|
|
The change arises from the incompatibility between the complex type in C99 and that in CUDA. Namely:
|
|
|
* `st-wslda`: return type must be C99 [double complex](https://en.cppreference.com/w/c/numeric/complex)
|
|
* `st-wslda`: return type must be C99 [double complex](https://en.cppreference.com/w/c/numeric/complex)
|
|
|
* `td-wslda`: return type must be compatible with [CUDA Complex](https://thrust.github.io/doc/group__complex__numbers.html)
|
|
* `td-wslda`: return type must be compatible with [CUDA Complex](https://thrust.github.io/doc/group__complex__numbers.html)
|
|
|
|
|
|
|
|
Below we provide example of the same code written in both standards:
|
|
Below we provide an example of the same code written in both standards:
|
|
|
* C99
|
|
* C99
|
|
|
```c
|
|
```c
|
|
|
double complex delta_ext(int ix, int iy, int iz, int it, double complex delta, double *params, size_t extra_data_size, void *extra_data)
|
|
double complex delta_ext(int ix, int iy, int iz, int it, double complex delta, double *params, size_t extra_data_size, void *extra_data)
|
| ... | | ... | |