MCPcopy Create free account
hub / github.com/conflow-dev/ConFlow / ecall_math

Function ecall_math

sgx_tf_ops/Enclave/Enclave.cpp:4796–4847  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4794}
4795
4796void ecall_math(float* input,float num,int N,float* output){
4797 float *x = (float*)malloc(sizeof(float)*N);
4798 memset(x, 0, sizeof(float)*N);
4799 for(int j=0;j<N;j++){
4800 x[j] = 0.0f;
4801 float sum = input[insert*N+j];
4802 float c = 0.0f;
4803 for(int i=0;i<Nt;i++){
4804 float y = input[indexs[i]*N+j] - c;
4805 float t = sum + y;
4806 c = (t - sum) - y;
4807 sum = t;
4808 }
4809 x[j] = sum;
4810 }
4811 for (int j = 0; j < N; j++) {
4812 x[j]= x[j]+num;
4813 }
4814 float mean = 0.0f, std, mean_sqr = 0.0f;
4815 float c_mean = 0.0f, c_mean_sqr = 0.0f;
4816
4817 for (int j = 0; j < N; j++) {
4818 float y = (x[j] /static_cast<float>(N)) - c_mean;
4819 float t = mean + y;
4820 c_mean = (t - mean) - y;
4821 mean = t;
4822
4823 float y2 = (x[j]*x[j]/static_cast<float>(N)) - c_mean_sqr;
4824 float t2 = mean_sqr + y2;
4825 c_mean_sqr = (t2 - mean_sqr) - y2;
4826 mean_sqr = t2;
4827 }
4828 std = sqrtf(mean_sqr - mean * mean)/static_cast<float>(Nt);
4829 mean = mean/static_cast<float>(Nt);
4830 for(int i=0;i<N*(Ne-1);i++){
4831 output[i] =(x[i%N] - gaussrand(mean, std))/static_cast<float>(Nt+1);
4832 }
4833 for(int j=N*(Ne-1);j<N*Ne;j++){
4834 output[j] = 0.0f;
4835 float sum = 0.0f;
4836 float c = 0.0f;
4837 for(int i=0;i<Nt;i++){
4838 float y = -1.0f * output[indexs[i]*N+(j-N*(Ne-1))] - c;
4839 float t = sum + y;
4840 c = (t - sum) - y;
4841 sum = t;
4842 }
4843 output[j] =x[j-N*(Ne-1)] + sum;
4844 }
4845 free(x);
4846 return;
4847}
4848
4849
4850void ecall_matadd(float* input1,float* input2,int N,int C,float* output){

Callers 1

mathFunction · 0.85

Calls 1

gaussrandFunction · 0.85

Tested by

no test coverage detected