ASCOT5
Loading...
Searching...
No Matches
Functions
offload.c File Reference

Offload functions. More...

#include <stdlib.h>
#include <string.h>
#include "ascot5.h"
#include "offload.h"

Go to the source code of this file.

Functions

void offload_init_offload (offload_package *o, real **offload_array, int **int_offload_array)
 Initialize offload package.
 
void offload_free_offload (offload_package *o, real **offload_array, int **int_offload_array)
 Free offload array and set offload_package to clean state.
 
void offload_pack (offload_package *o, real **offload_array, real *pack_array, size_t pack_length, int **int_offload_array, int *int_pack_array, size_t int_pack_length)
 Pack an offload array to package array.
 
void offload_unpack (offload_package *o, real *offload_array, size_t pack_length, int *int_offload_array, size_t int_pack_length, real **ptr, int **intptr)
 Unpack offload array from the package.
 

Detailed Description

Offload functions.

An offload package that is used to collect all offload arrays into a single one so that offloading can be done nice and clean. offload_pack() takes an offload data array and appends it to the common offload array. offload_unpack() returns a pointer at the start of the common offload array. offload_unpack() must be called in the same order as offload_pack() was called when data was packaged.

Since input data may contain both floats and integers, we store those separately (i.e. there is one common offload array for floats and one common offload array for integers).

Definition in file offload.c.

Function Documentation

◆ offload_init_offload()

void offload_init_offload ( offload_package * o,
real ** offload_array,
int ** int_offload_array )

Initialize offload package.

Sets offload_package.pack_array_length and offload_package.unpack_pos to zero and assigns NULL to offload_array pointer.

Parameters
ouninitialized offload package
offload_arraypointer to packarray
int_offload_arraypointer to int packarray

Definition at line 31 of file offload.c.

◆ offload_free_offload()

void offload_free_offload ( offload_package * o,
real ** offload_array,
int ** int_offload_array )

Free offload array and set offload_package to clean state.

Parameters
ooffload package
offload_arraypointer to offload_array
int_offload_arraypointer to int packarray

Definition at line 49 of file offload.c.

◆ offload_pack()

void offload_pack ( offload_package * o,
real ** offload_array,
real * pack_array,
size_t pack_length,
int ** int_offload_array,
int * int_pack_array,
size_t int_pack_length )

Pack an offload array to package array.

Reallocates the offload array so that the new data from the package array can be appended. Once the data has been appended, the old offload array is freed. The new length of the offload array is stored to offload_package struct.

Parameters
ooffload package
offload_arraypointer to offload array where data will be packed
pack_arraypack array containing the data to be appended
pack_lengthlength of the offload_array
int_offload_arraypointer to offload array where integer data will be packed
int_pack_arraypack array containing the integer data to be appended
int_pack_lengthlength of the int_offload_array

Definition at line 78 of file offload.c.

◆ offload_unpack()

void offload_unpack ( offload_package * o,
real * offload_array,
size_t pack_length,
int * int_offload_array,
size_t int_pack_length,
real ** ptr,
int ** intptr )

Unpack offload array from the package.

The data is not actually moved anywhere. Unpacking means that pointers to the start of packed offload arrays are returned. Unpacking must be done in the same order as data was packed.

Parameters
ooffload package
offload_arrayoffload array
pack_lengthlength of the data that is unpacked
int_offload_arrayint offload array
int_pack_length
ptrpointer where the unpacked data begins
intptrpointer where the unpacked int data begins

Definition at line 137 of file offload.c.