Skip to content
This repository has been archived by the owner on Mar 28, 2024. It is now read-only.

[BUG-233810] (W.i.p.) llStridedListStatistics #10846

Closed
sl-service-account opened this issue Apr 27, 2023 · 5 comments
Closed

[BUG-233810] (W.i.p.) llStridedListStatistics #10846

sl-service-account opened this issue Apr 27, 2023 · 5 comments

Comments

@sl-service-account
Copy link

How would you like the feature to work?

(W.I.P.)

Why is this feature important to you? How would it benefit the community?

(W.I.P.)

Original Jira Fields
Field Value
Issue BUG-233810
Summary (W.i.p.) llStridedListStatistics
Type New Feature Request
Priority Unset
Status Closed
Resolution Expected Behavior
Reporter Jabadahut50 (jabadahut50)
Assignee Shrike Linden (shrike.linden)
Created at 2023-04-27T00:18:03Z
Updated at 2023-05-10T18:05:30Z
{
  'Build Id': 'unset',
  'Business Unit': ['Platform'],
  'Date of First Response': '2023-04-27T20:33:37.402-0500',
  'How would you like the feature to work?': "AWS servers have support for 128 bit SIMD registers and Mono supports vector computing. It'd be nice to have functions in LSL to utilize this feature to provide dramatic speed up math in LSL processing.\r\n\r\nI propose the following LSL function.\r\n\r\nllSIMD (integer flag, float data1, float data2 ... float data8)\r\n\r\nperforms arithmetic using single input multiple data mathematics for fast calculation returning a float.\r\n\r\nflag - Set's the arithmetic function to perform\r\n      1 - Addition\r\n      2 - Subtraction\r\n      3 - Multiplication\r\n      4 - Division\r\nfloat data1- Initial data point to be operated against\r\nfloat data2 ... float data8 - data to be operated upon\r\n\r\nAdditional notes: \r\n- Integers can be substituted into data and will be implicitly cast to floats\r\n- empty data slots will be filled with 0's for addition and subtraction\r\n- empty data slots will be filled with 1's for multiplication and division",
  'ReOpened Count': 0.0,
  'Severity': 'Unset',
  'Target Viewer Version': 'viewer-development',
  'Why is this feature important to you? How would it benefit the community?': "SIMD is an important feature for speeding up modern code especially when you  don't have any access to multithreading such as the LSL coding environment.",
}
@sl-service-account
Copy link
Author

coffeedujour commented at 2023-04-28T01:33:37Z

Actual specific use cases ?

@sl-service-account
Copy link
Author

Jabadahut50 commented at 2023-04-28T08:22:33Z

Faster compression and decompression algorithms, faster physics calculations when your use case can't use or is better off not using sl's havok physics, faster bitwise flag checking and parsing, etc.

 

You could use it for all sorts of things where you need to use bulk math or logic.

@sl-service-account
Copy link
Author

JIRAUSER341305 commented at 2023-04-29T00:28:01Z

Bit late for April Fools, isn't it…?

Seriously, though.  The cost of passing the data in as a list (heap allocated array of heap allocated items), and lists are immutable, so passing a fresh list back out again with the results, is going to blow away any savings you'll get by using this function over just doing it the slow way, quite possibly by an order of magnitude…

It "could" work, maybe, if we had 8 global variables to load the data into (kind of like "registers", and it'd have to be a bank for each value type, so, 16 to support both floats and integers), and then the function takes just a single integer (maybe a second for the fan-out form, but I think I'd just use an unused register for that) containing the operand and other supporting state (like selecting which bank of "registers" to use, etc.).  And even then I have doubts.

Pretty sure you're not going to be doing any useful compression (with the about 20:1 expansion ratio of the data, and the lack of binary support in LSL — unless we got perhaps hex in a string as a third data type), or physics (the slow crawl of LSL compared to an actual compiled and optimised language not withstanding, we simply don't have access to that kind of raw instantaneous data to be of much use for physics — rough mathematical approximations are far more LSLs domain, and actually in reach).

That all said, a bulk math function modelled on SIMD and along the lines of llListStatistics, could indeed be handy.  I've considered similar in the past, but decided it was unlikely to be worth it.  Even in the list form, if it allowed any number of values in, and returned the appropriate number of results, probably two lists in and one list out (the second list holding just a single item in the fan-out form)…  It'd at least beat the pants off looping over a list…  (Be even more useful if we had destructuring.)  But in terms of speed benefits, you'd likely get better results hacking together a piece of Python to print out the LSL code to do the calculation you want, and then copy-paste that into your script.

So after all this, being as generous as I possibly can (because as I said, I've considered the idea myself in the past), I too still being it back to Coffee's response: Actual specific use cases ?

@sl-service-account
Copy link
Author

Jabadahut50 commented at 2023-04-29T15:24:18Z, updated at 2023-04-29T18:32:16Z

@Bleuhazenfurfle

I wasn't aware of lists immutability given they can be modified and appended to at the lsl level. I suppose I should have done a bit more research on exactly how LSL works under the hood before making a recommendation.

I could see the bank of "registers" thing working rather than trying to pull from a list given the immutability of Lists under the hood.

Quistess Alpha over in the forums brought up the idea of llStridedListStatistics that would allow any number of integers and floats in and letting the dev's implement SIMD under the hood for it rather than an explicit SIMD function. The initial implementation written above was naively based upon how other languages implement it but looking back now that was a dumb decision on my part as that just doesn't make sense with LSL given the constratints of the language. Destructuring would indeed be a very nice addition.

 

Personally I'm working on an ECS like system using LSL that would greatly benefit from mass math and logic speed ups (Yeah I know LSL isn't necessarily designed in a way where an ECS System would actually be fast even with faster math but I'm doing it mostly for the sheer interest of seeing if I can do it at all)

 

I'll rework the idea to take your and Quistess's reccomendations into account.

@sl-service-account
Copy link
Author

Shrike Linden commented at 2023-05-10T18:05:31Z

Hello, and thank you for your feature request.

Incoming suggestions are reviewed in the order they are received by a team of Lindens with diverse areas of expertise. We consider a number of factors: Is this change possible? Will it increase lag? Will it break existing content? Is it likely that the number of residents using this feature will justify the time to develop it? This wiki page further describes the reasoning we use: http://wiki.secondlife.com/wiki/Feature_Requests

This particular suggestion, unfortunately, cannot be tackled at this time. However, we regularly review previously deferred suggestions when circumstances change or resources become available.

We are grateful for the time you took to submit this feature request. We hope that you are not discouraged from submitting others in the future. Many excellent ideas to improve Second Life come from you, our residents. We can’t do it alone.

Thank you for your continued commitment to Second Life.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant