Using a Custom Bitfile in C Code

From Cpre584
Revision as of 20:54, 15 February 2012 by Cnel711 (talk | contribs) (New page: My current understanding is that running a routine on the coprocessor requires two parts: * A call to the '''cny_get_signature''' function to get the signature of the custom personality yo...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

My current understanding is that running a routine on the coprocessor requires two parts:

  • A call to the cny_get_signature function to get the signature of the custom personality you created
  • A cny coprocessor funcation call (ex: l_copcall_fmt, d_copcall_fmt, etc)

If you want to pass parameters to your function call, the vector adder set the standard of using an assembly file to marshal registers back and forth between the processor / coprocessor, though there may be other ways.

Getting the Signature

 cny_image_t        sig2;
 cny_image_t        sig;
 int stat;
 if (cny_get_signature)
   cny_get_signature("your custom personality name", &sig, &sig2, &stat);
 else 
   fprintf(stderr,"ERROR:  cny_get_signature not found\n");

Allocated Memory on the Coprocessor Board

System memory and memory used for the coprocessor are physically separate. In the example C file, function calls such as cny_cp_malloc and ny_cp_posix_memalign.

See: Convey Programmers Guide (.pdf) - Chapter 9

Making a Coprocessor Call

The vector adder example uses:

act_sum = l_copcall_fmt(sig, cpVadd, "AAAA", a1, a2, a3, size);

In this case, the l at the beginning of l_copcall_fmt means the return type is a long (64 bits). The first two arguments are always (1) the bitfile signature and (2) a assembly function name. The third argument lists the type and number of optional arguments that are passed (starting at register A8). For example, "AAAA" means there are 4 long variables passed to the coprocessor call.

See: Convey Programmers Guide (.pdf) - Appendix G