skia2/tools/SkVMTool.cpp
Mike Klein b5f95cd1f8 tool support for SkVM JIT on aarch64
- Add quick-building skvmtool
    - Remove SkString dependency
    - Add aarch64 support for perf dumps

Here's what I see on now for the tiny skvmtool program:

x86-64 (Xeon Gold 6154)
           │      skvm-jit-1707131987():
     24.93 │   0:   vmovups (%rsi),%ymm0
     50.13 │        vpmulld %ymm0,%ymm0,%ymm0
     24.93 │        vmovups %ymm0,(%rsi)
           │        add    $0x20,%rsi
           │        sub    $0x8,%rdi
           │      ↑ jne    0
           │        vzeroupper
           │      ← retq

aarch64 (Cortex A53)
           │      skvm-jit-485593645():
     11.55 │   0:   ldr    q0, [x1]
     47.65 │        mul    v0.4s, v0.4s, v0.4s
     31.77 │        str    q0, [x1]
           │        add    x1, x1, #0x10
      8.66 │        subs   x0, x0, #0x4
           │      ↑ b.ne   0
      0.36 │      ← ret

Change-Id: Ia83ebdc6d96c8bd367bce0e8f2792b5e5c79f750
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/225186
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
2019-07-02 20:11:19 +00:00

71 lines
1.5 KiB
C++

/*
* Copyright 2019 Google LLC
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "src/core/SkCpu.h"
#include "src/core/SkVM.h"
#include <stdio.h>
#include <stdlib.h>
void sk_abort_no_print() {
abort();
}
void SkDebugf(const char* fmt, ...) {
va_list args;
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
}
// TODO: remove SkVM dependency on SkWStream
bool SkWStream::writeDecAsText (int x) { SkDebugf("%d", x); return true; }
bool SkWStream::writeHexAsText (unsigned x, int) { SkDebugf("%x", x); return true; }
bool SkWStream::writeScalarAsText(float x) { SkDebugf("%g", x); return true; }
using namespace skvm;
static Program build() {
Builder b;
Arg ptr = b.arg(0);
I32 v = b.load32(ptr);
b.store32(ptr, b.mul(v,v));
return b.done();
}
int main(int argc, char** argv) {
#if defined(__x86_64__)
SkCpu::CacheRuntimeFeatures();
#endif
int loops = argc > 1 ? atoi(argv[1])
: 1;
if (loops < 0) {
// Benchmark program build and JIT.
loops = -loops;
while (loops --> 0) {
Program program = build();
int x = 4;
program.eval(0, &x);
}
} else {
// Benchmark JIT code.
Program program = build();
int buf[4096];
for (int i = 0; i < 4096; i++) {
buf[i] = 1;
}
while (loops --> 0) {
program.eval(4096, buf);
}
}
return 0;
}