How I spent the summer: Computer Continuum-2014 Summer School

    Good day to all! I want to talk about my experience of participating in the computer school Continuum-2014 summer school , where I taught my course. School events were held from August 25 to 30. However, I only got on the three days in which the trainings were held: from the 26th to the 28th.

    And although I spent only three days at the events themselves, the preparation took up a significant part of the summer outside of vacation. The task before me was not easy.
    1. An unusual site for me. For a long time I did not conduct classes outside the walls of the office or my native MIPT.
    2. Short deadlines. Usually I read my course during the semester or even the school year. What can be done in three days? I had to carefully limit and balance the volume of theory and practical tasks that I could throw out to the audience.
    3. I was completely unknown to the level of training of the public. When working with students of the same course, you can roughly imagine that they have already passed; in addition, we usually interview them. Who will be at this school and what will be the level of their training was a mystery to me. And in fact, people came very different (more on that later).

    About school

    The event was held with the participation of the following organizations and companies: St. Petersburg State University, St. Petersburg State Polytechnic University, Northern Arctic Federal University named after M.V. Lomonosov (Arkhangelsk), Euler Foundation (St. Petersburg), Nizhny Novgorod Foundation for the Promotion of Education and Research, Intel, EMC, JetBrains. School participants were offered a choice of several lesson tracks. My track was number 4 - "Fundamentals of software modeling." In addition, Intel was introduced on track 5 with its XDK .

    What was Intel track about

    In the first and second days, I spent part of the time on the theoretical foundations of software simulation, namely, why this technology is an important component of hardware and software development, how processor models are arranged and how peripheral devices differ from them .

    But still, I decided to devote most of the course time to practical work on creating processor models and peripherals of the OpenRISC 1000 architecture . In preparing the course, I decided for quite some time which model we would write. Why did I choose this particular architecture?
    1. I really did not want to once again make the 100500th MIPS.
    2. Open and free specification .
    3. A modular structure with many optional parts - in the worst case, even if you implement only the core and a dozen instructions, you can still see the result. On the other hand, if you go deeper into the support of details, then there will definitely be more work than three days.
    4. The simplicity of specifications with the presence of important concepts, such as interrupts and exceptions, external devices, timers, floating point operations, vector instructions, etc., which makes the architecture completely non-flash.
    5. Community support - if someone wants to continue working with OpenRISC 1000, then they have ready-made tools at their disposal : GCC and Clang compilers, Libc libraries, the Linux kernel, and even Verilog designs.

    Thus, OpenRISC 1000 left me a lot of room for maneuver - for any public there is a strength task. Wind River® Simics was

    used as a simulator and framework on which models were written and debugged . For academic organizations wishing to conduct training or non-profit research in the field of computer architecture or performance, there is the opportunity to get a free Simics license for 50 seats and a set of packages with ready-made models of Intel® Core ™ and Intel® Atom ™ processors. According to this program in Russia, Simics has already been installed in two universities - at the Moscow Institute of Physics and Technology and now at Petersburg IITU. Why was Simics chosen?

    1. I have been working with this product for a long time and quite intensively, and it was natural to use it.
    2. Simics provides a rich yet well-documented API for writing a variety of models and tools for researching computing systems and developing system software.
    3. The delivery for academic users includes a large number of examples of the implementation of devices with source codes, which made it possible to start studying with already working code and gradually modify it for the objectives of the course. So, the kernel model or1kwas based on sample-risc, and the tick timer was based on sample-timer-device.

    Who participated

    14 people came to my classes. Some were students of St. Petersburg State University, St. Petersburg Polytechnic University, TUSUR, as well as from Nizhny Novgorod (Higher School of Economics) and Volgograd (Volgograd State Technical University). Other participants turned out to be pretty senior teachers of universities, who were also interested in what they would tell. Finally, several colleagues from the St. Petersburg branch of Intel Labs “crept in”, who were motivated in many ways by professional interest. Everyone got to the third day, even colleagues from Intel, although they were always torn between very important workshops and my occupation. At the same time, everyone was interested in programming their own part of the platform being created.


    By the end of the third day, we had a good set: one common kernel model or1k, two implementations of the PIC interrupt controller and one and a half (one worked, and the second remained a little unfinished) timer, unit tests for the kernel instructions made and a common script for the platform, which It looked something like this:

    What was most pleasant and incredible - we managed to connect all the models into a common configuration and observe how periodic interrupts either reach or fail to reach the kernel, which, in turn, processes them according to the specification, passing n about the vector specified in it on the code of the exception handler. Of course, we did not have much time: to implement a full set of instructions, to ensure fair translation of addresses, to write a TLB model, etc. But it worked!

    What is easy for students

    As the new school year began, it was interesting for me as a teacher to find out what difficulties the participants may have in perceiving this type of practical work, all the more so as I will conduct a similar but more detailed course in this school year. First, I’ll list what turned out to be relatively easy.

    • Work in Linux. Although not all participants felt confident, no one complained about the impossibility of work. I was surprised that many used Midnight Commander, as I did - I had never seen anything like this before.
    • The general idea of ​​interpretation. Many of the students were familiar with the principle of pipelining commands in the CPU.
    • Read bit masks in the mind. Surprisingly, for some it was easier to write a constant as 0xc0000000 than to leave it in the form (1 << 31) | (1 << 30).
    • Support for branching instruction features - delay slot. For a number of RISC processors, the instruction immediately after branching is executed even if a transition to a new address is to occur. Some of the participants boldly rushed to simulate this (optional in general) functionality and successfully coped with it.
    • Writing DML Code DML is a specialized language used to quickly write Simics models. It combines a declarative description of device registers with an imperative description of processes that occur during their reading and writing. At first, I planned to limit myself to pure C (since I almost always write models for Simics on it myself), but it turned out that DML really allows you to speed up the process of writing models - two dozen lines in C were replaced by two with DML. It was not difficult for anyone to learn his basic ideas from the available examples.

    What caused difficulties

    On the other hand, there were surprises in the fact that some concepts were unknown or given with some difficulty to the participants (and sometimes to the teacher).

    • Work with Git. Only one person without prompts was able to push his edits into the general repository himself. Nevertheless, this version control system helped a lot with getting a common code with the final result.
    • Endianness. It would seem that everyone knows about the existence of two orders of bytes for representing multibyte sequences. And yet it was very difficult for me, like the other participants, to quickly reason about whether we put the data in memory correctly, in what order the bytes were extracted for decoding, etc.
    • Simulation using an event queue. Discrete event simulation (DES) is a key technique for efficiently modeling a large number of agents with asynchronously occurring events. The timer model actively used events. For some reason, this turned out to be more complicated than the synchronous processor model.
    • The need to expand the sign. Many processor arithmetic instructions require expansion of signed operands before they are used in the operation. Sometimes their original width was not equal to 8, 16 or 32 bits, and it was necessary to come up with the correct C-code to correctly take into account the position of the character and its extension.

    What surprises met

    Purely technical moments that are remembered.
    • GDB on Linux Mint is by default not allowed to connect to processes that are not descendants of the debugger (calling ptrace () returns “Permission denied”). It is treated simply:
      # echo 0 > /proc/sys/kernel/yama/ptrace_scope
      Or (enable debugging after rebooting): write 0 to the file /etc/sysctl.d/10-ptrace.conf.
    • Having the -l option is dangerous: it can be confused with -1, which will lead to long-term debugging with breaking the head.


    As I have repeatedly noticed after the end of the next course, I can’t say who, as a result of it, learned more - students or a teacher. So here - having plunged into a slightly different environment, on the other hand, having approached the daily used tools, I learned new about them. And of course, I met a large number of interesting people and, I hope, was able to interest them.

    Thanks to all the participants of the school for their interest in modern technologies and the diligence in solving the assigned tasks, and to its organizers for the very good coordination, clear schedule and technical support of the event. And to the readers of this post - thank you for your attention!

    Also popular now: