Visualization by - Website of Marek Gayer, Ph.D.

Download Report

Transcript Visualization by - Website of Marek Gayer, Ph.D.

www.ing.unipi.it
Open Microelectronics architecture considerations
Marek Gayer, Ph.D.
www.ing.unipi.it
Some of goals of framework
 Interactive input of simulation parameters and








PISA 2007
interactive visualization
Programmable flow of simulation modules
Open source
Multiplatform (at least Windows + Linux)
Easy installation and updates
Easily extendible by user without recompiling
Server based simulation
Ability to develop and contribute without necessity to
understand whole problems and technologies
Should encourage others to contribute
2
www.ing.unipi.it
Basics of Architecture
Server
Interactive Device designer
(like deckbuild)
Server Scripting – CGI, PHP, JSP,
Python, Perl
Flow Control – XML, XSLT, Python,
PHP
(like devedit)
User Interface - C++ with Qt / GTK / etc.
UI – Java / Java Web Start / Applet
UI - ECMAScript + SVG + DHTML
Design and flow visualization - SVG, OpenGL,
Library capabilities
Interactive Visualization
Simulator modules and their
bindings (C/C++, Fortran)
XML
over
TCP/IP
Data interchange between modules
(C++ library, files)
Visualization creating / assistance
modules (reduced XML grid, web
graphics formats)
(like tonyplot/3d)
Visualization by: OpenGL , SVG , VRML – X3D,
Java2D/3D
Common video formats
Statistics
PISA 2007
Data Storage of
results on server:
Files, SQL, XML, ...
3
www.ing.unipi.it
Interactive designer
 Will specify the task to compute server
(shape, materials, doping, …)
 Will also specify flow of simulation modules,
perhaps by an interactive graph editor
 Can create a grid, eventually meshing
 Result will be send to server
 Will use 2D shapes graphics, with control of Z
axis
 Could be made as a master thesis(es)
PISA 2007
4
www.ing.unipi.it
Interactive designer – C++
 + Fast performance
 + C/C++ will be probably used for
simulation modules and passing data
 - We must make and test binaries for
supported platforms
 - Easy delivery and update via web
browser not possible (like in Java)
PISA 2007
5
Interactive designer –
User Interface – C++ with Qt








www.ing.unipi.it
+ Most professional solution for multiplatform UI
+ Windows / Linux / Mac (native widgets)
+ Good documentation
+ Completeness
+ User Interface Designer (Qt Designer)
+ Bindings for Python, Java
- GPL / commercial license
+ Used by Google Earth, Skype (Linux), KDE (Linux)
 http://en.wikipedia.org/wiki/QT
 http://www.trolltech.com/
PISA 2007
6
www.ing.unipi.it
Qt Designer by Trolltech
PISA 2007
7
www.ing.unipi.it
Interactive designer
User Interface – C++ with GTK+
 + Often used for multiplatform UI
 + Windows / Linux / Mac (native widgets)
 - User Interface Designer
 + Bindings for Python, Java
 + LGPL license
 - Written in C, although C++ wrapper exists (gtkmm)
 + Used by Gnome, GIMP, Firefox
 http://en.wikipedia.org/wiki/GTK
 http://www.trolltech.com/
PISA 2007
8
www.ing.unipi.it
Glade – UI designer for GTK+
PISA 2007
9
Interactive designer
User Interface – C++
www.ing.unipi.it
 Other alternatives:
–wxWidgets
–FoxToolkit
–FLTK
–Ultimate++
PISA 2007
10
www.ing.unipi.it
Interactive designer –Java
 + Ability to deploy application in various ways
(web start, applet, java binaries)
 + Rich library (e.g. java2d)
http://java.sun.com/products/java-media/2D/
 + Many open source projects are in Java (SF:
23.000 Java, 20.000 C++, 18.000 C)
 + Java Web start
 - Java apps need considerable more memory
 - Java runtime must be installed
PISA 2007
11
www.ing.unipi.it
Drawing with Java2D Library
PISA 2007
12
Interactive designer –
Java – SWING library
www.ing.unipi.it
 + Made by Sun
 + Looks similar on each platform
 + Good object model design (more pure
Java)
 - Native GUI applications looks still better
 http://en.wikipedia.org/wiki/Swing_(Java)
 http://java.sun.com/products/jfc/tsc/sightings/
PISA 2007
13
www.ing.unipi.it
Maple 10 UI made with SWING
PISA 2007
14
Interactive designer –
Java – SWT library
www.ing.unipi.it
 + Made by IBM
 + Looks more native on each platform
 - Worser object model design
 - Harder to develop then Swing
 - More neccessary to test each platform
 + More professional look
 http://en.wikipedia.org/wiki/SWT
PISA 2007
15
www.ing.unipi.it
SWT on different platforms and Eclipse
on Window Vista
PISA 2007
16
Interactive designer –
Java Web Start
www.ing.unipi.it
 + Allows easy installation and launching of
software through web browser
 + Easy update of new versions of software
 + When installed once, it is not necessary to
install again (under the condition that no
changes were made)
 + During update, new jars are downloaded
 + Ability to use all features of Java: menus,
user interface, graphics, …
 http://en.wikipedia.org/wiki/Java_Web_Start
PISA 2007
17
Interactive designer
ECMAScript (AJAX)







+ Not necessary to install anything (Firefox)
+ Easy delivery of new versions of application
+ Fast start of application
- Considerably harder to develop complex applications then with C++ /
Java (hard testing, debugging)
- No IDE, no GUI designer, unmature tools
- Strange class/object model syntax
- Poor general class library (e.g. strings)
- Cannot access local filesystem due to security
- Limitations of UI due to DHTML
- Differences in each browser => necessary to test and maintain for
new browsers
- Memory requirements
- Interpreted, not compiled => slow
+- Graphics would have to be in SVG

http://en.wikipedia.org/wiki/Ajax_(programming)






PISA 2007
www.ing.unipi.it
18
www.ing.unipi.it
Google spreadsheet in ECMAScript
PISA 2007
19
Designer and simulation flow
visualization
www.ing.unipi.it
 Using the visualization in the UI
package:
– Graphics View for Qt
– Cairo for GTK
– Java2D for Java
 Using SVG
 Using OpenGL
PISA 2007
20
www.ing.unipi.it
SVG
 Standard for vector and raster graphics
based on XML used namely on the web
 With Batik, generation of SVG is as easy as
in Java2D (implements same interface)
http://en.wikipedia.org/wiki/Batik
 Possibility to add ECMAScript functionality
 Possibility to generate SVG from XML using
XSLT transformations
 Good support in browsers and other software
 http://en.wikipedia.org/wiki/Scalable_Vector_
Graphics
PISA 2007
21
www.ing.unipi.it
OpenGL




+ Portable library for 3D/2D graphics
- No object layer
- Uses state machine concept
- More complex to learn and to use due to
less abstraction level (compared to e.g.
Java2D)
 + Very fast performance
 + Bindings for different languages, including
Java:
http://en.wikipedia.org/wiki/Java_OpenGL
PISA 2007
22
www.ing.unipi.it
Inside Web Server
User defined
flow in e.g.
Python / XML
Sim.mod. 1
Visualization / Data assitance
(SVG / VRML / MPG / XML)
Interactive
visualization
Server core – CGI/PHP/JSP/Python
Interactive
designer
Sim.mod. 2
Sim.mod. 3
Data
Synchronizing
libraries /
(XSLT) data
converters
Sim. Mod 4
Sim Mod 5
PISA 2007
Sim Mod 6
Sim Mod 7
Shared
Memory
File
/ SQL
23
www.ing.unipi.it
Server Side (1/2)
 PHP/Python/JSP/CGI scripts on HTTP server will




PISA 2007
maintain communication with interactive and
visualization parts (including translation of data)
Will control the flow of simulation by launching
simulation modules (written in C++/Fortran)
Data exhange between simulator modules will be
realized using e.g. special C++ library, shared
memory, PHP/Python glue code
Mechanism for calling C functions from Python/PHP
glue should be investigated (something better then
exec with files as arguments) – e.g. PHP extensions.
How modules will be compiled and linked together
should be investigated
24
www.ing.unipi.it
Server Side (2/2)
 Possibility of using shared memory should be





PISA 2007
investigated
Input and output of modules could be defined XSD
schema
Parts of glue could be defined by XML data
(programmable by user / generated by designer)
XSLT transformations could be used for translation of
data to format that module expects
http://en.wikipedia.org/wiki/XSLT
Results (including partial ones could be saved in files
and/or SQL DB
25
www.ing.unipi.it
Interactive visualization of results
 Interaction with server for selecting part of
currently visualized data of transistor
 At least at beginning of project 2D
visualization should be sufficient
 Possibility to implement one or more of:
– OpenGL
– SVG (created on server)
– VRML/X3D (created on server)
– JPG / MPEG (created on server)
– Delivering numerical data and stats. (XML)
PISA 2007
26
www.ing.unipi.it
VRML/X3D









PISA 2007
3D Model scene is defined in text format
Can be zoomed, rotated, etc.
Requires plugin in web browser
Those plugins are not fully compatible (Scripting …)
For using in standalone application, library is needed
(CyberX3D, OpenVRML, Xj3D, H3D)
X3D (ISO standard) is successor of VRML, adds
support XML
For modification of visualization data, new
VRML/X3D file is usually created on server
http://en.wikipedia.org/wiki/VRML
http://en.wikipedia.org/wiki/X3D
27
www.ing.unipi.it
Progress (1/3)
 Established working environment for Python, Numpy




PISA 2007
and building extensions in CygWin
Even possible to run KDevelop and KDBG (possible
to debug extensions!)
Read important parts on Python and Numpy
programming book (“Python Scripting For
Computational Science”)
Created sample module in C, with one and two
dimensional float arrays and pointer to function.
Various programming styles (3 version of wrapper
func used)
The 2D and 1D arrays are now accessible in both C
and Python. Able to also use Python dictionary type
28
www.ing.unipi.it
Progress (2/3)
 With NUMPY, converting to type * and type **
does not need additional memory and values
do not have to be copied (in type **, helper
mapping array of pointers must be created)
 NUMPY alone is a reason to stick with Python
 Python extensions cannot be build easily with
Windows (requires 5 packages including.net
framework SDK – hundreds of MBs)
 Able to compile ViDES as library, then to link
with wrapper as Python extension (no need to
change a single line in original source code).
PISA 2007
29
www.ing.unipi.it
Progress (3/3)
 Wrote wrapper accepts tens of NumPY
arrays and converts them to C type *(*)
 Wrote allocations and file operations to
fill all needed variables for module
struttura to Python
 Compiles and links, but I am getting
Segmentation fault (debug needed)
PISA 2007
30
www.ing.unipi.it
Progress2 (1/3)
 Succesfully debugged ViDES struttura -
results in binary files are 100% same
 NumPy basic operations under matrixes
should be same as C extension (for example
I tested scalar multiplying on 1000x1000
matrix: 0.21s vs 0.20s)
 Compared performance of versions of array
accessing in Python and NumPy array as C
extension - 2D arrays (NumPy, C), 1D
(NumPy), and 2D lists (Python)
PISA 2007
31
www.ing.unipi.it
Progress2 (2/3)
 def PythonArray2dGridLoop (a, x, y, f):

for i in xrange(x.size):

for j in xrange(y.size):

a[i][j] = f(x[i], y[j]); # OR #

a[i][j] = x[i] + y[j]; # OR #

return a;
 Results: (e.g. 0.02s C vs. 3.5s Python), but with one
Python callback 0.75s C vs. 3.9s Python
 Howeever, direct manipulation in cycles is still slow;
i.e. fast code is expected to be moved to C extension
PISA 2007
32
www.ing.unipi.it
Progress2 (3/3)
 Could be a good idea to buy NumPy book, for $39.99
(electronic pdf version), I read first 50 sample pages
http://www.tramy.us/guidetoscipy.html Documentation
for older package, Numeric is available here:
http://numpy.sourceforge.net/numdoc/numdoc.pdf
for most case it should be enough
 TODO: make C++ class with overloaded operators,
as possible recommended datatype to use in C++
modules and check performance againts double **
PISA 2007
33
www.ing.unipi.it
Progress2 Notes (1/2)
 Shape of NumPy array can be anytime changed in
python, but we must keep the number of items
 Extended slice operations, which has base in python
are inspired from Numeric/Numpy package
 Numpy natively supports hundreds of operations:
–
–
–
–
PISA 2007
–
–
–
–
Aritmetic operators (*+-^%+=):
Concetation of matrices
Slices and indexing
Creation of Matrices and Vectors (filling arrays e.g. identity
matrix)
Reshaping
Assigment of multiple values
Transposing
Inverting
34
www.ing.unipi.it
Progress2 Notes (2/2)
–
–
–
–
–
–
–
–
–
Determinant
Summary of various elements
Sorting
Finding maximum and minimum
Flipping
Rotating
Various kind of multiplications
Finding values based on conditions
Statistics (average, median, variance, correlation,
covariance)
– Solving differential equation (diff function)
– Fourier transformation
– Direct reading from/to file. these operations are implemented
in C
PISA 2007
35
www.ing.unipi.it
Thank you for your attention.
?
?
Do you have any questions ?
PISA 2007
36