Skip to content

Commit

Permalink
Use gcc-10 in linux workflow
Browse files Browse the repository at this point in the history
Link with -ldl on linux
  • Loading branch information
kaizhangNV committed Feb 13, 2024
1 parent 40db068 commit 711016f
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 63 deletions.
13 changes: 12 additions & 1 deletion .github/workflows/linux-x86_64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,20 @@ on:
jobs:
build:

runs-on: ubuntu-latest
runs-on: ubuntu-20.04

steps:
- name: select gcc 10
run: |
sudo update-alternatives \
--install /usr/bin/gcc gcc /usr/bin/gcc-10 100 \
--slave /usr/bin/g++ g++ /usr/bin/g++-10 \
--slave /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-10 \
--slave /usr/bin/gcc-nm gcc-nm /usr/bin/gcc-nm-10 \
--slave /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-10 \
--slave /usr/bin/gcov gcov /usr/bin/gcov-10 \
--slave /usr/bin/gcov-dump gcov-dump /usr/bin/gcov-dump-10 \
--slave /usr/bin/gcov-tool gcov-tool /usr/bin/gcov-tool-10
- uses: actions/checkout@v3
- name: Install prerequisite
run: sudo apt-get install ninja-build
Expand Down
13 changes: 12 additions & 1 deletion .github/workflows/release-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,20 @@ on:
jobs:
build:

runs-on: ubuntu-latest
runs-on: ubuntu-20.04

steps:
- name: select gcc 10
run: |
sudo update-alternatives \
--install /usr/bin/gcc gcc /usr/bin/gcc-10 100 \
--slave /usr/bin/g++ g++ /usr/bin/g++-10 \
--slave /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-10 \
--slave /usr/bin/gcc-nm gcc-nm /usr/bin/gcc-nm-10 \
--slave /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-10 \
--slave /usr/bin/gcov gcov /usr/bin/gcov-10 \
--slave /usr/bin/gcov-dump gcov-dump /usr/bin/gcov-dump-10 \
--slave /usr/bin/gcov-tool gcov-tool /usr/bin/gcov-tool-10
- uses: actions/checkout@v3
- name: Install prerequisite
run: sudo apt-get install ninja-build
Expand Down
1 change: 1 addition & 0 deletions source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ target_link_libraries(falcor_perftest
PUBLIC
slang slang-gfx
external_includes
$<$<PLATFORM_ID:Linux>:dl>
)

set_target_properties(falcor_perftest PROPERTIES
Expand Down
123 changes: 63 additions & 60 deletions source/DeviceWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,69 +3,72 @@

Device::Device()
{
printf("slang: create global session\n");
slang::createGlobalSession(m_slangGlobalSession.writeRef());
m_pProgramManager = std::make_unique<ProgramManager>(this);

gfx::IDevice::Desc gfxDesc = {};
gfxDesc.deviceType = gfx::DeviceType::Vulkan;
gfxDesc.slang.slangGlobalSession = m_slangGlobalSession;
gfxDesc.shaderCache.maxEntryCount = 1000;
gfxDesc.shaderCache.shaderCachePath = nullptr;

std::vector<void*> extendedDescs;
// Add extended desc for root parameter attribute.
gfx::D3D12DeviceExtendedDesc extDesc = {};
extDesc.rootParameterShaderAttributeName = "root";
extendedDescs.push_back(&extDesc);

gfxDesc.extendedDescCount = extendedDescs.size();
gfxDesc.extendedDescs = extendedDescs.data();

gfx::AdapterList adapters = gfx::gfxGetAdapters(gfxDesc.deviceType);
if (adapters.getCount() == 0)
{
assert(!"No GPU found");
}

// Try to create device on specific GPU.
gfxDesc.adapterLUID = &adapters.getAdapters()[0].luid;

mpAPIDispatcher.reset(new PipelineCreationAPIDispatcher());
gfxDesc.apiCommandDispatcher = static_cast<ISlangUnknown*>(mpAPIDispatcher.get());

if (SLANG_FAILED(gfx::gfxCreateDevice(&gfxDesc, m_gfxDevice.writeRef())))
{
printf("Failed to create device on GPU 0 (%s).", adapters.getAdapters()[0].name);
}

if (SLANG_FAILED(gfx::gfxSetDebugCallback(&gGFXDebugCallBack)))
{
printf("Failed to setup debug callback\n");
}
else
{
gfx::gfxEnableDebugLayer();
}

// Otherwise try create device on any available GPU.
if (!m_gfxDevice)
{
gfxDesc.adapterLUID = nullptr;
if (SLANG_FAILED(gfx::gfxCreateDevice(&gfxDesc, m_gfxDevice.writeRef())))
assert(!"Failed to create device");
}

gfx::ITransientResourceHeap::Desc transientHeapDesc = {};
transientHeapDesc.flags = gfx::ITransientResourceHeap::Flags::AllowResizing;
transientHeapDesc.constantBufferSize = 16 * 1024 * 1024;
transientHeapDesc.samplerDescriptorCount = 2048;
transientHeapDesc.uavDescriptorCount = 1000000;
transientHeapDesc.srvDescriptorCount = 1000000;
transientHeapDesc.constantBufferDescriptorCount = 1000000;
transientHeapDesc.accelerationStructureDescriptorCount = 1000000;
if (SLANG_FAILED(m_gfxDevice->createTransientResourceHeap(transientHeapDesc, m_transientResourceHeaps.writeRef()))) {
assert(!"Fail to create transient source heaps");
}
// gfx::IDevice::Desc gfxDesc = {};
// gfxDesc.deviceType = gfx::DeviceType::Vulkan;
// gfxDesc.slang.slangGlobalSession = m_slangGlobalSession;
// gfxDesc.shaderCache.maxEntryCount = 1000;
// gfxDesc.shaderCache.shaderCachePath = nullptr;
//
// std::vector<void*> extendedDescs;
// // Add extended desc for root parameter attribute.
// gfx::D3D12DeviceExtendedDesc extDesc = {};
// extDesc.rootParameterShaderAttributeName = "root";
// extendedDescs.push_back(&extDesc);
//
// gfxDesc.extendedDescCount = extendedDescs.size();
// gfxDesc.extendedDescs = extendedDescs.data();
//
// printf("gfx:: get GPU adapters\n");
// gfx::AdapterList adapters = gfx::gfxGetAdapters(gfxDesc.deviceType);
// if (adapters.getCount() == 0)
// {
// assert(!"No GPU found");
// }
//
// // Try to create device on specific GPU.
// gfxDesc.adapterLUID = &adapters.getAdapters()[0].luid;
//
// mpAPIDispatcher.reset(new PipelineCreationAPIDispatcher());
// gfxDesc.apiCommandDispatcher = static_cast<ISlangUnknown*>(mpAPIDispatcher.get());
//
// printf("gfx create device\n");
// if (SLANG_FAILED(gfx::gfxCreateDevice(&gfxDesc, m_gfxDevice.writeRef())))
// {
// printf("Failed to create device on GPU 0 (%s).", adapters.getAdapters()[0].name);
// }
//
// if (SLANG_FAILED(gfx::gfxSetDebugCallback(&gGFXDebugCallBack)))
// {
// printf("Failed to setup debug callback\n");
// }
// else
// {
// gfx::gfxEnableDebugLayer();
// }
//
// // Otherwise try create device on any available GPU.
// if (!m_gfxDevice)
// {
// gfxDesc.adapterLUID = nullptr;
// if (SLANG_FAILED(gfx::gfxCreateDevice(&gfxDesc, m_gfxDevice.writeRef())))
// assert(!"Failed to create device");
// }
//
// gfx::ITransientResourceHeap::Desc transientHeapDesc = {};
// transientHeapDesc.flags = gfx::ITransientResourceHeap::Flags::AllowResizing;
// transientHeapDesc.constantBufferSize = 16 * 1024 * 1024;
// transientHeapDesc.samplerDescriptorCount = 2048;
// transientHeapDesc.uavDescriptorCount = 1000000;
// transientHeapDesc.srvDescriptorCount = 1000000;
// transientHeapDesc.constantBufferDescriptorCount = 1000000;
// transientHeapDesc.accelerationStructureDescriptorCount = 1000000;
// if (SLANG_FAILED(m_gfxDevice->createTransientResourceHeap(transientHeapDesc, m_transientResourceHeaps.writeRef()))) {
// assert(!"Fail to create transient source heaps");
// }
}

Device::~Device()
Expand Down
3 changes: 2 additions & 1 deletion source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,9 @@ void TestCase(ref<Device>& device)

int main(int argc, char* argv[])
{
printf("Starting creating device\n");
ref<Device> device = make_ref<Device>();
TestCase(device);
// TestCase(device);

return 0;
}

0 comments on commit 711016f

Please sign in to comment.