Add sample application to use the new memory pool API.

Details:
- add HsaGetInfo program that prints out all available CPU, GPU and their respective memory pools.

[git-p4: depot-paths = "//depot/stg/hsa/drivers/hsa/runtime/": change = 1237219]
This commit is contained in:
Besar Wicaksono (xN/A) TX [TEXT]
2016-02-15 18:11:44 -05:00
bovenliggende 2280190f70
commit c494af9d49
7 gewijzigde bestanden met toevoegingen van 564 en 0 verwijderingen
+7
Bestand weergeven
@@ -0,0 +1,7 @@
OPENCL_DEPTH = ../../..
include $(OPENCL_DEPTH)/runtimenew/runtimedefs
SUBDIRS = build
include $(OPENCL_DEPTH)/runtimenew/runtimerules
+8
Bestand weergeven
@@ -0,0 +1,8 @@
OPENCL_DEPTH = ../../../..
include $(OPENCL_DEPTH)/hsadefs
BUILD_SUBDIRS = $(DEFAULT_TARGETS)
BUILD_MAKEFILE = Makefile.get_info
include $(OPENCL_DEPTH)/hsarules
@@ -0,0 +1,107 @@
include $(OPENCL_DEPTH)/hsadefs
# Executable containing all the API core tests
EXE_TARGET = HsaGetInfo
#
# Makefile construct to copy executable to Dist folder
#
DIST_BIN_TARGET = $(EXE_TARGET)
ifdef ATI_OS_WINDOWS
DIST_BIN_TARGETS = $(EXE_TARGET)$(EXE_EXT)
endif
ifdef ATI_BITS_64
LIB_SUFFIX=64
BITS=64
CMPILERBITS=64
else
LIB_SUFFIX=
BITS=
ifdef ATI_OS_WINDOWS
CMPILERBITS=
else
CMPILERBITS=32
endif
endif
ifdef ATI_OS_WINDOWS
LFLAGS += /subsystem:console
CORE_LIB=dll
LIB_PREFIX=
DYN_LIB_EXT=$(LIB_EXT)
UTIL_EXT=win
else
LIB_PREFIX=lib
CORE_LIB=so
DYN_LIB_EXT=$(DLL_EXT)
UTIL_EXT=
endif
LCXXDEFS += -DAMD_INTERNAL_BUILD
vpath %.cpp $(COMPONENT_DEPTH)
CPPFILES := $(notdir $(wildcard $(COMPONENT_DEPTH)/*.cpp))
TOOLS_TEST_COMMON=$(COMPONENT_DEPTH)/../common
vpath %.cpp $(TOOLS_TEST_COMMON)
CPPFILES += $(notdir $(wildcard $(TOOLS_TEST_COMMON)/*.cpp))
ifdef ATI_OS_LINUX
GCXXOPTS := $(filter-out -fno-rtti,$(GCXXOPTS))
GCXXOPTS := $(filter-out -fno-exceptions,$(GCXXOPTS))
LFLAGS += -L$(DIST_LIB_DEST) -lpthread $(LIBSTDCXX) -lm -ldl -lrt -lstdc++
#LFLAGS += -L$(DIST_LIB_DEST) -lpthread $(LIBSTDCXX) -lm -ldl -lrt
endif
SC_DIR_NAME ?= finalizer
export HT_DEPTH=$(OPENCL_DEPTH)/compiler/$(SC_DIR_NAME)/HSAIL/hsail-tools
include $(HT_DEPTH)/htlibs
#LCINCS := $(INCSWITCH) "$(OPENCL_DEPTH)/contrib/gtest-1.6.0/include"
LCINCS += $(INCSWITCH) "$(OPENCL_DEPTH)/runtime"
LCINCS += $(INCSWITCH) "$(OPENCL_DEPTH)/runtime/samples"
LCINCS += $(INCSWITCH) "$(OPENCL_DEPTH)/contrib/elftoolchain/libelf"
LCINCS += $(INCSWITCH) "$(OPENCL_DEPTH)/contrib/elftoolchain/common"
LCINCS += $(INCSWITCH) "$(OPENCL_DEPTH)/runtime/inc"
LCINCS += $(LIBHSAIL_INCS) $(LIBHSAIL_AMD_INCS)
LCINCS += $(INCSWITCH) "$(OPENCL_PATH)/compiler/lib/include"
LCINCS += $(INCSWITCH) "$(OPENCL_DEPTH)/runtime/samples/common"
UTIL_BUILD=build/$(OS_TYPE)/util/$(UTIL_EXT)/$(BUILD_DIR)
#LLLIBS += $(OPENCL_DEPTH)/runtime/core/$(UTIL_BUILD)/util$(UTIL_EXT)$(LIB_EXT)
LIBELF_DIR=build/$(OS_TYPE)/$(BUILD_DIR)
RUNTIME_BUILD=build/$(OS_TYPE)/$(CORE_LIB)/$(BUILD_DIR)
ifdef ATI_OS_LINUX
GCXXOPTS := $(filter-out -fno-exceptions,$(GCXXOPTS))
LFLAGS += -L$(DIST_LIB_DEST) -lpthread $(LIBSTDCXX) -lm -ldl -lrt
LFLAGS += -L$(OPENCL_DEPTH)/contrib/elftoolchain/libelf/$(LIBELF_DIR) -lelf
LFLAGS += -L$(OPENCL_DEPTH)/runtime/core/$(RUNTIME_BUILD) -lhsa-runtime$(LIB_SUFFIX)
LFLAGS += -L$(OPENCL_DEPTH)/runtime/tools/$(RUNTIME_BUILD) -lhsa-runtime-tools$(LIB_SUFFIX)
else
# Verify the extension of libelf is valid i.e. is not dll but instead is "lib"
#LLLIBS += -L$(OPENCL_DEPTH)/contrib/elftoolchain/libelf/$(LIBELF_DIR)/libelf
LLLIBS += $(OPENCL_DEPTH)/runtime/core/$(RUNTIME_BUILD)/hsa-runtime$(LIB_SUFFIX)$(LIB_EXT)
LLLIBS += $(OPENCL_DEPTH)/runtime/tools/$(RUNTIME_BUILD)/hsa-runtime-tools$(LIB_SUFFIX)$(LIB_EXT)
endif
LLLIBS += $(LIBHSAIL_USER_LIBS)
#
# Copy the Hsa ample to Hsa distribution folder
#
ifdef ATI_OS_LINUX
LOCAL_TARGETS = inst_sample_copy
endif
inst_sample_copy:
$(MKDIR) $(DIST_BIN_DEST)/../../samples/$(OS_TYPE)
-$(RM) -f $(DIST_BIN_DEST)/../../samples/$(OS_TYPE)/$(EXE_TARGET)
$(CP) $(BUILD_DIR)/$(EXE_TARGET) $(DIST_BIN_DEST)/../../samples/$(OS_TYPE)
include $(OPENCL_DEPTH)/hsarules
+81
Bestand weergeven
@@ -0,0 +1,81 @@
#include "get_info.h"
#include <iostream>
GetInfo::GetInfo() : HsaTest("HSA Info") {}
GetInfo::~GetInfo() {}
void GetInfo::Run() {
std::cout << std::endl;
std::cout << "Num CPUs in platform: " << cpus_.size() << std::endl;
std::cout << "------------------------------------------------\n";
for (size_t i = 0; i < cpus_.size(); ++i) {
hsa_agent_t cpu = cpus_[i];
std::cout << "CPU[" << i << "] properties:" << std::endl;
std::cout << "------------------------------------------------\n";
AgentProps prop(cpu);
PrintAgentInfo(prop);
std::cout << "------------------------------------------------\n";
hsa_amd_memory_pool_t global_fine = global_fine_[cpu.handle];
if (global_fine.handle != 0) {
std::cout << "CPU[" << i << "] system fine grain pool properties:\n";
std::cout << "------------------------------------------------\n";
PoolProps prop(global_fine);
PrintPoolInfo(prop);
std::cout << "------------------------------------------------\n";
}
hsa_amd_memory_pool_t global_coarse = global_coarse_[cpu.handle];
if (global_coarse.handle != 0) {
std::cout << "CPU[" << i << "] system coarse grain pool properties:\n";
std::cout << "------------------------------------------------\n";
PoolProps prop(global_coarse);
PrintPoolInfo(prop);
std::cout << "------------------------------------------------\n";
}
}
std::cout << std::endl;
std::cout << "Num GPUs in platform: " << gpus_.size() << std::endl;
std::cout << "------------------------------------------------\n";
for (size_t i = 0; i < gpus_.size(); ++i) {
hsa_agent_t gpu = gpus_[i];
std::cout << "GPU[" << i << "] properties:" << std::endl;
std::cout << "------------------------------------------------\n";
AgentProps prop(gpu);
PrintAgentInfo(prop);
std::cout << "------------------------------------------------\n";
hsa_amd_memory_pool_t global_coarse = global_coarse_[gpu.handle];
if (global_coarse.handle != 0) {
std::cout << "GPU[" << i << "] local memory pool properties:\n";
std::cout << "------------------------------------------------\n";
PoolProps prop(global_coarse);
PrintPoolInfo(prop);
std::cout << "------------------------------------------------\n";
}
hsa_amd_memory_pool_t group = group_[gpu.handle];
if (group.handle != 0) {
std::cout << "GPU[" << i << "] group memory pool properties:\n";
std::cout << "------------------------------------------------\n";
PoolProps prop(group);
PrintPoolInfo(prop);
std::cout << "------------------------------------------------\n";
}
}
}
int main(int argc, char* argv[]) {
GetInfo get_info;
get_info.Init();
get_info.Run();
get_info.Cleanup();
return 0;
}
+14
Bestand weergeven
@@ -0,0 +1,14 @@
#ifndef GET_INFO_H
#define GET_INFO_H
#include "common/hsa_test.h"
class GetInfo : public HsaTest {
public:
GetInfo();
~GetInfo();
void Run() override;
};
#endif // GET_INFO_H