Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable profile by default #216

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

junjihashimoto
Copy link
Member

hasktorch is development phase, so we are going to take profile many times.
This pr enables profile by default.

Copy link
Member

@tscholak tscholak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! actually, I've spotted a problem

nix/shared.nix Outdated Show resolved Hide resolved
@tscholak
Copy link
Member

Hi @junjihashimoto, your last commit, b725b9f, only added the enableLibraryProfiling to the scope, but you still have to use it.

@tscholak
Copy link
Member

for instance, instead of

                    "hasktorch_${postfix}" =
                      overrideCabal
                        (haskellPackagesOld.callCabal2nix
                          "hasktorch"
                          ../hasktorch
                          { libtorch-ffi = haskellPackagesNew."libtorch-ffi_${postfix}"; }
                        )
                        (old: {
                              preConfigure = (old.preConfigure or "") + optionalString (!isDarwin) ''
                                export LD_PRELOAD=${pkgs.mkl}/lib/libmkl_rt.so
                              '';
                            }
                        );

write

                    "hasktorch_${postfix}" =
                      enableLibraryProfiling
                        (overrideCabal
                          (haskellPackagesOld.callCabal2nix
                            "hasktorch"
                            ../hasktorch
                            { libtorch-ffi = haskellPackagesNew."libtorch-ffi_${postfix}"; }
                          )
                          (old: {
                                preConfigure = (old.preConfigure or "") + optionalString (!isDarwin) ''
                                  export LD_PRELOAD=${pkgs.mkl}/lib/libmkl_rt.so
                                '';
                              }
                          )
                        );

@junjihashimoto
Copy link
Member Author

@tscholak
Thank you for pointing it out.

BTW, the failure of CI on stack-macos is the same as this issue(fpco/inline-c#102).

@tscholak
Copy link
Member

@junjihashimoto, in order to fix this nasty macOS bug, I introduced this hot-fix:

hasktorch/nix/shared.nix

Lines 46 to 48 in b725b9f

preConfigure = (old.preConfigure or "") + optionalString isDarwin ''
sed -i -e 's/-optc-std=c++11 -optc-xc++/-optc-xc++/g' ../libtorch-ffi/libtorch-ffi.cabal;
'';

I'm surprised it's not working any longer

@tscholak
Copy link
Member

tscholak commented Nov 4, 2019

@junjihashimoto it’s super hard to make both cabal and stack happy about this cx flag on all platforms. That’s why I went for this hot-fix solution in shared.nix

@junjihashimoto
Copy link
Member Author

junjihashimoto commented Nov 4, 2019

@tscholak
I can not find options to pass stack-macos.
This commit(0480dab) is the same as nix's one. But stack fails.

@junjihashimoto
Copy link
Member Author

junjihashimoto commented Nov 6, 2019

@tscholak
I've realized setting profile on macos is super hard.
ghc passes options of "-DPROFILING -x c" to clang in front of user's options(-xc++ -std=c++11).
clang uses the option of "clang -xc++ -std=c++11 -DPROFILING -x c 'generated code'."
So clang recognizes generated codes of inline-c-cpp as c-sources.
I am finding the source-codes adding the options in ghc-repo.

@junjihashimoto
Copy link
Member Author

We can get the result of benchmark from artifact of github-action.
image

@tscholak
Copy link
Member

tscholak commented Nov 6, 2019

sweet, @junjihashimoto !

@tscholak
Copy link
Member

tscholak commented Nov 6, 2019

I can try to fix the nix-macos build later today if it should still fail

@junjihashimoto
Copy link
Member Author

nix-macos fails during setup of nix.
I share the error with cachix-action.
https://github.com/cachix/cachix-action/issues/14

@tscholak
Copy link
Member

tscholak commented Nov 6, 2019

O.o, ok. I'll follow this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants