-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IO socketed engine to the arc-agi averages Signed-off-by: Josef Edwards <joed6834@colorado.edu>
- Loading branch information
1 parent
100d005
commit c0cc6ad
Showing
1 changed file
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#include <iostream> | ||
#include <string> | ||
#include <vector> | ||
#include <unordered_map> | ||
#include <sys/socket.h> | ||
#include <netinet/in.h> | ||
#include <arpa/inet.h> | ||
|
||
// Define the benchmark engine class | ||
class BenchmarkEngine { | ||
public: | ||
// Constructor | ||
BenchmarkEngine(); | ||
|
||
// Destructor | ||
~BenchmarkEngine(); | ||
|
||
// Define the benchmark function | ||
void benchmark(const std::vector<std::string>& nodes, const std::vector<std::pair<std::string, std::string>>& edges, const std::string& query); | ||
|
||
// Define the IO socket for benchmark output | ||
int benchmarkSocket; | ||
|
||
// Define the callback function for benchmark output | ||
void benchmarkCallback(double constructionTime, double queryTime, double reasoningTime); | ||
}; | ||
|
||
// Constructor | ||
BenchmarkEngine::BenchmarkEngine() { | ||
// Create the IO socket for benchmark output | ||
benchmarkSocket = socket(AF_INET, SOCK_STREAM, 0); | ||
|
||
// Connect to the IO socket | ||
struct sockaddr_in server_addr; | ||
server_addr.sin_family = AF_INET; | ||
server_addr.sin_port = htons(8080); | ||
inet_pton(AF_INET, "127.0.0.1", &server_addr.sin_addr); | ||
connect(benchmarkSocket, (struct sockaddr*)&server_addr, sizeof(server_addr)); | ||
} | ||
|
||
// Destructor | ||
BenchmarkEngine::~BenchmarkEngine() { | ||
// Close the IO socket | ||
close(benchmarkSocket); | ||
} | ||
|
||
// Define the benchmark function | ||
void BenchmarkEngine::benchmark(const std::vector<std::string>& nodes, const std::vector<std::pair<std::string, std::string>>& edges, const std::string& query) { | ||
// Send the benchmark data to the IO socket | ||
send(benchmarkSocket, &nodes, sizeof(std::vector<std::string>), 0); | ||
send(benchmarkSocket, &edges, sizeof(std::vector<std::pair<std::string, std::string>>), 0); | ||
send(benchmarkSocket, &query, sizeof(std::string), 0); | ||
|
||
// Receive the benchmark results from the IO socket | ||
double constructionTime, queryTime, reasoningTime; | ||
recv(benchmarkSocket, &constructionTime, sizeof(double), 0); | ||
recv(benchmarkSocket, &queryTime, sizeof(double), 0); | ||
recv(benchmarkSocket, &reasoningTime, sizeof(double), 0); | ||
|
||
// Print the benchmark results | ||
std::cout << "Construction Time: " << constructionTime << std::endl; | ||
std::cout << "Query Time: " << queryTime << std::endl; | ||
std::cout << "Reasoning Time: " << reasoningTime << std::endl; | ||
} | ||
|
||
// Define the callback function for benchmark output | ||
void BenchmarkEngine::benchmarkCallback(double constructionTime, double queryTime, double reasoningTime) { | ||
// Send the benchmark results to the IO socket | ||
send(benchmarkSocket, &constructionTime, sizeof(double), 0); | ||
send(benchmarkSocket, &queryTime, sizeof(double), 0); | ||
send(benchmarkSocket, &reasoningTime, sizeof(double), 0); | ||
} | ||
|
||
int main() { | ||
// Create a benchmark engine object | ||
BenchmarkEngine benchmarkEngine; | ||
|
||
// Define the knowledge graph construction algorithm | ||
std::vector<std::string> nodes = {"node1", "node2", "node3"}; | ||
std::vector<std::pair<std::string, std::string>> edges = {{"node1", "node2"}, {" |
c0cc6ad
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$1 million prize solution to the arc-agi benchmark, for Francois.