Пример #1
0
def test_metadata_run_traces(profile, format):
    data = profile("""
    __global__ void kernel(int* p) {
        *p = threadIdx.x;
    }
    __global__ void kernel2(int* p) {
        *p = threadIdx.x;
    }
    int main()
    {
        int* dptr;
        cudaMalloc(&dptr, sizeof(int));
        kernel<<<1, 1>>>(dptr);
        kernel<<<1, 1>>>(dptr);
        kernel2<<<1, 1>>>(dptr);
        cudaFree(dptr);
        return 0;
    }
    """,
                   format=format)
    run = data[run_file()]

    traces = run["traces"]
    assert "kernel-0.trace." + format in traces
    assert "kernel-1.trace." + format in traces
    assert "kernel2-0.trace." + format in traces
Пример #2
0
def test_general_no_include(profile, format):
    data = profile("""
    __global__ void kernel(int* p) {
        *p = 5;
    }
    int main() {
        int* dptr;
        cudaMalloc(&dptr, sizeof(int));
        kernel<<<1, 1>>>(dptr);
        cudaFree(dptr);
        return 0;
    }
    """,
                   format=format,
                   add_include=False)
    assert run_file() in data
    assert len(data) == 1
Пример #3
0
def test_general_emit_nothing(profile, format):
    data = profile("", with_main=True)
    assert run_file() in data
    assert len(data) == 1
Пример #4
0
def test_parameters_compression_run(profile, format):
    uncompressed = profile("", with_main=True, format=format)
    compressed = profile("", with_main=True, format=format, compress=True)

    assert not uncompressed[run_file()]["compress"]
    assert compressed[run_file()]["compress"]
Пример #5
0
def test_metadata_run_time(profile):
    data = profile("__global__ void kernel() {}", with_main=True)
    run = data[run_file()]

    assert run["type"] == "run"
    assert run["end"] >= run["start"]