-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathVDICompositingTest.cpp
116 lines (78 loc) · 3.18 KB
/
VDICompositingTest.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#include <iostream>
#include "ManageRendering.hpp"
#include <mpi.h>
#include "MPINatives.hpp"
#include "VDIParams.hpp"
#include <thread>
#include <fstream>
#include <zconf.h>
int main() {
std::cout << "Hello, World!" << std::endl;
std::string dataset = "Kingsnake";
bool isCluster = false;
int provided;
MPI_Init_thread(NULL, NULL, MPI_THREAD_SERIALIZED, &provided);
std::cout << "Got MPI thread level: " << provided << std::endl;
int rank;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
int num_processes;
MPI_Comm_size(MPI_COMM_WORLD, &num_processes);
MPI_Comm nodeComm;
MPI_Comm_split_type( MPI_COMM_WORLD, MPI_COMM_TYPE_SHARED, rank,
MPI_INFO_NULL, &nodeComm );
int node_rank;
MPI_Comm_rank(nodeComm,&node_rank);
if(!isCluster) {
node_rank = 0;
}
JVMData jvmData = setupJVM(isCluster, "VDICompositingTest", 0);
registerNatives(jvmData);
setPointerAddresses(jvmData, MPI_COMM_WORLD);
setMPIParams(jvmData, rank, node_rank, num_processes);
jstring jdataset = jvmData.env->NewStringUTF(dataset.c_str());
jfieldID datasetField = jvmData.env->GetFieldID(jvmData.clazz, "dataset", "Ljava/lang/String;");
jvmData.env->SetObjectField(jvmData.obj, datasetField, jdataset);
std::thread render(&doRender, jvmData);
waitRendererConfigured(jvmData);
//launch the compositing
JNIEnv *env;
jvmData.jvm->AttachCurrentThread(reinterpret_cast<void **>(&env), NULL);
jmethodID compositeMethod = env->GetMethodID(jvmData.clazz, "compositeVDIs", "(Ljava/nio/ByteBuffer;Ljava/nio/ByteBuffer;II)V");
if(compositeMethod == nullptr) {
if (env->ExceptionOccurred()) {
env->ExceptionDescribe();
} else {
std::cout << "ERROR: function compositeVDIs not found!";
}
} else {
std::cout << "compositeVDIs function successfully found!";
}
std::string basePath = "/home/aryaman/TestingData/";
std::string filePath = basePath + dataset + "_" + std::to_string(num_processes) + "_" + std::to_string(rank)
+ "SubVDI4_ndc_";
std::ifstream colorFile( filePath + "col", std::ios::in | std::ios::binary);
std::ifstream depthFile( filePath + "depth", std::ios::in | std::ios::binary);
if(!colorFile.is_open() || !depthFile.is_open()) {
std::cerr<< "Could not open the file! " << std::endl;
std::exit(-1);
}
char * colorBuffer = new char[colorSize];
char * depthBuffer = new char[depthSize];
colorFile.read(colorBuffer, colorSize);
depthFile.read(depthBuffer, depthSize);
jobject jcolorBuffer = env->NewDirectByteBuffer(colorBuffer, colorSize);
jobject jdepthBuffer = env->NewDirectByteBuffer(depthBuffer, depthSize);
int iterations = 5;
env->CallVoidMethod(jvmData.obj, compositeMethod, jcolorBuffer, jdepthBuffer, rank, iterations);
if(env->ExceptionOccurred()) {
env->ExceptionDescribe();
env->ExceptionClear();
}
std::cout<<"Back after calling do Render" <<std::endl;
sleep(60);
std::cout<<"Calling stopRendering!" <<std::endl;
stopRendering(jvmData);
render.join();
MPI_Finalize();
return 0;
}