User Tools

Site Tools


cs330_f2016:tmp

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
cs330_f2016:tmp [2016/10/12 14:30]
wingated
cs330_f2016:tmp [2021/06/30 23:42] (current)
Line 29: Line 29:
 The primary deliverable for this lab is a new Julia module. ​ Your module should export ''​parse'',​ ''​calc'' ​ ''​analyze''​ functions, and three return types, ''​NumVal'',​ ''​ClosureVal'',​ and ''​MatrixVal''​. The primary deliverable for this lab is a new Julia module. ​ Your module should export ''​parse'',​ ''​calc'' ​ ''​analyze''​ functions, and three return types, ''​NumVal'',​ ''​ClosureVal'',​ and ''​MatrixVal''​.
  
-Your module should be able to do everything that the three previous interpreters. ​ You are welcome to examine the code we developed in class. ​ The ''​CI8.jl''​ module is available on LearningSuite,​ under "​Content -> Julia -> Program analysis".+Your module should be able to do everything that the three previous interpreters. ​ You are welcome to examine the code we developed in class. ​ The ''​CI8.jl''​ module is available on LearningSuite,​ under "​Content -> Julia -> High Performance Primitives".
  
 Please name your module ''​HPInt''​. Please name your module ''​HPInt''​.
Line 48: Line 48:
 <code BNF> <code BNF>
 <OWL> ::= number <OWL> ::= number
-          | (+ <OWL> <OWL> <​OWL>​*)+          | (+ <OWL> <OWL> <​OWL>​*) ​   # all owls could be a MatrixVal or a NumVal
           | (- <OWL> <​OWL>​)           | (- <OWL> <​OWL>​)
           | (* <OWL> <​OWL>​)           | (* <OWL> <​OWL>​)
Line 62: Line 62:
           | (<​OWL>​ <​OWL>​*) ​             | (<​OWL>​ <​OWL>​*) ​  
           ​           ​
 +          #
           # new primitives here           # new primitives here
 +          #
           ​           ​
-          | (render_text <​string>​ <OWL> <​OWL>​) 
-          | (emboss <​OWL>​) 
           | (simple_load <​string>​)           | (simple_load <​string>​)
-          | (drop_shadow <​OWL>​) +          ​| (simple_save <OWL> <​string>​) ​       # this owl should evaluate to a MatrixVal 
-          | (inner_shadow <​OWL>​) +           
-          | (min <OWL> <​OWL>​)+          | (render_text <​string>​ <OWL> <​OWL>​) ​ # these owls should evaluate to NumVals 
 +          | (emboss <​OWL>​) ​                     # this owl should evaluate to a MatrixVal 
 +          ​| (drop_shadow <​OWL>​) ​                # this owl should evaluate to a MatrixVal 
 +          | (inner_shadow <​OWL>​) ​               # this owl should evaluate to a MatrixVal 
 +          ​ 
 +          | (min <OWL> <​OWL>​) ​                  # boths owls could be a MatrixVal or a NumVal
           | (max <OWL> <​OWL>​)           | (max <OWL> <​OWL>​)
                 ​                 ​
Line 93: Line 98:
   - Remember that when multiplying a MatrixVal by a MatrixVal, we want to use the ''​.*''​ operation (element-wise matrix multiply) instead of ''​*''​ (matrix-matrix multiply). ​   - Remember that when multiplying a MatrixVal by a MatrixVal, we want to use the ''​.*''​ operation (element-wise matrix multiply) instead of ''​*''​ (matrix-matrix multiply). ​
  
 +----
 ===Error handling:​=== ===Error handling:​===
  
Line 99: Line 105:
 In particular, you should carefully check the number and type of all subexpressions and strings. ​ For example, operations such as ''​min''​ or ''​max''​ should operate on ''​NumVal''​ or ''​MatrixVal''​ objects, but should throw an error if handed something like a ''​ClosureVal''​. In particular, you should carefully check the number and type of all subexpressions and strings. ​ For example, operations such as ''​min''​ or ''​max''​ should operate on ''​NumVal''​ or ''​MatrixVal''​ objects, but should throw an error if handed something like a ''​ClosureVal''​.
  
 +----
 ===Parallelization:​=== ===Parallelization:​===
  
 We discussed several opportunities for parallelization in class. ​ You must use the proper combination of ''​@spawn''​ and ''​fetch''​ to parallelize as many of the ''​calc''​ functions as possible by spawning for each sub-call to ''​calc''​. ​ You do not need to parallelize the analyze functions. We discussed several opportunities for parallelization in class. ​ You must use the proper combination of ''​@spawn''​ and ''​fetch''​ to parallelize as many of the ''​calc''​ functions as possible by spawning for each sub-call to ''​calc''​. ​ You do not need to parallelize the analyze functions.
  
 +
 +----
 +====Hints:​====
 +
 +Once all is said and done, the following program:
 +
 +<code lisp>
 +(with base_img (render_text "​Hello"​ 25 100)
 +  (with swirl (simple_load "/​Users/​wingated/​Desktop/​swirl_256.png"​)
 +    (with ds (drop_shadow base_img)
 +      (with tmp4 (+ (* (+ (min ds base_img) (- 1 base_img)) base_img) (* (- 1 base_img) swirl) )
 +        (with tmp5 (- 1 (emboss tmp4))
 +          (with base_img2 (render_text "​world!"​ 5 200)
 +     (with is (inner_shadow base_img2)
 +              (with tmp6 (max base_img2 (* (- 1 base_img2) is) )
 +                (with output (min tmp5 tmp6 )
 +   (simple_save output "​output.png"​)
 + )
 +              )
 +     )
 +   )
 + )
 +      )
 +    )
 +  )
 +)
 +</​code>​
 +
 +should generate the image shown below, using the ''​swirl_256.png''​ image shown at the right:
 +
 +{{:​cs330_f2016:​sample_text.png?​direct|}}
 +{{ :​cs330_f2016:​swirl_256.png?​direct|}}
  
cs330_f2016/tmp.1476282647.txt.gz · Last modified: 2021/06/30 23:40 (external edit)