- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I need to pass a structure to an OCALL from within the enclave. The structure is defined in "../TorchHost/gpu_glue_types.h" w.r.t. to the .edl file,
// gpu_glue_types.h
struct gpu_iMat {
int *ptr;
int rows;
int cols;
};
// typedef struct gpu_iMat gpu_iMat;
And the .edl file,
enclave {
include "../TorchEnclave/TH/TH.h"
trusted {
/* define ECALLs here. */
/* public void Train([user_check] NeuralNetConfig* config); */
// public void entry(int test);
// public void dot_product([user_check]THFloatTensor *xx, [user_check] THFloatTensor *yy);
public void test_conv([user_check] THFloatTensor *data,[user_check] THFloatTensor *label);
};
untrusted {
include "../TorchHost/gpu_glue_types.h"
/* define OCALLs here. */
void ocall_print_double(double test);
/* void EmitRoundError(size_t round, double error); */
void ocall_error([in, string] const char* msg);
/* void start_time();*/
/* void end_time([in, string] const char* msg);*/
void ocall_warn_INT_BOUNDS(float value, int iter, _Bool dir, [in, string] char* func_name, int line_no);
/* void ocall_print_enclave_app_ptrs([in, string] const char *ptr, [user_check] void *enc_ptr);*/
void gpu_hello();
struct gpu_iMat alloc_gpu_iMat(int rows, int cols);
//void free_gpu_iMat(struct gpu_iMat imat);
void gpu_print_iMat(const struct gpu_iMat imat);
};
};
The edger8r glue code generator fails the build with the error,
error: ../TorchEnclave/TorchEnclave.edl:13:48: unexpected token: imat Makefile:201: recipe for target 'TorchHost/TorchEnclave_u.c' failed make: *** [TorchHost/TorchEnclave_u.c] Error 255
removing imat pushes the error to the ')' following imat,
error: ../TorchEnclave/TorchEnclave.edl:13:44: unexpected token: ) Makefile:201: recipe for target 'TorchHost/TorchEnclave_u.c' failed make: *** [TorchHost/TorchEnclave_u.c] Error 255
The glue code for alloc_gpu_imat is successfully generated, which returns a C struct of the type gpu_iMat. But, edger8r fails to generate code for either free_gpu_iMat or gpu_print_iMat.The declaration of the structure follows https://software.intel.com/en-us/node/708973.
Am I missing something else ?
Although this could be implemented using pointers and a shallow copy, I would appreciate any help to make it work with passing structures by copy.
Thanks in advance !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Removing the 'const' (which is not really needed since it's a copy, so it's only a 'documentation' here) and also placing the 'include' outside the 'untrusted' block seems to solve this issue.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Removing the 'const' (which is not really needed since it's a copy, so it's only a 'documentation' here) and also placing the 'include' outside the 'untrusted' block seems to solve this issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Alright.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page