Skip to content

Instantly share code, notes, and snippets.

@LEW21
Created May 24, 2015 23:29
Show Gist options
  • Save LEW21/7b6d11c0607680c91c30 to your computer and use it in GitHub Desktop.
Save LEW21/7b6d11c0607680c91c30 to your computer and use it in GitHub Desktop.
gpunode-cudacore vs cudacore
diff -ur gpunode-cudacore/RTQuery.cuh cudacore/RTQuery.cuh
--- gpunode-cudacore/RTQuery.cuh 2015-05-25 01:17:50.780401283 +0200
+++ cudacore/RTQuery.cuh 2015-05-25 01:17:46.931636701 +0200
@@ -1,3 +1,6 @@
+#ifndef RTQUERY_H_
+#define RTQUERY_H_
+
#define RTCUBE_OP_NONE 0
#define RTCUBE_OP_SUM 1
#define RTCUBE_OP_MAX 2
@@ -69,4 +72,8 @@
void PrintQuerryResult(QueryResult result);
+std::string GetQuerryResultString(QueryResult result);
+
void FreeResult(QueryResult result);
+
+#endif /* RTQUERY_H_ */
diff -ur gpunode-cudacore/RTQuery.cu cudacore/RTQuery.cu
--- gpunode-cudacore/RTQuery.cu 2015-05-25 01:17:50.780401283 +0200
+++ cudacore/RTQuery.cu 2015-05-25 01:17:46.921630217 +0200
@@ -1,4 +1,7 @@
#include "RTQuery.cuh"
+#include <iostream>
+#include <sstream>
+#include <iomanip>
Querry InitQuerry(int dimCount, int measCount, int operationsCount)
{
@@ -187,6 +190,44 @@
}
}
+std::string GetQuerryResultString(QueryResult result)
+{
+ std::stringstream ss;
+ ss << "Querry result\nResult lines count:" << std::setw(4) << result.ResultsCount << "\nMeas per result:" << std::setw(4) << result.MeasPerResult << "\n\n";
+
+ for (int i = 0; i < result.ResultsCount; ++i)
+ {
+ int index = i;
+
+ ss << std::setw(3) << i << ": ";
+
+ for (int j = 0; j < result.Q.DimCount; ++j)
+ {
+ if ((int)result.Q.d_SelectDims[j] == 1)
+ {
+ int dimValIndex = index / result.d_SelectDimSizes[j];
+ int dimVal;
+ if ((int)result.Q.d_WhereDimMode[j] == RTCUBE_WHERE_SET)
+ dimVal = (int)result.Q.d_WhereDimVals[(int)result.Q.d_WhereDimValsStart[j] + dimValIndex];
+ else
+ dimVal = (int)result.Q.d_WhereStartRange[j] + dimValIndex;
+
+ ss << std::setw(3) << dimVal;
+
+ index %= result.d_SelectDimSizes[j];
+ }
+ }
+
+ ss << " :";
+
+ for (int j = 0; j < result.MeasPerResult; ++j)
+ ss << std::setw(10) << (int)result.d_ResultMeas[j * result.ResultsCount + i];
+
+ ss << "\n";
+ }
+ return ss.str();
+}
+
void FreeResult(QueryResult result)
{
thrust::device_free(result.d_ResultMeas);
diff -ur gpunode-cudacore/main.cu cudacore/RTUtil.cu
--- gpunode-cudacore/main.cu 2015-05-25 01:17:50.780401283 +0200
+++ cudacore/RTUtil.cu 2015-05-25 01:17:46.944978680 +0200
@@ -96,11 +96,8 @@
free(h_measPacked);
}
-int main()
+void RunSample()
{
- srand(time(NULL));
-
-
//Wygenerowanie przykładowych danych - normalnie trzeba je odebrać z sieci
int vectorsCount = 200000;
int dimensionsCount = 6;
@@ -178,7 +175,7 @@
printf ("Time of insert: %f ms\n\n", time);
PrintCubeInfo(cube);
- //PrintCubeMemory(cube); //Można wypisać do celów testowych pamięć kostki
+ //PrintCubeMemory(cube); //Można wypisać do celów testowych pamięć kostki
//Przykładowe Query do kostki - trzeba zbudować strukturę Query na podstawie reprezentacji pośredniej
printf("Sample Querry\n");
@@ -216,7 +213,7 @@
q.d_WhereDimValuesCounts[2] = 3; //ile wartości w zbiorze
q.d_WhereDimValuesCounts[3] = dimRanges[3]; //ile wszystkich wartości dla wymiaru
- //Tutaj wpisujemy początki i końce zakresów
+ //Tutaj wpisujemy początki i końce zakresów
q.d_WhereStartRange[0] = 0;
q.d_WhereStartRange[3] = 0;
@@ -261,13 +258,8 @@
FreeResult(result);
FreeQuerry(q);
-
+
//Przy zabijaniu node trzeba zwolnić kostkę
FreeCube(cube);
-
-
- //i wszystko :D
- return 0;
}
-
Only in cudacore/: RTUtil.cuh
Only in cudacore/: sample.cu
Only in cudacore/: RTCubeApi.cu
Only in cudacore/: RTCubeApi.h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment