Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Host code for testing dram latency #632

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/cuda/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ INDEPENDENT_TESTS += test_stack_load
INDEPENDENT_TESTS += test_memory_leak
INDEPENDENT_TESTS += test_dram_load_store
INDEPENDENT_TESTS += test_dram_host_allocated
INDEPENDENT_TESTS += test_dram_latency
INDEPENDENT_TESTS += test_dram_device_allocated
INDEPENDENT_TESTS += test_device_memset
INDEPENDENT_TESTS += test_device_memcpy
Expand Down
123 changes: 123 additions & 0 deletions examples/cuda/test_dram_latency.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
// Copyright (c) 2019, University of Washington All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// Redistributions of source code must retain the above copyright notice, this list
// of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above copyright notice, this
// list of conditions and the following disclaimer in the documentation and/or
// other materials provided with the distribution.
//
// Neither the name of the copyright holder nor the names of its contributors may
// be used to endorse or promote products derived from this software without
// specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

/******************************************************************************/
/* Dram latency test. */
/* Tests the DRAM latency by loading from DRAM after flushing the vcache. */
/* This tests uses the software/spmd/bsg_cuda_lite_runtime/dram_latency/ */
/* manycore binary in the BSG Manycore repository. */
/******************************************************************************/


#include "test_dram_load_store.h"

#define ALLOC_NAME "default_allocator"


int kernel_dram_load_store(int argc, char **argv) {
int rc;
char *bin_path, *test_name;
struct arguments_path args = {NULL, NULL};

argp_parse (&argp_path, argc, argv, 0, 0, &args);
bin_path = args.path;
test_name = args.name;

bsg_pr_test_info("Running the CUDA DRAM Load Store test.\n\n");

srand(time);


/**********************************************************************/
/* Define path to binary. */
/* Initialize device, load binary and unfreeze tiles. */
/**********************************************************************/
hb_mc_device_t device;
rc = hb_mc_device_init(&device, test_name, 0);
if (rc != HB_MC_SUCCESS) {
bsg_pr_err("failed to initialize device.\n");
return rc;
}

rc = hb_mc_device_program_init(&device, bin_path, ALLOC_NAME, 0);
if (rc != HB_MC_SUCCESS) {
bsg_pr_err("failed to initialize program.\n");
return rc;
}

hb_mc_dimension_t tg_dim = device.mesh->dim;
hb_mc_dimension_t grid_dim = { .x = 1, .y = 1};

int cuda_argv[] = {0};

/*********************************************************************
* Enquque grid of tile groups, pass in grid and tile group dimensions,
* kernel name, number and list of input arguments
***********************************************************************/
rc = hb_mc_kernel_enqueue (&device, grid_dim, tg_dim, "kernel_dram_latency",
1, cuda_argv);
if (rc != HB_MC_SUCCESS) {
bsg_pr_err("failed to initialize grid.\n");
return rc;
}


/*************************************************************************
* Launch and execute all tile groups on device and wait for all to finish.
**************************************************************************/
rc = hb_mc_device_tile_groups_execute(&device);
if (rc != HB_MC_SUCCESS) {
bsg_pr_err("failed to execute tile groups.\n");
return rc;
}


/**********************************************************************/
/* Freeze the tiles and memory manager cleanup. */
/**********************************************************************/
rc = hb_mc_device_finish(&device);
if (rc != HB_MC_SUCCESS) {
bsg_pr_err("failed to de-initialize device.\n");
return rc;
}


return HB_MC_SUCCESS;
}

#ifdef VCS
int vcs_main(int argc, char ** argv) {
#else
int main(int argc, char ** argv) {
#endif
bsg_pr_test_info("test_dram_load_store Regression Test \n");
int rc = kernel_dram_load_store(argc, argv);
bsg_pr_test_pass_fail(rc == HB_MC_SUCCESS);
return rc;
}


42 changes: 42 additions & 0 deletions examples/cuda/test_dram_latency.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright (c) 2019, University of Washington All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// Redistributions of source code must retain the above copyright notice, this list
// of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above copyright notice, this
// list of conditions and the following disclaimer in the documentation and/or
// other materials provided with the distribution.
//
// Neither the name of the copyright holder nor the names of its contributors may
// be used to endorse or promote products derived from this software without
// specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#ifndef TEST_DRAM_LOAD_STORE_H
#define TEST_DRAM_LOAD_STORE_H


#include <stdio.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>

#include "cuda_tests.h"


#endif