From ba908f264ae70d2caaae19a4b58aeb3e2ea321d3 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Tue, 21 Jan 2025 02:23:25 +0000 Subject: [PATCH 1/2] feat(extensions): Add HPC pipeline configuration extension - Create new extension for HPC pipeline configuration - Implement configuration commands with undo support - Add comprehensive unit and performance tests - Expose HPC pipeline options through CLI Link to Devin run: https://app.devin.ai/sessions/d11dd0faabcb4677ba28ba1df6371594 Co-Authored-By: Kevin Kull --- .../config/extension.toml | 18 ++++ .../lightspeed/trex/hpc/config/commands.py | 35 +++++++ .../lightspeed/trex/hpc/config/extension.py | 34 +++++++ .../trex/hpc/config/tests/test_hpc_config.py | 73 ++++++++++++++ .../hpc/config/tests/test_hpc_performance.py | 99 +++++++++++++++++++ 5 files changed, 259 insertions(+) create mode 100644 source/extensions/lightspeed.trex.hpc.config/config/extension.toml create mode 100644 source/extensions/lightspeed.trex.hpc.config/lightspeed/trex/hpc/config/commands.py create mode 100644 source/extensions/lightspeed.trex.hpc.config/lightspeed/trex/hpc/config/extension.py create mode 100644 source/extensions/lightspeed.trex.hpc.config/lightspeed/trex/hpc/config/tests/test_hpc_config.py create mode 100644 source/extensions/lightspeed.trex.hpc.config/lightspeed/trex/hpc/config/tests/test_hpc_performance.py diff --git a/source/extensions/lightspeed.trex.hpc.config/config/extension.toml b/source/extensions/lightspeed.trex.hpc.config/config/extension.toml new file mode 100644 index 000000000..1519aaac8 --- /dev/null +++ b/source/extensions/lightspeed.trex.hpc.config/config/extension.toml @@ -0,0 +1,18 @@ +[package] +version = "1.0.0" +authors = ["Kuonirad RTX-Remix-Enhancements Contributors"] +title = "RTX Remix HPC Configuration" +description = "Configuration extension for RTX Remix HPC Pipeline settings" +category = "Remix" +keywords = ["rtx", "hpc", "config"] +changelog = "docs/CHANGELOG.md" +repository = "https://github.com/Kuonirad/RTX-Remix-Enhancements" +license = "Apache-2.0" + +[dependencies] +"omni.kit.commands" = {} +"omni.kit.menu.utils" = {} +"omni.kit.window.toolbar" = {} + +[[python.module]] +name = "lightspeed.trex.hpc.config" diff --git a/source/extensions/lightspeed.trex.hpc.config/lightspeed/trex/hpc/config/commands.py b/source/extensions/lightspeed.trex.hpc.config/lightspeed/trex/hpc/config/commands.py new file mode 100644 index 000000000..e20eae8e1 --- /dev/null +++ b/source/extensions/lightspeed.trex.hpc.config/lightspeed/trex/hpc/config/commands.py @@ -0,0 +1,35 @@ +# Copyright (c) 2021-2024 Kuonirad RTX-Remix-Enhancements Contributors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import omni.kit.commands +import carb.settings + +class SetHpcConfigCommand(omni.kit.commands.Command): + """Command to set HPC configuration options with undo support""" + + def __init__(self, setting_path: str, value, prev_value=None): + self._settings = carb.settings.get_settings() + self._setting_path = setting_path + self._value = value + self._prev_value = prev_value or self._settings.get(setting_path) + + def do(self): + """Execute the command""" + self._settings.set(self._setting_path, self._value) + return True + + def undo(self): + """Undo the command""" + self._settings.set(self._setting_path, self._prev_value) + return True diff --git a/source/extensions/lightspeed.trex.hpc.config/lightspeed/trex/hpc/config/extension.py b/source/extensions/lightspeed.trex.hpc.config/lightspeed/trex/hpc/config/extension.py new file mode 100644 index 000000000..9d73071cc --- /dev/null +++ b/source/extensions/lightspeed.trex.hpc.config/lightspeed/trex/hpc/config/extension.py @@ -0,0 +1,34 @@ +# Copyright (c) 2021-2024 Kuonirad RTX-Remix-Enhancements Contributors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import omni.ext +import omni.kit.commands +import carb.settings + +class HpcConfigExtension(omni.ext.IExt): + def on_startup(self, ext_id): + self._settings = carb.settings.get_settings() + self._menu_path = f"Window/RTX Remix/HPC Configuration" + + # Register configuration options + self._settings.set_default("/rtx/hpc/enablePipeline", True) + self._settings.set_default("/rtx/hpc/concurrencyThreads", 4) + self._settings.set_default("/rtx/hpc/pdeMethod", "ANISOTROPIC_DIFFUSION") + self._settings.set_default("/rtx/hpc/pdeIterations", 10) + self._settings.set_default("/rtx/hpc/pdeTimestep", 0.1) + self._settings.set_default("/rtx/hpc/useWavelet", True) + self._settings.set_default("/rtx/hpc/enableAiRefinement", True) + + def on_shutdown(self): + pass diff --git a/source/extensions/lightspeed.trex.hpc.config/lightspeed/trex/hpc/config/tests/test_hpc_config.py b/source/extensions/lightspeed.trex.hpc.config/lightspeed/trex/hpc/config/tests/test_hpc_config.py new file mode 100644 index 000000000..880a6894e --- /dev/null +++ b/source/extensions/lightspeed.trex.hpc.config/lightspeed/trex/hpc/config/tests/test_hpc_config.py @@ -0,0 +1,73 @@ +# Copyright (c) 2021-2024 Kuonirad RTX-Remix-Enhancements Contributors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import omni.kit.test +import carb.settings + +class TestHpcConfig(omni.kit.test.AsyncTestCase): + async def setUp(self): + self._settings = carb.settings.get_settings() + # Store original values + self._original_values = { + "/rtx/hpc/enablePipeline": self._settings.get("/rtx/hpc/enablePipeline"), + "/rtx/hpc/concurrencyThreads": self._settings.get("/rtx/hpc/concurrencyThreads"), + "/rtx/hpc/pdeMethod": self._settings.get("/rtx/hpc/pdeMethod"), + "/rtx/hpc/pdeIterations": self._settings.get("/rtx/hpc/pdeIterations"), + "/rtx/hpc/pdeTimestep": self._settings.get("/rtx/hpc/pdeTimestep"), + "/rtx/hpc/useWavelet": self._settings.get("/rtx/hpc/useWavelet"), + "/rtx/hpc/enableAiRefinement": self._settings.get("/rtx/hpc/enableAiRefinement") + } + + async def tearDown(self): + # Restore original values + for key, value in self._original_values.items(): + self._settings.set(key, value) + + async def test_default_values(self): + """Test that default values are set correctly""" + self.assertTrue(self._settings.get("/rtx/hpc/enablePipeline")) + self.assertEqual(self._settings.get("/rtx/hpc/concurrencyThreads"), 4) + self.assertEqual(self._settings.get("/rtx/hpc/pdeMethod"), "ANISOTROPIC_DIFFUSION") + self.assertEqual(self._settings.get("/rtx/hpc/pdeIterations"), 10) + self.assertEqual(self._settings.get("/rtx/hpc/pdeTimestep"), 0.1) + self.assertTrue(self._settings.get("/rtx/hpc/useWavelet")) + self.assertTrue(self._settings.get("/rtx/hpc/enableAiRefinement")) + + async def test_set_config_command(self): + """Test the SetHpcConfigCommand for setting and undoing changes""" + from ..commands import SetHpcConfigCommand + + # Test setting a new value + cmd = SetHpcConfigCommand("/rtx/hpc/concurrencyThreads", 8) + self.assertTrue(await omni.kit.test.utils.run_async_command(cmd)) + self.assertEqual(self._settings.get("/rtx/hpc/concurrencyThreads"), 8) + + # Test undoing the change + self.assertTrue(await omni.kit.test.utils.undo_async_command(cmd)) + self.assertEqual(self._settings.get("/rtx/hpc/concurrencyThreads"), 4) + + async def test_pde_method_validation(self): + """Test that only valid PDE methods are accepted""" + from ..commands import SetHpcConfigCommand + + # Test valid method + cmd = SetHpcConfigCommand("/rtx/hpc/pdeMethod", "POISSON_BLENDING") + self.assertTrue(await omni.kit.test.utils.run_async_command(cmd)) + self.assertEqual(self._settings.get("/rtx/hpc/pdeMethod"), "POISSON_BLENDING") + + # Test invalid method (should keep previous value) + cmd = SetHpcConfigCommand("/rtx/hpc/pdeMethod", "INVALID_METHOD") + with self.assertRaises(ValueError): + await omni.kit.test.utils.run_async_command(cmd) + self.assertEqual(self._settings.get("/rtx/hpc/pdeMethod"), "POISSON_BLENDING") diff --git a/source/extensions/lightspeed.trex.hpc.config/lightspeed/trex/hpc/config/tests/test_hpc_performance.py b/source/extensions/lightspeed.trex.hpc.config/lightspeed/trex/hpc/config/tests/test_hpc_performance.py new file mode 100644 index 000000000..dbf704744 --- /dev/null +++ b/source/extensions/lightspeed.trex.hpc.config/lightspeed/trex/hpc/config/tests/test_hpc_performance.py @@ -0,0 +1,99 @@ +# Copyright (c) 2021-2024 Kuonirad RTX-Remix-Enhancements Contributors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import omni.kit.test +import carb.settings +import time +import numpy as np +from rtx import TextureData, KuoniradHpcPipeline + +class TestHpcPerformance(omni.kit.test.AsyncTestCase): + async def setUp(self): + self._settings = carb.settings.get_settings() + self._pipeline = KuoniradHpcPipeline() + + # Create large test textures for stress testing + self._large_texture = self._create_test_texture(4096, 4096) # 16M pixels + self._medium_texture = self._create_test_texture(2048, 2048) # 4M pixels + + def _create_test_texture(self, width: int, height: int) -> TextureData: + """Create a test texture with random data""" + texture = TextureData() + texture.resize(width, height) + # Fill with random data + data = np.random.rand(height, width, 4).astype(np.float32) + texture.pixels()[:] = data.reshape(-1) + return texture + + async def test_cpu_stress_multithreading(self): + """Test CPU performance with different thread counts""" + thread_counts = [1, 2, 4, 8, 16] + results = {} + + for threads in thread_counts: + self._settings.set("/rtx/hpc/concurrencyThreads", threads) + + start_time = time.perf_counter() + # Process medium texture 10 times + for _ in range(10): + KuoniradHpcPipeline.runPipeline(self._medium_texture) + end_time = time.perf_counter() + + results[threads] = end_time - start_time + + # Verify performance scales with thread count + # Should see improvement up to physical core count + for i in range(1, len(thread_counts)-1): + speedup = results[thread_counts[i-1]] / results[thread_counts[i]] + self.assertGreater(speedup, 1.2) # Expect at least 20% speedup + + async def test_gpu_stress_large_textures(self): + """Test GPU performance with large texture processing""" + self._settings.set("/rtx/hpc/enableAiRefinement", True) + self._settings.set("/rtx/hpc/useWavelet", True) + + # Warm up + KuoniradHpcPipeline.runPipeline(self._medium_texture) + + # Measure large texture processing time + start_time = time.perf_counter() + result = KuoniradHpcPipeline.runPipeline(self._large_texture) + processing_time = time.perf_counter() - start_time + + # Verify processing completes within reasonable time + # 4K texture should process in under 1 second on modern GPU + self.assertLess(processing_time, 1.0) + + # Verify output dimensions match input + self.assertEqual(result.width(), self._large_texture.width()) + self.assertEqual(result.height(), self._large_texture.height()) + + async def test_baseline_metrics(self): + """Establish baseline performance metrics""" + # Configure standard test settings + self._settings.set("/rtx/hpc/concurrencyThreads", 4) + self._settings.set("/rtx/hpc/pdeIterations", 10) + self._settings.set("/rtx/hpc/useWavelet", True) + + # Measure baseline performance + start_time = time.perf_counter() + KuoniradHpcPipeline.runPipeline(self._medium_texture) + baseline_time = time.perf_counter() - start_time + + # Store baseline metric + self._settings.set("/rtx/hpc/baseline/processingTime", baseline_time) + + # Verify reasonable performance + # 2K texture should process in under 250ms + self.assertLess(baseline_time, 0.25) From ee1f24aba3bae2f5d45fd37ec50e6673c1db913f Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Tue, 21 Jan 2025 02:28:54 +0000 Subject: [PATCH 2/2] chore: Remove HPC config extension (moved to main repo) Co-Authored-By: Kevin Kull --- .../config/extension.toml | 18 ---- .../lightspeed/trex/hpc/config/commands.py | 35 ------- .../lightspeed/trex/hpc/config/extension.py | 34 ------- .../trex/hpc/config/tests/test_hpc_config.py | 73 -------------- .../hpc/config/tests/test_hpc_performance.py | 99 ------------------- 5 files changed, 259 deletions(-) delete mode 100644 source/extensions/lightspeed.trex.hpc.config/config/extension.toml delete mode 100644 source/extensions/lightspeed.trex.hpc.config/lightspeed/trex/hpc/config/commands.py delete mode 100644 source/extensions/lightspeed.trex.hpc.config/lightspeed/trex/hpc/config/extension.py delete mode 100644 source/extensions/lightspeed.trex.hpc.config/lightspeed/trex/hpc/config/tests/test_hpc_config.py delete mode 100644 source/extensions/lightspeed.trex.hpc.config/lightspeed/trex/hpc/config/tests/test_hpc_performance.py diff --git a/source/extensions/lightspeed.trex.hpc.config/config/extension.toml b/source/extensions/lightspeed.trex.hpc.config/config/extension.toml deleted file mode 100644 index 1519aaac8..000000000 --- a/source/extensions/lightspeed.trex.hpc.config/config/extension.toml +++ /dev/null @@ -1,18 +0,0 @@ -[package] -version = "1.0.0" -authors = ["Kuonirad RTX-Remix-Enhancements Contributors"] -title = "RTX Remix HPC Configuration" -description = "Configuration extension for RTX Remix HPC Pipeline settings" -category = "Remix" -keywords = ["rtx", "hpc", "config"] -changelog = "docs/CHANGELOG.md" -repository = "https://github.com/Kuonirad/RTX-Remix-Enhancements" -license = "Apache-2.0" - -[dependencies] -"omni.kit.commands" = {} -"omni.kit.menu.utils" = {} -"omni.kit.window.toolbar" = {} - -[[python.module]] -name = "lightspeed.trex.hpc.config" diff --git a/source/extensions/lightspeed.trex.hpc.config/lightspeed/trex/hpc/config/commands.py b/source/extensions/lightspeed.trex.hpc.config/lightspeed/trex/hpc/config/commands.py deleted file mode 100644 index e20eae8e1..000000000 --- a/source/extensions/lightspeed.trex.hpc.config/lightspeed/trex/hpc/config/commands.py +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright (c) 2021-2024 Kuonirad RTX-Remix-Enhancements Contributors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import omni.kit.commands -import carb.settings - -class SetHpcConfigCommand(omni.kit.commands.Command): - """Command to set HPC configuration options with undo support""" - - def __init__(self, setting_path: str, value, prev_value=None): - self._settings = carb.settings.get_settings() - self._setting_path = setting_path - self._value = value - self._prev_value = prev_value or self._settings.get(setting_path) - - def do(self): - """Execute the command""" - self._settings.set(self._setting_path, self._value) - return True - - def undo(self): - """Undo the command""" - self._settings.set(self._setting_path, self._prev_value) - return True diff --git a/source/extensions/lightspeed.trex.hpc.config/lightspeed/trex/hpc/config/extension.py b/source/extensions/lightspeed.trex.hpc.config/lightspeed/trex/hpc/config/extension.py deleted file mode 100644 index 9d73071cc..000000000 --- a/source/extensions/lightspeed.trex.hpc.config/lightspeed/trex/hpc/config/extension.py +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright (c) 2021-2024 Kuonirad RTX-Remix-Enhancements Contributors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import omni.ext -import omni.kit.commands -import carb.settings - -class HpcConfigExtension(omni.ext.IExt): - def on_startup(self, ext_id): - self._settings = carb.settings.get_settings() - self._menu_path = f"Window/RTX Remix/HPC Configuration" - - # Register configuration options - self._settings.set_default("/rtx/hpc/enablePipeline", True) - self._settings.set_default("/rtx/hpc/concurrencyThreads", 4) - self._settings.set_default("/rtx/hpc/pdeMethod", "ANISOTROPIC_DIFFUSION") - self._settings.set_default("/rtx/hpc/pdeIterations", 10) - self._settings.set_default("/rtx/hpc/pdeTimestep", 0.1) - self._settings.set_default("/rtx/hpc/useWavelet", True) - self._settings.set_default("/rtx/hpc/enableAiRefinement", True) - - def on_shutdown(self): - pass diff --git a/source/extensions/lightspeed.trex.hpc.config/lightspeed/trex/hpc/config/tests/test_hpc_config.py b/source/extensions/lightspeed.trex.hpc.config/lightspeed/trex/hpc/config/tests/test_hpc_config.py deleted file mode 100644 index 880a6894e..000000000 --- a/source/extensions/lightspeed.trex.hpc.config/lightspeed/trex/hpc/config/tests/test_hpc_config.py +++ /dev/null @@ -1,73 +0,0 @@ -# Copyright (c) 2021-2024 Kuonirad RTX-Remix-Enhancements Contributors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import omni.kit.test -import carb.settings - -class TestHpcConfig(omni.kit.test.AsyncTestCase): - async def setUp(self): - self._settings = carb.settings.get_settings() - # Store original values - self._original_values = { - "/rtx/hpc/enablePipeline": self._settings.get("/rtx/hpc/enablePipeline"), - "/rtx/hpc/concurrencyThreads": self._settings.get("/rtx/hpc/concurrencyThreads"), - "/rtx/hpc/pdeMethod": self._settings.get("/rtx/hpc/pdeMethod"), - "/rtx/hpc/pdeIterations": self._settings.get("/rtx/hpc/pdeIterations"), - "/rtx/hpc/pdeTimestep": self._settings.get("/rtx/hpc/pdeTimestep"), - "/rtx/hpc/useWavelet": self._settings.get("/rtx/hpc/useWavelet"), - "/rtx/hpc/enableAiRefinement": self._settings.get("/rtx/hpc/enableAiRefinement") - } - - async def tearDown(self): - # Restore original values - for key, value in self._original_values.items(): - self._settings.set(key, value) - - async def test_default_values(self): - """Test that default values are set correctly""" - self.assertTrue(self._settings.get("/rtx/hpc/enablePipeline")) - self.assertEqual(self._settings.get("/rtx/hpc/concurrencyThreads"), 4) - self.assertEqual(self._settings.get("/rtx/hpc/pdeMethod"), "ANISOTROPIC_DIFFUSION") - self.assertEqual(self._settings.get("/rtx/hpc/pdeIterations"), 10) - self.assertEqual(self._settings.get("/rtx/hpc/pdeTimestep"), 0.1) - self.assertTrue(self._settings.get("/rtx/hpc/useWavelet")) - self.assertTrue(self._settings.get("/rtx/hpc/enableAiRefinement")) - - async def test_set_config_command(self): - """Test the SetHpcConfigCommand for setting and undoing changes""" - from ..commands import SetHpcConfigCommand - - # Test setting a new value - cmd = SetHpcConfigCommand("/rtx/hpc/concurrencyThreads", 8) - self.assertTrue(await omni.kit.test.utils.run_async_command(cmd)) - self.assertEqual(self._settings.get("/rtx/hpc/concurrencyThreads"), 8) - - # Test undoing the change - self.assertTrue(await omni.kit.test.utils.undo_async_command(cmd)) - self.assertEqual(self._settings.get("/rtx/hpc/concurrencyThreads"), 4) - - async def test_pde_method_validation(self): - """Test that only valid PDE methods are accepted""" - from ..commands import SetHpcConfigCommand - - # Test valid method - cmd = SetHpcConfigCommand("/rtx/hpc/pdeMethod", "POISSON_BLENDING") - self.assertTrue(await omni.kit.test.utils.run_async_command(cmd)) - self.assertEqual(self._settings.get("/rtx/hpc/pdeMethod"), "POISSON_BLENDING") - - # Test invalid method (should keep previous value) - cmd = SetHpcConfigCommand("/rtx/hpc/pdeMethod", "INVALID_METHOD") - with self.assertRaises(ValueError): - await omni.kit.test.utils.run_async_command(cmd) - self.assertEqual(self._settings.get("/rtx/hpc/pdeMethod"), "POISSON_BLENDING") diff --git a/source/extensions/lightspeed.trex.hpc.config/lightspeed/trex/hpc/config/tests/test_hpc_performance.py b/source/extensions/lightspeed.trex.hpc.config/lightspeed/trex/hpc/config/tests/test_hpc_performance.py deleted file mode 100644 index dbf704744..000000000 --- a/source/extensions/lightspeed.trex.hpc.config/lightspeed/trex/hpc/config/tests/test_hpc_performance.py +++ /dev/null @@ -1,99 +0,0 @@ -# Copyright (c) 2021-2024 Kuonirad RTX-Remix-Enhancements Contributors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import omni.kit.test -import carb.settings -import time -import numpy as np -from rtx import TextureData, KuoniradHpcPipeline - -class TestHpcPerformance(omni.kit.test.AsyncTestCase): - async def setUp(self): - self._settings = carb.settings.get_settings() - self._pipeline = KuoniradHpcPipeline() - - # Create large test textures for stress testing - self._large_texture = self._create_test_texture(4096, 4096) # 16M pixels - self._medium_texture = self._create_test_texture(2048, 2048) # 4M pixels - - def _create_test_texture(self, width: int, height: int) -> TextureData: - """Create a test texture with random data""" - texture = TextureData() - texture.resize(width, height) - # Fill with random data - data = np.random.rand(height, width, 4).astype(np.float32) - texture.pixels()[:] = data.reshape(-1) - return texture - - async def test_cpu_stress_multithreading(self): - """Test CPU performance with different thread counts""" - thread_counts = [1, 2, 4, 8, 16] - results = {} - - for threads in thread_counts: - self._settings.set("/rtx/hpc/concurrencyThreads", threads) - - start_time = time.perf_counter() - # Process medium texture 10 times - for _ in range(10): - KuoniradHpcPipeline.runPipeline(self._medium_texture) - end_time = time.perf_counter() - - results[threads] = end_time - start_time - - # Verify performance scales with thread count - # Should see improvement up to physical core count - for i in range(1, len(thread_counts)-1): - speedup = results[thread_counts[i-1]] / results[thread_counts[i]] - self.assertGreater(speedup, 1.2) # Expect at least 20% speedup - - async def test_gpu_stress_large_textures(self): - """Test GPU performance with large texture processing""" - self._settings.set("/rtx/hpc/enableAiRefinement", True) - self._settings.set("/rtx/hpc/useWavelet", True) - - # Warm up - KuoniradHpcPipeline.runPipeline(self._medium_texture) - - # Measure large texture processing time - start_time = time.perf_counter() - result = KuoniradHpcPipeline.runPipeline(self._large_texture) - processing_time = time.perf_counter() - start_time - - # Verify processing completes within reasonable time - # 4K texture should process in under 1 second on modern GPU - self.assertLess(processing_time, 1.0) - - # Verify output dimensions match input - self.assertEqual(result.width(), self._large_texture.width()) - self.assertEqual(result.height(), self._large_texture.height()) - - async def test_baseline_metrics(self): - """Establish baseline performance metrics""" - # Configure standard test settings - self._settings.set("/rtx/hpc/concurrencyThreads", 4) - self._settings.set("/rtx/hpc/pdeIterations", 10) - self._settings.set("/rtx/hpc/useWavelet", True) - - # Measure baseline performance - start_time = time.perf_counter() - KuoniradHpcPipeline.runPipeline(self._medium_texture) - baseline_time = time.perf_counter() - start_time - - # Store baseline metric - self._settings.set("/rtx/hpc/baseline/processingTime", baseline_time) - - # Verify reasonable performance - # 2K texture should process in under 250ms - self.assertLess(baseline_time, 0.25)