1 # Intellij and Clion
2
3 ----
4
5 * [Contents](hat-00.md)
6 * House Keeping
7 * [Project Layout](hat-01-01-project-layout.md)
8 * [Building Babylon](hat-01-02-building-babylon.md)
9 * [Building HAT](hat-01-03-building-hat.md)
10 * [Enabling the CUDA Backend](hat-01-05-building-hat-for-cuda.md)
11 * Programming Model
12 * [Programming Model](hat-03-programming-model.md)
13 * Interface Mapping
14 * [Interface Mapping Overview](hat-04-01-interface-mapping.md)
15 * [Cascade Interface Mapping](hat-04-02-cascade-interface-mapping.md)
16 * Implementation Detail
17 * [Walkthrough Of Accelerator.compute()](hat-accelerator-compute.md)
18 * [How we minimize buffer transfers](hat-minimizing-buffer-transfers.md)
19
20 ---
21
22 ## Intellij and Clion
23
24 We can use JetBrains' `IntelliJ` and `Clion` for dev work and
25 decided to leave some project artifacts in the repo.
26
27 Care must be taken with Intellij and Clion
28 as these tools do not play well together,
29 specifically we cannot have `Clion` and `Intellij`
30 project artifacts rooted under each other or in the same dir.
31
32 ### Intellij
33 The `intellij` subdir under the root HAT directory
34 contains the `.idea` project dir and the various `*.iml` files
35 for each of the various `modules`
36 (note the use of `Intellji`'s meaning of the word of module here)
37
38 As you will note the `intellij` dir is somewhat self contained. the various `*.iml`
39 files refer to the source dirs using relative paths.
40
41 I tend to add `Intellij` modules by hand. There are gotchas ;)
42
43 As with every intellij project, `.idea/modules.xml` 'points' to the iml files for each module (intellij's notion of module ;) )
44 ```xml
45 <!--
46 └──hat
47 └── intellij
48 └── .idea
49 └── modules.xml
50 -->
51 <modules>
52 <module fileurl="file://$PROJECT_DIR$/hat.iml" />
53 <module fileurl="file://$PROJECT_DIR$/backend_opencl.iml" />
54 <!-- yada yada -->
55 </modules>
56
57 ```
58
59 The various `.iml` files then have relative paths to their source/resource dirs roots.
60
61 ```xml
62 <module type="JAVA_MODULE" version="4">
63 <component name="NewModuleRootManager" inherit-compiler-output="true">
64 <exclude-output />
65 <content url="file://$MODULE_DIR$/../../../hat/src/java">
66 <sourceFolder url="file://$MODULE_DIR$/../../../hat/src/java" isTestSource="false" />
67 </content>
68 <orderEntry type="inheritedJdk" />
69 <orderEntry type="sourceFolder" forTests="false" />
70 <orderEntry type="module" module-name="hat" />
71 </component>
72 </module>
73
74 ```
75
76 Making run configurations available to other developers is probably `a bridge too far`
77
78 But with some careful XML tooling we can make it easier to add 'run configurations'.
79
80 ### How intellij stores run configurations
81
82 I also tend to hand hack run configurations so will leave this here for reference
83
84 ```xml
85 <component name="RunManager" selected="Application.MandelTest">
86 <configuration name="Mandel" type="Application"
87 factoryName="Application" temporary="true"
88 nameIsGenerated="true">
89 <option name="MAIN_CLASS_NAME" value="mandel.Mandel" />
90 <module name="mandel" />
91 <option name="VM_PARAMETERS" value="
92 --enable-preview
93 --add-exports=java.base/java.lang.foreign.mapper=ALL-UNNAMED
94 --patch-module=java.base=$PROJECT_DIR$/out/production/java_base_patch
95 -Djava.lang.foreign.mapper.debug=true" />
96 <extension name="coverage">
97 <pattern>
98 <option name="PATTERN" value="mandel.*" />
99 <option name="ENABLED" value="true" />
100 </pattern>
101 </extension>
102 <method v="2">
103 <option name="Make" enabled="true" />
104 </method>
105 </configuration>
106 <!-- more configs -->
107 </component>
108 ```
109
110 ### Clion
111
112 Thankfully Clion uses cmake, so we get to re-use the CMakeLists.txt in the various backends to build.
113
114 The intent is that these cmake artifacts can be run standalone (using cmake in the appropriate dir),
115 from within Clion and can be used by maven. So the CMakeLists.txt files have some extra variables to
116 help us use them in these three modes.
117
118
119
120