Skip to content
Closed
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
5 changes: 4 additions & 1 deletion .github/workflows/cuda_component_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@ jobs:
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: cuda component tests
run: .github/workflows_scripts/ci_individual_component.sh ${{matrix.component}} ${{matrix.debug}} ${{matrix.shlib}}
run: |
set -e
.github/workflows_scripts/ci_individual_component.sh ${{matrix.component}} ${{matrix.debug}} ${{matrix.shlib}}
echo "exit code was $?"
6 changes: 4 additions & 2 deletions .github/workflows/papi_framework_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ on:
pull_request:
# run CI if framework receives an update excluding individual
# components and counter analysis toolkit
paths-ignore:
- 'src/components/*/**'
#paths-ignore:
# - 'src/components/*/**'
# - 'src/counter_analysis_toolkit/**'
paths:
- 'src/counter_analysis_toolkit/**'
# allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand Down
25 changes: 17 additions & 8 deletions src/components/cuda/tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ include ../../Makefile_comp_tests.target

PAPI_CUDA_ROOT ?= $(shell dirname $(shell dirname $(shell which nvcc)))

TESTS = HelloWorld simpleMultiGPU \
pthreads cudaOpenMP concurrent_profiling \
test_multi_read_and_reset test_multipass_event_fail \
test_2thr_1gpu_not_allowed
TESTS = test_cuda_edelay_init

TESTS_NOCTX = concurrent_profiling_noCuCtx pthreads_noCuCtx \
cudaOpenMP_noCuCtx HelloWorld_noCuCtx \
simpleMultiGPU_noCuCtx
#TESTS = HelloWorld simpleMultiGPU \
# pthreads cudaOpenMP concurrent_profiling \
# test_multi_read_and_reset test_multipass_event_fail \
# test_2thr_1gpu_not_allowed

#TESTS_NOCTX = concurrent_profiling_noCuCtx pthreads_noCuCtx \
# cudaOpenMP_noCuCtx HelloWorld_noCuCtx \
# simpleMultiGPU_noCuCtx

NVCC = $(PAPI_CUDA_ROOT)/bin/nvcc
NVCC_VERSION := $(shell $(NVCC) --version | grep -oP '(?<=release )\d+\.\d+')
Expand Down Expand Up @@ -40,7 +42,11 @@ CFLAGS += -g $(PAPI_FLAG)
INCLUDE += -I$(PAPI_CUDA_ROOT)/include
CUDALIBS = -L$(PAPI_CUDA_ROOT)/lib64 -lcudart -lcuda

cuda_tests: $(TESTS) $(TESTS_NOCTX)
#cuda_tests: $(TESTS) $(TESTS_NOCTX)
cuda_tests: $(TESTS)

%.o:%.c
$(CC) $(CFLAGS) $(OPTFLAGS) $(INCLUDE) -c -o $@ $<

%.o:%.cu
$(NVCC) $(INCLUDE) $(NVCFLAGS) $(CUDA_CPPFLAGS) -c -o $@ $<
Expand Down Expand Up @@ -87,5 +93,8 @@ simpleMultiGPU: simpleMultiGPU.o $(UTILOBJS)
simpleMultiGPU_noCuCtx: simpleMultiGPU_noCuCtx.o $(UTILOBJS)
$(CXX) $(CFLAGS) -o simpleMultiGPU_noCuCtx simpleMultiGPU_noCuCtx.o $(UTILOBJS) $(PAPILIB) $(CUDALIBS) $(LDFLAGS)

test_cuda_edelay_init: test_cuda_edelay_init.o $(UTILOBJS)
$(CC) $(CFLAGS) $(INCLUDE) -o test_cuda_edelay_init test_cuda_edelay_init.o $(UTILOBJS) $(PAPILIB) $(LDFLAGS)

clean:
rm -f *.o $(TESTS) $(TESTS_NOCTX)
115 changes: 115 additions & 0 deletions src/components/cuda/tests/test_cuda_edelay_init.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/**
* @file test_cuda_edelay_init.c
* @brief Verify that the PAPI_EDELAY_INIT functionality is working properly with the
* cuda component. The test does this by:
*
* 1. Verifying that before accessing cuda native events the disabled member
* variable of PAPI_component_info_t is set to -26 (PAPI_EDELAY_INIT) and
* num_native_events is equal to -1.
* 2. Verfiying that after accessing cuda native events the disabled member
* variable of PAPI_comopnent_info_t is set to 0 (PAPI_OK) and num_native_events
* is > 0.
*
*/

#include <stdio.h>
#include <stdlib.h>

#include "papi.h"
#include "papi_test.h"

int test_cuda_is_edelay_init()
{
int retval = PAPI_library_init(PAPI_VER_CURRENT);
if (retval != PAPI_VER_CURRENT) {
fprintf(stderr, "PAPI_library_init failed: %d\n", retval);
return retval;
}

const char *component_name = "cuda";
int cidx = PAPI_get_component_index(component_name);
if (cidx < 0) {
fprintf(stderr, "PAPI_get_component_index failed: %d\n", retval);
return retval;
}

const PAPI_component_info_t *cmpinfo = PAPI_get_component_info(cidx);
if (cmpinfo == NULL) {
fprintf(stderr, "PAPI_get_component_info failed.\n");
return PAPI_ENOMEM;
}

if (cmpinfo->disabled != PAPI_EDELAY_INIT) {
fprintf(stderr, "The cuda component should be PAPI_EDELAY_INIT.\n");
return PAPI_ECOMBO;
}

if (cmpinfo->num_native_events == -1) {
fprintf(stderr, "The cuda component should have the value of -1 set for num_native_events.\n");
return PAPI_ECOMBO;
}

PAPI_shutdown();


return PAPI_OK;
}

int test_cuda_is_not_edelay_init_via_enum_cmp_event()
{
int retval = PAPI_library_init(PAPI_VER_CURRENT);
if (retval != PAPI_VER_CURRENT) {
fprintf(stderr, "PAPI_library_init failed: %d\n", retval);
return retval;
}

const char *component_name = "cuda";
int cidx = PAPI_get_component_index(component_name);
if (cidx < 0) {
fprintf(stderr, "PAPI_get_component_index failed: %d\n", retval);
return retval;
}

const PAPI_component_info_t *cmpinfo = PAPI_get_component_info(cidx);
if (cmpinfo == NULL) {
fprintf(stderr, "PAPI_get_component_info failed.\n");
return PAPI_ENOMEM;
}

int eventcode = 0 | PAPI_NATIVE_MASK;
int modifier = PAPI_ENUM_FIRST;
retval = PAPI_enum_cmp_event(&eventcode, modifier, cidx);
if (retval != PAPI_OK) {
fprintf(stderr, "PAPI_enum_cmp_event failed: %d\n", retval);
return retval;
}

if (cmpinfo->disabled != PAPI_OK) {
fprintf(stderr, "The cuda component failed to be initialized.\n");
return PAPI_ECOMBO;
}

if (cmpinfo->num_native_events < 0) {
fprintf(stderr, "The cuda component should have a value greater than -1 set for num_native_events.\n");
return PAPI_ECOMBO;
}

PAPI_shutdown();

return PAPI_OK;
}

int main()
{
int retval = test_cuda_is_edelay_init();
if (retval != PAPI_OK) {
return retval;
}

retval = test_cuda_is_not_edelay_init_via_enum_cmp_event();
if (retval != PAPI_OK) {
return retval;
}

return PAPI_OK;
}
2 changes: 2 additions & 0 deletions src/run_tests_shlib.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/sh

set -e

# File: run_tests_shlib.sh
# Author: Treece Burgess tburgess@icl.utk.edu
# This script is designed specifically for the PAPI GitHub CI when
Expand Down
Loading