[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [3499] trunk/py/scripts/tools/bi_farm: add Cuda option, this has NOT been tested :S
Campbell Barton
ideasman42 at gmail.com
Mon Jun 18 15:57:50 CEST 2012
Revision: 3499
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=3499
Author: campbellbarton
Date: 2012-06-18 13:57:49 +0000 (Mon, 18 Jun 2012)
Log Message:
-----------
add Cuda option, this has NOT been tested :S
Modified Paths:
--------------
trunk/py/scripts/tools/bi_farm/master_ui.py
trunk/py/scripts/tools/bi_farm/new_master.py
Modified: trunk/py/scripts/tools/bi_farm/master_ui.py
===================================================================
--- trunk/py/scripts/tools/bi_farm/master_ui.py 2012-06-18 13:57:05 UTC (rev 3498)
+++ trunk/py/scripts/tools/bi_farm/master_ui.py 2012-06-18 13:57:49 UTC (rev 3499)
@@ -81,8 +81,9 @@
step_types = ('1', '2', '3', '5', '10')
quality_types = ('File settings', 'Final 4K', 'Final 2K', 'Final 1K', 'Final 0.5k', 'Final HD', 'Preview 1K', 'NoShading 1K', 'Simplified 1K')
status_types = ('Disabled', 'In Progress', 'Done!')
+ processor_types = ('CPU', 'CUDA') # could add openal later?
- def __init__(self, id, revision, quality, step):
+ def __init__(self, id, revision, quality, step, processor):
self.id = id
self.status = "Disabled"
self.progress = "0% (0/0)"
@@ -92,6 +93,7 @@
self.enabled = False
self.stats = ""
self.step = step
+ self.processor = processor
@staticmethod
def find(id):
@@ -112,8 +114,12 @@
f = open(JOBS_FILE, "rb")
JOBS = pickle.load(f)
for job in JOBS:
+ # these could be removed later....
+ # only for restarting the farm on running jobs
if not hasattr(job, "step"):
job.step = 1
+ if not hasattr(job, "processor"):
+ job.processor = 'CPU'
f.close()
except IOError:
print("No jobs file, starting with 0 jobs.")
@@ -158,7 +164,13 @@
Job.dump()
-def job_add(id, revision, quality, step):
+def job_set_processor(id, processor):
+ # changes in priority are detected in master loop
+ Job.find(id).processor = processor
+ Job.dump()
+
+
+def job_add(id, revision, quality, step, processor):
# master loop will find the new job when refreshes it's jobs list in
# the outer loop, so actually starting to render may take a while
for job in JOBS:
@@ -184,7 +196,7 @@
print(command)
os.system(command)
- job = Job(id, revision, quality, step)
+ job = Job(id, revision, quality, step, processor)
JOBS.append(job)
# JOBS.sort(key=lambda job: job.revision)
Job.dump()
@@ -213,9 +225,10 @@
class Slave:
- def __init__(self, id, ip):
+ def __init__(self, id, ip, is_cuda):
self.id = id
self.ip = ip
+ self.is_cuda = is_cuda
self.status = "Disabled"
self.enabled = False
@@ -237,6 +250,12 @@
try:
f = open(SLAVES_FILE, "rb")
SLAVES = pickle.load(f)
+
+ # can remove later!
+ for slave in SLAVES:
+ if not hasattr(slave, "is_cuda"):
+ slave.is_cuda = False
+
f.close()
except IOError:
print("No slaves file, starting with 0 slaves.")
@@ -250,13 +269,13 @@
Slave.dump()
-def slave_add(id, ip):
+def slave_add(id, ip, is_cuda):
# master loop will detect new added slaves automatically
for slave in SLAVES:
if slave.ip == ip:
return
- SLAVES.append(Slave(id, ip))
+ SLAVES.append(Slave(id, ip, is_cuda))
SLAVES.sort(key=lambda slave: slave.id)
Slave.dump()
@@ -305,7 +324,7 @@
# add a slave
elif self.path == '/slave_add':
d = urllib.parse.parse_qs(command)
- slave_add(d['id'][0], d['ip'][0])
+ slave_add(d['id'][0], d['ip'][0], eval(d['is_cuda'][0].capitalize()))
# add a job
elif self.path == '/job_add':
d = urllib.parse.parse_qs(command)
@@ -313,7 +332,7 @@
rev = d['revision'][0]
else:
rev = 'HEAD'
- job_add(d['id'][0], rev, d['quality'][0], int(d['step'][0]))
+ job_add(d['id'][0], rev, d['quality'][0], int(d['step'][0]), d['processor'][0])
self.send_response(http.client.SEE_OTHER)
self.send_header("Location", "/")
@@ -440,7 +459,7 @@
# jobs
section("Jobs")
- table_begin("", "File", "Revision", "Quality", "Status", "Progress", "Stats", "Priority", "Step", "")
+ table_begin("", "File", "Revision", "Quality", "Status", "Progress", "Stats", "Priority", "Step", "Processor", "")
for job in JOBS:
output("<tr>\n")
@@ -468,6 +487,11 @@
# dropdown('job_set_step', job.id, job.step, Job.step_types)
# output("%d" % job.step)
output("<td>" + str(job.step) + "</td>\n")
+
+ # output("<td>")
+ # dropdown('job_set_processor', job.id, job.processor, Job.processor_types)
+ # output("%d" % job.processor)
+ output("<td>" + job.processor "</td>\n")
output("<td id='td-toggle'>")
action('job_remove(\\"%s\\")' % job.id, "X", "Are you sure you want to remove this job?")
@@ -502,6 +526,15 @@
output("\t<option %s value='%s'>%s</option>\n" % (state, option, option))
output("</select>\n")
+ output("<select name='processor'>\n")
+ for option in Job.processor_type:
+ if option == 'CPU':
+ state = "selected"
+ else:
+ state = ""
+ output("\t<option %s value='%s'>%s</option>\n" % (state, option, option))
+ output("</select>\n")
+
output("<input type='submit' class='job-add' value='Add Job'/>\n")
output("</form>\n")
@@ -539,7 +572,7 @@
# slaves
section("Slaves")
- table_begin("", "Name", "IP", "Status", "Since", "Logs", "")
+ table_begin("", "Name", "IP", "Cuda", "Status", "Since", "Logs", "")
for slave in SLAVES:
try:
@@ -555,6 +588,7 @@
output("</td>\n")
output("<td>" + slave.id + "</td>\n")
output("<td>" + slave.ip + "</td>\n")
+ output("<td>" + ("\u2611" if slave.is_cuda else "\u2610") + "</td>\n")
if slave.status == 'Disabled':
output("<td style='color:red'>" + slave.status + "</td>\n")
else:
@@ -575,6 +609,7 @@
output("<form method='post' action='/slave_add'>\n")
output("<input name='id' value='Computer X' size='25'/>\n")
output("<input name='ip' value='192.168.1.x' size='25'/>\n")
+ output("<input name='is_cuda' checked='no' type='checkbox'>Cuda</input>\n")
output("<input type='submit' value='Add Slave'/>\n")
output("</form>\n")
Modified: trunk/py/scripts/tools/bi_farm/new_master.py
===================================================================
--- trunk/py/scripts/tools/bi_farm/new_master.py 2012-06-18 13:57:05 UTC (rev 3498)
+++ trunk/py/scripts/tools/bi_farm/new_master.py 2012-06-18 13:57:49 UTC (rev 3499)
@@ -217,7 +217,9 @@
return kill_non_critical
-def job_find(slaves_state, do_finals, num_frames):
+def job_find(slaves_state, do_finals, num_frames,
+ filter_job=None):
+
# get enabled jobs sorted by priority
sorted_jobs = []
@@ -237,6 +239,11 @@
skipped_final = True
continue
+ if filter_job is None:
+ pass
+ elif not filter_job(job):
+ continue
+
# list images for this job
images = job_images(job)
@@ -255,7 +262,7 @@
return r_job, r_frames
if skipped_final:
- return job_find(slaves_state, True, num_frames)
+ return job_find(slaves_state, True, num_frames, filter_job=filter_job)
return r_job, r_frames
@@ -467,8 +474,18 @@
if not USE_MULTI_JOBS:
num_frames = 1
- slave_job, slave_frames = job_find(slaves_state, do_finals, num_frames)
+ # -------------------------------------------------------------
+ # Filter function so we can choose what slave gets what job
+ def is_slave_job_compat(job):
+ # test the processor
+ if job.processor == 'CPU':
+ return True
+ elif processor == 'CUDA':
+ return (slave.is_cuda == True)
+ slave_job, slave_frames = job_find(slaves_state, do_finals, num_frames,
+ filter_job=is_slave_job_compat)
+
if slave_job:
# call next update function
func = update_funcs[slave_func_nr]
More information about the Bf-extensions-cvs
mailing list