Fergus Mac Roich posted:I happen to have a brand new OnePlus 3. I just plugged it in with "USB Debugging" enabled and it seemed to install the drivers just fine. I happen to be doing a fresh install of Android Studio as we speak so I'll update on what happens there with a default application. Appreciate the help, I eventually got it working. I had to manually point the device to the android USB driver within a whole bunch of sub menus on device manager. Sadly the emulator is much much better on Intel processors due to the HAXM technology, it's just about useless on my AMD desktop. Sorry for the detail due to my tech issues, I appreciate the help everyone.
|
|
# ? Sep 27, 2016 13:25 |
|
|
# ? Apr 26, 2024 10:36 |
Not sure if this belongs in the 3D tread. What are my options for debugging and benchmarking OpenCL in Java? (I'm using JoCL.) I have an OpenCL application I'm making with JoCL and I'm having a hard time figuring out why the hotspots are what they are. The Java Mission Control application says that my program is spending most of its time in java.lang.integer.equals. That seems completely wrong. I've not been able to use any of nVidia's tools to debug the OpenCL code (since it seems to expect a C++ program). I'm out of ideas for finding out the source of the problem. The GPU is _way_ faster for most tasks, but I think the copying to and from system memory is hurting. I just wouldn't have expected it to hurt _that much_. What are my options for debugging and benchmarking OpenCL in Java? My source code is here: https://github.com/josephcatrambone/aij The GPUGraph is the subject of the inquiry.
|
|
# ? Oct 4, 2016 19:24 |
|
Jo posted:I have an OpenCL application I'm making with JoCL and I'm having a hard time figuring out why the hotspots are what they are. The Java Mission Control application says that my program is spending most of its time in java.lang.integer.equals. That seems completely wrong. The screenshot says that almost all of that time being spent in equals because ArrayList.indexOf is calling equals a lot. That seems completely plausible if indexOf is being called a lot on big lists - every call to indexOf effectively iterates over the entire list to try and find the right element. If you expand the list of things that call indexOf (and keep expanding until you see something you recognize), does that clarify what's being slow?
|
# ? Oct 4, 2016 19:39 |
|
Try changing shapes from List to HashMap and see how that effects the performance. You call getShape() a lot in GPUGraph.java and that's O(N) each time. Sorry, I can't answer your real question, haven't had to debug C++ calls from Java and I'm not sure how to go about that either. You won't be able to attach to the java program, so you'll probably have to attach to the shared library. You may even have to get a debug build of the library and compile your java program against the debug library before it'll work.
|
# ? Oct 4, 2016 19:47 |
Jabor posted:The screenshot says that almost all of that time being spent in equals because ArrayList.indexOf is calling equals a lot. That seems completely plausible if indexOf is being called a lot on big lists - every call to indexOf effectively iterates over the entire list to try and find the right element. Zaphod42 posted:Try changing shapes from List to HashMap and see how that effects the performance. You call getShape() a lot in GPUGraph.java and that's O(N) each time. Isn't ArrayList O(1)? I get that a Linked List would be O(n), but an array list should be as fast as a direct memory seek. In either case, it's still hard for me to believe that the program is spending 50% of its time doing isEqual when the graph has only twelve nodes. Even with a non-memoized implementation that shouldn't be more than 144 calls to the method compared to 1000*1000 multiplications PER LOOP. Fake Edit: The doc says an array list access should be O(1). It's just doing an array lookup.
|
|
# ? Oct 4, 2016 21:17 |
|
Jo posted:Isn't ArrayList O(1)? I get that a Linked List would be O(n), but an array list should be as fast as a direct memory seek. ArrayList .get() is O(1), but ArrayList .contains() or .indexOf() is O(N) because you don't know which array index the item is kept in. It could be anywhere. If you sort the array you get better than O(N) time but its still sub O(1) by a longshot, and then you have to keep the list sorted. Only HashMap gets you O(1) lookup because the object's hashcode gives you the array index it would be located in. There's no way to know if an ArrayList contains something unless you scan the entire list.
|
# ? Oct 4, 2016 21:37 |
|
ArrayList's .get() is O(1), but .indexOf() is O(n) because you have to get each object and test its equality until you find the one you're looking for. If you look at the source code for ArrayList's indexOf you'll see that it just loops through elements until it finds one that equals: Here A HashMap like Zaphod42 was suggesting would probably be a better fit for your problem. efb.
|
# ? Oct 4, 2016 21:37 |
|
If you're willing to come up with a scheme where object A is only kept at index 0 and object B is always index 1 and so on, then you get O(1) from an ArrayList But then you're just turning it into a HashMap that is backed by an ArrayList. See the difference?
|
# ? Oct 4, 2016 21:39 |
|
Is there a standard recommendation for learning Spring (specifically Spring Boot)? Course or book or tutorial series, whatever. I'm no Java expert, if that helps.
|
# ? Oct 4, 2016 23:54 |
Zorro KingOfEngland posted:ArrayList's .get() is O(1), but .indexOf() is O(n) because you have to get each object and test its equality until you find the one you're looking for. Aha! Well I'll have to trace down where index of is being called. If get() is actually calling it, I'd call that a bug in the docs because it means the runtime isn't as advertised. I'll just switch to a standard array and resize it as I add elements to the graph. No need to use a hashmap. Edit: OpenJDK's source indicates it's constant time. I wonder where that indexOf is getting called. Maybe I'm going down the rabbit hole with this one. Even with a fuckload of linear seeks, there's no way that finding an item in a list of length 12 takes 50% of a five-minute run. I think it's just the case that Java mission control can't effectively profile stuff that's native. It's probably not counting the two-minute matrix multiply or 30-second opencl compile. Treats it as blocked io? Jo fucked around with this message at 00:43 on Oct 5, 2016 |
|
# ? Oct 5, 2016 00:35 |
|
Jo posted:Aha! Well I'll have to trace down where index of is being called. If get() is actually calling it, I'd call that a bug in the docs because it means the runtime isn't as advertised. I'll just switch to a standard array and resize it as I add elements to the graph. No need to use a hashmap. You don't need to wonder! You can literally just expand the nodes in that stack trace view to find out where it's being called!
|
# ? Oct 5, 2016 00:55 |
|
Zaphod42 posted:Try changing shapes from List to HashMap and see how that effects the performance. You call getShape() a lot in GPUGraph.java and that's O(N) each time. Jo posted:Aha! Well I'll have to trace down where index of is being called. If get() is actually calling it, I'd call that a bug in the docs because it means the runtime isn't as advertised. I'll just switch to a standard array and resize it as I add elements to the graph. No need to use a hashmap. I already told you. IndexOf is called in getShape(). code:
I guess that's not indexOf() in particular, although I wouldn't be surprised if contains() just returns indexof(o) == -1. For that matter, looking at your code, is shapes.contains(node) even what you want there? You put Dimension objects into the Shapes ArrayList. Contains(int) will always return null, wont it? Seems like you're trying to do contains(index) but that's not what the contains() method does. Contains is for passing an object that would be in the array, not an index. code:
Zaphod42 fucked around with this message at 01:37 on Oct 5, 2016 |
# ? Oct 5, 2016 01:23 |
|
The try-catch will probably be a bunch slower than a range check would be, if you expect to be out of range a lot. For the other issue, if nulls are the billion-dollar mistake, List.indexOf() and Map.get() taking Object instead of their parameterized type has got to be worth a couple hundred thousand.
|
# ? Oct 5, 2016 02:02 |
Zaphod42 posted:I already told you. IndexOf is called in getShape(). gently caress, I need to work on my reading comprehension. You're absolutely right. I don't actually need the check. The base-case is handled by the inputs in the case anyway. That changes the profile a good bit. Still think I need to profile the OpenCL component separately, since the performance on the GPU instance is markedly better for most tasks but incurs a high one-time overhead starting up. Thanks everyone for the help -- removing that O(n) check shaved a nice 10% off the CPU benchmarks I had. Jo fucked around with this message at 08:05 on Oct 5, 2016 |
|
# ? Oct 5, 2016 07:48 |
|
Hey guys, after 9 months off, I'm back to teaching myself Java (slowly). Look what I just tried: code:
code:
(6-member array because they are six-sided dice, and the cup can contain any number of dice) code:
|
# ? Oct 7, 2016 18:13 |
|
Squashy Nipples posted:Hey guys, after 9 months off, I'm back to teaching myself Java (slowly). Your variable is called temp, so temp[i]++; I'm curious what error you're getting from the compiler.
|
# ? Oct 7, 2016 18:16 |
|
When do you change the value of temp? And don't call variables "temp".
|
# ? Oct 7, 2016 18:17 |
|
LOL, that was stupid. Next time reread before reposting. Thanks guys.
|
# ? Oct 7, 2016 18:17 |
|
smackfu posted:When do you change the value of temp? Well, I'm used to have the function name available as a temp variable, so I didn't know what else to call something that only exists within the scope of the Method. But yeah, definitely not the best idea.
|
# ? Oct 7, 2016 18:19 |
|
carry on then posted:I'm curious what error you're getting from the compiler. OK, here is the code that does what I want: code:
code:
|
# ? Oct 7, 2016 21:17 |
|
Squashy Nipples posted:One last question: when you initialize an array like I did ( int[] results = new int[6]; ), do I get an array of zeros, or an array of NULLs? int is a primitive data type, not an Object, in Java. So ints cannot be null. There's an Object which wraps the int plain data type called Integer, which has methods and is an object so it can be null. ints default to 0 as a result, while Objects default to null. so int[] myArray = int[10]; creates 10 zeros. Integer[] myArray = Integer[10]; creates 10 null references. You can also set the values as you initialize, like int[] myArray = {0, 1, 2}; which will cause them to be initialized to what you set, instead of 0. Note that the difference between primitives and Objects in java can be somewhat confusing because of a handy syntactic feature called autoboxing. If you say Integer x = new Integer(5); int[] myArray = new int[10]; you can legally do myArray[2] = x; Even though Integer is an Object. Java will automatically "unbox" the plain data int from within the Integer, and place that in the array. You can also do the opposite, called "boxing" int x = 5; Integer[] myArray = new Integer[10]; myArray[5] = x; Hope that clears it all up! Primitives are a special case of the language and are pretty much the only things in Java that aren't Objects, as they are necessary fundamentals. Everything else is made of Objects which either contain Primitives or other Objects.
|
# ? Oct 7, 2016 21:25 |
|
A thorough explanation, thank you. I recall reading discussions of boxing/unboxing, but some aspects of it take a while to sink in.
|
# ? Oct 7, 2016 21:56 |
|
Yeah that's not pretty.
|
# ? Oct 7, 2016 22:02 |
Can anyone recommend a guide for a beginner to learn the Spring framework? My teacher has been showing us how to build very basic Java Web applications using NetBeans and now we have an assignment to make a Spring MVC application. I'm really getting overwhelmed. I tried using the NetBeans template for Spring MVC but it seems they use deprecated classes which their guide acknowledges but provides no recourse. I tried looking at some examples from the book Spring in Action 4th edition but it seems like they use a completely different build structure which I can't even open in NetBeans, and starting a NetBeans Spring project and then following the textbook ends up with all kinds of import errors. Overall I'm very confused as it seems to be totally different than the bare bones servlets we have made in class so far. I haven't even got a hello world example to run properly yet...
|
|
# ? Oct 7, 2016 22:34 |
|
Ornithology posted:Can anyone recommend a guide for a beginner to learn the Spring framework? https://github.com/kolorobot/spring-mvc-quickstart-archetype There's instructions there, first you will need to install the archetype and then create an instance of it. I'm wondering if "different build structure" means Maven and if so you're going to have to handle it sooner or later. It's essentially an IDE-agnostic build system with dependency management and from your import errors it sounds like you tried shoehorning the project code into a Netbeans project and so it's not doing any of the dependency management that it's supposed to. There should be a "import Maven POM project" option or something similar that you use. Also, IntelliJ is by far the best IDE in the Java world and you get a free copy as a student so you should do that too. Paul MaudDib fucked around with this message at 23:35 on Oct 7, 2016 |
# ? Oct 7, 2016 23:23 |
|
Getting the right versions and dependencies can be a big pain. Spring is a pretty big heavyweight library, and while its very good and popular, I've always preferred things that are more lightweight and easier to just use the bit you need. Using a bunch of existing code is nice because it gives you all this powerful stuff, but just getting the configuration right can take a lot of fiddling and is not at all fun. The solution as MuadDib said is probably to use Maven, which will require you to set it up and configure it, but then should automatically guarantee your spring application will build and launch properly.
|
# ? Oct 7, 2016 23:30 |
|
Paul MaudDib posted:Also, IntelliJ is by far the best IDE in the Java world and you get a free copy as a student so you should do that too.
|
# ? Oct 7, 2016 23:45 |
|
Trapick posted:For beginners (but not student, so would cost dollars), is the Ultimate edition significantly better than the Community edition? I used community all through college and never needed a feature that was ultimate-only.
|
# ? Oct 7, 2016 23:49 |
|
Trapick posted:For beginners (but not student, so would cost dollars), is the Ultimate edition significantly better than the Community edition? The Ultimate edition mostly adds web-dev related stuff, like JavaScript syntax highlighting (you can still use Community edition as a dumb text editor).
|
# ? Oct 8, 2016 00:39 |
|
I have a class named ImageData with subclasses SuccessData and FailureData. Can I produce two separate collections, one containing only the SuccessData objects, and the other containing only the FailureData objects, using Java 8 Streams in a single fluent expression?
|
# ? Oct 8, 2016 02:29 |
|
Yes kind of.code:
|
# ? Oct 8, 2016 02:47 |
Thanks for the suggestions regarding the Spring framework, guys. I've got Hello World working now at least but I've run into an issue with iterating over a collection in a jsp file. Any helps would be highly appreciated.. I'm sure it's a simple fix that I'm missing. edit: Fixed - code removed, I was missing taglib reference on the jsp page denzelcurrypower fucked around with this message at 07:03 on Oct 8, 2016 |
|
# ? Oct 8, 2016 06:49 |
|
Ornithology posted:Thanks for the suggestions regarding the Spring framework, guys. I've got Hello World working now at least but I've run into an issue with iterating over a collection in a jsp file. Any helps would be highly appreciated.. I'm sure it's a simple fix that I'm missing. Jsp files are...kind of poo poo. Look into thymeleaf for you templates.
|
# ? Oct 8, 2016 20:00 |
|
I spent a couple hours a few days ago trying to figure out why, no matter what I did, turning on Thymeleaf's caching didn't seem to do anything. It finally worked when I used reflection to get the field I needed, set it to be accessible, and set it myself. Then I discovered that turning off JRebel made it work fine. Thanks, JRebel.
|
# ? Oct 8, 2016 21:48 |
ToxicSlurpee posted:Jsp files are...kind of poo poo. Look into thymeleaf for you templates. Thanks for the suggestion. The curriculum in my school program seems pretty out of date so it's always good to know the better options that I should be learning!
|
|
# ? Oct 8, 2016 22:15 |
|
ToxicSlurpee posted:Jsp files are...kind of poo poo. Look into thymeleaf for you templates. Thymeleaf is awesome, however its documentation does leave something to be desired. Or maybe that's just because my brain has been poisoned by too many years of JSTL nonsense.
|
# ? Oct 9, 2016 01:00 |
|
At work I use jsp's a lot, simply because that was the only thing our cms supported back when they started working with it. Some new stuff uses freemarker, and for automated e-mails we use velocity templates. I have to say I find it kinda hard to see how one is better than the other, they all seem very similar to me.
|
# ? Oct 9, 2016 08:05 |
|
Ornithology posted:Thanks for the suggestion. The curriculum in my school program seems pretty out of date so it's always good to know the better options that I should be learning! School programs typically are, sadly. Don't sweat it too much; thymeleaf will eventually be old garbage nobody uses some day too. Jsp stuff is just old, showing its age, and has security issues. Xss problems are the big one. It's neat and not totally awful (it still gets a good amount of use) there are just better options.
|
# ? Oct 9, 2016 21:19 |
Such as not using java? I actually don't mean that to sound snarky. I'm really wondering: what are the benefits of using Java for web dev, when there are plenty of other stacks available that don't require you to muck around with IDEs or roll your own DAOs? Is the performance benefit that significant? Or is it all about scale, for maintainability of large codebases?
|
|
# ? Oct 9, 2016 22:02 |
|
|
# ? Apr 26, 2024 10:36 |
|
Performance, library support, maintainability, deployment simplicity are all reasons I use java even when I'm not being paid to.
|
# ? Oct 9, 2016 22:07 |