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

Function ecall_sort_de

sgx_tf_ops/Enclave/Enclave.cpp:5356–5422  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5354
5355
5356void ecall_sort_de(float *input,int N,int M ,int C,int L,float *output){
5357 float *x = (float*)malloc(sizeof(float)*N);
5358 memset(x, 0, sizeof(float)*N);
5359 for(int j=0;j<N;j++){
5360 x[j] = 0.0f;
5361 float sum = input[insert*N+j];
5362 float c = 0.0f;
5363 for(int i=0;i<Nt;i++){
5364 float y = input[indexs[i]*N+j] - c;
5365 float t = sum + y;
5366 c = (t - sum) - y;
5367 sum = t;
5368 }
5369 x[j] = sum;
5370 }
5371
5372 float *tmp = (float*)malloc(sizeof(float)*C);
5373 memset(tmp, 0, sizeof(float)*C);
5374
5375 for(int i=0;i<M;i++){
5376 for(int k =0;k<L;k++){
5377 for(int j =0;j<C;j++){
5378 tmp[j] = x[i*C*L+j*L+k];
5379 }
5380 std::sort(tmp,tmp+C,compare);
5381 for(int j =0;j<C;j++){
5382 x[i*C*L+j*L+k] = tmp[j];
5383 }
5384 }
5385 }
5386
5387 float mean = 0.0f, std, mean_sqr = 0.0f;
5388 float c_mean = 0.0f, c_mean_sqr = 0.0f;
5389
5390 for (int j = 0; j < N; j++) {
5391 float y = (x[j]/static_cast<float>(N)) - c_mean;
5392 float t = mean + y;
5393 c_mean = (t - mean) - y;
5394 mean = t;
5395
5396 float y2 = (x[j]*x[j]/static_cast<float>(N)) - c_mean_sqr;
5397 float t2 = mean_sqr + y2;
5398 c_mean_sqr = (t2 - mean_sqr) - y2;
5399 mean_sqr = t2;
5400 }
5401 std = sqrtf(mean_sqr - mean * mean)/static_cast<float>(Nt);
5402 mean = mean/static_cast<float>(Nt);
5403 for(int i=0;i<N*(Ne-1);i++){
5404 output[i] =(x[i%N] - gaussrand(mean, std))/static_cast<float>(Nt+1);
5405 }
5406 for(int j=N*(Ne-1);j<N*Ne;j++){
5407 output[j] = 0.0f;
5408 float sum = 0.0f;
5409 float c = 0.0f;
5410 for(int i=0;i<Nt;i++){
5411 float y = -1.0f * output[indexs[i]*N+(j-N*(Ne-1))] - c;
5412 float t = sum + y;
5413 c = (t - sum) - y;

Callers 1

sort_deFunction · 0.85

Calls 1

gaussrandFunction · 0.85

Tested by

no test coverage detected