Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test/**/Output
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ jobs:
- os: osx
julia: nightly

cache:
directories:
- /home/travis/.julia/

notifications:
email: false

Expand All @@ -23,3 +27,6 @@ codecov: true
branches:
only:
- master

before_install:
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then choco install python3 --params "PrependPath=1"; fi
5 changes: 0 additions & 5 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,3 @@ DataStructures = "0.15, 0.16, 0.17"
LLVM = "1.4.0"
TimerOutputs = "0.5"
julia = "1.3"
[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]
6 changes: 6 additions & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[deps]
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
LLVM = "929cbde3-209d-540e-8aea-75f648917ca0"
LLVM_jll = "86de99a1-58d6-5da7-8064-bd56ce2e322c"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
7 changes: 7 additions & 0 deletions test/codegen/native.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# RUN: julia --startup-file=no -L ../definitions/native.jl %s | FileCheck %s

valid_kernel() = return

# CHECK-LABEL: define{{.*}} void @julia_valid_kernel
native_code_llvm(valid_kernel, Tuple{}; optimize=false, dump_module=true)

39 changes: 39 additions & 0 deletions test/lit.cfg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import os
import sys
import re
import platform

import lit.util
import lit.formats

import lit.llvm

config.llvm_tools_dir = os.environ.get('LLVM_TOOLS_DIR')
config.lit_tools_dir = '' # Intentionally empty
lit.llvm.initialize(lit_config, config)

from lit.llvm import llvm_config

config.name = 'GPUCompiler'
config.suffixes = ['.ll', '.jl']
config.test_source_root = os.path.dirname(__file__)
execute_external = platform.system() != 'Windows'
config.test_format = lit.formats.ShTest(execute_external)
config.substitutions.append(('%shlibext', '.dylib' if platform.system() == 'Darwin' else '.dll' if
platform.system() == 'Windows' else '.so'))

# Lit uses an empty environment so we copy over the settings from
# Pkg.test(), most importantly that's the `JULIA_LOAD_PATH`.
config.environment['JULIA_PROJECT'] = os.environ.get('JULIA_PROJECT')

LOAD_PATH = os.environ.get('JULIA_LOAD_PATH')
DEPOT_PATH = os.environ.get('JULIA_DEPOT_PATH')

if LOAD_PATH:
config.environment['JULIA_LOAD_PATH'] = LOAD_PATH

if DEPOT_PATH:
config.environment['JULIA_DEPOT_PATH'] = DEPOT_PATH

llvm_config.use_default_substitutions()

46 changes: 46 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,49 @@ end
haskey(ENV, "CI") && GPUCompiler.timings()

end

using LLVM_jll
function lit(f; adjust_PATH=true, adjust_LIBPATH=true)
PATH_SEP = Sys.iswindows() ? ';' : ':'
env_mapping = Dict{String,String}()
PATH = string(LLVM_jll.PATH, PATH_SEP, Base.Sys.BINDIR) # To get the right julia
if adjust_PATH
if !isempty(get(ENV, "PATH", ""))
env_mapping["PATH"] = string(PATH, PATH_SEP, ENV["PATH"])
else
env_mapping["PATH"] = PATH
end
end
LIBPATH=LLVM_jll.LIBPATH
LIBPATH_env=LLVM_jll.LIBPATH_env
if adjust_LIBPATH
if !isempty(get(ENV, LIBPATH_env, ""))
env_mapping[LIBPATH_env] = string(LIBPATH, PATH_SEP, ENV[LIBPATH_env])
else
env_mapping[LIBPATH_env] = LIBPATH
end
end
if Sys.iswindows()
PYTHONPATH = joinpath(LLVM_jll.artifact_dir, "tools", "lit")
if haskey(ENV, "PYTHONPATH")
env_mapping["PYTHONPATH"] = string(PYTHONPATH, PATH_SEP, ENV["PYTHONPATH"])
else
env_mapping["PYTHONPATH"] = PYTHONPATH
end
end
# set JULIA_PROJECT to the `test/Project.toml`
env_mapping["JULIA_PROJECT"] = Base.current_project()
env_mapping["LLVM_TOOLS_DIR"] = joinpath(LLVM_jll.artifact_dir, "tools")
lit_path = joinpath(LLVM_jll.artifact_dir, "tools", "lit", "lit.py")
withenv(env_mapping...) do
f(lit_path)
end
end

lit() do lit_path
if Sys.iswindows()
run(`python $lit_path -va codegen`)
else
run(`$lit_path -va codegen`)
end
end