(define-module (vfx packages intel)
#:use-module (gnu packages)
#:use-module (gnu packages pkg-config)
#:use-module (gnu packages llvm)
#:use-module (gnu packages vulkan)
#:use-module (gnu packages compression)
#:use-module (gnu packages flex)
#:use-module (gnu packages bison)
#:use-module (gnu packages protobuf)
#:use-module (gnu packages python)
#:use-module (gnu packages libffi)
#:use-module (guix)
#:use-module (guix gexp)
#:use-module (guix build utils)
#:use-module (guix build-system cmake)
#:use-module ((guix licenses) #:prefix licenses:))
(define (llvm-uri component version)
;; LLVM release candidate file names are formatted 'tool-A.B.C-rcN/tool-A.B.CrcN.src.tar.xz'
;; so we specify the version as A.B.C-rcN and delete the hyphen when referencing the file name.
(string-append "https://github.com/llvm/llvm-project/releases/download"
"/llvmorg-" version "/" component "-" (string-delete #\- version) ".src.tar.xz"))
(define-public llvm-11.1
(package
(inherit llvm-11)
(version "11.1.0")
(source
(origin
(method url-fetch)
(uri (llvm-uri "llvm" version))
(sha256
(base32
"199yq3a214avcbi4kk2q0ajriifkvsr0l2dkx3a666m033ihi1ff"))))))
(define-public spirv-headers-3
(package
(name "spirv-headers")
(version "3.236.0")
(source
(origin
(method url-fetch)
(uri
(string-append "https://github.com/KhronosGroup/SPIRV-Headers/"
"archive/refs/tags/sdk-1." version ".tar.gz"))
(sha256
(base32 "0y1b5d7vslqfv76l7an9bzs7vchc39kxs962lzmnji6pzn2wcx2d"))))
(build-system cmake-build-system)
(arguments
`(#:tests? #f)) ;no tests
(home-page "https://github.com/KhronosGroup/SPIRV-Headers")
(synopsis "Machine-readable files from the SPIR-V Registry")
(description
"SPIRV-Headers is a repository containing machine-readable files from
the SPIR-V Registry. This includes:
@itemize
@item Header files for various languages.
@item JSON files describing the grammar for the SPIR-V core instruction set,
and for the GLSL.std.450 extended instruction set.
@item The XML registry file.
@end itemize\n")
(license (licenses:x11-style
(string-append "https://github.com/KhronosGroup/SPIRV-Headers/blob/"
version "/LICENSE")))))
(define-public spirv-tools-3
(package
(name "spirv-tools")
(version "3.236.0")
(source
(origin
(method url-fetch)
(uri
(string-append "https://github.com/KhronosGroup/SPIRV-Tools/"
"archive/refs/tags/sdk-1." version ".tar.gz"))
(sha256
(base32 "1agxkmbvlyr1vwy53s62rjlygp8c5wvgjyfmqcks33xsm21cg2b7"))))
(build-system cmake-build-system)
(arguments
`(#:configure-flags (list "-DBUILD_SHARED_LIBS=ON"
(string-append
"-DSPIRV-Headers_SOURCE_DIR="
(assoc-ref %build-inputs "spirv-headers")))))
(inputs (list spirv-headers-3))
(native-inputs (list pkg-config python))
(home-page "https://github.com/KhronosGroup/SPIRV-Tools")
(synopsis "API and commands for processing SPIR-V modules")
(description
"The SPIR-V Tools project provides an API and commands for processing
SPIR-V modules. The project includes an assembler, binary module
parser,disassembler, validator, and optimizer for SPIR-V.")
(license licenses:asl2.0)))
(define-public spirv-llvm-translator
(package
(name "spirv-llvm-translator")
(version "15.0.0")
(source
(origin
(method url-fetch)
(uri
(string-append "https://github.com/KhronosGroup/SPIRV-LLVM-Translator/"
"archive/refs/tags/v" version ".tar.gz"))
(sha256
(base32 "123dhhpiw0kx6z5s0s91c5d82if5vp17hbl50267b219yxvvvgmi"))))
(build-system cmake-build-system)
(native-inputs
(list pkg-config))
(inputs
(list llvm-15 spirv-headers-3 spirv-tools-3 libffi))
(arguments
`(#:tests? #f
#:configure-flags
(list (string-append "-DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR="
(assoc-ref %build-inputs "spirv-headers")
(string-append "-DPKG_CONFIG_PATH="
(assoc-ref %build-inputs "spirv-tools")
"/lib/pkgconfig")))))
(home-page "https://github.com/intel/intel-graphics-compiler")
(synopsis "Intel Graphics Compiler for OpenCL")
(description "The Intel® Graphics Compiler for OpenCL™ is an LLVM based
compiler for OpenCL™ targeting Intel Gen graphics hardware architecture.")
(license licenses:expat)))
(define-public opencl-clang
(package
(name "opencl-clang")
(version "15.0.0")
(source
(origin
(method url-fetch)
(uri
(string-append "https://github.com/intel/opencl-clang/"
"archive/refs/tags/v" version ".tar.gz"))
(sha256
(base32 "048lmm2ydp02n7yvqzn3sbvm4w3z8sz7cpv5w9ccdj1bwms9c5za"))))
(build-system cmake-build-system)
(inputs
(list llvm-15 clang-15 spirv-llvm-translator libffi))
(arguments
`(#:tests? #f
#:phases
(modify-phases %standard-phases
(add-after 'unpack 'force
(lambda _
(substitute* "cl_headers/CMakeLists.txt"
(("endif\\(USE_PREBUILT_LLVM\\)")
(string-append "endif(USE_PREBUILT_LLVM)
set(OPENCL_HEADERS_DIR \"" (assoc-ref %build-inputs "clang") "/lib/clang/15.0.6/include\")")))
#t)))
#:configure-flags
(list "-DLLVMSPIRV_INCLUDED_IN_LLVM=OFF"
(string-append "-DSPIRV_TRANSLATOR_DIR="
(assoc-ref %build-inputs "spirv-llvm-translator")))))
(home-page "https://github.com/intel/vc-intrinsics")
(synopsis "Thin wrapper library around clang")
(description "The library has OpenCL-oriented API and is capable
to compile OpenCL C kernels to SPIR-V modules.")
(license licenses:bsd-3)))
(define-public vc-intrinsics
(package
(name "vc-intrinsics")
(version "0.11.0")
(source
(origin
(method url-fetch)
(uri
(string-append "https://github.com/intel/vc-intrinsics/"
"archive/refs/tags/v" version ".tar.gz"))
(sha256
(base32 "17xvh6nw42k8ivr4xybawr777njyh2n50k0mrr0nvyp7diidbb75"))))
(build-system cmake-build-system)
(inputs
(list llvm-11.1 python))
(arguments
`(#:tests? #f
#:configure-flags
(list (string-append "-DLLVM_DIR="
(assoc-ref %build-inputs "llvm")
"/lib/cmake/llvm"))))
(home-page "https://github.com/intel/vc-intrinsics")
(synopsis "Intel VC Intrinsics")
(description "VC Intrinsics project contains a set of new intrinsics
on top of core LLVM IR instructions that represent SIMD semantics of a
program targeting GPU.")
(license licenses:expat)))
(define-public graphics-compiler
(package
(name "graphics-compiler")
(version "1.0.13181.1")
(source
(origin
(method url-fetch)
(uri
(string-append "https://github.com/intel/intel-graphics-compiler/"
"archive/refs/tags/igc-" version ".tar.gz"))
(sha256
(base32 "1k0ffsp44mxyarxpjsnp81vh59j1lkjqcsaqdwwr9ya0r3qadhi9"))))
(build-system cmake-build-system)
(native-inputs
(list flex bison lld))
(inputs
(list llvm-11.1 clang-11 opencl-clang spirv-llvm-translator spirv-tools-3 protobuf vc-intrinsics zlib))
(arguments
`(#:tests? #f
#:configure-flags
(list "-DIGC_OPTION__SPIRV_TOOLS_MODE=Prebuilds"
"-DIGC_OPTION__USE_PREINSTALLED_SPIRV_HEADERS=ON"
"-DSPIRV_TOOLS_BUILD_STATIC=OFF"
"-DIGC_OPTION__VC_INTRINSICS_MODE=Source"
(string-append "-DVC_INTRINSICS_SRC="
(assoc-ref %build-inputs "vc-intrinsics")
"/lib/cmake/LLVM")
;;(string-append "-DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR="
;; (assoc-ref %build-inputs "spirv-headers"))
;;(string-append "-DPKG_CONFIG_PATH="
;; (assoc-ref %build-inputs "spirv-tools")
;; "/lib/pkgconfig")
)
;; #:phases
;; (modify-phases %standard-phases
;; (add-before 'configure 'integrate-dependencies
;; (lambda _
;; (symlink "saga-gis"))))
))
(home-page "https://github.com/intel/intel-graphics-compiler")
(synopsis "Intel Graphics Compiler for OpenCL")
(description "The Intel Graphics Compiler for OpenCL is an LLVM based
compiler for OpenCL targeting Intel Gen graphics hardware architecture.")
(license licenses:expat)))
(define-public graphics-compute-runtime
(package
(name "graphics-compute-runtime")
(version "22.49.25018.23")
(source
(origin
(method url-fetch)
(uri
(string-append "https://github.com/intel/compute-runtime/"
"archive/refs/tags/" version ".tar.gz"))
(sha256
(base32 "0mznb0zsw0slylq06kmla1l3ywxnpy9aa5xh6px669si7h26w3mq"))))
(build-system cmake-build-system)
(native-inputs
(list pkg-config graphics-compiler))
;;(inputs
;; (list zlib))
(home-page "https://github.com/intel/compute-runtime")
(synopsis "Intel Graphics Compute Runtime for OpenCL Driver")
(description "The Intel(R) Graphics Compute Runtime for oneAPI Level Zero
and OpenCL(TM) Driver is an open source project providing compute API support
(Level Zero, OpenCL) for Intel graphics hardware architectures (HD Graphics, Xe).")
(license licenses:expat)))