-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #275 from KernelTuner/tegra_observer
Tegra observer with continuous observer
- Loading branch information
Showing
5 changed files
with
447 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/env python | ||
"""This is the minimal example from the README""" | ||
|
||
import json | ||
|
||
import numpy | ||
from kernel_tuner import tune_kernel | ||
from kernel_tuner.observers.tegra import TegraObserver | ||
|
||
def tune(): | ||
|
||
kernel_string = """ | ||
__global__ void vector_add(float *c, float *a, float *b, int n) { | ||
int i = blockIdx.x * block_size_x + threadIdx.x; | ||
if (i<n) { | ||
c[i] = a[i] + b[i]; | ||
} | ||
} | ||
""" | ||
|
||
size = 800000 | ||
|
||
a = numpy.random.randn(size).astype(numpy.float32) | ||
b = numpy.random.randn(size).astype(numpy.float32) | ||
c = numpy.zeros_like(b) | ||
n = numpy.int32(size) | ||
|
||
args = [c, a, b, n] | ||
|
||
tune_params = dict() | ||
tune_params["block_size_x"] = [128+64*i for i in range(15)] | ||
|
||
tegraobserver = TegraObserver(["core_freq"]) | ||
|
||
metrics = dict() | ||
metrics["f"] = lambda p: p["core_freq"] | ||
|
||
results, env = tune_kernel("vector_add", kernel_string, size, args, tune_params, observers=[tegraobserver], metrics=metrics) | ||
|
||
print(results) | ||
|
||
return results | ||
|
||
|
||
if __name__ == "__main__": | ||
tune() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.