Skip to content

Commit

Permalink
modify cmake and add macro
Browse files Browse the repository at this point in the history
  • Loading branch information
wenhu1024 committed Dec 5, 2024
1 parent 41c9a13 commit 908be33
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
15 changes: 9 additions & 6 deletions gpgpu-testcase/driver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@ cmake_minimum_required(VERSION 3.21)
set(PROJECT spike_driver)
project(${PROJECT})

set(CMAKE_CXX_STANDARD 17)
# Define KERNEL_ADDRESS if not already defined, with a default value of 0x80000098
if(NOT DEFINED KERNEL_ADDRESS)
set(KERNEL_ADDRESS "0x800000b8")
endif()

# Add the KERNEL_ADDRESS definition as a compile-time macro
add_compile_definitions(KERNEL_ADDRESS=${KERNEL_ADDRESS})

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS -lstdc++)

include_directories(${CMAKE_SOURCE_DIR}/include)
Expand All @@ -14,8 +21,6 @@ include_directories($ENV{SPIKE_SRC_DIR}/build)
include_directories($ENV{SPIKE_SRC_DIR}/softfloat)
include_directories($ENV{SPIKE_SRC_DIR}/fesvr)

#set(CMAKE_POSITION_INDEPENDENT_CODE True)

file(GLOB_RECURSE SRCS ./ventus.cpp)

link_directories($ENV{SPIKE_TARGET_DIR}/lib)
Expand All @@ -24,11 +29,9 @@ add_library(${PROJECT} SHARED ${SRCS})

target_link_libraries(${PROJECT} PUBLIC spike_main)


set_target_properties(${PROJECT} PROPERTIES OUTPUT_NAME "${PROJECT}")
set_target_properties(${PROJECT} PROPERTIES CLEAN_DIRECT_OUTPUT 1)


add_executable(spike_test ./test.cpp)
add_dependencies(spike_test ${PROJECT})
target_link_libraries(spike_test PUBLIC ${PROJECT})
target_link_libraries(spike_test PUBLIC ${PROJECT})
6 changes: 5 additions & 1 deletion gpgpu-testcase/driver/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
#include <iostream>
using namespace std;

#ifndef KERNEL_ADDRESS
#define KERNEL_ADDRESS 0x800000b8 // need modify
#endif

struct meta_data{ // 这个metadata是供驱动使用的,而不是给硬件的
uint64_t kernel_id;
uint64_t kernel_size[3];///> 每个kernel的workgroup三维数目
Expand Down Expand Up @@ -63,7 +67,7 @@ int main(){
meta.pdsBaseAddr=pdsbase;
uint32_t data_2[14];//metadata
for(int i=0;i<14;i++) data_2[i]=1;
data_2[0]=0x800000b8;
data_2[0]=KERNEL_ADDRESS;
data_2[1]=(uint32_t)vaddr_4;
data_2[2]=meta.kernel_size[0];
data_2[6]=num_thread;
Expand Down

0 comments on commit 908be33

Please sign in to comment.