Message Boards Message Boards

0
|
9210 Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Calculation speed, Cup&memory&Kernel

Posted 9 years ago

Hello; I had run a program. It takes a long time...... And during, I check my cup occupancy rate at 20%, memory usage rate at 75% and kernels status is idle. My program:

SunPosition[GeoPosition[{0, 0}], 
 DateRange[DateObject[{2014, 1, 1, 0, 0}, TimeZone -> 0], 
  DateObject[{2014, 12, 31, 24, 59}, TimeZone -> 0], {1, "Minute"}], 
 CelestialSystem -> "Equatorial"]

How to speed it up? Thank you!

POSTED BY: c deng
2 Replies
Posted 9 years ago

so many thank??

I thought about Parallelize. However, I use ------

Partition[time, UpTo[Round[Length[time]/$KernelCount]]];

to separate the "time" table(Sorry, I can't find all script). What's the simpler but more efficient way is to use ParalleTable.

I already set use 7-8 kernels. I used ---

Needs["Benchmarking`"];

to test speed. The CUP workload reached 100%. It did have some improvement. But form what I observed, efficiency may not only decide by the number of cup-core. I also found form Internet that we can use compile into C to gain a faster script. But I current use Manipulate, maybe I can can only rely on Exorp gif or avi. Thank you patient writing and reading. Also it really cheering to see someone have the small thought but do it in a more efficient way.

POSTED BY: c deng

Dear ce deng,

There are few possibilities to speed up the code. Please see the following post for great tips&tricks. As for your code the easiest way is to notice and workaround few problems: - You can speed up the code by using multiple CPU cores (it may also depend on your Mathematica license, as it requires few kernels to run). For this purpose instead of using SunPosition[] on the list of dates, generate the dates in ParallelTable[] and use ParallelTable[] again to call SunPosition on each element of the list containing dates. - One of the bottlenecks of the code may be using DateObject[]. I noticed that for generating large date lists it is much more efficient to use AbsoluteTime and then to "retranslate" it to DateList. Using 4 Mathematica kernels my code works about 2.4 times faster than original one. If you have no possibility of using multiple CPU cores or Mathematica Kernels then the code will be sped up only about 1.1 times.

IMPORTANT: please see that in my code I used only 3 days time range.

TimeSeries[
 ParallelTable[{d, 
   SunPosition[GeoPosition[{0, 0}], d, 
    CelestialSystem -> "Equatorial"]}, {d, 
   DateList /@ 
    ParallelTable[
     time, {time, 
      AbsoluteTime@DateObject[{2014, 1, 1, 0, 0}, TimeZone -> 0], 
      AbsoluteTime@DateObject[{2014, 1, 3, 24, 59}, TimeZone -> 0], 
      60.}]}]]
Attachments:
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract