eholk / harlan

A language for GPU computing.
Other
1.19k stars 83 forks source link

./harlanc test/hello.kfc took a very long time, is that normal? #110

Closed muyinliu closed 9 years ago

muyinliu commented 10 years ago

@eholk I run the command "./harlanc test/hello.kfc" and it took over 2 minutes. But finally I got runnable file "hello". Is that normal? And why it took so long?

eholk commented 10 years ago

Two minutes is a little long, but not abnormal. How much RAM do you have? Harlan uses the Nanopass framework, which unfortunately generates a lot of code at macro expansion time. Currently Harlan uses about 5GB RAM on my machine. If you have this much free, compilation takes about 40 seconds, which is better than 2 minutes, but still longer than I'd like. I'm working on a few options to reduce this.

99 is related.

muyinliu commented 10 years ago

I use MacBook 516 which came out in 2010. Here is the profile:

Model Name:  MacBook
Model Type:  13-inch, Mid 2010
Model Identifier:  MacBook7,1
Processor Name:  Intel Core 2 Duo CPU P8600
Processor Model:  Penryn
Processor Speed:  2.4 GHz
Number of Processors:  1
Total Number of Cores:  2
Memory Size:  4 GB 1067 MHz DDR3
Graphics Model:  NVIDIA GeForce 320M 256 MB
Manufactured during:  May 2010
L1 Cache:  64 KB
L2 Cache:  3 MB
L3 Cache:  -
Processor Bitrate:  64 bit
EFI Bitrate:  64 bit
Kernel Bitrate:  64 bit
Bus Speed:  1.07 GHz
Boot ROM Version:  MB71.0039.B0E
System SMC Version:  1.60f6
Power Source:  AC Power. Fully charged.
Minimum Supported Operating System:  OS X 10.6.3 Build 10D2125 (Snow Leopard)
Current Boot Operating System:  OS X 10.9.0 Build 13A603 (Mavericks)
Maximum Supported Operating System:  Latest version of OS X 10.9 (Mavericks)

Here is the time records:

harlan$ time ./harlanc test/hello.kfc

real    2m55.865s
user    1m23.920s
sys 0m32.725s
harlan$ time ./harlanc test/hello.kfc

real    3m6.301s
user    1m23.739s
sys 0m32.437s
harlan$ time ./harlanc test/hello.kfc

real    1m57.516s
user    1m16.198s
sys 0m20.928s
harlan$ time ./harlanc test/hello.kfc

real    1m44.939s
user    1m11.048s
sys 0m18.169s

The last 2 record is under few application is still running. I closed most application to test.

The progress petite max memory is 2.67Gb, CPU seems always larger than 95%.

eholk commented 10 years ago

Thanks for the info! Unfortunately, this is probably about the best we'll be able to do for a while.

For developing Harlan programs, you can try harlani. It gives you a shell that you can use to compile programs without having to stop and restart the compiler each time. This avoids paying the cost of compiling Harlan each time you want to compile a program written in Harlan.

muyinliu commented 10 years ago

Thanks for your tips. I try ./harlani on my MacBook, I got this error:

harlan$ ./harlani
Some useful options:
 (make-shared-object)  -- Compile to a shared library instead of an executable
 (harlan-library-path) -- Where Harlan finds imported libraries
 (harlan-runtime-path) -- Where Harlan finds its runtime files
 (verbose)             -- Make Harlan print detailed information
 (debug)               -- Generate debugging information
 (timing)              -- Display pass timing information

Compile a file with (compile "filename")
> compile test/hello.kfc

Exception in match: Unmatched datum with irritant compile

It seems didn't work?

And from #11, is that Vicare works well in OS X? I really want to try Vicare. I will make a report after trying.

eholk commented 10 years ago

The harlani commands need to be in S-expressions. Try (compile "test/hello.kfc") instead.

On Fri, Dec 6, 2013 at 2:52 AM, muyinliu notifications@github.com wrote:

Thanks for your tips. I try ./harlani on my MacBook, I got this error:

harlan$ ./harlani Some useful options: (make-shared-object) -- Compile to a shared library instead of an executable (harlan-library-path) -- Where Harlan finds imported libraries (harlan-runtime-path) -- Where Harlan finds its runtime files (verbose) -- Make Harlan print detailed information (debug) -- Generate debugging information (timing) -- Display pass timing information

Compile a file with (compile "filename")

compile test/hello.kfc

Exception in match: Unmatched datum with irritant compile

It seems didn't work?

And from #11 https://github.com/eholk/harlan/issues/11, is that Vicare works well in OS X? I really want to try Vicare. I will make a report after trying.

— Reply to this email directly or view it on GitHubhttps://github.com/eholk/harlan/issues/110#issuecomment-29969907 .

muyinliu commented 10 years ago

(compile "test/hello.kfc") is okay, thanks.

Here is the record:

harlan$ ./harlani
Some useful options:
 (make-shared-object)  -- Compile to a shared library instead of an executable
 (harlan-library-path) -- Where Harlan finds imported libraries
 (harlan-runtime-path) -- Where Harlan finds its runtime files
 (verbose)             -- Make Harlan print detailed information
 (debug)               -- Generate debugging information
 (timing)              -- Display pass timing information

Compile a file with (compile "filename")
> (compile "test/hello.kfc")
#t
> (compile "test/hello.kfc")
#t
>

Every time compile only take few second, CPU less than 30% and less memory(about 500Mb of the progress petite).

eholk commented 10 years ago

Awesome! I hope this works for now until we can get the regular harlanc memory usage down.

Please keep playing around with this and feel free to ask about any issues you run into. This is still a research project so there are likely to be many issues, but I will do by best to address them promptly.

On Fri, Dec 6, 2013 at 11:03 AM, muyinliu notifications@github.com wrote:

(compile "test/hello.kfc") is okay, thanks.

Here is the record:

harlan$ ./harlani Some useful options: (make-shared-object) -- Compile to a shared library instead of an executable (harlan-library-path) -- Where Harlan finds imported libraries (harlan-runtime-path) -- Where Harlan finds its runtime files (verbose) -- Make Harlan print detailed information (debug) -- Generate debugging information (timing) -- Display pass timing information

Compile a file with (compile "filename")

(compile "test/hello.kfc")

t

(compile "test/hello.kfc")

t

Every time compile only take few second, CPU less than 30% and less memory(about 500Mb of the progress petite).

— Reply to this email directly or view it on GitHubhttps://github.com/eholk/harlan/issues/110#issuecomment-30005380 .

eholk commented 10 years ago

417059e includes some changes that make Harlan's memory usage significantly less. Hopefully this will help.

eholk commented 9 years ago

6e789cc0f997fd30c481958d7e54fa663eeb2cfa improves performance some more too. Compiling hello.kfc on my machine takes 8.5 seconds now. I'll continue to work on improving the compiler's performance, but I'm going to go ahead and consider this bug fixed.

Please let me know if you're still seeing multiple minute compile times though.