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