A short example is available below:
/**
* Example 1
* Assume we declared a profile (INOUT MATRIX) with the path 'solve_T'.
* This profile will be called by the client. Our implementation expects
* a profile (IN INT, IN INT, INOUT MATRIX). This profile is known to
* FAST with the path 'T_solve'.
* We will write a convertor that changes the name and extracts the
* matrix's dimensions.
*/
// declare a new convertor with 2 IN, 1 INOUT and 0 OUT arguments
cvt = diet_convertor_alloc("T_solve", 0, 1, 1);
// apply the function DIET_CVT_MAT_NB_ROW to determine the
// 0th argument of the converted profile. The function's
// argument is the 0th argument of the source profile. As it
// is an IN argument, the last parameter is not important.
diet_arg_cvt_set(&(cvt->arg_convs[0]), DIET_CVT_MAT_NB_ROW, 0, NULL, 0);
// apply the function DIET_CVT_MAT_NB_COL to determine the
// 1st argument of the converted profile. The function's
// argument is the 0th argument of the source profile. As it
// is a IN argument, the last parameter is not important.
diet_arg_cvt_set(&(cvt->arg_convs[1]), DIET_CVT_MAT_NB_COL, 0, NULL, 0);
// apply the function DIET_CVT_IDENTITY to determine the
// 2nd argument of the converted profile. The function's
// argument is the 0th argument of the source profile and
// it will be written back to the 0th argument of the source
// profile when the call has finished.
diet_arg-cvt_set(&(cvt->arg_convs[2]), DIET_CVT_IDENTITY, 0, NULL, 0);
// NOTE: The last line could also be written as:
//diet_arg_cvt_short_set(&(cvt->arg_convs[2]), 0, NULL);
// add the service using our convertor
diet_service_table_add(profile, cvt, solve_T);
// free our convertor
diet_convertor_free(cvt);
More examples on how to create and use convertors are given in the
files
examples/dmat_manips/server.c and examples/BLAS/server.c.