Hello everyone,
I just joined this forum and I am very new to xmos. I look forward to learning from you all. My first problem:
I have some functions in a file 'matrix.c' running on xmos StartKit. I am calling some of those functions inside a bigger function 'void calculations( )' in a separate file 'matrix_calc.c'. My task is to parallelise 2 functions that are called in 'void calculations( )'. Thus I want to transfer those functions to xmos_calc.xc file. The issue is that these functions that I wish to parallelise contain float variables that are defined inside matrix.c.
Any ideas how I can do this?
I've described the above problem in a different way below:
matrix.c contains:
void func_a ( )
{
}
void func_b ( );
{
}
void func_c ( );
{
}
matrix_calc.c contains:
void calculations ( )
{
void func_a( );
void func_b( );
void func_c( );
}
Task : To parallelise: func_a( ) and func_b( );
Transfer functions containing float from a c file to xc file
-
- Newbie
- Posts: 1
- Joined: Mon Mar 16, 2015 1:25 am
-
- XCore Addict
- Posts: 158
- Joined: Thu Mar 20, 2014 8:04 am
Hi,
- rename to matrix.xc; mainly this should define the server interface to access the float variables (if there are lot other functions in matrix.c file, try moving the shared float data and related functions to a separate file, matrix.xc
- Define interface to access the variables;
- Use client functions inside func_a() and func_b() in order to access the variables
- Use func_a() and func_b() inside a par;
==========================================
xmos_calc.xc file contain ::
//file_begin
void func_a (client interface share_data i)
{
/* some process*/
float x[];
i.fnA(x):
//get float variables and process
}
void func_b (client interface share_data i)
{
/* some process*/
float x[];
i.fnA(x):
//get float variables and process
}
//file_end
=======================================================
matrix.'xc':
interface share_data {
void fnA( float x[]);
};
void calculations ( server interface share_data i[n], unsigned n) {
while (1) {
select {
case i[int n].fnA( float x[]):
//send float data
break ;
}
}
}
=======================================================
main() {
interface share_data i[2];
par {
calculations(i, 2);
func_a(i[0]);
func_b(i[1]);
}
}
=======================================================
This is a rough outline of the approach and more refinements may be needed. Hope this helps.
Reference: https://www.xmos.com/download/public/XM ... 8documenta...
- rename to matrix.xc; mainly this should define the server interface to access the float variables (if there are lot other functions in matrix.c file, try moving the shared float data and related functions to a separate file, matrix.xc
- Define interface to access the variables;
- Use client functions inside func_a() and func_b() in order to access the variables
- Use func_a() and func_b() inside a par;
==========================================
xmos_calc.xc file contain ::
//file_begin
void func_a (client interface share_data i)
{
/* some process*/
float x[];
i.fnA(x):
//get float variables and process
}
void func_b (client interface share_data i)
{
/* some process*/
float x[];
i.fnA(x):
//get float variables and process
}
//file_end
=======================================================
matrix.'xc':
interface share_data {
void fnA( float x[]);
};
void calculations ( server interface share_data i[n], unsigned n) {
while (1) {
select {
case i[int n].fnA( float x[]):
//send float data
break ;
}
}
}
=======================================================
main() {
interface share_data i[2];
par {
calculations(i, 2);
func_a(i[0]);
func_b(i[1]);
}
}
=======================================================
This is a rough outline of the approach and more refinements may be needed. Hope this helps.
Reference: https://www.xmos.com/download/public/XM ... 8documenta...