MATLAB Answers

Global variables when doing Matlab array job in a cluster

조회 수: 10(최근 30일)
CT
CT 1 Apr 2020
답변: Rik 1 Apr 2020
I am running a Matlab array job in the cluster of my university. Specifically, I run a script f.m in parallel several times using the command qsub from the terminal. The parallel jobs may be done in different nodes, depending on the availability.
The script f.m defines some global variables and calls some other functions which use those global variables. I am aware that global variables are not recommended but in my setting they are the easiest way to perform certain tasks.
Question: Each parallel job should use "its own" global variables. Is it correct to say that the global variables do not interfere across parallel jobs despite having the same names?

  댓글 수: 0

로그인 to comment.

채택된 답변

Rik
Rik 1 Apr 2020
I don't have a direct link to the doc, but I'll take Walter's word for it:
"The initial value of the global variables will not be transferred to the workers, and the workers do not share the global variable with each other -- you cannot use global to communicate between the workers. Also, the value of the global variables will not be copied back from the workers to the client."

  댓글 수: 0

로그인 to comment.

추가 답변(0개)

이 질문에 답변하려면 로그인을(를) 수행하십시오.


Translated by