firqaaa commited on
Commit
c9f208f
·
verified ·
1 Parent(s): 8fa41b3

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +94 -23
index.html CHANGED
@@ -604,10 +604,58 @@
604
  document.getElementById('totalThreads').textContent = totalThreads;
605
  document.getElementById('spatialDims').textContent = `${gridX}×${gridY}×${gridZ}`;
606
 
 
 
 
 
 
 
 
 
 
 
607
  create3DCube();
608
- selectedBlock = null;
609
- selectedThread = null;
610
- updateBlockInfo();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
611
  }
612
 
613
  function create3DCube() {
@@ -704,8 +752,20 @@
704
  return;
705
  }
706
 
 
 
 
 
 
 
 
 
 
 
 
 
707
  const b = selectedBlock;
708
- const threadsPerBlock = b.dim.x * b.dim.y * b.dim.z;
709
  const warpSize = 32; // Standard warp size for modern GPUs
710
  const numWarps = Math.ceil(threadsPerBlock / warpSize);
711
 
@@ -718,10 +778,10 @@
718
  const directions = [
719
  { dx: -1, dy: 0, dz: 0, name: 'left' },
720
  { dx: 1, dy: 0, dz: 0, name: 'right' },
721
- { dx: 0, dy: -1, dz: 0, name: 'back' },
722
- { dx: 0, dy: 1, dz: 0, name: 'front' },
723
- { dx: 0, dy: 0, dz: -1, name: 'below' },
724
- { dx: 0, dy: 0, dz: 1, name: 'above' }
725
  ];
726
 
727
  directions.forEach(dir => {
@@ -742,7 +802,7 @@
742
 
743
  <div class="info-item">
744
  <div class="label">Block Dimensions</div>
745
- <div class="value">[${b.dim.x}, ${b.dim.y}, ${b.dim.z}] = ${threadsPerBlock} threads</div>
746
  </div>
747
 
748
  <div class="info-item">
@@ -787,9 +847,20 @@
787
 
788
  threadGrid.innerHTML = '';
789
 
790
- const b = selectedBlock;
 
 
 
 
 
 
 
 
 
 
 
791
  const maxThreadsToShow = 64; // Limit for visual clarity
792
- const totalThreads = b.dim.x * b.dim.y * b.dim.z;
793
 
794
  if (totalThreads > maxThreadsToShow) {
795
  threadGrid.innerHTML = `
@@ -801,31 +872,31 @@
801
  return;
802
  }
803
 
804
- threadGrid.style.gridTemplateColumns = `repeat(${Math.min(b.dim.x, 8)}, 1fr)`;
805
 
806
- // Create threads for visualization
807
- for (let z = 0; z < Math.min(b.dim.z, 4); z++) { // Show max 4 Z layers
808
- for (let y = 0; y < b.dim.y; y++) {
809
- for (let x = 0; x < b.dim.x; x++) {
810
  const thread = document.createElement('div');
811
  thread.className = 'thread-detail';
812
  thread.textContent = `${x},${y},${z}`;
813
- thread.title = `Thread [${x}, ${y}, ${z}] in Block [${b.idx.x}, ${b.idx.y}, ${b.idx.z}]`;
814
 
815
- // Calculate global position
816
- const globalX = b.dim.x * b.idx.x + x;
817
- const globalY = b.dim.y * b.idx.y + y;
818
- const globalZ = b.dim.z * b.idx.z + z;
819
 
820
  thread.addEventListener('click', () => {
821
  document.querySelectorAll('.thread-detail.selected').forEach(t => t.classList.remove('selected'));
822
  thread.classList.add('selected');
823
 
824
  selectedThread = {
825
- blockIdx: b.idx,
826
  threadIdx: { x, y, z },
827
  globalIdx: { x: globalX, y: globalY, z: globalZ },
828
- blockDim: b.dim
829
  };
830
 
831
  showThreadDetails();
 
604
  document.getElementById('totalThreads').textContent = totalThreads;
605
  document.getElementById('spatialDims').textContent = `${gridX}×${gridY}×${gridZ}`;
606
 
607
+ // Store the currently selected block position before rebuilding
608
+ let previousSelection = null;
609
+ if (selectedBlock) {
610
+ previousSelection = {
611
+ x: selectedBlock.idx.x,
612
+ y: selectedBlock.idx.y,
613
+ z: selectedBlock.idx.z
614
+ };
615
+ }
616
+
617
  create3DCube();
618
+
619
+ // If we had a block selected before, reselect it and update its dimensions
620
+ if (previousSelection &&
621
+ previousSelection.x < gridX &&
622
+ previousSelection.y < gridY &&
623
+ previousSelection.z < gridZ) {
624
+
625
+ // Update the selected block with new dimensions
626
+ selectedBlock = {
627
+ idx: {
628
+ x: previousSelection.x,
629
+ y: previousSelection.y,
630
+ z: previousSelection.z
631
+ },
632
+ dim: {
633
+ x: blockX,
634
+ y: blockY,
635
+ z: blockZ
636
+ }
637
+ };
638
+
639
+ // Find and reselect the corresponding visual block in the new cube
640
+ const blocks = document.querySelectorAll('.block-cube');
641
+ blocks.forEach(block => {
642
+ const label = block.querySelector('.block-label');
643
+ if (label && label.textContent === `[${previousSelection.x},${previousSelection.y},${previousSelection.z}]`) {
644
+ block.classList.add('selected');
645
+ }
646
+ });
647
+
648
+ // Clear any previous thread selection since dimensions changed
649
+ selectedThread = null;
650
+
651
+ // Update the info panel with new dimensions and thread grid
652
+ updateBlockInfo();
653
+ } else {
654
+ // Clear selection if the previously selected block no longer exists
655
+ selectedBlock = null;
656
+ selectedThread = null;
657
+ updateBlockInfo();
658
+ }
659
  }
660
 
661
  function create3DCube() {
 
752
  return;
753
  }
754
 
755
+ // Always get current dimensions from input controls, not from cached selectedBlock.dim
756
+ const currentBlockX = parseInt(document.getElementById('blockX').value);
757
+ const currentBlockY = parseInt(document.getElementById('blockY').value);
758
+ const currentBlockZ = parseInt(document.getElementById('blockZ').value);
759
+
760
+ // Update the selectedBlock dimensions to match current inputs
761
+ selectedBlock.dim = {
762
+ x: currentBlockX,
763
+ y: currentBlockY,
764
+ z: currentBlockZ
765
+ };
766
+
767
  const b = selectedBlock;
768
+ const threadsPerBlock = currentBlockX * currentBlockY * currentBlockZ;
769
  const warpSize = 32; // Standard warp size for modern GPUs
770
  const numWarps = Math.ceil(threadsPerBlock / warpSize);
771
 
 
778
  const directions = [
779
  { dx: -1, dy: 0, dz: 0, name: 'left' },
780
  { dx: 1, dy: 0, dz: 0, name: 'right' },
781
+ { dx: 0, dy: -1, dz: 0, name: 'top' },
782
+ { dx: 0, dy: 1, dz: 0, name: 'bottom' },
783
+ { dx: 0, dy: 0, dz: -1, name: 'front' },
784
+ { dx: 0, dy: 0, dz: 1, name: 'back' }
785
  ];
786
 
787
  directions.forEach(dir => {
 
802
 
803
  <div class="info-item">
804
  <div class="label">Block Dimensions</div>
805
+ <div class="value">[${currentBlockX}, ${currentBlockY}, ${currentBlockZ}] = ${threadsPerBlock} threads</div>
806
  </div>
807
 
808
  <div class="info-item">
 
847
 
848
  threadGrid.innerHTML = '';
849
 
850
+ // Get current dimensions directly from the input controls to ensure we use the latest values
851
+ const currentBlockX = parseInt(document.getElementById('blockX').value);
852
+ const currentBlockY = parseInt(document.getElementById('blockY').value);
853
+ const currentBlockZ = parseInt(document.getElementById('blockZ').value);
854
+
855
+ // Update the selected block dimensions to match current inputs
856
+ selectedBlock.dim = {
857
+ x: currentBlockX,
858
+ y: currentBlockY,
859
+ z: currentBlockZ
860
+ };
861
+
862
  const maxThreadsToShow = 64; // Limit for visual clarity
863
+ const totalThreads = currentBlockX * currentBlockY * currentBlockZ;
864
 
865
  if (totalThreads > maxThreadsToShow) {
866
  threadGrid.innerHTML = `
 
872
  return;
873
  }
874
 
875
+ threadGrid.style.gridTemplateColumns = `repeat(${Math.min(currentBlockX, 8)}, 1fr)`;
876
 
877
+ // Create threads using the current input dimensions
878
+ for (let z = 0; z < Math.min(currentBlockZ, 4); z++) { // Show max 4 Z layers
879
+ for (let y = 0; y < currentBlockY; y++) {
880
+ for (let x = 0; x < currentBlockX; x++) {
881
  const thread = document.createElement('div');
882
  thread.className = 'thread-detail';
883
  thread.textContent = `${x},${y},${z}`;
884
+ thread.title = `Thread [${x}, ${y}, ${z}] in Block [${selectedBlock.idx.x}, ${selectedBlock.idx.y}, ${selectedBlock.idx.z}]`;
885
 
886
+ // Calculate global position using current dimensions
887
+ const globalX = currentBlockX * selectedBlock.idx.x + x;
888
+ const globalY = currentBlockY * selectedBlock.idx.y + y;
889
+ const globalZ = currentBlockZ * selectedBlock.idx.z + z;
890
 
891
  thread.addEventListener('click', () => {
892
  document.querySelectorAll('.thread-detail.selected').forEach(t => t.classList.remove('selected'));
893
  thread.classList.add('selected');
894
 
895
  selectedThread = {
896
+ blockIdx: selectedBlock.idx,
897
  threadIdx: { x, y, z },
898
  globalIdx: { x: globalX, y: globalY, z: globalZ },
899
+ blockDim: { x: currentBlockX, y: currentBlockY, z: currentBlockZ }
900
  };
901
 
902
  showThreadDetails();