no message
This commit is contained in:
@@ -0,0 +1,146 @@
|
||||
package _VisualDVM.ProjectData.SapforData.Regions;
|
||||
import Common.Utils.CommonUtils;
|
||||
import _VisualDVM.Current;
|
||||
import Common.Database.Objects.DBObject;
|
||||
import Common.Utils.Index;
|
||||
import _VisualDVM.ProjectData.Files.DBProjectFile;
|
||||
import _VisualDVM.ProjectData.SapforData.Arrays.Distribution.AlignRule;
|
||||
import _VisualDVM.ProjectData.SapforData.Arrays.Distribution.DataDirective;
|
||||
import _VisualDVM.ProjectData.SapforData.Arrays.ProjectArray;
|
||||
import javafx.util.Pair;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Vector;
|
||||
public class ParallelRegion extends DBObject {
|
||||
public BigInteger regionId;
|
||||
//name in program
|
||||
public String originalName;
|
||||
// file -> <start, end> lines
|
||||
public LinkedHashMap<String, Vector<Pair<Integer, Integer>>> lines;
|
||||
//ключ - адрес. меняем
|
||||
public LinkedHashMap<BigInteger, ProjectArray> arrays;
|
||||
//for directive creating
|
||||
public DataDirective dataDirectives;
|
||||
public int maxdim = 0;
|
||||
public Vector<String> fragments = new Vector<>();
|
||||
public int lines_count = 0;
|
||||
public int loops_count = 0;
|
||||
public int arrays_count = 0;
|
||||
public int fd_count = 0;
|
||||
public int fc_count = 0;
|
||||
public ParallelRegion(String[] splited, Index idx) {
|
||||
// regionId = Long.parseLong(splited[idx.Inc()]);
|
||||
regionId = new BigInteger(splited[idx.Inc()]);
|
||||
originalName = splited[idx.Inc()];
|
||||
String[] localSplited = splited[idx.Inc()].split("\\|");
|
||||
int lines_size = Integer.parseInt(localSplited[0]);
|
||||
lines = new LinkedHashMap<>(lines_size);
|
||||
//распаковка Lines -----------------------------------------------
|
||||
//---------------------------------------------------------------
|
||||
for (int i = 0; i < lines_size; ++i) {
|
||||
String line_file = CommonUtils.toW(localSplited[1]);
|
||||
int line_list_size = Integer.parseInt(localSplited[2]);
|
||||
Vector<Pair<Integer, Integer>> current_lines = new Vector<>(line_list_size);
|
||||
for (int k = 0; k < line_list_size; ++k) {
|
||||
int first = Integer.parseInt(splited[idx.Inc()]);
|
||||
if (first == 0) first++;
|
||||
localSplited = splited[idx.Inc()].split("\\|");
|
||||
int second = Integer.parseInt((localSplited[0]));
|
||||
current_lines.add(new Pair<>(first, second));
|
||||
fragments.add(line_file + ": " + first + "-" + second);
|
||||
}
|
||||
lines.put(line_file, current_lines);
|
||||
}
|
||||
maxdim = 0;
|
||||
int arrays_size = Integer.parseInt(splited[idx.Inc()]);
|
||||
arrays = new LinkedHashMap<>(arrays_size);
|
||||
for (int i = 0; i < arrays_size; ++i) {
|
||||
//long array_address = Long.parseLong((splited[idx.Inc()]));
|
||||
BigInteger array_address = new BigInteger((splited[idx.Inc()]));
|
||||
ProjectArray new_array = new ProjectArray(splited, idx, array_address);
|
||||
arrays.put(array_address, new_array);
|
||||
//-------------------------------------------------------
|
||||
if (new_array.isTemplFlag == 1) {
|
||||
maxdim = Math.max(maxdim, new_array.dimSize);
|
||||
Current.getProject().templates.add(new_array);
|
||||
new_array.regIDs.add(regionId);
|
||||
} else if (new_array.isLoopArrayFlag != 1) arrays_count++;
|
||||
}
|
||||
int dataDirectives_alignRules_size = Integer.parseInt(splited[idx.Inc()]);
|
||||
dataDirectives = new DataDirective();
|
||||
dataDirectives.alignRules = new Vector<>(dataDirectives_alignRules_size);
|
||||
for (int i = 0; i < dataDirectives_alignRules_size; ++i)
|
||||
dataDirectives.alignRules.add(new AlignRule(splited, idx));
|
||||
for (int i = 0; i < dataDirectives.alignRules.size(); ++i)
|
||||
dataDirectives.alignRules.get(i).parent_region = this;
|
||||
//--------------------------------------------------------------
|
||||
lines_count = 0;
|
||||
loops_count = 0;
|
||||
fd_count = 0;
|
||||
fc_count = 0;
|
||||
for (String FKey : lines.keySet()) {
|
||||
for (Pair<Integer, Integer> L : lines.get(FKey)) {
|
||||
lines_count += (L.getValue() - L.getKey());
|
||||
DBProjectFile f = Current.getProject().db.files.Data.get(FKey);
|
||||
loops_count += f.FragmentLoopCount(L.getKey(), L.getValue());
|
||||
fc_count += f.FragmentFunctionCallsCount(L.getKey(), L.getValue());
|
||||
fd_count += f.FragmentFunctionDeclsCount(L.getKey(), L.getValue());
|
||||
}
|
||||
}
|
||||
//--------------------------------------------------
|
||||
}
|
||||
public boolean ArrayBelongsToRegion(long id) {
|
||||
return arrays.values().stream().anyMatch(array -> array.id == id);
|
||||
}
|
||||
public ProjectArray getArrayById(long id) {
|
||||
for (ProjectArray array : arrays.values()) {
|
||||
if (array.id == id) return array;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Область распараллеливания: " + originalName;
|
||||
}
|
||||
@Override
|
||||
public Object getPK() {
|
||||
return regionId;
|
||||
}
|
||||
public void UpdateLoopsCount() {
|
||||
loops_count = 0;
|
||||
for (String FKey : lines.keySet()) {
|
||||
for (Pair<Integer, Integer> L : lines.get(FKey)) {
|
||||
DBProjectFile f = Current.getProject().db.files.Data.get(FKey);
|
||||
loops_count += f.FragmentLoopCount(L.getKey(), L.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
public void UpdateFunctionsCount() {
|
||||
fd_count = 0;
|
||||
fc_count = 0;
|
||||
for (String FKey : lines.keySet()) {
|
||||
for (Pair<Integer, Integer> L : lines.get(FKey)) {
|
||||
DBProjectFile f = Current.getProject().db.files.Data.get(FKey);
|
||||
fc_count += f.FragmentFunctionCallsCount(L.getKey(), L.getValue());
|
||||
fd_count += f.FragmentFunctionDeclsCount(L.getKey(), L.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
public void UpdateArraysCount() {
|
||||
arrays_count=0;
|
||||
for (String FKey : lines.keySet()) {
|
||||
for (Pair<Integer, Integer> L : lines.get(FKey)) {
|
||||
DBProjectFile f = Current.getProject().db.files.Data.get(FKey);
|
||||
arrays_count += f.FragmentArraysCount(L.getKey(), L.getValue());
|
||||
}
|
||||
}
|
||||
/*
|
||||
if (new_array.isTemplFlag == 1) {
|
||||
maxdim = Math.max(maxdim, new_array.dimSize);
|
||||
Current.getProject().templates.put(new_array.address, new_array);
|
||||
new_array.regIDs.add(regionId);
|
||||
} else if (new_array.isLoopArrayFlag != 1) arrays_count++;
|
||||
*/
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package _VisualDVM.ProjectData.SapforData.Regions;
|
||||
import _VisualDVM.Current;
|
||||
import Common.Database.Tables.DataSet;
|
||||
import Common.Visual.DataSetControlForm;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
import static Common.Visual.Tables.TableRenderers.RendererMultiline;
|
||||
import static Common.Visual.Tables.TableRenderers.RendererTopLeft;
|
||||
public class RegionsSet extends DataSet<BigInteger, ParallelRegion> {
|
||||
//суррогат. нужен только для сохры столбцов. во всяком случае пока.
|
||||
public RegionsSet() {
|
||||
super(BigInteger.class, ParallelRegion.class);
|
||||
}
|
||||
@Override
|
||||
public Current CurrentName() {
|
||||
return Current.ParallelRegionInfo;
|
||||
}
|
||||
@Override
|
||||
public String getSingleDescription() {
|
||||
return "область распараллеливания";
|
||||
}
|
||||
@Override
|
||||
public String getPluralDescription() {
|
||||
return "области распараллеливания";
|
||||
}
|
||||
@Override
|
||||
protected DataSetControlForm createUI() {
|
||||
return new DataSetControlForm(this) {
|
||||
@Override
|
||||
protected void AdditionalInitColumns() {
|
||||
columns.get(0).setVisible(false);
|
||||
for (int i = 1; i < 7; ++i)
|
||||
columns.get(i).setRenderer(RendererTopLeft);
|
||||
columns.get(7).setRenderer(RendererMultiline);
|
||||
}
|
||||
};
|
||||
}
|
||||
@Override
|
||||
public Object getFieldAt(ParallelRegion object, int columnIndex) {
|
||||
switch (columnIndex) {
|
||||
case 1:
|
||||
return object.originalName;
|
||||
case 2:
|
||||
return object.lines_count;
|
||||
case 3:
|
||||
return object.arrays_count;
|
||||
case 4:
|
||||
return object.loops_count;
|
||||
case 5:
|
||||
return object.fd_count;
|
||||
case 6:
|
||||
return object.fc_count;
|
||||
case 7:
|
||||
return object.fragments;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public String[] getUIColumnNames() {
|
||||
return new String[]{"Имя", "Строк кода", "Массивов", "Циклов", "Объявлений процедур", "Вызовов процедур", "Фрагменты"};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package _VisualDVM.ProjectData.SapforData.Regions.UI;
|
||||
import _VisualDVM.Current;
|
||||
import Common.Visual.Tables.StyledCellLabel;
|
||||
import _VisualDVM.ProjectData.SapforData.Arrays.ProjectArray;
|
||||
import javafx.util.Pair;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ChangeListener;
|
||||
import java.util.LinkedHashMap;
|
||||
public class ArrayAlignmentBar extends JToolBar {
|
||||
public ProjectArray array;
|
||||
public LinkedHashMap<Integer, Pair<JSpinner, JSpinner>> dimensions = new LinkedHashMap<>();
|
||||
public ArrayAlignmentBar(ProjectArray array_in) {
|
||||
array = array_in;
|
||||
array.bar = this;
|
||||
array.init_new_ac(); //набор коефициентов.
|
||||
this.setFloatable(false);
|
||||
//-
|
||||
StyledCellLabel label = new StyledCellLabel();
|
||||
label.setOpaque(false);
|
||||
label.setText(array.GetShortNameWithDimLetters() + " → " + array.align_template.shortName + " [ ");
|
||||
add(label);
|
||||
//---
|
||||
int i = 0;
|
||||
for (int dim : array.ac_current.keySet()) {
|
||||
if (array.ac_current.get(dim).active) {
|
||||
//просто идут подряд. четные - K, нечетные B
|
||||
JSpinner K = new DimensionSpinner(array.ac_current.get(dim).K);
|
||||
JSpinner B = new DimensionSpinner(array.ac_current.get(dim).B);
|
||||
dimensions.put(dim, new Pair<>(K, B));
|
||||
add(K);
|
||||
label = new StyledCellLabel();
|
||||
label.setOpaque(false);
|
||||
label.setText(" * " + array.ac_current.get(dim).getLetter() + " + ");
|
||||
add(label);
|
||||
add(B);
|
||||
label = new StyledCellLabel();
|
||||
label.setOpaque(false);
|
||||
label.setText((i < array.ac_current.keySet().size() - 1) ? " , " : " ]");
|
||||
add(label);
|
||||
ChangeListener changeListener = e -> {
|
||||
//инфа о связях. из списка всех объявленных массивов.
|
||||
ProjectArray d_array = Current.getProject().declaratedArrays.get(array.id);
|
||||
//опять же, берем инфу из объявлений!
|
||||
for (ProjectArray d_link : d_array.links.values()) {
|
||||
//это массивы из объявлений. прежде чем их трогать проверим а есть ли они в текущей области.
|
||||
// по адресам принадлежность смотреть нельзя.
|
||||
// на момент поиска массивов у них их еще нет. а вот ид совпадают.
|
||||
if (Current.getParallelRegion().ArrayBelongsToRegion(d_link.id)) {
|
||||
//инфа о массиве уже из области. имеющая адрес и бар.
|
||||
ProjectArray r_link = Current.getParallelRegion().getArrayById(d_link.id);
|
||||
Pair<JSpinner, JSpinner> pair = r_link.bar.dimensions.get(dim);
|
||||
pair.getKey().setValue(K.getValue());
|
||||
pair.getValue().setValue(B.getValue());
|
||||
}
|
||||
}
|
||||
};
|
||||
K.addChangeListener(changeListener);
|
||||
B.addChangeListener(changeListener);
|
||||
}
|
||||
++i;
|
||||
}
|
||||
}
|
||||
public void apply_changes() {
|
||||
for (int dim : dimensions.keySet()) {
|
||||
array.ac_new.get(dim).K = (int) dimensions.get(dim).getKey().getValue();
|
||||
array.ac_new.get(dim).B = (int) dimensions.get(dim).getValue().getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package _VisualDVM.ProjectData.SapforData.Regions.UI;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
public class DimensionSpinner extends JSpinner {
|
||||
public DimensionSpinner(int value_in) {
|
||||
java.awt.Dimension p = new Dimension(40, 26);
|
||||
setMinimumSize(p);
|
||||
setMaximumSize(p);
|
||||
setPreferredSize(p);
|
||||
setModel(new SpinnerNumberModel(
|
||||
value_in,
|
||||
-65535, 65535, 1));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="_VisualDVM.ProjectData.SapforData.Regions.UI.ParallelRegionFields">
|
||||
<grid id="27dc6" binding="Content" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="500" height="400"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
</form>
|
||||
@@ -0,0 +1,13 @@
|
||||
package _VisualDVM.ProjectData.SapforData.Regions.UI;
|
||||
import Common.Visual.Windows.Dialog.DialogFields;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
public class ParallelRegionFields implements DialogFields {
|
||||
public JPanel Content;
|
||||
// public JToolBar arraysBar;
|
||||
@Override
|
||||
public Component getContent() {
|
||||
return Content;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user