讲解:PyOpenCL、Python、Python、dataSQL|Python

Assignment 2, Deadline 15 November 2019General Remarks• The complete assignment must be written as a single Jupyter notebookthat contains the code, relevant output, graphcis and all explanations.• The Notebook must be executable without errors. To make sure that thisis the case, before submitting reload the notebook and run it from scratchto make sure it runs fine. Any submitted notebook that does not runcorrectly will receive an automatic 0 mark.• While you can (and should) include in your notebooks results from longerruntime, make sure that the parameter choices in your notebook on submissionare chosen such that the notebook does not take longer than 2minutes to run on your computer. We are most likely using much fastermachines for marking. But notebooks that have a substantially longerrunning time will be rejected.• You must follow in your code PEP8 coding guidelines with the only exceptionthat lines can be longer than 80 characters. But please do not makethem much longer than 100 characters so that they are still readable (considerat a soft limit). Failure to adhere to PEP8 coding guidelines canresult in substantial point reductions in severe cases.• Correctness of the codes will count 40% of the mark. You will receive30% for presentation, which includes sensible graphs and thorough documentation.The remaining 30% will be for efficient coding. However,a submission without documentation will still count as a fail as this is amandatory component.• You will be able to submit your Jupyter notebooks from a few days beforethe deadline onwards to the Moodle course page. A correspondingannouncement will be made in time.The following two questions are computational exercises that require you todevelop code implementations with PyOpenCL. It is ex代做PyOpenCL、Python程序设计调试、Pythonpected that you developefficient implementations that make use of advanced CPU parallelisation features.If you have problems with OpenCL CPU drivers on your own computersyou can use the Microsoft Azure Notebook platform.1Question 1: OpenCL CSR matrix-vector productGiven a sparse matrix in CSR format. Develop a class that derives from ScipyLinearOperator and which is initialised with data, indices, and indptr arraythat describe the sparse matrix. The class shall provide an efficient OpenCLaccelerated matrix-vector product. Make use of efficient parallelisation andSIMD features provided by Intel’s AVX2 technology. Make sure that your datamovements are efficient. In particular, the sparse matrix data should only betransferred to the device once and not during each matrix/vector product.Question 2: Potentials generated by random particles.We consider the Laplace equation−∇2u = fon the unit square with zero conditions on the boundary. Based on the finitedifference 5 point stencil discretization discussed in the lecture develop a LinearOperatorthat takes a vector u of values on an M ×M grid (xi, yj ) for xi =iM+1 ,j = 1, . . . , M and yi described in the same way, and returns the approximateevaluation of −∇2u for this vector. The evaluation of the 5 point stencil shouldbe parallelized using PyOpenCL without storing the matrix explicitly.The CG iterative solver in Scipy only requires a LinearOperator that implementsmatvecs. As right-hand side you can use the simple function f = 1.For different values of M plot the convergence curve of the residual r = kb −Axjk2/kbk2 (for these it is best to use a semilogy plot). Also, investigate howthe number of iterations grows as M increases. Finally, produce nice plots ofthe solution u on the unit square.2转自:http://www.3daixie.com/contents/11/3444.html

你可能感兴趣的:(讲解:PyOpenCL、Python、Python、dataSQL|Python)