summaryrefslogtreecommitdiff
path: root/llama.cpp/scripts/snapdragon
diff options
context:
space:
mode:
Diffstat (limited to 'llama.cpp/scripts/snapdragon')
-rw-r--r--llama.cpp/scripts/snapdragon/adb/llama-cli.farf1
-rwxr-xr-xllama.cpp/scripts/snapdragon/adb/run-bench.sh52
-rwxr-xr-xllama.cpp/scripts/snapdragon/adb/run-cli.sh59
-rwxr-xr-xllama.cpp/scripts/snapdragon/adb/run-completion.sh59
-rwxr-xr-xllama.cpp/scripts/snapdragon/adb/run-mtmd.sh68
-rwxr-xr-xllama.cpp/scripts/snapdragon/adb/run-tool.sh54
-rw-r--r--llama.cpp/scripts/snapdragon/qdc/readme.md1
-rw-r--r--llama.cpp/scripts/snapdragon/qdc/requirements.txt25
-rw-r--r--llama.cpp/scripts/snapdragon/qdc/tests/test_bench.py63
-rw-r--r--llama.cpp/scripts/snapdragon/windows/run-bench.ps140
-rw-r--r--llama.cpp/scripts/snapdragon/windows/run-cli.ps153
-rw-r--r--llama.cpp/scripts/snapdragon/windows/run-tool.ps156
-rw-r--r--llama.cpp/scripts/snapdragon/windows/setup-build.ps1105
13 files changed, 636 insertions, 0 deletions
diff --git a/llama.cpp/scripts/snapdragon/adb/llama-cli.farf b/llama.cpp/scripts/snapdragon/adb/llama-cli.farf
new file mode 100644
index 0000000..de84fe8
--- /dev/null
+++ b/llama.cpp/scripts/snapdragon/adb/llama-cli.farf
@@ -0,0 +1 @@
+0xffff
diff --git a/llama.cpp/scripts/snapdragon/adb/run-bench.sh b/llama.cpp/scripts/snapdragon/adb/run-bench.sh
new file mode 100755
index 0000000..2750860
--- /dev/null
+++ b/llama.cpp/scripts/snapdragon/adb/run-bench.sh
@@ -0,0 +1,52 @@
+#!/bin/sh
+#
+
+# Basedir on device
+basedir=/data/local/tmp/llama.cpp
+
+branch=.
+[ "$B" != "" ] && branch=$B
+
+adbserial=
+[ "$S" != "" ] && adbserial="-s $S"
+
+adbhost=
+[ "$H" != "" ] && adbhost="-H $H"
+
+model="Llama-3.2-3B-Instruct-Q4_0.gguf"
+[ "$M" != "" ] && model="$M"
+
+device="HTP0"
+[ "$D" != "" ] && device="$D"
+
+verbose=
+[ "$V" != "" ] && verbose="GGML_HEXAGON_VERBOSE=$V" cli_opts="$cli_opts -v"
+
+experimental=
+[ "$E" != "" ] && experimental="GGML_HEXAGON_EXPERIMENTAL=$E"
+
+profile=
+[ "$PROF" != "" ] && profile="GGML_HEXAGON_PROFILE=$PROF GGML_HEXAGON_OPSYNC=1" cli_opts="$cli_opts -v"
+
+opmask=
+[ "$OPMASK" != "" ] && opmask="GGML_HEXAGON_OPMASK=$OPMASK"
+
+nhvx=
+[ "$NHVX" != "" ] && nhvx="GGML_HEXAGON_NHVX=$NHVX"
+
+ndev=
+[ "$NDEV" != "" ] && ndev="GGML_HEXAGON_NDEV=$NDEV"
+
+hb=
+[ "$HB" != "" ] && hb="GGML_HEXAGON_HOSTBUF=$HB"
+
+set -x
+
+adb $adbserial $adbhost shell " \
+ cd $basedir; \
+ LD_LIBRARY_PATH=$basedir/$branch/lib \
+ ADSP_LIBRARY_PATH=$basedir/$branch/lib \
+ $ndev $nhvx $opmask $verbose $experimental $profile $hb ./$branch/bin/llama-bench --device $device --mmap 0 -m $basedir/../gguf/$model \
+ --poll 1000 -t 6 --cpu-mask 0xfc --cpu-strict 1 \
+ --batch-size 128 -ngl 99 $cli_opts $@ \
+"
diff --git a/llama.cpp/scripts/snapdragon/adb/run-cli.sh b/llama.cpp/scripts/snapdragon/adb/run-cli.sh
new file mode 100755
index 0000000..d19d4e9
--- /dev/null
+++ b/llama.cpp/scripts/snapdragon/adb/run-cli.sh
@@ -0,0 +1,59 @@
+#!/bin/sh
+#
+
+# Basedir on device
+basedir=/data/local/tmp/llama.cpp
+
+cli_opts=
+
+branch=.
+[ "$B" != "" ] && branch=$B
+
+adbserial=
+[ "$S" != "" ] && adbserial="-s $S"
+
+adbhost=
+[ "$H" != "" ] && adbhost="-H $H"
+
+model="Llama-3.2-3B-Instruct-Q4_0.gguf"
+[ "$M" != "" ] && model="$M"
+
+device="HTP0"
+[ "$D" != "" ] && device="$D"
+
+experimental=
+[ "$E" != "" ] && experimental="GGML_HEXAGON_EXPERIMENTAL=$E"
+
+verbose=
+[ "$V" != "" ] && verbose="GGML_HEXAGON_VERBOSE=$V" cli_opts="$cli_opts -v"
+
+sched=
+[ "$SCHED" != "" ] && sched="GGML_SCHED_DEBUG=2" cli_opts="$cli_opts -v"
+
+profile=
+[ "$PROF" != "" ] && profile="GGML_HEXAGON_PROFILE=$PROF GGML_HEXAGON_OPSYNC=1" cli_opts="$cli_opts -v"
+
+opmask=
+[ "$OPMASK" != "" ] && opmask="GGML_HEXAGON_OPMASK=$OPMASK"
+
+nhvx=
+[ "$NHVX" != "" ] && nhvx="GGML_HEXAGON_NHVX=$NHVX"
+
+ndev=
+[ "$NDEV" != "" ] && ndev="GGML_HEXAGON_NDEV=$NDEV"
+
+hb=
+[ "$HB" != "" ] && hb="GGML_HEXAGON_HOSTBUF=$HB"
+
+set -x
+
+adb $adbserial $adbhost shell " \
+ cd $basedir; ulimit -c unlimited; \
+ LD_LIBRARY_PATH=$basedir/$branch/lib \
+ ADSP_LIBRARY_PATH=$basedir/$branch/lib \
+ $verbose $experimental $sched $opmask $profile $nhvx $ndev $hb \
+ ./$branch/bin/llama-cli --no-mmap -m $basedir/../gguf/$model \
+ --poll 1000 -t 6 --cpu-mask 0xfc --cpu-strict 1 \
+ --ctx-size 8192 --batch-size 128 -fa on \
+ -ngl 99 --device $device $cli_opts $@ \
+"
diff --git a/llama.cpp/scripts/snapdragon/adb/run-completion.sh b/llama.cpp/scripts/snapdragon/adb/run-completion.sh
new file mode 100755
index 0000000..da9df11
--- /dev/null
+++ b/llama.cpp/scripts/snapdragon/adb/run-completion.sh
@@ -0,0 +1,59 @@
+#!/bin/sh
+#
+
+# Basedir on device
+basedir=/data/local/tmp/llama.cpp
+
+cli_opts=
+
+branch=.
+[ "$B" != "" ] && branch=$B
+
+adbserial=
+[ "$S" != "" ] && adbserial="-s $S"
+
+adbhost=
+[ "$H" != "" ] && adbhost="-H $H"
+
+model="Llama-3.2-3B-Instruct-Q4_0.gguf"
+[ "$M" != "" ] && model="$M"
+
+device="HTP0"
+[ "$D" != "" ] && device="$D"
+
+experimental=
+[ "$E" != "" ] && experimental="GGML_HEXAGON_EXPERIMENTAL=$E"
+
+verbose=
+[ "$V" != "" ] && verbose="GGML_HEXAGON_VERBOSE=$V" cli_opts="$cli_opts -v"
+
+sched=
+[ "$SCHED" != "" ] && sched="GGML_SCHED_DEBUG=2" cli_opts="$cli_opts -v"
+
+profile=
+[ "$PROF" != "" ] && profile="GGML_HEXAGON_PROFILE=$PROF GGML_HEXAGON_OPSYNC=1" cli_opts="$cli_opts -v"
+
+opmask=
+[ "$OPMASK" != "" ] && opmask="GGML_HEXAGON_OPMASK=$OPMASK"
+
+nhvx=
+[ "$NHVX" != "" ] && nhvx="GGML_HEXAGON_NHVX=$NHVX"
+
+ndev=
+[ "$NDEV" != "" ] && ndev="GGML_HEXAGON_NDEV=$NDEV"
+
+hb=
+[ "$HB" != "" ] && hb="GGML_HEXAGON_HOSTBUF=$HB"
+
+set -x
+
+adb $adbserial $adbhost shell " \
+ cd $basedir; ulimit -c unlimited; \
+ LD_LIBRARY_PATH=$basedir/$branch/lib \
+ ADSP_LIBRARY_PATH=$basedir/$branch/lib \
+ $verbose $experimental $sched $opmask $profile $nhvx $ndev $hb \
+ ./$branch/bin/llama-completion --no-mmap -m $basedir/../gguf/$model \
+ --poll 1000 -t 6 --cpu-mask 0xfc --cpu-strict 1 \
+ --ctx-size 8192 --batch-size 128 -fa on \
+ -ngl 99 -no-cnv --device $device $cli_opts $@ \
+"
diff --git a/llama.cpp/scripts/snapdragon/adb/run-mtmd.sh b/llama.cpp/scripts/snapdragon/adb/run-mtmd.sh
new file mode 100755
index 0000000..fc018e7
--- /dev/null
+++ b/llama.cpp/scripts/snapdragon/adb/run-mtmd.sh
@@ -0,0 +1,68 @@
+#!/bin/sh
+#
+
+# Basedir on device
+basedir=/data/local/tmp/llama.cpp
+
+cli_opts=
+
+branch=.
+[ "$B" != "" ] && branch=$B
+
+adbserial=
+[ "$S" != "" ] && adbserial="-s $S"
+
+adbhost=
+[ "$H" != "" ] && adbhost="-H $H"
+
+model="gemma-3-4b-it-Q4_0.gguf"
+[ "$M" != "" ] && model="$M"
+
+mmproj="mmproj-F16.gguf"
+[ "$MMPROJ" != "" ] && mmproj="$MMPROJ"
+
+image=
+[ "$IMG" != "" ] && image="$IMG"
+
+device="HTP0"
+[ "$D" != "" ] && device="$D"
+
+verbose=
+[ "$V" != "" ] && verbose="GGML_HEXAGON_VERBOSE=$V"
+
+experimental="GGML_HEXAGON_EXPERIMENTAL=1"
+[ "$E" != "" ] && experimental="GGML_HEXAGON_EXPERIMENTAL=$E"
+
+sched=
+[ "$SCHED" != "" ] && sched="GGML_SCHED_DEBUG=2" cli_opts="$cli_opts -v"
+
+profile=
+[ "$PROF" != "" ] && profile="GGML_HEXAGON_PROFILE=$PROF GGML_HEXAGON_OPSYNC=1"
+
+opmask=
+[ "$OPMASK" != "" ] && opmask="GGML_HEXAGON_OPMASK=$OPMASK"
+
+nhvx=
+[ "$NHVX" != "" ] && nhvx="GGML_HEXAGON_NHVX=$NHVX"
+
+ndev=
+[ "$NDEV" != "" ] && ndev="GGML_HEXAGON_NDEV=$NDEV"
+
+# MTMD backend device for vision model (defaults to CPU if not set)
+mtmd_backend=
+[ "$MTMD_DEVICE" != "" ] && mtmd_backend="MTMD_BACKEND_DEVICE=$MTMD_DEVICE"
+
+set -x
+
+adb $adbserial $adbhost shell " \
+ cd $basedir; ulimit -c unlimited; \
+ LD_LIBRARY_PATH=$basedir/$branch/lib \
+ ADSP_LIBRARY_PATH=$basedir/$branch/lib \
+ $verbose $experimental $sched $opmask $profile $nhvx $ndev $mtmd_backend \
+ ./$branch/bin/llama-mtmd-cli --no-mmap -m $basedir/../gguf/$model \
+ --mmproj $basedir/../gguf/$mmproj \
+ --image $basedir/../gguf/$image \
+ --poll 1000 -t 6 --cpu-mask 0xfc --cpu-strict 1 \
+ --ctx-size 8192 --batch-size 128 -ctk q8_0 -ctv q8_0 -fa on \
+ -ngl 99 --device $device -v $cli_opts $@ \
+"
diff --git a/llama.cpp/scripts/snapdragon/adb/run-tool.sh b/llama.cpp/scripts/snapdragon/adb/run-tool.sh
new file mode 100755
index 0000000..4647ede
--- /dev/null
+++ b/llama.cpp/scripts/snapdragon/adb/run-tool.sh
@@ -0,0 +1,54 @@
+#!/bin/sh
+#
+
+# Basedir on device
+basedir=/data/local/tmp/llama.cpp
+
+cli_opts=
+
+branch=.
+[ "$B" != "" ] && branch=$B
+
+adbserial=
+[ "$S" != "" ] && adbserial="-s $S"
+
+adbhost=
+[ "$H" != "" ] && adbhost="-H $H"
+
+device="HTP0"
+[ "$D" != "" ] && device="$D"
+
+verbose=
+[ "$V" != "" ] && verbose="GGML_HEXAGON_VERBOSE=$V"
+
+experimental=
+[ "$E" != "" ] && experimental="GGML_HEXAGON_EXPERIMENTAL=$E"
+
+sched=
+[ "$SCHED" != "" ] && sched="GGML_SCHED_DEBUG=2" cli_opts="$cli_opts -v"
+
+profile=
+[ "$PROF" != "" ] && profile="GGML_HEXAGON_PROFILE=$PROF GGML_HEXAGON_OPSYNC=1"
+
+opmask=
+[ "$OPMASK" != "" ] && opmask="GGML_HEXAGON_OPMASK=$OPMASK"
+
+nhvx=
+[ "$NHVX" != "" ] && nhvx="GGML_HEXAGON_NHVX=$NHVX"
+
+ndev=
+[ "$NDEV" != "" ] && ndev="GGML_HEXAGON_NDEV=$NDEV"
+
+hb=
+[ "$HB" != "" ] && hb="GGML_HEXAGON_HOSTBUF=$HB"
+
+set -x
+
+tool=$1; shift
+
+adb $adbserial $adbhost shell " \
+ cd $basedir; ulimit -c unlimited; \
+ LD_LIBRARY_PATH=$basedir/$branch/lib \
+ ADSP_LIBRARY_PATH=$basedir/$branch/lib \
+ $verbose $experimental $sched $opmask $profile $nhvx $ndev $hb ./$branch/bin/$tool $@ \
+"
diff --git a/llama.cpp/scripts/snapdragon/qdc/readme.md b/llama.cpp/scripts/snapdragon/qdc/readme.md
new file mode 100644
index 0000000..b92cf24
--- /dev/null
+++ b/llama.cpp/scripts/snapdragon/qdc/readme.md
@@ -0,0 +1 @@
+This directory includes pytest based scripts for running CI jobs on Qualcomm Device Cloud (QDC).
diff --git a/llama.cpp/scripts/snapdragon/qdc/requirements.txt b/llama.cpp/scripts/snapdragon/qdc/requirements.txt
new file mode 100644
index 0000000..f04bd68
--- /dev/null
+++ b/llama.cpp/scripts/snapdragon/qdc/requirements.txt
@@ -0,0 +1,25 @@
+Appium-Python-Client==5.2.4
+attrs==25.4.0
+certifi==2025.10.5
+exceptiongroup==1.3.0
+h11==0.16.0
+idna==3.11
+iniconfig==2.1.0
+outcome==1.3.0.post0
+packaging==25.0
+pluggy==1.6.0
+Pygments==2.19.2
+PySocks==1.7.1
+pytest==8.4.2
+pytest-dependency==0.6.0
+selenium==4.36.0
+setuptools==80.9.0
+sniffio==1.3.1
+sortedcontainers==2.4.0
+tomli==2.3.0
+trio==0.31.0
+trio-websocket==0.12.2
+typing_extensions==4.15.0
+urllib3==2.5.0
+websocket-client==1.9.0
+wsproto==1.2.0
diff --git a/llama.cpp/scripts/snapdragon/qdc/tests/test_bench.py b/llama.cpp/scripts/snapdragon/qdc/tests/test_bench.py
new file mode 100644
index 0000000..651ab5b
--- /dev/null
+++ b/llama.cpp/scripts/snapdragon/qdc/tests/test_bench.py
@@ -0,0 +1,63 @@
+import pytest
+import subprocess
+import sys
+
+tmp_path='/data/local/tmp'
+pkg_path=f'{tmp_path}/llama.cpp'
+lib_path=f'{pkg_path}/lib'
+bin_path=f'{pkg_path}/bin'
+
+model='../gguf/Llama-3.2-1B-Instruct-Q4_0.gguf'
+cli_pref=f'cd {pkg_path} && LD_LIBRARY_PATH={lib_path} ADSP_LIBRARY_PATH={lib_path} {bin_path}'
+
+
+def run_cmd(cmd):
+ p = subprocess.run(cmd, text = True, stdout = subprocess.PIPE, stderr = subprocess.STDOUT)
+ sys.stdout.write(p.stdout)
+ assert(p.returncode == 0)
+
+
+@pytest.mark.dependency()
+def test_install():
+ run_cmd(['adb', 'push', 'llama.cpp', f'{tmp_path}'])
+ run_cmd(['adb', 'shell', f'chmod 755 {bin_path}/*'])
+
+
+## Basic cli tests
+def run_llama_cli(dev, opts):
+ prompt='what is the most popular cookie in the world?\nPlease provide a very brief bullet point summary.\nBegin your answer with **BEGIN**.'
+ opts = '--batch-size 128 -n 128 -no-cnv --seed 42 ' + opts
+ run_cmd(['adb', 'shell', f'{cli_pref}/llama-cli -m {model} --device {dev} -ngl 99 -t 4 {opts} -p "{prompt}"'])
+
+
+@pytest.mark.dependency(depends=['test_install'])
+def test_llama_cli_cpu():
+ run_llama_cli('none', '-ctk q8_0 -ctv q8_0 -fa on')
+
+
+@pytest.mark.dependency(depends=['test_install'])
+def test_llama_cli_gpu():
+ run_llama_cli('GPUOpenCL', '-fa on')
+
+
+@pytest.mark.dependency(depends=['test_install'])
+def test_llama_cli_npu():
+ run_llama_cli('HTP0', '-ctk q8_0 -ctv q8_0 -fa on')
+
+
+## Basic bench tests
+def run_llama_bench(dev):
+ run_cmd(['adb', 'shell', f'{cli_pref}/llama-bench -m {model} --device {dev} -ngl 99 --batch-size 128 -t 4 -p 128 -n 32'])
+
+
+@pytest.mark.dependency(depends=['test_install'])
+def test_llama_bench_cpu():
+ run_llama_bench('none')
+
+
+def test_llama_bench_gpu():
+ run_llama_bench('GPUOpenCL')
+
+
+def test_llama_bench_npu():
+ run_llama_bench('HTP0')
diff --git a/llama.cpp/scripts/snapdragon/windows/run-bench.ps1 b/llama.cpp/scripts/snapdragon/windows/run-bench.ps1
new file mode 100644
index 0000000..21fd063
--- /dev/null
+++ b/llama.cpp/scripts/snapdragon/windows/run-bench.ps1
@@ -0,0 +1,40 @@
+
+#!/usr/bin/env pwsh
+
+# Basedir on device
+$basedir=".\pkg-snapdragon"
+
+$cli_opts=$args
+
+$model="Llama-3.2-3B-Instruct-Q4_0.gguf"
+if ($null -ne $env:M) {
+ $model=$env:M
+}
+
+$device="HTP0"
+if ($null -ne $env:D) {
+ $device=$env:D
+}
+
+if ($null -ne $env:V) {
+ $env:GGML_HEXAGON_VERBOSE=$env:V
+}
+
+if ($null -ne $env:OPMASK) {
+ $env:GGML_HEXAGON_OPMASK=$env:OPMASK
+}
+
+if ($null -ne $env:NHVX) {
+ $env:GGML_HEXAGON_NHVX=$env:NHVX
+}
+
+if ($null -ne $env:NDEV) {
+ $env:GGML_HEXAGON_NDEV=$env:NDEV
+}
+
+$env:ADSP_LIBRARY_PATH="$basedir\lib"
+
+& "$basedir\bin\llama-bench.exe" `
+ --mmap 0 -m $basedir\..\..\gguf\$model `
+ --poll 1000 -t 6 --cpu-mask 0xfc --cpu-strict 1 `
+ --batch-size 128 -ngl 99 --device $device $cli_opts
diff --git a/llama.cpp/scripts/snapdragon/windows/run-cli.ps1 b/llama.cpp/scripts/snapdragon/windows/run-cli.ps1
new file mode 100644
index 0000000..b13161a
--- /dev/null
+++ b/llama.cpp/scripts/snapdragon/windows/run-cli.ps1
@@ -0,0 +1,53 @@
+
+#!/usr/bin/env pwsh
+
+# Basedir on device
+$basedir=".\pkg-snapdragon"
+
+$cli_opts=$args
+
+$model="Llama-3.2-3B-Instruct-Q4_0.gguf"
+if ($null -ne $env:M) {
+ $model=$env:M
+}
+
+$device="HTP0"
+if ($null -ne $env:D) {
+ $device=$env:D
+}
+
+if ($null -ne $env:V) {
+ $env:GGML_HEXAGON_VERBOSE=$env:V
+}
+
+if ($null -ne $env:E) {
+ $env:GGML_HEXAGON_EXPERIMENTAL=$env:E
+}
+
+if ($null -ne $env:SCHED) {
+ $env:GGML_SCHED_DEBUG=$env:SCHED; $cli_opts="$cli_opts -v"
+}
+
+if ($null -ne $env:PROF) {
+ $env:GGML_HEXAGON_PROFILE=$env:PROF; $env:GGML_HEXAGON_OPSYNC=1
+}
+
+if ($null -ne $env:OPMASK) {
+ $env:GGML_HEXAGON_OPMASK=$env:OPMASK
+}
+
+if ($null -ne $env:NHVX) {
+ $env:GGML_HEXAGON_NHVX=$env:NHVX
+}
+
+if ($null -ne $env:NDEV) {
+ $env:GGML_HEXAGON_NDEV=$env:NDEV
+}
+
+$env:ADSP_LIBRARY_PATH="$basedir\lib"
+
+& "$basedir\bin\llama-completion.exe" `
+ --no-mmap -no-cnv -m $basedir\..\..\gguf\$model `
+ --poll 1000 -t 6 --cpu-mask 0xfc --cpu-strict 1 `
+ --ctx-size 8192 --batch-size 128 -ctk q8_0 -ctv q8_0 -fa on `
+ -ngl 99 --device $device $cli_opts
diff --git a/llama.cpp/scripts/snapdragon/windows/run-tool.ps1 b/llama.cpp/scripts/snapdragon/windows/run-tool.ps1
new file mode 100644
index 0000000..70094af
--- /dev/null
+++ b/llama.cpp/scripts/snapdragon/windows/run-tool.ps1
@@ -0,0 +1,56 @@
+
+#!/usr/bin/env pwsh
+
+# Basedir on device
+$basedir=".\pkg-snapdragon"
+
+if ($args.Count -eq 0) {
+ Write-Host "No arguments provided.Expected the tool and argument to run."
+ exit -1
+}
+
+$tool=$args[0]
+$cli_opts=@()
+
+if ($args.Count -gt 1) {
+ $cli_opts=$args[1..($args.Count - 1)]
+ $remainingArgs = $args[1..($args.Count - 1)]
+}
+
+$device="HTP0"
+if ($null -ne $env:D) {
+ $device=$env:D
+}
+
+if ($null -ne $env:V) {
+ $env:GGML_HEXAGON_VERBOSE=$env:V
+}
+
+if ($null -ne $env:E) {
+ $env:GGML_HEXAGON_EXPERIMENTAL=$env:E
+}
+
+if ($null -ne $env:SCHED) {
+ $env:GGML_SCHED_DEBUG=$env:SCHED; $cli_opts="$cli_opts -v"
+}
+
+if ($null -ne $env:PROF) {
+ $env:GGML_HEXAGON_PROFILE=$env:PROF; $env:GGML_HEXAGON_OPSYNC=1
+}
+
+if ($null -ne $env:OPMASK) {
+ $env:GGML_HEXAGON_OPMASK=$env:OPMASK
+}
+
+if ($null -ne $env:NHVX) {
+ $env:GGML_HEXAGON_NHVX=$env:NHVX
+}
+
+if ($null -ne $env:NDEV) {
+ $env:GGML_HEXAGON_NDEV=$env:NDEV
+}
+
+$env:ADSP_LIBRARY_PATH="$basedir\lib"
+
+& "$basedir\bin\$tool" `
+ $cli_opts
diff --git a/llama.cpp/scripts/snapdragon/windows/setup-build.ps1 b/llama.cpp/scripts/snapdragon/windows/setup-build.ps1
new file mode 100644
index 0000000..0f3244c
--- /dev/null
+++ b/llama.cpp/scripts/snapdragon/windows/setup-build.ps1
@@ -0,0 +1,105 @@
+# Requires Run as Administrator is NOT strictly necessary for User-scope env vars,
+# but recommended for creating directories in C:\ root if permissions are restricted.
+
+$ErrorActionPreference = "Stop"
+
+# --- Configuration ---
+$BaseDir = "C:\Qualcomm"
+
+# SDK 1: Hexagon
+$HexagonUrl = "https://github.com/snapdragon-toolchain/hexagon-sdk/releases/download/v6.4.0.2/hexagon-sdk-v6.4.0.2-arm64-wos.tar.xz"
+$HexagonParent = Join-Path $BaseDir "Hexagon_SDK"
+$HexagonSdkVersion = "6.4.0.2"
+$HexagonToolsVersion = "19.0.04"
+$HexagonSdkTarget = Join-Path $HexagonParent $HexagonSdkVersion
+$HexagonToolsTarget = Join-Path $HexagonSdkTarget "\tools\HEXAGON_Tools\$HexagonToolsVersion"
+
+# SDK 2: OpenCL
+$OpenCLUrl = "https://github.com/snapdragon-toolchain/opencl-sdk/releases/download/v2.3.2/adreno-opencl-sdk-v2.3.2-arm64-wos.tar.xz"
+$OpenCLParent = Join-Path $BaseDir "OpenCL_SDK"
+$OpenCLVersion = "2.3.2"
+$OpenCLTarget = Join-Path $OpenCLParent $OpenCLVersion
+
+# --- Helper Function ---
+function Install-QualcommSDK {
+ param (
+ [string]$Url,
+ [string]$ParentDir,
+ [string]$TargetDir,
+ [string]$Name
+ )
+
+ # 1. Create Parent Directory
+ if (-not (Test-Path -Path $ParentDir)) {
+ Write-Host "Creating directory: $ParentDir" -ForegroundColor Cyan
+ New-Item -Path $ParentDir -ItemType Directory -Force | Out-Null
+ }
+
+ # 2. Check for Specific Version Directory
+ if (Test-Path -Path $TargetDir) {
+ Write-Host "$Name ($TargetDir) already exists. Skipping download." -ForegroundColor Green
+ }
+ else {
+ Write-Host "$Name not found. preparing to download..." -ForegroundColor Yellow
+
+ # Create the target directory to extract into
+ New-Item -Path $TargetDir -ItemType Directory -Force | Out-Null
+
+ # Define temporary archive path
+ $TempFile = Join-Path $ParentDir "temp_sdk.tar.xz"
+
+ try {
+ # Download
+ Write-Host "Downloading from: $Url"
+ Invoke-WebRequest -Uri $Url -OutFile $TempFile
+
+ # Untar
+ # Note: We assume Windows includes tar.exe (Win 10 build 17063+)
+ Write-Host "Extracting archive to $TargetDir..."
+
+ # We use -C to extract contents INTO the target directory created above
+ tar -xJvf $TempFile -C $TargetDir\..
+
+ Write-Host "Extraction complete." -ForegroundColor Green
+ }
+ catch {
+ Write-Error "Failed to download or extract $Name. Error: $_"
+ # Cleanup target dir if failed so script tries again next time
+ Remove-Item -Path $TargetDir -Recurse -Force -ErrorAction SilentlyContinue
+ }
+ finally {
+ # Cleanup Archive
+ if (Test-Path $TempFile) { Remove-Item $TempFile -Force }
+ }
+ }
+}
+
+# --- Execution ---
+
+# 1. Ensure Base C:\Qualcomm exists
+if (-not (Test-Path $BaseDir)) {
+ New-Item -Path $BaseDir -ItemType Directory -Force | Out-Null
+}
+
+# 2. Run Install Logic
+Install-QualcommSDK -Url $HexagonUrl -ParentDir $HexagonParent -TargetDir $HexagonSdkTarget -Name "Hexagon SDK"
+Install-QualcommSDK -Url $OpenCLUrl -ParentDir $OpenCLParent -TargetDir $OpenCLTarget -Name "OpenCL SDK"
+
+# --- Environment Variables ---
+
+Write-Host "`nSetting Environment Variables..." -ForegroundColor Cyan
+
+# Set OPENCL_SDK_ROOT
+[System.Environment]::SetEnvironmentVariable('OPENCL_SDK_ROOT', $OpenCLTarget, [System.EnvironmentVariableTarget]::User)
+$env:OPENCL_SDK_ROOT = $OpenCLTarget # Set for current session as well
+Write-Host "OPENCL_SDK_ROOT set to: $OpenCLTarget"
+
+# Set HEXAGON_SDK_ROOT
+[System.Environment]::SetEnvironmentVariable('HEXAGON_SDK_ROOT', $HexagonSdkTarget, [System.EnvironmentVariableTarget]::User)
+$env:HEXAGON_SDK_ROOT = $HexagonSdkTarget # Set for current session as well
+Write-Host "HEXAGON_SDK_ROOT set to: $HexagonSdkTarget"
+
+# Set HEXAGON_SDK_ROOT
+[System.Environment]::SetEnvironmentVariable('HEXAGON_TOOLS_ROOT', $HexagonToolsTarget, [System.EnvironmentVariableTarget]::User)
+$env:HEXAGON_TOOLS_ROOT = $HexagonToolsTarget # Set for current session as well
+Write-Host "HEXAGON_TOOLS_ROOT set to: $HexagonToolsTarget"