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

Add cuda compilation environment support #158

Closed
3 tasks done
waruqi opened this issue Feb 26, 2018 · 4 comments
Closed
3 tasks done

Add cuda compilation environment support #158

waruqi opened this issue Feb 26, 2018 · 4 comments
Milestone

Comments

@waruqi
Copy link
Member

waruqi commented Feb 26, 2018

Support CUDA Toolkit http://docs.nvidia.com/cuda/index.html

@waruqi waruqi added this to the 2.1.10 milestone Feb 26, 2018
@waruqi
Copy link
Member Author

waruqi commented Mar 9, 2018

xmake will detect cuda sdk environment automatically, we can only run the following command to compile cuda program:

$ xmake

And we can also configure a given cuda sdk directory if detect failed.

$ xmake f --cuda=/usr/local/cuda-9.1/ 
$ xmake

@waruqi
Copy link
Member Author

waruqi commented Mar 9, 2018

Create an empty project for cuda:

$ xmake create -P test -l cuda
$ cd test
$ xmake

@waruqi
Copy link
Member Author

waruqi commented Mar 9, 2018

cuda_test

@waruqi waruqi closed this as completed Mar 9, 2018
@waruqi
Copy link
Member Author

waruqi commented May 29, 2018

-- define target
target("cuda_console")

    -- set kind
    set_kind("binary")

    -- add include directories
    add_includedirs("inc")

    -- add files
    add_files("src/*.cu")

    -- generate SASS code for each SM architecture
    for _, sm in ipairs({"30", "35", "37", "50", "52", "60", "61", "70"}) do
        add_cuflags("-gencode arch=compute_" .. sm .. ",code=sm_" .. sm)
        add_ldflags("-gencode arch=compute_" .. sm .. ",code=sm_" .. sm)
    end

    -- generate PTX code from the highest SM architecture to guarantee forward-compatibility
    sm = "70"
    add_cuflags("-gencode arch=compute_" .. sm .. ",code=compute_" .. sm)
    add_ldflags("-gencode arch=compute_" .. sm .. ",code=compute_" .. sm)

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

No branches or pull requests

1 participant