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.
Este ejercicio forma parte del curso
Parallel Programming in R
Instrucciones del ejercicio
- Generate a cluster of four cores.
- Export
test_varandtest_sumto the cluster. - Print "Accuracy OK" if the sum of
test_varequalstest_sum, else print "Errors". - Stop the cluster.
Ejercicio interactivo práctico
Prueba este ejercicio y completa el código de muestra.
# 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
___