passing client options to distributed clients, ready to actually distribute work

git-svn-id: svn://anubis/fart/trunk@223 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
Josh Holtrop committed 2009-04-05 18:12:44 +00:00
1 parent 1dbe7040e4
commit 6fdaf01214
5 files changed
+83 -37

No files matched your search

+19 -3
View File
@@ -41,52 +41,68 @@ Scene::Scene(const map<string, const char *> & options,
if (it->first == "width")
{
m_width = atoi(it->second);
m_client_options.push_back("--width");
m_client_options.push_back(it->second);
}
else if (it->first == "height")
{
m_height = atoi(it->second);
m_client_options.push_back("--height");
m_client_options.push_back(it->second);
}
else if (it->first == "multisample")
{
m_multisample_level = atoi(it->second);
m_client_options.push_back("--multisample");
m_client_options.push_back(it->second);
}
else if (it->first == "field-of-view")
{
m_vfov = atof(it->second);
m_client_options.push_back("--field-of-view");
m_client_options.push_back(it->second);
}
else if (it->first == "output-file")
{
m_output_file_name = it->second;
/* no client option necessary */
}
else if (it->first == "max-depth")
{
m_max_depth = atoi(it->second);
m_client_options.push_back("--max-depth");
m_client_options.push_back(it->second);
}
else if (it->first == "verbose")
{
m_verbose = true;
/* no client option necessary */
}
else if (it->first == "host")
{
m_server_name = it->second;
m_server = false;
/* no client option necessary */
}
else if (it->first == "port")
{
m_server_port = atoi(it->second);
/* no client option necessary */
}
else if (it->first == "hosts")
{
m_hosts_file = it->second;
/* no client option necessary */
}
}
m_client_options.push_back(filename);
/* start the distribution infrastructure */
if (m_server)
{
if (m_hosts_file != "")
m_distrib.readHostFile(m_hosts_file.c_str());
m_distrib.startServer();
m_distrib.startServer(m_client_options);
}
else
{
@@ -108,7 +124,7 @@ Scene::~Scene()
void Scene::render()
{
if (m_verbose)
if (m_verbose && m_server)
{
cout << " *** Beginning scene render ***" << endl;
cout << "Parameters:" << endl;
@@ -130,7 +146,7 @@ void Scene::render()
}
}
if (m_verbose)
if (m_verbose && m_server)
{
cout << " *** Ending scene render ***" << endl;
cout << "Writing output file '" << m_output_file_name << '\'' << endl;
+1
View File
@@ -95,6 +95,7 @@ class Scene
std::string m_hosts_file;
int m_server_port;
distrib m_distrib;
std::vector<std::string> m_client_options;
/* framebuffer */
unsigned char * m_data;
+26 -21
View File
@@ -30,6 +30,7 @@ int main(int argc, char * argv[])
int opt;
int option_index;
map<string, const char *> scene_options;
bool server = true;
static const struct option long_options[] = {
{ "output-file", required_argument, NULL, 'o' },
@@ -77,6 +78,7 @@ int main(int argc, char * argv[])
break;
case 257:
scene_options["host"] = optarg;
server = false;
break;
case 258:
scene_options["port"] = optarg;
@@ -104,29 +106,32 @@ int main(int argc, char * argv[])
gettimeofday(&after, NULL); /* stop timing */
double time_before = before.tv_sec + before.tv_usec / 1000000.0;
double time_after = after.tv_sec + after.tv_usec / 1000000.0;
double total_seconds = time_after - time_before;
cout << "Elapsed time: " << total_seconds << " seconds";
double seconds = total_seconds;
int days = (int) (seconds / (60.0 * 60.0 * 24.0));
seconds -= days * 60.0 * 60.0 * 24.0;
int hours = (int) (seconds / (60.0 * 60.0));
seconds -= hours * 60.0 * 60.0;
int minutes = (int) (seconds / 60.0);
seconds -= minutes * 60.0;
if (days || hours || minutes)
if (server)
{
cout << " (";
if (days)
cout << days << " days, ";
if (days || hours)
cout << hours << " hours, ";
cout << minutes << " minutes, ";
cout << seconds << " seconds)";
double time_before = before.tv_sec + before.tv_usec / 1000000.0;
double time_after = after.tv_sec + after.tv_usec / 1000000.0;
double total_seconds = time_after - time_before;
cout << "Elapsed time: " << total_seconds << " seconds";
double seconds = total_seconds;
int days = (int) (seconds / (60.0 * 60.0 * 24.0));
seconds -= days * 60.0 * 60.0 * 24.0;
int hours = (int) (seconds / (60.0 * 60.0));
seconds -= hours * 60.0 * 60.0;
int minutes = (int) (seconds / 60.0);
seconds -= minutes * 60.0;
if (days || hours || minutes)
{
cout << " (";
if (days)
cout << days << " days, ";
if (days || hours)
cout << hours << " hours, ";
cout << minutes << " minutes, ";
cout << seconds << " seconds)";
}
cout << endl;
}
cout << endl;
return 0;
}