LoslegenKostenlos loslegen

Running code on the cluster

You work for a data consultancy and your company uses a lot of parallel R code. But lately, the results have been erratic, and sometimes the code gives varying results for the same input. Before any further troubleshooting, you have decided to run a basic check on each cluster.

You have created a variable test_var and calculated the sum of all its elements, test_sum. You want to check if each cluster can sum this variable accurately. The parallel package has been loaded for you.

Diese Übung ist Teil des Kurses

Parallel Programming in R

Kurs anzeigen

Anleitung zur Übung

  • Generate a cluster of four cores.
  • Export test_var and test_sum to the cluster.
  • Print "Accuracy OK" if the sum of test_var equals test_sum, else print "Errors".
  • Stop the cluster.

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# Make a cluster of four cores
cl <- ___
# Export test_var and test_sum to cluster
clusterExport(___, ___, envir = environment())
# Check the sum on cluster
clusterEvalQ(___, {
  ___
  
  
})
# Stop cluster
___
Code bearbeiten und ausführen