![]() ![]() An analogy could be to build a wall by laying bricks alone, one by one (serial) as opposed to building it with the help of three friends (parallel with 4 “cores”). ![]() The desired result of parallelizing a task is a reduction in its execution time. Recruiting more than one core for a given task is known as parallelization. When a program runs serially (as they usually do by default), only one core is recruited for performing the program’s task. The number of cores in your computer can be retrieved from R with the command: numCores <- parallel::detectCores() # Requires library(parallel) print(numCores) # In my case, this prints 8 Each of them can be loosely thought of as an independent mini-computer, capable of doing tasks independently of the other ones. Modern laptops typically have 4 or 8 cores. If you prefer to execute it line-by-line, you may be interested in visiting the vignette version of this tutorial. If you are missing any, you can install it running install.package(''), where stands for the name of the library (for instance, install.package('parallel')). Additionally, some libraries may be required. R is required, and RStudio is recommended. In this short tutorial, we will talk about one of them: parallelization. There are several strategies to increase the execution speed of loops. When the tasks are complex, or if the number of repetitions is high, loops may take a lot of time to run even on a computer. Luckily for us, computers are good at performing repetitive tasks, and they never complain about boredom. Although it is not part of the definition, loops also tend to be boring. Loops are, by definition, repetitive tasks. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |